@needle-tools/engine 4.11.0-next.8bfb2f5 → 4.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/components.needle.json +1 -1
  3. package/dist/{gltf-progressive-CXVECA3a.js → gltf-progressive-BvlZQAkt.js} +3 -3
  4. package/dist/{gltf-progressive-D4Z_Khp3.min.js → gltf-progressive-CftVUJy3.min.js} +1 -1
  5. package/dist/{gltf-progressive-CHeORqEv.umd.cjs → gltf-progressive-GwdQV1Qx.umd.cjs} +1 -1
  6. package/dist/{needle-engine.bundle-lul9TfB2.js → needle-engine.bundle-Dh4X0Qy5.js} +6264 -6202
  7. package/dist/{needle-engine.bundle-8EmDJd2O.umd.cjs → needle-engine.bundle-DhRclTK5.umd.cjs} +142 -142
  8. package/dist/{needle-engine.bundle-DtF-fcok.min.js → needle-engine.bundle-IPerDSpg.min.js} +144 -144
  9. package/dist/needle-engine.d.ts +6 -0
  10. package/dist/needle-engine.js +4 -4
  11. package/dist/needle-engine.min.js +1 -1
  12. package/dist/needle-engine.umd.cjs +1 -1
  13. package/dist/{postprocessing-DQ2pynXW.js → postprocessing-CJC0Npcd.js} +2 -2
  14. package/dist/{postprocessing-BsnRNRRS.umd.cjs → postprocessing-DrM4PWU3.umd.cjs} +1 -1
  15. package/dist/{postprocessing-BHMVuZQ1.min.js → postprocessing-l7zsdO_Q.min.js} +1 -1
  16. package/dist/{three-qw28ZtTy.min.js → three-BDW9I486.min.js} +13 -13
  17. package/dist/{three-CJSAehtG.js → three-MHVqtJYj.js} +1 -0
  18. package/dist/{three-examples-Doq0rvFU.js → three-examples-C5Ht-QFN.js} +1 -1
  19. package/dist/{three-examples-Deqc1bNw.umd.cjs → three-examples-CgwGHSgz.umd.cjs} +1 -1
  20. package/dist/{three-examples-BivkhnvN.min.js → three-examples-fvEPSC8L.min.js} +1 -1
  21. package/dist/{three-B-jwTHao.umd.cjs → three-iFaDq9U3.umd.cjs} +13 -13
  22. package/dist/{three-mesh-ui-CktOi6oI.js → three-mesh-ui-BjWTTk1R.js} +1 -1
  23. package/dist/{three-mesh-ui-CsHwj9cJ.umd.cjs → three-mesh-ui-Bm32sS2a.umd.cjs} +1 -1
  24. package/dist/{three-mesh-ui-DhYXcXZe.min.js → three-mesh-ui-CLdkp21K.min.js} +1 -1
  25. package/dist/{vendor-BcsPRUmt.umd.cjs → vendor-CAWj5cBK.umd.cjs} +2 -2
  26. package/dist/{vendor-CyfN5nor.js → vendor-DJBpoQcM.js} +608 -599
  27. package/dist/{vendor-DyavoogU.min.js → vendor-DWGd3dEf.min.js} +20 -20
  28. package/lib/engine/js-extensions/Object3D.d.ts +6 -0
  29. package/lib/engine/js-extensions/Object3D.js +15 -0
  30. package/lib/engine/js-extensions/Object3D.js.map +1 -1
  31. package/lib/engine-components/Collider.d.ts +26 -0
  32. package/lib/engine-components/Collider.js +26 -0
  33. package/lib/engine-components/Collider.js.map +1 -1
  34. package/lib/engine-components/ContactShadows.d.ts +11 -2
  35. package/lib/engine-components/ContactShadows.js +11 -2
  36. package/lib/engine-components/ContactShadows.js.map +1 -1
  37. package/lib/engine-components/DropListener.d.ts +3 -0
  38. package/lib/engine-components/DropListener.js +44 -21
  39. package/lib/engine-components/DropListener.js.map +1 -1
  40. package/lib/engine-components/Duplicatable.d.ts +2 -2
  41. package/lib/engine-components/Duplicatable.js +2 -2
  42. package/lib/engine-components/EventList.d.ts +18 -1
  43. package/lib/engine-components/EventList.js +18 -1
  44. package/lib/engine-components/EventList.js.map +1 -1
  45. package/lib/engine-components/GroundProjection.d.ts +3 -0
  46. package/lib/engine-components/GroundProjection.js +3 -0
  47. package/lib/engine-components/GroundProjection.js.map +1 -1
  48. package/lib/engine-components/Interactable.d.ts +4 -0
  49. package/lib/engine-components/Interactable.js +4 -0
  50. package/lib/engine-components/Interactable.js.map +1 -1
  51. package/lib/engine-components/OrbitControls.d.ts +4 -2
  52. package/lib/engine-components/OrbitControls.js +31 -3
  53. package/lib/engine-components/OrbitControls.js.map +1 -1
  54. package/lib/engine-components/RigidBody.d.ts +5 -0
  55. package/lib/engine-components/RigidBody.js +5 -0
  56. package/lib/engine-components/RigidBody.js.map +1 -1
  57. package/lib/engine-components/SeeThrough.js +20 -0
  58. package/lib/engine-components/SeeThrough.js.map +1 -1
  59. package/lib/engine-components/export/usdz/ThreeUSDZExporter.d.ts +4 -2
  60. package/lib/engine-components/export/usdz/ThreeUSDZExporter.js +69 -14
  61. package/lib/engine-components/export/usdz/ThreeUSDZExporter.js.map +1 -1
  62. package/lib/engine-components/ui/Text.js +6 -1
  63. package/lib/engine-components/ui/Text.js.map +1 -1
  64. package/lib/engine-components/utils/LookAt.d.ts +3 -0
  65. package/lib/engine-components/utils/LookAt.js +3 -0
  66. package/lib/engine-components/utils/LookAt.js.map +1 -1
  67. package/lib/engine-components/utils/OpenURL.d.ts +2 -1
  68. package/lib/engine-components/utils/OpenURL.js +2 -1
  69. package/lib/engine-components/utils/OpenURL.js.map +1 -1
  70. package/lib/engine-components/web/ScrollFollow.js +1 -2
  71. package/lib/engine-components/web/ScrollFollow.js.map +1 -1
  72. package/lib/engine-components/webxr/WebARCameraBackground.d.ts +2 -0
  73. package/lib/engine-components/webxr/WebARCameraBackground.js +2 -0
  74. package/lib/engine-components/webxr/WebARCameraBackground.js.map +1 -1
  75. package/lib/engine-components/webxr/WebARSessionRoot.d.ts +1 -1
  76. package/lib/engine-components/webxr/WebARSessionRoot.js +1 -1
  77. package/lib/engine-components/webxr/WebXR.d.ts +2 -0
  78. package/lib/engine-components/webxr/WebXR.js +2 -0
  79. package/lib/engine-components/webxr/WebXR.js.map +1 -1
  80. package/lib/engine-components/webxr/WebXRImageTracking.d.ts +29 -0
  81. package/lib/engine-components/webxr/WebXRImageTracking.js +29 -0
  82. package/lib/engine-components/webxr/WebXRImageTracking.js.map +1 -1
  83. package/package.json +3 -3
  84. package/plugins/vite/index.js +4 -1
  85. package/plugins/vite/needle-app.js +103 -57
  86. package/src/engine/js-extensions/Object3D.ts +24 -0
  87. package/src/engine-components/Collider.ts +27 -1
  88. package/src/engine-components/ContactShadows.ts +12 -4
  89. package/src/engine-components/DropListener.ts +45 -24
  90. package/src/engine-components/Duplicatable.ts +2 -2
  91. package/src/engine-components/EventList.ts +18 -1
  92. package/src/engine-components/GroundProjection.ts +4 -1
  93. package/src/engine-components/Interactable.ts +4 -1
  94. package/src/engine-components/OrbitControls.ts +27 -3
  95. package/src/engine-components/RigidBody.ts +6 -1
  96. package/src/engine-components/SeeThrough.ts +42 -2
  97. package/src/engine-components/export/usdz/ThreeUSDZExporter.ts +117 -17
  98. package/src/engine-components/ui/Text.ts +11 -2
  99. package/src/engine-components/utils/LookAt.ts +3 -0
  100. package/src/engine-components/utils/OpenURL.ts +3 -2
  101. package/src/engine-components/web/ScrollFollow.ts +1 -1
  102. package/src/engine-components/webxr/WebARCameraBackground.ts +2 -0
  103. package/src/engine-components/webxr/WebARSessionRoot.ts +1 -1
  104. package/src/engine-components/webxr/WebXR.ts +2 -0
  105. package/src/engine-components/webxr/WebXRImageTracking.ts +30 -3
@@ -2,11 +2,11 @@
2
2
  * @license
3
3
  * Copyright 2010-2024 Three.js Authors
4
4
  * SPDX-License-Identifier: MIT
5
- */const Ks="169",G_={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},H_={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},W_=0,sf=1,X_=2,tA=3,nA=0,Lf=1,Df=2,oi=3,fs=0,ln=1,Ji=2,Fi=0,Ps=1,cc=2,rf=3,of=4,Uf=5,Zs=100,q_=101,$_=102,Y_=103,Ff=104,Z_=200,J_=201,K_=202,j_=203,Ou=204,Vu=205,Q_=206,ey=207,ty=208,ny=209,iy=210,sy=211,ry=212,oy=213,ay=214,lc=0,uc=1,hc=2,nr=3,dc=4,pc=5,fc=6,mc=7,fa=0,Of=1,Vf=2,Ti=0,Ah=1,Nh=2,Bf=3,Eh=4,cy=5,Ch=6,Rh=7,af="attached",ly="detached",Ih=300,wi=301,Vi=302,ir=303,sr=304,hr=306,rr=1e3,Si=1001,ea=1002,Qt=1003,Ph=1004,iA=1004,Cs=1005,sA=1005,Ut=1006,js=1007,rA=1007,Jn=1008,uy=1008,es=1009,zf=1010,kf=1011,ta=1012,ma=1013,Bi=1014,Gn=1015,Ln=1016,Lh=1017,Dh=1018,or=1020,Uh=35902,Fh=35899,Gf=1021,Oh=1022,Rn=1023,Hf=1024,Wf=1025,Qs=1026,ar=1027,Hc=1028,Wc=1029,na=1030,Vh=1031,oA=1032,Bh=1033,$o=33776,Yo=33777,Zo=33778,Jo=33779,gc=35840,Bu=35841,xc=35842,zu=35843,_c=36196,yc=37492,vc=37496,Mc=37808,ku=37809,Gu=37810,Hu=37811,Sc=37812,Wu=37813,Xu=37814,qu=37815,$u=37816,Yu=37817,Zu=37818,Ju=37819,Ku=37820,ju=37821,Ko=36492,Qu=36494,Tc=36495,Xf=36283,eh=36284,th=36285,nh=36286,qf=2200,$f=2201,hy=2202,ia=2300,bc=2301,Eu=2302,Br=2400,zr=2401,wc=2402,zh=2500,Yf=2501,dy=0,py=1,fy=2,Zf=3200,Jf=3201,aA=3202,cA=3203,ms=0,Kf=1,Li="",kn="srgb",li="srgb-linear",kh="display-p3",Xc="display-p3-linear",Ac="linear",Vt="srgb",Nc="rec709",Ec="p3",my=0,$s=7680,gy=7681,xy=7682,_y=7683,yy=34055,vy=34056,My=5386,Sy=512,Ty=513,by=514,wy=515,Ay=516,Ny=517,Ey=518,ih=519,Cy=512,jf=513,Ry=514,Qf=515,Iy=516,Py=517,Ly=518,Dy=519,sa=35044,kr=35048,lA=35040,uA=35045,hA=35049,dA=35041,pA=35046,fA=35050,mA=35042,gA="100",sh="300 es",Di=2e3,jr=2001;class Ai{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const r=i.indexOf(t);r!==-1&&i.splice(r,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const n=this._listeners[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let r=0,o=i.length;r<o;r++)i[r].call(this,e);e.target=null}}}const Vn=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let _0=1234567;const qr=Math.PI/180,ra=180/Math.PI;function bi(){const s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Vn[s&255]+Vn[s>>8&255]+Vn[s>>16&255]+Vn[s>>24&255]+"-"+Vn[e&255]+Vn[e>>8&255]+"-"+Vn[e>>16&15|64]+Vn[e>>24&255]+"-"+Vn[t&63|128]+Vn[t>>8&255]+"-"+Vn[t>>16&255]+Vn[t>>24&255]+Vn[n&255]+Vn[n>>8&255]+Vn[n>>16&255]+Vn[n>>24&255]).toLowerCase()}function jt(s,e,t){return Math.max(e,Math.min(t,s))}function em(s,e){return(s%e+e)%e}function xA(s,e,t,n,i){return n+(s-e)*(i-n)/(t-e)}function _A(s,e,t){return s!==e?(t-s)/(e-s):0}function Ka(s,e,t){return(1-t)*s+t*e}function yA(s,e,t,n){return Ka(s,e,1-Math.exp(-t*n))}function vA(s,e=1){return e-Math.abs(em(s,e*2)-e)}function MA(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*(3-2*s))}function SA(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*s*(s*(s*6-15)+10))}function TA(s,e){return s+Math.floor(Math.random()*(e-s+1))}function bA(s,e){return s+Math.random()*(e-s)}function wA(s){return s*(.5-Math.random())}function AA(s){s!==void 0&&(_0=s);let e=_0+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function NA(s){return s*qr}function EA(s){return s*ra}function CA(s){return(s&s-1)===0&&s!==0}function RA(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function IA(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function PA(s,e,t,n,i){const r=Math.cos,o=Math.sin,a=r(t/2),c=o(t/2),l=r((e+n)/2),u=o((e+n)/2),h=r((e-n)/2),d=o((e-n)/2),p=r((n-e)/2),f=o((n-e)/2);switch(i){case"XYX":s.set(a*u,c*h,c*d,a*l);break;case"YZY":s.set(c*d,a*u,c*h,a*l);break;case"ZXZ":s.set(c*h,c*d,a*u,a*l);break;case"XZX":s.set(a*u,c*f,c*p,a*l);break;case"YXY":s.set(c*p,a*u,c*f,a*l);break;case"ZYZ":s.set(c*f,c*p,a*u,a*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Yn(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("Invalid component type.")}}function ut(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("Invalid component type.")}}const Gh={DEG2RAD:qr,RAD2DEG:ra,generateUUID:bi,clamp:jt,euclideanModulo:em,mapLinear:xA,inverseLerp:_A,lerp:Ka,damp:yA,pingpong:vA,smoothstep:MA,smootherstep:SA,randInt:TA,randFloat:bA,randFloatSpread:wA,seededRandom:AA,degToRad:NA,radToDeg:EA,isPowerOfTwo:CA,ceilPowerOfTwo:RA,floorPowerOfTwo:IA,setQuaternionFromProperEuler:PA,normalize:ut,denormalize:Yn};class J{constructor(e=0,t=0){J.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,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[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=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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 n=this.dot(e)/t;return Math.acos(jt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,o=this.y-e.y;return this.x=r*n-o*i+e.x,this.y=r*i+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Ke{constructor(e,t,n,i,r,o,a,c,l){Ke.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,r,o,a,c,l)}set(e,t,n,i,r,o,a,c,l){const u=this.elements;return u[0]=e,u[1]=i,u[2]=a,u[3]=t,u[4]=r,u[5]=c,u[6]=n,u[7]=o,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){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 n=e.elements,i=t.elements,r=this.elements,o=n[0],a=n[3],c=n[6],l=n[1],u=n[4],h=n[7],d=n[2],p=n[5],f=n[8],x=i[0],m=i[3],g=i[6],y=i[1],_=i[4],v=i[7],I=i[2],T=i[5],w=i[8];return r[0]=o*x+a*y+c*I,r[3]=o*m+a*_+c*T,r[6]=o*g+a*v+c*w,r[1]=l*x+u*y+h*I,r[4]=l*m+u*_+h*T,r[7]=l*g+u*v+h*w,r[2]=d*x+p*y+f*I,r[5]=d*m+p*_+f*T,r[8]=d*g+p*v+f*w,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],n=e[1],i=e[2],r=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8];return t*o*u-t*a*l-n*r*u+n*a*c+i*r*l-i*o*c}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],h=u*o-a*l,d=a*c-u*r,p=l*r-o*c,f=t*h+n*d+i*p;if(f===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/f;return e[0]=h*x,e[1]=(i*l-u*n)*x,e[2]=(a*n-i*o)*x,e[3]=d*x,e[4]=(u*t-i*c)*x,e[5]=(i*r-a*t)*x,e[6]=p*x,e[7]=(n*c-l*t)*x,e[8]=(o*t-n*r)*x,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,n,i,r,o,a){const c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*o+l*a)+o+e,-i*l,i*c,-i*(-l*o+c*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(qd.makeScale(e,t)),this}rotate(e){return this.premultiply(qd.makeRotation(-e)),this}translate(e,t){return this.premultiply(qd.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),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const qd=new Ke;function Uy(s){for(let e=s.length-1;e>=0;--e)if(s[e]>=65535)return!0;return!1}const LA={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function ko(s,e){return new LA[s](e)}function Cc(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function Fy(){const s=Cc("canvas");return s.style.display="block",s}const y0={};function Cu(s){s in y0||(y0[s]=!0,console.warn(s))}function DA(s,e,t){return new Promise(function(n,i){function r(){switch(s.clientWaitSync(e,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:i();break;case s.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}function UA(s){const e=s.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function FA(s){const e=s.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}const v0=new Ke().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),M0=new Ke().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Ca={[li]:{transfer:Ac,primaries:Nc,luminanceCoefficients:[.2126,.7152,.0722],toReference:s=>s,fromReference:s=>s},[kn]:{transfer:Vt,primaries:Nc,luminanceCoefficients:[.2126,.7152,.0722],toReference:s=>s.convertSRGBToLinear(),fromReference:s=>s.convertLinearToSRGB()},[Xc]:{transfer:Ac,primaries:Ec,luminanceCoefficients:[.2289,.6917,.0793],toReference:s=>s.applyMatrix3(M0),fromReference:s=>s.applyMatrix3(v0)},[kh]:{transfer:Vt,primaries:Ec,luminanceCoefficients:[.2289,.6917,.0793],toReference:s=>s.convertSRGBToLinear().applyMatrix3(M0),fromReference:s=>s.applyMatrix3(v0).convertLinearToSRGB()}},OA=new Set([li,Xc]),gt={enabled:!0,_workingColorSpace:li,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(s){if(!OA.has(s))throw new Error(`Unsupported working color space, "${s}".`);this._workingColorSpace=s},convert:function(s,e,t){if(this.enabled===!1||e===t||!e||!t)return s;const n=Ca[e].toReference,i=Ca[t].fromReference;return i(n(s))},fromWorkingColorSpace:function(s,e){return this.convert(s,this._workingColorSpace,e)},toWorkingColorSpace:function(s,e){return this.convert(s,e,this._workingColorSpace)},getPrimaries:function(s){return Ca[s].primaries},getTransfer:function(s){return s===Li?Ac:Ca[s].transfer},getLuminanceCoefficients:function(s,e=this._workingColorSpace){return s.fromArray(Ca[e].luminanceCoefficients)}};function jo(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function $d(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}let go;class Oy{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{go===void 0&&(go=Cc("canvas")),go.width=e.width,go.height=e.height;const n=go.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=go}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Cc("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let o=0;o<r.length;o++)r[o]=jo(r[o]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(jo(t[n]/255)*255):t[n]=jo(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let VA=0;class Js{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:VA++}),this.uuid=bi(),this.data=e,this.dataReady=!0,this.version=0}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 n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let o=0,a=i.length;o<a;o++)i[o].isDataTexture?r.push(Yd(i[o].image)):r.push(Yd(i[o]))}else r=Yd(i);n.url=r}return t||(e.images[this.uuid]=n),n}}function Yd(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?Oy.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let BA=0;class Xt extends Ai{constructor(e=Xt.DEFAULT_IMAGE,t=Xt.DEFAULT_MAPPING,n=Si,i=Si,r=Ut,o=Jn,a=Rn,c=es,l=Xt.DEFAULT_ANISOTROPY,u=Li){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:BA++}),this.uuid=bi(),this.name="",this.source=new Js(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=o,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=c,this.offset=new J(0,0),this.repeat=new J(1,1),this.center=new J(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ke,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}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)}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.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Ih)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case rr:e.x=e.x-Math.floor(e.x);break;case Si:e.x=e.x<0?0:1;break;case ea: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 rr:e.y=e.y-Math.floor(e.y);break;case Si:e.y=e.y<0?0:1;break;case ea: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++}}Xt.DEFAULT_IMAGE=null;Xt.DEFAULT_MAPPING=Ih;Xt.DEFAULT_ANISOTROPY=4;class st{constructor(e=0,t=0,n=0,i=1){st.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,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,n=this.y,i=this.z,r=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*i+o[12]*r,this.y=o[1]*t+o[5]*n+o[9]*i+o[13]*r,this.z=o[2]*t+o[6]*n+o[10]*i+o[14]*r,this.w=o[3]*t+o[7]*n+o[11]*i+o[15]*r,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,n,i,r;const c=e.elements,l=c[0],u=c[4],h=c[8],d=c[1],p=c[5],f=c[9],x=c[2],m=c[6],g=c[10];if(Math.abs(u-d)<.01&&Math.abs(h-x)<.01&&Math.abs(f-m)<.01){if(Math.abs(u+d)<.1&&Math.abs(h+x)<.1&&Math.abs(f+m)<.1&&Math.abs(l+p+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const _=(l+1)/2,v=(p+1)/2,I=(g+1)/2,T=(u+d)/4,w=(h+x)/4,C=(f+m)/4;return _>v&&_>I?_<.01?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(_),i=T/n,r=w/n):v>I?v<.01?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(v),n=T/i,r=C/i):I<.01?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(I),n=w/r,i=C/r),this.set(n,i,r,t),this}let y=Math.sqrt((m-f)*(m-f)+(h-x)*(h-x)+(d-u)*(d-u));return Math.abs(y)<.001&&(y=1),this.x=(m-f)/y,this.y=(h-x)/y,this.z=(d-u)/y,this.w=Math.acos((l+p+g-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=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class fn extends Ai{constructor(e=1,t=1,n={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new st(0,0,e,t),this.scissorTest=!1,this.viewport=new st(0,0,e,t);const i={width:e,height:t,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ut,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);const r=new Xt(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);r.flipY=!1,r.generateMipmaps=n.generateMipmaps,r.internalFormat=n.internalFormat,this.textures=[];const o=n.count;for(let a=0;a<o;a++)this.textures[a]=r.clone(),this.textures[a].isRenderTargetTexture=!0;this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.depthTexture=n.depthTexture,this.samples=n.samples}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n;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 n=0,i=e.textures.length;n<i;n++)this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new Js(t),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 zi extends fn{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class qc extends Xt{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Qt,this.minFilter=Qt,this.wrapR=Si,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class zA extends zi{constructor(e=1,t=1,n=1,i={}){super(e,t,i),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new qc(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class Hh extends Xt{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Qt,this.minFilter=Qt,this.wrapR=Si,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class kA extends zi{constructor(e=1,t=1,n=1,i={}){super(e,t,i),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new Hh(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class Qn{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,o,a){let c=n[i+0],l=n[i+1],u=n[i+2],h=n[i+3];const d=r[o+0],p=r[o+1],f=r[o+2],x=r[o+3];if(a===0){e[t+0]=c,e[t+1]=l,e[t+2]=u,e[t+3]=h;return}if(a===1){e[t+0]=d,e[t+1]=p,e[t+2]=f,e[t+3]=x;return}if(h!==x||c!==d||l!==p||u!==f){let m=1-a;const g=c*d+l*p+u*f+h*x,y=g>=0?1:-1,_=1-g*g;if(_>Number.EPSILON){const I=Math.sqrt(_),T=Math.atan2(I,g*y);m=Math.sin(m*T)/I,a=Math.sin(a*T)/I}const v=a*y;if(c=c*m+d*v,l=l*m+p*v,u=u*m+f*v,h=h*m+x*v,m===1-a){const I=1/Math.sqrt(c*c+l*l+u*u+h*h);c*=I,l*=I,u*=I,h*=I}}e[t]=c,e[t+1]=l,e[t+2]=u,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,i,r,o){const a=n[i],c=n[i+1],l=n[i+2],u=n[i+3],h=r[o],d=r[o+1],p=r[o+2],f=r[o+3];return e[t]=a*f+u*h+c*p-l*d,e[t+1]=c*f+u*d+l*h-a*p,e[t+2]=l*f+u*p+a*d-c*h,e[t+3]=u*f-a*h-c*d-l*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,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,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 n=e._x,i=e._y,r=e._z,o=e._order,a=Math.cos,c=Math.sin,l=a(n/2),u=a(i/2),h=a(r/2),d=c(n/2),p=c(i/2),f=c(r/2);switch(o){case"XYZ":this._x=d*u*h+l*p*f,this._y=l*p*h-d*u*f,this._z=l*u*f+d*p*h,this._w=l*u*h-d*p*f;break;case"YXZ":this._x=d*u*h+l*p*f,this._y=l*p*h-d*u*f,this._z=l*u*f-d*p*h,this._w=l*u*h+d*p*f;break;case"ZXY":this._x=d*u*h-l*p*f,this._y=l*p*h+d*u*f,this._z=l*u*f+d*p*h,this._w=l*u*h-d*p*f;break;case"ZYX":this._x=d*u*h-l*p*f,this._y=l*p*h+d*u*f,this._z=l*u*f-d*p*h,this._w=l*u*h+d*p*f;break;case"YZX":this._x=d*u*h+l*p*f,this._y=l*p*h+d*u*f,this._z=l*u*f-d*p*h,this._w=l*u*h-d*p*f;break;case"XZY":this._x=d*u*h-l*p*f,this._y=l*p*h-d*u*f,this._z=l*u*f+d*p*h,this._w=l*u*h+d*p*f;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],r=t[8],o=t[1],a=t[5],c=t[9],l=t[2],u=t[6],h=t[10],d=n+a+h;if(d>0){const p=.5/Math.sqrt(d+1);this._w=.25/p,this._x=(u-c)*p,this._y=(r-l)*p,this._z=(o-i)*p}else if(n>a&&n>h){const p=2*Math.sqrt(1+n-a-h);this._w=(u-c)/p,this._x=.25*p,this._y=(i+o)/p,this._z=(r+l)/p}else if(a>h){const p=2*Math.sqrt(1+a-n-h);this._w=(r-l)/p,this._x=(i+o)/p,this._y=.25*p,this._z=(c+u)/p}else{const p=2*Math.sqrt(1+h-n-a);this._w=(o-i)/p,this._x=(r+l)/p,this._y=(c+u)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(jt(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(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 n=e._x,i=e._y,r=e._z,o=e._w,a=t._x,c=t._y,l=t._z,u=t._w;return this._x=n*u+o*a+i*l-r*c,this._y=i*u+o*c+r*a-n*l,this._z=r*u+o*l+n*c-i*a,this._w=o*u-n*a-i*c-r*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,i=this._y,r=this._z,o=this._w;let a=o*e._w+n*e._x+i*e._y+r*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=n,this._y=i,this._z=r,this;const c=1-a*a;if(c<=Number.EPSILON){const p=1-t;return this._w=p*o+t*this._w,this._x=p*n+t*this._x,this._y=p*i+t*this._y,this._z=p*r+t*this._z,this.normalize(),this}const l=Math.sqrt(c),u=Math.atan2(l,a),h=Math.sin((1-t)*u)/l,d=Math.sin(t*u)/l;return this._w=o*h+this._w*d,this._x=n*h+this._x*d,this._y=i*h+this._y*d,this._z=r*h+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*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 E{constructor(e=0,t=0,n=0){E.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw 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(S0.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(S0.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=e.elements,o=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*o,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*o,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*o,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,r=e.x,o=e.y,a=e.z,c=e.w,l=2*(o*i-a*n),u=2*(a*t-r*i),h=2*(r*n-o*t);return this.x=t+c*l+o*h-a*u,this.y=n+c*u+a*l-r*h,this.z=i+c*h+r*u-o*l,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,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,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=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,r=e.z,o=t.x,a=t.y,c=t.z;return this.x=i*c-r*a,this.y=r*o-n*c,this.z=n*a-i*o,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Zd.copy(this).projectOnVector(e),this.sub(Zd)}reflect(e){return this.sub(Zd.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 n=this.dot(e)/t;return Math.acos(jt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){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(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,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,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Zd=new E,S0=new Qn;class Hn{constructor(e=new E(1/0,1/0,1/0),t=new E(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(qi.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(qi.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=qi.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let o=0,a=r.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,qi):qi.fromBufferAttribute(r,o),qi.applyMatrix4(e.matrixWorld),this.expandByPoint(qi);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),wl.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),wl.copy(n.boundingBox)),wl.applyMatrix4(e.matrixWorld),this.union(wl)}const i=e.children;for(let r=0,o=i.length;r<o;r++)this.expandByObject(i[r],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,qi),qi.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Ra),Al.subVectors(this.max,Ra),xo.subVectors(e.a,Ra),_o.subVectors(e.b,Ra),yo.subVectors(e.c,Ra),Bs.subVectors(_o,xo),zs.subVectors(yo,_o),vr.subVectors(xo,yo);let t=[0,-Bs.z,Bs.y,0,-zs.z,zs.y,0,-vr.z,vr.y,Bs.z,0,-Bs.x,zs.z,0,-zs.x,vr.z,0,-vr.x,-Bs.y,Bs.x,0,-zs.y,zs.x,0,-vr.y,vr.x,0];return!Jd(t,xo,_o,yo,Al)||(t=[1,0,0,0,1,0,0,0,1],!Jd(t,xo,_o,yo,Al))?!1:(Nl.crossVectors(Bs,zs),t=[Nl.x,Nl.y,Nl.z],Jd(t,xo,_o,yo,Al))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,qi).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(qi).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:(Ms[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ms[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ms[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ms[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ms[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ms[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ms[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ms[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ms),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)}}const Ms=[new E,new E,new E,new E,new E,new E,new E,new E],qi=new E,wl=new Hn,xo=new E,_o=new E,yo=new E,Bs=new E,zs=new E,vr=new E,Ra=new E,Al=new E,Nl=new E,Mr=new E;function Jd(s,e,t,n,i){for(let r=0,o=s.length-3;r<=o;r+=3){Mr.fromArray(s,r);const a=i.x*Math.abs(Mr.x)+i.y*Math.abs(Mr.y)+i.z*Math.abs(Mr.z),c=e.dot(Mr),l=t.dot(Mr),u=n.dot(Mr);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}const GA=new Hn,Ia=new E,Kd=new E;class Dn{constructor(e=new E,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 n=this.center;t!==void 0?n.copy(t):GA.setFromPoints(e).getCenter(n);let i=0;for(let r=0,o=e.length;r<o;r++)i=Math.max(i,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(i),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 n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=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;Ia.subVectors(e,this.center);const t=Ia.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(Ia,i/n),this.radius+=i}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):(Kd.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ia.copy(e.center).add(Kd)),this.expandByPoint(Ia.copy(e.center).sub(Kd))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Ss=new E,jd=new E,El=new E,ks=new E,Qd=new E,Cl=new E,ep=new E;class no{constructor(e=new E,t=new E(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,Ss)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Ss.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Ss.copy(this.origin).addScaledVector(this.direction,t),Ss.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){jd.copy(e).add(t).multiplyScalar(.5),El.copy(t).sub(e).normalize(),ks.copy(this.origin).sub(jd);const r=e.distanceTo(t)*.5,o=-this.direction.dot(El),a=ks.dot(this.direction),c=-ks.dot(El),l=ks.lengthSq(),u=Math.abs(1-o*o);let h,d,p,f;if(u>0)if(h=o*c-a,d=o*a-c,f=r*u,h>=0)if(d>=-f)if(d<=f){const x=1/u;h*=x,d*=x,p=h*(h+o*d+2*a)+d*(o*h+d+2*c)+l}else d=r,h=Math.max(0,-(o*d+a)),p=-h*h+d*(d+2*c)+l;else d=-r,h=Math.max(0,-(o*d+a)),p=-h*h+d*(d+2*c)+l;else d<=-f?(h=Math.max(0,-(-o*r+a)),d=h>0?-r:Math.min(Math.max(-r,-c),r),p=-h*h+d*(d+2*c)+l):d<=f?(h=0,d=Math.min(Math.max(-r,-c),r),p=d*(d+2*c)+l):(h=Math.max(0,-(o*r+a)),d=h>0?r:Math.min(Math.max(-r,-c),r),p=-h*h+d*(d+2*c)+l);else d=o>0?-r:r,h=Math.max(0,-(o*d+a)),p=-h*h+d*(d+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(jd).addScaledVector(El,d),p}intersectSphere(e,t){Ss.subVectors(e.center,this.origin);const n=Ss.dot(this.direction),i=Ss.dot(Ss)-n*n,r=e.radius*e.radius;if(i>r)return null;const o=Math.sqrt(r-i),a=n-o,c=n+o;return c<0?null:a<0?this.at(c,t):this.at(a,t)}intersectsSphere(e){return 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 n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,o,a,c;const l=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,d=this.origin;return l>=0?(n=(e.min.x-d.x)*l,i=(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,i=(e.min.x-d.x)*l),u>=0?(r=(e.min.y-d.y)*u,o=(e.max.y-d.y)*u):(r=(e.max.y-d.y)*u,o=(e.min.y-d.y)*u),n>o||r>i||((r>n||isNaN(n))&&(n=r),(o<i||isNaN(i))&&(i=o),h>=0?(a=(e.min.z-d.z)*h,c=(e.max.z-d.z)*h):(a=(e.max.z-d.z)*h,c=(e.min.z-d.z)*h),n>c||a>i)||((a>n||n!==n)&&(n=a),(c<i||i!==i)&&(i=c),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,Ss)!==null}intersectTriangle(e,t,n,i,r){Qd.subVectors(t,e),Cl.subVectors(n,e),ep.crossVectors(Qd,Cl);let o=this.direction.dot(ep),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;ks.subVectors(this.origin,e);const c=a*this.direction.dot(Cl.crossVectors(ks,Cl));if(c<0)return null;const l=a*this.direction.dot(Qd.cross(ks));if(l<0||c+l>o)return null;const u=-a*ks.dot(ep);return u<0?null:this.at(u/o,r)}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 Fe{constructor(e,t,n,i,r,o,a,c,l,u,h,d,p,f,x,m){Fe.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,n,i,r,o,a,c,l,u,h,d,p,f,x,m)}set(e,t,n,i,r,o,a,c,l,u,h,d,p,f,x,m){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=r,g[5]=o,g[9]=a,g[13]=c,g[2]=l,g[6]=u,g[10]=h,g[14]=d,g[3]=p,g[7]=f,g[11]=x,g[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 Fe().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[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,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/vo.setFromMatrixColumn(e,0).length(),r=1/vo.setFromMatrixColumn(e,1).length(),o=1/vo.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,r=e.z,o=Math.cos(n),a=Math.sin(n),c=Math.cos(i),l=Math.sin(i),u=Math.cos(r),h=Math.sin(r);if(e.order==="XYZ"){const d=o*u,p=o*h,f=a*u,x=a*h;t[0]=c*u,t[4]=-c*h,t[8]=l,t[1]=p+f*l,t[5]=d-x*l,t[9]=-a*c,t[2]=x-d*l,t[6]=f+p*l,t[10]=o*c}else if(e.order==="YXZ"){const d=c*u,p=c*h,f=l*u,x=l*h;t[0]=d+x*a,t[4]=f*a-p,t[8]=o*l,t[1]=o*h,t[5]=o*u,t[9]=-a,t[2]=p*a-f,t[6]=x+d*a,t[10]=o*c}else if(e.order==="ZXY"){const d=c*u,p=c*h,f=l*u,x=l*h;t[0]=d-x*a,t[4]=-o*h,t[8]=f+p*a,t[1]=p+f*a,t[5]=o*u,t[9]=x-d*a,t[2]=-o*l,t[6]=a,t[10]=o*c}else if(e.order==="ZYX"){const d=o*u,p=o*h,f=a*u,x=a*h;t[0]=c*u,t[4]=f*l-p,t[8]=d*l+x,t[1]=c*h,t[5]=x*l+d,t[9]=p*l-f,t[2]=-l,t[6]=a*c,t[10]=o*c}else if(e.order==="YZX"){const d=o*c,p=o*l,f=a*c,x=a*l;t[0]=c*u,t[4]=x-d*h,t[8]=f*h+p,t[1]=h,t[5]=o*u,t[9]=-a*u,t[2]=-l*u,t[6]=p*h+f,t[10]=d-x*h}else if(e.order==="XZY"){const d=o*c,p=o*l,f=a*c,x=a*l;t[0]=c*u,t[4]=-h,t[8]=l*u,t[1]=d*h+x,t[5]=o*u,t[9]=p*h-f,t[2]=f*h-p,t[6]=a*u,t[10]=x*h+d}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(HA,e,WA)}lookAt(e,t,n){const i=this.elements;return gi.subVectors(e,t),gi.lengthSq()===0&&(gi.z=1),gi.normalize(),Gs.crossVectors(n,gi),Gs.lengthSq()===0&&(Math.abs(n.z)===1?gi.x+=1e-4:gi.z+=1e-4,gi.normalize(),Gs.crossVectors(n,gi)),Gs.normalize(),Rl.crossVectors(gi,Gs),i[0]=Gs.x,i[4]=Rl.x,i[8]=gi.x,i[1]=Gs.y,i[5]=Rl.y,i[9]=gi.y,i[2]=Gs.z,i[6]=Rl.z,i[10]=gi.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,o=n[0],a=n[4],c=n[8],l=n[12],u=n[1],h=n[5],d=n[9],p=n[13],f=n[2],x=n[6],m=n[10],g=n[14],y=n[3],_=n[7],v=n[11],I=n[15],T=i[0],w=i[4],C=i[8],F=i[12],M=i[1],b=i[5],G=i[9],W=i[13],$=i[2],ie=i[6],q=i[10],he=i[14],Q=i[3],we=i[7],Ne=i[11],Ee=i[15];return r[0]=o*T+a*M+c*$+l*Q,r[4]=o*w+a*b+c*ie+l*we,r[8]=o*C+a*G+c*q+l*Ne,r[12]=o*F+a*W+c*he+l*Ee,r[1]=u*T+h*M+d*$+p*Q,r[5]=u*w+h*b+d*ie+p*we,r[9]=u*C+h*G+d*q+p*Ne,r[13]=u*F+h*W+d*he+p*Ee,r[2]=f*T+x*M+m*$+g*Q,r[6]=f*w+x*b+m*ie+g*we,r[10]=f*C+x*G+m*q+g*Ne,r[14]=f*F+x*W+m*he+g*Ee,r[3]=y*T+_*M+v*$+I*Q,r[7]=y*w+_*b+v*ie+I*we,r[11]=y*C+_*G+v*q+I*Ne,r[15]=y*F+_*W+v*he+I*Ee,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],n=e[4],i=e[8],r=e[12],o=e[1],a=e[5],c=e[9],l=e[13],u=e[2],h=e[6],d=e[10],p=e[14],f=e[3],x=e[7],m=e[11],g=e[15];return f*(+r*c*h-i*l*h-r*a*d+n*l*d+i*a*p-n*c*p)+x*(+t*c*p-t*l*d+r*o*d-i*o*p+i*l*u-r*c*u)+m*(+t*l*h-t*a*p-r*o*h+n*o*p+r*a*u-n*l*u)+g*(-i*a*u-t*c*h+t*a*d+i*o*h-n*o*d+n*c*u)}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,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],h=e[9],d=e[10],p=e[11],f=e[12],x=e[13],m=e[14],g=e[15],y=h*m*l-x*d*l+x*c*p-a*m*p-h*c*g+a*d*g,_=f*d*l-u*m*l-f*c*p+o*m*p+u*c*g-o*d*g,v=u*x*l-f*h*l+f*a*p-o*x*p-u*a*g+o*h*g,I=f*h*c-u*x*c-f*a*d+o*x*d+u*a*m-o*h*m,T=t*y+n*_+i*v+r*I;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/T;return e[0]=y*w,e[1]=(x*d*r-h*m*r-x*i*p+n*m*p+h*i*g-n*d*g)*w,e[2]=(a*m*r-x*c*r+x*i*l-n*m*l-a*i*g+n*c*g)*w,e[3]=(h*c*r-a*d*r-h*i*l+n*d*l+a*i*p-n*c*p)*w,e[4]=_*w,e[5]=(u*m*r-f*d*r+f*i*p-t*m*p-u*i*g+t*d*g)*w,e[6]=(f*c*r-o*m*r-f*i*l+t*m*l+o*i*g-t*c*g)*w,e[7]=(o*d*r-u*c*r+u*i*l-t*d*l-o*i*p+t*c*p)*w,e[8]=v*w,e[9]=(f*h*r-u*x*r-f*n*p+t*x*p+u*n*g-t*h*g)*w,e[10]=(o*x*r-f*a*r+f*n*l-t*x*l-o*n*g+t*a*g)*w,e[11]=(u*a*r-o*h*r-u*n*l+t*h*l+o*n*p-t*a*p)*w,e[12]=I*w,e[13]=(u*x*i-f*h*i+f*n*d-t*x*d-u*n*m+t*h*m)*w,e[14]=(f*a*i-o*x*i-f*n*c+t*x*c+o*n*m-t*a*m)*w,e[15]=(o*h*i-u*a*i+u*n*c-t*h*c-o*n*d+t*a*d)*w,this}scale(e){const t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),r=1-n,o=e.x,a=e.y,c=e.z,l=r*o,u=r*a;return this.set(l*o+n,l*a-i*c,l*c+i*a,0,l*a+i*c,u*a+n,u*c-i*o,0,l*c-i*a,u*c+i*o,r*c*c+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,o){return this.set(1,n,r,0,e,1,o,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,r=t._x,o=t._y,a=t._z,c=t._w,l=r+r,u=o+o,h=a+a,d=r*l,p=r*u,f=r*h,x=o*u,m=o*h,g=a*h,y=c*l,_=c*u,v=c*h,I=n.x,T=n.y,w=n.z;return i[0]=(1-(x+g))*I,i[1]=(p+v)*I,i[2]=(f-_)*I,i[3]=0,i[4]=(p-v)*T,i[5]=(1-(d+g))*T,i[6]=(m+y)*T,i[7]=0,i[8]=(f+_)*w,i[9]=(m-y)*w,i[10]=(1-(d+x))*w,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let r=vo.set(i[0],i[1],i[2]).length();const o=vo.set(i[4],i[5],i[6]).length(),a=vo.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),e.x=i[12],e.y=i[13],e.z=i[14],$i.copy(this);const l=1/r,u=1/o,h=1/a;return $i.elements[0]*=l,$i.elements[1]*=l,$i.elements[2]*=l,$i.elements[4]*=u,$i.elements[5]*=u,$i.elements[6]*=u,$i.elements[8]*=h,$i.elements[9]*=h,$i.elements[10]*=h,t.setFromRotationMatrix($i),n.x=r,n.y=o,n.z=a,this}makePerspective(e,t,n,i,r,o,a=Di){const c=this.elements,l=2*r/(t-e),u=2*r/(n-i),h=(t+e)/(t-e),d=(n+i)/(n-i);let p,f;if(a===Di)p=-(o+r)/(o-r),f=-2*o*r/(o-r);else if(a===jr)p=-o/(o-r),f=-o*r/(o-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=l,c[4]=0,c[8]=h,c[12]=0,c[1]=0,c[5]=u,c[9]=d,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=f,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,r,o,a=Di){const c=this.elements,l=1/(t-e),u=1/(n-i),h=1/(o-r),d=(t+e)*l,p=(n+i)*u;let f,x;if(a===Di)f=(o+r)*h,x=-2*h;else if(a===jr)f=r*h,x=-1*h;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=2*l,c[4]=0,c[8]=0,c[12]=-d,c[1]=0,c[5]=2*u,c[9]=0,c[13]=-p,c[2]=0,c[6]=0,c[10]=x,c[14]=-f,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const vo=new E,$i=new Fe,HA=new E(0,0,0),WA=new E(1,1,1),Gs=new E,Rl=new E,gi=new E,T0=new Fe,b0=new Qn;class ui{constructor(e=0,t=0,n=0,i=ui.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,r=i[0],o=i[4],a=i[8],c=i[1],l=i[5],u=i[9],h=i[2],d=i[6],p=i[10];switch(t){case"XYZ":this._y=Math.asin(jt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,p),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-jt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,p),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin(jt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,p),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-jt(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(jt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(a,p));break;case"XZY":this._z=Math.asin(-jt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-u,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return T0.makeRotationFromQuaternion(e),this.setFromRotationMatrix(T0,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return b0.setFromEuler(this),this.setFromQuaternion(b0,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}}ui.DEFAULT_ORDER="XYZ";class $c{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 XA=0;const w0=new E,Mo=new Qn,Ts=new Fe,Il=new E,Pa=new E,qA=new E,$A=new Qn,A0=new E(1,0,0),N0=new E(0,1,0),E0=new E(0,0,1),C0={type:"added"},YA={type:"removed"},So={type:"childadded",child:null},tp={type:"childremoved",child:null};class yt extends Ai{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:XA++}),this.uuid=bi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=yt.DEFAULT_UP.clone();const e=new E,t=new ui,n=new Qn,i=new E(1,1,1);function r(){n.setFromEuler(t,!1)}function o(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Fe},normalMatrix:{value:new Ke}}),this.matrix=new Fe,this.matrixWorld=new Fe,this.matrixAutoUpdate=yt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=yt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new $c,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Mo.setFromAxisAngle(e,t),this.quaternion.multiply(Mo),this}rotateOnWorldAxis(e,t){return Mo.setFromAxisAngle(e,t),this.quaternion.premultiply(Mo),this}rotateX(e){return this.rotateOnAxis(A0,e)}rotateY(e){return this.rotateOnAxis(N0,e)}rotateZ(e){return this.rotateOnAxis(E0,e)}translateOnAxis(e,t){return w0.copy(e).applyQuaternion(this.quaternion),this.position.add(w0.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(A0,e)}translateY(e){return this.translateOnAxis(N0,e)}translateZ(e){return this.translateOnAxis(E0,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ts.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Il.copy(e):Il.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),Pa.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ts.lookAt(Pa,Il,this.up):Ts.lookAt(Il,Pa,this.up),this.quaternion.setFromRotationMatrix(Ts),i&&(Ts.extractRotation(i.matrixWorld),Mo.setFromRotationMatrix(Ts),this.quaternion.premultiply(Mo.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(C0),So.child=e,this.dispatchEvent(So),So.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(YA),tp.child=e,this.dispatchEvent(tp),tp.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),Ts.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Ts.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ts),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(C0),So.child=e,this.dispatchEvent(So),So.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){const o=this.children[n].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const i=this.children;for(let r=0,o=i.length;r<o;r++)i[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Pa,e,qA),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Pa,$A,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 n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].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),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 n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const i=this.children;for(let r=0,o=i.length;r<o;r++)i[r].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));function r(a,c){return a[c.uuid]===void 0&&(a[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const c=a.shapes;if(Array.isArray(c))for(let l=0,u=c.length;l<u;l++){const h=c[l];r(e.shapes,h)}else r(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let c=0,l=this.material.length;c<l;c++)a.push(r(e.materials,this.material[c]));i.material=a}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){const c=this.animations[a];i.animations.push(r(e.animations,c))}}if(t){const a=o(e.geometries),c=o(e.materials),l=o(e.textures),u=o(e.images),h=o(e.shapes),d=o(e.skeletons),p=o(e.animations),f=o(e.nodes);a.length>0&&(n.geometries=a),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),u.length>0&&(n.images=u),h.length>0&&(n.shapes=h),d.length>0&&(n.skeletons=d),p.length>0&&(n.animations=p),f.length>0&&(n.nodes=f)}return n.object=i,n;function o(a){const c=[];for(const l in a){const u=a[l];delete u.metadata,c.push(u)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const i=e.children[n];this.add(i.clone())}return this}}yt.DEFAULT_UP=new E(0,1,0);yt.DEFAULT_MATRIX_AUTO_UPDATE=!0;yt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Yi=new E,bs=new E,np=new E,ws=new E,To=new E,bo=new E,R0=new E,ip=new E,sp=new E,rp=new E,op=new st,ap=new st,cp=new st;class Zn{constructor(e=new E,t=new E,n=new E){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),Yi.subVectors(e,t),i.cross(Yi);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){Yi.subVectors(i,t),bs.subVectors(n,t),np.subVectors(e,t);const o=Yi.dot(Yi),a=Yi.dot(bs),c=Yi.dot(np),l=bs.dot(bs),u=bs.dot(np),h=o*l-a*a;if(h===0)return r.set(0,0,0),null;const d=1/h,p=(l*c-a*u)*d,f=(o*u-a*c)*d;return r.set(1-p-f,f,p)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,ws)===null?!1:ws.x>=0&&ws.y>=0&&ws.x+ws.y<=1}static getInterpolation(e,t,n,i,r,o,a,c){return this.getBarycoord(e,t,n,i,ws)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(r,ws.x),c.addScaledVector(o,ws.y),c.addScaledVector(a,ws.z),c)}static getInterpolatedAttribute(e,t,n,i,r,o){return op.setScalar(0),ap.setScalar(0),cp.setScalar(0),op.fromBufferAttribute(e,t),ap.fromBufferAttribute(e,n),cp.fromBufferAttribute(e,i),o.setScalar(0),o.addScaledVector(op,r.x),o.addScaledVector(ap,r.y),o.addScaledVector(cp,r.z),o}static isFrontFacing(e,t,n,i){return Yi.subVectors(n,t),bs.subVectors(e,t),Yi.cross(bs).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),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 Yi.subVectors(this.c,this.b),bs.subVectors(this.a,this.b),Yi.cross(bs).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Zn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Zn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return Zn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return Zn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Zn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,r=this.c;let o,a;To.subVectors(i,n),bo.subVectors(r,n),ip.subVectors(e,n);const c=To.dot(ip),l=bo.dot(ip);if(c<=0&&l<=0)return t.copy(n);sp.subVectors(e,i);const u=To.dot(sp),h=bo.dot(sp);if(u>=0&&h<=u)return t.copy(i);const d=c*h-u*l;if(d<=0&&c>=0&&u<=0)return o=c/(c-u),t.copy(n).addScaledVector(To,o);rp.subVectors(e,r);const p=To.dot(rp),f=bo.dot(rp);if(f>=0&&p<=f)return t.copy(r);const x=p*l-c*f;if(x<=0&&l>=0&&f<=0)return a=l/(l-f),t.copy(n).addScaledVector(bo,a);const m=u*f-p*h;if(m<=0&&h-u>=0&&p-f>=0)return R0.subVectors(r,i),a=(h-u)/(h-u+(p-f)),t.copy(i).addScaledVector(R0,a);const g=1/(m+x+d);return o=x*g,a=d*g,t.copy(n).addScaledVector(To,o).addScaledVector(bo,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const Vy={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},Hs={h:0,s:0,l:0},Pl={h:0,s:0,l:0};function lp(s,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?s+(e-s)*6*t:t<1/2?e:t<2/3?s+(e-s)*6*(2/3-t):s}class _e{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=kn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,gt.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=gt.workingColorSpace){return this.r=e,this.g=t,this.b=n,gt.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=gt.workingColorSpace){if(e=em(e,1),t=jt(t,0,1),n=jt(n,0,1),t===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+t):n+t-n*t,o=2*n-r;this.r=lp(o,r,e+1/3),this.g=lp(o,r,e),this.b=lp(o,r,e-1/3)}return gt.toWorkingColorSpace(this,i),this}setStyle(e,t=kn){function n(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=i[1],o=r.length;if(o===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(r,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=kn){const n=Vy[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.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=jo(e.r),this.g=jo(e.g),this.b=jo(e.b),this}copyLinearToSRGB(e){return this.r=$d(e.r),this.g=$d(e.g),this.b=$d(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=kn){return gt.fromWorkingColorSpace(Bn.copy(this),e),Math.round(jt(Bn.r*255,0,255))*65536+Math.round(jt(Bn.g*255,0,255))*256+Math.round(jt(Bn.b*255,0,255))}getHexString(e=kn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=gt.workingColorSpace){gt.fromWorkingColorSpace(Bn.copy(this),t);const n=Bn.r,i=Bn.g,r=Bn.b,o=Math.max(n,i,r),a=Math.min(n,i,r);let c,l;const u=(a+o)/2;if(a===o)c=0,l=0;else{const h=o-a;switch(l=u<=.5?h/(o+a):h/(2-o-a),o){case n:c=(i-r)/h+(i<r?6:0);break;case i:c=(r-n)/h+2;break;case r:c=(n-i)/h+4;break}c/=6}return e.h=c,e.s=l,e.l=u,e}getRGB(e,t=gt.workingColorSpace){return gt.fromWorkingColorSpace(Bn.copy(this),t),e.r=Bn.r,e.g=Bn.g,e.b=Bn.b,e}getStyle(e=kn){gt.fromWorkingColorSpace(Bn.copy(this),e);const t=Bn.r,n=Bn.g,i=Bn.b;return e!==kn?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(Hs),this.setHSL(Hs.h+e,Hs.s+t,Hs.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Hs),e.getHSL(Pl);const n=Ka(Hs.h,Pl.h,t),i=Ka(Hs.s,Pl.s,t),r=Ka(Hs.l,Pl.l,t);return this.setHSL(n,i,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*i,this.g=r[1]*t+r[4]*n+r[7]*i,this.b=r[2]*t+r[5]*n+r[8]*i,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 Bn=new _e;_e.NAMES=Vy;let ZA=0;class mn extends Ai{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:ZA++}),this.uuid=bi(),this.name="",this.type="Material",this.blending=Ps,this.side=fs,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Ou,this.blendDst=Vu,this.blendEquation=Zs,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new _e(0,0,0),this.blendAlpha=0,this.depthFunc=nr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=ih,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=$s,this.stencilZFail=$s,this.stencilZPass=$s,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.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}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Ps&&(n.blending=this.blending),this.side!==fs&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==Ou&&(n.blendSrc=this.blendSrc),this.blendDst!==Vu&&(n.blendDst=this.blendDst),this.blendEquation!==Zs&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==nr&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==ih&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==$s&&(n.stencilFail=this.stencilFail),this.stencilZFail!==$s&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==$s&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(r){const o=[];for(const a in r){const c=r[a];delete c.metadata,o.push(c)}return o}if(t){const r=i(e.textures),o=i(e.images);r.length>0&&(n.textures=r),o.length>0&&(n.images=o)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const i=t.length;n=new Array(i);for(let r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class ss extends mn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new _e(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 ui,this.combine=fa,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 Es=JA();function JA(){const s=new ArrayBuffer(4),e=new Float32Array(s),t=new Uint32Array(s),n=new Uint32Array(512),i=new Uint32Array(512);for(let c=0;c<256;++c){const l=c-127;l<-27?(n[c]=0,n[c|256]=32768,i[c]=24,i[c|256]=24):l<-14?(n[c]=1024>>-l-14,n[c|256]=1024>>-l-14|32768,i[c]=-l-1,i[c|256]=-l-1):l<=15?(n[c]=l+15<<10,n[c|256]=l+15<<10|32768,i[c]=13,i[c|256]=13):l<128?(n[c]=31744,n[c|256]=64512,i[c]=24,i[c|256]=24):(n[c]=31744,n[c|256]=64512,i[c]=13,i[c|256]=13)}const r=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,u=0;for(;(l&8388608)===0;)l<<=1,u-=8388608;l&=-8388609,u+=947912704,r[c]=l|u}for(let c=1024;c<2048;++c)r[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)o[c]=c<<23;o[31]=1199570944,o[32]=2147483648;for(let c=33;c<63;++c)o[c]=2147483648+(c-32<<23);o[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(a[c]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:i,mantissaTable:r,exponentTable:o,offsetTable:a}}function si(s){Math.abs(s)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),s=jt(s,-65504,65504),Es.floatView[0]=s;const e=Es.uint32View[0],t=e>>23&511;return Es.baseTable[t]+((e&8388607)>>Es.shiftTable[t])}function Za(s){const e=s>>10;return Es.uint32View[0]=Es.mantissaTable[Es.offsetTable[e]+(s&1023)]+Es.exponentTable[e],Es.floatView[0]}const By={toHalfFloat:si,fromHalfFloat:Za},an=new E,Ll=new J;class At{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=sa,this.updateRanges=[],this.gpuType=Gn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Ll.fromBufferAttribute(this,t),Ll.applyMatrix3(e),this.setXY(t,Ll.x,Ll.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)an.fromBufferAttribute(this,t),an.applyMatrix3(e),this.setXYZ(t,an.x,an.y,an.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)an.fromBufferAttribute(this,t),an.applyMatrix4(e),this.setXYZ(t,an.x,an.y,an.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)an.fromBufferAttribute(this,t),an.applyNormalMatrix(e),this.setXYZ(t,an.x,an.y,an.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)an.fromBufferAttribute(this,t),an.transformDirection(e),this.setXYZ(t,an.x,an.y,an.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=Yn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=ut(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Yn(t,this.array)),t}setX(e,t){return this.normalized&&(t=ut(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Yn(t,this.array)),t}setY(e,t){return this.normalized&&(t=ut(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=Yn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=ut(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=Yn(t,this.array)),t}setW(e,t){return this.normalized&&(t=ut(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=ut(t,this.array),n=ut(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=ut(t,this.array),n=ut(n,this.array),i=ut(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e*=this.itemSize,this.normalized&&(t=ut(t,this.array),n=ut(n,this.array),i=ut(i,this.array),r=ut(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,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!==sa&&(e.usage=this.usage),e}}class KA extends At{constructor(e,t,n){super(new Int8Array(e),t,n)}}class jA extends At{constructor(e,t,n){super(new Uint8Array(e),t,n)}}class QA extends At{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}}class e1 extends At{constructor(e,t,n){super(new Int16Array(e),t,n)}}class Wh extends At{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class t1 extends At{constructor(e,t,n){super(new Int32Array(e),t,n)}}class tm extends At{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class zy extends At{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=Za(this.array[e*this.itemSize]);return this.normalized&&(t=Yn(t,this.array)),t}setX(e,t){return this.normalized&&(t=ut(t,this.array)),this.array[e*this.itemSize]=si(t),this}getY(e){let t=Za(this.array[e*this.itemSize+1]);return this.normalized&&(t=Yn(t,this.array)),t}setY(e,t){return this.normalized&&(t=ut(t,this.array)),this.array[e*this.itemSize+1]=si(t),this}getZ(e){let t=Za(this.array[e*this.itemSize+2]);return this.normalized&&(t=Yn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=ut(t,this.array)),this.array[e*this.itemSize+2]=si(t),this}getW(e){let t=Za(this.array[e*this.itemSize+3]);return this.normalized&&(t=Yn(t,this.array)),t}setW(e,t){return this.normalized&&(t=ut(t,this.array)),this.array[e*this.itemSize+3]=si(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=ut(t,this.array),n=ut(n,this.array)),this.array[e+0]=si(t),this.array[e+1]=si(n),this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=ut(t,this.array),n=ut(n,this.array),i=ut(i,this.array)),this.array[e+0]=si(t),this.array[e+1]=si(n),this.array[e+2]=si(i),this}setXYZW(e,t,n,i,r){return e*=this.itemSize,this.normalized&&(t=ut(t,this.array),n=ut(n,this.array),i=ut(i,this.array),r=ut(r,this.array)),this.array[e+0]=si(t),this.array[e+1]=si(n),this.array[e+2]=si(i),this.array[e+3]=si(r),this}}class Ve extends At{constructor(e,t,n){super(new Float32Array(e),t,n)}}let n1=0;const Ei=new Fe,up=new yt,wo=new E,xi=new Hn,La=new Hn,_n=new E;class at extends Ai{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:n1++}),this.uuid=bi(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Uy(e)?tm:Wh)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const r=new Ke().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Ei.makeRotationFromQuaternion(e),this.applyMatrix4(Ei),this}rotateX(e){return Ei.makeRotationX(e),this.applyMatrix4(Ei),this}rotateY(e){return Ei.makeRotationY(e),this.applyMatrix4(Ei),this}rotateZ(e){return Ei.makeRotationZ(e),this.applyMatrix4(Ei),this}translate(e,t,n){return Ei.makeTranslation(e,t,n),this.applyMatrix4(Ei),this}scale(e,t,n){return Ei.makeScale(e,t,n),this.applyMatrix4(Ei),this}lookAt(e){return up.lookAt(e),up.updateMatrix(),this.applyMatrix4(up.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(wo).negate(),this.translate(wo.x,wo.y,wo.z),this}setFromPoints(e){const t=[];for(let n=0,i=e.length;n<i;n++){const r=e[n];t.push(r.x,r.y,r.z||0)}return this.setAttribute("position",new Ve(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Hn);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new E(-1/0,-1/0,-1/0),new E(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){const r=t[n];xi.setFromBufferAttribute(r),this.morphTargetsRelative?(_n.addVectors(this.boundingBox.min,xi.min),this.boundingBox.expandByPoint(_n),_n.addVectors(this.boundingBox.max,xi.max),this.boundingBox.expandByPoint(_n)):(this.boundingBox.expandByPoint(xi.min),this.boundingBox.expandByPoint(xi.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Dn);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new E,1/0);return}if(e){const n=this.boundingSphere.center;if(xi.setFromBufferAttribute(e),t)for(let r=0,o=t.length;r<o;r++){const a=t[r];La.setFromBufferAttribute(a),this.morphTargetsRelative?(_n.addVectors(xi.min,La.min),xi.expandByPoint(_n),_n.addVectors(xi.max,La.max),xi.expandByPoint(_n)):(xi.expandByPoint(La.min),xi.expandByPoint(La.max))}xi.getCenter(n);let i=0;for(let r=0,o=e.count;r<o;r++)_n.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(_n));if(t)for(let r=0,o=t.length;r<o;r++){const a=t[r],c=this.morphTargetsRelative;for(let l=0,u=a.count;l<u;l++)_n.fromBufferAttribute(a,l),c&&(wo.fromBufferAttribute(e,l),_n.add(wo)),i=Math.max(i,n.distanceToSquared(_n))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,i=t.normal,r=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new At(new Float32Array(4*n.count),4));const o=this.getAttribute("tangent"),a=[],c=[];for(let C=0;C<n.count;C++)a[C]=new E,c[C]=new E;const l=new E,u=new E,h=new E,d=new J,p=new J,f=new J,x=new E,m=new E;function g(C,F,M){l.fromBufferAttribute(n,C),u.fromBufferAttribute(n,F),h.fromBufferAttribute(n,M),d.fromBufferAttribute(r,C),p.fromBufferAttribute(r,F),f.fromBufferAttribute(r,M),u.sub(l),h.sub(l),p.sub(d),f.sub(d);const b=1/(p.x*f.y-f.x*p.y);isFinite(b)&&(x.copy(u).multiplyScalar(f.y).addScaledVector(h,-p.y).multiplyScalar(b),m.copy(h).multiplyScalar(p.x).addScaledVector(u,-f.x).multiplyScalar(b),a[C].add(x),a[F].add(x),a[M].add(x),c[C].add(m),c[F].add(m),c[M].add(m))}let y=this.groups;y.length===0&&(y=[{start:0,count:e.count}]);for(let C=0,F=y.length;C<F;++C){const M=y[C],b=M.start,G=M.count;for(let W=b,$=b+G;W<$;W+=3)g(e.getX(W+0),e.getX(W+1),e.getX(W+2))}const _=new E,v=new E,I=new E,T=new E;function w(C){I.fromBufferAttribute(i,C),T.copy(I);const F=a[C];_.copy(F),_.sub(I.multiplyScalar(I.dot(F))).normalize(),v.crossVectors(T,F);const b=v.dot(c[C])<0?-1:1;o.setXYZW(C,_.x,_.y,_.z,b)}for(let C=0,F=y.length;C<F;++C){const M=y[C],b=M.start,G=M.count;for(let W=b,$=b+G;W<$;W+=3)w(e.getX(W+0)),w(e.getX(W+1)),w(e.getX(W+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new At(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,p=n.count;d<p;d++)n.setXYZ(d,0,0,0);const i=new E,r=new E,o=new E,a=new E,c=new E,l=new E,u=new E,h=new E;if(e)for(let d=0,p=e.count;d<p;d+=3){const f=e.getX(d+0),x=e.getX(d+1),m=e.getX(d+2);i.fromBufferAttribute(t,f),r.fromBufferAttribute(t,x),o.fromBufferAttribute(t,m),u.subVectors(o,r),h.subVectors(i,r),u.cross(h),a.fromBufferAttribute(n,f),c.fromBufferAttribute(n,x),l.fromBufferAttribute(n,m),a.add(u),c.add(u),l.add(u),n.setXYZ(f,a.x,a.y,a.z),n.setXYZ(x,c.x,c.y,c.z),n.setXYZ(m,l.x,l.y,l.z)}else for(let d=0,p=t.count;d<p;d+=3)i.fromBufferAttribute(t,d+0),r.fromBufferAttribute(t,d+1),o.fromBufferAttribute(t,d+2),u.subVectors(o,r),h.subVectors(i,r),u.cross(h),n.setXYZ(d+0,u.x,u.y,u.z),n.setXYZ(d+1,u.x,u.y,u.z),n.setXYZ(d+2,u.x,u.y,u.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)_n.fromBufferAttribute(e,t),_n.normalize(),e.setXYZ(t,_n.x,_n.y,_n.z)}toNonIndexed(){function e(a,c){const l=a.array,u=a.itemSize,h=a.normalized,d=new l.constructor(c.length*u);let p=0,f=0;for(let x=0,m=c.length;x<m;x++){a.isInterleavedBufferAttribute?p=c[x]*a.data.stride+a.offset:p=c[x]*u;for(let g=0;g<u;g++)d[f++]=l[p++]}return new At(d,u,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new at,n=this.index.array,i=this.attributes;for(const a in i){const c=i[a],l=e(c,n);t.setAttribute(a,l)}const r=this.morphAttributes;for(const a in r){const c=[],l=r[a];for(let u=0,h=l.length;u<h;u++){const d=l[u],p=e(d,n);c.push(p)}t.morphAttributes[a]=c}t.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,c=o.length;a<c;a++){const l=o[a];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){const e={metadata:{version:4.6,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 c=this.parameters;for(const l in c)c[l]!==void 0&&(e[l]=c[l]);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 n=this.attributes;for(const c in n){const l=n[c];e.data.attributes[c]=l.toJSON(e.data)}const i={};let r=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],u=[];for(let h=0,d=l.length;h<d;h++){const p=l[h];u.push(p.toJSON(e.data))}u.length>0&&(i[c]=u,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),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 n=e.index;n!==null&&this.setIndex(n.clone(t));const i=e.attributes;for(const l in i){const u=i[l];this.setAttribute(l,u.clone(t))}const r=e.morphAttributes;for(const l in r){const u=[],h=r[l];for(let d=0,p=h.length;d<p;d++)u.push(h[d].clone(t));this.morphAttributes[l]=u}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let l=0,u=o.length;l<u;l++){const h=o[l];this.addGroup(h.start,h.count,h.materialIndex)}const a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const I0=new Fe,Sr=new no,Dl=new Dn,P0=new E,Ul=new E,Fl=new E,Ol=new E,hp=new E,Vl=new E,L0=new E,Bl=new E;class kt extends yt{constructor(e=new at,t=new ss){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,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,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r<o;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(e,t){const n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,o=n.morphTargetsRelative;t.fromBufferAttribute(i,e);const a=this.morphTargetInfluences;if(r&&a){Vl.set(0,0,0);for(let c=0,l=r.length;c<l;c++){const u=a[c],h=r[c];u!==0&&(hp.fromBufferAttribute(h,e),o?Vl.addScaledVector(hp,u):Vl.addScaledVector(hp.sub(t),u))}t.add(Vl)}return t}raycast(e,t){const n=this.geometry,i=this.material,r=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Dl.copy(n.boundingSphere),Dl.applyMatrix4(r),Sr.copy(e.ray).recast(e.near),!(Dl.containsPoint(Sr.origin)===!1&&(Sr.intersectSphere(Dl,P0)===null||Sr.origin.distanceToSquared(P0)>(e.far-e.near)**2))&&(I0.copy(r).invert(),Sr.copy(e.ray).applyMatrix4(I0),!(n.boundingBox!==null&&Sr.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Sr)))}_computeIntersections(e,t,n){let i;const r=this.geometry,o=this.material,a=r.index,c=r.attributes.position,l=r.attributes.uv,u=r.attributes.uv1,h=r.attributes.normal,d=r.groups,p=r.drawRange;if(a!==null)if(Array.isArray(o))for(let f=0,x=d.length;f<x;f++){const m=d[f],g=o[m.materialIndex],y=Math.max(m.start,p.start),_=Math.min(a.count,Math.min(m.start+m.count,p.start+p.count));for(let v=y,I=_;v<I;v+=3){const T=a.getX(v),w=a.getX(v+1),C=a.getX(v+2);i=zl(this,g,e,n,l,u,h,T,w,C),i&&(i.faceIndex=Math.floor(v/3),i.face.materialIndex=m.materialIndex,t.push(i))}}else{const f=Math.max(0,p.start),x=Math.min(a.count,p.start+p.count);for(let m=f,g=x;m<g;m+=3){const y=a.getX(m),_=a.getX(m+1),v=a.getX(m+2);i=zl(this,o,e,n,l,u,h,y,_,v),i&&(i.faceIndex=Math.floor(m/3),t.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let f=0,x=d.length;f<x;f++){const m=d[f],g=o[m.materialIndex],y=Math.max(m.start,p.start),_=Math.min(c.count,Math.min(m.start+m.count,p.start+p.count));for(let v=y,I=_;v<I;v+=3){const T=v,w=v+1,C=v+2;i=zl(this,g,e,n,l,u,h,T,w,C),i&&(i.faceIndex=Math.floor(v/3),i.face.materialIndex=m.materialIndex,t.push(i))}}else{const f=Math.max(0,p.start),x=Math.min(c.count,p.start+p.count);for(let m=f,g=x;m<g;m+=3){const y=m,_=m+1,v=m+2;i=zl(this,o,e,n,l,u,h,y,_,v),i&&(i.faceIndex=Math.floor(m/3),t.push(i))}}}}function i1(s,e,t,n,i,r,o,a){let c;if(e.side===ln?c=n.intersectTriangle(o,r,i,!0,a):c=n.intersectTriangle(i,r,o,e.side===fs,a),c===null)return null;Bl.copy(a),Bl.applyMatrix4(s.matrixWorld);const l=t.ray.origin.distanceTo(Bl);return l<t.near||l>t.far?null:{distance:l,point:Bl.clone(),object:s}}function zl(s,e,t,n,i,r,o,a,c,l){s.getVertexPosition(a,Ul),s.getVertexPosition(c,Fl),s.getVertexPosition(l,Ol);const u=i1(s,e,t,n,Ul,Fl,Ol,L0);if(u){const h=new E;Zn.getBarycoord(L0,Ul,Fl,Ol,h),i&&(u.uv=Zn.getInterpolatedAttribute(i,a,c,l,h,new J)),r&&(u.uv1=Zn.getInterpolatedAttribute(r,a,c,l,h,new J)),o&&(u.normal=Zn.getInterpolatedAttribute(o,a,c,l,h,new E),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));const d={a,b:c,c:l,normal:new E,materialIndex:0};Zn.getNormal(Ul,Fl,Ol,d.normal),u.face=d,u.barycoord=h}return u}class _s extends at{constructor(e=1,t=1,n=1,i=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:o};const a=this;i=Math.floor(i),r=Math.floor(r),o=Math.floor(o);const c=[],l=[],u=[],h=[];let d=0,p=0;f("z","y","x",-1,-1,n,t,e,o,r,0),f("z","y","x",1,-1,n,t,-e,o,r,1),f("x","z","y",1,1,e,n,t,i,o,2),f("x","z","y",1,-1,e,n,-t,i,o,3),f("x","y","z",1,-1,e,t,n,i,r,4),f("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(c),this.setAttribute("position",new Ve(l,3)),this.setAttribute("normal",new Ve(u,3)),this.setAttribute("uv",new Ve(h,2));function f(x,m,g,y,_,v,I,T,w,C,F){const M=v/w,b=I/C,G=v/2,W=I/2,$=T/2,ie=w+1,q=C+1;let he=0,Q=0;const we=new E;for(let Ne=0;Ne<q;Ne++){const Ee=Ne*b-W;for(let Qe=0;Qe<ie;Qe++){const ht=Qe*M-G;we[x]=ht*y,we[m]=Ee*_,we[g]=$,l.push(we.x,we.y,we.z),we[x]=0,we[m]=0,we[g]=T>0?1:-1,u.push(we.x,we.y,we.z),h.push(Qe/w),h.push(1-Ne/C),he+=1}}for(let Ne=0;Ne<C;Ne++)for(let Ee=0;Ee<w;Ee++){const Qe=d+Ee+ie*Ne,ht=d+Ee+ie*(Ne+1),ne=d+(Ee+1)+ie*(Ne+1),ue=d+(Ee+1)+ie*Ne;c.push(Qe,ht,ue),c.push(ht,ne,ue),Q+=6}a.addGroup(p,Q,F),p+=Q,d+=he}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new _s(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function oa(s){const e={};for(const t in s){e[t]={};for(const n in s[t]){const i=s[t][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=i.clone():Array.isArray(i)?e[t][n]=i.slice():e[t][n]=i}}return e}function $n(s){const e={};for(let t=0;t<s.length;t++){const n=oa(s[t]);for(const i in n)e[i]=n[i]}return e}function s1(s){const e=[];for(let t=0;t<s.length;t++)e.push(s[t].clone());return e}function ky(s){const e=s.getRenderTarget();return e===null?s.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:gt.workingColorSpace}const nm={clone:oa,merge:$n};var r1=`void main() {
5
+ */const Ks="169",G_={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},H_={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},W_=0,sf=1,X_=2,tA=3,nA=0,Lf=1,Df=2,oi=3,fs=0,ln=1,Ji=2,Fi=0,Ps=1,cc=2,rf=3,of=4,Uf=5,Zs=100,q_=101,$_=102,Y_=103,Ff=104,Z_=200,J_=201,K_=202,j_=203,Ou=204,Vu=205,Q_=206,ey=207,ty=208,ny=209,iy=210,sy=211,ry=212,oy=213,ay=214,lc=0,uc=1,hc=2,nr=3,dc=4,pc=5,fc=6,mc=7,fa=0,Of=1,Vf=2,Ti=0,Ah=1,Nh=2,Bf=3,Eh=4,cy=5,Ch=6,Rh=7,af="attached",ly="detached",Ih=300,wi=301,Vi=302,ir=303,sr=304,hr=306,rr=1e3,Si=1001,ea=1002,Qt=1003,Ph=1004,iA=1004,Cs=1005,sA=1005,Ut=1006,js=1007,rA=1007,Jn=1008,uy=1008,es=1009,zf=1010,kf=1011,ta=1012,ma=1013,Bi=1014,Gn=1015,Ln=1016,Lh=1017,Dh=1018,or=1020,Uh=35902,Fh=35899,Gf=1021,Oh=1022,Rn=1023,Hf=1024,Wf=1025,Qs=1026,ar=1027,Hc=1028,Wc=1029,na=1030,Vh=1031,oA=1032,Bh=1033,$o=33776,Yo=33777,Zo=33778,Jo=33779,gc=35840,Bu=35841,xc=35842,zu=35843,_c=36196,yc=37492,vc=37496,Mc=37808,ku=37809,Gu=37810,Hu=37811,Sc=37812,Wu=37813,Xu=37814,qu=37815,$u=37816,Yu=37817,Zu=37818,Ju=37819,Ku=37820,ju=37821,Ko=36492,Qu=36494,Tc=36495,Xf=36283,eh=36284,th=36285,nh=36286,qf=2200,$f=2201,hy=2202,ia=2300,bc=2301,Eu=2302,zr=2400,kr=2401,wc=2402,zh=2500,Yf=2501,dy=0,py=1,fy=2,Zf=3200,Jf=3201,aA=3202,cA=3203,ms=0,Kf=1,Li="",kn="srgb",li="srgb-linear",kh="display-p3",Xc="display-p3-linear",Ac="linear",Vt="srgb",Nc="rec709",Ec="p3",my=0,$s=7680,gy=7681,xy=7682,_y=7683,yy=34055,vy=34056,My=5386,Sy=512,Ty=513,by=514,wy=515,Ay=516,Ny=517,Ey=518,ih=519,Cy=512,jf=513,Ry=514,Qf=515,Iy=516,Py=517,Ly=518,Dy=519,sa=35044,Gr=35048,lA=35040,uA=35045,hA=35049,dA=35041,pA=35046,fA=35050,mA=35042,gA="100",sh="300 es",Di=2e3,Qr=2001;class Ai{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const r=i.indexOf(t);r!==-1&&i.splice(r,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const n=this._listeners[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let r=0,o=i.length;r<o;r++)i[r].call(this,e);e.target=null}}}const Vn=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let _0=1234567;const $r=Math.PI/180,ra=180/Math.PI;function bi(){const s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Vn[s&255]+Vn[s>>8&255]+Vn[s>>16&255]+Vn[s>>24&255]+"-"+Vn[e&255]+Vn[e>>8&255]+"-"+Vn[e>>16&15|64]+Vn[e>>24&255]+"-"+Vn[t&63|128]+Vn[t>>8&255]+"-"+Vn[t>>16&255]+Vn[t>>24&255]+Vn[n&255]+Vn[n>>8&255]+Vn[n>>16&255]+Vn[n>>24&255]).toLowerCase()}function jt(s,e,t){return Math.max(e,Math.min(t,s))}function em(s,e){return(s%e+e)%e}function xA(s,e,t,n,i){return n+(s-e)*(i-n)/(t-e)}function _A(s,e,t){return s!==e?(t-s)/(e-s):0}function Ka(s,e,t){return(1-t)*s+t*e}function yA(s,e,t,n){return Ka(s,e,1-Math.exp(-t*n))}function vA(s,e=1){return e-Math.abs(em(s,e*2)-e)}function MA(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*(3-2*s))}function SA(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*s*(s*(s*6-15)+10))}function TA(s,e){return s+Math.floor(Math.random()*(e-s+1))}function bA(s,e){return s+Math.random()*(e-s)}function wA(s){return s*(.5-Math.random())}function AA(s){s!==void 0&&(_0=s);let e=_0+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function NA(s){return s*$r}function EA(s){return s*ra}function CA(s){return(s&s-1)===0&&s!==0}function RA(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function IA(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function PA(s,e,t,n,i){const r=Math.cos,o=Math.sin,a=r(t/2),c=o(t/2),l=r((e+n)/2),u=o((e+n)/2),h=r((e-n)/2),d=o((e-n)/2),p=r((n-e)/2),f=o((n-e)/2);switch(i){case"XYX":s.set(a*u,c*h,c*d,a*l);break;case"YZY":s.set(c*d,a*u,c*h,a*l);break;case"ZXZ":s.set(c*h,c*d,a*u,a*l);break;case"XZX":s.set(a*u,c*f,c*p,a*l);break;case"YXY":s.set(c*p,a*u,c*f,a*l);break;case"ZYZ":s.set(c*f,c*p,a*u,a*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Yn(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("Invalid component type.")}}function ut(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("Invalid component type.")}}const Gh={DEG2RAD:$r,RAD2DEG:ra,generateUUID:bi,clamp:jt,euclideanModulo:em,mapLinear:xA,inverseLerp:_A,lerp:Ka,damp:yA,pingpong:vA,smoothstep:MA,smootherstep:SA,randInt:TA,randFloat:bA,randFloatSpread:wA,seededRandom:AA,degToRad:NA,radToDeg:EA,isPowerOfTwo:CA,ceilPowerOfTwo:RA,floorPowerOfTwo:IA,setQuaternionFromProperEuler:PA,normalize:ut,denormalize:Yn};class J{constructor(e=0,t=0){J.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,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[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=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}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 n=this.dot(e)/t;return Math.acos(jt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,o=this.y-e.y;return this.x=r*n-o*i+e.x,this.y=r*i+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Ke{constructor(e,t,n,i,r,o,a,c,l){Ke.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,r,o,a,c,l)}set(e,t,n,i,r,o,a,c,l){const u=this.elements;return u[0]=e,u[1]=i,u[2]=a,u[3]=t,u[4]=r,u[5]=c,u[6]=n,u[7]=o,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){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 n=e.elements,i=t.elements,r=this.elements,o=n[0],a=n[3],c=n[6],l=n[1],u=n[4],h=n[7],d=n[2],p=n[5],f=n[8],x=i[0],m=i[3],g=i[6],y=i[1],_=i[4],v=i[7],I=i[2],T=i[5],w=i[8];return r[0]=o*x+a*y+c*I,r[3]=o*m+a*_+c*T,r[6]=o*g+a*v+c*w,r[1]=l*x+u*y+h*I,r[4]=l*m+u*_+h*T,r[7]=l*g+u*v+h*w,r[2]=d*x+p*y+f*I,r[5]=d*m+p*_+f*T,r[8]=d*g+p*v+f*w,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],n=e[1],i=e[2],r=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8];return t*o*u-t*a*l-n*r*u+n*a*c+i*r*l-i*o*c}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],h=u*o-a*l,d=a*c-u*r,p=l*r-o*c,f=t*h+n*d+i*p;if(f===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/f;return e[0]=h*x,e[1]=(i*l-u*n)*x,e[2]=(a*n-i*o)*x,e[3]=d*x,e[4]=(u*t-i*c)*x,e[5]=(i*r-a*t)*x,e[6]=p*x,e[7]=(n*c-l*t)*x,e[8]=(o*t-n*r)*x,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,n,i,r,o,a){const c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*o+l*a)+o+e,-i*l,i*c,-i*(-l*o+c*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(qd.makeScale(e,t)),this}rotate(e){return this.premultiply(qd.makeRotation(-e)),this}translate(e,t){return this.premultiply(qd.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),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const qd=new Ke;function Uy(s){for(let e=s.length-1;e>=0;--e)if(s[e]>=65535)return!0;return!1}const LA={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function ko(s,e){return new LA[s](e)}function Cc(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function Fy(){const s=Cc("canvas");return s.style.display="block",s}const y0={};function Cu(s){s in y0||(y0[s]=!0,console.warn(s))}function DA(s,e,t){return new Promise(function(n,i){function r(){switch(s.clientWaitSync(e,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:i();break;case s.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}function UA(s){const e=s.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function FA(s){const e=s.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}const v0=new Ke().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),M0=new Ke().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Ca={[li]:{transfer:Ac,primaries:Nc,luminanceCoefficients:[.2126,.7152,.0722],toReference:s=>s,fromReference:s=>s},[kn]:{transfer:Vt,primaries:Nc,luminanceCoefficients:[.2126,.7152,.0722],toReference:s=>s.convertSRGBToLinear(),fromReference:s=>s.convertLinearToSRGB()},[Xc]:{transfer:Ac,primaries:Ec,luminanceCoefficients:[.2289,.6917,.0793],toReference:s=>s.applyMatrix3(M0),fromReference:s=>s.applyMatrix3(v0)},[kh]:{transfer:Vt,primaries:Ec,luminanceCoefficients:[.2289,.6917,.0793],toReference:s=>s.convertSRGBToLinear().applyMatrix3(M0),fromReference:s=>s.applyMatrix3(v0).convertLinearToSRGB()}},OA=new Set([li,Xc]),gt={enabled:!0,_workingColorSpace:li,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(s){if(!OA.has(s))throw new Error(`Unsupported working color space, "${s}".`);this._workingColorSpace=s},convert:function(s,e,t){if(this.enabled===!1||e===t||!e||!t)return s;const n=Ca[e].toReference,i=Ca[t].fromReference;return i(n(s))},fromWorkingColorSpace:function(s,e){return this.convert(s,this._workingColorSpace,e)},toWorkingColorSpace:function(s,e){return this.convert(s,e,this._workingColorSpace)},getPrimaries:function(s){return Ca[s].primaries},getTransfer:function(s){return s===Li?Ac:Ca[s].transfer},getLuminanceCoefficients:function(s,e=this._workingColorSpace){return s.fromArray(Ca[e].luminanceCoefficients)}};function jo(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function $d(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}let go;class Oy{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{go===void 0&&(go=Cc("canvas")),go.width=e.width,go.height=e.height;const n=go.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=go}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Cc("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let o=0;o<r.length;o++)r[o]=jo(r[o]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(jo(t[n]/255)*255):t[n]=jo(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let VA=0;class Js{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:VA++}),this.uuid=bi(),this.data=e,this.dataReady=!0,this.version=0}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 n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let o=0,a=i.length;o<a;o++)i[o].isDataTexture?r.push(Yd(i[o].image)):r.push(Yd(i[o]))}else r=Yd(i);n.url=r}return t||(e.images[this.uuid]=n),n}}function Yd(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?Oy.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let BA=0;class Xt extends Ai{constructor(e=Xt.DEFAULT_IMAGE,t=Xt.DEFAULT_MAPPING,n=Si,i=Si,r=Ut,o=Jn,a=Rn,c=es,l=Xt.DEFAULT_ANISOTROPY,u=Li){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:BA++}),this.uuid=bi(),this.name="",this.source=new Js(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=o,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=c,this.offset=new J(0,0),this.repeat=new J(1,1),this.center=new J(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ke,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}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)}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.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Ih)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case rr:e.x=e.x-Math.floor(e.x);break;case Si:e.x=e.x<0?0:1;break;case ea: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 rr:e.y=e.y-Math.floor(e.y);break;case Si:e.y=e.y<0?0:1;break;case ea: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++}}Xt.DEFAULT_IMAGE=null;Xt.DEFAULT_MAPPING=Ih;Xt.DEFAULT_ANISOTROPY=4;class st{constructor(e=0,t=0,n=0,i=1){st.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,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,n=this.y,i=this.z,r=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*i+o[12]*r,this.y=o[1]*t+o[5]*n+o[9]*i+o[13]*r,this.z=o[2]*t+o[6]*n+o[10]*i+o[14]*r,this.w=o[3]*t+o[7]*n+o[11]*i+o[15]*r,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,n,i,r;const c=e.elements,l=c[0],u=c[4],h=c[8],d=c[1],p=c[5],f=c[9],x=c[2],m=c[6],g=c[10];if(Math.abs(u-d)<.01&&Math.abs(h-x)<.01&&Math.abs(f-m)<.01){if(Math.abs(u+d)<.1&&Math.abs(h+x)<.1&&Math.abs(f+m)<.1&&Math.abs(l+p+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const _=(l+1)/2,v=(p+1)/2,I=(g+1)/2,T=(u+d)/4,w=(h+x)/4,C=(f+m)/4;return _>v&&_>I?_<.01?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(_),i=T/n,r=w/n):v>I?v<.01?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(v),n=T/i,r=C/i):I<.01?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(I),n=w/r,i=C/r),this.set(n,i,r,t),this}let y=Math.sqrt((m-f)*(m-f)+(h-x)*(h-x)+(d-u)*(d-u));return Math.abs(y)<.001&&(y=1),this.x=(m-f)/y,this.y=(h-x)/y,this.z=(d-u)/y,this.w=Math.acos((l+p+g-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=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class fn extends Ai{constructor(e=1,t=1,n={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new st(0,0,e,t),this.scissorTest=!1,this.viewport=new st(0,0,e,t);const i={width:e,height:t,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ut,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);const r=new Xt(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);r.flipY=!1,r.generateMipmaps=n.generateMipmaps,r.internalFormat=n.internalFormat,this.textures=[];const o=n.count;for(let a=0;a<o;a++)this.textures[a]=r.clone(),this.textures[a].isRenderTargetTexture=!0;this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.depthTexture=n.depthTexture,this.samples=n.samples}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n;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 n=0,i=e.textures.length;n<i;n++)this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new Js(t),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 zi extends fn{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class qc extends Xt{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Qt,this.minFilter=Qt,this.wrapR=Si,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class zA extends zi{constructor(e=1,t=1,n=1,i={}){super(e,t,i),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new qc(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class Hh extends Xt{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Qt,this.minFilter=Qt,this.wrapR=Si,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class kA extends zi{constructor(e=1,t=1,n=1,i={}){super(e,t,i),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new Hh(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class Qn{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,o,a){let c=n[i+0],l=n[i+1],u=n[i+2],h=n[i+3];const d=r[o+0],p=r[o+1],f=r[o+2],x=r[o+3];if(a===0){e[t+0]=c,e[t+1]=l,e[t+2]=u,e[t+3]=h;return}if(a===1){e[t+0]=d,e[t+1]=p,e[t+2]=f,e[t+3]=x;return}if(h!==x||c!==d||l!==p||u!==f){let m=1-a;const g=c*d+l*p+u*f+h*x,y=g>=0?1:-1,_=1-g*g;if(_>Number.EPSILON){const I=Math.sqrt(_),T=Math.atan2(I,g*y);m=Math.sin(m*T)/I,a=Math.sin(a*T)/I}const v=a*y;if(c=c*m+d*v,l=l*m+p*v,u=u*m+f*v,h=h*m+x*v,m===1-a){const I=1/Math.sqrt(c*c+l*l+u*u+h*h);c*=I,l*=I,u*=I,h*=I}}e[t]=c,e[t+1]=l,e[t+2]=u,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,i,r,o){const a=n[i],c=n[i+1],l=n[i+2],u=n[i+3],h=r[o],d=r[o+1],p=r[o+2],f=r[o+3];return e[t]=a*f+u*h+c*p-l*d,e[t+1]=c*f+u*d+l*h-a*p,e[t+2]=l*f+u*p+a*d-c*h,e[t+3]=u*f-a*h-c*d-l*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,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,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 n=e._x,i=e._y,r=e._z,o=e._order,a=Math.cos,c=Math.sin,l=a(n/2),u=a(i/2),h=a(r/2),d=c(n/2),p=c(i/2),f=c(r/2);switch(o){case"XYZ":this._x=d*u*h+l*p*f,this._y=l*p*h-d*u*f,this._z=l*u*f+d*p*h,this._w=l*u*h-d*p*f;break;case"YXZ":this._x=d*u*h+l*p*f,this._y=l*p*h-d*u*f,this._z=l*u*f-d*p*h,this._w=l*u*h+d*p*f;break;case"ZXY":this._x=d*u*h-l*p*f,this._y=l*p*h+d*u*f,this._z=l*u*f+d*p*h,this._w=l*u*h-d*p*f;break;case"ZYX":this._x=d*u*h-l*p*f,this._y=l*p*h+d*u*f,this._z=l*u*f-d*p*h,this._w=l*u*h+d*p*f;break;case"YZX":this._x=d*u*h+l*p*f,this._y=l*p*h+d*u*f,this._z=l*u*f-d*p*h,this._w=l*u*h-d*p*f;break;case"XZY":this._x=d*u*h-l*p*f,this._y=l*p*h-d*u*f,this._z=l*u*f+d*p*h,this._w=l*u*h+d*p*f;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],r=t[8],o=t[1],a=t[5],c=t[9],l=t[2],u=t[6],h=t[10],d=n+a+h;if(d>0){const p=.5/Math.sqrt(d+1);this._w=.25/p,this._x=(u-c)*p,this._y=(r-l)*p,this._z=(o-i)*p}else if(n>a&&n>h){const p=2*Math.sqrt(1+n-a-h);this._w=(u-c)/p,this._x=.25*p,this._y=(i+o)/p,this._z=(r+l)/p}else if(a>h){const p=2*Math.sqrt(1+a-n-h);this._w=(r-l)/p,this._x=(i+o)/p,this._y=.25*p,this._z=(c+u)/p}else{const p=2*Math.sqrt(1+h-n-a);this._w=(o-i)/p,this._x=(r+l)/p,this._y=(c+u)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(jt(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(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 n=e._x,i=e._y,r=e._z,o=e._w,a=t._x,c=t._y,l=t._z,u=t._w;return this._x=n*u+o*a+i*l-r*c,this._y=i*u+o*c+r*a-n*l,this._z=r*u+o*l+n*c-i*a,this._w=o*u-n*a-i*c-r*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,i=this._y,r=this._z,o=this._w;let a=o*e._w+n*e._x+i*e._y+r*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=n,this._y=i,this._z=r,this;const c=1-a*a;if(c<=Number.EPSILON){const p=1-t;return this._w=p*o+t*this._w,this._x=p*n+t*this._x,this._y=p*i+t*this._y,this._z=p*r+t*this._z,this.normalize(),this}const l=Math.sqrt(c),u=Math.atan2(l,a),h=Math.sin((1-t)*u)/l,d=Math.sin(t*u)/l;return this._w=o*h+this._w*d,this._x=n*h+this._x*d,this._y=i*h+this._y*d,this._z=r*h+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*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 E{constructor(e=0,t=0,n=0){E.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw 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(S0.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(S0.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=e.elements,o=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*o,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*o,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*o,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,r=e.x,o=e.y,a=e.z,c=e.w,l=2*(o*i-a*n),u=2*(a*t-r*i),h=2*(r*n-o*t);return this.x=t+c*l+o*h-a*u,this.y=n+c*u+a*l-r*h,this.z=i+c*h+r*u-o*l,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,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,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=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,r=e.z,o=t.x,a=t.y,c=t.z;return this.x=i*c-r*a,this.y=r*o-n*c,this.z=n*a-i*o,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Zd.copy(this).projectOnVector(e),this.sub(Zd)}reflect(e){return this.sub(Zd.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 n=this.dot(e)/t;return Math.acos(jt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){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(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,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,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Zd=new E,S0=new Qn;class Hn{constructor(e=new E(1/0,1/0,1/0),t=new E(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(qi.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(qi.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=qi.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let o=0,a=r.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,qi):qi.fromBufferAttribute(r,o),qi.applyMatrix4(e.matrixWorld),this.expandByPoint(qi);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),wl.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),wl.copy(n.boundingBox)),wl.applyMatrix4(e.matrixWorld),this.union(wl)}const i=e.children;for(let r=0,o=i.length;r<o;r++)this.expandByObject(i[r],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,qi),qi.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Ra),Al.subVectors(this.max,Ra),xo.subVectors(e.a,Ra),_o.subVectors(e.b,Ra),yo.subVectors(e.c,Ra),Bs.subVectors(_o,xo),zs.subVectors(yo,_o),Mr.subVectors(xo,yo);let t=[0,-Bs.z,Bs.y,0,-zs.z,zs.y,0,-Mr.z,Mr.y,Bs.z,0,-Bs.x,zs.z,0,-zs.x,Mr.z,0,-Mr.x,-Bs.y,Bs.x,0,-zs.y,zs.x,0,-Mr.y,Mr.x,0];return!Jd(t,xo,_o,yo,Al)||(t=[1,0,0,0,1,0,0,0,1],!Jd(t,xo,_o,yo,Al))?!1:(Nl.crossVectors(Bs,zs),t=[Nl.x,Nl.y,Nl.z],Jd(t,xo,_o,yo,Al))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,qi).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(qi).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:(Ms[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ms[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ms[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ms[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ms[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ms[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ms[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ms[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ms),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)}}const Ms=[new E,new E,new E,new E,new E,new E,new E,new E],qi=new E,wl=new Hn,xo=new E,_o=new E,yo=new E,Bs=new E,zs=new E,Mr=new E,Ra=new E,Al=new E,Nl=new E,Sr=new E;function Jd(s,e,t,n,i){for(let r=0,o=s.length-3;r<=o;r+=3){Sr.fromArray(s,r);const a=i.x*Math.abs(Sr.x)+i.y*Math.abs(Sr.y)+i.z*Math.abs(Sr.z),c=e.dot(Sr),l=t.dot(Sr),u=n.dot(Sr);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}const GA=new Hn,Ia=new E,Kd=new E;class Dn{constructor(e=new E,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 n=this.center;t!==void 0?n.copy(t):GA.setFromPoints(e).getCenter(n);let i=0;for(let r=0,o=e.length;r<o;r++)i=Math.max(i,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(i),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 n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=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;Ia.subVectors(e,this.center);const t=Ia.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(Ia,i/n),this.radius+=i}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):(Kd.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ia.copy(e.center).add(Kd)),this.expandByPoint(Ia.copy(e.center).sub(Kd))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Ss=new E,jd=new E,El=new E,ks=new E,Qd=new E,Cl=new E,ep=new E;class io{constructor(e=new E,t=new E(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,Ss)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Ss.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Ss.copy(this.origin).addScaledVector(this.direction,t),Ss.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){jd.copy(e).add(t).multiplyScalar(.5),El.copy(t).sub(e).normalize(),ks.copy(this.origin).sub(jd);const r=e.distanceTo(t)*.5,o=-this.direction.dot(El),a=ks.dot(this.direction),c=-ks.dot(El),l=ks.lengthSq(),u=Math.abs(1-o*o);let h,d,p,f;if(u>0)if(h=o*c-a,d=o*a-c,f=r*u,h>=0)if(d>=-f)if(d<=f){const x=1/u;h*=x,d*=x,p=h*(h+o*d+2*a)+d*(o*h+d+2*c)+l}else d=r,h=Math.max(0,-(o*d+a)),p=-h*h+d*(d+2*c)+l;else d=-r,h=Math.max(0,-(o*d+a)),p=-h*h+d*(d+2*c)+l;else d<=-f?(h=Math.max(0,-(-o*r+a)),d=h>0?-r:Math.min(Math.max(-r,-c),r),p=-h*h+d*(d+2*c)+l):d<=f?(h=0,d=Math.min(Math.max(-r,-c),r),p=d*(d+2*c)+l):(h=Math.max(0,-(o*r+a)),d=h>0?r:Math.min(Math.max(-r,-c),r),p=-h*h+d*(d+2*c)+l);else d=o>0?-r:r,h=Math.max(0,-(o*d+a)),p=-h*h+d*(d+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(jd).addScaledVector(El,d),p}intersectSphere(e,t){Ss.subVectors(e.center,this.origin);const n=Ss.dot(this.direction),i=Ss.dot(Ss)-n*n,r=e.radius*e.radius;if(i>r)return null;const o=Math.sqrt(r-i),a=n-o,c=n+o;return c<0?null:a<0?this.at(c,t):this.at(a,t)}intersectsSphere(e){return 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 n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,o,a,c;const l=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,d=this.origin;return l>=0?(n=(e.min.x-d.x)*l,i=(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,i=(e.min.x-d.x)*l),u>=0?(r=(e.min.y-d.y)*u,o=(e.max.y-d.y)*u):(r=(e.max.y-d.y)*u,o=(e.min.y-d.y)*u),n>o||r>i||((r>n||isNaN(n))&&(n=r),(o<i||isNaN(i))&&(i=o),h>=0?(a=(e.min.z-d.z)*h,c=(e.max.z-d.z)*h):(a=(e.max.z-d.z)*h,c=(e.min.z-d.z)*h),n>c||a>i)||((a>n||n!==n)&&(n=a),(c<i||i!==i)&&(i=c),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,Ss)!==null}intersectTriangle(e,t,n,i,r){Qd.subVectors(t,e),Cl.subVectors(n,e),ep.crossVectors(Qd,Cl);let o=this.direction.dot(ep),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;ks.subVectors(this.origin,e);const c=a*this.direction.dot(Cl.crossVectors(ks,Cl));if(c<0)return null;const l=a*this.direction.dot(Qd.cross(ks));if(l<0||c+l>o)return null;const u=-a*ks.dot(ep);return u<0?null:this.at(u/o,r)}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 Fe{constructor(e,t,n,i,r,o,a,c,l,u,h,d,p,f,x,m){Fe.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,n,i,r,o,a,c,l,u,h,d,p,f,x,m)}set(e,t,n,i,r,o,a,c,l,u,h,d,p,f,x,m){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=r,g[5]=o,g[9]=a,g[13]=c,g[2]=l,g[6]=u,g[10]=h,g[14]=d,g[3]=p,g[7]=f,g[11]=x,g[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 Fe().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[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,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/vo.setFromMatrixColumn(e,0).length(),r=1/vo.setFromMatrixColumn(e,1).length(),o=1/vo.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,r=e.z,o=Math.cos(n),a=Math.sin(n),c=Math.cos(i),l=Math.sin(i),u=Math.cos(r),h=Math.sin(r);if(e.order==="XYZ"){const d=o*u,p=o*h,f=a*u,x=a*h;t[0]=c*u,t[4]=-c*h,t[8]=l,t[1]=p+f*l,t[5]=d-x*l,t[9]=-a*c,t[2]=x-d*l,t[6]=f+p*l,t[10]=o*c}else if(e.order==="YXZ"){const d=c*u,p=c*h,f=l*u,x=l*h;t[0]=d+x*a,t[4]=f*a-p,t[8]=o*l,t[1]=o*h,t[5]=o*u,t[9]=-a,t[2]=p*a-f,t[6]=x+d*a,t[10]=o*c}else if(e.order==="ZXY"){const d=c*u,p=c*h,f=l*u,x=l*h;t[0]=d-x*a,t[4]=-o*h,t[8]=f+p*a,t[1]=p+f*a,t[5]=o*u,t[9]=x-d*a,t[2]=-o*l,t[6]=a,t[10]=o*c}else if(e.order==="ZYX"){const d=o*u,p=o*h,f=a*u,x=a*h;t[0]=c*u,t[4]=f*l-p,t[8]=d*l+x,t[1]=c*h,t[5]=x*l+d,t[9]=p*l-f,t[2]=-l,t[6]=a*c,t[10]=o*c}else if(e.order==="YZX"){const d=o*c,p=o*l,f=a*c,x=a*l;t[0]=c*u,t[4]=x-d*h,t[8]=f*h+p,t[1]=h,t[5]=o*u,t[9]=-a*u,t[2]=-l*u,t[6]=p*h+f,t[10]=d-x*h}else if(e.order==="XZY"){const d=o*c,p=o*l,f=a*c,x=a*l;t[0]=c*u,t[4]=-h,t[8]=l*u,t[1]=d*h+x,t[5]=o*u,t[9]=p*h-f,t[2]=f*h-p,t[6]=a*u,t[10]=x*h+d}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(HA,e,WA)}lookAt(e,t,n){const i=this.elements;return gi.subVectors(e,t),gi.lengthSq()===0&&(gi.z=1),gi.normalize(),Gs.crossVectors(n,gi),Gs.lengthSq()===0&&(Math.abs(n.z)===1?gi.x+=1e-4:gi.z+=1e-4,gi.normalize(),Gs.crossVectors(n,gi)),Gs.normalize(),Rl.crossVectors(gi,Gs),i[0]=Gs.x,i[4]=Rl.x,i[8]=gi.x,i[1]=Gs.y,i[5]=Rl.y,i[9]=gi.y,i[2]=Gs.z,i[6]=Rl.z,i[10]=gi.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,o=n[0],a=n[4],c=n[8],l=n[12],u=n[1],h=n[5],d=n[9],p=n[13],f=n[2],x=n[6],m=n[10],g=n[14],y=n[3],_=n[7],v=n[11],I=n[15],T=i[0],w=i[4],C=i[8],F=i[12],M=i[1],b=i[5],G=i[9],W=i[13],$=i[2],ie=i[6],q=i[10],he=i[14],Q=i[3],we=i[7],Ne=i[11],Ee=i[15];return r[0]=o*T+a*M+c*$+l*Q,r[4]=o*w+a*b+c*ie+l*we,r[8]=o*C+a*G+c*q+l*Ne,r[12]=o*F+a*W+c*he+l*Ee,r[1]=u*T+h*M+d*$+p*Q,r[5]=u*w+h*b+d*ie+p*we,r[9]=u*C+h*G+d*q+p*Ne,r[13]=u*F+h*W+d*he+p*Ee,r[2]=f*T+x*M+m*$+g*Q,r[6]=f*w+x*b+m*ie+g*we,r[10]=f*C+x*G+m*q+g*Ne,r[14]=f*F+x*W+m*he+g*Ee,r[3]=y*T+_*M+v*$+I*Q,r[7]=y*w+_*b+v*ie+I*we,r[11]=y*C+_*G+v*q+I*Ne,r[15]=y*F+_*W+v*he+I*Ee,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],n=e[4],i=e[8],r=e[12],o=e[1],a=e[5],c=e[9],l=e[13],u=e[2],h=e[6],d=e[10],p=e[14],f=e[3],x=e[7],m=e[11],g=e[15];return f*(+r*c*h-i*l*h-r*a*d+n*l*d+i*a*p-n*c*p)+x*(+t*c*p-t*l*d+r*o*d-i*o*p+i*l*u-r*c*u)+m*(+t*l*h-t*a*p-r*o*h+n*o*p+r*a*u-n*l*u)+g*(-i*a*u-t*c*h+t*a*d+i*o*h-n*o*d+n*c*u)}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,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],h=e[9],d=e[10],p=e[11],f=e[12],x=e[13],m=e[14],g=e[15],y=h*m*l-x*d*l+x*c*p-a*m*p-h*c*g+a*d*g,_=f*d*l-u*m*l-f*c*p+o*m*p+u*c*g-o*d*g,v=u*x*l-f*h*l+f*a*p-o*x*p-u*a*g+o*h*g,I=f*h*c-u*x*c-f*a*d+o*x*d+u*a*m-o*h*m,T=t*y+n*_+i*v+r*I;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/T;return e[0]=y*w,e[1]=(x*d*r-h*m*r-x*i*p+n*m*p+h*i*g-n*d*g)*w,e[2]=(a*m*r-x*c*r+x*i*l-n*m*l-a*i*g+n*c*g)*w,e[3]=(h*c*r-a*d*r-h*i*l+n*d*l+a*i*p-n*c*p)*w,e[4]=_*w,e[5]=(u*m*r-f*d*r+f*i*p-t*m*p-u*i*g+t*d*g)*w,e[6]=(f*c*r-o*m*r-f*i*l+t*m*l+o*i*g-t*c*g)*w,e[7]=(o*d*r-u*c*r+u*i*l-t*d*l-o*i*p+t*c*p)*w,e[8]=v*w,e[9]=(f*h*r-u*x*r-f*n*p+t*x*p+u*n*g-t*h*g)*w,e[10]=(o*x*r-f*a*r+f*n*l-t*x*l-o*n*g+t*a*g)*w,e[11]=(u*a*r-o*h*r-u*n*l+t*h*l+o*n*p-t*a*p)*w,e[12]=I*w,e[13]=(u*x*i-f*h*i+f*n*d-t*x*d-u*n*m+t*h*m)*w,e[14]=(f*a*i-o*x*i-f*n*c+t*x*c+o*n*m-t*a*m)*w,e[15]=(o*h*i-u*a*i+u*n*c-t*h*c-o*n*d+t*a*d)*w,this}scale(e){const t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),r=1-n,o=e.x,a=e.y,c=e.z,l=r*o,u=r*a;return this.set(l*o+n,l*a-i*c,l*c+i*a,0,l*a+i*c,u*a+n,u*c-i*o,0,l*c-i*a,u*c+i*o,r*c*c+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,o){return this.set(1,n,r,0,e,1,o,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,r=t._x,o=t._y,a=t._z,c=t._w,l=r+r,u=o+o,h=a+a,d=r*l,p=r*u,f=r*h,x=o*u,m=o*h,g=a*h,y=c*l,_=c*u,v=c*h,I=n.x,T=n.y,w=n.z;return i[0]=(1-(x+g))*I,i[1]=(p+v)*I,i[2]=(f-_)*I,i[3]=0,i[4]=(p-v)*T,i[5]=(1-(d+g))*T,i[6]=(m+y)*T,i[7]=0,i[8]=(f+_)*w,i[9]=(m-y)*w,i[10]=(1-(d+x))*w,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let r=vo.set(i[0],i[1],i[2]).length();const o=vo.set(i[4],i[5],i[6]).length(),a=vo.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),e.x=i[12],e.y=i[13],e.z=i[14],$i.copy(this);const l=1/r,u=1/o,h=1/a;return $i.elements[0]*=l,$i.elements[1]*=l,$i.elements[2]*=l,$i.elements[4]*=u,$i.elements[5]*=u,$i.elements[6]*=u,$i.elements[8]*=h,$i.elements[9]*=h,$i.elements[10]*=h,t.setFromRotationMatrix($i),n.x=r,n.y=o,n.z=a,this}makePerspective(e,t,n,i,r,o,a=Di){const c=this.elements,l=2*r/(t-e),u=2*r/(n-i),h=(t+e)/(t-e),d=(n+i)/(n-i);let p,f;if(a===Di)p=-(o+r)/(o-r),f=-2*o*r/(o-r);else if(a===Qr)p=-o/(o-r),f=-o*r/(o-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=l,c[4]=0,c[8]=h,c[12]=0,c[1]=0,c[5]=u,c[9]=d,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=f,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,r,o,a=Di){const c=this.elements,l=1/(t-e),u=1/(n-i),h=1/(o-r),d=(t+e)*l,p=(n+i)*u;let f,x;if(a===Di)f=(o+r)*h,x=-2*h;else if(a===Qr)f=r*h,x=-1*h;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=2*l,c[4]=0,c[8]=0,c[12]=-d,c[1]=0,c[5]=2*u,c[9]=0,c[13]=-p,c[2]=0,c[6]=0,c[10]=x,c[14]=-f,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const vo=new E,$i=new Fe,HA=new E(0,0,0),WA=new E(1,1,1),Gs=new E,Rl=new E,gi=new E,T0=new Fe,b0=new Qn;class ui{constructor(e=0,t=0,n=0,i=ui.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,r=i[0],o=i[4],a=i[8],c=i[1],l=i[5],u=i[9],h=i[2],d=i[6],p=i[10];switch(t){case"XYZ":this._y=Math.asin(jt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,p),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-jt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,p),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin(jt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,p),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-jt(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(jt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(a,p));break;case"XZY":this._z=Math.asin(-jt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-u,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return T0.makeRotationFromQuaternion(e),this.setFromRotationMatrix(T0,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return b0.setFromEuler(this),this.setFromQuaternion(b0,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}}ui.DEFAULT_ORDER="XYZ";class $c{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 XA=0;const w0=new E,Mo=new Qn,Ts=new Fe,Il=new E,Pa=new E,qA=new E,$A=new Qn,A0=new E(1,0,0),N0=new E(0,1,0),E0=new E(0,0,1),C0={type:"added"},YA={type:"removed"},So={type:"childadded",child:null},tp={type:"childremoved",child:null};class yt extends Ai{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:XA++}),this.uuid=bi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=yt.DEFAULT_UP.clone();const e=new E,t=new ui,n=new Qn,i=new E(1,1,1);function r(){n.setFromEuler(t,!1)}function o(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Fe},normalMatrix:{value:new Ke}}),this.matrix=new Fe,this.matrixWorld=new Fe,this.matrixAutoUpdate=yt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=yt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new $c,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Mo.setFromAxisAngle(e,t),this.quaternion.multiply(Mo),this}rotateOnWorldAxis(e,t){return Mo.setFromAxisAngle(e,t),this.quaternion.premultiply(Mo),this}rotateX(e){return this.rotateOnAxis(A0,e)}rotateY(e){return this.rotateOnAxis(N0,e)}rotateZ(e){return this.rotateOnAxis(E0,e)}translateOnAxis(e,t){return w0.copy(e).applyQuaternion(this.quaternion),this.position.add(w0.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(A0,e)}translateY(e){return this.translateOnAxis(N0,e)}translateZ(e){return this.translateOnAxis(E0,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ts.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Il.copy(e):Il.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),Pa.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ts.lookAt(Pa,Il,this.up):Ts.lookAt(Il,Pa,this.up),this.quaternion.setFromRotationMatrix(Ts),i&&(Ts.extractRotation(i.matrixWorld),Mo.setFromRotationMatrix(Ts),this.quaternion.premultiply(Mo.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(C0),So.child=e,this.dispatchEvent(So),So.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(YA),tp.child=e,this.dispatchEvent(tp),tp.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),Ts.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Ts.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ts),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(C0),So.child=e,this.dispatchEvent(So),So.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){const o=this.children[n].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const i=this.children;for(let r=0,o=i.length;r<o;r++)i[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Pa,e,qA),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Pa,$A,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 n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].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),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 n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const i=this.children;for(let r=0,o=i.length;r<o;r++)i[r].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));function r(a,c){return a[c.uuid]===void 0&&(a[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const c=a.shapes;if(Array.isArray(c))for(let l=0,u=c.length;l<u;l++){const h=c[l];r(e.shapes,h)}else r(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let c=0,l=this.material.length;c<l;c++)a.push(r(e.materials,this.material[c]));i.material=a}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){const c=this.animations[a];i.animations.push(r(e.animations,c))}}if(t){const a=o(e.geometries),c=o(e.materials),l=o(e.textures),u=o(e.images),h=o(e.shapes),d=o(e.skeletons),p=o(e.animations),f=o(e.nodes);a.length>0&&(n.geometries=a),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),u.length>0&&(n.images=u),h.length>0&&(n.shapes=h),d.length>0&&(n.skeletons=d),p.length>0&&(n.animations=p),f.length>0&&(n.nodes=f)}return n.object=i,n;function o(a){const c=[];for(const l in a){const u=a[l];delete u.metadata,c.push(u)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const i=e.children[n];this.add(i.clone())}return this}}yt.DEFAULT_UP=new E(0,1,0);yt.DEFAULT_MATRIX_AUTO_UPDATE=!0;yt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Yi=new E,bs=new E,np=new E,ws=new E,To=new E,bo=new E,R0=new E,ip=new E,sp=new E,rp=new E,op=new st,ap=new st,cp=new st;class Zn{constructor(e=new E,t=new E,n=new E){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),Yi.subVectors(e,t),i.cross(Yi);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){Yi.subVectors(i,t),bs.subVectors(n,t),np.subVectors(e,t);const o=Yi.dot(Yi),a=Yi.dot(bs),c=Yi.dot(np),l=bs.dot(bs),u=bs.dot(np),h=o*l-a*a;if(h===0)return r.set(0,0,0),null;const d=1/h,p=(l*c-a*u)*d,f=(o*u-a*c)*d;return r.set(1-p-f,f,p)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,ws)===null?!1:ws.x>=0&&ws.y>=0&&ws.x+ws.y<=1}static getInterpolation(e,t,n,i,r,o,a,c){return this.getBarycoord(e,t,n,i,ws)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(r,ws.x),c.addScaledVector(o,ws.y),c.addScaledVector(a,ws.z),c)}static getInterpolatedAttribute(e,t,n,i,r,o){return op.setScalar(0),ap.setScalar(0),cp.setScalar(0),op.fromBufferAttribute(e,t),ap.fromBufferAttribute(e,n),cp.fromBufferAttribute(e,i),o.setScalar(0),o.addScaledVector(op,r.x),o.addScaledVector(ap,r.y),o.addScaledVector(cp,r.z),o}static isFrontFacing(e,t,n,i){return Yi.subVectors(n,t),bs.subVectors(e,t),Yi.cross(bs).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),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 Yi.subVectors(this.c,this.b),bs.subVectors(this.a,this.b),Yi.cross(bs).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Zn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Zn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return Zn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return Zn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Zn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,r=this.c;let o,a;To.subVectors(i,n),bo.subVectors(r,n),ip.subVectors(e,n);const c=To.dot(ip),l=bo.dot(ip);if(c<=0&&l<=0)return t.copy(n);sp.subVectors(e,i);const u=To.dot(sp),h=bo.dot(sp);if(u>=0&&h<=u)return t.copy(i);const d=c*h-u*l;if(d<=0&&c>=0&&u<=0)return o=c/(c-u),t.copy(n).addScaledVector(To,o);rp.subVectors(e,r);const p=To.dot(rp),f=bo.dot(rp);if(f>=0&&p<=f)return t.copy(r);const x=p*l-c*f;if(x<=0&&l>=0&&f<=0)return a=l/(l-f),t.copy(n).addScaledVector(bo,a);const m=u*f-p*h;if(m<=0&&h-u>=0&&p-f>=0)return R0.subVectors(r,i),a=(h-u)/(h-u+(p-f)),t.copy(i).addScaledVector(R0,a);const g=1/(m+x+d);return o=x*g,a=d*g,t.copy(n).addScaledVector(To,o).addScaledVector(bo,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const Vy={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},Hs={h:0,s:0,l:0},Pl={h:0,s:0,l:0};function lp(s,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?s+(e-s)*6*t:t<1/2?e:t<2/3?s+(e-s)*6*(2/3-t):s}class _e{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=kn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,gt.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=gt.workingColorSpace){return this.r=e,this.g=t,this.b=n,gt.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=gt.workingColorSpace){if(e=em(e,1),t=jt(t,0,1),n=jt(n,0,1),t===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+t):n+t-n*t,o=2*n-r;this.r=lp(o,r,e+1/3),this.g=lp(o,r,e),this.b=lp(o,r,e-1/3)}return gt.toWorkingColorSpace(this,i),this}setStyle(e,t=kn){function n(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=i[1],o=r.length;if(o===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(r,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=kn){const n=Vy[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.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=jo(e.r),this.g=jo(e.g),this.b=jo(e.b),this}copyLinearToSRGB(e){return this.r=$d(e.r),this.g=$d(e.g),this.b=$d(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=kn){return gt.fromWorkingColorSpace(Bn.copy(this),e),Math.round(jt(Bn.r*255,0,255))*65536+Math.round(jt(Bn.g*255,0,255))*256+Math.round(jt(Bn.b*255,0,255))}getHexString(e=kn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=gt.workingColorSpace){gt.fromWorkingColorSpace(Bn.copy(this),t);const n=Bn.r,i=Bn.g,r=Bn.b,o=Math.max(n,i,r),a=Math.min(n,i,r);let c,l;const u=(a+o)/2;if(a===o)c=0,l=0;else{const h=o-a;switch(l=u<=.5?h/(o+a):h/(2-o-a),o){case n:c=(i-r)/h+(i<r?6:0);break;case i:c=(r-n)/h+2;break;case r:c=(n-i)/h+4;break}c/=6}return e.h=c,e.s=l,e.l=u,e}getRGB(e,t=gt.workingColorSpace){return gt.fromWorkingColorSpace(Bn.copy(this),t),e.r=Bn.r,e.g=Bn.g,e.b=Bn.b,e}getStyle(e=kn){gt.fromWorkingColorSpace(Bn.copy(this),e);const t=Bn.r,n=Bn.g,i=Bn.b;return e!==kn?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(Hs),this.setHSL(Hs.h+e,Hs.s+t,Hs.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Hs),e.getHSL(Pl);const n=Ka(Hs.h,Pl.h,t),i=Ka(Hs.s,Pl.s,t),r=Ka(Hs.l,Pl.l,t);return this.setHSL(n,i,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*i,this.g=r[1]*t+r[4]*n+r[7]*i,this.b=r[2]*t+r[5]*n+r[8]*i,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 Bn=new _e;_e.NAMES=Vy;let ZA=0;class mn extends Ai{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:ZA++}),this.uuid=bi(),this.name="",this.type="Material",this.blending=Ps,this.side=fs,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Ou,this.blendDst=Vu,this.blendEquation=Zs,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new _e(0,0,0),this.blendAlpha=0,this.depthFunc=nr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=ih,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=$s,this.stencilZFail=$s,this.stencilZPass=$s,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.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}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Ps&&(n.blending=this.blending),this.side!==fs&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==Ou&&(n.blendSrc=this.blendSrc),this.blendDst!==Vu&&(n.blendDst=this.blendDst),this.blendEquation!==Zs&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==nr&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==ih&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==$s&&(n.stencilFail=this.stencilFail),this.stencilZFail!==$s&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==$s&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(r){const o=[];for(const a in r){const c=r[a];delete c.metadata,o.push(c)}return o}if(t){const r=i(e.textures),o=i(e.images);r.length>0&&(n.textures=r),o.length>0&&(n.images=o)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const i=t.length;n=new Array(i);for(let r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class ss extends mn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new _e(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 ui,this.combine=fa,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 Es=JA();function JA(){const s=new ArrayBuffer(4),e=new Float32Array(s),t=new Uint32Array(s),n=new Uint32Array(512),i=new Uint32Array(512);for(let c=0;c<256;++c){const l=c-127;l<-27?(n[c]=0,n[c|256]=32768,i[c]=24,i[c|256]=24):l<-14?(n[c]=1024>>-l-14,n[c|256]=1024>>-l-14|32768,i[c]=-l-1,i[c|256]=-l-1):l<=15?(n[c]=l+15<<10,n[c|256]=l+15<<10|32768,i[c]=13,i[c|256]=13):l<128?(n[c]=31744,n[c|256]=64512,i[c]=24,i[c|256]=24):(n[c]=31744,n[c|256]=64512,i[c]=13,i[c|256]=13)}const r=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,u=0;for(;(l&8388608)===0;)l<<=1,u-=8388608;l&=-8388609,u+=947912704,r[c]=l|u}for(let c=1024;c<2048;++c)r[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)o[c]=c<<23;o[31]=1199570944,o[32]=2147483648;for(let c=33;c<63;++c)o[c]=2147483648+(c-32<<23);o[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(a[c]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:i,mantissaTable:r,exponentTable:o,offsetTable:a}}function si(s){Math.abs(s)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),s=jt(s,-65504,65504),Es.floatView[0]=s;const e=Es.uint32View[0],t=e>>23&511;return Es.baseTable[t]+((e&8388607)>>Es.shiftTable[t])}function Za(s){const e=s>>10;return Es.uint32View[0]=Es.mantissaTable[Es.offsetTable[e]+(s&1023)]+Es.exponentTable[e],Es.floatView[0]}const By={toHalfFloat:si,fromHalfFloat:Za},an=new E,Ll=new J;class At{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=sa,this.updateRanges=[],this.gpuType=Gn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Ll.fromBufferAttribute(this,t),Ll.applyMatrix3(e),this.setXY(t,Ll.x,Ll.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)an.fromBufferAttribute(this,t),an.applyMatrix3(e),this.setXYZ(t,an.x,an.y,an.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)an.fromBufferAttribute(this,t),an.applyMatrix4(e),this.setXYZ(t,an.x,an.y,an.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)an.fromBufferAttribute(this,t),an.applyNormalMatrix(e),this.setXYZ(t,an.x,an.y,an.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)an.fromBufferAttribute(this,t),an.transformDirection(e),this.setXYZ(t,an.x,an.y,an.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=Yn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=ut(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Yn(t,this.array)),t}setX(e,t){return this.normalized&&(t=ut(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Yn(t,this.array)),t}setY(e,t){return this.normalized&&(t=ut(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=Yn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=ut(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=Yn(t,this.array)),t}setW(e,t){return this.normalized&&(t=ut(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=ut(t,this.array),n=ut(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=ut(t,this.array),n=ut(n,this.array),i=ut(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e*=this.itemSize,this.normalized&&(t=ut(t,this.array),n=ut(n,this.array),i=ut(i,this.array),r=ut(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,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!==sa&&(e.usage=this.usage),e}}class KA extends At{constructor(e,t,n){super(new Int8Array(e),t,n)}}class jA extends At{constructor(e,t,n){super(new Uint8Array(e),t,n)}}class QA extends At{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}}class e1 extends At{constructor(e,t,n){super(new Int16Array(e),t,n)}}class Wh extends At{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class t1 extends At{constructor(e,t,n){super(new Int32Array(e),t,n)}}class tm extends At{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class zy extends At{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=Za(this.array[e*this.itemSize]);return this.normalized&&(t=Yn(t,this.array)),t}setX(e,t){return this.normalized&&(t=ut(t,this.array)),this.array[e*this.itemSize]=si(t),this}getY(e){let t=Za(this.array[e*this.itemSize+1]);return this.normalized&&(t=Yn(t,this.array)),t}setY(e,t){return this.normalized&&(t=ut(t,this.array)),this.array[e*this.itemSize+1]=si(t),this}getZ(e){let t=Za(this.array[e*this.itemSize+2]);return this.normalized&&(t=Yn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=ut(t,this.array)),this.array[e*this.itemSize+2]=si(t),this}getW(e){let t=Za(this.array[e*this.itemSize+3]);return this.normalized&&(t=Yn(t,this.array)),t}setW(e,t){return this.normalized&&(t=ut(t,this.array)),this.array[e*this.itemSize+3]=si(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=ut(t,this.array),n=ut(n,this.array)),this.array[e+0]=si(t),this.array[e+1]=si(n),this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=ut(t,this.array),n=ut(n,this.array),i=ut(i,this.array)),this.array[e+0]=si(t),this.array[e+1]=si(n),this.array[e+2]=si(i),this}setXYZW(e,t,n,i,r){return e*=this.itemSize,this.normalized&&(t=ut(t,this.array),n=ut(n,this.array),i=ut(i,this.array),r=ut(r,this.array)),this.array[e+0]=si(t),this.array[e+1]=si(n),this.array[e+2]=si(i),this.array[e+3]=si(r),this}}class Ve extends At{constructor(e,t,n){super(new Float32Array(e),t,n)}}let n1=0;const Ei=new Fe,up=new yt,wo=new E,xi=new Hn,La=new Hn,_n=new E;class at extends Ai{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:n1++}),this.uuid=bi(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Uy(e)?tm:Wh)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const r=new Ke().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Ei.makeRotationFromQuaternion(e),this.applyMatrix4(Ei),this}rotateX(e){return Ei.makeRotationX(e),this.applyMatrix4(Ei),this}rotateY(e){return Ei.makeRotationY(e),this.applyMatrix4(Ei),this}rotateZ(e){return Ei.makeRotationZ(e),this.applyMatrix4(Ei),this}translate(e,t,n){return Ei.makeTranslation(e,t,n),this.applyMatrix4(Ei),this}scale(e,t,n){return Ei.makeScale(e,t,n),this.applyMatrix4(Ei),this}lookAt(e){return up.lookAt(e),up.updateMatrix(),this.applyMatrix4(up.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(wo).negate(),this.translate(wo.x,wo.y,wo.z),this}setFromPoints(e){const t=[];for(let n=0,i=e.length;n<i;n++){const r=e[n];t.push(r.x,r.y,r.z||0)}return this.setAttribute("position",new Ve(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Hn);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new E(-1/0,-1/0,-1/0),new E(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){const r=t[n];xi.setFromBufferAttribute(r),this.morphTargetsRelative?(_n.addVectors(this.boundingBox.min,xi.min),this.boundingBox.expandByPoint(_n),_n.addVectors(this.boundingBox.max,xi.max),this.boundingBox.expandByPoint(_n)):(this.boundingBox.expandByPoint(xi.min),this.boundingBox.expandByPoint(xi.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Dn);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new E,1/0);return}if(e){const n=this.boundingSphere.center;if(xi.setFromBufferAttribute(e),t)for(let r=0,o=t.length;r<o;r++){const a=t[r];La.setFromBufferAttribute(a),this.morphTargetsRelative?(_n.addVectors(xi.min,La.min),xi.expandByPoint(_n),_n.addVectors(xi.max,La.max),xi.expandByPoint(_n)):(xi.expandByPoint(La.min),xi.expandByPoint(La.max))}xi.getCenter(n);let i=0;for(let r=0,o=e.count;r<o;r++)_n.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(_n));if(t)for(let r=0,o=t.length;r<o;r++){const a=t[r],c=this.morphTargetsRelative;for(let l=0,u=a.count;l<u;l++)_n.fromBufferAttribute(a,l),c&&(wo.fromBufferAttribute(e,l),_n.add(wo)),i=Math.max(i,n.distanceToSquared(_n))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,i=t.normal,r=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new At(new Float32Array(4*n.count),4));const o=this.getAttribute("tangent"),a=[],c=[];for(let C=0;C<n.count;C++)a[C]=new E,c[C]=new E;const l=new E,u=new E,h=new E,d=new J,p=new J,f=new J,x=new E,m=new E;function g(C,F,M){l.fromBufferAttribute(n,C),u.fromBufferAttribute(n,F),h.fromBufferAttribute(n,M),d.fromBufferAttribute(r,C),p.fromBufferAttribute(r,F),f.fromBufferAttribute(r,M),u.sub(l),h.sub(l),p.sub(d),f.sub(d);const b=1/(p.x*f.y-f.x*p.y);isFinite(b)&&(x.copy(u).multiplyScalar(f.y).addScaledVector(h,-p.y).multiplyScalar(b),m.copy(h).multiplyScalar(p.x).addScaledVector(u,-f.x).multiplyScalar(b),a[C].add(x),a[F].add(x),a[M].add(x),c[C].add(m),c[F].add(m),c[M].add(m))}let y=this.groups;y.length===0&&(y=[{start:0,count:e.count}]);for(let C=0,F=y.length;C<F;++C){const M=y[C],b=M.start,G=M.count;for(let W=b,$=b+G;W<$;W+=3)g(e.getX(W+0),e.getX(W+1),e.getX(W+2))}const _=new E,v=new E,I=new E,T=new E;function w(C){I.fromBufferAttribute(i,C),T.copy(I);const F=a[C];_.copy(F),_.sub(I.multiplyScalar(I.dot(F))).normalize(),v.crossVectors(T,F);const b=v.dot(c[C])<0?-1:1;o.setXYZW(C,_.x,_.y,_.z,b)}for(let C=0,F=y.length;C<F;++C){const M=y[C],b=M.start,G=M.count;for(let W=b,$=b+G;W<$;W+=3)w(e.getX(W+0)),w(e.getX(W+1)),w(e.getX(W+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new At(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,p=n.count;d<p;d++)n.setXYZ(d,0,0,0);const i=new E,r=new E,o=new E,a=new E,c=new E,l=new E,u=new E,h=new E;if(e)for(let d=0,p=e.count;d<p;d+=3){const f=e.getX(d+0),x=e.getX(d+1),m=e.getX(d+2);i.fromBufferAttribute(t,f),r.fromBufferAttribute(t,x),o.fromBufferAttribute(t,m),u.subVectors(o,r),h.subVectors(i,r),u.cross(h),a.fromBufferAttribute(n,f),c.fromBufferAttribute(n,x),l.fromBufferAttribute(n,m),a.add(u),c.add(u),l.add(u),n.setXYZ(f,a.x,a.y,a.z),n.setXYZ(x,c.x,c.y,c.z),n.setXYZ(m,l.x,l.y,l.z)}else for(let d=0,p=t.count;d<p;d+=3)i.fromBufferAttribute(t,d+0),r.fromBufferAttribute(t,d+1),o.fromBufferAttribute(t,d+2),u.subVectors(o,r),h.subVectors(i,r),u.cross(h),n.setXYZ(d+0,u.x,u.y,u.z),n.setXYZ(d+1,u.x,u.y,u.z),n.setXYZ(d+2,u.x,u.y,u.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)_n.fromBufferAttribute(e,t),_n.normalize(),e.setXYZ(t,_n.x,_n.y,_n.z)}toNonIndexed(){function e(a,c){const l=a.array,u=a.itemSize,h=a.normalized,d=new l.constructor(c.length*u);let p=0,f=0;for(let x=0,m=c.length;x<m;x++){a.isInterleavedBufferAttribute?p=c[x]*a.data.stride+a.offset:p=c[x]*u;for(let g=0;g<u;g++)d[f++]=l[p++]}return new At(d,u,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new at,n=this.index.array,i=this.attributes;for(const a in i){const c=i[a],l=e(c,n);t.setAttribute(a,l)}const r=this.morphAttributes;for(const a in r){const c=[],l=r[a];for(let u=0,h=l.length;u<h;u++){const d=l[u],p=e(d,n);c.push(p)}t.morphAttributes[a]=c}t.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,c=o.length;a<c;a++){const l=o[a];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){const e={metadata:{version:4.6,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 c=this.parameters;for(const l in c)c[l]!==void 0&&(e[l]=c[l]);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 n=this.attributes;for(const c in n){const l=n[c];e.data.attributes[c]=l.toJSON(e.data)}const i={};let r=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],u=[];for(let h=0,d=l.length;h<d;h++){const p=l[h];u.push(p.toJSON(e.data))}u.length>0&&(i[c]=u,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),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 n=e.index;n!==null&&this.setIndex(n.clone(t));const i=e.attributes;for(const l in i){const u=i[l];this.setAttribute(l,u.clone(t))}const r=e.morphAttributes;for(const l in r){const u=[],h=r[l];for(let d=0,p=h.length;d<p;d++)u.push(h[d].clone(t));this.morphAttributes[l]=u}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let l=0,u=o.length;l<u;l++){const h=o[l];this.addGroup(h.start,h.count,h.materialIndex)}const a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const I0=new Fe,Tr=new io,Dl=new Dn,P0=new E,Ul=new E,Fl=new E,Ol=new E,hp=new E,Vl=new E,L0=new E,Bl=new E;class kt extends yt{constructor(e=new at,t=new ss){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,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,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r<o;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(e,t){const n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,o=n.morphTargetsRelative;t.fromBufferAttribute(i,e);const a=this.morphTargetInfluences;if(r&&a){Vl.set(0,0,0);for(let c=0,l=r.length;c<l;c++){const u=a[c],h=r[c];u!==0&&(hp.fromBufferAttribute(h,e),o?Vl.addScaledVector(hp,u):Vl.addScaledVector(hp.sub(t),u))}t.add(Vl)}return t}raycast(e,t){const n=this.geometry,i=this.material,r=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Dl.copy(n.boundingSphere),Dl.applyMatrix4(r),Tr.copy(e.ray).recast(e.near),!(Dl.containsPoint(Tr.origin)===!1&&(Tr.intersectSphere(Dl,P0)===null||Tr.origin.distanceToSquared(P0)>(e.far-e.near)**2))&&(I0.copy(r).invert(),Tr.copy(e.ray).applyMatrix4(I0),!(n.boundingBox!==null&&Tr.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Tr)))}_computeIntersections(e,t,n){let i;const r=this.geometry,o=this.material,a=r.index,c=r.attributes.position,l=r.attributes.uv,u=r.attributes.uv1,h=r.attributes.normal,d=r.groups,p=r.drawRange;if(a!==null)if(Array.isArray(o))for(let f=0,x=d.length;f<x;f++){const m=d[f],g=o[m.materialIndex],y=Math.max(m.start,p.start),_=Math.min(a.count,Math.min(m.start+m.count,p.start+p.count));for(let v=y,I=_;v<I;v+=3){const T=a.getX(v),w=a.getX(v+1),C=a.getX(v+2);i=zl(this,g,e,n,l,u,h,T,w,C),i&&(i.faceIndex=Math.floor(v/3),i.face.materialIndex=m.materialIndex,t.push(i))}}else{const f=Math.max(0,p.start),x=Math.min(a.count,p.start+p.count);for(let m=f,g=x;m<g;m+=3){const y=a.getX(m),_=a.getX(m+1),v=a.getX(m+2);i=zl(this,o,e,n,l,u,h,y,_,v),i&&(i.faceIndex=Math.floor(m/3),t.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let f=0,x=d.length;f<x;f++){const m=d[f],g=o[m.materialIndex],y=Math.max(m.start,p.start),_=Math.min(c.count,Math.min(m.start+m.count,p.start+p.count));for(let v=y,I=_;v<I;v+=3){const T=v,w=v+1,C=v+2;i=zl(this,g,e,n,l,u,h,T,w,C),i&&(i.faceIndex=Math.floor(v/3),i.face.materialIndex=m.materialIndex,t.push(i))}}else{const f=Math.max(0,p.start),x=Math.min(c.count,p.start+p.count);for(let m=f,g=x;m<g;m+=3){const y=m,_=m+1,v=m+2;i=zl(this,o,e,n,l,u,h,y,_,v),i&&(i.faceIndex=Math.floor(m/3),t.push(i))}}}}function i1(s,e,t,n,i,r,o,a){let c;if(e.side===ln?c=n.intersectTriangle(o,r,i,!0,a):c=n.intersectTriangle(i,r,o,e.side===fs,a),c===null)return null;Bl.copy(a),Bl.applyMatrix4(s.matrixWorld);const l=t.ray.origin.distanceTo(Bl);return l<t.near||l>t.far?null:{distance:l,point:Bl.clone(),object:s}}function zl(s,e,t,n,i,r,o,a,c,l){s.getVertexPosition(a,Ul),s.getVertexPosition(c,Fl),s.getVertexPosition(l,Ol);const u=i1(s,e,t,n,Ul,Fl,Ol,L0);if(u){const h=new E;Zn.getBarycoord(L0,Ul,Fl,Ol,h),i&&(u.uv=Zn.getInterpolatedAttribute(i,a,c,l,h,new J)),r&&(u.uv1=Zn.getInterpolatedAttribute(r,a,c,l,h,new J)),o&&(u.normal=Zn.getInterpolatedAttribute(o,a,c,l,h,new E),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));const d={a,b:c,c:l,normal:new E,materialIndex:0};Zn.getNormal(Ul,Fl,Ol,d.normal),u.face=d,u.barycoord=h}return u}class _s extends at{constructor(e=1,t=1,n=1,i=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:o};const a=this;i=Math.floor(i),r=Math.floor(r),o=Math.floor(o);const c=[],l=[],u=[],h=[];let d=0,p=0;f("z","y","x",-1,-1,n,t,e,o,r,0),f("z","y","x",1,-1,n,t,-e,o,r,1),f("x","z","y",1,1,e,n,t,i,o,2),f("x","z","y",1,-1,e,n,-t,i,o,3),f("x","y","z",1,-1,e,t,n,i,r,4),f("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(c),this.setAttribute("position",new Ve(l,3)),this.setAttribute("normal",new Ve(u,3)),this.setAttribute("uv",new Ve(h,2));function f(x,m,g,y,_,v,I,T,w,C,F){const M=v/w,b=I/C,G=v/2,W=I/2,$=T/2,ie=w+1,q=C+1;let he=0,Q=0;const we=new E;for(let Ne=0;Ne<q;Ne++){const Ee=Ne*b-W;for(let Qe=0;Qe<ie;Qe++){const ht=Qe*M-G;we[x]=ht*y,we[m]=Ee*_,we[g]=$,l.push(we.x,we.y,we.z),we[x]=0,we[m]=0,we[g]=T>0?1:-1,u.push(we.x,we.y,we.z),h.push(Qe/w),h.push(1-Ne/C),he+=1}}for(let Ne=0;Ne<C;Ne++)for(let Ee=0;Ee<w;Ee++){const Qe=d+Ee+ie*Ne,ht=d+Ee+ie*(Ne+1),ne=d+(Ee+1)+ie*(Ne+1),ue=d+(Ee+1)+ie*Ne;c.push(Qe,ht,ue),c.push(ht,ne,ue),Q+=6}a.addGroup(p,Q,F),p+=Q,d+=he}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new _s(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function oa(s){const e={};for(const t in s){e[t]={};for(const n in s[t]){const i=s[t][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=i.clone():Array.isArray(i)?e[t][n]=i.slice():e[t][n]=i}}return e}function $n(s){const e={};for(let t=0;t<s.length;t++){const n=oa(s[t]);for(const i in n)e[i]=n[i]}return e}function s1(s){const e=[];for(let t=0;t<s.length;t++)e.push(s[t].clone());return e}function ky(s){const e=s.getRenderTarget();return e===null?s.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:gt.workingColorSpace}const nm={clone:oa,merge:$n};var r1=`void main() {
6
6
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
7
7
  }`,o1=`void main() {
8
8
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
9
- }`;class ki extends mn{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=r1,this.fragmentShader=o1,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=oa(e.uniforms),this.uniformsGroups=s1(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const i in this.uniforms){const o=this.uniforms[i].value;o&&o.isTexture?t.uniforms[i]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[i]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[i]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[i]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[i]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[i]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[i]={type:"m4",value:o.toArray()}:t.uniforms[i]={value:o}}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 n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class Yc extends yt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Fe,this.projectionMatrix=new Fe,this.projectionMatrixInverse=new Fe,this.coordinateSystem=Di}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const Ws=new E,D0=new J,U0=new J;class hn extends Yc{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,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=ra*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(qr*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return ra*2*Math.atan(Math.tan(qr*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){Ws.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Ws.x,Ws.y).multiplyScalar(-e/Ws.z),Ws.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Ws.x,Ws.y).multiplyScalar(-e/Ws.z)}getViewSize(e,t){return this.getViewBounds(e,D0,U0),t.subVectors(U0,D0)}setViewOffset(e,t,n,i,r,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(qr*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,l=o.fullHeight;r+=o.offsetX*i/c,t-=o.offsetY*n/l,i*=o.width/c,n*=o.height/l}const a=this.filmOffset;a!==0&&(r+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem),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}}const Ao=-90,No=1;class Xh extends yt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new hn(Ao,No,e,t);i.layers=this.layers,this.add(i);const r=new hn(Ao,No,e,t);r.layers=this.layers,this.add(r);const o=new hn(Ao,No,e,t);o.layers=this.layers,this.add(o);const a=new hn(Ao,No,e,t);a.layers=this.layers,this.add(a);const c=new hn(Ao,No,e,t);c.layers=this.layers,this.add(c);const l=new hn(Ao,No,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,r,o,a,c]=t;for(const l of t)this.remove(l);if(e===Di)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===jr)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,o,a,c,l,u]=this.children,h=e.getRenderTarget(),d=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),f=e.xr.enabled;e.xr.enabled=!1;const x=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,i),e.render(t,r),e.setRenderTarget(n,1,i),e.render(t,o),e.setRenderTarget(n,2,i),e.render(t,a),e.setRenderTarget(n,3,i),e.render(t,c),e.setRenderTarget(n,4,i),e.render(t,l),n.texture.generateMipmaps=x,e.setRenderTarget(n,5,i),e.render(t,u),e.setRenderTarget(h,d,p),e.xr.enabled=f,n.texture.needsPMREMUpdate=!0}}class io extends Xt{constructor(e,t,n,i,r,o,a,c,l,u){e=e!==void 0?e:[],t=t!==void 0?t:wi,super(e,t,n,i,r,o,a,c,l,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class qh extends zi{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new io(i,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:Ut}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:`
9
+ }`;class ki extends mn{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=r1,this.fragmentShader=o1,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=oa(e.uniforms),this.uniformsGroups=s1(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const i in this.uniforms){const o=this.uniforms[i].value;o&&o.isTexture?t.uniforms[i]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[i]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[i]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[i]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[i]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[i]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[i]={type:"m4",value:o.toArray()}:t.uniforms[i]={value:o}}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 n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class Yc extends yt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Fe,this.projectionMatrix=new Fe,this.projectionMatrixInverse=new Fe,this.coordinateSystem=Di}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const Ws=new E,D0=new J,U0=new J;class hn extends Yc{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,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=ra*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan($r*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return ra*2*Math.atan(Math.tan($r*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){Ws.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Ws.x,Ws.y).multiplyScalar(-e/Ws.z),Ws.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Ws.x,Ws.y).multiplyScalar(-e/Ws.z)}getViewSize(e,t){return this.getViewBounds(e,D0,U0),t.subVectors(U0,D0)}setViewOffset(e,t,n,i,r,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan($r*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,l=o.fullHeight;r+=o.offsetX*i/c,t-=o.offsetY*n/l,i*=o.width/c,n*=o.height/l}const a=this.filmOffset;a!==0&&(r+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem),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}}const Ao=-90,No=1;class Xh extends yt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new hn(Ao,No,e,t);i.layers=this.layers,this.add(i);const r=new hn(Ao,No,e,t);r.layers=this.layers,this.add(r);const o=new hn(Ao,No,e,t);o.layers=this.layers,this.add(o);const a=new hn(Ao,No,e,t);a.layers=this.layers,this.add(a);const c=new hn(Ao,No,e,t);c.layers=this.layers,this.add(c);const l=new hn(Ao,No,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,r,o,a,c]=t;for(const l of t)this.remove(l);if(e===Di)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Qr)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,o,a,c,l,u]=this.children,h=e.getRenderTarget(),d=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),f=e.xr.enabled;e.xr.enabled=!1;const x=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,i),e.render(t,r),e.setRenderTarget(n,1,i),e.render(t,o),e.setRenderTarget(n,2,i),e.render(t,a),e.setRenderTarget(n,3,i),e.render(t,c),e.setRenderTarget(n,4,i),e.render(t,l),n.texture.generateMipmaps=x,e.setRenderTarget(n,5,i),e.render(t,u),e.setRenderTarget(h,d,p),e.xr.enabled=f,n.texture.needsPMREMUpdate=!0}}class so extends Xt{constructor(e,t,n,i,r,o,a,c,l,u){e=e!==void 0?e:[],t=t!==void 0?t:wi,super(e,t,n,i,r,o,a,c,l,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class qh extends zi{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new so(i,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:Ut}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:`
10
10
 
11
11
  varying vec3 vWorldDirection;
12
12
 
@@ -41,7 +41,7 @@
41
41
  gl_FragColor = texture2D( tEquirect, sampleUV );
42
42
 
43
43
  }
44
- `},i=new _s(5,5,5),r=new ki({name:"CubemapFromEquirect",uniforms:oa(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:ln,blending:Fi});r.uniforms.tEquirect.value=t;const o=new kt(i,r),a=t.minFilter;return t.minFilter===Jn&&(t.minFilter=Ut),new Xh(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,i){const r=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,i);e.setRenderTarget(r)}}const dp=new E,a1=new E,c1=new Ke;class cs{constructor(e=new E(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=dp.subVectors(n,t).cross(a1.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,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 n=e.delta(dp),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:t.copy(e.start).addScaledVector(n,r)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||c1.getNormalMatrix(e),i=this.coplanarPoint(dp).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),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 Tr=new Dn,kl=new E;class ga{constructor(e=new cs,t=new cs,n=new cs,i=new cs,r=new cs,o=new cs){this.planes=[e,t,n,i,r,o]}set(e,t,n,i,r,o){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(r),a[5].copy(o),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Di){const n=this.planes,i=e.elements,r=i[0],o=i[1],a=i[2],c=i[3],l=i[4],u=i[5],h=i[6],d=i[7],p=i[8],f=i[9],x=i[10],m=i[11],g=i[12],y=i[13],_=i[14],v=i[15];if(n[0].setComponents(c-r,d-l,m-p,v-g).normalize(),n[1].setComponents(c+r,d+l,m+p,v+g).normalize(),n[2].setComponents(c+o,d+u,m+f,v+y).normalize(),n[3].setComponents(c-o,d-u,m-f,v-y).normalize(),n[4].setComponents(c-a,d-h,m-x,v-_).normalize(),t===Di)n[5].setComponents(c+a,d+h,m+x,v+_).normalize();else if(t===jr)n[5].setComponents(a,h,x,_).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(),Tr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Tr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Tr)}intersectsSprite(e){return Tr.center.set(0,0,0),Tr.radius=.7071067811865476,Tr.applyMatrix4(e.matrixWorld),this.intersectsSphere(Tr)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const i=t[n];if(kl.x=i.normal.x>0?e.max.x:e.min.x,kl.y=i.normal.y>0?e.max.y:e.min.y,kl.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(kl)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function Gy(){let s=null,e=!1,t=null,n=null;function i(r,o){t(r,o),n=s.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&(n=s.requestAnimationFrame(i),e=!0)},stop:function(){s.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){s=r}}}function l1(s){const e=new WeakMap;function t(a,c){const l=a.array,u=a.usage,h=l.byteLength,d=s.createBuffer();s.bindBuffer(c,d),s.bufferData(c,l,u),a.onUploadCallback();let p;if(l instanceof Float32Array)p=s.FLOAT;else if(l instanceof Uint16Array)a.isFloat16BufferAttribute?p=s.HALF_FLOAT:p=s.UNSIGNED_SHORT;else if(l instanceof Int16Array)p=s.SHORT;else if(l instanceof Uint32Array)p=s.UNSIGNED_INT;else if(l instanceof Int32Array)p=s.INT;else if(l instanceof Int8Array)p=s.BYTE;else if(l instanceof Uint8Array)p=s.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)p=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:d,type:p,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:h}}function n(a,c,l){const u=c.array,h=c.updateRanges;if(s.bindBuffer(l,a),h.length===0)s.bufferSubData(l,0,u);else{h.sort((p,f)=>p.start-f.start);let d=0;for(let p=1;p<h.length;p++){const f=h[d],x=h[p];x.start<=f.start+f.count+1?f.count=Math.max(f.count,x.start+x.count-f.start):(++d,h[d]=x)}h.length=d+1;for(let p=0,f=h.length;p<f;p++){const x=h[p];s.bufferSubData(l,x.start*u.BYTES_PER_ELEMENT,u,x.start,x.count)}c.clearUpdateRanges()}c.onUploadCallback()}function i(a){return a.isInterleavedBufferAttribute&&(a=a.data),e.get(a)}function r(a){a.isInterleavedBufferAttribute&&(a=a.data);const c=e.get(a);c&&(s.deleteBuffer(c.buffer),e.delete(a))}function o(a,c){if(a.isInterleavedBufferAttribute&&(a=a.data),a.isGLBufferAttribute){const u=e.get(a);(!u||u.version<a.version)&&e.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}const l=e.get(a);if(l===void 0)e.set(a,t(a,c));else if(l.version<a.version){if(l.size!==a.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(l.buffer,a,c),l.version=a.version}}return{get:i,remove:r,update:o}}class so extends at{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const r=e/2,o=t/2,a=Math.floor(n),c=Math.floor(i),l=a+1,u=c+1,h=e/a,d=t/c,p=[],f=[],x=[],m=[];for(let g=0;g<u;g++){const y=g*d-o;for(let _=0;_<l;_++){const v=_*h-r;f.push(v,-y,0),x.push(0,0,1),m.push(_/a),m.push(1-g/c)}}for(let g=0;g<c;g++)for(let y=0;y<a;y++){const _=y+l*g,v=y+l*(g+1),I=y+1+l*(g+1),T=y+1+l*g;p.push(_,v,T),p.push(v,I,T)}this.setIndex(p),this.setAttribute("position",new Ve(f,3)),this.setAttribute("normal",new Ve(x,3)),this.setAttribute("uv",new Ve(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new so(e.width,e.height,e.widthSegments,e.heightSegments)}}var u1=`#ifdef USE_ALPHAHASH
44
+ `},i=new _s(5,5,5),r=new ki({name:"CubemapFromEquirect",uniforms:oa(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:ln,blending:Fi});r.uniforms.tEquirect.value=t;const o=new kt(i,r),a=t.minFilter;return t.minFilter===Jn&&(t.minFilter=Ut),new Xh(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,i){const r=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,i);e.setRenderTarget(r)}}const dp=new E,a1=new E,c1=new Ke;class cs{constructor(e=new E(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=dp.subVectors(n,t).cross(a1.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,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 n=e.delta(dp),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:t.copy(e.start).addScaledVector(n,r)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||c1.getNormalMatrix(e),i=this.coplanarPoint(dp).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),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 br=new Dn,kl=new E;class ga{constructor(e=new cs,t=new cs,n=new cs,i=new cs,r=new cs,o=new cs){this.planes=[e,t,n,i,r,o]}set(e,t,n,i,r,o){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(r),a[5].copy(o),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Di){const n=this.planes,i=e.elements,r=i[0],o=i[1],a=i[2],c=i[3],l=i[4],u=i[5],h=i[6],d=i[7],p=i[8],f=i[9],x=i[10],m=i[11],g=i[12],y=i[13],_=i[14],v=i[15];if(n[0].setComponents(c-r,d-l,m-p,v-g).normalize(),n[1].setComponents(c+r,d+l,m+p,v+g).normalize(),n[2].setComponents(c+o,d+u,m+f,v+y).normalize(),n[3].setComponents(c-o,d-u,m-f,v-y).normalize(),n[4].setComponents(c-a,d-h,m-x,v-_).normalize(),t===Di)n[5].setComponents(c+a,d+h,m+x,v+_).normalize();else if(t===Qr)n[5].setComponents(a,h,x,_).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(),br.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),br.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(br)}intersectsSprite(e){return br.center.set(0,0,0),br.radius=.7071067811865476,br.applyMatrix4(e.matrixWorld),this.intersectsSphere(br)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const i=t[n];if(kl.x=i.normal.x>0?e.max.x:e.min.x,kl.y=i.normal.y>0?e.max.y:e.min.y,kl.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(kl)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function Gy(){let s=null,e=!1,t=null,n=null;function i(r,o){t(r,o),n=s.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&(n=s.requestAnimationFrame(i),e=!0)},stop:function(){s.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){s=r}}}function l1(s){const e=new WeakMap;function t(a,c){const l=a.array,u=a.usage,h=l.byteLength,d=s.createBuffer();s.bindBuffer(c,d),s.bufferData(c,l,u),a.onUploadCallback();let p;if(l instanceof Float32Array)p=s.FLOAT;else if(l instanceof Uint16Array)a.isFloat16BufferAttribute?p=s.HALF_FLOAT:p=s.UNSIGNED_SHORT;else if(l instanceof Int16Array)p=s.SHORT;else if(l instanceof Uint32Array)p=s.UNSIGNED_INT;else if(l instanceof Int32Array)p=s.INT;else if(l instanceof Int8Array)p=s.BYTE;else if(l instanceof Uint8Array)p=s.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)p=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:d,type:p,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:h}}function n(a,c,l){const u=c.array,h=c.updateRanges;if(s.bindBuffer(l,a),h.length===0)s.bufferSubData(l,0,u);else{h.sort((p,f)=>p.start-f.start);let d=0;for(let p=1;p<h.length;p++){const f=h[d],x=h[p];x.start<=f.start+f.count+1?f.count=Math.max(f.count,x.start+x.count-f.start):(++d,h[d]=x)}h.length=d+1;for(let p=0,f=h.length;p<f;p++){const x=h[p];s.bufferSubData(l,x.start*u.BYTES_PER_ELEMENT,u,x.start,x.count)}c.clearUpdateRanges()}c.onUploadCallback()}function i(a){return a.isInterleavedBufferAttribute&&(a=a.data),e.get(a)}function r(a){a.isInterleavedBufferAttribute&&(a=a.data);const c=e.get(a);c&&(s.deleteBuffer(c.buffer),e.delete(a))}function o(a,c){if(a.isInterleavedBufferAttribute&&(a=a.data),a.isGLBufferAttribute){const u=e.get(a);(!u||u.version<a.version)&&e.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}const l=e.get(a);if(l===void 0)e.set(a,t(a,c));else if(l.version<a.version){if(l.size!==a.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(l.buffer,a,c),l.version=a.version}}return{get:i,remove:r,update:o}}class ro extends at{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const r=e/2,o=t/2,a=Math.floor(n),c=Math.floor(i),l=a+1,u=c+1,h=e/a,d=t/c,p=[],f=[],x=[],m=[];for(let g=0;g<u;g++){const y=g*d-o;for(let _=0;_<l;_++){const v=_*h-r;f.push(v,-y,0),x.push(0,0,1),m.push(_/a),m.push(1-g/c)}}for(let g=0;g<c;g++)for(let y=0;y<a;y++){const _=y+l*g,v=y+l*(g+1),I=y+1+l*(g+1),T=y+1+l*g;p.push(_,v,T),p.push(v,I,T)}this.setIndex(p),this.setAttribute("position",new Ve(f,3)),this.setAttribute("normal",new Ve(x,3)),this.setAttribute("uv",new Ve(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ro(e.width,e.height,e.widthSegments,e.heightSegments)}}var u1=`#ifdef USE_ALPHAHASH
45
45
  if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
46
46
  #endif`,h1=`#ifdef USE_ALPHAHASH
47
47
  const float ALPHA_HASH_SCALE = 0.05;
@@ -3592,7 +3592,7 @@ void main() {
3592
3592
  #include <tonemapping_fragment>
3593
3593
  #include <colorspace_fragment>
3594
3594
  #include <fog_fragment>
3595
- }`,lt={alphahash_fragment:u1,alphahash_pars_fragment:h1,alphamap_fragment:d1,alphamap_pars_fragment:p1,alphatest_fragment:f1,alphatest_pars_fragment:m1,aomap_fragment:g1,aomap_pars_fragment:x1,batching_pars_vertex:_1,batching_vertex:y1,begin_vertex:v1,beginnormal_vertex:M1,bsdfs:S1,iridescence_fragment:T1,bumpmap_pars_fragment:b1,clipping_planes_fragment:w1,clipping_planes_pars_fragment:A1,clipping_planes_pars_vertex:N1,clipping_planes_vertex:E1,color_fragment:C1,color_pars_fragment:R1,color_pars_vertex:I1,color_vertex:P1,common:L1,cube_uv_reflection_fragment:D1,defaultnormal_vertex:U1,displacementmap_pars_vertex:F1,displacementmap_vertex:O1,emissivemap_fragment:V1,emissivemap_pars_fragment:B1,colorspace_fragment:z1,colorspace_pars_fragment:k1,envmap_fragment:G1,envmap_common_pars_fragment:H1,envmap_pars_fragment:W1,envmap_pars_vertex:X1,envmap_physical_pars_fragment:nN,envmap_vertex:q1,fog_vertex:$1,fog_pars_vertex:Y1,fog_fragment:Z1,fog_pars_fragment:J1,gradientmap_pars_fragment:K1,lightmap_pars_fragment:j1,lights_lambert_fragment:Q1,lights_lambert_pars_fragment:eN,lights_pars_begin:tN,lights_toon_fragment:iN,lights_toon_pars_fragment:sN,lights_phong_fragment:rN,lights_phong_pars_fragment:oN,lights_physical_fragment:aN,lights_physical_pars_fragment:cN,lights_fragment_begin:lN,lights_fragment_maps:uN,lights_fragment_end:hN,logdepthbuf_fragment:dN,logdepthbuf_pars_fragment:pN,logdepthbuf_pars_vertex:fN,logdepthbuf_vertex:mN,map_fragment:gN,map_pars_fragment:xN,map_particle_fragment:_N,map_particle_pars_fragment:yN,metalnessmap_fragment:vN,metalnessmap_pars_fragment:MN,morphinstance_vertex:SN,morphcolor_vertex:TN,morphnormal_vertex:bN,morphtarget_pars_vertex:wN,morphtarget_vertex:AN,normal_fragment_begin:NN,normal_fragment_maps:EN,normal_pars_fragment:CN,normal_pars_vertex:RN,normal_vertex:IN,normalmap_pars_fragment:PN,clearcoat_normal_fragment_begin:LN,clearcoat_normal_fragment_maps:DN,clearcoat_pars_fragment:UN,iridescence_pars_fragment:FN,opaque_fragment:ON,packing:VN,premultiplied_alpha_fragment:BN,project_vertex:zN,dithering_fragment:kN,dithering_pars_fragment:GN,roughnessmap_fragment:HN,roughnessmap_pars_fragment:WN,shadowmap_pars_fragment:XN,shadowmap_pars_vertex:qN,shadowmap_vertex:$N,shadowmask_pars_fragment:YN,skinbase_vertex:ZN,skinning_pars_vertex:JN,skinning_vertex:KN,skinnormal_vertex:jN,specularmap_fragment:QN,specularmap_pars_fragment:eE,tonemapping_fragment:tE,tonemapping_pars_fragment:nE,transmission_fragment:iE,transmission_pars_fragment:sE,uv_pars_fragment:rE,uv_pars_vertex:oE,uv_vertex:aE,worldpos_vertex:cE,background_vert:lE,background_frag:uE,backgroundCube_vert:hE,backgroundCube_frag:dE,cube_vert:pE,cube_frag:fE,depth_vert:mE,depth_frag:gE,distanceRGBA_vert:xE,distanceRGBA_frag:_E,equirect_vert:yE,equirect_frag:vE,linedashed_vert:ME,linedashed_frag:SE,meshbasic_vert:TE,meshbasic_frag:bE,meshlambert_vert:wE,meshlambert_frag:AE,meshmatcap_vert:NE,meshmatcap_frag:EE,meshnormal_vert:CE,meshnormal_frag:RE,meshphong_vert:IE,meshphong_frag:PE,meshphysical_vert:LE,meshphysical_frag:DE,meshtoon_vert:UE,meshtoon_frag:FE,points_vert:OE,points_frag:VE,shadow_vert:BE,shadow_frag:zE,sprite_vert:kE,sprite_frag:GE},Se={common:{diffuse:{value:new _e(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ke},alphaMap:{value:null},alphaMapTransform:{value:new Ke},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ke}},envmap:{envMap:{value:null},envMapRotation:{value:new Ke},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ke}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ke}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ke},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ke},normalScale:{value:new J(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ke},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ke}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ke}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ke}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new _e(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new _e(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ke},alphaTest:{value:0},uvTransform:{value:new Ke}},sprite:{diffuse:{value:new _e(16777215)},opacity:{value:1},center:{value:new J(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ke},alphaMap:{value:null},alphaMapTransform:{value:new Ke},alphaTest:{value:0}}},Pi={basic:{uniforms:$n([Se.common,Se.specularmap,Se.envmap,Se.aomap,Se.lightmap,Se.fog]),vertexShader:lt.meshbasic_vert,fragmentShader:lt.meshbasic_frag},lambert:{uniforms:$n([Se.common,Se.specularmap,Se.envmap,Se.aomap,Se.lightmap,Se.emissivemap,Se.bumpmap,Se.normalmap,Se.displacementmap,Se.fog,Se.lights,{emissive:{value:new _e(0)}}]),vertexShader:lt.meshlambert_vert,fragmentShader:lt.meshlambert_frag},phong:{uniforms:$n([Se.common,Se.specularmap,Se.envmap,Se.aomap,Se.lightmap,Se.emissivemap,Se.bumpmap,Se.normalmap,Se.displacementmap,Se.fog,Se.lights,{emissive:{value:new _e(0)},specular:{value:new _e(1118481)},shininess:{value:30}}]),vertexShader:lt.meshphong_vert,fragmentShader:lt.meshphong_frag},standard:{uniforms:$n([Se.common,Se.envmap,Se.aomap,Se.lightmap,Se.emissivemap,Se.bumpmap,Se.normalmap,Se.displacementmap,Se.roughnessmap,Se.metalnessmap,Se.fog,Se.lights,{emissive:{value:new _e(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:lt.meshphysical_vert,fragmentShader:lt.meshphysical_frag},toon:{uniforms:$n([Se.common,Se.aomap,Se.lightmap,Se.emissivemap,Se.bumpmap,Se.normalmap,Se.displacementmap,Se.gradientmap,Se.fog,Se.lights,{emissive:{value:new _e(0)}}]),vertexShader:lt.meshtoon_vert,fragmentShader:lt.meshtoon_frag},matcap:{uniforms:$n([Se.common,Se.bumpmap,Se.normalmap,Se.displacementmap,Se.fog,{matcap:{value:null}}]),vertexShader:lt.meshmatcap_vert,fragmentShader:lt.meshmatcap_frag},points:{uniforms:$n([Se.points,Se.fog]),vertexShader:lt.points_vert,fragmentShader:lt.points_frag},dashed:{uniforms:$n([Se.common,Se.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:lt.linedashed_vert,fragmentShader:lt.linedashed_frag},depth:{uniforms:$n([Se.common,Se.displacementmap]),vertexShader:lt.depth_vert,fragmentShader:lt.depth_frag},normal:{uniforms:$n([Se.common,Se.bumpmap,Se.normalmap,Se.displacementmap,{opacity:{value:1}}]),vertexShader:lt.meshnormal_vert,fragmentShader:lt.meshnormal_frag},sprite:{uniforms:$n([Se.sprite,Se.fog]),vertexShader:lt.sprite_vert,fragmentShader:lt.sprite_frag},background:{uniforms:{uvTransform:{value:new Ke},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:lt.background_vert,fragmentShader:lt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ke}},vertexShader:lt.backgroundCube_vert,fragmentShader:lt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:lt.cube_vert,fragmentShader:lt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:lt.equirect_vert,fragmentShader:lt.equirect_frag},distanceRGBA:{uniforms:$n([Se.common,Se.displacementmap,{referencePosition:{value:new E},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:lt.distanceRGBA_vert,fragmentShader:lt.distanceRGBA_frag},shadow:{uniforms:$n([Se.lights,Se.fog,{color:{value:new _e(0)},opacity:{value:1}}]),vertexShader:lt.shadow_vert,fragmentShader:lt.shadow_frag}};Pi.physical={uniforms:$n([Pi.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ke},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ke},clearcoatNormalScale:{value:new J(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ke},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ke},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ke},sheen:{value:0},sheenColor:{value:new _e(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ke},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ke},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ke},transmissionSamplerSize:{value:new J},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ke},attenuationDistance:{value:0},attenuationColor:{value:new _e(0)},specularColor:{value:new _e(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ke},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ke},anisotropyVector:{value:new J},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ke}}]),vertexShader:lt.meshphysical_vert,fragmentShader:lt.meshphysical_frag};const Gl={r:0,b:0,g:0},br=new ui,HE=new Fe;function WE(s,e,t,n,i,r,o){const a=new _e(0);let c=r===!0?0:1,l,u,h=null,d=0,p=null;function f(y){let _=y.isScene===!0?y.background:null;return _&&_.isTexture&&(_=(y.backgroundBlurriness>0?t:e).get(_)),_}function x(y){let _=!1;const v=f(y);v===null?g(a,c):v&&v.isColor&&(g(v,1),_=!0);const I=s.xr.getEnvironmentBlendMode();I==="additive"?n.buffers.color.setClear(0,0,0,1,o):I==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,o),(s.autoClear||_)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil))}function m(y,_){const v=f(_);v&&(v.isCubeTexture||v.mapping===hr)?(u===void 0&&(u=new kt(new _s(1,1,1),new ki({name:"BackgroundCubeMaterial",uniforms:oa(Pi.backgroundCube.uniforms),vertexShader:Pi.backgroundCube.vertexShader,fragmentShader:Pi.backgroundCube.fragmentShader,side:ln,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(I,T,w){this.matrixWorld.copyPosition(w.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(u)),br.copy(_.backgroundRotation),br.x*=-1,br.y*=-1,br.z*=-1,v.isCubeTexture&&v.isRenderTargetTexture===!1&&(br.y*=-1,br.z*=-1),u.material.uniforms.envMap.value=v,u.material.uniforms.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=_.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(HE.makeRotationFromEuler(br)),u.material.toneMapped=gt.getTransfer(v.colorSpace)!==Vt,(h!==v||d!==v.version||p!==s.toneMapping)&&(u.material.needsUpdate=!0,h=v,d=v.version,p=s.toneMapping),u.layers.enableAll(),y.unshift(u,u.geometry,u.material,0,0,null)):v&&v.isTexture&&(l===void 0&&(l=new kt(new so(2,2),new ki({name:"BackgroundMaterial",uniforms:oa(Pi.background.uniforms),vertexShader:Pi.background.vertexShader,fragmentShader:Pi.background.fragmentShader,side:fs,depthTest:!1,depthWrite:!1,fog:!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=v,l.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,l.material.toneMapped=gt.getTransfer(v.colorSpace)!==Vt,v.matrixAutoUpdate===!0&&v.updateMatrix(),l.material.uniforms.uvTransform.value.copy(v.matrix),(h!==v||d!==v.version||p!==s.toneMapping)&&(l.material.needsUpdate=!0,h=v,d=v.version,p=s.toneMapping),l.layers.enableAll(),y.unshift(l,l.geometry,l.material,0,0,null))}function g(y,_){y.getRGB(Gl,ky(s)),n.buffers.color.setClear(Gl.r,Gl.g,Gl.b,_,o)}return{getClearColor:function(){return a},setClearColor:function(y,_=1){a.set(y),c=_,g(a,c)},getClearAlpha:function(){return c},setClearAlpha:function(y){c=y,g(a,c)},render:x,addToRenderList:m}}function XE(s,e){const t=s.getParameter(s.MAX_VERTEX_ATTRIBS),n={},i=d(null);let r=i,o=!1;function a(M,b,G,W,$){let ie=!1;const q=h(W,G,b);r!==q&&(r=q,l(r.object)),ie=p(M,W,G,$),ie&&f(M,W,G,$),$!==null&&e.update($,s.ELEMENT_ARRAY_BUFFER),(ie||o)&&(o=!1,v(M,b,G,W),$!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,e.get($).buffer))}function c(){return s.createVertexArray()}function l(M){return s.bindVertexArray(M)}function u(M){return s.deleteVertexArray(M)}function h(M,b,G){const W=G.wireframe===!0;let $=n[M.id];$===void 0&&($={},n[M.id]=$);let ie=$[b.id];ie===void 0&&(ie={},$[b.id]=ie);let q=ie[W];return q===void 0&&(q=d(c()),ie[W]=q),q}function d(M){const b=[],G=[],W=[];for(let $=0;$<t;$++)b[$]=0,G[$]=0,W[$]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:b,enabledAttributes:G,attributeDivisors:W,object:M,attributes:{},index:null}}function p(M,b,G,W){const $=r.attributes,ie=b.attributes;let q=0;const he=G.getAttributes();for(const Q in he)if(he[Q].location>=0){const Ne=$[Q];let Ee=ie[Q];if(Ee===void 0&&(Q==="instanceMatrix"&&M.instanceMatrix&&(Ee=M.instanceMatrix),Q==="instanceColor"&&M.instanceColor&&(Ee=M.instanceColor)),Ne===void 0||Ne.attribute!==Ee||Ee&&Ne.data!==Ee.data)return!0;q++}return r.attributesNum!==q||r.index!==W}function f(M,b,G,W){const $={},ie=b.attributes;let q=0;const he=G.getAttributes();for(const Q in he)if(he[Q].location>=0){let Ne=ie[Q];Ne===void 0&&(Q==="instanceMatrix"&&M.instanceMatrix&&(Ne=M.instanceMatrix),Q==="instanceColor"&&M.instanceColor&&(Ne=M.instanceColor));const Ee={};Ee.attribute=Ne,Ne&&Ne.data&&(Ee.data=Ne.data),$[Q]=Ee,q++}r.attributes=$,r.attributesNum=q,r.index=W}function x(){const M=r.newAttributes;for(let b=0,G=M.length;b<G;b++)M[b]=0}function m(M){g(M,0)}function g(M,b){const G=r.newAttributes,W=r.enabledAttributes,$=r.attributeDivisors;G[M]=1,W[M]===0&&(s.enableVertexAttribArray(M),W[M]=1),$[M]!==b&&(s.vertexAttribDivisor(M,b),$[M]=b)}function y(){const M=r.newAttributes,b=r.enabledAttributes;for(let G=0,W=b.length;G<W;G++)b[G]!==M[G]&&(s.disableVertexAttribArray(G),b[G]=0)}function _(M,b,G,W,$,ie,q){q===!0?s.vertexAttribIPointer(M,b,G,$,ie):s.vertexAttribPointer(M,b,G,W,$,ie)}function v(M,b,G,W){x();const $=W.attributes,ie=G.getAttributes(),q=b.defaultAttributeValues;for(const he in ie){const Q=ie[he];if(Q.location>=0){let we=$[he];if(we===void 0&&(he==="instanceMatrix"&&M.instanceMatrix&&(we=M.instanceMatrix),he==="instanceColor"&&M.instanceColor&&(we=M.instanceColor)),we!==void 0){const Ne=we.normalized,Ee=we.itemSize,Qe=e.get(we);if(Qe===void 0)continue;const ht=Qe.buffer,ne=Qe.type,ue=Qe.bytesPerElement,Ae=ne===s.INT||ne===s.UNSIGNED_INT||we.gpuType===ma;if(we.isInterleavedBufferAttribute){const ge=we.data,Ze=ge.stride,Xe=we.offset;if(ge.isInstancedInterleavedBuffer){for(let Je=0;Je<Q.locationSize;Je++)g(Q.location+Je,ge.meshPerAttribute);M.isInstancedMesh!==!0&&W._maxInstanceCount===void 0&&(W._maxInstanceCount=ge.meshPerAttribute*ge.count)}else for(let Je=0;Je<Q.locationSize;Je++)m(Q.location+Je);s.bindBuffer(s.ARRAY_BUFFER,ht);for(let Je=0;Je<Q.locationSize;Je++)_(Q.location+Je,Ee/Q.locationSize,ne,Ne,Ze*ue,(Xe+Ee/Q.locationSize*Je)*ue,Ae)}else{if(we.isInstancedBufferAttribute){for(let ge=0;ge<Q.locationSize;ge++)g(Q.location+ge,we.meshPerAttribute);M.isInstancedMesh!==!0&&W._maxInstanceCount===void 0&&(W._maxInstanceCount=we.meshPerAttribute*we.count)}else for(let ge=0;ge<Q.locationSize;ge++)m(Q.location+ge);s.bindBuffer(s.ARRAY_BUFFER,ht);for(let ge=0;ge<Q.locationSize;ge++)_(Q.location+ge,Ee/Q.locationSize,ne,Ne,Ee*ue,Ee/Q.locationSize*ge*ue,Ae)}}else if(q!==void 0){const Ne=q[he];if(Ne!==void 0)switch(Ne.length){case 2:s.vertexAttrib2fv(Q.location,Ne);break;case 3:s.vertexAttrib3fv(Q.location,Ne);break;case 4:s.vertexAttrib4fv(Q.location,Ne);break;default:s.vertexAttrib1fv(Q.location,Ne)}}}}y()}function I(){C();for(const M in n){const b=n[M];for(const G in b){const W=b[G];for(const $ in W)u(W[$].object),delete W[$];delete b[G]}delete n[M]}}function T(M){if(n[M.id]===void 0)return;const b=n[M.id];for(const G in b){const W=b[G];for(const $ in W)u(W[$].object),delete W[$];delete b[G]}delete n[M.id]}function w(M){for(const b in n){const G=n[b];if(G[M.id]===void 0)continue;const W=G[M.id];for(const $ in W)u(W[$].object),delete W[$];delete G[M.id]}}function C(){F(),o=!0,r!==i&&(r=i,l(r.object))}function F(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:a,reset:C,resetDefaultState:F,dispose:I,releaseStatesOfGeometry:T,releaseStatesOfProgram:w,initAttributes:x,enableAttribute:m,disableUnusedAttributes:y}}function qE(s,e,t){let n;function i(l){n=l}function r(l,u){s.drawArrays(n,l,u),t.update(u,n,1)}function o(l,u,h){h!==0&&(s.drawArraysInstanced(n,l,u,h),t.update(u,n,h))}function a(l,u,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,u,0,h);let p=0;for(let f=0;f<h;f++)p+=u[f];t.update(p,n,1)}function c(l,u,h,d){if(h===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let f=0;f<l.length;f++)o(l[f],u[f],d[f]);else{p.multiDrawArraysInstancedWEBGL(n,l,0,u,0,d,0,h);let f=0;for(let x=0;x<h;x++)f+=u[x];for(let x=0;x<d.length;x++)t.update(f,n,d[x])}}this.setMode=i,this.render=r,this.renderInstances=o,this.renderMultiDraw=a,this.renderMultiDrawInstances=c}function $E(s,e,t,n){let i;function r(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const w=e.get("EXT_texture_filter_anisotropic");i=s.getParameter(w.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function o(w){return!(w!==Rn&&n.convert(w)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(w){const C=w===Ln&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(w!==es&&n.convert(w)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_TYPE)&&w!==Gn&&!C)}function c(w){if(w==="highp"){if(s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.HIGH_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";w="mediump"}return w==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp";const u=c(l);u!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",u,"instead."),l=u);const h=t.logarithmicDepthBuffer===!0,d=t.reverseDepthBuffer===!0&&e.has("EXT_clip_control");if(d===!0){const w=e.get("EXT_clip_control");w.clipControlEXT(w.LOWER_LEFT_EXT,w.ZERO_TO_ONE_EXT)}const p=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),f=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=s.getParameter(s.MAX_TEXTURE_SIZE),m=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),g=s.getParameter(s.MAX_VERTEX_ATTRIBS),y=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),_=s.getParameter(s.MAX_VARYING_VECTORS),v=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),I=f>0,T=s.getParameter(s.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:h,reverseDepthBuffer:d,maxTextures:p,maxVertexTextures:f,maxTextureSize:x,maxCubemapSize:m,maxAttributes:g,maxVertexUniforms:y,maxVaryings:_,maxFragmentUniforms:v,vertexTextures:I,maxSamples:T}}function YE(s){const e=this;let t=null,n=0,i=!1,r=!1;const o=new cs,a=new Ke,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(h,d){const p=h.length!==0||d||n!==0||i;return i=d,n=h.length,p},this.beginShadows=function(){r=!0,u(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(h,d){t=u(h,d,0)},this.setState=function(h,d,p){const f=h.clippingPlanes,x=h.clipIntersection,m=h.clipShadows,g=s.get(h);if(!i||f===null||f.length===0||r&&!m)r?u(null):l();else{const y=r?0:n,_=y*4;let v=g.clippingState||null;c.value=v,v=u(f,d,_,p);for(let I=0;I!==_;++I)v[I]=t[I];g.clippingState=v,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=y}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(h,d,p,f){const x=h!==null?h.length:0;let m=null;if(x!==0){if(m=c.value,f!==!0||m===null){const g=p+x*4,y=d.matrixWorldInverse;a.getNormalMatrix(y),(m===null||m.length<g)&&(m=new Float32Array(g));for(let _=0,v=p;_!==x;++_,v+=4)o.copy(h[_]).applyMatrix4(y,a),o.normal.toArray(m,v),m[v+3]=o.constant}c.value=m,c.needsUpdate=!0}return e.numPlanes=x,e.numIntersection=0,m}}function ZE(s){let e=new WeakMap;function t(o,a){return a===ir?o.mapping=wi:a===sr&&(o.mapping=Vi),o}function n(o){if(o&&o.isTexture){const a=o.mapping;if(a===ir||a===sr)if(e.has(o)){const c=e.get(o).texture;return t(c,o.mapping)}else{const c=o.image;if(c&&c.height>0){const l=new qh(c.height);return l.fromEquirectangularTexture(s,o),e.set(o,l),o.addEventListener("dispose",i),t(l.texture,o.mapping)}else return null}}return o}function i(o){const a=o.target;a.removeEventListener("dispose",i);const c=e.get(a);c!==void 0&&(e.delete(a),c.dispose())}function r(){e=new WeakMap}return{get:n,dispose:r}}class ro extends Yc{constructor(e=-1,t=1,n=1,i=-1,r=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=o,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),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-e,o=n+e,a=i+t,c=i-t;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,o=r+l*this.view.width,a-=u*this.view.offsetY,c=a-u*this.view.height}this.projectionMatrix.makeOrthographic(r,o,a,c,this.near,this.far,this.coordinateSystem),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 Go=4,F0=[.125,.215,.35,.446,.526,.582],Or=20,pp=new ro,O0=new _e;let fp=null,mp=0,gp=0,xp=!1;const Ur=(1+Math.sqrt(5))/2,Eo=1/Ur,V0=[new E(-Ur,Eo,0),new E(Ur,Eo,0),new E(-Eo,0,Ur),new E(Eo,0,Ur),new E(0,Ur,-Eo),new E(0,Ur,Eo),new E(-1,1,-1),new E(1,1,-1),new E(-1,1,1),new E(1,1,1)];let rh=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){fp=this._renderer.getRenderTarget(),mp=this._renderer.getActiveCubeFace(),gp=this._renderer.getActiveMipmapLevel(),xp=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(e,n,i,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=G0(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=k0(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.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._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(fp,mp,gp),this._renderer.xr.enabled=xp,e.scissorTest=!1,Hl(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===wi||e.mapping===Vi?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),fp=this._renderer.getRenderTarget(),mp=this._renderer.getActiveCubeFace(),gp=this._renderer.getActiveMipmapLevel(),xp=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Ut,minFilter:Ut,generateMipmaps:!1,type:Ln,format:Rn,colorSpace:li,depthBuffer:!1},i=z0(e,t,n),{_lodMax:r}=this;if({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=B0(r),this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=z0(e,t,n);const{_lodMax:o}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=B0(o)),this._blurMaterial=JE(o,e,t)}return i}_compileMaterial(e){const t=new kt(this._lodPlanes[0],e);this._renderer.compile(t,pp)}_sceneToCubeUV(e,t,n,i){const a=new hn(90,1,t,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,h=u.autoClear,d=u.toneMapping;u.getClearColor(O0),u.toneMapping=Ti,u.autoClear=!1;const p=new ss({name:"PMREM.Background",side:ln,depthWrite:!1,depthTest:!1}),f=new kt(new _s,p);let x=!1;const m=e.background;m?m.isColor&&(p.color.copy(m),e.background=null,x=!0):(p.color.copy(O0),x=!0);for(let g=0;g<6;g++){const y=g%3;y===0?(a.up.set(0,c[g],0),a.lookAt(l[g],0,0)):y===1?(a.up.set(0,0,c[g]),a.lookAt(0,l[g],0)):(a.up.set(0,c[g],0),a.lookAt(0,0,l[g]));const _=this._cubeSize;Hl(i,y*_,g>2?_:0,_,_),u.setRenderTarget(i),x&&u.render(f,a),u.render(e,a)}f.geometry.dispose(),f.material.dispose(),u.toneMapping=d,u.autoClear=h,e.background=m}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===wi||e.mapping===Vi;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=G0()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=k0());const r=i?this._cubemapMaterial:this._equirectMaterial,o=new kt(this._lodPlanes[0],r),a=r.uniforms;a.envMap.value=e;const c=this._cubeSize;Hl(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(o,pp)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const i=this._lodPlanes.length;for(let r=1;r<i;r++){const o=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),a=V0[(i-r-1)%V0.length];this._blur(e,r-1,r,o,a)}t.autoClear=n}_blur(e,t,n,i,r){const o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,i,"latitudinal",r),this._halfBlur(o,e,n,n,i,"longitudinal",r)}_halfBlur(e,t,n,i,r,o,a){const c=this._renderer,l=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const u=3,h=new kt(this._lodPlanes[i],l),d=l.uniforms,p=this._sizeLods[n]-1,f=isFinite(r)?Math.PI/(2*p):2*Math.PI/(2*Or-1),x=r/f,m=isFinite(r)?1+Math.floor(u*x):Or;m>Or&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Or}`);const g=[];let y=0;for(let w=0;w<Or;++w){const C=w/x,F=Math.exp(-C*C/2);g.push(F),w===0?y+=F:w<m&&(y+=2*F)}for(let w=0;w<g.length;w++)g[w]=g[w]/y;d.envMap.value=e.texture,d.samples.value=m,d.weights.value=g,d.latitudinal.value=o==="latitudinal",a&&(d.poleAxis.value=a);const{_lodMax:_}=this;d.dTheta.value=f,d.mipInt.value=_-n;const v=this._sizeLods[i],I=3*v*(i>_-Go?i-_+Go:0),T=4*(this._cubeSize-v);Hl(t,I,T,3*v,2*v),c.setRenderTarget(t),c.render(h,pp)}};function B0(s){const e=[],t=[],n=[];let i=s;const r=s-Go+1+F0.length;for(let o=0;o<r;o++){const a=Math.pow(2,i);t.push(a);let c=1/a;o>s-Go?c=F0[o-s+Go-1]:o===0&&(c=0),n.push(c);const l=1/(a-2),u=-l,h=1+l,d=[u,u,h,u,h,h,u,u,h,h,u,h],p=6,f=6,x=3,m=2,g=1,y=new Float32Array(x*f*p),_=new Float32Array(m*f*p),v=new Float32Array(g*f*p);for(let T=0;T<p;T++){const w=T%3*2/3-1,C=T>2?0:-1,F=[w,C,0,w+2/3,C,0,w+2/3,C+1,0,w,C,0,w+2/3,C+1,0,w,C+1,0];y.set(F,x*f*T),_.set(d,m*f*T);const M=[T,T,T,T,T,T];v.set(M,g*f*T)}const I=new at;I.setAttribute("position",new At(y,x)),I.setAttribute("uv",new At(_,m)),I.setAttribute("faceIndex",new At(v,g)),e.push(I),i>Go&&i--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function z0(s,e,t){const n=new zi(s,e,t);return n.texture.mapping=hr,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Hl(s,e,t,n,i){s.viewport.set(e,t,n,i),s.scissor.set(e,t,n,i)}function JE(s,e,t){const n=new Float32Array(Or),i=new E(0,1,0);return new ki({name:"SphericalGaussianBlur",defines:{n:Or,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:im(),fragmentShader:`
3595
+ }`,lt={alphahash_fragment:u1,alphahash_pars_fragment:h1,alphamap_fragment:d1,alphamap_pars_fragment:p1,alphatest_fragment:f1,alphatest_pars_fragment:m1,aomap_fragment:g1,aomap_pars_fragment:x1,batching_pars_vertex:_1,batching_vertex:y1,begin_vertex:v1,beginnormal_vertex:M1,bsdfs:S1,iridescence_fragment:T1,bumpmap_pars_fragment:b1,clipping_planes_fragment:w1,clipping_planes_pars_fragment:A1,clipping_planes_pars_vertex:N1,clipping_planes_vertex:E1,color_fragment:C1,color_pars_fragment:R1,color_pars_vertex:I1,color_vertex:P1,common:L1,cube_uv_reflection_fragment:D1,defaultnormal_vertex:U1,displacementmap_pars_vertex:F1,displacementmap_vertex:O1,emissivemap_fragment:V1,emissivemap_pars_fragment:B1,colorspace_fragment:z1,colorspace_pars_fragment:k1,envmap_fragment:G1,envmap_common_pars_fragment:H1,envmap_pars_fragment:W1,envmap_pars_vertex:X1,envmap_physical_pars_fragment:nN,envmap_vertex:q1,fog_vertex:$1,fog_pars_vertex:Y1,fog_fragment:Z1,fog_pars_fragment:J1,gradientmap_pars_fragment:K1,lightmap_pars_fragment:j1,lights_lambert_fragment:Q1,lights_lambert_pars_fragment:eN,lights_pars_begin:tN,lights_toon_fragment:iN,lights_toon_pars_fragment:sN,lights_phong_fragment:rN,lights_phong_pars_fragment:oN,lights_physical_fragment:aN,lights_physical_pars_fragment:cN,lights_fragment_begin:lN,lights_fragment_maps:uN,lights_fragment_end:hN,logdepthbuf_fragment:dN,logdepthbuf_pars_fragment:pN,logdepthbuf_pars_vertex:fN,logdepthbuf_vertex:mN,map_fragment:gN,map_pars_fragment:xN,map_particle_fragment:_N,map_particle_pars_fragment:yN,metalnessmap_fragment:vN,metalnessmap_pars_fragment:MN,morphinstance_vertex:SN,morphcolor_vertex:TN,morphnormal_vertex:bN,morphtarget_pars_vertex:wN,morphtarget_vertex:AN,normal_fragment_begin:NN,normal_fragment_maps:EN,normal_pars_fragment:CN,normal_pars_vertex:RN,normal_vertex:IN,normalmap_pars_fragment:PN,clearcoat_normal_fragment_begin:LN,clearcoat_normal_fragment_maps:DN,clearcoat_pars_fragment:UN,iridescence_pars_fragment:FN,opaque_fragment:ON,packing:VN,premultiplied_alpha_fragment:BN,project_vertex:zN,dithering_fragment:kN,dithering_pars_fragment:GN,roughnessmap_fragment:HN,roughnessmap_pars_fragment:WN,shadowmap_pars_fragment:XN,shadowmap_pars_vertex:qN,shadowmap_vertex:$N,shadowmask_pars_fragment:YN,skinbase_vertex:ZN,skinning_pars_vertex:JN,skinning_vertex:KN,skinnormal_vertex:jN,specularmap_fragment:QN,specularmap_pars_fragment:eE,tonemapping_fragment:tE,tonemapping_pars_fragment:nE,transmission_fragment:iE,transmission_pars_fragment:sE,uv_pars_fragment:rE,uv_pars_vertex:oE,uv_vertex:aE,worldpos_vertex:cE,background_vert:lE,background_frag:uE,backgroundCube_vert:hE,backgroundCube_frag:dE,cube_vert:pE,cube_frag:fE,depth_vert:mE,depth_frag:gE,distanceRGBA_vert:xE,distanceRGBA_frag:_E,equirect_vert:yE,equirect_frag:vE,linedashed_vert:ME,linedashed_frag:SE,meshbasic_vert:TE,meshbasic_frag:bE,meshlambert_vert:wE,meshlambert_frag:AE,meshmatcap_vert:NE,meshmatcap_frag:EE,meshnormal_vert:CE,meshnormal_frag:RE,meshphong_vert:IE,meshphong_frag:PE,meshphysical_vert:LE,meshphysical_frag:DE,meshtoon_vert:UE,meshtoon_frag:FE,points_vert:OE,points_frag:VE,shadow_vert:BE,shadow_frag:zE,sprite_vert:kE,sprite_frag:GE},Se={common:{diffuse:{value:new _e(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ke},alphaMap:{value:null},alphaMapTransform:{value:new Ke},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ke}},envmap:{envMap:{value:null},envMapRotation:{value:new Ke},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ke}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ke}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ke},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ke},normalScale:{value:new J(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ke},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ke}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ke}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ke}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new _e(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new _e(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ke},alphaTest:{value:0},uvTransform:{value:new Ke}},sprite:{diffuse:{value:new _e(16777215)},opacity:{value:1},center:{value:new J(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ke},alphaMap:{value:null},alphaMapTransform:{value:new Ke},alphaTest:{value:0}}},Pi={basic:{uniforms:$n([Se.common,Se.specularmap,Se.envmap,Se.aomap,Se.lightmap,Se.fog]),vertexShader:lt.meshbasic_vert,fragmentShader:lt.meshbasic_frag},lambert:{uniforms:$n([Se.common,Se.specularmap,Se.envmap,Se.aomap,Se.lightmap,Se.emissivemap,Se.bumpmap,Se.normalmap,Se.displacementmap,Se.fog,Se.lights,{emissive:{value:new _e(0)}}]),vertexShader:lt.meshlambert_vert,fragmentShader:lt.meshlambert_frag},phong:{uniforms:$n([Se.common,Se.specularmap,Se.envmap,Se.aomap,Se.lightmap,Se.emissivemap,Se.bumpmap,Se.normalmap,Se.displacementmap,Se.fog,Se.lights,{emissive:{value:new _e(0)},specular:{value:new _e(1118481)},shininess:{value:30}}]),vertexShader:lt.meshphong_vert,fragmentShader:lt.meshphong_frag},standard:{uniforms:$n([Se.common,Se.envmap,Se.aomap,Se.lightmap,Se.emissivemap,Se.bumpmap,Se.normalmap,Se.displacementmap,Se.roughnessmap,Se.metalnessmap,Se.fog,Se.lights,{emissive:{value:new _e(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:lt.meshphysical_vert,fragmentShader:lt.meshphysical_frag},toon:{uniforms:$n([Se.common,Se.aomap,Se.lightmap,Se.emissivemap,Se.bumpmap,Se.normalmap,Se.displacementmap,Se.gradientmap,Se.fog,Se.lights,{emissive:{value:new _e(0)}}]),vertexShader:lt.meshtoon_vert,fragmentShader:lt.meshtoon_frag},matcap:{uniforms:$n([Se.common,Se.bumpmap,Se.normalmap,Se.displacementmap,Se.fog,{matcap:{value:null}}]),vertexShader:lt.meshmatcap_vert,fragmentShader:lt.meshmatcap_frag},points:{uniforms:$n([Se.points,Se.fog]),vertexShader:lt.points_vert,fragmentShader:lt.points_frag},dashed:{uniforms:$n([Se.common,Se.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:lt.linedashed_vert,fragmentShader:lt.linedashed_frag},depth:{uniforms:$n([Se.common,Se.displacementmap]),vertexShader:lt.depth_vert,fragmentShader:lt.depth_frag},normal:{uniforms:$n([Se.common,Se.bumpmap,Se.normalmap,Se.displacementmap,{opacity:{value:1}}]),vertexShader:lt.meshnormal_vert,fragmentShader:lt.meshnormal_frag},sprite:{uniforms:$n([Se.sprite,Se.fog]),vertexShader:lt.sprite_vert,fragmentShader:lt.sprite_frag},background:{uniforms:{uvTransform:{value:new Ke},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:lt.background_vert,fragmentShader:lt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ke}},vertexShader:lt.backgroundCube_vert,fragmentShader:lt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:lt.cube_vert,fragmentShader:lt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:lt.equirect_vert,fragmentShader:lt.equirect_frag},distanceRGBA:{uniforms:$n([Se.common,Se.displacementmap,{referencePosition:{value:new E},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:lt.distanceRGBA_vert,fragmentShader:lt.distanceRGBA_frag},shadow:{uniforms:$n([Se.lights,Se.fog,{color:{value:new _e(0)},opacity:{value:1}}]),vertexShader:lt.shadow_vert,fragmentShader:lt.shadow_frag}};Pi.physical={uniforms:$n([Pi.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ke},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ke},clearcoatNormalScale:{value:new J(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ke},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ke},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ke},sheen:{value:0},sheenColor:{value:new _e(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ke},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ke},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ke},transmissionSamplerSize:{value:new J},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ke},attenuationDistance:{value:0},attenuationColor:{value:new _e(0)},specularColor:{value:new _e(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ke},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ke},anisotropyVector:{value:new J},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ke}}]),vertexShader:lt.meshphysical_vert,fragmentShader:lt.meshphysical_frag};const Gl={r:0,b:0,g:0},wr=new ui,HE=new Fe;function WE(s,e,t,n,i,r,o){const a=new _e(0);let c=r===!0?0:1,l,u,h=null,d=0,p=null;function f(y){let _=y.isScene===!0?y.background:null;return _&&_.isTexture&&(_=(y.backgroundBlurriness>0?t:e).get(_)),_}function x(y){let _=!1;const v=f(y);v===null?g(a,c):v&&v.isColor&&(g(v,1),_=!0);const I=s.xr.getEnvironmentBlendMode();I==="additive"?n.buffers.color.setClear(0,0,0,1,o):I==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,o),(s.autoClear||_)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil))}function m(y,_){const v=f(_);v&&(v.isCubeTexture||v.mapping===hr)?(u===void 0&&(u=new kt(new _s(1,1,1),new ki({name:"BackgroundCubeMaterial",uniforms:oa(Pi.backgroundCube.uniforms),vertexShader:Pi.backgroundCube.vertexShader,fragmentShader:Pi.backgroundCube.fragmentShader,side:ln,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(I,T,w){this.matrixWorld.copyPosition(w.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(u)),wr.copy(_.backgroundRotation),wr.x*=-1,wr.y*=-1,wr.z*=-1,v.isCubeTexture&&v.isRenderTargetTexture===!1&&(wr.y*=-1,wr.z*=-1),u.material.uniforms.envMap.value=v,u.material.uniforms.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=_.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(HE.makeRotationFromEuler(wr)),u.material.toneMapped=gt.getTransfer(v.colorSpace)!==Vt,(h!==v||d!==v.version||p!==s.toneMapping)&&(u.material.needsUpdate=!0,h=v,d=v.version,p=s.toneMapping),u.layers.enableAll(),y.unshift(u,u.geometry,u.material,0,0,null)):v&&v.isTexture&&(l===void 0&&(l=new kt(new ro(2,2),new ki({name:"BackgroundMaterial",uniforms:oa(Pi.background.uniforms),vertexShader:Pi.background.vertexShader,fragmentShader:Pi.background.fragmentShader,side:fs,depthTest:!1,depthWrite:!1,fog:!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=v,l.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,l.material.toneMapped=gt.getTransfer(v.colorSpace)!==Vt,v.matrixAutoUpdate===!0&&v.updateMatrix(),l.material.uniforms.uvTransform.value.copy(v.matrix),(h!==v||d!==v.version||p!==s.toneMapping)&&(l.material.needsUpdate=!0,h=v,d=v.version,p=s.toneMapping),l.layers.enableAll(),y.unshift(l,l.geometry,l.material,0,0,null))}function g(y,_){y.getRGB(Gl,ky(s)),n.buffers.color.setClear(Gl.r,Gl.g,Gl.b,_,o)}return{getClearColor:function(){return a},setClearColor:function(y,_=1){a.set(y),c=_,g(a,c)},getClearAlpha:function(){return c},setClearAlpha:function(y){c=y,g(a,c)},render:x,addToRenderList:m}}function XE(s,e){const t=s.getParameter(s.MAX_VERTEX_ATTRIBS),n={},i=d(null);let r=i,o=!1;function a(M,b,G,W,$){let ie=!1;const q=h(W,G,b);r!==q&&(r=q,l(r.object)),ie=p(M,W,G,$),ie&&f(M,W,G,$),$!==null&&e.update($,s.ELEMENT_ARRAY_BUFFER),(ie||o)&&(o=!1,v(M,b,G,W),$!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,e.get($).buffer))}function c(){return s.createVertexArray()}function l(M){return s.bindVertexArray(M)}function u(M){return s.deleteVertexArray(M)}function h(M,b,G){const W=G.wireframe===!0;let $=n[M.id];$===void 0&&($={},n[M.id]=$);let ie=$[b.id];ie===void 0&&(ie={},$[b.id]=ie);let q=ie[W];return q===void 0&&(q=d(c()),ie[W]=q),q}function d(M){const b=[],G=[],W=[];for(let $=0;$<t;$++)b[$]=0,G[$]=0,W[$]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:b,enabledAttributes:G,attributeDivisors:W,object:M,attributes:{},index:null}}function p(M,b,G,W){const $=r.attributes,ie=b.attributes;let q=0;const he=G.getAttributes();for(const Q in he)if(he[Q].location>=0){const Ne=$[Q];let Ee=ie[Q];if(Ee===void 0&&(Q==="instanceMatrix"&&M.instanceMatrix&&(Ee=M.instanceMatrix),Q==="instanceColor"&&M.instanceColor&&(Ee=M.instanceColor)),Ne===void 0||Ne.attribute!==Ee||Ee&&Ne.data!==Ee.data)return!0;q++}return r.attributesNum!==q||r.index!==W}function f(M,b,G,W){const $={},ie=b.attributes;let q=0;const he=G.getAttributes();for(const Q in he)if(he[Q].location>=0){let Ne=ie[Q];Ne===void 0&&(Q==="instanceMatrix"&&M.instanceMatrix&&(Ne=M.instanceMatrix),Q==="instanceColor"&&M.instanceColor&&(Ne=M.instanceColor));const Ee={};Ee.attribute=Ne,Ne&&Ne.data&&(Ee.data=Ne.data),$[Q]=Ee,q++}r.attributes=$,r.attributesNum=q,r.index=W}function x(){const M=r.newAttributes;for(let b=0,G=M.length;b<G;b++)M[b]=0}function m(M){g(M,0)}function g(M,b){const G=r.newAttributes,W=r.enabledAttributes,$=r.attributeDivisors;G[M]=1,W[M]===0&&(s.enableVertexAttribArray(M),W[M]=1),$[M]!==b&&(s.vertexAttribDivisor(M,b),$[M]=b)}function y(){const M=r.newAttributes,b=r.enabledAttributes;for(let G=0,W=b.length;G<W;G++)b[G]!==M[G]&&(s.disableVertexAttribArray(G),b[G]=0)}function _(M,b,G,W,$,ie,q){q===!0?s.vertexAttribIPointer(M,b,G,$,ie):s.vertexAttribPointer(M,b,G,W,$,ie)}function v(M,b,G,W){x();const $=W.attributes,ie=G.getAttributes(),q=b.defaultAttributeValues;for(const he in ie){const Q=ie[he];if(Q.location>=0){let we=$[he];if(we===void 0&&(he==="instanceMatrix"&&M.instanceMatrix&&(we=M.instanceMatrix),he==="instanceColor"&&M.instanceColor&&(we=M.instanceColor)),we!==void 0){const Ne=we.normalized,Ee=we.itemSize,Qe=e.get(we);if(Qe===void 0)continue;const ht=Qe.buffer,ne=Qe.type,ue=Qe.bytesPerElement,Ae=ne===s.INT||ne===s.UNSIGNED_INT||we.gpuType===ma;if(we.isInterleavedBufferAttribute){const ge=we.data,Ze=ge.stride,Xe=we.offset;if(ge.isInstancedInterleavedBuffer){for(let Je=0;Je<Q.locationSize;Je++)g(Q.location+Je,ge.meshPerAttribute);M.isInstancedMesh!==!0&&W._maxInstanceCount===void 0&&(W._maxInstanceCount=ge.meshPerAttribute*ge.count)}else for(let Je=0;Je<Q.locationSize;Je++)m(Q.location+Je);s.bindBuffer(s.ARRAY_BUFFER,ht);for(let Je=0;Je<Q.locationSize;Je++)_(Q.location+Je,Ee/Q.locationSize,ne,Ne,Ze*ue,(Xe+Ee/Q.locationSize*Je)*ue,Ae)}else{if(we.isInstancedBufferAttribute){for(let ge=0;ge<Q.locationSize;ge++)g(Q.location+ge,we.meshPerAttribute);M.isInstancedMesh!==!0&&W._maxInstanceCount===void 0&&(W._maxInstanceCount=we.meshPerAttribute*we.count)}else for(let ge=0;ge<Q.locationSize;ge++)m(Q.location+ge);s.bindBuffer(s.ARRAY_BUFFER,ht);for(let ge=0;ge<Q.locationSize;ge++)_(Q.location+ge,Ee/Q.locationSize,ne,Ne,Ee*ue,Ee/Q.locationSize*ge*ue,Ae)}}else if(q!==void 0){const Ne=q[he];if(Ne!==void 0)switch(Ne.length){case 2:s.vertexAttrib2fv(Q.location,Ne);break;case 3:s.vertexAttrib3fv(Q.location,Ne);break;case 4:s.vertexAttrib4fv(Q.location,Ne);break;default:s.vertexAttrib1fv(Q.location,Ne)}}}}y()}function I(){C();for(const M in n){const b=n[M];for(const G in b){const W=b[G];for(const $ in W)u(W[$].object),delete W[$];delete b[G]}delete n[M]}}function T(M){if(n[M.id]===void 0)return;const b=n[M.id];for(const G in b){const W=b[G];for(const $ in W)u(W[$].object),delete W[$];delete b[G]}delete n[M.id]}function w(M){for(const b in n){const G=n[b];if(G[M.id]===void 0)continue;const W=G[M.id];for(const $ in W)u(W[$].object),delete W[$];delete G[M.id]}}function C(){F(),o=!0,r!==i&&(r=i,l(r.object))}function F(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:a,reset:C,resetDefaultState:F,dispose:I,releaseStatesOfGeometry:T,releaseStatesOfProgram:w,initAttributes:x,enableAttribute:m,disableUnusedAttributes:y}}function qE(s,e,t){let n;function i(l){n=l}function r(l,u){s.drawArrays(n,l,u),t.update(u,n,1)}function o(l,u,h){h!==0&&(s.drawArraysInstanced(n,l,u,h),t.update(u,n,h))}function a(l,u,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,u,0,h);let p=0;for(let f=0;f<h;f++)p+=u[f];t.update(p,n,1)}function c(l,u,h,d){if(h===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let f=0;f<l.length;f++)o(l[f],u[f],d[f]);else{p.multiDrawArraysInstancedWEBGL(n,l,0,u,0,d,0,h);let f=0;for(let x=0;x<h;x++)f+=u[x];for(let x=0;x<d.length;x++)t.update(f,n,d[x])}}this.setMode=i,this.render=r,this.renderInstances=o,this.renderMultiDraw=a,this.renderMultiDrawInstances=c}function $E(s,e,t,n){let i;function r(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const w=e.get("EXT_texture_filter_anisotropic");i=s.getParameter(w.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function o(w){return!(w!==Rn&&n.convert(w)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(w){const C=w===Ln&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(w!==es&&n.convert(w)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_TYPE)&&w!==Gn&&!C)}function c(w){if(w==="highp"){if(s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.HIGH_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";w="mediump"}return w==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp";const u=c(l);u!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",u,"instead."),l=u);const h=t.logarithmicDepthBuffer===!0,d=t.reverseDepthBuffer===!0&&e.has("EXT_clip_control");if(d===!0){const w=e.get("EXT_clip_control");w.clipControlEXT(w.LOWER_LEFT_EXT,w.ZERO_TO_ONE_EXT)}const p=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),f=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=s.getParameter(s.MAX_TEXTURE_SIZE),m=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),g=s.getParameter(s.MAX_VERTEX_ATTRIBS),y=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),_=s.getParameter(s.MAX_VARYING_VECTORS),v=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),I=f>0,T=s.getParameter(s.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:h,reverseDepthBuffer:d,maxTextures:p,maxVertexTextures:f,maxTextureSize:x,maxCubemapSize:m,maxAttributes:g,maxVertexUniforms:y,maxVaryings:_,maxFragmentUniforms:v,vertexTextures:I,maxSamples:T}}function YE(s){const e=this;let t=null,n=0,i=!1,r=!1;const o=new cs,a=new Ke,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(h,d){const p=h.length!==0||d||n!==0||i;return i=d,n=h.length,p},this.beginShadows=function(){r=!0,u(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(h,d){t=u(h,d,0)},this.setState=function(h,d,p){const f=h.clippingPlanes,x=h.clipIntersection,m=h.clipShadows,g=s.get(h);if(!i||f===null||f.length===0||r&&!m)r?u(null):l();else{const y=r?0:n,_=y*4;let v=g.clippingState||null;c.value=v,v=u(f,d,_,p);for(let I=0;I!==_;++I)v[I]=t[I];g.clippingState=v,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=y}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(h,d,p,f){const x=h!==null?h.length:0;let m=null;if(x!==0){if(m=c.value,f!==!0||m===null){const g=p+x*4,y=d.matrixWorldInverse;a.getNormalMatrix(y),(m===null||m.length<g)&&(m=new Float32Array(g));for(let _=0,v=p;_!==x;++_,v+=4)o.copy(h[_]).applyMatrix4(y,a),o.normal.toArray(m,v),m[v+3]=o.constant}c.value=m,c.needsUpdate=!0}return e.numPlanes=x,e.numIntersection=0,m}}function ZE(s){let e=new WeakMap;function t(o,a){return a===ir?o.mapping=wi:a===sr&&(o.mapping=Vi),o}function n(o){if(o&&o.isTexture){const a=o.mapping;if(a===ir||a===sr)if(e.has(o)){const c=e.get(o).texture;return t(c,o.mapping)}else{const c=o.image;if(c&&c.height>0){const l=new qh(c.height);return l.fromEquirectangularTexture(s,o),e.set(o,l),o.addEventListener("dispose",i),t(l.texture,o.mapping)}else return null}}return o}function i(o){const a=o.target;a.removeEventListener("dispose",i);const c=e.get(a);c!==void 0&&(e.delete(a),c.dispose())}function r(){e=new WeakMap}return{get:n,dispose:r}}class oo extends Yc{constructor(e=-1,t=1,n=1,i=-1,r=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=o,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),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-e,o=n+e,a=i+t,c=i-t;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,o=r+l*this.view.width,a-=u*this.view.offsetY,c=a-u*this.view.height}this.projectionMatrix.makeOrthographic(r,o,a,c,this.near,this.far,this.coordinateSystem),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 Go=4,F0=[.125,.215,.35,.446,.526,.582],Vr=20,pp=new oo,O0=new _e;let fp=null,mp=0,gp=0,xp=!1;const Fr=(1+Math.sqrt(5))/2,Eo=1/Fr,V0=[new E(-Fr,Eo,0),new E(Fr,Eo,0),new E(-Eo,0,Fr),new E(Eo,0,Fr),new E(0,Fr,-Eo),new E(0,Fr,Eo),new E(-1,1,-1),new E(1,1,-1),new E(-1,1,1),new E(1,1,1)];let rh=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){fp=this._renderer.getRenderTarget(),mp=this._renderer.getActiveCubeFace(),gp=this._renderer.getActiveMipmapLevel(),xp=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(e,n,i,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=G0(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=k0(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.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._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(fp,mp,gp),this._renderer.xr.enabled=xp,e.scissorTest=!1,Hl(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===wi||e.mapping===Vi?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),fp=this._renderer.getRenderTarget(),mp=this._renderer.getActiveCubeFace(),gp=this._renderer.getActiveMipmapLevel(),xp=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Ut,minFilter:Ut,generateMipmaps:!1,type:Ln,format:Rn,colorSpace:li,depthBuffer:!1},i=z0(e,t,n),{_lodMax:r}=this;if({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=B0(r),this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=z0(e,t,n);const{_lodMax:o}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=B0(o)),this._blurMaterial=JE(o,e,t)}return i}_compileMaterial(e){const t=new kt(this._lodPlanes[0],e);this._renderer.compile(t,pp)}_sceneToCubeUV(e,t,n,i){const a=new hn(90,1,t,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,h=u.autoClear,d=u.toneMapping;u.getClearColor(O0),u.toneMapping=Ti,u.autoClear=!1;const p=new ss({name:"PMREM.Background",side:ln,depthWrite:!1,depthTest:!1}),f=new kt(new _s,p);let x=!1;const m=e.background;m?m.isColor&&(p.color.copy(m),e.background=null,x=!0):(p.color.copy(O0),x=!0);for(let g=0;g<6;g++){const y=g%3;y===0?(a.up.set(0,c[g],0),a.lookAt(l[g],0,0)):y===1?(a.up.set(0,0,c[g]),a.lookAt(0,l[g],0)):(a.up.set(0,c[g],0),a.lookAt(0,0,l[g]));const _=this._cubeSize;Hl(i,y*_,g>2?_:0,_,_),u.setRenderTarget(i),x&&u.render(f,a),u.render(e,a)}f.geometry.dispose(),f.material.dispose(),u.toneMapping=d,u.autoClear=h,e.background=m}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===wi||e.mapping===Vi;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=G0()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=k0());const r=i?this._cubemapMaterial:this._equirectMaterial,o=new kt(this._lodPlanes[0],r),a=r.uniforms;a.envMap.value=e;const c=this._cubeSize;Hl(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(o,pp)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const i=this._lodPlanes.length;for(let r=1;r<i;r++){const o=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),a=V0[(i-r-1)%V0.length];this._blur(e,r-1,r,o,a)}t.autoClear=n}_blur(e,t,n,i,r){const o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,i,"latitudinal",r),this._halfBlur(o,e,n,n,i,"longitudinal",r)}_halfBlur(e,t,n,i,r,o,a){const c=this._renderer,l=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const u=3,h=new kt(this._lodPlanes[i],l),d=l.uniforms,p=this._sizeLods[n]-1,f=isFinite(r)?Math.PI/(2*p):2*Math.PI/(2*Vr-1),x=r/f,m=isFinite(r)?1+Math.floor(u*x):Vr;m>Vr&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Vr}`);const g=[];let y=0;for(let w=0;w<Vr;++w){const C=w/x,F=Math.exp(-C*C/2);g.push(F),w===0?y+=F:w<m&&(y+=2*F)}for(let w=0;w<g.length;w++)g[w]=g[w]/y;d.envMap.value=e.texture,d.samples.value=m,d.weights.value=g,d.latitudinal.value=o==="latitudinal",a&&(d.poleAxis.value=a);const{_lodMax:_}=this;d.dTheta.value=f,d.mipInt.value=_-n;const v=this._sizeLods[i],I=3*v*(i>_-Go?i-_+Go:0),T=4*(this._cubeSize-v);Hl(t,I,T,3*v,2*v),c.setRenderTarget(t),c.render(h,pp)}};function B0(s){const e=[],t=[],n=[];let i=s;const r=s-Go+1+F0.length;for(let o=0;o<r;o++){const a=Math.pow(2,i);t.push(a);let c=1/a;o>s-Go?c=F0[o-s+Go-1]:o===0&&(c=0),n.push(c);const l=1/(a-2),u=-l,h=1+l,d=[u,u,h,u,h,h,u,u,h,h,u,h],p=6,f=6,x=3,m=2,g=1,y=new Float32Array(x*f*p),_=new Float32Array(m*f*p),v=new Float32Array(g*f*p);for(let T=0;T<p;T++){const w=T%3*2/3-1,C=T>2?0:-1,F=[w,C,0,w+2/3,C,0,w+2/3,C+1,0,w,C,0,w+2/3,C+1,0,w,C+1,0];y.set(F,x*f*T),_.set(d,m*f*T);const M=[T,T,T,T,T,T];v.set(M,g*f*T)}const I=new at;I.setAttribute("position",new At(y,x)),I.setAttribute("uv",new At(_,m)),I.setAttribute("faceIndex",new At(v,g)),e.push(I),i>Go&&i--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function z0(s,e,t){const n=new zi(s,e,t);return n.texture.mapping=hr,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Hl(s,e,t,n,i){s.viewport.set(e,t,n,i),s.scissor.set(e,t,n,i)}function JE(s,e,t){const n=new Float32Array(Vr),i=new E(0,1,0);return new ki({name:"SphericalGaussianBlur",defines:{n:Vr,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:im(),fragmentShader:`
3596
3596
 
3597
3597
  precision mediump float;
3598
3598
  precision mediump int;
@@ -3742,7 +3742,7 @@ void main() {
3742
3742
  gl_Position = vec4( position, 1.0 );
3743
3743
 
3744
3744
  }
3745
- `}function KE(s){let e=new WeakMap,t=null;function n(a){if(a&&a.isTexture){const c=a.mapping,l=c===ir||c===sr,u=c===wi||c===Vi;if(l||u){let h=e.get(a);const d=h!==void 0?h.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==d)return t===null&&(t=new rh(s)),h=l?t.fromEquirectangular(a,h):t.fromCubemap(a,h),h.texture.pmremVersion=a.pmremVersion,e.set(a,h),h.texture;if(h!==void 0)return h.texture;{const p=a.image;return l&&p&&p.height>0||u&&p&&i(p)?(t=new rh(s),h=l?t.fromEquirectangular(a):t.fromCubemap(a),h.texture.pmremVersion=a.pmremVersion,e.set(a,h),a.addEventListener("dispose",r),h.texture):null}}}return a}function i(a){let c=0;const l=6;for(let u=0;u<l;u++)a[u]!==void 0&&c++;return c===l}function r(a){const c=a.target;c.removeEventListener("dispose",r);const l=e.get(c);l!==void 0&&(e.delete(c),l.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:o}}function jE(s){const e={};function t(n){if(e[n]!==void 0)return e[n];let i;switch(n){case"WEBGL_depth_texture":i=s.getExtension("WEBGL_depth_texture")||s.getExtension("MOZ_WEBGL_depth_texture")||s.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=s.getExtension("EXT_texture_filter_anisotropic")||s.getExtension("MOZ_EXT_texture_filter_anisotropic")||s.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=s.getExtension("WEBGL_compressed_texture_s3tc")||s.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||s.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=s.getExtension("WEBGL_compressed_texture_pvrtc")||s.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=s.getExtension(n)}return e[n]=i,i}return{has:function(n){return t(n)!==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(n){const i=t(n);return i===null&&Cu("THREE.WebGLRenderer: "+n+" extension not supported."),i}}}function QE(s,e,t,n){const i={},r=new WeakMap;function o(h){const d=h.target;d.index!==null&&e.remove(d.index);for(const f in d.attributes)e.remove(d.attributes[f]);for(const f in d.morphAttributes){const x=d.morphAttributes[f];for(let m=0,g=x.length;m<g;m++)e.remove(x[m])}d.removeEventListener("dispose",o),delete i[d.id];const p=r.get(d);p&&(e.remove(p),r.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function a(h,d){return i[d.id]===!0||(d.addEventListener("dispose",o),i[d.id]=!0,t.memory.geometries++),d}function c(h){const d=h.attributes;for(const f in d)e.update(d[f],s.ARRAY_BUFFER);const p=h.morphAttributes;for(const f in p){const x=p[f];for(let m=0,g=x.length;m<g;m++)e.update(x[m],s.ARRAY_BUFFER)}}function l(h){const d=[],p=h.index,f=h.attributes.position;let x=0;if(p!==null){const y=p.array;x=p.version;for(let _=0,v=y.length;_<v;_+=3){const I=y[_+0],T=y[_+1],w=y[_+2];d.push(I,T,T,w,w,I)}}else if(f!==void 0){const y=f.array;x=f.version;for(let _=0,v=y.length/3-1;_<v;_+=3){const I=_+0,T=_+1,w=_+2;d.push(I,T,T,w,w,I)}}else return;const m=new(Uy(d)?tm:Wh)(d,1);m.version=x;const g=r.get(h);g&&e.remove(g),r.set(h,m)}function u(h){const d=r.get(h);if(d){const p=h.index;p!==null&&d.version<p.version&&l(h)}else l(h);return r.get(h)}return{get:a,update:c,getWireframeAttribute:u}}function eC(s,e,t){let n;function i(d){n=d}let r,o;function a(d){r=d.type,o=d.bytesPerElement}function c(d,p){s.drawElements(n,p,r,d*o),t.update(p,n,1)}function l(d,p,f){f!==0&&(s.drawElementsInstanced(n,p,r,d*o,f),t.update(p,n,f))}function u(d,p,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,p,0,r,d,0,f);let m=0;for(let g=0;g<f;g++)m+=p[g];t.update(m,n,1)}function h(d,p,f,x){if(f===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let g=0;g<d.length;g++)l(d[g]/o,p[g],x[g]);else{m.multiDrawElementsInstancedWEBGL(n,p,0,r,d,0,x,0,f);let g=0;for(let y=0;y<f;y++)g+=p[y];for(let y=0;y<x.length;y++)t.update(g,n,x[y])}}this.setMode=i,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=u,this.renderMultiDrawInstances=h}function tC(s){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,o,a){switch(t.calls++,o){case s.TRIANGLES:t.triangles+=a*(r/3);break;case s.LINES:t.lines+=a*(r/2);break;case s.LINE_STRIP:t.lines+=a*(r-1);break;case s.LINE_LOOP:t.lines+=a*r;break;case s.POINTS:t.points+=a*r;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function i(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:i,update:n}}function nC(s,e,t){const n=new WeakMap,i=new st;function r(o,a,c){const l=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,h=u!==void 0?u.length:0;let d=n.get(a);if(d===void 0||d.count!==h){let F=function(){w.dispose(),n.delete(a),a.removeEventListener("dispose",F)};d!==void 0&&d.texture.dispose();const p=a.morphAttributes.position!==void 0,f=a.morphAttributes.normal!==void 0,x=a.morphAttributes.color!==void 0,m=a.morphAttributes.position||[],g=a.morphAttributes.normal||[],y=a.morphAttributes.color||[];let _=0;p===!0&&(_=1),f===!0&&(_=2),x===!0&&(_=3);let v=a.attributes.position.count*_,I=1;v>e.maxTextureSize&&(I=Math.ceil(v/e.maxTextureSize),v=e.maxTextureSize);const T=new Float32Array(v*I*4*h),w=new qc(T,v,I,h);w.type=Gn,w.needsUpdate=!0;const C=_*4;for(let M=0;M<h;M++){const b=m[M],G=g[M],W=y[M],$=v*I*4*M;for(let ie=0;ie<b.count;ie++){const q=ie*C;p===!0&&(i.fromBufferAttribute(b,ie),T[$+q+0]=i.x,T[$+q+1]=i.y,T[$+q+2]=i.z,T[$+q+3]=0),f===!0&&(i.fromBufferAttribute(G,ie),T[$+q+4]=i.x,T[$+q+5]=i.y,T[$+q+6]=i.z,T[$+q+7]=0),x===!0&&(i.fromBufferAttribute(W,ie),T[$+q+8]=i.x,T[$+q+9]=i.y,T[$+q+10]=i.z,T[$+q+11]=W.itemSize===4?i.w:1)}}d={count:h,texture:w,size:new J(v,I)},n.set(a,d),a.addEventListener("dispose",F)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(s,"morphTexture",o.morphTexture,t);else{let p=0;for(let x=0;x<l.length;x++)p+=l[x];const f=a.morphTargetsRelative?1:1-p;c.getUniforms().setValue(s,"morphTargetBaseInfluence",f),c.getUniforms().setValue(s,"morphTargetInfluences",l)}c.getUniforms().setValue(s,"morphTargetsTexture",d.texture,t),c.getUniforms().setValue(s,"morphTargetsTextureSize",d.size)}return{update:r}}function iC(s,e,t,n){let i=new WeakMap;function r(c){const l=n.render.frame,u=c.geometry,h=e.get(c,u);if(i.get(h)!==l&&(e.update(h),i.set(h,l)),c.isInstancedMesh&&(c.hasEventListener("dispose",a)===!1&&c.addEventListener("dispose",a),i.get(c)!==l&&(t.update(c.instanceMatrix,s.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,s.ARRAY_BUFFER),i.set(c,l))),c.isSkinnedMesh){const d=c.skeleton;i.get(d)!==l&&(d.update(),i.set(d,l))}return h}function o(){i=new WeakMap}function a(c){const l=c.target;l.removeEventListener("dispose",a),t.remove(l.instanceMatrix),l.instanceColor!==null&&t.remove(l.instanceColor)}return{update:r,dispose:o}}class oo extends Xt{constructor(e,t,n,i,r,o,a,c,l,u=Qs){if(u!==Qs&&u!==ar)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&u===Qs&&(n=Bi),n===void 0&&u===ar&&(n=or),super(null,i,r,o,a,c,u,n,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:Qt,this.minFilter=c!==void 0?c:Qt,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}const Hy=new Xt,H0=new oo(1,1),Wy=new qc,Xy=new Hh,qy=new io,W0=[],X0=[],q0=new Float32Array(16),$0=new Float32Array(9),Y0=new Float32Array(4);function xa(s,e,t){const n=s[0];if(n<=0||n>0)return s;const i=e*t;let r=W0[i];if(r===void 0&&(r=new Float32Array(i),W0[i]=r),e!==0){n.toArray(r,0);for(let o=1,a=0;o!==e;++o)a+=t,s[o].toArray(r,a)}return r}function gn(s,e){if(s.length!==e.length)return!1;for(let t=0,n=s.length;t<n;t++)if(s[t]!==e[t])return!1;return!0}function xn(s,e){for(let t=0,n=e.length;t<n;t++)s[t]=e[t]}function $h(s,e){let t=X0[e];t===void 0&&(t=new Int32Array(e),X0[e]=t);for(let n=0;n!==e;++n)t[n]=s.allocateTextureUnit();return t}function sC(s,e){const t=this.cache;t[0]!==e&&(s.uniform1f(this.addr,e),t[0]=e)}function rC(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(gn(t,e))return;s.uniform2fv(this.addr,e),xn(t,e)}}function oC(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.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)&&(s.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(gn(t,e))return;s.uniform3fv(this.addr,e),xn(t,e)}}function aC(s,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)&&(s.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(gn(t,e))return;s.uniform4fv(this.addr,e),xn(t,e)}}function cC(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(gn(t,e))return;s.uniformMatrix2fv(this.addr,!1,e),xn(t,e)}else{if(gn(t,n))return;Y0.set(n),s.uniformMatrix2fv(this.addr,!1,Y0),xn(t,n)}}function lC(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(gn(t,e))return;s.uniformMatrix3fv(this.addr,!1,e),xn(t,e)}else{if(gn(t,n))return;$0.set(n),s.uniformMatrix3fv(this.addr,!1,$0),xn(t,n)}}function uC(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(gn(t,e))return;s.uniformMatrix4fv(this.addr,!1,e),xn(t,e)}else{if(gn(t,n))return;q0.set(n),s.uniformMatrix4fv(this.addr,!1,q0),xn(t,n)}}function hC(s,e){const t=this.cache;t[0]!==e&&(s.uniform1i(this.addr,e),t[0]=e)}function dC(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(gn(t,e))return;s.uniform2iv(this.addr,e),xn(t,e)}}function pC(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(gn(t,e))return;s.uniform3iv(this.addr,e),xn(t,e)}}function fC(s,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)&&(s.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(gn(t,e))return;s.uniform4iv(this.addr,e),xn(t,e)}}function mC(s,e){const t=this.cache;t[0]!==e&&(s.uniform1ui(this.addr,e),t[0]=e)}function gC(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(gn(t,e))return;s.uniform2uiv(this.addr,e),xn(t,e)}}function xC(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(gn(t,e))return;s.uniform3uiv(this.addr,e),xn(t,e)}}function _C(s,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)&&(s.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(gn(t,e))return;s.uniform4uiv(this.addr,e),xn(t,e)}}function yC(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i);let r;this.type===s.SAMPLER_2D_SHADOW?(H0.compareFunction=Qf,r=H0):r=Hy,t.setTexture2D(e||r,i)}function vC(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTexture3D(e||Xy,i)}function MC(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTextureCube(e||qy,i)}function SC(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTexture2DArray(e||Wy,i)}function TC(s){switch(s){case 5126:return sC;case 35664:return rC;case 35665:return oC;case 35666:return aC;case 35674:return cC;case 35675:return lC;case 35676:return uC;case 5124:case 35670:return hC;case 35667:case 35671:return dC;case 35668:case 35672:return pC;case 35669:case 35673:return fC;case 5125:return mC;case 36294:return gC;case 36295:return xC;case 36296:return _C;case 35678:case 36198:case 36298:case 36306:case 35682:return yC;case 35679:case 36299:case 36307:return vC;case 35680:case 36300:case 36308:case 36293:return MC;case 36289:case 36303:case 36311:case 36292:return SC}}function bC(s,e){s.uniform1fv(this.addr,e)}function wC(s,e){const t=xa(e,this.size,2);s.uniform2fv(this.addr,t)}function AC(s,e){const t=xa(e,this.size,3);s.uniform3fv(this.addr,t)}function NC(s,e){const t=xa(e,this.size,4);s.uniform4fv(this.addr,t)}function EC(s,e){const t=xa(e,this.size,4);s.uniformMatrix2fv(this.addr,!1,t)}function CC(s,e){const t=xa(e,this.size,9);s.uniformMatrix3fv(this.addr,!1,t)}function RC(s,e){const t=xa(e,this.size,16);s.uniformMatrix4fv(this.addr,!1,t)}function IC(s,e){s.uniform1iv(this.addr,e)}function PC(s,e){s.uniform2iv(this.addr,e)}function LC(s,e){s.uniform3iv(this.addr,e)}function DC(s,e){s.uniform4iv(this.addr,e)}function UC(s,e){s.uniform1uiv(this.addr,e)}function FC(s,e){s.uniform2uiv(this.addr,e)}function OC(s,e){s.uniform3uiv(this.addr,e)}function VC(s,e){s.uniform4uiv(this.addr,e)}function BC(s,e,t){const n=this.cache,i=e.length,r=$h(t,i);gn(n,r)||(s.uniform1iv(this.addr,r),xn(n,r));for(let o=0;o!==i;++o)t.setTexture2D(e[o]||Hy,r[o])}function zC(s,e,t){const n=this.cache,i=e.length,r=$h(t,i);gn(n,r)||(s.uniform1iv(this.addr,r),xn(n,r));for(let o=0;o!==i;++o)t.setTexture3D(e[o]||Xy,r[o])}function kC(s,e,t){const n=this.cache,i=e.length,r=$h(t,i);gn(n,r)||(s.uniform1iv(this.addr,r),xn(n,r));for(let o=0;o!==i;++o)t.setTextureCube(e[o]||qy,r[o])}function GC(s,e,t){const n=this.cache,i=e.length,r=$h(t,i);gn(n,r)||(s.uniform1iv(this.addr,r),xn(n,r));for(let o=0;o!==i;++o)t.setTexture2DArray(e[o]||Wy,r[o])}function HC(s){switch(s){case 5126:return bC;case 35664:return wC;case 35665:return AC;case 35666:return NC;case 35674:return EC;case 35675:return CC;case 35676:return RC;case 5124:case 35670:return IC;case 35667:case 35671:return PC;case 35668:case 35672:return LC;case 35669:case 35673:return DC;case 5125:return UC;case 36294:return FC;case 36295:return OC;case 36296:return VC;case 35678:case 36198:case 36298:case 36306:case 35682:return BC;case 35679:case 36299:case 36307:return zC;case 35680:case 36300:case 36308:case 36293:return kC;case 36289:case 36303:case 36311:case 36292:return GC}}class WC{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=TC(t.type)}}class XC{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=HC(t.type)}}class qC{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const i=this.seq;for(let r=0,o=i.length;r!==o;++r){const a=i[r];a.setValue(e,t[a.id],n)}}}const _p=/(\w+)(\])?(\[|\.)?/g;function Z0(s,e){s.seq.push(e),s.map[e.id]=e}function $C(s,e,t){const n=s.name,i=n.length;for(_p.lastIndex=0;;){const r=_p.exec(n),o=_p.lastIndex;let a=r[1];const c=r[2]==="]",l=r[3];if(c&&(a=a|0),l===void 0||l==="["&&o+2===i){Z0(t,l===void 0?new WC(a,s,e):new XC(a,s,e));break}else{let h=t.map[a];h===void 0&&(h=new qC(a),Z0(t,h)),t=h}}}class Ru{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){const r=e.getActiveUniform(t,i),o=e.getUniformLocation(t,r.name);$C(r,o,this)}}setValue(e,t,n,i){const r=this.map[t];r!==void 0&&r.setValue(e,n,i)}setOptional(e,t,n){const i=t[n];i!==void 0&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,o=t.length;r!==o;++r){const a=t[r],c=n[a.id];c.needsUpdate!==!1&&a.setValue(e,c.value,i)}}static seqWithValue(e,t){const n=[];for(let i=0,r=e.length;i!==r;++i){const o=e[i];o.id in t&&n.push(o)}return n}}function J0(s,e,t){const n=s.createShader(e);return s.shaderSource(n,t),s.compileShader(n),n}const YC=37297;let ZC=0;function JC(s,e){const t=s.split(`
3745
+ `}function KE(s){let e=new WeakMap,t=null;function n(a){if(a&&a.isTexture){const c=a.mapping,l=c===ir||c===sr,u=c===wi||c===Vi;if(l||u){let h=e.get(a);const d=h!==void 0?h.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==d)return t===null&&(t=new rh(s)),h=l?t.fromEquirectangular(a,h):t.fromCubemap(a,h),h.texture.pmremVersion=a.pmremVersion,e.set(a,h),h.texture;if(h!==void 0)return h.texture;{const p=a.image;return l&&p&&p.height>0||u&&p&&i(p)?(t=new rh(s),h=l?t.fromEquirectangular(a):t.fromCubemap(a),h.texture.pmremVersion=a.pmremVersion,e.set(a,h),a.addEventListener("dispose",r),h.texture):null}}}return a}function i(a){let c=0;const l=6;for(let u=0;u<l;u++)a[u]!==void 0&&c++;return c===l}function r(a){const c=a.target;c.removeEventListener("dispose",r);const l=e.get(c);l!==void 0&&(e.delete(c),l.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:o}}function jE(s){const e={};function t(n){if(e[n]!==void 0)return e[n];let i;switch(n){case"WEBGL_depth_texture":i=s.getExtension("WEBGL_depth_texture")||s.getExtension("MOZ_WEBGL_depth_texture")||s.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=s.getExtension("EXT_texture_filter_anisotropic")||s.getExtension("MOZ_EXT_texture_filter_anisotropic")||s.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=s.getExtension("WEBGL_compressed_texture_s3tc")||s.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||s.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=s.getExtension("WEBGL_compressed_texture_pvrtc")||s.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=s.getExtension(n)}return e[n]=i,i}return{has:function(n){return t(n)!==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(n){const i=t(n);return i===null&&Cu("THREE.WebGLRenderer: "+n+" extension not supported."),i}}}function QE(s,e,t,n){const i={},r=new WeakMap;function o(h){const d=h.target;d.index!==null&&e.remove(d.index);for(const f in d.attributes)e.remove(d.attributes[f]);for(const f in d.morphAttributes){const x=d.morphAttributes[f];for(let m=0,g=x.length;m<g;m++)e.remove(x[m])}d.removeEventListener("dispose",o),delete i[d.id];const p=r.get(d);p&&(e.remove(p),r.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function a(h,d){return i[d.id]===!0||(d.addEventListener("dispose",o),i[d.id]=!0,t.memory.geometries++),d}function c(h){const d=h.attributes;for(const f in d)e.update(d[f],s.ARRAY_BUFFER);const p=h.morphAttributes;for(const f in p){const x=p[f];for(let m=0,g=x.length;m<g;m++)e.update(x[m],s.ARRAY_BUFFER)}}function l(h){const d=[],p=h.index,f=h.attributes.position;let x=0;if(p!==null){const y=p.array;x=p.version;for(let _=0,v=y.length;_<v;_+=3){const I=y[_+0],T=y[_+1],w=y[_+2];d.push(I,T,T,w,w,I)}}else if(f!==void 0){const y=f.array;x=f.version;for(let _=0,v=y.length/3-1;_<v;_+=3){const I=_+0,T=_+1,w=_+2;d.push(I,T,T,w,w,I)}}else return;const m=new(Uy(d)?tm:Wh)(d,1);m.version=x;const g=r.get(h);g&&e.remove(g),r.set(h,m)}function u(h){const d=r.get(h);if(d){const p=h.index;p!==null&&d.version<p.version&&l(h)}else l(h);return r.get(h)}return{get:a,update:c,getWireframeAttribute:u}}function eC(s,e,t){let n;function i(d){n=d}let r,o;function a(d){r=d.type,o=d.bytesPerElement}function c(d,p){s.drawElements(n,p,r,d*o),t.update(p,n,1)}function l(d,p,f){f!==0&&(s.drawElementsInstanced(n,p,r,d*o,f),t.update(p,n,f))}function u(d,p,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,p,0,r,d,0,f);let m=0;for(let g=0;g<f;g++)m+=p[g];t.update(m,n,1)}function h(d,p,f,x){if(f===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let g=0;g<d.length;g++)l(d[g]/o,p[g],x[g]);else{m.multiDrawElementsInstancedWEBGL(n,p,0,r,d,0,x,0,f);let g=0;for(let y=0;y<f;y++)g+=p[y];for(let y=0;y<x.length;y++)t.update(g,n,x[y])}}this.setMode=i,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=u,this.renderMultiDrawInstances=h}function tC(s){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,o,a){switch(t.calls++,o){case s.TRIANGLES:t.triangles+=a*(r/3);break;case s.LINES:t.lines+=a*(r/2);break;case s.LINE_STRIP:t.lines+=a*(r-1);break;case s.LINE_LOOP:t.lines+=a*r;break;case s.POINTS:t.points+=a*r;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function i(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:i,update:n}}function nC(s,e,t){const n=new WeakMap,i=new st;function r(o,a,c){const l=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,h=u!==void 0?u.length:0;let d=n.get(a);if(d===void 0||d.count!==h){let F=function(){w.dispose(),n.delete(a),a.removeEventListener("dispose",F)};d!==void 0&&d.texture.dispose();const p=a.morphAttributes.position!==void 0,f=a.morphAttributes.normal!==void 0,x=a.morphAttributes.color!==void 0,m=a.morphAttributes.position||[],g=a.morphAttributes.normal||[],y=a.morphAttributes.color||[];let _=0;p===!0&&(_=1),f===!0&&(_=2),x===!0&&(_=3);let v=a.attributes.position.count*_,I=1;v>e.maxTextureSize&&(I=Math.ceil(v/e.maxTextureSize),v=e.maxTextureSize);const T=new Float32Array(v*I*4*h),w=new qc(T,v,I,h);w.type=Gn,w.needsUpdate=!0;const C=_*4;for(let M=0;M<h;M++){const b=m[M],G=g[M],W=y[M],$=v*I*4*M;for(let ie=0;ie<b.count;ie++){const q=ie*C;p===!0&&(i.fromBufferAttribute(b,ie),T[$+q+0]=i.x,T[$+q+1]=i.y,T[$+q+2]=i.z,T[$+q+3]=0),f===!0&&(i.fromBufferAttribute(G,ie),T[$+q+4]=i.x,T[$+q+5]=i.y,T[$+q+6]=i.z,T[$+q+7]=0),x===!0&&(i.fromBufferAttribute(W,ie),T[$+q+8]=i.x,T[$+q+9]=i.y,T[$+q+10]=i.z,T[$+q+11]=W.itemSize===4?i.w:1)}}d={count:h,texture:w,size:new J(v,I)},n.set(a,d),a.addEventListener("dispose",F)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(s,"morphTexture",o.morphTexture,t);else{let p=0;for(let x=0;x<l.length;x++)p+=l[x];const f=a.morphTargetsRelative?1:1-p;c.getUniforms().setValue(s,"morphTargetBaseInfluence",f),c.getUniforms().setValue(s,"morphTargetInfluences",l)}c.getUniforms().setValue(s,"morphTargetsTexture",d.texture,t),c.getUniforms().setValue(s,"morphTargetsTextureSize",d.size)}return{update:r}}function iC(s,e,t,n){let i=new WeakMap;function r(c){const l=n.render.frame,u=c.geometry,h=e.get(c,u);if(i.get(h)!==l&&(e.update(h),i.set(h,l)),c.isInstancedMesh&&(c.hasEventListener("dispose",a)===!1&&c.addEventListener("dispose",a),i.get(c)!==l&&(t.update(c.instanceMatrix,s.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,s.ARRAY_BUFFER),i.set(c,l))),c.isSkinnedMesh){const d=c.skeleton;i.get(d)!==l&&(d.update(),i.set(d,l))}return h}function o(){i=new WeakMap}function a(c){const l=c.target;l.removeEventListener("dispose",a),t.remove(l.instanceMatrix),l.instanceColor!==null&&t.remove(l.instanceColor)}return{update:r,dispose:o}}class ao extends Xt{constructor(e,t,n,i,r,o,a,c,l,u=Qs){if(u!==Qs&&u!==ar)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&u===Qs&&(n=Bi),n===void 0&&u===ar&&(n=or),super(null,i,r,o,a,c,u,n,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:Qt,this.minFilter=c!==void 0?c:Qt,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}const Hy=new Xt,H0=new ao(1,1),Wy=new qc,Xy=new Hh,qy=new so,W0=[],X0=[],q0=new Float32Array(16),$0=new Float32Array(9),Y0=new Float32Array(4);function xa(s,e,t){const n=s[0];if(n<=0||n>0)return s;const i=e*t;let r=W0[i];if(r===void 0&&(r=new Float32Array(i),W0[i]=r),e!==0){n.toArray(r,0);for(let o=1,a=0;o!==e;++o)a+=t,s[o].toArray(r,a)}return r}function gn(s,e){if(s.length!==e.length)return!1;for(let t=0,n=s.length;t<n;t++)if(s[t]!==e[t])return!1;return!0}function xn(s,e){for(let t=0,n=e.length;t<n;t++)s[t]=e[t]}function $h(s,e){let t=X0[e];t===void 0&&(t=new Int32Array(e),X0[e]=t);for(let n=0;n!==e;++n)t[n]=s.allocateTextureUnit();return t}function sC(s,e){const t=this.cache;t[0]!==e&&(s.uniform1f(this.addr,e),t[0]=e)}function rC(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(gn(t,e))return;s.uniform2fv(this.addr,e),xn(t,e)}}function oC(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.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)&&(s.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(gn(t,e))return;s.uniform3fv(this.addr,e),xn(t,e)}}function aC(s,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)&&(s.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(gn(t,e))return;s.uniform4fv(this.addr,e),xn(t,e)}}function cC(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(gn(t,e))return;s.uniformMatrix2fv(this.addr,!1,e),xn(t,e)}else{if(gn(t,n))return;Y0.set(n),s.uniformMatrix2fv(this.addr,!1,Y0),xn(t,n)}}function lC(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(gn(t,e))return;s.uniformMatrix3fv(this.addr,!1,e),xn(t,e)}else{if(gn(t,n))return;$0.set(n),s.uniformMatrix3fv(this.addr,!1,$0),xn(t,n)}}function uC(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(gn(t,e))return;s.uniformMatrix4fv(this.addr,!1,e),xn(t,e)}else{if(gn(t,n))return;q0.set(n),s.uniformMatrix4fv(this.addr,!1,q0),xn(t,n)}}function hC(s,e){const t=this.cache;t[0]!==e&&(s.uniform1i(this.addr,e),t[0]=e)}function dC(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(gn(t,e))return;s.uniform2iv(this.addr,e),xn(t,e)}}function pC(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(gn(t,e))return;s.uniform3iv(this.addr,e),xn(t,e)}}function fC(s,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)&&(s.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(gn(t,e))return;s.uniform4iv(this.addr,e),xn(t,e)}}function mC(s,e){const t=this.cache;t[0]!==e&&(s.uniform1ui(this.addr,e),t[0]=e)}function gC(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(gn(t,e))return;s.uniform2uiv(this.addr,e),xn(t,e)}}function xC(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(gn(t,e))return;s.uniform3uiv(this.addr,e),xn(t,e)}}function _C(s,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)&&(s.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(gn(t,e))return;s.uniform4uiv(this.addr,e),xn(t,e)}}function yC(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i);let r;this.type===s.SAMPLER_2D_SHADOW?(H0.compareFunction=Qf,r=H0):r=Hy,t.setTexture2D(e||r,i)}function vC(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTexture3D(e||Xy,i)}function MC(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTextureCube(e||qy,i)}function SC(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTexture2DArray(e||Wy,i)}function TC(s){switch(s){case 5126:return sC;case 35664:return rC;case 35665:return oC;case 35666:return aC;case 35674:return cC;case 35675:return lC;case 35676:return uC;case 5124:case 35670:return hC;case 35667:case 35671:return dC;case 35668:case 35672:return pC;case 35669:case 35673:return fC;case 5125:return mC;case 36294:return gC;case 36295:return xC;case 36296:return _C;case 35678:case 36198:case 36298:case 36306:case 35682:return yC;case 35679:case 36299:case 36307:return vC;case 35680:case 36300:case 36308:case 36293:return MC;case 36289:case 36303:case 36311:case 36292:return SC}}function bC(s,e){s.uniform1fv(this.addr,e)}function wC(s,e){const t=xa(e,this.size,2);s.uniform2fv(this.addr,t)}function AC(s,e){const t=xa(e,this.size,3);s.uniform3fv(this.addr,t)}function NC(s,e){const t=xa(e,this.size,4);s.uniform4fv(this.addr,t)}function EC(s,e){const t=xa(e,this.size,4);s.uniformMatrix2fv(this.addr,!1,t)}function CC(s,e){const t=xa(e,this.size,9);s.uniformMatrix3fv(this.addr,!1,t)}function RC(s,e){const t=xa(e,this.size,16);s.uniformMatrix4fv(this.addr,!1,t)}function IC(s,e){s.uniform1iv(this.addr,e)}function PC(s,e){s.uniform2iv(this.addr,e)}function LC(s,e){s.uniform3iv(this.addr,e)}function DC(s,e){s.uniform4iv(this.addr,e)}function UC(s,e){s.uniform1uiv(this.addr,e)}function FC(s,e){s.uniform2uiv(this.addr,e)}function OC(s,e){s.uniform3uiv(this.addr,e)}function VC(s,e){s.uniform4uiv(this.addr,e)}function BC(s,e,t){const n=this.cache,i=e.length,r=$h(t,i);gn(n,r)||(s.uniform1iv(this.addr,r),xn(n,r));for(let o=0;o!==i;++o)t.setTexture2D(e[o]||Hy,r[o])}function zC(s,e,t){const n=this.cache,i=e.length,r=$h(t,i);gn(n,r)||(s.uniform1iv(this.addr,r),xn(n,r));for(let o=0;o!==i;++o)t.setTexture3D(e[o]||Xy,r[o])}function kC(s,e,t){const n=this.cache,i=e.length,r=$h(t,i);gn(n,r)||(s.uniform1iv(this.addr,r),xn(n,r));for(let o=0;o!==i;++o)t.setTextureCube(e[o]||qy,r[o])}function GC(s,e,t){const n=this.cache,i=e.length,r=$h(t,i);gn(n,r)||(s.uniform1iv(this.addr,r),xn(n,r));for(let o=0;o!==i;++o)t.setTexture2DArray(e[o]||Wy,r[o])}function HC(s){switch(s){case 5126:return bC;case 35664:return wC;case 35665:return AC;case 35666:return NC;case 35674:return EC;case 35675:return CC;case 35676:return RC;case 5124:case 35670:return IC;case 35667:case 35671:return PC;case 35668:case 35672:return LC;case 35669:case 35673:return DC;case 5125:return UC;case 36294:return FC;case 36295:return OC;case 36296:return VC;case 35678:case 36198:case 36298:case 36306:case 35682:return BC;case 35679:case 36299:case 36307:return zC;case 35680:case 36300:case 36308:case 36293:return kC;case 36289:case 36303:case 36311:case 36292:return GC}}class WC{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=TC(t.type)}}class XC{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=HC(t.type)}}class qC{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const i=this.seq;for(let r=0,o=i.length;r!==o;++r){const a=i[r];a.setValue(e,t[a.id],n)}}}const _p=/(\w+)(\])?(\[|\.)?/g;function Z0(s,e){s.seq.push(e),s.map[e.id]=e}function $C(s,e,t){const n=s.name,i=n.length;for(_p.lastIndex=0;;){const r=_p.exec(n),o=_p.lastIndex;let a=r[1];const c=r[2]==="]",l=r[3];if(c&&(a=a|0),l===void 0||l==="["&&o+2===i){Z0(t,l===void 0?new WC(a,s,e):new XC(a,s,e));break}else{let h=t.map[a];h===void 0&&(h=new qC(a),Z0(t,h)),t=h}}}class Ru{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){const r=e.getActiveUniform(t,i),o=e.getUniformLocation(t,r.name);$C(r,o,this)}}setValue(e,t,n,i){const r=this.map[t];r!==void 0&&r.setValue(e,n,i)}setOptional(e,t,n){const i=t[n];i!==void 0&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,o=t.length;r!==o;++r){const a=t[r],c=n[a.id];c.needsUpdate!==!1&&a.setValue(e,c.value,i)}}static seqWithValue(e,t){const n=[];for(let i=0,r=e.length;i!==r;++i){const o=e[i];o.id in t&&n.push(o)}return n}}function J0(s,e,t){const n=s.createShader(e);return s.shaderSource(n,t),s.compileShader(n),n}const YC=37297;let ZC=0;function JC(s,e){const t=s.split(`
3746
3746
  `),n=[],i=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let o=i;o<r;o++){const a=o+1;n.push(`${a===e?">":" "} ${a}: ${t[o]}`)}return n.join(`
3747
3747
  `)}function KC(s){const e=gt.getPrimaries(gt.workingColorSpace),t=gt.getPrimaries(s);let n;switch(e===t?n="":e===Ec&&t===Nc?n="LinearDisplayP3ToLinearSRGB":e===Nc&&t===Ec&&(n="LinearSRGBToLinearDisplayP3"),s){case li:case Xc:return[n,"LinearTransferOETF"];case kn:case kh:return[n,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",s),[n,"LinearTransferOETF"]}}function K0(s,e,t){const n=s.getShaderParameter(e,s.COMPILE_STATUS),i=s.getShaderInfoLog(e).trim();if(n&&i==="")return"";const r=/ERROR: 0:(\d+)/.exec(i);if(r){const o=parseInt(r[1]);return t.toUpperCase()+`
3748
3748
 
@@ -3820,7 +3820,7 @@ void main() {
3820
3820
  squared_mean = squared_mean / samples;
3821
3821
  float std_dev = sqrt( squared_mean - mean * mean );
3822
3822
  gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3823
- }`;function RR(s,e,t){let n=new ga;const i=new J,r=new J,o=new st,a=new Yh({depthPacking:Jf}),c=new sm,l={},u=t.maxTextureSize,h={[fs]:ln,[ln]:fs,[Ji]:Ji},d=new ki({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new J},radius:{value:4}},vertexShader:ER,fragmentShader:CR}),p=d.clone();p.defines.HORIZONTAL_PASS=1;const f=new at;f.setAttribute("position",new At(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const x=new kt(f,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Lf;let g=this.type;this.render=function(T,w,C){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||T.length===0)return;const F=s.getRenderTarget(),M=s.getActiveCubeFace(),b=s.getActiveMipmapLevel(),G=s.state;G.setBlending(Fi),G.buffers.color.setClear(1,1,1,1),G.buffers.depth.setTest(!0),G.setScissorTest(!1);const W=g!==oi&&this.type===oi,$=g===oi&&this.type!==oi;for(let ie=0,q=T.length;ie<q;ie++){const he=T[ie],Q=he.shadow;if(Q===void 0){console.warn("THREE.WebGLShadowMap:",he,"has no shadow.");continue}if(Q.autoUpdate===!1&&Q.needsUpdate===!1)continue;i.copy(Q.mapSize);const we=Q.getFrameExtents();if(i.multiply(we),r.copy(Q.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(r.x=Math.floor(u/we.x),i.x=r.x*we.x,Q.mapSize.x=r.x),i.y>u&&(r.y=Math.floor(u/we.y),i.y=r.y*we.y,Q.mapSize.y=r.y)),Q.map===null||W===!0||$===!0){const Ee=this.type!==oi?{minFilter:Qt,magFilter:Qt}:{};Q.map!==null&&Q.map.dispose(),Q.map=new zi(i.x,i.y,Ee),Q.map.texture.name=he.name+".shadowMap",Q.camera.updateProjectionMatrix()}s.setRenderTarget(Q.map),s.clear();const Ne=Q.getViewportCount();for(let Ee=0;Ee<Ne;Ee++){const Qe=Q.getViewport(Ee);o.set(r.x*Qe.x,r.y*Qe.y,r.x*Qe.z,r.y*Qe.w),G.viewport(o),Q.updateMatrices(he,Ee),n=Q.getFrustum(),v(w,C,Q.camera,he,this.type)}Q.isPointLightShadow!==!0&&this.type===oi&&y(Q,C),Q.needsUpdate=!1}g=this.type,m.needsUpdate=!1,s.setRenderTarget(F,M,b)};function y(T,w){const C=e.update(x);d.defines.VSM_SAMPLES!==T.blurSamples&&(d.defines.VSM_SAMPLES=T.blurSamples,p.defines.VSM_SAMPLES=T.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),T.mapPass===null&&(T.mapPass=new zi(i.x,i.y)),d.uniforms.shadow_pass.value=T.map.texture,d.uniforms.resolution.value=T.mapSize,d.uniforms.radius.value=T.radius,s.setRenderTarget(T.mapPass),s.clear(),s.renderBufferDirect(w,null,C,d,x,null),p.uniforms.shadow_pass.value=T.mapPass.texture,p.uniforms.resolution.value=T.mapSize,p.uniforms.radius.value=T.radius,s.setRenderTarget(T.map),s.clear(),s.renderBufferDirect(w,null,C,p,x,null)}function _(T,w,C,F){let M=null;const b=C.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(b!==void 0)M=b;else if(M=C.isPointLight===!0?c:a,s.localClippingEnabled&&w.clipShadows===!0&&Array.isArray(w.clippingPlanes)&&w.clippingPlanes.length!==0||w.displacementMap&&w.displacementScale!==0||w.alphaMap&&w.alphaTest>0||w.map&&w.alphaTest>0){const G=M.uuid,W=w.uuid;let $=l[G];$===void 0&&($={},l[G]=$);let ie=$[W];ie===void 0&&(ie=M.clone(),$[W]=ie,w.addEventListener("dispose",I)),M=ie}if(M.visible=w.visible,M.wireframe=w.wireframe,F===oi?M.side=w.shadowSide!==null?w.shadowSide:w.side:M.side=w.shadowSide!==null?w.shadowSide:h[w.side],M.alphaMap=w.alphaMap,M.alphaTest=w.alphaTest,M.map=w.map,M.clipShadows=w.clipShadows,M.clippingPlanes=w.clippingPlanes,M.clipIntersection=w.clipIntersection,M.displacementMap=w.displacementMap,M.displacementScale=w.displacementScale,M.displacementBias=w.displacementBias,M.wireframeLinewidth=w.wireframeLinewidth,M.linewidth=w.linewidth,C.isPointLight===!0&&M.isMeshDistanceMaterial===!0){const G=s.properties.get(M);G.light=C}return M}function v(T,w,C,F,M){if(T.visible===!1)return;if(T.layers.test(w.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&M===oi)&&(!T.frustumCulled||n.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(C.matrixWorldInverse,T.matrixWorld);const W=e.update(T),$=T.material;if(Array.isArray($)){const ie=W.groups;for(let q=0,he=ie.length;q<he;q++){const Q=ie[q],we=$[Q.materialIndex];if(we&&we.visible){const Ne=_(T,we,F,M);T.onBeforeShadow(s,T,w,C,W,Ne,Q),s.renderBufferDirect(C,null,W,Ne,T,Q),T.onAfterShadow(s,T,w,C,W,Ne,Q)}}}else if($.visible){const ie=_(T,$,F,M);T.onBeforeShadow(s,T,w,C,W,ie,null),s.renderBufferDirect(C,null,W,ie,T,null),T.onAfterShadow(s,T,w,C,W,ie,null)}}const G=T.children;for(let W=0,$=G.length;W<$;W++)v(G[W],w,C,F,M)}function I(T){T.target.removeEventListener("dispose",I);for(const C in l){const F=l[C],M=T.target.uuid;M in F&&(F[M].dispose(),delete F[M])}}}const IR={[lc]:uc,[hc]:fc,[dc]:mc,[nr]:pc,[uc]:lc,[fc]:hc,[mc]:dc,[pc]:nr};function PR(s){function e(){let O=!1;const Pe=new st;let ee=null;const le=new st(0,0,0,0);return{setMask:function(Ce){ee!==Ce&&!O&&(s.colorMask(Ce,Ce,Ce,Ce),ee=Ce)},setLocked:function(Ce){O=Ce},setClear:function(Ce,Le,bt,on,ni){ni===!0&&(Ce*=on,Le*=on,bt*=on),Pe.set(Ce,Le,bt,on),le.equals(Pe)===!1&&(s.clearColor(Ce,Le,bt,on),le.copy(Pe))},reset:function(){O=!1,ee=null,le.set(-1,0,0,0)}}}function t(){let O=!1,Pe=!1,ee=null,le=null,Ce=null;return{setReversed:function(Le){Pe=Le},setTest:function(Le){Le?Ae(s.DEPTH_TEST):ge(s.DEPTH_TEST)},setMask:function(Le){ee!==Le&&!O&&(s.depthMask(Le),ee=Le)},setFunc:function(Le){if(Pe&&(Le=IR[Le]),le!==Le){switch(Le){case lc:s.depthFunc(s.NEVER);break;case uc:s.depthFunc(s.ALWAYS);break;case hc:s.depthFunc(s.LESS);break;case nr:s.depthFunc(s.LEQUAL);break;case dc:s.depthFunc(s.EQUAL);break;case pc:s.depthFunc(s.GEQUAL);break;case fc:s.depthFunc(s.GREATER);break;case mc:s.depthFunc(s.NOTEQUAL);break;default:s.depthFunc(s.LEQUAL)}le=Le}},setLocked:function(Le){O=Le},setClear:function(Le){Ce!==Le&&(s.clearDepth(Le),Ce=Le)},reset:function(){O=!1,ee=null,le=null,Ce=null}}}function n(){let O=!1,Pe=null,ee=null,le=null,Ce=null,Le=null,bt=null,on=null,ni=null;return{setTest:function(Et){O||(Et?Ae(s.STENCIL_TEST):ge(s.STENCIL_TEST))},setMask:function(Et){Pe!==Et&&!O&&(s.stencilMask(Et),Pe=Et)},setFunc:function(Et,ii,vs){(ee!==Et||le!==ii||Ce!==vs)&&(s.stencilFunc(Et,ii,vs),ee=Et,le=ii,Ce=vs)},setOp:function(Et,ii,vs){(Le!==Et||bt!==ii||on!==vs)&&(s.stencilOp(Et,ii,vs),Le=Et,bt=ii,on=vs)},setLocked:function(Et){O=Et},setClear:function(Et){ni!==Et&&(s.clearStencil(Et),ni=Et)},reset:function(){O=!1,Pe=null,ee=null,le=null,Ce=null,Le=null,bt=null,on=null,ni=null}}}const i=new e,r=new t,o=new n,a=new WeakMap,c=new WeakMap;let l={},u={},h=new WeakMap,d=[],p=null,f=!1,x=null,m=null,g=null,y=null,_=null,v=null,I=null,T=new _e(0,0,0),w=0,C=!1,F=null,M=null,b=null,G=null,W=null;const $=s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let ie=!1,q=0;const he=s.getParameter(s.VERSION);he.indexOf("WebGL")!==-1?(q=parseFloat(/^WebGL (\d)/.exec(he)[1]),ie=q>=1):he.indexOf("OpenGL ES")!==-1&&(q=parseFloat(/^OpenGL ES (\d)/.exec(he)[1]),ie=q>=2);let Q=null,we={};const Ne=s.getParameter(s.SCISSOR_BOX),Ee=s.getParameter(s.VIEWPORT),Qe=new st().fromArray(Ne),ht=new st().fromArray(Ee);function ne(O,Pe,ee,le){const Ce=new Uint8Array(4),Le=s.createTexture();s.bindTexture(O,Le),s.texParameteri(O,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(O,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let bt=0;bt<ee;bt++)O===s.TEXTURE_3D||O===s.TEXTURE_2D_ARRAY?s.texImage3D(Pe,0,s.RGBA,1,1,le,0,s.RGBA,s.UNSIGNED_BYTE,Ce):s.texImage2D(Pe+bt,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,Ce);return Le}const ue={};ue[s.TEXTURE_2D]=ne(s.TEXTURE_2D,s.TEXTURE_2D,1),ue[s.TEXTURE_CUBE_MAP]=ne(s.TEXTURE_CUBE_MAP,s.TEXTURE_CUBE_MAP_POSITIVE_X,6),ue[s.TEXTURE_2D_ARRAY]=ne(s.TEXTURE_2D_ARRAY,s.TEXTURE_2D_ARRAY,1,1),ue[s.TEXTURE_3D]=ne(s.TEXTURE_3D,s.TEXTURE_3D,1,1),i.setClear(0,0,0,1),r.setClear(1),o.setClear(0),Ae(s.DEPTH_TEST),r.setFunc(nr),ye(!1),de(sf),Ae(s.CULL_FACE),P(Fi);function Ae(O){l[O]!==!0&&(s.enable(O),l[O]=!0)}function ge(O){l[O]!==!1&&(s.disable(O),l[O]=!1)}function Ze(O,Pe){return u[O]!==Pe?(s.bindFramebuffer(O,Pe),u[O]=Pe,O===s.DRAW_FRAMEBUFFER&&(u[s.FRAMEBUFFER]=Pe),O===s.FRAMEBUFFER&&(u[s.DRAW_FRAMEBUFFER]=Pe),!0):!1}function Xe(O,Pe){let ee=d,le=!1;if(O){ee=h.get(Pe),ee===void 0&&(ee=[],h.set(Pe,ee));const Ce=O.textures;if(ee.length!==Ce.length||ee[0]!==s.COLOR_ATTACHMENT0){for(let Le=0,bt=Ce.length;Le<bt;Le++)ee[Le]=s.COLOR_ATTACHMENT0+Le;ee.length=Ce.length,le=!0}}else ee[0]!==s.BACK&&(ee[0]=s.BACK,le=!0);le&&s.drawBuffers(ee)}function Je(O){return p!==O?(s.useProgram(O),p=O,!0):!1}const dt={[Zs]:s.FUNC_ADD,[q_]:s.FUNC_SUBTRACT,[$_]:s.FUNC_REVERSE_SUBTRACT};dt[Y_]=s.MIN,dt[Ff]=s.MAX;const ae={[Z_]:s.ZERO,[J_]:s.ONE,[K_]:s.SRC_COLOR,[Ou]:s.SRC_ALPHA,[iy]:s.SRC_ALPHA_SATURATE,[ty]:s.DST_COLOR,[Q_]:s.DST_ALPHA,[j_]:s.ONE_MINUS_SRC_COLOR,[Vu]:s.ONE_MINUS_SRC_ALPHA,[ny]:s.ONE_MINUS_DST_COLOR,[ey]:s.ONE_MINUS_DST_ALPHA,[sy]:s.CONSTANT_COLOR,[ry]:s.ONE_MINUS_CONSTANT_COLOR,[oy]:s.CONSTANT_ALPHA,[ay]:s.ONE_MINUS_CONSTANT_ALPHA};function P(O,Pe,ee,le,Ce,Le,bt,on,ni,Et){if(O===Fi){f===!0&&(ge(s.BLEND),f=!1);return}if(f===!1&&(Ae(s.BLEND),f=!0),O!==Uf){if(O!==x||Et!==C){if((m!==Zs||_!==Zs)&&(s.blendEquation(s.FUNC_ADD),m=Zs,_=Zs),Et)switch(O){case Ps:s.blendFuncSeparate(s.ONE,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case cc:s.blendFunc(s.ONE,s.ONE);break;case rf:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case of:s.blendFuncSeparate(s.ZERO,s.SRC_COLOR,s.ZERO,s.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",O);break}else switch(O){case Ps:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case cc:s.blendFunc(s.SRC_ALPHA,s.ONE);break;case rf:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case of:s.blendFunc(s.ZERO,s.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",O);break}g=null,y=null,v=null,I=null,T.set(0,0,0),w=0,x=O,C=Et}return}Ce=Ce||Pe,Le=Le||ee,bt=bt||le,(Pe!==m||Ce!==_)&&(s.blendEquationSeparate(dt[Pe],dt[Ce]),m=Pe,_=Ce),(ee!==g||le!==y||Le!==v||bt!==I)&&(s.blendFuncSeparate(ae[ee],ae[le],ae[Le],ae[bt]),g=ee,y=le,v=Le,I=bt),(on.equals(T)===!1||ni!==w)&&(s.blendColor(on.r,on.g,on.b,ni),T.copy(on),w=ni),x=O,C=!1}function Me(O,Pe){O.side===Ji?ge(s.CULL_FACE):Ae(s.CULL_FACE);let ee=O.side===ln;Pe&&(ee=!ee),ye(ee),O.blending===Ps&&O.transparent===!1?P(Fi):P(O.blending,O.blendEquation,O.blendSrc,O.blendDst,O.blendEquationAlpha,O.blendSrcAlpha,O.blendDstAlpha,O.blendColor,O.blendAlpha,O.premultipliedAlpha),r.setFunc(O.depthFunc),r.setTest(O.depthTest),r.setMask(O.depthWrite),i.setMask(O.colorWrite);const le=O.stencilWrite;o.setTest(le),le&&(o.setMask(O.stencilWriteMask),o.setFunc(O.stencilFunc,O.stencilRef,O.stencilFuncMask),o.setOp(O.stencilFail,O.stencilZFail,O.stencilZPass)),qe(O.polygonOffset,O.polygonOffsetFactor,O.polygonOffsetUnits),O.alphaToCoverage===!0?Ae(s.SAMPLE_ALPHA_TO_COVERAGE):ge(s.SAMPLE_ALPHA_TO_COVERAGE)}function ye(O){F!==O&&(O?s.frontFace(s.CW):s.frontFace(s.CCW),F=O)}function de(O){O!==W_?(Ae(s.CULL_FACE),O!==M&&(O===sf?s.cullFace(s.BACK):O===X_?s.cullFace(s.FRONT):s.cullFace(s.FRONT_AND_BACK))):ge(s.CULL_FACE),M=O}function Te(O){O!==b&&(ie&&s.lineWidth(O),b=O)}function qe(O,Pe,ee){O?(Ae(s.POLYGON_OFFSET_FILL),(G!==Pe||W!==ee)&&(s.polygonOffset(Pe,ee),G=Pe,W=ee)):ge(s.POLYGON_OFFSET_FILL)}function Ie(O){O?Ae(s.SCISSOR_TEST):ge(s.SCISSOR_TEST)}function R(O){O===void 0&&(O=s.TEXTURE0+$-1),Q!==O&&(s.activeTexture(O),Q=O)}function S(O,Pe,ee){ee===void 0&&(Q===null?ee=s.TEXTURE0+$-1:ee=Q);let le=we[ee];le===void 0&&(le={type:void 0,texture:void 0},we[ee]=le),(le.type!==O||le.texture!==Pe)&&(Q!==ee&&(s.activeTexture(ee),Q=ee),s.bindTexture(O,Pe||ue[O]),le.type=O,le.texture=Pe)}function X(){const O=we[Q];O!==void 0&&O.type!==void 0&&(s.bindTexture(O.type,null),O.type=void 0,O.texture=void 0)}function re(){try{s.compressedTexImage2D.apply(s,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function ce(){try{s.compressedTexImage3D.apply(s,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function se(){try{s.texSubImage2D.apply(s,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function ke(){try{s.texSubImage3D.apply(s,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function be(){try{s.compressedTexSubImage2D.apply(s,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function De(){try{s.compressedTexSubImage3D.apply(s,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function vt(){try{s.texStorage2D.apply(s,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function me(){try{s.texStorage3D.apply(s,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function Ue(){try{s.texImage2D.apply(s,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function tt(){try{s.texImage3D.apply(s,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function nt(O){Qe.equals(O)===!1&&(s.scissor(O.x,O.y,O.z,O.w),Qe.copy(O))}function Be(O){ht.equals(O)===!1&&(s.viewport(O.x,O.y,O.z,O.w),ht.copy(O))}function Mt(O,Pe){let ee=c.get(Pe);ee===void 0&&(ee=new WeakMap,c.set(Pe,ee));let le=ee.get(O);le===void 0&&(le=s.getUniformBlockIndex(Pe,O.name),ee.set(O,le))}function ct(O,Pe){const le=c.get(Pe).get(O);a.get(Pe)!==le&&(s.uniformBlockBinding(Pe,le,O.__bindingPointIndex),a.set(Pe,le))}function Ot(){s.disable(s.BLEND),s.disable(s.CULL_FACE),s.disable(s.DEPTH_TEST),s.disable(s.POLYGON_OFFSET_FILL),s.disable(s.SCISSOR_TEST),s.disable(s.STENCIL_TEST),s.disable(s.SAMPLE_ALPHA_TO_COVERAGE),s.blendEquation(s.FUNC_ADD),s.blendFunc(s.ONE,s.ZERO),s.blendFuncSeparate(s.ONE,s.ZERO,s.ONE,s.ZERO),s.blendColor(0,0,0,0),s.colorMask(!0,!0,!0,!0),s.clearColor(0,0,0,0),s.depthMask(!0),s.depthFunc(s.LESS),s.clearDepth(1),s.stencilMask(4294967295),s.stencilFunc(s.ALWAYS,0,4294967295),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),s.clearStencil(0),s.cullFace(s.BACK),s.frontFace(s.CCW),s.polygonOffset(0,0),s.activeTexture(s.TEXTURE0),s.bindFramebuffer(s.FRAMEBUFFER,null),s.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),s.bindFramebuffer(s.READ_FRAMEBUFFER,null),s.useProgram(null),s.lineWidth(1),s.scissor(0,0,s.canvas.width,s.canvas.height),s.viewport(0,0,s.canvas.width,s.canvas.height),l={},Q=null,we={},u={},h=new WeakMap,d=[],p=null,f=!1,x=null,m=null,g=null,y=null,_=null,v=null,I=null,T=new _e(0,0,0),w=0,C=!1,F=null,M=null,b=null,G=null,W=null,Qe.set(0,0,s.canvas.width,s.canvas.height),ht.set(0,0,s.canvas.width,s.canvas.height),i.reset(),r.reset(),o.reset()}return{buffers:{color:i,depth:r,stencil:o},enable:Ae,disable:ge,bindFramebuffer:Ze,drawBuffers:Xe,useProgram:Je,setBlending:P,setMaterial:Me,setFlipSided:ye,setCullFace:de,setLineWidth:Te,setPolygonOffset:qe,setScissorTest:Ie,activeTexture:R,bindTexture:S,unbindTexture:X,compressedTexImage2D:re,compressedTexImage3D:ce,texImage2D:Ue,texImage3D:tt,updateUBOMapping:Mt,uniformBlockBinding:ct,texStorage2D:vt,texStorage3D:me,texSubImage2D:se,texSubImage3D:ke,compressedTexSubImage2D:be,compressedTexSubImage3D:De,scissor:nt,viewport:Be,reset:Ot}}function LR(s,e){const t=s.image&&s.image.width?s.image.width/s.image.height:1;return t>e?(s.repeat.x=1,s.repeat.y=t/e,s.offset.x=0,s.offset.y=(1-s.repeat.y)/2):(s.repeat.x=e/t,s.repeat.y=1,s.offset.x=(1-s.repeat.x)/2,s.offset.y=0),s}function DR(s,e){const t=s.image&&s.image.width?s.image.width/s.image.height:1;return t>e?(s.repeat.x=e/t,s.repeat.y=1,s.offset.x=(1-s.repeat.x)/2,s.offset.y=0):(s.repeat.x=1,s.repeat.y=t/e,s.offset.x=0,s.offset.y=(1-s.repeat.y)/2),s}function UR(s){return s.repeat.x=1,s.repeat.y=1,s.offset.x=0,s.offset.y=0,s}function lf(s,e,t,n){const i=FR(n);switch(t){case Gf:return s*e;case Hf:return s*e;case Wf:return s*e*2;case Hc:return s*e/i.components*i.byteLength;case Wc:return s*e/i.components*i.byteLength;case na:return s*e*2/i.components*i.byteLength;case Vh:return s*e*2/i.components*i.byteLength;case Oh:return s*e*3/i.components*i.byteLength;case Rn:return s*e*4/i.components*i.byteLength;case Bh:return s*e*4/i.components*i.byteLength;case $o:case Yo:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case Zo:case Jo:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Bu:case zu:return Math.max(s,16)*Math.max(e,8)/4;case gc:case xc:return Math.max(s,8)*Math.max(e,8)/2;case _c:case yc:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case vc:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Mc:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case ku:return Math.floor((s+4)/5)*Math.floor((e+3)/4)*16;case Gu:return Math.floor((s+4)/5)*Math.floor((e+4)/5)*16;case Hu:return Math.floor((s+5)/6)*Math.floor((e+4)/5)*16;case Sc:return Math.floor((s+5)/6)*Math.floor((e+5)/6)*16;case Wu:return Math.floor((s+7)/8)*Math.floor((e+4)/5)*16;case Xu:return Math.floor((s+7)/8)*Math.floor((e+5)/6)*16;case qu:return Math.floor((s+7)/8)*Math.floor((e+7)/8)*16;case $u:return Math.floor((s+9)/10)*Math.floor((e+4)/5)*16;case Yu:return Math.floor((s+9)/10)*Math.floor((e+5)/6)*16;case Zu:return Math.floor((s+9)/10)*Math.floor((e+7)/8)*16;case Ju:return Math.floor((s+9)/10)*Math.floor((e+9)/10)*16;case Ku:return Math.floor((s+11)/12)*Math.floor((e+9)/10)*16;case ju:return Math.floor((s+11)/12)*Math.floor((e+11)/12)*16;case Ko:case Qu:case Tc:return Math.ceil(s/4)*Math.ceil(e/4)*16;case Xf:case eh:return Math.ceil(s/4)*Math.ceil(e/4)*8;case th:case nh:return Math.ceil(s/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function FR(s){switch(s){case es:case zf:return{byteLength:1,components:1};case ta:case kf:case Ln:return{byteLength:2,components:1};case Lh:case Dh:return{byteLength:2,components:4};case Bi:case ma:case Gn:return{byteLength:4,components:1};case Uh:case Fh:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${s}.`)}const OR={contain:LR,cover:DR,fill:UR,getByteLength:lf};function VR(s,e,t,n,i,r,o){const a=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new J,u=new WeakMap;let h;const d=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function f(R,S){return p?new OffscreenCanvas(R,S):Cc("canvas")}function x(R,S,X){let re=1;const ce=Ie(R);if((ce.width>X||ce.height>X)&&(re=X/Math.max(ce.width,ce.height)),re<1)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap||typeof VideoFrame<"u"&&R instanceof VideoFrame){const se=Math.floor(re*ce.width),ke=Math.floor(re*ce.height);h===void 0&&(h=f(se,ke));const be=S?f(se,ke):h;return be.width=se,be.height=ke,be.getContext("2d").drawImage(R,0,0,se,ke),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+ce.width+"x"+ce.height+") to ("+se+"x"+ke+")."),be}else return"data"in R&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+ce.width+"x"+ce.height+")."),R;return R}function m(R){return R.generateMipmaps&&R.minFilter!==Qt&&R.minFilter!==Ut}function g(R){s.generateMipmap(R)}function y(R,S,X,re,ce=!1){if(R!==null){if(s[R]!==void 0)return s[R];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let se=S;if(S===s.RED&&(X===s.FLOAT&&(se=s.R32F),X===s.HALF_FLOAT&&(se=s.R16F),X===s.UNSIGNED_BYTE&&(se=s.R8)),S===s.RED_INTEGER&&(X===s.UNSIGNED_BYTE&&(se=s.R8UI),X===s.UNSIGNED_SHORT&&(se=s.R16UI),X===s.UNSIGNED_INT&&(se=s.R32UI),X===s.BYTE&&(se=s.R8I),X===s.SHORT&&(se=s.R16I),X===s.INT&&(se=s.R32I)),S===s.RG&&(X===s.FLOAT&&(se=s.RG32F),X===s.HALF_FLOAT&&(se=s.RG16F),X===s.UNSIGNED_BYTE&&(se=s.RG8)),S===s.RG_INTEGER&&(X===s.UNSIGNED_BYTE&&(se=s.RG8UI),X===s.UNSIGNED_SHORT&&(se=s.RG16UI),X===s.UNSIGNED_INT&&(se=s.RG32UI),X===s.BYTE&&(se=s.RG8I),X===s.SHORT&&(se=s.RG16I),X===s.INT&&(se=s.RG32I)),S===s.RGB_INTEGER&&(X===s.UNSIGNED_BYTE&&(se=s.RGB8UI),X===s.UNSIGNED_SHORT&&(se=s.RGB16UI),X===s.UNSIGNED_INT&&(se=s.RGB32UI),X===s.BYTE&&(se=s.RGB8I),X===s.SHORT&&(se=s.RGB16I),X===s.INT&&(se=s.RGB32I)),S===s.RGBA_INTEGER&&(X===s.UNSIGNED_BYTE&&(se=s.RGBA8UI),X===s.UNSIGNED_SHORT&&(se=s.RGBA16UI),X===s.UNSIGNED_INT&&(se=s.RGBA32UI),X===s.BYTE&&(se=s.RGBA8I),X===s.SHORT&&(se=s.RGBA16I),X===s.INT&&(se=s.RGBA32I)),S===s.RGB&&(X===s.UNSIGNED_INT_5_9_9_9_REV&&(se=s.RGB9_E5),X===s.UNSIGNED_INT_10F_11F_11F_REV&&(se=s.R11F_G11F_B10F)),S===s.RGBA){const ke=ce?Ac:gt.getTransfer(re);X===s.FLOAT&&(se=s.RGBA32F),X===s.HALF_FLOAT&&(se=s.RGBA16F),X===s.UNSIGNED_BYTE&&(se=ke===Vt?s.SRGB8_ALPHA8:s.RGBA8),X===s.UNSIGNED_SHORT_4_4_4_4&&(se=s.RGBA4),X===s.UNSIGNED_SHORT_5_5_5_1&&(se=s.RGB5_A1)}return(se===s.R16F||se===s.R32F||se===s.RG16F||se===s.RG32F||se===s.RGBA16F||se===s.RGBA32F)&&e.get("EXT_color_buffer_float"),se}function _(R,S){let X;return R?S===null||S===Bi||S===or?X=s.DEPTH24_STENCIL8:S===Gn?X=s.DEPTH32F_STENCIL8:S===ta&&(X=s.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):S===null||S===Bi||S===or?X=s.DEPTH_COMPONENT24:S===Gn?X=s.DEPTH_COMPONENT32F:S===ta&&(X=s.DEPTH_COMPONENT16),X}function v(R,S){return m(R)===!0||R.isFramebufferTexture&&R.minFilter!==Qt&&R.minFilter!==Ut?Math.log2(Math.max(S.width,S.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?S.mipmaps.length:1}function I(R){const S=R.target;S.removeEventListener("dispose",I),w(S),S.isVideoTexture&&u.delete(S)}function T(R){const S=R.target;S.removeEventListener("dispose",T),F(S)}function w(R){const S=n.get(R);if(S.__webglInit===void 0)return;const X=R.source,re=d.get(X);if(re){const ce=re[S.__cacheKey];ce.usedTimes--,ce.usedTimes===0&&C(R),Object.keys(re).length===0&&d.delete(X)}n.remove(R)}function C(R){const S=n.get(R);s.deleteTexture(S.__webglTexture);const X=R.source,re=d.get(X);delete re[S.__cacheKey],o.memory.textures--}function F(R){const S=n.get(R);if(R.depthTexture&&R.depthTexture.dispose(),R.isWebGLCubeRenderTarget)for(let re=0;re<6;re++){if(Array.isArray(S.__webglFramebuffer[re]))for(let ce=0;ce<S.__webglFramebuffer[re].length;ce++)s.deleteFramebuffer(S.__webglFramebuffer[re][ce]);else s.deleteFramebuffer(S.__webglFramebuffer[re]);S.__webglDepthbuffer&&s.deleteRenderbuffer(S.__webglDepthbuffer[re])}else{if(Array.isArray(S.__webglFramebuffer))for(let re=0;re<S.__webglFramebuffer.length;re++)s.deleteFramebuffer(S.__webglFramebuffer[re]);else s.deleteFramebuffer(S.__webglFramebuffer);if(S.__webglDepthbuffer&&s.deleteRenderbuffer(S.__webglDepthbuffer),S.__webglMultisampledFramebuffer&&s.deleteFramebuffer(S.__webglMultisampledFramebuffer),S.__webglColorRenderbuffer)for(let re=0;re<S.__webglColorRenderbuffer.length;re++)S.__webglColorRenderbuffer[re]&&s.deleteRenderbuffer(S.__webglColorRenderbuffer[re]);S.__webglDepthRenderbuffer&&s.deleteRenderbuffer(S.__webglDepthRenderbuffer)}const X=R.textures;for(let re=0,ce=X.length;re<ce;re++){const se=n.get(X[re]);se.__webglTexture&&(s.deleteTexture(se.__webglTexture),o.memory.textures--),n.remove(X[re])}n.remove(R)}let M=0;function b(){M=0}function G(){const R=M;return R>=i.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+i.maxTextures),M+=1,R}function W(R){const S=[];return S.push(R.wrapS),S.push(R.wrapT),S.push(R.wrapR||0),S.push(R.magFilter),S.push(R.minFilter),S.push(R.anisotropy),S.push(R.internalFormat),S.push(R.format),S.push(R.type),S.push(R.generateMipmaps),S.push(R.premultiplyAlpha),S.push(R.flipY),S.push(R.unpackAlignment),S.push(R.colorSpace),S.join()}function $(R,S){const X=n.get(R);if(R.isVideoTexture&&Te(R),R.isRenderTargetTexture===!1&&R.version>0&&X.__version!==R.version){const re=R.image;if(re===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(re.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ht(X,R,S);return}}t.bindTexture(s.TEXTURE_2D,X.__webglTexture,s.TEXTURE0+S)}function ie(R,S){const X=n.get(R);if(R.version>0&&X.__version!==R.version){ht(X,R,S);return}t.bindTexture(s.TEXTURE_2D_ARRAY,X.__webglTexture,s.TEXTURE0+S)}function q(R,S){const X=n.get(R);if(R.version>0&&X.__version!==R.version){ht(X,R,S);return}t.bindTexture(s.TEXTURE_3D,X.__webglTexture,s.TEXTURE0+S)}function he(R,S){const X=n.get(R);if(R.version>0&&X.__version!==R.version){ne(X,R,S);return}t.bindTexture(s.TEXTURE_CUBE_MAP,X.__webglTexture,s.TEXTURE0+S)}const Q={[rr]:s.REPEAT,[Si]:s.CLAMP_TO_EDGE,[ea]:s.MIRRORED_REPEAT},we={[Qt]:s.NEAREST,[Ph]:s.NEAREST_MIPMAP_NEAREST,[Cs]:s.NEAREST_MIPMAP_LINEAR,[Ut]:s.LINEAR,[js]:s.LINEAR_MIPMAP_NEAREST,[Jn]:s.LINEAR_MIPMAP_LINEAR},Ne={[Cy]:s.NEVER,[Dy]:s.ALWAYS,[jf]:s.LESS,[Qf]:s.LEQUAL,[Ry]:s.EQUAL,[Ly]:s.GEQUAL,[Iy]:s.GREATER,[Py]:s.NOTEQUAL};function Ee(R,S){if(S.type===Gn&&e.has("OES_texture_float_linear")===!1&&(S.magFilter===Ut||S.magFilter===js||S.magFilter===Cs||S.magFilter===Jn||S.minFilter===Ut||S.minFilter===js||S.minFilter===Cs||S.minFilter===Jn)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),s.texParameteri(R,s.TEXTURE_WRAP_S,Q[S.wrapS]),s.texParameteri(R,s.TEXTURE_WRAP_T,Q[S.wrapT]),(R===s.TEXTURE_3D||R===s.TEXTURE_2D_ARRAY)&&s.texParameteri(R,s.TEXTURE_WRAP_R,Q[S.wrapR]),s.texParameteri(R,s.TEXTURE_MAG_FILTER,we[S.magFilter]),s.texParameteri(R,s.TEXTURE_MIN_FILTER,we[S.minFilter]),S.compareFunction&&(s.texParameteri(R,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(R,s.TEXTURE_COMPARE_FUNC,Ne[S.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(S.magFilter===Qt||S.minFilter!==Cs&&S.minFilter!==Jn||S.type===Gn&&e.has("OES_texture_float_linear")===!1)return;if(S.anisotropy>1||n.get(S).__currentAnisotropy){const X=e.get("EXT_texture_filter_anisotropic");s.texParameterf(R,X.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(S.anisotropy,i.getMaxAnisotropy())),n.get(S).__currentAnisotropy=S.anisotropy}}}function Qe(R,S){let X=!1;R.__webglInit===void 0&&(R.__webglInit=!0,S.addEventListener("dispose",I));const re=S.source;let ce=d.get(re);ce===void 0&&(ce={},d.set(re,ce));const se=W(S);if(se!==R.__cacheKey){ce[se]===void 0&&(ce[se]={texture:s.createTexture(),usedTimes:0},o.memory.textures++,X=!0),ce[se].usedTimes++;const ke=ce[R.__cacheKey];ke!==void 0&&(ce[R.__cacheKey].usedTimes--,ke.usedTimes===0&&C(S)),R.__cacheKey=se,R.__webglTexture=ce[se].texture}return X}function ht(R,S,X){let re=s.TEXTURE_2D;(S.isDataArrayTexture||S.isCompressedArrayTexture)&&(re=s.TEXTURE_2D_ARRAY),S.isData3DTexture&&(re=s.TEXTURE_3D);const ce=Qe(R,S),se=S.source;t.bindTexture(re,R.__webglTexture,s.TEXTURE0+X);const ke=n.get(se);if(se.version!==ke.__version||ce===!0){t.activeTexture(s.TEXTURE0+X);const be=gt.getPrimaries(gt.workingColorSpace),De=S.colorSpace===Li?null:gt.getPrimaries(S.colorSpace),vt=S.colorSpace===Li||be===De?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,S.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,S.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,vt);let me=x(S.image,!1,i.maxTextureSize);me=qe(S,me);const Ue=r.convert(S.format,S.colorSpace),tt=r.convert(S.type);let nt=y(S.internalFormat,Ue,tt,S.colorSpace,S.isVideoTexture);Ee(re,S);let Be;const Mt=S.mipmaps,ct=S.isVideoTexture!==!0,Ot=ke.__version===void 0||ce===!0,O=se.dataReady,Pe=v(S,me);if(S.isDepthTexture)nt=_(S.format===ar,S.type),Ot&&(ct?t.texStorage2D(s.TEXTURE_2D,1,nt,me.width,me.height):t.texImage2D(s.TEXTURE_2D,0,nt,me.width,me.height,0,Ue,tt,null));else if(S.isDataTexture)if(Mt.length>0){ct&&Ot&&t.texStorage2D(s.TEXTURE_2D,Pe,nt,Mt[0].width,Mt[0].height);for(let ee=0,le=Mt.length;ee<le;ee++)Be=Mt[ee],ct?O&&t.texSubImage2D(s.TEXTURE_2D,ee,0,0,Be.width,Be.height,Ue,tt,Be.data):t.texImage2D(s.TEXTURE_2D,ee,nt,Be.width,Be.height,0,Ue,tt,Be.data);S.generateMipmaps=!1}else ct?(Ot&&t.texStorage2D(s.TEXTURE_2D,Pe,nt,me.width,me.height),O&&t.texSubImage2D(s.TEXTURE_2D,0,0,0,me.width,me.height,Ue,tt,me.data)):t.texImage2D(s.TEXTURE_2D,0,nt,me.width,me.height,0,Ue,tt,me.data);else if(S.isCompressedTexture)if(S.isCompressedArrayTexture){ct&&Ot&&t.texStorage3D(s.TEXTURE_2D_ARRAY,Pe,nt,Mt[0].width,Mt[0].height,me.depth);for(let ee=0,le=Mt.length;ee<le;ee++)if(Be=Mt[ee],S.format!==Rn)if(Ue!==null)if(ct){if(O)if(S.layerUpdates.size>0){const Ce=lf(Be.width,Be.height,S.format,S.type);for(const Le of S.layerUpdates){const bt=Be.data.subarray(Le*Ce/Be.data.BYTES_PER_ELEMENT,(Le+1)*Ce/Be.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,ee,0,0,Le,Be.width,Be.height,1,Ue,bt,0,0)}S.clearLayerUpdates()}else t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,ee,0,0,0,Be.width,Be.height,me.depth,Ue,Be.data,0,0)}else t.compressedTexImage3D(s.TEXTURE_2D_ARRAY,ee,nt,Be.width,Be.height,me.depth,0,Be.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else ct?O&&t.texSubImage3D(s.TEXTURE_2D_ARRAY,ee,0,0,0,Be.width,Be.height,me.depth,Ue,tt,Be.data):t.texImage3D(s.TEXTURE_2D_ARRAY,ee,nt,Be.width,Be.height,me.depth,0,Ue,tt,Be.data)}else{ct&&Ot&&t.texStorage2D(s.TEXTURE_2D,Pe,nt,Mt[0].width,Mt[0].height);for(let ee=0,le=Mt.length;ee<le;ee++)Be=Mt[ee],S.format!==Rn?Ue!==null?ct?O&&t.compressedTexSubImage2D(s.TEXTURE_2D,ee,0,0,Be.width,Be.height,Ue,Be.data):t.compressedTexImage2D(s.TEXTURE_2D,ee,nt,Be.width,Be.height,0,Be.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ct?O&&t.texSubImage2D(s.TEXTURE_2D,ee,0,0,Be.width,Be.height,Ue,tt,Be.data):t.texImage2D(s.TEXTURE_2D,ee,nt,Be.width,Be.height,0,Ue,tt,Be.data)}else if(S.isDataArrayTexture)if(ct){if(Ot&&t.texStorage3D(s.TEXTURE_2D_ARRAY,Pe,nt,me.width,me.height,me.depth),O)if(S.layerUpdates.size>0){const ee=lf(me.width,me.height,S.format,S.type);for(const le of S.layerUpdates){const Ce=me.data.subarray(le*ee/me.data.BYTES_PER_ELEMENT,(le+1)*ee/me.data.BYTES_PER_ELEMENT);t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,le,me.width,me.height,1,Ue,tt,Ce)}S.clearLayerUpdates()}else t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,me.width,me.height,me.depth,Ue,tt,me.data)}else t.texImage3D(s.TEXTURE_2D_ARRAY,0,nt,me.width,me.height,me.depth,0,Ue,tt,me.data);else if(S.isData3DTexture)ct?(Ot&&t.texStorage3D(s.TEXTURE_3D,Pe,nt,me.width,me.height,me.depth),O&&t.texSubImage3D(s.TEXTURE_3D,0,0,0,0,me.width,me.height,me.depth,Ue,tt,me.data)):t.texImage3D(s.TEXTURE_3D,0,nt,me.width,me.height,me.depth,0,Ue,tt,me.data);else if(S.isFramebufferTexture){if(Ot)if(ct)t.texStorage2D(s.TEXTURE_2D,Pe,nt,me.width,me.height);else{let ee=me.width,le=me.height;for(let Ce=0;Ce<Pe;Ce++)t.texImage2D(s.TEXTURE_2D,Ce,nt,ee,le,0,Ue,tt,null),ee>>=1,le>>=1}}else if(Mt.length>0){if(ct&&Ot){const ee=Ie(Mt[0]);t.texStorage2D(s.TEXTURE_2D,Pe,nt,ee.width,ee.height)}for(let ee=0,le=Mt.length;ee<le;ee++)Be=Mt[ee],ct?O&&t.texSubImage2D(s.TEXTURE_2D,ee,0,0,Ue,tt,Be):t.texImage2D(s.TEXTURE_2D,ee,nt,Ue,tt,Be);S.generateMipmaps=!1}else if(ct){if(Ot){const ee=Ie(me);t.texStorage2D(s.TEXTURE_2D,Pe,nt,ee.width,ee.height)}O&&t.texSubImage2D(s.TEXTURE_2D,0,0,0,Ue,tt,me)}else t.texImage2D(s.TEXTURE_2D,0,nt,Ue,tt,me);m(S)&&g(re),ke.__version=se.version,S.onUpdate&&S.onUpdate(S)}R.__version=S.version}function ne(R,S,X){if(S.image.length!==6)return;const re=Qe(R,S),ce=S.source;t.bindTexture(s.TEXTURE_CUBE_MAP,R.__webglTexture,s.TEXTURE0+X);const se=n.get(ce);if(ce.version!==se.__version||re===!0){t.activeTexture(s.TEXTURE0+X);const ke=gt.getPrimaries(gt.workingColorSpace),be=S.colorSpace===Li?null:gt.getPrimaries(S.colorSpace),De=S.colorSpace===Li||ke===be?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,S.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,S.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,De);const vt=S.isCompressedTexture||S.image[0].isCompressedTexture,me=S.image[0]&&S.image[0].isDataTexture,Ue=[];for(let le=0;le<6;le++)!vt&&!me?Ue[le]=x(S.image[le],!0,i.maxCubemapSize):Ue[le]=me?S.image[le].image:S.image[le],Ue[le]=qe(S,Ue[le]);const tt=Ue[0],nt=r.convert(S.format,S.colorSpace),Be=r.convert(S.type),Mt=y(S.internalFormat,nt,Be,S.colorSpace),ct=S.isVideoTexture!==!0,Ot=se.__version===void 0||re===!0,O=ce.dataReady;let Pe=v(S,tt);Ee(s.TEXTURE_CUBE_MAP,S);let ee;if(vt){ct&&Ot&&t.texStorage2D(s.TEXTURE_CUBE_MAP,Pe,Mt,tt.width,tt.height);for(let le=0;le<6;le++){ee=Ue[le].mipmaps;for(let Ce=0;Ce<ee.length;Ce++){const Le=ee[Ce];S.format!==Rn?nt!==null?ct?O&&t.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+le,Ce,0,0,Le.width,Le.height,nt,Le.data):t.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+le,Ce,Mt,Le.width,Le.height,0,Le.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ct?O&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+le,Ce,0,0,Le.width,Le.height,nt,Be,Le.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+le,Ce,Mt,Le.width,Le.height,0,nt,Be,Le.data)}}}else{if(ee=S.mipmaps,ct&&Ot){ee.length>0&&Pe++;const le=Ie(Ue[0]);t.texStorage2D(s.TEXTURE_CUBE_MAP,Pe,Mt,le.width,le.height)}for(let le=0;le<6;le++)if(me){ct?O&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+le,0,0,0,Ue[le].width,Ue[le].height,nt,Be,Ue[le].data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+le,0,Mt,Ue[le].width,Ue[le].height,0,nt,Be,Ue[le].data);for(let Ce=0;Ce<ee.length;Ce++){const bt=ee[Ce].image[le].image;ct?O&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+le,Ce+1,0,0,bt.width,bt.height,nt,Be,bt.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+le,Ce+1,Mt,bt.width,bt.height,0,nt,Be,bt.data)}}else{ct?O&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+le,0,0,0,nt,Be,Ue[le]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+le,0,Mt,nt,Be,Ue[le]);for(let Ce=0;Ce<ee.length;Ce++){const Le=ee[Ce];ct?O&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+le,Ce+1,0,0,nt,Be,Le.image[le]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+le,Ce+1,Mt,nt,Be,Le.image[le])}}}m(S)&&g(s.TEXTURE_CUBE_MAP),se.__version=ce.version,S.onUpdate&&S.onUpdate(S)}R.__version=S.version}function ue(R,S,X,re,ce,se){const ke=r.convert(X.format,X.colorSpace),be=r.convert(X.type),De=y(X.internalFormat,ke,be,X.colorSpace);if(!n.get(S).__hasExternalTextures){const me=Math.max(1,S.width>>se),Ue=Math.max(1,S.height>>se);ce===s.TEXTURE_3D||ce===s.TEXTURE_2D_ARRAY?t.texImage3D(ce,se,De,me,Ue,S.depth,0,ke,be,null):t.texImage2D(ce,se,De,me,Ue,0,ke,be,null)}t.bindFramebuffer(s.FRAMEBUFFER,R),de(S)?a.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,re,ce,n.get(X).__webglTexture,0,ye(S)):(ce===s.TEXTURE_2D||ce>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&ce<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,re,ce,n.get(X).__webglTexture,se),t.bindFramebuffer(s.FRAMEBUFFER,null)}function Ae(R,S,X){if(s.bindRenderbuffer(s.RENDERBUFFER,R),S.depthBuffer){const re=S.depthTexture,ce=re&&re.isDepthTexture?re.type:null,se=_(S.stencilBuffer,ce),ke=S.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,be=ye(S);de(S)?a.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,be,se,S.width,S.height):X?s.renderbufferStorageMultisample(s.RENDERBUFFER,be,se,S.width,S.height):s.renderbufferStorage(s.RENDERBUFFER,se,S.width,S.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,ke,s.RENDERBUFFER,R)}else{const re=S.textures;for(let ce=0;ce<re.length;ce++){const se=re[ce],ke=r.convert(se.format,se.colorSpace),be=r.convert(se.type),De=y(se.internalFormat,ke,be,se.colorSpace),vt=ye(S);X&&de(S)===!1?s.renderbufferStorageMultisample(s.RENDERBUFFER,vt,De,S.width,S.height):de(S)?a.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,vt,De,S.width,S.height):s.renderbufferStorage(s.RENDERBUFFER,De,S.width,S.height)}}s.bindRenderbuffer(s.RENDERBUFFER,null)}function ge(R,S){if(S&&S.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(s.FRAMEBUFFER,R),!(S.depthTexture&&S.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(S.depthTexture).__webglTexture||S.depthTexture.image.width!==S.width||S.depthTexture.image.height!==S.height)&&(S.depthTexture.image.width=S.width,S.depthTexture.image.height=S.height,S.depthTexture.needsUpdate=!0),$(S.depthTexture,0);const re=n.get(S.depthTexture).__webglTexture,ce=ye(S);if(S.depthTexture.format===Qs)de(S)?a.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,re,0,ce):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,re,0);else if(S.depthTexture.format===ar)de(S)?a.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,re,0,ce):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,re,0);else throw new Error("Unknown depthTexture format")}function Ze(R){const S=n.get(R),X=R.isWebGLCubeRenderTarget===!0;if(S.__boundDepthTexture!==R.depthTexture){const re=R.depthTexture;if(S.__depthDisposeCallback&&S.__depthDisposeCallback(),re){const ce=()=>{delete S.__boundDepthTexture,delete S.__depthDisposeCallback,re.removeEventListener("dispose",ce)};re.addEventListener("dispose",ce),S.__depthDisposeCallback=ce}S.__boundDepthTexture=re}if(R.depthTexture&&!S.__autoAllocateDepthBuffer){if(X)throw new Error("target.depthTexture not supported in Cube render targets");ge(S.__webglFramebuffer,R)}else if(X){S.__webglDepthbuffer=[];for(let re=0;re<6;re++)if(t.bindFramebuffer(s.FRAMEBUFFER,S.__webglFramebuffer[re]),S.__webglDepthbuffer[re]===void 0)S.__webglDepthbuffer[re]=s.createRenderbuffer(),Ae(S.__webglDepthbuffer[re],R,!1);else{const ce=R.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,se=S.__webglDepthbuffer[re];s.bindRenderbuffer(s.RENDERBUFFER,se),s.framebufferRenderbuffer(s.FRAMEBUFFER,ce,s.RENDERBUFFER,se)}}else if(t.bindFramebuffer(s.FRAMEBUFFER,S.__webglFramebuffer),S.__webglDepthbuffer===void 0)S.__webglDepthbuffer=s.createRenderbuffer(),Ae(S.__webglDepthbuffer,R,!1);else{const re=R.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,ce=S.__webglDepthbuffer;s.bindRenderbuffer(s.RENDERBUFFER,ce),s.framebufferRenderbuffer(s.FRAMEBUFFER,re,s.RENDERBUFFER,ce)}t.bindFramebuffer(s.FRAMEBUFFER,null)}function Xe(R,S,X){const re=n.get(R);S!==void 0&&ue(re.__webglFramebuffer,R,R.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),X!==void 0&&Ze(R)}function Je(R){const S=R.texture,X=n.get(R),re=n.get(S);R.addEventListener("dispose",T);const ce=R.textures,se=R.isWebGLCubeRenderTarget===!0,ke=ce.length>1;if(ke||(re.__webglTexture===void 0&&(re.__webglTexture=s.createTexture()),re.__version=S.version,o.memory.textures++),se){X.__webglFramebuffer=[];for(let be=0;be<6;be++)if(S.mipmaps&&S.mipmaps.length>0){X.__webglFramebuffer[be]=[];for(let De=0;De<S.mipmaps.length;De++)X.__webglFramebuffer[be][De]=s.createFramebuffer()}else X.__webglFramebuffer[be]=s.createFramebuffer()}else{if(S.mipmaps&&S.mipmaps.length>0){X.__webglFramebuffer=[];for(let be=0;be<S.mipmaps.length;be++)X.__webglFramebuffer[be]=s.createFramebuffer()}else X.__webglFramebuffer=s.createFramebuffer();if(ke)for(let be=0,De=ce.length;be<De;be++){const vt=n.get(ce[be]);vt.__webglTexture===void 0&&(vt.__webglTexture=s.createTexture(),o.memory.textures++)}if(R.samples>0&&de(R)===!1){X.__webglMultisampledFramebuffer=s.createFramebuffer(),X.__webglColorRenderbuffer=[],t.bindFramebuffer(s.FRAMEBUFFER,X.__webglMultisampledFramebuffer);for(let be=0;be<ce.length;be++){const De=ce[be];X.__webglColorRenderbuffer[be]=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,X.__webglColorRenderbuffer[be]);const vt=r.convert(De.format,De.colorSpace),me=r.convert(De.type),Ue=y(De.internalFormat,vt,me,De.colorSpace,R.isXRRenderTarget===!0),tt=ye(R);s.renderbufferStorageMultisample(s.RENDERBUFFER,tt,Ue,R.width,R.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+be,s.RENDERBUFFER,X.__webglColorRenderbuffer[be])}s.bindRenderbuffer(s.RENDERBUFFER,null),R.depthBuffer&&(X.__webglDepthRenderbuffer=s.createRenderbuffer(),Ae(X.__webglDepthRenderbuffer,R,!0)),t.bindFramebuffer(s.FRAMEBUFFER,null)}}if(se){t.bindTexture(s.TEXTURE_CUBE_MAP,re.__webglTexture),Ee(s.TEXTURE_CUBE_MAP,S);for(let be=0;be<6;be++)if(S.mipmaps&&S.mipmaps.length>0)for(let De=0;De<S.mipmaps.length;De++)ue(X.__webglFramebuffer[be][De],R,S,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+be,De);else ue(X.__webglFramebuffer[be],R,S,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+be,0);m(S)&&g(s.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(ke){for(let be=0,De=ce.length;be<De;be++){const vt=ce[be],me=n.get(vt);t.bindTexture(s.TEXTURE_2D,me.__webglTexture),Ee(s.TEXTURE_2D,vt),ue(X.__webglFramebuffer,R,vt,s.COLOR_ATTACHMENT0+be,s.TEXTURE_2D,0),m(vt)&&g(s.TEXTURE_2D)}t.unbindTexture()}else{let be=s.TEXTURE_2D;if((R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(be=R.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture(be,re.__webglTexture),Ee(be,S),S.mipmaps&&S.mipmaps.length>0)for(let De=0;De<S.mipmaps.length;De++)ue(X.__webglFramebuffer[De],R,S,s.COLOR_ATTACHMENT0,be,De);else ue(X.__webglFramebuffer,R,S,s.COLOR_ATTACHMENT0,be,0);m(S)&&g(be),t.unbindTexture()}R.depthBuffer&&Ze(R)}function dt(R){const S=R.textures;for(let X=0,re=S.length;X<re;X++){const ce=S[X];if(m(ce)){const se=R.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:s.TEXTURE_2D,ke=n.get(ce).__webglTexture;t.bindTexture(se,ke),g(se),t.unbindTexture()}}}const ae=[],P=[];function Me(R){if(R.samples>0){if(de(R)===!1){const S=R.textures,X=R.width,re=R.height;let ce=s.COLOR_BUFFER_BIT;const se=R.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,ke=n.get(R),be=S.length>1;if(be)for(let De=0;De<S.length;De++)t.bindFramebuffer(s.FRAMEBUFFER,ke.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+De,s.RENDERBUFFER,null),t.bindFramebuffer(s.FRAMEBUFFER,ke.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+De,s.TEXTURE_2D,null,0);t.bindFramebuffer(s.READ_FRAMEBUFFER,ke.__webglMultisampledFramebuffer),t.bindFramebuffer(s.DRAW_FRAMEBUFFER,ke.__webglFramebuffer);for(let De=0;De<S.length;De++){if(R.resolveDepthBuffer&&(R.depthBuffer&&(ce|=s.DEPTH_BUFFER_BIT),R.stencilBuffer&&R.resolveStencilBuffer&&(ce|=s.STENCIL_BUFFER_BIT)),be){s.framebufferRenderbuffer(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,ke.__webglColorRenderbuffer[De]);const vt=n.get(S[De]).__webglTexture;s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,vt,0)}s.blitFramebuffer(0,0,X,re,0,0,X,re,ce,s.NEAREST),c===!0&&(ae.length=0,P.length=0,ae.push(s.COLOR_ATTACHMENT0+De),R.depthBuffer&&R.resolveDepthBuffer===!1&&(ae.push(se),P.push(se),s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,P)),s.invalidateFramebuffer(s.READ_FRAMEBUFFER,ae))}if(t.bindFramebuffer(s.READ_FRAMEBUFFER,null),t.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),be)for(let De=0;De<S.length;De++){t.bindFramebuffer(s.FRAMEBUFFER,ke.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+De,s.RENDERBUFFER,ke.__webglColorRenderbuffer[De]);const vt=n.get(S[De]).__webglTexture;t.bindFramebuffer(s.FRAMEBUFFER,ke.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+De,s.TEXTURE_2D,vt,0)}t.bindFramebuffer(s.DRAW_FRAMEBUFFER,ke.__webglMultisampledFramebuffer)}else if(R.depthBuffer&&R.resolveDepthBuffer===!1&&c){const S=R.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,[S])}}}function ye(R){return Math.min(i.maxSamples,R.samples)}function de(R){const S=n.get(R);return R.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&S.__useRenderToTexture!==!1}function Te(R){const S=o.render.frame;u.get(R)!==S&&(u.set(R,S),R.update())}function qe(R,S){const X=R.colorSpace,re=R.format,ce=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||X!==li&&X!==Li&&(gt.getTransfer(X)===Vt?(re!==Rn||ce!==es)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",X)),S}function Ie(R){return typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement?(l.width=R.naturalWidth||R.width,l.height=R.naturalHeight||R.height):typeof VideoFrame<"u"&&R instanceof VideoFrame?(l.width=R.displayWidth,l.height=R.displayHeight):(l.width=R.width,l.height=R.height),l}this.allocateTextureUnit=G,this.resetTextureUnits=b,this.setTexture2D=$,this.setTexture2DArray=ie,this.setTexture3D=q,this.setTextureCube=he,this.rebindTextures=Xe,this.setupRenderTarget=Je,this.updateRenderTargetMipmap=dt,this.updateMultisampleRenderTarget=Me,this.setupDepthRenderbuffer=Ze,this.setupFrameBufferTexture=ue,this.useMultisampledRTT=de}function $y(s,e){function t(n,i=Li){let r;const o=gt.getTransfer(i);if(n===es)return s.UNSIGNED_BYTE;if(n===Lh)return s.UNSIGNED_SHORT_4_4_4_4;if(n===Dh)return s.UNSIGNED_SHORT_5_5_5_1;if(n===Uh)return s.UNSIGNED_INT_5_9_9_9_REV;if(n===Fh)return s.UNSIGNED_INT_10F_11F_11F_REV;if(n===zf)return s.BYTE;if(n===kf)return s.SHORT;if(n===ta)return s.UNSIGNED_SHORT;if(n===ma)return s.INT;if(n===Bi)return s.UNSIGNED_INT;if(n===Gn)return s.FLOAT;if(n===Ln)return s.HALF_FLOAT;if(n===Gf)return s.ALPHA;if(n===Oh)return s.RGB;if(n===Rn)return s.RGBA;if(n===Hf)return s.LUMINANCE;if(n===Wf)return s.LUMINANCE_ALPHA;if(n===Qs)return s.DEPTH_COMPONENT;if(n===ar)return s.DEPTH_STENCIL;if(n===Hc)return s.RED;if(n===Wc)return s.RED_INTEGER;if(n===na)return s.RG;if(n===Vh)return s.RG_INTEGER;if(n===Bh)return s.RGBA_INTEGER;if(n===$o||n===Yo||n===Zo||n===Jo)if(o===Vt)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===$o)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Yo)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Zo)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Jo)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===$o)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Yo)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Zo)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Jo)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===gc||n===Bu||n===xc||n===zu)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===gc)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Bu)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===xc)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===zu)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===_c||n===yc||n===vc)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===_c||n===yc)return o===Vt?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===vc)return o===Vt?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===Mc||n===ku||n===Gu||n===Hu||n===Sc||n===Wu||n===Xu||n===qu||n===$u||n===Yu||n===Zu||n===Ju||n===Ku||n===ju)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Mc)return o===Vt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===ku)return o===Vt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Gu)return o===Vt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Hu)return o===Vt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Sc)return o===Vt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Wu)return o===Vt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Xu)return o===Vt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===qu)return o===Vt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===$u)return o===Vt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Yu)return o===Vt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Zu)return o===Vt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Ju)return o===Vt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Ku)return o===Vt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===ju)return o===Vt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Ko||n===Qu||n===Tc)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===Ko)return o===Vt?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Qu)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Tc)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Xf||n===eh||n===th||n===nh)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===Ko)return r.COMPRESSED_RED_RGTC1_EXT;if(n===eh)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===th)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===nh)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===or?s.UNSIGNED_INT_24_8:s[n]!==void 0?s[n]:null}return{convert:t}}class rm extends hn{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Gr extends yt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const BR={type:"move"};class yp{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Gr,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 Gr,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new E,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new E),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Gr,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new E,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new E),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 n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let i=null,r=null,o=null;const a=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){o=!0;for(const x of e.hand.values()){const m=t.getJointPose(x,n),g=this._getHandJoint(l,x);m!==null&&(g.matrix.fromArray(m.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.matrixWorldNeedsUpdate=!0,g.jointRadius=m.radius),g.visible=m!==null}const u=l.joints["index-finger-tip"],h=l.joints["thumb-tip"],d=u.position.distanceTo(h.position),p=.02,f=.005;l.inputState.pinching&&d>p+f?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&d<=p-f&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1));a!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null&&(i=r),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(BR)))}return a!==null&&(a.visible=i!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Gr;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const zR=`
3823
+ }`;function RR(s,e,t){let n=new ga;const i=new J,r=new J,o=new st,a=new Yh({depthPacking:Jf}),c=new sm,l={},u=t.maxTextureSize,h={[fs]:ln,[ln]:fs,[Ji]:Ji},d=new ki({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new J},radius:{value:4}},vertexShader:ER,fragmentShader:CR}),p=d.clone();p.defines.HORIZONTAL_PASS=1;const f=new at;f.setAttribute("position",new At(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const x=new kt(f,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Lf;let g=this.type;this.render=function(T,w,C){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||T.length===0)return;const F=s.getRenderTarget(),M=s.getActiveCubeFace(),b=s.getActiveMipmapLevel(),G=s.state;G.setBlending(Fi),G.buffers.color.setClear(1,1,1,1),G.buffers.depth.setTest(!0),G.setScissorTest(!1);const W=g!==oi&&this.type===oi,$=g===oi&&this.type!==oi;for(let ie=0,q=T.length;ie<q;ie++){const he=T[ie],Q=he.shadow;if(Q===void 0){console.warn("THREE.WebGLShadowMap:",he,"has no shadow.");continue}if(Q.autoUpdate===!1&&Q.needsUpdate===!1)continue;i.copy(Q.mapSize);const we=Q.getFrameExtents();if(i.multiply(we),r.copy(Q.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(r.x=Math.floor(u/we.x),i.x=r.x*we.x,Q.mapSize.x=r.x),i.y>u&&(r.y=Math.floor(u/we.y),i.y=r.y*we.y,Q.mapSize.y=r.y)),Q.map===null||W===!0||$===!0){const Ee=this.type!==oi?{minFilter:Qt,magFilter:Qt}:{};Q.map!==null&&Q.map.dispose(),Q.map=new zi(i.x,i.y,Ee),Q.map.texture.name=he.name+".shadowMap",Q.camera.updateProjectionMatrix()}s.setRenderTarget(Q.map),s.clear();const Ne=Q.getViewportCount();for(let Ee=0;Ee<Ne;Ee++){const Qe=Q.getViewport(Ee);o.set(r.x*Qe.x,r.y*Qe.y,r.x*Qe.z,r.y*Qe.w),G.viewport(o),Q.updateMatrices(he,Ee),n=Q.getFrustum(),v(w,C,Q.camera,he,this.type)}Q.isPointLightShadow!==!0&&this.type===oi&&y(Q,C),Q.needsUpdate=!1}g=this.type,m.needsUpdate=!1,s.setRenderTarget(F,M,b)};function y(T,w){const C=e.update(x);d.defines.VSM_SAMPLES!==T.blurSamples&&(d.defines.VSM_SAMPLES=T.blurSamples,p.defines.VSM_SAMPLES=T.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),T.mapPass===null&&(T.mapPass=new zi(i.x,i.y)),d.uniforms.shadow_pass.value=T.map.texture,d.uniforms.resolution.value=T.mapSize,d.uniforms.radius.value=T.radius,s.setRenderTarget(T.mapPass),s.clear(),s.renderBufferDirect(w,null,C,d,x,null),p.uniforms.shadow_pass.value=T.mapPass.texture,p.uniforms.resolution.value=T.mapSize,p.uniforms.radius.value=T.radius,s.setRenderTarget(T.map),s.clear(),s.renderBufferDirect(w,null,C,p,x,null)}function _(T,w,C,F){let M=null;const b=C.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(b!==void 0)M=b;else if(M=C.isPointLight===!0?c:a,s.localClippingEnabled&&w.clipShadows===!0&&Array.isArray(w.clippingPlanes)&&w.clippingPlanes.length!==0||w.displacementMap&&w.displacementScale!==0||w.alphaMap&&w.alphaTest>0||w.map&&w.alphaTest>0){const G=M.uuid,W=w.uuid;let $=l[G];$===void 0&&($={},l[G]=$);let ie=$[W];ie===void 0&&(ie=M.clone(),$[W]=ie,w.addEventListener("dispose",I)),M=ie}if(M.visible=w.visible,M.wireframe=w.wireframe,F===oi?M.side=w.shadowSide!==null?w.shadowSide:w.side:M.side=w.shadowSide!==null?w.shadowSide:h[w.side],M.alphaMap=w.alphaMap,M.alphaTest=w.alphaTest,M.map=w.map,M.clipShadows=w.clipShadows,M.clippingPlanes=w.clippingPlanes,M.clipIntersection=w.clipIntersection,M.displacementMap=w.displacementMap,M.displacementScale=w.displacementScale,M.displacementBias=w.displacementBias,M.wireframeLinewidth=w.wireframeLinewidth,M.linewidth=w.linewidth,C.isPointLight===!0&&M.isMeshDistanceMaterial===!0){const G=s.properties.get(M);G.light=C}return M}function v(T,w,C,F,M){if(T.visible===!1)return;if(T.layers.test(w.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&M===oi)&&(!T.frustumCulled||n.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(C.matrixWorldInverse,T.matrixWorld);const W=e.update(T),$=T.material;if(Array.isArray($)){const ie=W.groups;for(let q=0,he=ie.length;q<he;q++){const Q=ie[q],we=$[Q.materialIndex];if(we&&we.visible){const Ne=_(T,we,F,M);T.onBeforeShadow(s,T,w,C,W,Ne,Q),s.renderBufferDirect(C,null,W,Ne,T,Q),T.onAfterShadow(s,T,w,C,W,Ne,Q)}}}else if($.visible){const ie=_(T,$,F,M);T.onBeforeShadow(s,T,w,C,W,ie,null),s.renderBufferDirect(C,null,W,ie,T,null),T.onAfterShadow(s,T,w,C,W,ie,null)}}const G=T.children;for(let W=0,$=G.length;W<$;W++)v(G[W],w,C,F,M)}function I(T){T.target.removeEventListener("dispose",I);for(const C in l){const F=l[C],M=T.target.uuid;M in F&&(F[M].dispose(),delete F[M])}}}const IR={[lc]:uc,[hc]:fc,[dc]:mc,[nr]:pc,[uc]:lc,[fc]:hc,[mc]:dc,[pc]:nr};function PR(s){function e(){let O=!1;const Pe=new st;let ee=null;const le=new st(0,0,0,0);return{setMask:function(Ce){ee!==Ce&&!O&&(s.colorMask(Ce,Ce,Ce,Ce),ee=Ce)},setLocked:function(Ce){O=Ce},setClear:function(Ce,Le,bt,on,ni){ni===!0&&(Ce*=on,Le*=on,bt*=on),Pe.set(Ce,Le,bt,on),le.equals(Pe)===!1&&(s.clearColor(Ce,Le,bt,on),le.copy(Pe))},reset:function(){O=!1,ee=null,le.set(-1,0,0,0)}}}function t(){let O=!1,Pe=!1,ee=null,le=null,Ce=null;return{setReversed:function(Le){Pe=Le},setTest:function(Le){Le?Ae(s.DEPTH_TEST):ge(s.DEPTH_TEST)},setMask:function(Le){ee!==Le&&!O&&(s.depthMask(Le),ee=Le)},setFunc:function(Le){if(Pe&&(Le=IR[Le]),le!==Le){switch(Le){case lc:s.depthFunc(s.NEVER);break;case uc:s.depthFunc(s.ALWAYS);break;case hc:s.depthFunc(s.LESS);break;case nr:s.depthFunc(s.LEQUAL);break;case dc:s.depthFunc(s.EQUAL);break;case pc:s.depthFunc(s.GEQUAL);break;case fc:s.depthFunc(s.GREATER);break;case mc:s.depthFunc(s.NOTEQUAL);break;default:s.depthFunc(s.LEQUAL)}le=Le}},setLocked:function(Le){O=Le},setClear:function(Le){Ce!==Le&&(s.clearDepth(Le),Ce=Le)},reset:function(){O=!1,ee=null,le=null,Ce=null}}}function n(){let O=!1,Pe=null,ee=null,le=null,Ce=null,Le=null,bt=null,on=null,ni=null;return{setTest:function(Et){O||(Et?Ae(s.STENCIL_TEST):ge(s.STENCIL_TEST))},setMask:function(Et){Pe!==Et&&!O&&(s.stencilMask(Et),Pe=Et)},setFunc:function(Et,ii,vs){(ee!==Et||le!==ii||Ce!==vs)&&(s.stencilFunc(Et,ii,vs),ee=Et,le=ii,Ce=vs)},setOp:function(Et,ii,vs){(Le!==Et||bt!==ii||on!==vs)&&(s.stencilOp(Et,ii,vs),Le=Et,bt=ii,on=vs)},setLocked:function(Et){O=Et},setClear:function(Et){ni!==Et&&(s.clearStencil(Et),ni=Et)},reset:function(){O=!1,Pe=null,ee=null,le=null,Ce=null,Le=null,bt=null,on=null,ni=null}}}const i=new e,r=new t,o=new n,a=new WeakMap,c=new WeakMap;let l={},u={},h=new WeakMap,d=[],p=null,f=!1,x=null,m=null,g=null,y=null,_=null,v=null,I=null,T=new _e(0,0,0),w=0,C=!1,F=null,M=null,b=null,G=null,W=null;const $=s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let ie=!1,q=0;const he=s.getParameter(s.VERSION);he.indexOf("WebGL")!==-1?(q=parseFloat(/^WebGL (\d)/.exec(he)[1]),ie=q>=1):he.indexOf("OpenGL ES")!==-1&&(q=parseFloat(/^OpenGL ES (\d)/.exec(he)[1]),ie=q>=2);let Q=null,we={};const Ne=s.getParameter(s.SCISSOR_BOX),Ee=s.getParameter(s.VIEWPORT),Qe=new st().fromArray(Ne),ht=new st().fromArray(Ee);function ne(O,Pe,ee,le){const Ce=new Uint8Array(4),Le=s.createTexture();s.bindTexture(O,Le),s.texParameteri(O,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(O,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let bt=0;bt<ee;bt++)O===s.TEXTURE_3D||O===s.TEXTURE_2D_ARRAY?s.texImage3D(Pe,0,s.RGBA,1,1,le,0,s.RGBA,s.UNSIGNED_BYTE,Ce):s.texImage2D(Pe+bt,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,Ce);return Le}const ue={};ue[s.TEXTURE_2D]=ne(s.TEXTURE_2D,s.TEXTURE_2D,1),ue[s.TEXTURE_CUBE_MAP]=ne(s.TEXTURE_CUBE_MAP,s.TEXTURE_CUBE_MAP_POSITIVE_X,6),ue[s.TEXTURE_2D_ARRAY]=ne(s.TEXTURE_2D_ARRAY,s.TEXTURE_2D_ARRAY,1,1),ue[s.TEXTURE_3D]=ne(s.TEXTURE_3D,s.TEXTURE_3D,1,1),i.setClear(0,0,0,1),r.setClear(1),o.setClear(0),Ae(s.DEPTH_TEST),r.setFunc(nr),ye(!1),de(sf),Ae(s.CULL_FACE),P(Fi);function Ae(O){l[O]!==!0&&(s.enable(O),l[O]=!0)}function ge(O){l[O]!==!1&&(s.disable(O),l[O]=!1)}function Ze(O,Pe){return u[O]!==Pe?(s.bindFramebuffer(O,Pe),u[O]=Pe,O===s.DRAW_FRAMEBUFFER&&(u[s.FRAMEBUFFER]=Pe),O===s.FRAMEBUFFER&&(u[s.DRAW_FRAMEBUFFER]=Pe),!0):!1}function Xe(O,Pe){let ee=d,le=!1;if(O){ee=h.get(Pe),ee===void 0&&(ee=[],h.set(Pe,ee));const Ce=O.textures;if(ee.length!==Ce.length||ee[0]!==s.COLOR_ATTACHMENT0){for(let Le=0,bt=Ce.length;Le<bt;Le++)ee[Le]=s.COLOR_ATTACHMENT0+Le;ee.length=Ce.length,le=!0}}else ee[0]!==s.BACK&&(ee[0]=s.BACK,le=!0);le&&s.drawBuffers(ee)}function Je(O){return p!==O?(s.useProgram(O),p=O,!0):!1}const dt={[Zs]:s.FUNC_ADD,[q_]:s.FUNC_SUBTRACT,[$_]:s.FUNC_REVERSE_SUBTRACT};dt[Y_]=s.MIN,dt[Ff]=s.MAX;const ae={[Z_]:s.ZERO,[J_]:s.ONE,[K_]:s.SRC_COLOR,[Ou]:s.SRC_ALPHA,[iy]:s.SRC_ALPHA_SATURATE,[ty]:s.DST_COLOR,[Q_]:s.DST_ALPHA,[j_]:s.ONE_MINUS_SRC_COLOR,[Vu]:s.ONE_MINUS_SRC_ALPHA,[ny]:s.ONE_MINUS_DST_COLOR,[ey]:s.ONE_MINUS_DST_ALPHA,[sy]:s.CONSTANT_COLOR,[ry]:s.ONE_MINUS_CONSTANT_COLOR,[oy]:s.CONSTANT_ALPHA,[ay]:s.ONE_MINUS_CONSTANT_ALPHA};function P(O,Pe,ee,le,Ce,Le,bt,on,ni,Et){if(O===Fi){f===!0&&(ge(s.BLEND),f=!1);return}if(f===!1&&(Ae(s.BLEND),f=!0),O!==Uf){if(O!==x||Et!==C){if((m!==Zs||_!==Zs)&&(s.blendEquation(s.FUNC_ADD),m=Zs,_=Zs),Et)switch(O){case Ps:s.blendFuncSeparate(s.ONE,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case cc:s.blendFunc(s.ONE,s.ONE);break;case rf:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case of:s.blendFuncSeparate(s.ZERO,s.SRC_COLOR,s.ZERO,s.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",O);break}else switch(O){case Ps:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case cc:s.blendFunc(s.SRC_ALPHA,s.ONE);break;case rf:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case of:s.blendFunc(s.ZERO,s.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",O);break}g=null,y=null,v=null,I=null,T.set(0,0,0),w=0,x=O,C=Et}return}Ce=Ce||Pe,Le=Le||ee,bt=bt||le,(Pe!==m||Ce!==_)&&(s.blendEquationSeparate(dt[Pe],dt[Ce]),m=Pe,_=Ce),(ee!==g||le!==y||Le!==v||bt!==I)&&(s.blendFuncSeparate(ae[ee],ae[le],ae[Le],ae[bt]),g=ee,y=le,v=Le,I=bt),(on.equals(T)===!1||ni!==w)&&(s.blendColor(on.r,on.g,on.b,ni),T.copy(on),w=ni),x=O,C=!1}function Me(O,Pe){O.side===Ji?ge(s.CULL_FACE):Ae(s.CULL_FACE);let ee=O.side===ln;Pe&&(ee=!ee),ye(ee),O.blending===Ps&&O.transparent===!1?P(Fi):P(O.blending,O.blendEquation,O.blendSrc,O.blendDst,O.blendEquationAlpha,O.blendSrcAlpha,O.blendDstAlpha,O.blendColor,O.blendAlpha,O.premultipliedAlpha),r.setFunc(O.depthFunc),r.setTest(O.depthTest),r.setMask(O.depthWrite),i.setMask(O.colorWrite);const le=O.stencilWrite;o.setTest(le),le&&(o.setMask(O.stencilWriteMask),o.setFunc(O.stencilFunc,O.stencilRef,O.stencilFuncMask),o.setOp(O.stencilFail,O.stencilZFail,O.stencilZPass)),qe(O.polygonOffset,O.polygonOffsetFactor,O.polygonOffsetUnits),O.alphaToCoverage===!0?Ae(s.SAMPLE_ALPHA_TO_COVERAGE):ge(s.SAMPLE_ALPHA_TO_COVERAGE)}function ye(O){F!==O&&(O?s.frontFace(s.CW):s.frontFace(s.CCW),F=O)}function de(O){O!==W_?(Ae(s.CULL_FACE),O!==M&&(O===sf?s.cullFace(s.BACK):O===X_?s.cullFace(s.FRONT):s.cullFace(s.FRONT_AND_BACK))):ge(s.CULL_FACE),M=O}function Te(O){O!==b&&(ie&&s.lineWidth(O),b=O)}function qe(O,Pe,ee){O?(Ae(s.POLYGON_OFFSET_FILL),(G!==Pe||W!==ee)&&(s.polygonOffset(Pe,ee),G=Pe,W=ee)):ge(s.POLYGON_OFFSET_FILL)}function Ie(O){O?Ae(s.SCISSOR_TEST):ge(s.SCISSOR_TEST)}function R(O){O===void 0&&(O=s.TEXTURE0+$-1),Q!==O&&(s.activeTexture(O),Q=O)}function S(O,Pe,ee){ee===void 0&&(Q===null?ee=s.TEXTURE0+$-1:ee=Q);let le=we[ee];le===void 0&&(le={type:void 0,texture:void 0},we[ee]=le),(le.type!==O||le.texture!==Pe)&&(Q!==ee&&(s.activeTexture(ee),Q=ee),s.bindTexture(O,Pe||ue[O]),le.type=O,le.texture=Pe)}function X(){const O=we[Q];O!==void 0&&O.type!==void 0&&(s.bindTexture(O.type,null),O.type=void 0,O.texture=void 0)}function re(){try{s.compressedTexImage2D.apply(s,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function ce(){try{s.compressedTexImage3D.apply(s,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function se(){try{s.texSubImage2D.apply(s,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function ke(){try{s.texSubImage3D.apply(s,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function be(){try{s.compressedTexSubImage2D.apply(s,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function De(){try{s.compressedTexSubImage3D.apply(s,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function vt(){try{s.texStorage2D.apply(s,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function me(){try{s.texStorage3D.apply(s,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function Ue(){try{s.texImage2D.apply(s,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function tt(){try{s.texImage3D.apply(s,arguments)}catch(O){console.error("THREE.WebGLState:",O)}}function nt(O){Qe.equals(O)===!1&&(s.scissor(O.x,O.y,O.z,O.w),Qe.copy(O))}function Be(O){ht.equals(O)===!1&&(s.viewport(O.x,O.y,O.z,O.w),ht.copy(O))}function Mt(O,Pe){let ee=c.get(Pe);ee===void 0&&(ee=new WeakMap,c.set(Pe,ee));let le=ee.get(O);le===void 0&&(le=s.getUniformBlockIndex(Pe,O.name),ee.set(O,le))}function ct(O,Pe){const le=c.get(Pe).get(O);a.get(Pe)!==le&&(s.uniformBlockBinding(Pe,le,O.__bindingPointIndex),a.set(Pe,le))}function Ot(){s.disable(s.BLEND),s.disable(s.CULL_FACE),s.disable(s.DEPTH_TEST),s.disable(s.POLYGON_OFFSET_FILL),s.disable(s.SCISSOR_TEST),s.disable(s.STENCIL_TEST),s.disable(s.SAMPLE_ALPHA_TO_COVERAGE),s.blendEquation(s.FUNC_ADD),s.blendFunc(s.ONE,s.ZERO),s.blendFuncSeparate(s.ONE,s.ZERO,s.ONE,s.ZERO),s.blendColor(0,0,0,0),s.colorMask(!0,!0,!0,!0),s.clearColor(0,0,0,0),s.depthMask(!0),s.depthFunc(s.LESS),s.clearDepth(1),s.stencilMask(4294967295),s.stencilFunc(s.ALWAYS,0,4294967295),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),s.clearStencil(0),s.cullFace(s.BACK),s.frontFace(s.CCW),s.polygonOffset(0,0),s.activeTexture(s.TEXTURE0),s.bindFramebuffer(s.FRAMEBUFFER,null),s.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),s.bindFramebuffer(s.READ_FRAMEBUFFER,null),s.useProgram(null),s.lineWidth(1),s.scissor(0,0,s.canvas.width,s.canvas.height),s.viewport(0,0,s.canvas.width,s.canvas.height),l={},Q=null,we={},u={},h=new WeakMap,d=[],p=null,f=!1,x=null,m=null,g=null,y=null,_=null,v=null,I=null,T=new _e(0,0,0),w=0,C=!1,F=null,M=null,b=null,G=null,W=null,Qe.set(0,0,s.canvas.width,s.canvas.height),ht.set(0,0,s.canvas.width,s.canvas.height),i.reset(),r.reset(),o.reset()}return{buffers:{color:i,depth:r,stencil:o},enable:Ae,disable:ge,bindFramebuffer:Ze,drawBuffers:Xe,useProgram:Je,setBlending:P,setMaterial:Me,setFlipSided:ye,setCullFace:de,setLineWidth:Te,setPolygonOffset:qe,setScissorTest:Ie,activeTexture:R,bindTexture:S,unbindTexture:X,compressedTexImage2D:re,compressedTexImage3D:ce,texImage2D:Ue,texImage3D:tt,updateUBOMapping:Mt,uniformBlockBinding:ct,texStorage2D:vt,texStorage3D:me,texSubImage2D:se,texSubImage3D:ke,compressedTexSubImage2D:be,compressedTexSubImage3D:De,scissor:nt,viewport:Be,reset:Ot}}function LR(s,e){const t=s.image&&s.image.width?s.image.width/s.image.height:1;return t>e?(s.repeat.x=1,s.repeat.y=t/e,s.offset.x=0,s.offset.y=(1-s.repeat.y)/2):(s.repeat.x=e/t,s.repeat.y=1,s.offset.x=(1-s.repeat.x)/2,s.offset.y=0),s}function DR(s,e){const t=s.image&&s.image.width?s.image.width/s.image.height:1;return t>e?(s.repeat.x=e/t,s.repeat.y=1,s.offset.x=(1-s.repeat.x)/2,s.offset.y=0):(s.repeat.x=1,s.repeat.y=t/e,s.offset.x=0,s.offset.y=(1-s.repeat.y)/2),s}function UR(s){return s.repeat.x=1,s.repeat.y=1,s.offset.x=0,s.offset.y=0,s}function lf(s,e,t,n){const i=FR(n);switch(t){case Gf:return s*e;case Hf:return s*e;case Wf:return s*e*2;case Hc:return s*e/i.components*i.byteLength;case Wc:return s*e/i.components*i.byteLength;case na:return s*e*2/i.components*i.byteLength;case Vh:return s*e*2/i.components*i.byteLength;case Oh:return s*e*3/i.components*i.byteLength;case Rn:return s*e*4/i.components*i.byteLength;case Bh:return s*e*4/i.components*i.byteLength;case $o:case Yo:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case Zo:case Jo:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Bu:case zu:return Math.max(s,16)*Math.max(e,8)/4;case gc:case xc:return Math.max(s,8)*Math.max(e,8)/2;case _c:case yc:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case vc:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Mc:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case ku:return Math.floor((s+4)/5)*Math.floor((e+3)/4)*16;case Gu:return Math.floor((s+4)/5)*Math.floor((e+4)/5)*16;case Hu:return Math.floor((s+5)/6)*Math.floor((e+4)/5)*16;case Sc:return Math.floor((s+5)/6)*Math.floor((e+5)/6)*16;case Wu:return Math.floor((s+7)/8)*Math.floor((e+4)/5)*16;case Xu:return Math.floor((s+7)/8)*Math.floor((e+5)/6)*16;case qu:return Math.floor((s+7)/8)*Math.floor((e+7)/8)*16;case $u:return Math.floor((s+9)/10)*Math.floor((e+4)/5)*16;case Yu:return Math.floor((s+9)/10)*Math.floor((e+5)/6)*16;case Zu:return Math.floor((s+9)/10)*Math.floor((e+7)/8)*16;case Ju:return Math.floor((s+9)/10)*Math.floor((e+9)/10)*16;case Ku:return Math.floor((s+11)/12)*Math.floor((e+9)/10)*16;case ju:return Math.floor((s+11)/12)*Math.floor((e+11)/12)*16;case Ko:case Qu:case Tc:return Math.ceil(s/4)*Math.ceil(e/4)*16;case Xf:case eh:return Math.ceil(s/4)*Math.ceil(e/4)*8;case th:case nh:return Math.ceil(s/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function FR(s){switch(s){case es:case zf:return{byteLength:1,components:1};case ta:case kf:case Ln:return{byteLength:2,components:1};case Lh:case Dh:return{byteLength:2,components:4};case Bi:case ma:case Gn:return{byteLength:4,components:1};case Uh:case Fh:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${s}.`)}const OR={contain:LR,cover:DR,fill:UR,getByteLength:lf};function VR(s,e,t,n,i,r,o){const a=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new J,u=new WeakMap;let h;const d=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function f(R,S){return p?new OffscreenCanvas(R,S):Cc("canvas")}function x(R,S,X){let re=1;const ce=Ie(R);if((ce.width>X||ce.height>X)&&(re=X/Math.max(ce.width,ce.height)),re<1)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap||typeof VideoFrame<"u"&&R instanceof VideoFrame){const se=Math.floor(re*ce.width),ke=Math.floor(re*ce.height);h===void 0&&(h=f(se,ke));const be=S?f(se,ke):h;return be.width=se,be.height=ke,be.getContext("2d").drawImage(R,0,0,se,ke),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+ce.width+"x"+ce.height+") to ("+se+"x"+ke+")."),be}else return"data"in R&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+ce.width+"x"+ce.height+")."),R;return R}function m(R){return R.generateMipmaps&&R.minFilter!==Qt&&R.minFilter!==Ut}function g(R){s.generateMipmap(R)}function y(R,S,X,re,ce=!1){if(R!==null){if(s[R]!==void 0)return s[R];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let se=S;if(S===s.RED&&(X===s.FLOAT&&(se=s.R32F),X===s.HALF_FLOAT&&(se=s.R16F),X===s.UNSIGNED_BYTE&&(se=s.R8)),S===s.RED_INTEGER&&(X===s.UNSIGNED_BYTE&&(se=s.R8UI),X===s.UNSIGNED_SHORT&&(se=s.R16UI),X===s.UNSIGNED_INT&&(se=s.R32UI),X===s.BYTE&&(se=s.R8I),X===s.SHORT&&(se=s.R16I),X===s.INT&&(se=s.R32I)),S===s.RG&&(X===s.FLOAT&&(se=s.RG32F),X===s.HALF_FLOAT&&(se=s.RG16F),X===s.UNSIGNED_BYTE&&(se=s.RG8)),S===s.RG_INTEGER&&(X===s.UNSIGNED_BYTE&&(se=s.RG8UI),X===s.UNSIGNED_SHORT&&(se=s.RG16UI),X===s.UNSIGNED_INT&&(se=s.RG32UI),X===s.BYTE&&(se=s.RG8I),X===s.SHORT&&(se=s.RG16I),X===s.INT&&(se=s.RG32I)),S===s.RGB_INTEGER&&(X===s.UNSIGNED_BYTE&&(se=s.RGB8UI),X===s.UNSIGNED_SHORT&&(se=s.RGB16UI),X===s.UNSIGNED_INT&&(se=s.RGB32UI),X===s.BYTE&&(se=s.RGB8I),X===s.SHORT&&(se=s.RGB16I),X===s.INT&&(se=s.RGB32I)),S===s.RGBA_INTEGER&&(X===s.UNSIGNED_BYTE&&(se=s.RGBA8UI),X===s.UNSIGNED_SHORT&&(se=s.RGBA16UI),X===s.UNSIGNED_INT&&(se=s.RGBA32UI),X===s.BYTE&&(se=s.RGBA8I),X===s.SHORT&&(se=s.RGBA16I),X===s.INT&&(se=s.RGBA32I)),S===s.RGB&&(X===s.UNSIGNED_INT_5_9_9_9_REV&&(se=s.RGB9_E5),X===s.UNSIGNED_INT_10F_11F_11F_REV&&(se=s.R11F_G11F_B10F)),S===s.RGBA){const ke=ce?Ac:gt.getTransfer(re);X===s.FLOAT&&(se=s.RGBA32F),X===s.HALF_FLOAT&&(se=s.RGBA16F),X===s.UNSIGNED_BYTE&&(se=ke===Vt?s.SRGB8_ALPHA8:s.RGBA8),X===s.UNSIGNED_SHORT_4_4_4_4&&(se=s.RGBA4),X===s.UNSIGNED_SHORT_5_5_5_1&&(se=s.RGB5_A1)}return(se===s.R16F||se===s.R32F||se===s.RG16F||se===s.RG32F||se===s.RGBA16F||se===s.RGBA32F)&&e.get("EXT_color_buffer_float"),se}function _(R,S){let X;return R?S===null||S===Bi||S===or?X=s.DEPTH24_STENCIL8:S===Gn?X=s.DEPTH32F_STENCIL8:S===ta&&(X=s.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):S===null||S===Bi||S===or?X=s.DEPTH_COMPONENT24:S===Gn?X=s.DEPTH_COMPONENT32F:S===ta&&(X=s.DEPTH_COMPONENT16),X}function v(R,S){return m(R)===!0||R.isFramebufferTexture&&R.minFilter!==Qt&&R.minFilter!==Ut?Math.log2(Math.max(S.width,S.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?S.mipmaps.length:1}function I(R){const S=R.target;S.removeEventListener("dispose",I),w(S),S.isVideoTexture&&u.delete(S)}function T(R){const S=R.target;S.removeEventListener("dispose",T),F(S)}function w(R){const S=n.get(R);if(S.__webglInit===void 0)return;const X=R.source,re=d.get(X);if(re){const ce=re[S.__cacheKey];ce.usedTimes--,ce.usedTimes===0&&C(R),Object.keys(re).length===0&&d.delete(X)}n.remove(R)}function C(R){const S=n.get(R);s.deleteTexture(S.__webglTexture);const X=R.source,re=d.get(X);delete re[S.__cacheKey],o.memory.textures--}function F(R){const S=n.get(R);if(R.depthTexture&&R.depthTexture.dispose(),R.isWebGLCubeRenderTarget)for(let re=0;re<6;re++){if(Array.isArray(S.__webglFramebuffer[re]))for(let ce=0;ce<S.__webglFramebuffer[re].length;ce++)s.deleteFramebuffer(S.__webglFramebuffer[re][ce]);else s.deleteFramebuffer(S.__webglFramebuffer[re]);S.__webglDepthbuffer&&s.deleteRenderbuffer(S.__webglDepthbuffer[re])}else{if(Array.isArray(S.__webglFramebuffer))for(let re=0;re<S.__webglFramebuffer.length;re++)s.deleteFramebuffer(S.__webglFramebuffer[re]);else s.deleteFramebuffer(S.__webglFramebuffer);if(S.__webglDepthbuffer&&s.deleteRenderbuffer(S.__webglDepthbuffer),S.__webglMultisampledFramebuffer&&s.deleteFramebuffer(S.__webglMultisampledFramebuffer),S.__webglColorRenderbuffer)for(let re=0;re<S.__webglColorRenderbuffer.length;re++)S.__webglColorRenderbuffer[re]&&s.deleteRenderbuffer(S.__webglColorRenderbuffer[re]);S.__webglDepthRenderbuffer&&s.deleteRenderbuffer(S.__webglDepthRenderbuffer)}const X=R.textures;for(let re=0,ce=X.length;re<ce;re++){const se=n.get(X[re]);se.__webglTexture&&(s.deleteTexture(se.__webglTexture),o.memory.textures--),n.remove(X[re])}n.remove(R)}let M=0;function b(){M=0}function G(){const R=M;return R>=i.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+i.maxTextures),M+=1,R}function W(R){const S=[];return S.push(R.wrapS),S.push(R.wrapT),S.push(R.wrapR||0),S.push(R.magFilter),S.push(R.minFilter),S.push(R.anisotropy),S.push(R.internalFormat),S.push(R.format),S.push(R.type),S.push(R.generateMipmaps),S.push(R.premultiplyAlpha),S.push(R.flipY),S.push(R.unpackAlignment),S.push(R.colorSpace),S.join()}function $(R,S){const X=n.get(R);if(R.isVideoTexture&&Te(R),R.isRenderTargetTexture===!1&&R.version>0&&X.__version!==R.version){const re=R.image;if(re===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(re.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ht(X,R,S);return}}t.bindTexture(s.TEXTURE_2D,X.__webglTexture,s.TEXTURE0+S)}function ie(R,S){const X=n.get(R);if(R.version>0&&X.__version!==R.version){ht(X,R,S);return}t.bindTexture(s.TEXTURE_2D_ARRAY,X.__webglTexture,s.TEXTURE0+S)}function q(R,S){const X=n.get(R);if(R.version>0&&X.__version!==R.version){ht(X,R,S);return}t.bindTexture(s.TEXTURE_3D,X.__webglTexture,s.TEXTURE0+S)}function he(R,S){const X=n.get(R);if(R.version>0&&X.__version!==R.version){ne(X,R,S);return}t.bindTexture(s.TEXTURE_CUBE_MAP,X.__webglTexture,s.TEXTURE0+S)}const Q={[rr]:s.REPEAT,[Si]:s.CLAMP_TO_EDGE,[ea]:s.MIRRORED_REPEAT},we={[Qt]:s.NEAREST,[Ph]:s.NEAREST_MIPMAP_NEAREST,[Cs]:s.NEAREST_MIPMAP_LINEAR,[Ut]:s.LINEAR,[js]:s.LINEAR_MIPMAP_NEAREST,[Jn]:s.LINEAR_MIPMAP_LINEAR},Ne={[Cy]:s.NEVER,[Dy]:s.ALWAYS,[jf]:s.LESS,[Qf]:s.LEQUAL,[Ry]:s.EQUAL,[Ly]:s.GEQUAL,[Iy]:s.GREATER,[Py]:s.NOTEQUAL};function Ee(R,S){if(S.type===Gn&&e.has("OES_texture_float_linear")===!1&&(S.magFilter===Ut||S.magFilter===js||S.magFilter===Cs||S.magFilter===Jn||S.minFilter===Ut||S.minFilter===js||S.minFilter===Cs||S.minFilter===Jn)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),s.texParameteri(R,s.TEXTURE_WRAP_S,Q[S.wrapS]),s.texParameteri(R,s.TEXTURE_WRAP_T,Q[S.wrapT]),(R===s.TEXTURE_3D||R===s.TEXTURE_2D_ARRAY)&&s.texParameteri(R,s.TEXTURE_WRAP_R,Q[S.wrapR]),s.texParameteri(R,s.TEXTURE_MAG_FILTER,we[S.magFilter]),s.texParameteri(R,s.TEXTURE_MIN_FILTER,we[S.minFilter]),S.compareFunction&&(s.texParameteri(R,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(R,s.TEXTURE_COMPARE_FUNC,Ne[S.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(S.magFilter===Qt||S.minFilter!==Cs&&S.minFilter!==Jn||S.type===Gn&&e.has("OES_texture_float_linear")===!1)return;if(S.anisotropy>1||n.get(S).__currentAnisotropy){const X=e.get("EXT_texture_filter_anisotropic");s.texParameterf(R,X.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(S.anisotropy,i.getMaxAnisotropy())),n.get(S).__currentAnisotropy=S.anisotropy}}}function Qe(R,S){let X=!1;R.__webglInit===void 0&&(R.__webglInit=!0,S.addEventListener("dispose",I));const re=S.source;let ce=d.get(re);ce===void 0&&(ce={},d.set(re,ce));const se=W(S);if(se!==R.__cacheKey){ce[se]===void 0&&(ce[se]={texture:s.createTexture(),usedTimes:0},o.memory.textures++,X=!0),ce[se].usedTimes++;const ke=ce[R.__cacheKey];ke!==void 0&&(ce[R.__cacheKey].usedTimes--,ke.usedTimes===0&&C(S)),R.__cacheKey=se,R.__webglTexture=ce[se].texture}return X}function ht(R,S,X){let re=s.TEXTURE_2D;(S.isDataArrayTexture||S.isCompressedArrayTexture)&&(re=s.TEXTURE_2D_ARRAY),S.isData3DTexture&&(re=s.TEXTURE_3D);const ce=Qe(R,S),se=S.source;t.bindTexture(re,R.__webglTexture,s.TEXTURE0+X);const ke=n.get(se);if(se.version!==ke.__version||ce===!0){t.activeTexture(s.TEXTURE0+X);const be=gt.getPrimaries(gt.workingColorSpace),De=S.colorSpace===Li?null:gt.getPrimaries(S.colorSpace),vt=S.colorSpace===Li||be===De?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,S.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,S.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,vt);let me=x(S.image,!1,i.maxTextureSize);me=qe(S,me);const Ue=r.convert(S.format,S.colorSpace),tt=r.convert(S.type);let nt=y(S.internalFormat,Ue,tt,S.colorSpace,S.isVideoTexture);Ee(re,S);let Be;const Mt=S.mipmaps,ct=S.isVideoTexture!==!0,Ot=ke.__version===void 0||ce===!0,O=se.dataReady,Pe=v(S,me);if(S.isDepthTexture)nt=_(S.format===ar,S.type),Ot&&(ct?t.texStorage2D(s.TEXTURE_2D,1,nt,me.width,me.height):t.texImage2D(s.TEXTURE_2D,0,nt,me.width,me.height,0,Ue,tt,null));else if(S.isDataTexture)if(Mt.length>0){ct&&Ot&&t.texStorage2D(s.TEXTURE_2D,Pe,nt,Mt[0].width,Mt[0].height);for(let ee=0,le=Mt.length;ee<le;ee++)Be=Mt[ee],ct?O&&t.texSubImage2D(s.TEXTURE_2D,ee,0,0,Be.width,Be.height,Ue,tt,Be.data):t.texImage2D(s.TEXTURE_2D,ee,nt,Be.width,Be.height,0,Ue,tt,Be.data);S.generateMipmaps=!1}else ct?(Ot&&t.texStorage2D(s.TEXTURE_2D,Pe,nt,me.width,me.height),O&&t.texSubImage2D(s.TEXTURE_2D,0,0,0,me.width,me.height,Ue,tt,me.data)):t.texImage2D(s.TEXTURE_2D,0,nt,me.width,me.height,0,Ue,tt,me.data);else if(S.isCompressedTexture)if(S.isCompressedArrayTexture){ct&&Ot&&t.texStorage3D(s.TEXTURE_2D_ARRAY,Pe,nt,Mt[0].width,Mt[0].height,me.depth);for(let ee=0,le=Mt.length;ee<le;ee++)if(Be=Mt[ee],S.format!==Rn)if(Ue!==null)if(ct){if(O)if(S.layerUpdates.size>0){const Ce=lf(Be.width,Be.height,S.format,S.type);for(const Le of S.layerUpdates){const bt=Be.data.subarray(Le*Ce/Be.data.BYTES_PER_ELEMENT,(Le+1)*Ce/Be.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,ee,0,0,Le,Be.width,Be.height,1,Ue,bt,0,0)}S.clearLayerUpdates()}else t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,ee,0,0,0,Be.width,Be.height,me.depth,Ue,Be.data,0,0)}else t.compressedTexImage3D(s.TEXTURE_2D_ARRAY,ee,nt,Be.width,Be.height,me.depth,0,Be.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else ct?O&&t.texSubImage3D(s.TEXTURE_2D_ARRAY,ee,0,0,0,Be.width,Be.height,me.depth,Ue,tt,Be.data):t.texImage3D(s.TEXTURE_2D_ARRAY,ee,nt,Be.width,Be.height,me.depth,0,Ue,tt,Be.data)}else{ct&&Ot&&t.texStorage2D(s.TEXTURE_2D,Pe,nt,Mt[0].width,Mt[0].height);for(let ee=0,le=Mt.length;ee<le;ee++)Be=Mt[ee],S.format!==Rn?Ue!==null?ct?O&&t.compressedTexSubImage2D(s.TEXTURE_2D,ee,0,0,Be.width,Be.height,Ue,Be.data):t.compressedTexImage2D(s.TEXTURE_2D,ee,nt,Be.width,Be.height,0,Be.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ct?O&&t.texSubImage2D(s.TEXTURE_2D,ee,0,0,Be.width,Be.height,Ue,tt,Be.data):t.texImage2D(s.TEXTURE_2D,ee,nt,Be.width,Be.height,0,Ue,tt,Be.data)}else if(S.isDataArrayTexture)if(ct){if(Ot&&t.texStorage3D(s.TEXTURE_2D_ARRAY,Pe,nt,me.width,me.height,me.depth),O)if(S.layerUpdates.size>0){const ee=lf(me.width,me.height,S.format,S.type);for(const le of S.layerUpdates){const Ce=me.data.subarray(le*ee/me.data.BYTES_PER_ELEMENT,(le+1)*ee/me.data.BYTES_PER_ELEMENT);t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,le,me.width,me.height,1,Ue,tt,Ce)}S.clearLayerUpdates()}else t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,me.width,me.height,me.depth,Ue,tt,me.data)}else t.texImage3D(s.TEXTURE_2D_ARRAY,0,nt,me.width,me.height,me.depth,0,Ue,tt,me.data);else if(S.isData3DTexture)ct?(Ot&&t.texStorage3D(s.TEXTURE_3D,Pe,nt,me.width,me.height,me.depth),O&&t.texSubImage3D(s.TEXTURE_3D,0,0,0,0,me.width,me.height,me.depth,Ue,tt,me.data)):t.texImage3D(s.TEXTURE_3D,0,nt,me.width,me.height,me.depth,0,Ue,tt,me.data);else if(S.isFramebufferTexture){if(Ot)if(ct)t.texStorage2D(s.TEXTURE_2D,Pe,nt,me.width,me.height);else{let ee=me.width,le=me.height;for(let Ce=0;Ce<Pe;Ce++)t.texImage2D(s.TEXTURE_2D,Ce,nt,ee,le,0,Ue,tt,null),ee>>=1,le>>=1}}else if(Mt.length>0){if(ct&&Ot){const ee=Ie(Mt[0]);t.texStorage2D(s.TEXTURE_2D,Pe,nt,ee.width,ee.height)}for(let ee=0,le=Mt.length;ee<le;ee++)Be=Mt[ee],ct?O&&t.texSubImage2D(s.TEXTURE_2D,ee,0,0,Ue,tt,Be):t.texImage2D(s.TEXTURE_2D,ee,nt,Ue,tt,Be);S.generateMipmaps=!1}else if(ct){if(Ot){const ee=Ie(me);t.texStorage2D(s.TEXTURE_2D,Pe,nt,ee.width,ee.height)}O&&t.texSubImage2D(s.TEXTURE_2D,0,0,0,Ue,tt,me)}else t.texImage2D(s.TEXTURE_2D,0,nt,Ue,tt,me);m(S)&&g(re),ke.__version=se.version,S.onUpdate&&S.onUpdate(S)}R.__version=S.version}function ne(R,S,X){if(S.image.length!==6)return;const re=Qe(R,S),ce=S.source;t.bindTexture(s.TEXTURE_CUBE_MAP,R.__webglTexture,s.TEXTURE0+X);const se=n.get(ce);if(ce.version!==se.__version||re===!0){t.activeTexture(s.TEXTURE0+X);const ke=gt.getPrimaries(gt.workingColorSpace),be=S.colorSpace===Li?null:gt.getPrimaries(S.colorSpace),De=S.colorSpace===Li||ke===be?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,S.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,S.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,De);const vt=S.isCompressedTexture||S.image[0].isCompressedTexture,me=S.image[0]&&S.image[0].isDataTexture,Ue=[];for(let le=0;le<6;le++)!vt&&!me?Ue[le]=x(S.image[le],!0,i.maxCubemapSize):Ue[le]=me?S.image[le].image:S.image[le],Ue[le]=qe(S,Ue[le]);const tt=Ue[0],nt=r.convert(S.format,S.colorSpace),Be=r.convert(S.type),Mt=y(S.internalFormat,nt,Be,S.colorSpace),ct=S.isVideoTexture!==!0,Ot=se.__version===void 0||re===!0,O=ce.dataReady;let Pe=v(S,tt);Ee(s.TEXTURE_CUBE_MAP,S);let ee;if(vt){ct&&Ot&&t.texStorage2D(s.TEXTURE_CUBE_MAP,Pe,Mt,tt.width,tt.height);for(let le=0;le<6;le++){ee=Ue[le].mipmaps;for(let Ce=0;Ce<ee.length;Ce++){const Le=ee[Ce];S.format!==Rn?nt!==null?ct?O&&t.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+le,Ce,0,0,Le.width,Le.height,nt,Le.data):t.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+le,Ce,Mt,Le.width,Le.height,0,Le.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ct?O&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+le,Ce,0,0,Le.width,Le.height,nt,Be,Le.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+le,Ce,Mt,Le.width,Le.height,0,nt,Be,Le.data)}}}else{if(ee=S.mipmaps,ct&&Ot){ee.length>0&&Pe++;const le=Ie(Ue[0]);t.texStorage2D(s.TEXTURE_CUBE_MAP,Pe,Mt,le.width,le.height)}for(let le=0;le<6;le++)if(me){ct?O&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+le,0,0,0,Ue[le].width,Ue[le].height,nt,Be,Ue[le].data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+le,0,Mt,Ue[le].width,Ue[le].height,0,nt,Be,Ue[le].data);for(let Ce=0;Ce<ee.length;Ce++){const bt=ee[Ce].image[le].image;ct?O&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+le,Ce+1,0,0,bt.width,bt.height,nt,Be,bt.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+le,Ce+1,Mt,bt.width,bt.height,0,nt,Be,bt.data)}}else{ct?O&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+le,0,0,0,nt,Be,Ue[le]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+le,0,Mt,nt,Be,Ue[le]);for(let Ce=0;Ce<ee.length;Ce++){const Le=ee[Ce];ct?O&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+le,Ce+1,0,0,nt,Be,Le.image[le]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+le,Ce+1,Mt,nt,Be,Le.image[le])}}}m(S)&&g(s.TEXTURE_CUBE_MAP),se.__version=ce.version,S.onUpdate&&S.onUpdate(S)}R.__version=S.version}function ue(R,S,X,re,ce,se){const ke=r.convert(X.format,X.colorSpace),be=r.convert(X.type),De=y(X.internalFormat,ke,be,X.colorSpace);if(!n.get(S).__hasExternalTextures){const me=Math.max(1,S.width>>se),Ue=Math.max(1,S.height>>se);ce===s.TEXTURE_3D||ce===s.TEXTURE_2D_ARRAY?t.texImage3D(ce,se,De,me,Ue,S.depth,0,ke,be,null):t.texImage2D(ce,se,De,me,Ue,0,ke,be,null)}t.bindFramebuffer(s.FRAMEBUFFER,R),de(S)?a.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,re,ce,n.get(X).__webglTexture,0,ye(S)):(ce===s.TEXTURE_2D||ce>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&ce<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,re,ce,n.get(X).__webglTexture,se),t.bindFramebuffer(s.FRAMEBUFFER,null)}function Ae(R,S,X){if(s.bindRenderbuffer(s.RENDERBUFFER,R),S.depthBuffer){const re=S.depthTexture,ce=re&&re.isDepthTexture?re.type:null,se=_(S.stencilBuffer,ce),ke=S.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,be=ye(S);de(S)?a.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,be,se,S.width,S.height):X?s.renderbufferStorageMultisample(s.RENDERBUFFER,be,se,S.width,S.height):s.renderbufferStorage(s.RENDERBUFFER,se,S.width,S.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,ke,s.RENDERBUFFER,R)}else{const re=S.textures;for(let ce=0;ce<re.length;ce++){const se=re[ce],ke=r.convert(se.format,se.colorSpace),be=r.convert(se.type),De=y(se.internalFormat,ke,be,se.colorSpace),vt=ye(S);X&&de(S)===!1?s.renderbufferStorageMultisample(s.RENDERBUFFER,vt,De,S.width,S.height):de(S)?a.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,vt,De,S.width,S.height):s.renderbufferStorage(s.RENDERBUFFER,De,S.width,S.height)}}s.bindRenderbuffer(s.RENDERBUFFER,null)}function ge(R,S){if(S&&S.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(s.FRAMEBUFFER,R),!(S.depthTexture&&S.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(S.depthTexture).__webglTexture||S.depthTexture.image.width!==S.width||S.depthTexture.image.height!==S.height)&&(S.depthTexture.image.width=S.width,S.depthTexture.image.height=S.height,S.depthTexture.needsUpdate=!0),$(S.depthTexture,0);const re=n.get(S.depthTexture).__webglTexture,ce=ye(S);if(S.depthTexture.format===Qs)de(S)?a.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,re,0,ce):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,re,0);else if(S.depthTexture.format===ar)de(S)?a.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,re,0,ce):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,re,0);else throw new Error("Unknown depthTexture format")}function Ze(R){const S=n.get(R),X=R.isWebGLCubeRenderTarget===!0;if(S.__boundDepthTexture!==R.depthTexture){const re=R.depthTexture;if(S.__depthDisposeCallback&&S.__depthDisposeCallback(),re){const ce=()=>{delete S.__boundDepthTexture,delete S.__depthDisposeCallback,re.removeEventListener("dispose",ce)};re.addEventListener("dispose",ce),S.__depthDisposeCallback=ce}S.__boundDepthTexture=re}if(R.depthTexture&&!S.__autoAllocateDepthBuffer){if(X)throw new Error("target.depthTexture not supported in Cube render targets");ge(S.__webglFramebuffer,R)}else if(X){S.__webglDepthbuffer=[];for(let re=0;re<6;re++)if(t.bindFramebuffer(s.FRAMEBUFFER,S.__webglFramebuffer[re]),S.__webglDepthbuffer[re]===void 0)S.__webglDepthbuffer[re]=s.createRenderbuffer(),Ae(S.__webglDepthbuffer[re],R,!1);else{const ce=R.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,se=S.__webglDepthbuffer[re];s.bindRenderbuffer(s.RENDERBUFFER,se),s.framebufferRenderbuffer(s.FRAMEBUFFER,ce,s.RENDERBUFFER,se)}}else if(t.bindFramebuffer(s.FRAMEBUFFER,S.__webglFramebuffer),S.__webglDepthbuffer===void 0)S.__webglDepthbuffer=s.createRenderbuffer(),Ae(S.__webglDepthbuffer,R,!1);else{const re=R.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,ce=S.__webglDepthbuffer;s.bindRenderbuffer(s.RENDERBUFFER,ce),s.framebufferRenderbuffer(s.FRAMEBUFFER,re,s.RENDERBUFFER,ce)}t.bindFramebuffer(s.FRAMEBUFFER,null)}function Xe(R,S,X){const re=n.get(R);S!==void 0&&ue(re.__webglFramebuffer,R,R.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),X!==void 0&&Ze(R)}function Je(R){const S=R.texture,X=n.get(R),re=n.get(S);R.addEventListener("dispose",T);const ce=R.textures,se=R.isWebGLCubeRenderTarget===!0,ke=ce.length>1;if(ke||(re.__webglTexture===void 0&&(re.__webglTexture=s.createTexture()),re.__version=S.version,o.memory.textures++),se){X.__webglFramebuffer=[];for(let be=0;be<6;be++)if(S.mipmaps&&S.mipmaps.length>0){X.__webglFramebuffer[be]=[];for(let De=0;De<S.mipmaps.length;De++)X.__webglFramebuffer[be][De]=s.createFramebuffer()}else X.__webglFramebuffer[be]=s.createFramebuffer()}else{if(S.mipmaps&&S.mipmaps.length>0){X.__webglFramebuffer=[];for(let be=0;be<S.mipmaps.length;be++)X.__webglFramebuffer[be]=s.createFramebuffer()}else X.__webglFramebuffer=s.createFramebuffer();if(ke)for(let be=0,De=ce.length;be<De;be++){const vt=n.get(ce[be]);vt.__webglTexture===void 0&&(vt.__webglTexture=s.createTexture(),o.memory.textures++)}if(R.samples>0&&de(R)===!1){X.__webglMultisampledFramebuffer=s.createFramebuffer(),X.__webglColorRenderbuffer=[],t.bindFramebuffer(s.FRAMEBUFFER,X.__webglMultisampledFramebuffer);for(let be=0;be<ce.length;be++){const De=ce[be];X.__webglColorRenderbuffer[be]=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,X.__webglColorRenderbuffer[be]);const vt=r.convert(De.format,De.colorSpace),me=r.convert(De.type),Ue=y(De.internalFormat,vt,me,De.colorSpace,R.isXRRenderTarget===!0),tt=ye(R);s.renderbufferStorageMultisample(s.RENDERBUFFER,tt,Ue,R.width,R.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+be,s.RENDERBUFFER,X.__webglColorRenderbuffer[be])}s.bindRenderbuffer(s.RENDERBUFFER,null),R.depthBuffer&&(X.__webglDepthRenderbuffer=s.createRenderbuffer(),Ae(X.__webglDepthRenderbuffer,R,!0)),t.bindFramebuffer(s.FRAMEBUFFER,null)}}if(se){t.bindTexture(s.TEXTURE_CUBE_MAP,re.__webglTexture),Ee(s.TEXTURE_CUBE_MAP,S);for(let be=0;be<6;be++)if(S.mipmaps&&S.mipmaps.length>0)for(let De=0;De<S.mipmaps.length;De++)ue(X.__webglFramebuffer[be][De],R,S,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+be,De);else ue(X.__webglFramebuffer[be],R,S,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+be,0);m(S)&&g(s.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(ke){for(let be=0,De=ce.length;be<De;be++){const vt=ce[be],me=n.get(vt);t.bindTexture(s.TEXTURE_2D,me.__webglTexture),Ee(s.TEXTURE_2D,vt),ue(X.__webglFramebuffer,R,vt,s.COLOR_ATTACHMENT0+be,s.TEXTURE_2D,0),m(vt)&&g(s.TEXTURE_2D)}t.unbindTexture()}else{let be=s.TEXTURE_2D;if((R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(be=R.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture(be,re.__webglTexture),Ee(be,S),S.mipmaps&&S.mipmaps.length>0)for(let De=0;De<S.mipmaps.length;De++)ue(X.__webglFramebuffer[De],R,S,s.COLOR_ATTACHMENT0,be,De);else ue(X.__webglFramebuffer,R,S,s.COLOR_ATTACHMENT0,be,0);m(S)&&g(be),t.unbindTexture()}R.depthBuffer&&Ze(R)}function dt(R){const S=R.textures;for(let X=0,re=S.length;X<re;X++){const ce=S[X];if(m(ce)){const se=R.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:s.TEXTURE_2D,ke=n.get(ce).__webglTexture;t.bindTexture(se,ke),g(se),t.unbindTexture()}}}const ae=[],P=[];function Me(R){if(R.samples>0){if(de(R)===!1){const S=R.textures,X=R.width,re=R.height;let ce=s.COLOR_BUFFER_BIT;const se=R.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,ke=n.get(R),be=S.length>1;if(be)for(let De=0;De<S.length;De++)t.bindFramebuffer(s.FRAMEBUFFER,ke.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+De,s.RENDERBUFFER,null),t.bindFramebuffer(s.FRAMEBUFFER,ke.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+De,s.TEXTURE_2D,null,0);t.bindFramebuffer(s.READ_FRAMEBUFFER,ke.__webglMultisampledFramebuffer),t.bindFramebuffer(s.DRAW_FRAMEBUFFER,ke.__webglFramebuffer);for(let De=0;De<S.length;De++){if(R.resolveDepthBuffer&&(R.depthBuffer&&(ce|=s.DEPTH_BUFFER_BIT),R.stencilBuffer&&R.resolveStencilBuffer&&(ce|=s.STENCIL_BUFFER_BIT)),be){s.framebufferRenderbuffer(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,ke.__webglColorRenderbuffer[De]);const vt=n.get(S[De]).__webglTexture;s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,vt,0)}s.blitFramebuffer(0,0,X,re,0,0,X,re,ce,s.NEAREST),c===!0&&(ae.length=0,P.length=0,ae.push(s.COLOR_ATTACHMENT0+De),R.depthBuffer&&R.resolveDepthBuffer===!1&&(ae.push(se),P.push(se),s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,P)),s.invalidateFramebuffer(s.READ_FRAMEBUFFER,ae))}if(t.bindFramebuffer(s.READ_FRAMEBUFFER,null),t.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),be)for(let De=0;De<S.length;De++){t.bindFramebuffer(s.FRAMEBUFFER,ke.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+De,s.RENDERBUFFER,ke.__webglColorRenderbuffer[De]);const vt=n.get(S[De]).__webglTexture;t.bindFramebuffer(s.FRAMEBUFFER,ke.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+De,s.TEXTURE_2D,vt,0)}t.bindFramebuffer(s.DRAW_FRAMEBUFFER,ke.__webglMultisampledFramebuffer)}else if(R.depthBuffer&&R.resolveDepthBuffer===!1&&c){const S=R.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,[S])}}}function ye(R){return Math.min(i.maxSamples,R.samples)}function de(R){const S=n.get(R);return R.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&S.__useRenderToTexture!==!1}function Te(R){const S=o.render.frame;u.get(R)!==S&&(u.set(R,S),R.update())}function qe(R,S){const X=R.colorSpace,re=R.format,ce=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||X!==li&&X!==Li&&(gt.getTransfer(X)===Vt?(re!==Rn||ce!==es)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",X)),S}function Ie(R){return typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement?(l.width=R.naturalWidth||R.width,l.height=R.naturalHeight||R.height):typeof VideoFrame<"u"&&R instanceof VideoFrame?(l.width=R.displayWidth,l.height=R.displayHeight):(l.width=R.width,l.height=R.height),l}this.allocateTextureUnit=G,this.resetTextureUnits=b,this.setTexture2D=$,this.setTexture2DArray=ie,this.setTexture3D=q,this.setTextureCube=he,this.rebindTextures=Xe,this.setupRenderTarget=Je,this.updateRenderTargetMipmap=dt,this.updateMultisampleRenderTarget=Me,this.setupDepthRenderbuffer=Ze,this.setupFrameBufferTexture=ue,this.useMultisampledRTT=de}function $y(s,e){function t(n,i=Li){let r;const o=gt.getTransfer(i);if(n===es)return s.UNSIGNED_BYTE;if(n===Lh)return s.UNSIGNED_SHORT_4_4_4_4;if(n===Dh)return s.UNSIGNED_SHORT_5_5_5_1;if(n===Uh)return s.UNSIGNED_INT_5_9_9_9_REV;if(n===Fh)return s.UNSIGNED_INT_10F_11F_11F_REV;if(n===zf)return s.BYTE;if(n===kf)return s.SHORT;if(n===ta)return s.UNSIGNED_SHORT;if(n===ma)return s.INT;if(n===Bi)return s.UNSIGNED_INT;if(n===Gn)return s.FLOAT;if(n===Ln)return s.HALF_FLOAT;if(n===Gf)return s.ALPHA;if(n===Oh)return s.RGB;if(n===Rn)return s.RGBA;if(n===Hf)return s.LUMINANCE;if(n===Wf)return s.LUMINANCE_ALPHA;if(n===Qs)return s.DEPTH_COMPONENT;if(n===ar)return s.DEPTH_STENCIL;if(n===Hc)return s.RED;if(n===Wc)return s.RED_INTEGER;if(n===na)return s.RG;if(n===Vh)return s.RG_INTEGER;if(n===Bh)return s.RGBA_INTEGER;if(n===$o||n===Yo||n===Zo||n===Jo)if(o===Vt)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===$o)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Yo)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Zo)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Jo)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===$o)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Yo)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Zo)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Jo)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===gc||n===Bu||n===xc||n===zu)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===gc)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Bu)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===xc)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===zu)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===_c||n===yc||n===vc)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===_c||n===yc)return o===Vt?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===vc)return o===Vt?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===Mc||n===ku||n===Gu||n===Hu||n===Sc||n===Wu||n===Xu||n===qu||n===$u||n===Yu||n===Zu||n===Ju||n===Ku||n===ju)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Mc)return o===Vt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===ku)return o===Vt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Gu)return o===Vt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Hu)return o===Vt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Sc)return o===Vt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Wu)return o===Vt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Xu)return o===Vt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===qu)return o===Vt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===$u)return o===Vt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Yu)return o===Vt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Zu)return o===Vt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Ju)return o===Vt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Ku)return o===Vt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===ju)return o===Vt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Ko||n===Qu||n===Tc)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===Ko)return o===Vt?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Qu)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Tc)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Xf||n===eh||n===th||n===nh)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===Ko)return r.COMPRESSED_RED_RGTC1_EXT;if(n===eh)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===th)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===nh)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===or?s.UNSIGNED_INT_24_8:s[n]!==void 0?s[n]:null}return{convert:t}}class rm extends hn{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Hr extends yt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const BR={type:"move"};class yp{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Hr,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 Hr,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new E,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new E),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Hr,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new E,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new E),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 n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let i=null,r=null,o=null;const a=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){o=!0;for(const x of e.hand.values()){const m=t.getJointPose(x,n),g=this._getHandJoint(l,x);m!==null&&(g.matrix.fromArray(m.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.matrixWorldNeedsUpdate=!0,g.jointRadius=m.radius),g.visible=m!==null}const u=l.joints["index-finger-tip"],h=l.joints["thumb-tip"],d=u.position.distanceTo(h.position),p=.02,f=.005;l.inputState.pinching&&d>p+f?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&d<=p-f&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1));a!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null&&(i=r),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(BR)))}return a!==null&&(a.visible=i!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Hr;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const zR=`
3824
3824
  void main() {
3825
3825
 
3826
3826
  gl_Position = vec4( position, 1.0 );
@@ -3844,7 +3844,7 @@ void main() {
3844
3844
 
3845
3845
  }
3846
3846
 
3847
- }`;class GR{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){const i=new Xt,r=e.properties.get(i);r.__webglTexture=t.texture,(t.depthNear!=n.depthNear||t.depthFar!=n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new ki({vertexShader:zR,fragmentShader:kR,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new kt(new so(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class HR extends Ai{constructor(e,t){super();const n=this;let i=null,r=1,o=null,a="local-floor",c=1,l=null,u=null,h=null,d=null,p=null,f=null;const x=new GR,m=t.getContextAttributes();let g=null,y=null;const _=[],v=[],I=new J;let T=null;const w=new hn;w.layers.enable(1),w.viewport=new st;const C=new hn;C.layers.enable(2),C.viewport=new st;const F=[w,C],M=new rm;M.layers.enable(1),M.layers.enable(2);let b=null,G=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.controllerAutoUpdate=!0,this.getController=function(ne){let ue=_[ne];return ue===void 0&&(ue=new yp,_[ne]=ue),ue.getTargetRaySpace()},this.getControllerGrip=function(ne){let ue=_[ne];return ue===void 0&&(ue=new yp,_[ne]=ue),ue.getGripSpace()},this.getHand=function(ne){let ue=_[ne];return ue===void 0&&(ue=new yp,_[ne]=ue),ue.getHandSpace()};function W(ne){const ue=v.indexOf(ne.inputSource);if(ue===-1)return;const Ae=_[ue];Ae!==void 0&&(Ae.update(ne.inputSource,ne.frame,l||o),Ae.dispatchEvent({type:ne.type,data:ne.inputSource}))}function $(){i.removeEventListener("select",W),i.removeEventListener("selectstart",W),i.removeEventListener("selectend",W),i.removeEventListener("squeeze",W),i.removeEventListener("squeezestart",W),i.removeEventListener("squeezeend",W),i.removeEventListener("end",$),i.removeEventListener("inputsourceschange",ie);for(let ne=0;ne<_.length;ne++){const ue=v[ne];ue!==null&&(v[ne]=null,_[ne]&&_[ne].disconnect(ue))}b=null,G=null,x.reset(),e.setRenderTarget(g),p=null,d=null,h=null,i=null,y=null,ht.stop(),n.isPresenting=!1,e.setPixelRatio(T),e.setSize(I.width,I.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ne){r=ne,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ne){a=ne,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(ne){l=ne},this.getBaseLayer=function(){return d!==null?d:p},this.getBinding=function(){return h},this.getFrame=function(){return f},this.getSession=function(){return i},this.setSession=async function(ne){if(i=ne,i!==null){if(g=e.getRenderTarget(),i.addEventListener("select",W),i.addEventListener("selectstart",W),i.addEventListener("selectend",W),i.addEventListener("squeeze",W),i.addEventListener("squeezestart",W),i.addEventListener("squeezeend",W),i.addEventListener("end",$),i.addEventListener("inputsourceschange",ie),m.xrCompatible!==!0&&await t.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(I),typeof XRWebGLBinding<"u"&&"createProjectionLayer"in XRWebGLBinding.prototype){let Ae=null,ge=null,Ze=null;m.depth&&(Ze=m.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,Ae=m.stencil?ar:Qs,ge=m.stencil?or:Bi);const Xe={colorFormat:t.RGBA8,depthFormat:Ze,scaleFactor:r};h=new XRWebGLBinding(i,t),d=h.createProjectionLayer(Xe),i.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),y=new zi(d.textureWidth,d.textureHeight,{format:Rn,type:es,depthTexture:new oo(d.textureWidth,d.textureHeight,ge,void 0,void 0,void 0,void 0,void 0,void 0,Ae),stencilBuffer:m.stencil,colorSpace:e.outputColorSpace,samples:m.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1})}else{const Ae={antialias:m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:r};p=new XRWebGLLayer(i,t,Ae),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),y=new zi(p.framebufferWidth,p.framebufferHeight,{format:Rn,type:es,colorSpace:e.outputColorSpace,stencilBuffer:m.stencil})}y.isXRRenderTarget=!0,this.setFoveation(c),l=null,o=await i.requestReferenceSpace(a),ht.setContext(i),ht.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return x.getDepthTexture()};function ie(ne){for(let ue=0;ue<ne.removed.length;ue++){const Ae=ne.removed[ue],ge=v.indexOf(Ae);ge>=0&&(v[ge]=null,_[ge]&&_[ge].disconnect(Ae))}for(let ue=0;ue<ne.added.length;ue++){const Ae=ne.added[ue];let ge=v.indexOf(Ae);if(ge===-1){for(let Xe=0;Xe<_.length;Xe++)if(Xe>=v.length){v.push(Ae),ge=Xe;break}else if(v[Xe]===null){v[Xe]=Ae,ge=Xe;break}if(ge===-1)break}const Ze=_[ge];Ze&&Ze.connect(Ae)}}const q=new E,he=new E;function Q(ne,ue,Ae){q.setFromMatrixPosition(ue.matrixWorld),he.setFromMatrixPosition(Ae.matrixWorld);const ge=q.distanceTo(he),Ze=ue.projectionMatrix.elements,Xe=Ae.projectionMatrix.elements,Je=Ze[14]/(Ze[10]-1),dt=Ze[14]/(Ze[10]+1),ae=(Ze[9]+1)/Ze[5],P=(Ze[9]-1)/Ze[5],Me=(Ze[8]-1)/Ze[0],ye=(Xe[8]+1)/Xe[0],de=Je*Me,Te=Je*ye,qe=ge/(-Me+ye),Ie=qe*-Me;if(ue.matrixWorld.decompose(ne.position,ne.quaternion,ne.scale),ne.translateX(Ie),ne.translateZ(qe),ne.matrixWorld.compose(ne.position,ne.quaternion,ne.scale),ne.matrixWorldInverse.copy(ne.matrixWorld).invert(),Ze[10]===-1)ne.projectionMatrix.copy(ue.projectionMatrix),ne.projectionMatrixInverse.copy(ue.projectionMatrixInverse);else{const R=Je+qe,S=dt+qe,X=de-Ie,re=Te+(ge-Ie),ce=ae*dt/S*R,se=P*dt/S*R;ne.projectionMatrix.makePerspective(X,re,ce,se,R,S),ne.projectionMatrixInverse.copy(ne.projectionMatrix).invert()}}function we(ne,ue){ue===null?ne.matrixWorld.copy(ne.matrix):ne.matrixWorld.multiplyMatrices(ue.matrixWorld,ne.matrix),ne.matrixWorldInverse.copy(ne.matrixWorld).invert()}this.updateCamera=function(ne){if(i===null)return;let ue=ne.near,Ae=ne.far;x.texture!==null&&(x.depthNear>0&&(ue=x.depthNear),x.depthFar>0&&(Ae=x.depthFar)),M.near=C.near=w.near=ue,M.far=C.far=w.far=Ae,(b!==M.near||G!==M.far)&&(i.updateRenderState({depthNear:M.near,depthFar:M.far}),b=M.near,G=M.far);const ge=ne.parent,Ze=M.cameras;we(M,ge);for(let Xe=0;Xe<Ze.length;Xe++)we(Ze[Xe],ge);Ze.length===2?Q(M,w,C):M.projectionMatrix.copy(w.projectionMatrix),Ne(ne,M,ge)};function Ne(ne,ue,Ae){Ae===null?ne.matrix.copy(ue.matrixWorld):(ne.matrix.copy(Ae.matrixWorld),ne.matrix.invert(),ne.matrix.multiply(ue.matrixWorld)),ne.matrix.decompose(ne.position,ne.quaternion,ne.scale),ne.updateMatrixWorld(!0),ne.projectionMatrix.copy(ue.projectionMatrix),ne.projectionMatrixInverse.copy(ue.projectionMatrixInverse),ne.isPerspectiveCamera&&(ne.fov=ra*2*Math.atan(1/ne.projectionMatrix.elements[5]),ne.zoom=1)}this.getCamera=function(){return M},this.getFoveation=function(){if(!(d===null&&p===null))return c},this.setFoveation=function(ne){c=ne,d!==null&&(d.fixedFoveation=ne),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=ne)},this.hasDepthSensing=function(){return x.texture!==null},this.getDepthSensingMesh=function(){return x.getMesh(M)};let Ee=null;function Qe(ne,ue){if(u=ue.getViewerPose(l||o),f=ue,u!==null){const Ae=u.views;p!==null&&(e.setRenderTargetFramebuffer(y,p.framebuffer),e.setRenderTarget(y));let ge=!1;Ae.length!==M.cameras.length&&(M.cameras.length=0,ge=!0);for(let Xe=0;Xe<Ae.length;Xe++){const Je=Ae[Xe];let dt=null;if(p!==null)dt=p.getViewport(Je);else{const P=h.getViewSubImage(d,Je);dt=P.viewport,Xe===0&&(e.setRenderTargetTextures(y,P.colorTexture,d.ignoreDepthValues?void 0:P.depthStencilTexture),e.setRenderTarget(y))}let ae=F[Xe];ae===void 0&&(ae=new hn,ae.layers.enable(Xe),ae.viewport=new st,F[Xe]=ae),ae.matrix.fromArray(Je.transform.matrix),ae.matrix.decompose(ae.position,ae.quaternion,ae.scale),ae.projectionMatrix.fromArray(Je.projectionMatrix),ae.projectionMatrixInverse.copy(ae.projectionMatrix).invert(),ae.viewport.set(dt.x,dt.y,dt.width,dt.height),Xe===0&&(M.matrix.copy(ae.matrix),M.matrix.decompose(M.position,M.quaternion,M.scale)),ge===!0&&M.cameras.push(ae)}const Ze=i.enabledFeatures;if(Ze&&Ze.includes("depth-sensing")){const Xe=h.getDepthInformation(Ae[0]);Xe&&Xe.isValid&&Xe.texture&&x.init(e,Xe,i.renderState)}}if(n.controllerAutoUpdate)for(let Ae=0;Ae<_.length;Ae++){const ge=v[Ae],Ze=_[Ae];ge!==null&&Ze!==void 0&&Ze.update(ge,ue,l||o)}Ee&&Ee(ne,ue),ue.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:ue}),f=null}const ht=new Gy;ht.setAnimationLoop(Qe),this.setAnimationLoop=function(ne){Ee=ne},this.dispose=function(){}}}const wr=new ui,WR=new Fe;function XR(s,e){function t(m,g){m.matrixAutoUpdate===!0&&m.updateMatrix(),g.value.copy(m.matrix)}function n(m,g){g.color.getRGB(m.fogColor.value,ky(s)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function i(m,g,y,_,v){g.isMeshBasicMaterial||g.isMeshLambertMaterial?r(m,g):g.isMeshToonMaterial?(r(m,g),h(m,g)):g.isMeshPhongMaterial?(r(m,g),u(m,g)):g.isMeshStandardMaterial?(r(m,g),d(m,g),g.isMeshPhysicalMaterial&&p(m,g,v)):g.isMeshMatcapMaterial?(r(m,g),f(m,g)):g.isMeshDepthMaterial?r(m,g):g.isMeshDistanceMaterial?(r(m,g),x(m,g)):g.isMeshNormalMaterial?r(m,g):g.isLineBasicMaterial?(o(m,g),g.isLineDashedMaterial&&a(m,g)):g.isPointsMaterial?c(m,g,y,_):g.isSpriteMaterial?l(m,g):g.isShadowMaterial?(m.color.value.copy(g.color),m.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function r(m,g){m.opacity.value=g.opacity,g.color&&m.diffuse.value.copy(g.color),g.emissive&&m.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(m.map.value=g.map,t(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.bumpMap&&(m.bumpMap.value=g.bumpMap,t(g.bumpMap,m.bumpMapTransform),m.bumpScale.value=g.bumpScale,g.side===ln&&(m.bumpScale.value*=-1)),g.normalMap&&(m.normalMap.value=g.normalMap,t(g.normalMap,m.normalMapTransform),m.normalScale.value.copy(g.normalScale),g.side===ln&&m.normalScale.value.negate()),g.displacementMap&&(m.displacementMap.value=g.displacementMap,t(g.displacementMap,m.displacementMapTransform),m.displacementScale.value=g.displacementScale,m.displacementBias.value=g.displacementBias),g.emissiveMap&&(m.emissiveMap.value=g.emissiveMap,t(g.emissiveMap,m.emissiveMapTransform)),g.specularMap&&(m.specularMap.value=g.specularMap,t(g.specularMap,m.specularMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);const y=e.get(g),_=y.envMap,v=y.envMapRotation;_&&(m.envMap.value=_,wr.copy(v),wr.x*=-1,wr.y*=-1,wr.z*=-1,_.isCubeTexture&&_.isRenderTargetTexture===!1&&(wr.y*=-1,wr.z*=-1),m.envMapRotation.value.setFromMatrix4(WR.makeRotationFromEuler(wr)),m.flipEnvMap.value=_.isCubeTexture&&_.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap&&(m.lightMap.value=g.lightMap,m.lightMapIntensity.value=g.lightMapIntensity,t(g.lightMap,m.lightMapTransform)),g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,m.aoMapTransform))}function o(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform))}function a(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function c(m,g,y,_){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*y,m.scale.value=_*.5,g.map&&(m.map.value=g.map,t(g.map,m.uvTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function l(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function u(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function h(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function d(m,g){m.metalness.value=g.metalness,g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,m.metalnessMapTransform)),m.roughness.value=g.roughness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,m.roughnessMapTransform)),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function p(m,g,y){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,m.sheenColorMapTransform)),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,m.sheenRoughnessMapTransform))),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,m.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(m.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===ln&&m.clearcoatNormalScale.value.negate())),g.dispersion>0&&(m.dispersion.value=g.dispersion),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,m.iridescenceMapTransform)),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=y.texture,m.transmissionSamplerSize.value.set(y.width,y.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,m.transmissionMapTransform)),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(m.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(m.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,m.specularColorMapTransform)),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,m.specularIntensityMapTransform))}function f(m,g){g.matcap&&(m.matcap.value=g.matcap)}function x(m,g){const y=e.get(g).light;m.referencePosition.value.setFromMatrixPosition(y.matrixWorld),m.nearDistance.value=y.shadow.camera.near,m.farDistance.value=y.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function qR(s,e,t,n){let i={},r={},o=[];const a=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function c(y,_){const v=_.program;n.uniformBlockBinding(y,v)}function l(y,_){let v=i[y.id];v===void 0&&(f(y),v=u(y),i[y.id]=v,y.addEventListener("dispose",m));const I=_.program;n.updateUBOMapping(y,I);const T=e.render.frame;r[y.id]!==T&&(d(y),r[y.id]=T)}function u(y){const _=h();y.__bindingPointIndex=_;const v=s.createBuffer(),I=y.__size,T=y.usage;return s.bindBuffer(s.UNIFORM_BUFFER,v),s.bufferData(s.UNIFORM_BUFFER,I,T),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,_,v),v}function h(){for(let y=0;y<a;y++)if(o.indexOf(y)===-1)return o.push(y),y;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(y){const _=i[y.id],v=y.uniforms,I=y.__cache;s.bindBuffer(s.UNIFORM_BUFFER,_);for(let T=0,w=v.length;T<w;T++){const C=Array.isArray(v[T])?v[T]:[v[T]];for(let F=0,M=C.length;F<M;F++){const b=C[F];if(p(b,T,F,I)===!0){const G=b.__offset,W=Array.isArray(b.value)?b.value:[b.value];let $=0;for(let ie=0;ie<W.length;ie++){const q=W[ie],he=x(q);typeof q=="number"||typeof q=="boolean"?(b.__data[0]=q,s.bufferSubData(s.UNIFORM_BUFFER,G+$,b.__data)):q.isMatrix3?(b.__data[0]=q.elements[0],b.__data[1]=q.elements[1],b.__data[2]=q.elements[2],b.__data[3]=0,b.__data[4]=q.elements[3],b.__data[5]=q.elements[4],b.__data[6]=q.elements[5],b.__data[7]=0,b.__data[8]=q.elements[6],b.__data[9]=q.elements[7],b.__data[10]=q.elements[8],b.__data[11]=0):(q.toArray(b.__data,$),$+=he.storage/Float32Array.BYTES_PER_ELEMENT)}s.bufferSubData(s.UNIFORM_BUFFER,G,b.__data)}}}s.bindBuffer(s.UNIFORM_BUFFER,null)}function p(y,_,v,I){const T=y.value,w=_+"_"+v;if(I[w]===void 0)return typeof T=="number"||typeof T=="boolean"?I[w]=T:I[w]=T.clone(),!0;{const C=I[w];if(typeof T=="number"||typeof T=="boolean"){if(C!==T)return I[w]=T,!0}else if(C.equals(T)===!1)return C.copy(T),!0}return!1}function f(y){const _=y.uniforms;let v=0;const I=16;for(let w=0,C=_.length;w<C;w++){const F=Array.isArray(_[w])?_[w]:[_[w]];for(let M=0,b=F.length;M<b;M++){const G=F[M],W=Array.isArray(G.value)?G.value:[G.value];for(let $=0,ie=W.length;$<ie;$++){const q=W[$],he=x(q),Q=v%I,we=Q%he.boundary,Ne=Q+we;v+=we,Ne!==0&&I-Ne<he.storage&&(v+=I-Ne),G.__data=new Float32Array(he.storage/Float32Array.BYTES_PER_ELEMENT),G.__offset=v,v+=he.storage}}}const T=v%I;return T>0&&(v+=I-T),y.__size=v,y.__cache={},this}function x(y){const _={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(_.boundary=4,_.storage=4):y.isVector2?(_.boundary=8,_.storage=8):y.isVector3||y.isColor?(_.boundary=16,_.storage=12):y.isVector4?(_.boundary=16,_.storage=16):y.isMatrix3?(_.boundary=48,_.storage=48):y.isMatrix4?(_.boundary=64,_.storage=64):y.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",y),_}function m(y){const _=y.target;_.removeEventListener("dispose",m);const v=o.indexOf(_.__bindingPointIndex);o.splice(v,1),s.deleteBuffer(i[_.id]),delete i[_.id],delete r[_.id]}function g(){for(const y in i)s.deleteBuffer(i[y]);o=[],i={},r={}}return{bind:c,update:l,dispose:g}}class Yy{constructor(e={}){const{canvas:t=Fy(),context:n=null,depth:i=!0,stencil:r=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1}=e;this.isWebGLRenderer=!0;let d;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");d=n.getContextAttributes().alpha}else d=o;const p=new Uint32Array(4),f=new Int32Array(4);let x=null,m=null;const g=[],y=[];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._outputColorSpace=kn,this.toneMapping=Ti,this.toneMappingExposure=1;const _=this;let v=!1,I=0,T=0,w=null,C=-1,F=null;const M=new st,b=new st;let G=null;const W=new _e(0);let $=0,ie=t.width,q=t.height,he=1,Q=null,we=null;const Ne=new st(0,0,ie,q),Ee=new st(0,0,ie,q);let Qe=!1;const ht=new ga;let ne=!1,ue=!1;const Ae=new Fe,ge=new Fe,Ze=new E,Xe=new st,Je={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let dt=!1;function ae(){return w===null?he:1}let P=n;function Me(N,B){return t.getContext(N,B)}try{const N={alpha:!0,depth:i,stencil:r,antialias:a,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Ks}`),t.addEventListener("webglcontextlost",le,!1),t.addEventListener("webglcontextrestored",Ce,!1),t.addEventListener("webglcontextcreationerror",Le,!1),P===null){const B="webgl2";if(P=Me(B,N),P===null)throw Me(B)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(N){throw console.error("THREE.WebGLRenderer: "+N.message),N}let ye,de,Te,qe,Ie,R,S,X,re,ce,se,ke,be,De,vt,me,Ue,tt,nt,Be,Mt,ct,Ot,O;function Pe(){ye=new jE(P),ye.init(),ct=new $y(P,ye),de=new $E(P,ye,e,ct),Te=new PR(P),de.reverseDepthBuffer&&Te.buffers.depth.setReversed(!0),qe=new tC(P),Ie=new yR,R=new VR(P,ye,Te,Ie,de,ct,qe),S=new ZE(_),X=new KE(_),re=new l1(P),Ot=new XE(P,re),ce=new QE(P,re,qe,Ot),se=new iC(P,ce,re,qe),nt=new nC(P,de,R),me=new YE(Ie),ke=new _R(_,S,X,ye,de,Ot,me),be=new XR(_,Ie),De=new MR,vt=new NR(ye),tt=new WE(_,S,X,Te,se,d,c),Ue=new RR(_,se,de),O=new qR(P,qe,de,Te),Be=new qE(P,ye,qe),Mt=new eC(P,ye,qe),qe.programs=ke.programs,_.capabilities=de,_.extensions=ye,_.properties=Ie,_.renderLists=De,_.shadowMap=Ue,_.state=Te,_.info=qe}Pe();const ee=new HR(_,P);this.xr=ee,this.getContext=function(){return P},this.getContextAttributes=function(){return P.getContextAttributes()},this.forceContextLoss=function(){const N=ye.get("WEBGL_lose_context");N&&N.loseContext()},this.forceContextRestore=function(){const N=ye.get("WEBGL_lose_context");N&&N.restoreContext()},this.getPixelRatio=function(){return he},this.setPixelRatio=function(N){N!==void 0&&(he=N,this.setSize(ie,q,!1))},this.getSize=function(N){return N.set(ie,q)},this.setSize=function(N,B,Y=!0){if(ee.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}ie=N,q=B,t.width=Math.floor(N*he),t.height=Math.floor(B*he),Y===!0&&(t.style.width=N+"px",t.style.height=B+"px"),this.setViewport(0,0,N,B)},this.getDrawingBufferSize=function(N){return N.set(ie*he,q*he).floor()},this.setDrawingBufferSize=function(N,B,Y){ie=N,q=B,he=Y,t.width=Math.floor(N*Y),t.height=Math.floor(B*Y),this.setViewport(0,0,N,B)},this.getCurrentViewport=function(N){return N.copy(M)},this.getViewport=function(N){return N.copy(Ne)},this.setViewport=function(N,B,Y,Z){N.isVector4?Ne.set(N.x,N.y,N.z,N.w):Ne.set(N,B,Y,Z),Te.viewport(M.copy(Ne).multiplyScalar(he).round())},this.getScissor=function(N){return N.copy(Ee)},this.setScissor=function(N,B,Y,Z){N.isVector4?Ee.set(N.x,N.y,N.z,N.w):Ee.set(N,B,Y,Z),Te.scissor(b.copy(Ee).multiplyScalar(he).round())},this.getScissorTest=function(){return Qe},this.setScissorTest=function(N){Te.setScissorTest(Qe=N)},this.setOpaqueSort=function(N){Q=N},this.setTransparentSort=function(N){we=N},this.getClearColor=function(N){return N.copy(tt.getClearColor())},this.setClearColor=function(){tt.setClearColor.apply(tt,arguments)},this.getClearAlpha=function(){return tt.getClearAlpha()},this.setClearAlpha=function(){tt.setClearAlpha.apply(tt,arguments)},this.clear=function(N=!0,B=!0,Y=!0){let Z=0;if(N){let k=!1;if(w!==null){const xe=w.texture.format;k=xe===Bh||xe===Vh||xe===Wc}if(k){const xe=w.texture.type,Re=xe===es||xe===Bi||xe===ta||xe===or||xe===Lh||xe===Dh,ze=tt.getClearColor(),Ge=tt.getClearAlpha(),je=ze.r,et=ze.g,He=ze.b;Re?(p[0]=je,p[1]=et,p[2]=He,p[3]=Ge,P.clearBufferuiv(P.COLOR,0,p)):(f[0]=je,f[1]=et,f[2]=He,f[3]=Ge,P.clearBufferiv(P.COLOR,0,f))}else Z|=P.COLOR_BUFFER_BIT}B&&(Z|=P.DEPTH_BUFFER_BIT,P.clearDepth(this.capabilities.reverseDepthBuffer?0:1)),Y&&(Z|=P.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),P.clear(Z)},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",le,!1),t.removeEventListener("webglcontextrestored",Ce,!1),t.removeEventListener("webglcontextcreationerror",Le,!1),De.dispose(),vt.dispose(),Ie.dispose(),S.dispose(),X.dispose(),se.dispose(),Ot.dispose(),O.dispose(),ke.dispose(),ee.dispose(),ee.removeEventListener("sessionstart",u0),ee.removeEventListener("sessionend",h0),yr.stop()};function le(N){N.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),v=!0}function Ce(){console.log("THREE.WebGLRenderer: Context Restored."),v=!1;const N=qe.autoReset,B=Ue.enabled,Y=Ue.autoUpdate,Z=Ue.needsUpdate,k=Ue.type;Pe(),qe.autoReset=N,Ue.enabled=B,Ue.autoUpdate=Y,Ue.needsUpdate=Z,Ue.type=k}function Le(N){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",N.statusMessage)}function bt(N){const B=N.target;B.removeEventListener("dispose",bt),on(B)}function on(N){ni(N),Ie.remove(N)}function ni(N){const B=Ie.get(N).programs;B!==void 0&&(B.forEach(function(Y){ke.releaseProgram(Y)}),N.isShaderMaterial&&ke.releaseShaderCache(N))}this.renderBufferDirect=function(N,B,Y,Z,k,xe){B===null&&(B=Je);const Re=k.isMesh&&k.matrixWorld.determinant()<0,ze=Kw(N,B,Y,Z,k);Te.setMaterial(Z,Re);let Ge=Y.index,je=1;if(Z.wireframe===!0){if(Ge=ce.getWireframeAttribute(Y),Ge===void 0)return;je=2}const et=Y.drawRange,He=Y.attributes.position;let Lt=et.start*je,Gt=(et.start+et.count)*je;xe!==null&&(Lt=Math.max(Lt,xe.start*je),Gt=Math.min(Gt,(xe.start+xe.count)*je)),Ge!==null?(Lt=Math.max(Lt,0),Gt=Math.min(Gt,Ge.count)):He!=null&&(Lt=Math.max(Lt,0),Gt=Math.min(Gt,He.count));const Jt=Gt-Lt;if(Jt<0||Jt===1/0)return;Ot.setup(k,Z,ze,Y,Ge);let fi,Rt=Be;if(Ge!==null&&(fi=re.get(Ge),Rt=Mt,Rt.setIndex(fi)),k.isMesh)Z.wireframe===!0?(Te.setLineWidth(Z.wireframeLinewidth*ae()),Rt.setMode(P.LINES)):Rt.setMode(P.TRIANGLES);else if(k.isLine){let $e=Z.linewidth;$e===void 0&&($e=1),Te.setLineWidth($e*ae()),k.isLineSegments?Rt.setMode(P.LINES):k.isLineLoop?Rt.setMode(P.LINE_LOOP):Rt.setMode(P.LINE_STRIP)}else k.isPoints?Rt.setMode(P.POINTS):k.isSprite&&Rt.setMode(P.TRIANGLES);if(k.isBatchedMesh)if(k._multiDrawInstances!==null)Rt.renderMultiDrawInstances(k._multiDrawStarts,k._multiDrawCounts,k._multiDrawCount,k._multiDrawInstances);else if(ye.get("WEBGL_multi_draw"))Rt.renderMultiDraw(k._multiDrawStarts,k._multiDrawCounts,k._multiDrawCount);else{const $e=k._multiDrawStarts,An=k._multiDrawCounts,It=k._multiDrawCount,Xi=Ge?re.get(Ge).bytesPerElement:1,fo=Ie.get(Z).currentProgram.getUniforms();for(let mi=0;mi<It;mi++)fo.setValue(P,"_gl_DrawID",mi),Rt.render($e[mi]/Xi,An[mi])}else if(k.isInstancedMesh)Rt.renderInstances(Lt,Jt,k.count);else if(Y.isInstancedBufferGeometry){const $e=Y._maxInstanceCount!==void 0?Y._maxInstanceCount:1/0,An=Math.min(Y.instanceCount,$e);Rt.renderInstances(Lt,Jt,An)}else Rt.render(Lt,Jt)};function Et(N,B,Y){N.transparent===!0&&N.side===Ji&&N.forceSinglePass===!1?(N.side=ln,N.needsUpdate=!0,bl(N,B,Y),N.side=fs,N.needsUpdate=!0,bl(N,B,Y),N.side=Ji):bl(N,B,Y)}this.compile=function(N,B,Y=null){Y===null&&(Y=N),m=vt.get(Y),m.init(B),y.push(m),Y.traverseVisible(function(k){k.isLight&&k.layers.test(B.layers)&&(m.pushLight(k),k.castShadow&&m.pushShadow(k))}),N!==Y&&N.traverseVisible(function(k){k.isLight&&k.layers.test(B.layers)&&(m.pushLight(k),k.castShadow&&m.pushShadow(k))}),m.setupLights();const Z=new Set;return N.traverse(function(k){if(!(k.isMesh||k.isPoints||k.isLine||k.isSprite))return;const xe=k.material;if(xe)if(Array.isArray(xe))for(let Re=0;Re<xe.length;Re++){const ze=xe[Re];Et(ze,Y,k),Z.add(ze)}else Et(xe,Y,k),Z.add(xe)}),y.pop(),m=null,Z},this.compileAsync=function(N,B,Y=null){const Z=this.compile(N,B,Y);return new Promise(k=>{function xe(){if(Z.forEach(function(Re){Ie.get(Re).currentProgram.isReady()&&Z.delete(Re)}),Z.size===0){k(N);return}setTimeout(xe,10)}ye.get("KHR_parallel_shader_compile")!==null?xe():setTimeout(xe,10)})};let ii=null;function vs(N){ii&&ii(N)}function u0(){yr.stop()}function h0(){yr.start()}const yr=new Gy;yr.setAnimationLoop(vs),typeof self<"u"&&yr.setContext(self),this.setAnimationLoop=function(N){ii=N,ee.setAnimationLoop(N),N===null?yr.stop():yr.start()},ee.addEventListener("sessionstart",u0),ee.addEventListener("sessionend",h0),this.render=function(N,B){if(B!==void 0&&B.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(v===!0)return;if(N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),B.parent===null&&B.matrixWorldAutoUpdate===!0&&B.updateMatrixWorld(),ee.enabled===!0&&ee.isPresenting===!0&&(ee.cameraAutoUpdate===!0&&ee.updateCamera(B),B=ee.getCamera()),N.isScene===!0&&N.onBeforeRender(_,N,B,w),m=vt.get(N,y.length),m.init(B),y.push(m),ge.multiplyMatrices(B.projectionMatrix,B.matrixWorldInverse),ht.setFromProjectionMatrix(ge),ue=this.localClippingEnabled,ne=me.init(this.clippingPlanes,ue),x=De.get(N,g.length),x.init(),g.push(x),ee.enabled===!0&&ee.isPresenting===!0){const xe=_.xr.getDepthSensingMesh();xe!==null&&Gd(xe,B,-1/0,_.sortObjects)}Gd(N,B,0,_.sortObjects),x.finish(),_.sortObjects===!0&&x.sort(Q,we),dt=ee.enabled===!1||ee.isPresenting===!1||ee.hasDepthSensing()===!1,dt&&tt.addToRenderList(x,N),this.info.render.frame++,ne===!0&&me.beginShadows();const Y=m.state.shadowsArray;Ue.render(Y,N,B),ne===!0&&me.endShadows(),this.info.autoReset===!0&&this.info.reset();const Z=x.opaque,k=x.transmissive;if(m.setupLights(),B.isArrayCamera){const xe=B.cameras;if(k.length>0)for(let Re=0,ze=xe.length;Re<ze;Re++){const Ge=xe[Re];p0(Z,k,N,Ge)}dt&&tt.render(N);for(let Re=0,ze=xe.length;Re<ze;Re++){const Ge=xe[Re];d0(x,N,Ge,Ge.viewport)}}else k.length>0&&p0(Z,k,N,B),dt&&tt.render(N),d0(x,N,B);w!==null&&(R.updateMultisampleRenderTarget(w),R.updateRenderTargetMipmap(w)),N.isScene===!0&&N.onAfterRender(_,N,B),Ot.resetDefaultState(),C=-1,F=null,y.pop(),y.length>0?(m=y[y.length-1],ne===!0&&me.setGlobalState(_.clippingPlanes,m.state.camera)):m=null,g.pop(),g.length>0?x=g[g.length-1]:x=null};function Gd(N,B,Y,Z){if(N.visible===!1)return;if(N.layers.test(B.layers)){if(N.isGroup)Y=N.renderOrder;else if(N.isLOD)N.autoUpdate===!0&&N.update(B);else if(N.isLight)m.pushLight(N),N.castShadow&&m.pushShadow(N);else if(N.isSprite){if(!N.frustumCulled||ht.intersectsSprite(N)){Z&&Xe.setFromMatrixPosition(N.matrixWorld).applyMatrix4(ge);const Re=se.update(N),ze=N.material;ze.visible&&x.push(N,Re,ze,Y,Xe.z,null)}}else if((N.isMesh||N.isLine||N.isPoints)&&(!N.frustumCulled||ht.intersectsObject(N))){const Re=se.update(N),ze=N.material;if(Z&&(N.boundingSphere!==void 0?(N.boundingSphere===null&&N.computeBoundingSphere(),Xe.copy(N.boundingSphere.center)):(Re.boundingSphere===null&&Re.computeBoundingSphere(),Xe.copy(Re.boundingSphere.center)),Xe.applyMatrix4(N.matrixWorld).applyMatrix4(ge)),Array.isArray(ze)){const Ge=Re.groups;for(let je=0,et=Ge.length;je<et;je++){const He=Ge[je],Lt=ze[He.materialIndex];Lt&&Lt.visible&&x.push(N,Re,Lt,Y,Xe.z,He)}}else ze.visible&&x.push(N,Re,ze,Y,Xe.z,null)}}const xe=N.children;for(let Re=0,ze=xe.length;Re<ze;Re++)Gd(xe[Re],B,Y,Z)}function d0(N,B,Y,Z){const k=N.opaque,xe=N.transmissive,Re=N.transparent;m.setupLightsView(Y),ne===!0&&me.setGlobalState(_.clippingPlanes,Y),Z&&Te.viewport(M.copy(Z)),k.length>0&&Tl(k,B,Y),xe.length>0&&Tl(xe,B,Y),Re.length>0&&Tl(Re,B,Y),Te.buffers.depth.setTest(!0),Te.buffers.depth.setMask(!0),Te.buffers.color.setMask(!0),Te.setPolygonOffset(!1)}function p0(N,B,Y,Z){if((Y.isScene===!0?Y.overrideMaterial:null)!==null)return;m.state.transmissionRenderTarget[Z.id]===void 0&&(m.state.transmissionRenderTarget[Z.id]=new zi(1,1,{generateMipmaps:!0,type:ye.has("EXT_color_buffer_half_float")||ye.has("EXT_color_buffer_float")?Ln:es,minFilter:Jn,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:gt.workingColorSpace}));const xe=m.state.transmissionRenderTarget[Z.id],Re=Z.viewport||M;xe.setSize(Re.z,Re.w);const ze=_.getRenderTarget();_.setRenderTarget(xe),_.getClearColor(W),$=_.getClearAlpha(),$<1&&_.setClearColor(16777215,.5),_.clear(),dt&&tt.render(Y);const Ge=_.toneMapping;_.toneMapping=Ti;const je=Z.viewport;if(Z.viewport!==void 0&&(Z.viewport=void 0),m.setupLightsView(Z),ne===!0&&me.setGlobalState(_.clippingPlanes,Z),Tl(N,Y,Z),R.updateMultisampleRenderTarget(xe),R.updateRenderTargetMipmap(xe),ye.has("WEBGL_multisampled_render_to_texture")===!1){let et=!1;for(let He=0,Lt=B.length;He<Lt;He++){const Gt=B[He],Jt=Gt.object,fi=Gt.geometry,Rt=Gt.material,$e=Gt.group;if(Rt.side===Ji&&Jt.layers.test(Z.layers)){const An=Rt.side;Rt.side=ln,Rt.needsUpdate=!0,f0(Jt,Y,Z,fi,Rt,$e),Rt.side=An,Rt.needsUpdate=!0,et=!0}}et===!0&&(R.updateMultisampleRenderTarget(xe),R.updateRenderTargetMipmap(xe))}_.setRenderTarget(ze),_.setClearColor(W,$),je!==void 0&&(Z.viewport=je),_.toneMapping=Ge}function Tl(N,B,Y){const Z=B.isScene===!0?B.overrideMaterial:null;for(let k=0,xe=N.length;k<xe;k++){const Re=N[k],ze=Re.object,Ge=Re.geometry,je=Z===null?Re.material:Z,et=Re.group;ze.layers.test(Y.layers)&&f0(ze,B,Y,Ge,je,et)}}function f0(N,B,Y,Z,k,xe){N.onBeforeRender(_,B,Y,Z,k,xe),N.modelViewMatrix.multiplyMatrices(Y.matrixWorldInverse,N.matrixWorld),N.normalMatrix.getNormalMatrix(N.modelViewMatrix),k.onBeforeRender(_,B,Y,Z,N,xe),k.transparent===!0&&k.side===Ji&&k.forceSinglePass===!1?(k.side=ln,k.needsUpdate=!0,_.renderBufferDirect(Y,B,Z,k,N,xe),k.side=fs,k.needsUpdate=!0,_.renderBufferDirect(Y,B,Z,k,N,xe),k.side=Ji):_.renderBufferDirect(Y,B,Z,k,N,xe),N.onAfterRender(_,B,Y,Z,k,xe)}function bl(N,B,Y){B.isScene!==!0&&(B=Je);const Z=Ie.get(N),k=m.state.lights,xe=m.state.shadowsArray,Re=k.state.version,ze=ke.getParameters(N,k.state,xe,B,Y),Ge=ke.getProgramCacheKey(ze);let je=Z.programs;Z.environment=N.isMeshStandardMaterial?B.environment:null,Z.fog=B.fog,Z.envMap=(N.isMeshStandardMaterial?X:S).get(N.envMap||Z.environment),Z.envMapRotation=Z.environment!==null&&N.envMap===null?B.environmentRotation:N.envMapRotation,je===void 0&&(N.addEventListener("dispose",bt),je=new Map,Z.programs=je);let et=je.get(Ge);if(et!==void 0){if(Z.currentProgram===et&&Z.lightsStateVersion===Re)return g0(N,ze),et}else ze.uniforms=ke.getUniforms(N),N.onBuild(Y,ze,_),N.onBeforeCompile(ze,_),et=ke.acquireProgram(ze,Ge),je.set(Ge,et),Z.uniforms=ze.uniforms;const He=Z.uniforms;return(!N.isShaderMaterial&&!N.isRawShaderMaterial||N.clipping===!0)&&(He.clippingPlanes=me.uniform),g0(N,ze),Z.needsLights=Qw(N),Z.lightsStateVersion=Re,Z.needsLights&&(He.ambientLightColor.value=k.state.ambient,He.lightProbe.value=k.state.probe,He.directionalLights.value=k.state.directional,He.directionalLightShadows.value=k.state.directionalShadow,He.spotLights.value=k.state.spot,He.spotLightShadows.value=k.state.spotShadow,He.rectAreaLights.value=k.state.rectArea,He.ltc_1.value=k.state.rectAreaLTC1,He.ltc_2.value=k.state.rectAreaLTC2,He.pointLights.value=k.state.point,He.pointLightShadows.value=k.state.pointShadow,He.hemisphereLights.value=k.state.hemi,He.directionalShadowMap.value=k.state.directionalShadowMap,He.directionalShadowMatrix.value=k.state.directionalShadowMatrix,He.spotShadowMap.value=k.state.spotShadowMap,He.spotLightMatrix.value=k.state.spotLightMatrix,He.spotLightMap.value=k.state.spotLightMap,He.pointShadowMap.value=k.state.pointShadowMap,He.pointShadowMatrix.value=k.state.pointShadowMatrix),Z.currentProgram=et,Z.uniformsList=null,et}function m0(N){if(N.uniformsList===null){const B=N.currentProgram.getUniforms();N.uniformsList=Ru.seqWithValue(B.seq,N.uniforms)}return N.uniformsList}function g0(N,B){const Y=Ie.get(N);Y.outputColorSpace=B.outputColorSpace,Y.batching=B.batching,Y.batchingColor=B.batchingColor,Y.instancing=B.instancing,Y.instancingColor=B.instancingColor,Y.instancingMorph=B.instancingMorph,Y.skinning=B.skinning,Y.morphTargets=B.morphTargets,Y.morphNormals=B.morphNormals,Y.morphColors=B.morphColors,Y.morphTargetsCount=B.morphTargetsCount,Y.numClippingPlanes=B.numClippingPlanes,Y.numIntersection=B.numClipIntersection,Y.vertexAlphas=B.vertexAlphas,Y.vertexTangents=B.vertexTangents,Y.toneMapping=B.toneMapping}function Kw(N,B,Y,Z,k){B.isScene!==!0&&(B=Je),R.resetTextureUnits();const xe=B.fog,Re=Z.isMeshStandardMaterial?B.environment:null,ze=w===null?_.outputColorSpace:w.isXRRenderTarget===!0?w.texture.colorSpace:li,Ge=(Z.isMeshStandardMaterial?X:S).get(Z.envMap||Re),je=Z.vertexColors===!0&&!!Y.attributes.color&&Y.attributes.color.itemSize===4,et=!!Y.attributes.tangent&&(!!Z.normalMap||Z.anisotropy>0),He=!!Y.morphAttributes.position,Lt=!!Y.morphAttributes.normal,Gt=!!Y.morphAttributes.color;let Jt=Ti;Z.toneMapped&&(w===null||w.isXRRenderTarget===!0)&&(Jt=_.toneMapping);const fi=Y.morphAttributes.position||Y.morphAttributes.normal||Y.morphAttributes.color,Rt=fi!==void 0?fi.length:0,$e=Ie.get(Z),An=m.state.lights;if(ne===!0&&(ue===!0||N!==F)){const Ni=N===F&&Z.id===C;me.setState(Z,N,Ni)}let It=!1;Z.version===$e.__version?($e.needsLights&&$e.lightsStateVersion!==An.state.version||$e.outputColorSpace!==ze||k.isBatchedMesh&&$e.batching===!1||!k.isBatchedMesh&&$e.batching===!0||k.isBatchedMesh&&$e.batchingColor===!0&&k.colorTexture===null||k.isBatchedMesh&&$e.batchingColor===!1&&k.colorTexture!==null||k.isInstancedMesh&&$e.instancing===!1||!k.isInstancedMesh&&$e.instancing===!0||k.isSkinnedMesh&&$e.skinning===!1||!k.isSkinnedMesh&&$e.skinning===!0||k.isInstancedMesh&&$e.instancingColor===!0&&k.instanceColor===null||k.isInstancedMesh&&$e.instancingColor===!1&&k.instanceColor!==null||k.isInstancedMesh&&$e.instancingMorph===!0&&k.morphTexture===null||k.isInstancedMesh&&$e.instancingMorph===!1&&k.morphTexture!==null||$e.envMap!==Ge||Z.fog===!0&&$e.fog!==xe||$e.numClippingPlanes!==void 0&&($e.numClippingPlanes!==me.numPlanes||$e.numIntersection!==me.numIntersection)||$e.vertexAlphas!==je||$e.vertexTangents!==et||$e.morphTargets!==He||$e.morphNormals!==Lt||$e.morphColors!==Gt||$e.toneMapping!==Jt||$e.morphTargetsCount!==Rt)&&(It=!0):(It=!0,$e.__version=Z.version);let Xi=$e.currentProgram;It===!0&&(Xi=bl(Z,B,k));let fo=!1,mi=!1,Hd=!1;const tn=Xi.getUniforms(),Vs=$e.uniforms;if(Te.useProgram(Xi.program)&&(fo=!0,mi=!0,Hd=!0),Z.id!==C&&(C=Z.id,mi=!0),fo||F!==N){de.reverseDepthBuffer?(Ae.copy(N.projectionMatrix),UA(Ae),FA(Ae),tn.setValue(P,"projectionMatrix",Ae)):tn.setValue(P,"projectionMatrix",N.projectionMatrix),tn.setValue(P,"viewMatrix",N.matrixWorldInverse);const Ni=tn.map.cameraPosition;Ni!==void 0&&Ni.setValue(P,Ze.setFromMatrixPosition(N.matrixWorld)),de.logarithmicDepthBuffer&&tn.setValue(P,"logDepthBufFC",2/(Math.log(N.far+1)/Math.LN2)),(Z.isMeshPhongMaterial||Z.isMeshToonMaterial||Z.isMeshLambertMaterial||Z.isMeshBasicMaterial||Z.isMeshStandardMaterial||Z.isShaderMaterial)&&tn.setValue(P,"isOrthographic",N.isOrthographicCamera===!0),F!==N&&(F=N,mi=!0,Hd=!0)}if(k.isSkinnedMesh){tn.setOptional(P,k,"bindMatrix"),tn.setOptional(P,k,"bindMatrixInverse");const Ni=k.skeleton;Ni&&(Ni.boneTexture===null&&Ni.computeBoneTexture(),tn.setValue(P,"boneTexture",Ni.boneTexture,R))}k.isBatchedMesh&&(tn.setOptional(P,k,"batchingTexture"),tn.setValue(P,"batchingTexture",k._matricesTexture,R),tn.setOptional(P,k,"batchingIdTexture"),tn.setValue(P,"batchingIdTexture",k._indirectTexture,R),tn.setOptional(P,k,"batchingColorTexture"),k._colorsTexture!==null&&tn.setValue(P,"batchingColorTexture",k._colorsTexture,R));const Wd=Y.morphAttributes;if((Wd.position!==void 0||Wd.normal!==void 0||Wd.color!==void 0)&&nt.update(k,Y,Xi),(mi||$e.receiveShadow!==k.receiveShadow)&&($e.receiveShadow=k.receiveShadow,tn.setValue(P,"receiveShadow",k.receiveShadow)),Z.isMeshGouraudMaterial&&Z.envMap!==null&&(Vs.envMap.value=Ge,Vs.flipEnvMap.value=Ge.isCubeTexture&&Ge.isRenderTargetTexture===!1?-1:1),Z.isMeshStandardMaterial&&Z.envMap===null&&B.environment!==null&&(Vs.envMapIntensity.value=B.environmentIntensity),mi&&(tn.setValue(P,"toneMappingExposure",_.toneMappingExposure),$e.needsLights&&jw(Vs,Hd),xe&&Z.fog===!0&&be.refreshFogUniforms(Vs,xe),be.refreshMaterialUniforms(Vs,Z,he,q,m.state.transmissionRenderTarget[N.id]),Ru.upload(P,m0($e),Vs,R)),Z.isShaderMaterial&&Z.uniformsNeedUpdate===!0&&(Ru.upload(P,m0($e),Vs,R),Z.uniformsNeedUpdate=!1),Z.isSpriteMaterial&&tn.setValue(P,"center",k.center),tn.setValue(P,"modelViewMatrix",k.modelViewMatrix),tn.setValue(P,"normalMatrix",k.normalMatrix),tn.setValue(P,"modelMatrix",k.matrixWorld),Z.isShaderMaterial||Z.isRawShaderMaterial){const Ni=Z.uniformsGroups;for(let Xd=0,eA=Ni.length;Xd<eA;Xd++){const x0=Ni[Xd];O.update(x0,Xi),O.bind(x0,Xi)}}return Xi}function jw(N,B){N.ambientLightColor.needsUpdate=B,N.lightProbe.needsUpdate=B,N.directionalLights.needsUpdate=B,N.directionalLightShadows.needsUpdate=B,N.pointLights.needsUpdate=B,N.pointLightShadows.needsUpdate=B,N.spotLights.needsUpdate=B,N.spotLightShadows.needsUpdate=B,N.rectAreaLights.needsUpdate=B,N.hemisphereLights.needsUpdate=B}function Qw(N){return N.isMeshLambertMaterial||N.isMeshToonMaterial||N.isMeshPhongMaterial||N.isMeshStandardMaterial||N.isShadowMaterial||N.isShaderMaterial&&N.lights===!0}this.getActiveCubeFace=function(){return I},this.getActiveMipmapLevel=function(){return T},this.getRenderTarget=function(){return w},this.setRenderTargetTextures=function(N,B,Y){Ie.get(N.texture).__webglTexture=B,Ie.get(N.depthTexture).__webglTexture=Y;const Z=Ie.get(N);Z.__hasExternalTextures=!0,Z.__autoAllocateDepthBuffer=Y===void 0,Z.__autoAllocateDepthBuffer||ye.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),Z.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(N,B){const Y=Ie.get(N);Y.__webglFramebuffer=B,Y.__useDefaultFramebuffer=B===void 0},this.setRenderTarget=function(N,B=0,Y=0){w=N,I=B,T=Y;let Z=!0,k=null,xe=!1,Re=!1;if(N){const Ge=Ie.get(N);if(Ge.__useDefaultFramebuffer!==void 0)Te.bindFramebuffer(P.FRAMEBUFFER,null),Z=!1;else if(Ge.__webglFramebuffer===void 0)R.setupRenderTarget(N);else if(Ge.__hasExternalTextures)R.rebindTextures(N,Ie.get(N.texture).__webglTexture,Ie.get(N.depthTexture).__webglTexture);else if(N.depthBuffer){const He=N.depthTexture;if(Ge.__boundDepthTexture!==He){if(He!==null&&Ie.has(He)&&(N.width!==He.image.width||N.height!==He.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");R.setupDepthRenderbuffer(N)}}const je=N.texture;(je.isData3DTexture||je.isDataArrayTexture||je.isCompressedArrayTexture)&&(Re=!0);const et=Ie.get(N).__webglFramebuffer;N.isWebGLCubeRenderTarget?(Array.isArray(et[B])?k=et[B][Y]:k=et[B],xe=!0):N.samples>0&&R.useMultisampledRTT(N)===!1?k=Ie.get(N).__webglMultisampledFramebuffer:Array.isArray(et)?k=et[Y]:k=et,M.copy(N.viewport),b.copy(N.scissor),G=N.scissorTest}else M.copy(Ne).multiplyScalar(he).floor(),b.copy(Ee).multiplyScalar(he).floor(),G=Qe;if(Te.bindFramebuffer(P.FRAMEBUFFER,k)&&Z&&Te.drawBuffers(N,k),Te.viewport(M),Te.scissor(b),Te.setScissorTest(G),xe){const Ge=Ie.get(N.texture);P.framebufferTexture2D(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0,P.TEXTURE_CUBE_MAP_POSITIVE_X+B,Ge.__webglTexture,Y)}else if(Re){const Ge=Ie.get(N.texture),je=B||0;P.framebufferTextureLayer(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0,Ge.__webglTexture,Y||0,je)}C=-1},this.readRenderTargetPixels=function(N,B,Y,Z,k,xe,Re){if(!(N&&N.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ze=Ie.get(N).__webglFramebuffer;if(N.isWebGLCubeRenderTarget&&Re!==void 0&&(ze=ze[Re]),ze){Te.bindFramebuffer(P.FRAMEBUFFER,ze);try{const Ge=N.texture,je=Ge.format,et=Ge.type;if(!de.textureFormatReadable(je)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!de.textureTypeReadable(et)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}B>=0&&B<=N.width-Z&&Y>=0&&Y<=N.height-k&&P.readPixels(B,Y,Z,k,ct.convert(je),ct.convert(et),xe)}finally{const Ge=w!==null?Ie.get(w).__webglFramebuffer:null;Te.bindFramebuffer(P.FRAMEBUFFER,Ge)}}},this.readRenderTargetPixelsAsync=async function(N,B,Y,Z,k,xe,Re){if(!(N&&N.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ze=Ie.get(N).__webglFramebuffer;if(N.isWebGLCubeRenderTarget&&Re!==void 0&&(ze=ze[Re]),ze){const Ge=N.texture,je=Ge.format,et=Ge.type;if(!de.textureFormatReadable(je))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!de.textureTypeReadable(et))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(B>=0&&B<=N.width-Z&&Y>=0&&Y<=N.height-k){Te.bindFramebuffer(P.FRAMEBUFFER,ze);const He=P.createBuffer();P.bindBuffer(P.PIXEL_PACK_BUFFER,He),P.bufferData(P.PIXEL_PACK_BUFFER,xe.byteLength,P.STREAM_READ),P.readPixels(B,Y,Z,k,ct.convert(je),ct.convert(et),0);const Lt=w!==null?Ie.get(w).__webglFramebuffer:null;Te.bindFramebuffer(P.FRAMEBUFFER,Lt);const Gt=P.fenceSync(P.SYNC_GPU_COMMANDS_COMPLETE,0);return P.flush(),await DA(P,Gt,4),P.bindBuffer(P.PIXEL_PACK_BUFFER,He),P.getBufferSubData(P.PIXEL_PACK_BUFFER,0,xe),P.deleteBuffer(He),P.deleteSync(Gt),xe}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(N,B=null,Y=0){N.isTexture!==!0&&(Cu("WebGLRenderer: copyFramebufferToTexture function signature has changed."),B=arguments[0]||null,N=arguments[1]);const Z=Math.pow(2,-Y),k=Math.floor(N.image.width*Z),xe=Math.floor(N.image.height*Z),Re=B!==null?B.x:0,ze=B!==null?B.y:0;R.setTexture2D(N,0),P.copyTexSubImage2D(P.TEXTURE_2D,Y,0,0,Re,ze,k,xe),Te.unbindTexture()},this.copyTextureToTexture=function(N,B,Y=null,Z=null,k=0){N.isTexture!==!0&&(Cu("WebGLRenderer: copyTextureToTexture function signature has changed."),Z=arguments[0]||null,N=arguments[1],B=arguments[2],k=arguments[3]||0,Y=null);let xe,Re,ze,Ge,je,et;Y!==null?(xe=Y.max.x-Y.min.x,Re=Y.max.y-Y.min.y,ze=Y.min.x,Ge=Y.min.y):(xe=N.image.width,Re=N.image.height,ze=0,Ge=0),Z!==null?(je=Z.x,et=Z.y):(je=0,et=0);const He=ct.convert(B.format),Lt=ct.convert(B.type);R.setTexture2D(B,0),P.pixelStorei(P.UNPACK_FLIP_Y_WEBGL,B.flipY),P.pixelStorei(P.UNPACK_PREMULTIPLY_ALPHA_WEBGL,B.premultiplyAlpha),P.pixelStorei(P.UNPACK_ALIGNMENT,B.unpackAlignment);const Gt=P.getParameter(P.UNPACK_ROW_LENGTH),Jt=P.getParameter(P.UNPACK_IMAGE_HEIGHT),fi=P.getParameter(P.UNPACK_SKIP_PIXELS),Rt=P.getParameter(P.UNPACK_SKIP_ROWS),$e=P.getParameter(P.UNPACK_SKIP_IMAGES),An=N.isCompressedTexture?N.mipmaps[k]:N.image;P.pixelStorei(P.UNPACK_ROW_LENGTH,An.width),P.pixelStorei(P.UNPACK_IMAGE_HEIGHT,An.height),P.pixelStorei(P.UNPACK_SKIP_PIXELS,ze),P.pixelStorei(P.UNPACK_SKIP_ROWS,Ge),N.isDataTexture?P.texSubImage2D(P.TEXTURE_2D,k,je,et,xe,Re,He,Lt,An.data):N.isCompressedTexture?P.compressedTexSubImage2D(P.TEXTURE_2D,k,je,et,An.width,An.height,He,An.data):P.texSubImage2D(P.TEXTURE_2D,k,je,et,xe,Re,He,Lt,An),P.pixelStorei(P.UNPACK_ROW_LENGTH,Gt),P.pixelStorei(P.UNPACK_IMAGE_HEIGHT,Jt),P.pixelStorei(P.UNPACK_SKIP_PIXELS,fi),P.pixelStorei(P.UNPACK_SKIP_ROWS,Rt),P.pixelStorei(P.UNPACK_SKIP_IMAGES,$e),k===0&&B.generateMipmaps&&P.generateMipmap(P.TEXTURE_2D),Te.unbindTexture()},this.copyTextureToTexture3D=function(N,B,Y=null,Z=null,k=0){N.isTexture!==!0&&(Cu("WebGLRenderer: copyTextureToTexture3D function signature has changed."),Y=arguments[0]||null,Z=arguments[1]||null,N=arguments[2],B=arguments[3],k=arguments[4]||0);let xe,Re,ze,Ge,je,et,He,Lt,Gt;const Jt=N.isCompressedTexture?N.mipmaps[k]:N.image;Y!==null?(xe=Y.max.x-Y.min.x,Re=Y.max.y-Y.min.y,ze=Y.max.z-Y.min.z,Ge=Y.min.x,je=Y.min.y,et=Y.min.z):(xe=Jt.width,Re=Jt.height,ze=Jt.depth,Ge=0,je=0,et=0),Z!==null?(He=Z.x,Lt=Z.y,Gt=Z.z):(He=0,Lt=0,Gt=0);const fi=ct.convert(B.format),Rt=ct.convert(B.type);let $e;if(B.isData3DTexture)R.setTexture3D(B,0),$e=P.TEXTURE_3D;else if(B.isDataArrayTexture||B.isCompressedArrayTexture)R.setTexture2DArray(B,0),$e=P.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}P.pixelStorei(P.UNPACK_FLIP_Y_WEBGL,B.flipY),P.pixelStorei(P.UNPACK_PREMULTIPLY_ALPHA_WEBGL,B.premultiplyAlpha),P.pixelStorei(P.UNPACK_ALIGNMENT,B.unpackAlignment);const An=P.getParameter(P.UNPACK_ROW_LENGTH),It=P.getParameter(P.UNPACK_IMAGE_HEIGHT),Xi=P.getParameter(P.UNPACK_SKIP_PIXELS),fo=P.getParameter(P.UNPACK_SKIP_ROWS),mi=P.getParameter(P.UNPACK_SKIP_IMAGES);P.pixelStorei(P.UNPACK_ROW_LENGTH,Jt.width),P.pixelStorei(P.UNPACK_IMAGE_HEIGHT,Jt.height),P.pixelStorei(P.UNPACK_SKIP_PIXELS,Ge),P.pixelStorei(P.UNPACK_SKIP_ROWS,je),P.pixelStorei(P.UNPACK_SKIP_IMAGES,et),N.isDataTexture||N.isData3DTexture?P.texSubImage3D($e,k,He,Lt,Gt,xe,Re,ze,fi,Rt,Jt.data):B.isCompressedArrayTexture?P.compressedTexSubImage3D($e,k,He,Lt,Gt,xe,Re,ze,fi,Jt.data):P.texSubImage3D($e,k,He,Lt,Gt,xe,Re,ze,fi,Rt,Jt),P.pixelStorei(P.UNPACK_ROW_LENGTH,An),P.pixelStorei(P.UNPACK_IMAGE_HEIGHT,It),P.pixelStorei(P.UNPACK_SKIP_PIXELS,Xi),P.pixelStorei(P.UNPACK_SKIP_ROWS,fo),P.pixelStorei(P.UNPACK_SKIP_IMAGES,mi),k===0&&B.generateMipmaps&&P.generateMipmap($e),Te.unbindTexture()},this.initRenderTarget=function(N){Ie.get(N).__webglFramebuffer===void 0&&R.setupRenderTarget(N)},this.initTexture=function(N){N.isCubeTexture?R.setTextureCube(N,0):N.isData3DTexture?R.setTexture3D(N,0):N.isDataArrayTexture||N.isCompressedArrayTexture?R.setTexture2DArray(N,0):R.setTexture2D(N,0),Te.unbindTexture()},this.resetState=function(){I=0,T=0,w=null,Te.reset(),Ot.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Di}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===kh?"display-p3":"srgb",t.unpackColorSpace=gt.workingColorSpace===Xc?"display-p3":"srgb"}}class Zh{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new _e(e),this.density=t}clone(){return new Zh(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}let om=class Zy{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new _e(e),this.near=t,this.far=n}clone(){return new Zy(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}};class Jh extends yt{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 ui,this.environmentIntensity=1,this.environmentRotation=new ui,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}}class _a{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=sa,this.updateRanges=[],this.version=0,this.uuid=bi()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=bi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=bi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const qn=new E;class Ds{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)qn.fromBufferAttribute(this,t),qn.applyMatrix4(e),this.setXYZ(t,qn.x,qn.y,qn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)qn.fromBufferAttribute(this,t),qn.applyNormalMatrix(e),this.setXYZ(t,qn.x,qn.y,qn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)qn.fromBufferAttribute(this,t),qn.transformDirection(e),this.setXYZ(t,qn.x,qn.y,qn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=Yn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=ut(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=ut(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=ut(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=ut(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=ut(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Yn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Yn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Yn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Yn(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=ut(t,this.array),n=ut(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=ut(t,this.array),n=ut(n,this.array),i=ut(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=ut(t,this.array),n=ut(n,this.array),i=ut(i,this.array),r=ut(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return new At(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Ds(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class Zc extends mn{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new _e(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let Co;const Da=new E,Ro=new E,Io=new E,Po=new J,Ua=new J,Jy=new Fe,Xl=new E,Fa=new E,ql=new E,rx=new J,vp=new J,ox=new J;class am extends yt{constructor(e=new Zc){if(super(),this.isSprite=!0,this.type="Sprite",Co===void 0){Co=new at;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new _a(t,5);Co.setIndex([0,1,2,0,2,3]),Co.setAttribute("position",new Ds(n,3,0,!1)),Co.setAttribute("uv",new Ds(n,2,3,!1))}this.geometry=Co,this.material=e,this.center=new J(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Ro.setFromMatrixScale(this.matrixWorld),Jy.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Io.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Ro.multiplyScalar(-Io.z);const n=this.material.rotation;let i,r;n!==0&&(r=Math.cos(n),i=Math.sin(n));const o=this.center;$l(Xl.set(-.5,-.5,0),Io,o,Ro,i,r),$l(Fa.set(.5,-.5,0),Io,o,Ro,i,r),$l(ql.set(.5,.5,0),Io,o,Ro,i,r),rx.set(0,0),vp.set(1,0),ox.set(1,1);let a=e.ray.intersectTriangle(Xl,Fa,ql,!1,Da);if(a===null&&($l(Fa.set(-.5,.5,0),Io,o,Ro,i,r),vp.set(0,1),a=e.ray.intersectTriangle(Xl,ql,Fa,!1,Da),a===null))return;const c=e.ray.origin.distanceTo(Da);c<e.near||c>e.far||t.push({distance:c,point:Da.clone(),uv:Zn.getInterpolation(Da,Xl,Fa,ql,rx,vp,ox,new J),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function $l(s,e,t,n,i,r){Po.subVectors(s,t).addScalar(.5).multiply(n),i!==void 0?(Ua.x=r*Po.x-i*Po.y,Ua.y=i*Po.x+r*Po.y):Ua.copy(Po),s.copy(e),s.x+=Ua.x,s.y+=Ua.y,s.applyMatrix4(Jy)}const Yl=new E,ax=new E;class cm extends yt{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let n=0,i=t.length;n<i;n++){const r=t[n];this.addLevel(r.object.clone(),r.distance,r.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,n=0){t=Math.abs(t);const i=this.levels;let r;for(r=0;r<i.length&&!(t<i[r].distance);r++);return i.splice(r,0,{distance:t,hysteresis:n,object:e}),this.add(e),this}removeLevel(e){const t=this.levels;for(let n=0;n<t.length;n++)if(t[n].distance===e){const i=t.splice(n,1);return this.remove(i[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let n,i;for(n=1,i=t.length;n<i;n++){let r=t[n].distance;if(t[n].object.visible&&(r-=r*t[n].hysteresis),e<r)break}return t[n-1].object}return null}raycast(e,t){if(this.levels.length>0){Yl.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(Yl);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Yl.setFromMatrixPosition(e.matrixWorld),ax.setFromMatrixPosition(this.matrixWorld);const n=Yl.distanceTo(ax)/e.zoom;t[0].object.visible=!0;let i,r;for(i=1,r=t.length;i<r;i++){let o=t[i].distance;if(t[i].object.visible&&(o-=o*t[i].hysteresis),n>=o)t[i-1].object.visible=!1,t[i].object.visible=!0;else break}for(this._currentLevel=i-1;i<r;i++)t[i].object.visible=!1}}toJSON(e){const t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];const n=this.levels;for(let i=0,r=n.length;i<r;i++){const o=n[i];t.object.levels.push({object:o.object.uuid,distance:o.distance,hysteresis:o.hysteresis})}return t}}const cx=new E,lx=new st,ux=new st,$R=new E,hx=new Fe,Zl=new E,Mp=new Dn,dx=new Fe,Sp=new no;class lm extends kt{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=af,this.bindMatrix=new Fe,this.bindMatrixInverse=new Fe,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Hn),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Zl),this.boundingBox.expandByPoint(Zl)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Dn),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Zl),this.boundingSphere.expandByPoint(Zl)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Mp.copy(this.boundingSphere),Mp.applyMatrix4(i),e.ray.intersectsSphere(Mp)!==!1&&(dx.copy(i).invert(),Sp.copy(e.ray).applyMatrix4(dx),!(this.boundingBox!==null&&Sp.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Sp)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new st,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);const r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===af?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===ly?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,i=this.geometry;lx.fromBufferAttribute(i.attributes.skinIndex,e),ux.fromBufferAttribute(i.attributes.skinWeight,e),cx.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let r=0;r<4;r++){const o=ux.getComponent(r);if(o!==0){const a=lx.getComponent(r);hx.multiplyMatrices(n.bones[a].matrixWorld,n.boneInverses[a]),t.addScaledVector($R.copy(cx).applyMatrix4(hx),o)}}return t.applyMatrix4(this.bindMatrixInverse)}}class Kh extends yt{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Oi extends Xt{constructor(e=null,t=1,n=1,i,r,o,a,c,l=Qt,u=Qt,h,d){super(null,o,a,c,l,u,i,r,h,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const px=new Fe,YR=new Fe;class Jc{constructor(e=[],t=[]){this.uuid=bi(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Fe)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new Fe;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,o=e.length;r<o;r++){const a=e[r]?e[r].matrixWorld:YR;px.multiplyMatrices(a,t[r]),px.toArray(n,r*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new Jc(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new Oi(t,e,e,Rn,Gn);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const i=this.bones[t];if(i.name===e)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){const r=e.bones[n];let o=t[r];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",r),o=new Kh),this.bones.push(o),this.boneInverses.push(new Fe().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){const o=t[i];e.bones.push(o.uuid);const a=n[i];e.boneInverses.push(a.toArray())}return e}}class Us extends At{constructor(e,t,n,i=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Lo=new Fe,fx=new Fe,Jl=[],mx=new Hn,ZR=new Fe,Oa=new kt,Va=new Dn;class um extends kt{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Us(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,ZR)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Hn),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Lo),mx.copy(e.boundingBox).applyMatrix4(Lo),this.boundingBox.union(mx)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Dn),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Lo),Va.copy(e.boundingSphere).applyMatrix4(Lo),this.boundingSphere.union(Va)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,o=e*r+1;for(let a=0;a<n.length;a++)n[a]=i[o+a]}raycast(e,t){const n=this.matrixWorld,i=this.count;if(Oa.geometry=this.geometry,Oa.material=this.material,Oa.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Va.copy(this.boundingSphere),Va.applyMatrix4(n),e.ray.intersectsSphere(Va)!==!1))for(let r=0;r<i;r++){this.getMatrixAt(r,Lo),fx.multiplyMatrices(n,Lo),Oa.matrixWorld=fx,Oa.raycast(e,Jl);for(let o=0,a=Jl.length;o<a;o++){const c=Jl[o];c.instanceId=r,c.object=this,t.push(c)}Jl.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Us(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const n=t.morphTargetInfluences,i=n.length+1;this.morphTexture===null&&(this.morphTexture=new Oi(new Float32Array(i*this.count),i,this.count,Hc,Gn));const r=this.morphTexture.source.data.data;let o=0;for(let l=0;l<n.length;l++)o+=n[l];const a=this.geometry.morphTargetsRelative?1:1-o,c=i*e;r[c]=a,r.set(n,c+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}}function JR(s,e){return s.z-e.z}function KR(s,e){return e.z-s.z}class jR{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,n){const i=this.pool,r=this.list;this.index>=i.length&&i.push({start:-1,count:-1,z:-1,index:-1});const o=i[this.index];r.push(o),this.index++,o.start=e.start,o.count=e.count,o.z=t,o.index=n}reset(){this.list.length=0,this.index=0}}const Xs=new Fe,Tp=new Fe,QR=new Fe,eI=new _e(1,1,1),gx=new Fe,bp=new ga,Kl=new Hn,Ar=new Dn,Ba=new E,xx=new E,tI=new E,wp=new jR,zn=new kt,jl=[];function nI(s,e,t=0){const n=e.itemSize;if(s.isInterleavedBufferAttribute||s.array.constructor!==e.array.constructor){const i=s.count;for(let r=0;r<i;r++)for(let o=0;o<n;o++)e.setComponent(r+t,o,s.getComponent(r,o))}else e.array.set(s.array,t*n);e.needsUpdate=!0}class hm extends kt{get maxInstanceCount(){return this._maxInstanceCount}constructor(e,t,n=t*2,i){super(new at,i),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._drawInfo=[],this._availableInstanceIds=[],this._drawRanges=[],this._reservedRanges=[],this._bounds=[],this._maxInstanceCount=e,this._maxVertexCount=t,this._maxIndexCount=n,this._geometryInitialized=!1,this._geometryCount=0,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._visibilityChanged=!0,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}_initMatricesTexture(){let e=Math.sqrt(this._maxInstanceCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4),n=new Oi(t,e,e,Rn,Gn);this._matricesTexture=n}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Uint32Array(e*e),n=new Oi(t,e,e,Wc,Bi);this._indirectTexture=n}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Float32Array(e*e*4).fill(1),n=new Oi(t,e,e,Rn,Gn);n.colorSpace=gt.workingColorSpace,this._colorsTexture=n}_initializeGeometry(e){const t=this.geometry,n=this._maxVertexCount,i=this._maxIndexCount;if(this._geometryInitialized===!1){for(const r in e.attributes){const o=e.getAttribute(r),{array:a,itemSize:c,normalized:l}=o,u=new a.constructor(n*c),h=new At(u,c,l);t.setAttribute(r,h)}if(e.getIndex()!==null){const r=n>65535?new Uint32Array(i):new Uint16Array(i);t.setIndex(new At(r,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const n in t.attributes){if(!e.hasAttribute(n))throw new Error(`BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const i=e.getAttribute(n),r=t.getAttribute(n);if(i.itemSize!==r.itemSize||i.normalized!==r.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Hn);const e=this.boundingBox,t=this._drawInfo;e.makeEmpty();for(let n=0,i=t.length;n<i;n++){if(t[n].active===!1)continue;const r=t[n].geometryIndex;this.getMatrixAt(n,Xs),this.getBoundingBoxAt(r,Kl).applyMatrix4(Xs),e.union(Kl)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Dn);const e=this.boundingSphere,t=this._drawInfo;e.makeEmpty();for(let n=0,i=t.length;n<i;n++){if(t[n].active===!1)continue;const r=t[n].geometryIndex;this.getMatrixAt(n,Xs),this.getBoundingSphereAt(r,Ar).applyMatrix4(Xs),e.union(Ar)}}addInstance(e){if(this._drawInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("BatchedMesh: Maximum item count reached.");const n={visible:!0,active:!0,geometryIndex:e};let i=null;this._availableInstanceIds.length>0?(i=this._availableInstanceIds.pop(),this._drawInfo[i]=n):(i=this._drawInfo.length,this._drawInfo.push(n));const r=this._matricesTexture,o=r.image.data;QR.toArray(o,i*16),r.needsUpdate=!0;const a=this._colorsTexture;return a&&(eI.toArray(a.image.data,i*4),a.needsUpdate=!0),i}addGeometry(e,t=-1,n=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._drawInfo.length>=this._maxInstanceCount)throw new Error("BatchedMesh: Maximum item count reached.");const i={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let r=null;const o=this._reservedRanges,a=this._drawRanges,c=this._bounds;this._geometryCount!==0&&(r=o[o.length-1]),t===-1?i.vertexCount=e.getAttribute("position").count:i.vertexCount=t,r===null?i.vertexStart=0:i.vertexStart=r.vertexStart+r.vertexCount;const l=e.getIndex(),u=l!==null;if(u&&(n===-1?i.indexCount=l.count:i.indexCount=n,r===null?i.indexStart=0:i.indexStart=r.indexStart+r.indexCount),i.indexStart!==-1&&i.indexStart+i.indexCount>this._maxIndexCount||i.vertexStart+i.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const h=this._geometryCount;return this._geometryCount++,o.push(i),a.push({start:u?i.indexStart:i.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new Hn,sphereInitialized:!1,sphere:new Dn}),this.setGeometryAt(h,e),h}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const n=this.geometry,i=n.getIndex()!==null,r=n.getIndex(),o=t.getIndex(),a=this._reservedRanges[e];if(i&&o.count>a.indexCount||t.attributes.position.count>a.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const c=a.vertexStart,l=a.vertexCount;for(const p in n.attributes){const f=t.getAttribute(p),x=n.getAttribute(p);nI(f,x,c);const m=f.itemSize;for(let g=f.count,y=l;g<y;g++){const _=c+g;for(let v=0;v<m;v++)x.setComponent(_,v,0)}x.needsUpdate=!0,x.addUpdateRange(c*m,l*m)}if(i){const p=a.indexStart;for(let f=0;f<o.count;f++)r.setX(p+f,c+o.getX(f));for(let f=o.count,x=a.indexCount;f<x;f++)r.setX(p+f,c);r.needsUpdate=!0,r.addUpdateRange(p,a.indexCount)}const u=this._bounds[e];t.boundingBox!==null?(u.box.copy(t.boundingBox),u.boxInitialized=!0):u.boxInitialized=!1,t.boundingSphere!==null?(u.sphere.copy(t.boundingSphere),u.sphereInitialized=!0):u.sphereInitialized=!1;const h=this._drawRanges[e],d=t.getAttribute("position");return h.count=i?o.count:d.count,this._visibilityChanged=!0,e}deleteInstance(e){const t=this._drawInfo;return e>=t.length||t[e].active===!1?this:(t[e].active=!1,this._availableInstanceIds.push(e),this._visibilityChanged=!0,this)}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;const n=this._bounds[e],i=n.box,r=this.geometry;if(n.boxInitialized===!1){i.makeEmpty();const o=r.index,a=r.attributes.position,c=this._drawRanges[e];for(let l=c.start,u=c.start+c.count;l<u;l++){let h=l;o&&(h=o.getX(h)),i.expandByPoint(Ba.fromBufferAttribute(a,h))}n.boxInitialized=!0}return t.copy(i),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;const n=this._bounds[e],i=n.sphere,r=this.geometry;if(n.sphereInitialized===!1){i.makeEmpty(),this.getBoundingBoxAt(e,Kl),Kl.getCenter(i.center);const o=r.index,a=r.attributes.position,c=this._drawRanges[e];let l=0;for(let u=c.start,h=c.start+c.count;u<h;u++){let d=u;o&&(d=o.getX(d)),Ba.fromBufferAttribute(a,d),l=Math.max(l,i.center.distanceToSquared(Ba))}i.radius=Math.sqrt(l),n.sphereInitialized=!0}return t.copy(i),t}setMatrixAt(e,t){const n=this._drawInfo,i=this._matricesTexture,r=this._matricesTexture.image.data;return e>=n.length||n[e].active===!1?this:(t.toArray(r,e*16),i.needsUpdate=!0,this)}getMatrixAt(e,t){const n=this._drawInfo,i=this._matricesTexture.image.data;return e>=n.length||n[e].active===!1?null:t.fromArray(i,e*16)}setColorAt(e,t){this._colorsTexture===null&&this._initColorsTexture();const n=this._colorsTexture,i=this._colorsTexture.image.data,r=this._drawInfo;return e>=r.length||r[e].active===!1?this:(t.toArray(i,e*4),n.needsUpdate=!0,this)}getColorAt(e,t){const n=this._colorsTexture.image.data,i=this._drawInfo;return e>=i.length||i[e].active===!1?null:t.fromArray(n,e*4)}setVisibleAt(e,t){const n=this._drawInfo;return e>=n.length||n[e].active===!1||n[e].visible===t?this:(n[e].visible=t,this._visibilityChanged=!0,this)}getVisibleAt(e){const t=this._drawInfo;return e>=t.length||t[e].active===!1?!1:t[e].visible}setGeometryIdAt(e,t){const n=this._drawInfo;return e>=n.length||n[e].active===!1||t<0||t>=this._geometryCount?null:(n[e].geometryIndex=t,this)}getGeometryIdAt(e){const t=this._drawInfo;return e>=t.length||t[e].active===!1?-1:t[e].geometryIndex}getGeometryRangeAt(e,t={}){if(e<0||e>=this._geometryCount)return null;const n=this._drawRanges[e];return t.start=n.start,t.count=n.count,t}raycast(e,t){const n=this._drawInfo,i=this._drawRanges,r=this.matrixWorld,o=this.geometry;zn.material=this.material,zn.geometry.index=o.index,zn.geometry.attributes=o.attributes,zn.geometry.boundingBox===null&&(zn.geometry.boundingBox=new Hn),zn.geometry.boundingSphere===null&&(zn.geometry.boundingSphere=new Dn);for(let a=0,c=n.length;a<c;a++){if(!n[a].visible||!n[a].active)continue;const l=n[a].geometryIndex,u=i[l];zn.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(a,zn.matrixWorld).premultiply(r),this.getBoundingBoxAt(l,zn.geometry.boundingBox),this.getBoundingSphereAt(l,zn.geometry.boundingSphere),zn.raycast(e,jl);for(let h=0,d=jl.length;h<d;h++){const p=jl[h];p.object=this,p.batchId=a,t.push(p)}jl.length=0}zn.material=null,zn.geometry.index=null,zn.geometry.attributes={},zn.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(t=>({...t})),this._reservedRanges=e._reservedRanges.map(t=>({...t})),this._drawInfo=e._drawInfo.map(t=>({...t})),this._bounds=e._bounds.map(t=>({boxInitialized:t.boxInitialized,box:t.box.clone(),sphereInitialized:t.sphereInitialized,sphere:t.sphere.clone()})),this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(e,t,n,i,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const o=i.getIndex(),a=o===null?1:o.array.BYTES_PER_ELEMENT,c=this._drawInfo,l=this._multiDrawStarts,u=this._multiDrawCounts,h=this._drawRanges,d=this.perObjectFrustumCulled,p=this._indirectTexture,f=p.image.data;d&&(gx.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),bp.setFromProjectionMatrix(gx,e.coordinateSystem));let x=0;if(this.sortObjects){Tp.copy(this.matrixWorld).invert(),Ba.setFromMatrixPosition(n.matrixWorld).applyMatrix4(Tp),xx.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(Tp);for(let y=0,_=c.length;y<_;y++)if(c[y].visible&&c[y].active){const v=c[y].geometryIndex;this.getMatrixAt(y,Xs),this.getBoundingSphereAt(v,Ar).applyMatrix4(Xs);let I=!1;if(d&&(I=!bp.intersectsSphere(Ar)),!I){const T=tI.subVectors(Ar.center,Ba).dot(xx);wp.push(h[v],T,y)}}const m=wp.list,g=this.customSort;g===null?m.sort(r.transparent?KR:JR):g.call(this,m,n);for(let y=0,_=m.length;y<_;y++){const v=m[y];l[x]=v.start*a,u[x]=v.count,f[x]=v.index,x++}wp.reset()}else for(let m=0,g=c.length;m<g;m++)if(c[m].visible&&c[m].active){const y=c[m].geometryIndex;let _=!1;if(d&&(this.getMatrixAt(m,Xs),this.getBoundingSphereAt(y,Ar).applyMatrix4(Xs),_=!bp.intersectsSphere(Ar)),!_){const v=h[y];l[x]=v.start*a,u[x]=v.count,f[x]=m,x++}}p.needsUpdate=!0,this._multiDrawCount=x,this._visibilityChanged=!1}onBeforeShadow(e,t,n,i,r,o){this.onBeforeRender(e,null,i,r,o)}}class Fn extends mn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new _e(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const oh=new E,ah=new E,_x=new Fe,za=new no,Ql=new Dn,Ap=new E,yx=new E;class Fs extends yt{constructor(e=new at,t=new Fn){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let i=1,r=t.count;i<r;i++)oh.fromBufferAttribute(t,i-1),ah.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=oh.distanceTo(ah);e.setAttribute("lineDistance",new Ve(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Ql.copy(n.boundingSphere),Ql.applyMatrix4(i),Ql.radius+=r,e.ray.intersectsSphere(Ql)===!1)return;_x.copy(i).invert(),za.copy(e.ray).applyMatrix4(_x);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=this.isLineSegments?2:1,u=n.index,d=n.attributes.position;if(u!==null){const p=Math.max(0,o.start),f=Math.min(u.count,o.start+o.count);for(let x=p,m=f-1;x<m;x+=l){const g=u.getX(x),y=u.getX(x+1),_=eu(this,e,za,c,g,y);_&&t.push(_)}if(this.isLineLoop){const x=u.getX(f-1),m=u.getX(p),g=eu(this,e,za,c,x,m);g&&t.push(g)}}else{const p=Math.max(0,o.start),f=Math.min(d.count,o.start+o.count);for(let x=p,m=f-1;x<m;x+=l){const g=eu(this,e,za,c,x,x+1);g&&t.push(g)}if(this.isLineLoop){const x=eu(this,e,za,c,f-1,p);x&&t.push(x)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r<o;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}function eu(s,e,t,n,i,r){const o=s.geometry.attributes.position;if(oh.fromBufferAttribute(o,i),ah.fromBufferAttribute(o,r),t.distanceSqToSegment(oh,ah,Ap,yx)>n)return;Ap.applyMatrix4(s.matrixWorld);const c=e.ray.origin.distanceTo(Ap);if(!(c<e.near||c>e.far))return{distance:c,point:yx.clone().applyMatrix4(s.matrixWorld),index:i,face:null,faceIndex:null,barycoord:null,object:s}}const vx=new E,Mx=new E;class rs extends Fs{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let i=0,r=t.count;i<r;i+=2)vx.fromBufferAttribute(t,i),Mx.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+vx.distanceTo(Mx);e.setAttribute("lineDistance",new Ve(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class dm extends Fs{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class ya extends mn{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new _e(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const Sx=new Fe,uf=new no,tu=new Dn,nu=new E;class pm extends yt{constructor(e=new at,t=new ya){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),tu.copy(n.boundingSphere),tu.applyMatrix4(i),tu.radius+=r,e.ray.intersectsSphere(tu)===!1)return;Sx.copy(i).invert(),uf.copy(e.ray).applyMatrix4(Sx);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=n.index,h=n.attributes.position;if(l!==null){const d=Math.max(0,o.start),p=Math.min(l.count,o.start+o.count);for(let f=d,x=p;f<x;f++){const m=l.getX(f);nu.fromBufferAttribute(h,m),Tx(nu,m,c,i,e,t,this)}}else{const d=Math.max(0,o.start),p=Math.min(h.count,o.start+o.count);for(let f=d,x=p;f<x;f++)nu.fromBufferAttribute(h,f),Tx(nu,f,c,i,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r<o;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}function Tx(s,e,t,n,i,r,o){const a=uf.distanceSqToPoint(s);if(a<t){const c=new E;uf.closestPointToPoint(s,c),c.applyMatrix4(n);const l=i.ray.origin.distanceTo(c);if(l<i.near||l>i.far)return;r.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:e,face:null,faceIndex:null,barycoord:null,object:o})}}class Ky extends Xt{constructor(e,t,n,i,r,o,a,c,l){super(e,t,n,i,r,o,a,c,l),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:Ut,this.magFilter=r!==void 0?r:Ut,this.generateMipmaps=!1;const u=this;function h(){u.needsUpdate=!0,e.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class fm extends Xt{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Qt,this.minFilter=Qt,this.generateMipmaps=!1,this.needsUpdate=!0}}class Kc extends Xt{constructor(e,t,n,i,r,o,a,c,l,u,h,d){super(null,o,a,c,l,u,i,r,h,d),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class jy extends Kc{constructor(e,t,n,i,r,o){super(e,t,n,r,o),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=Si,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Qy extends Kc{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,wi),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class ev extends Xt{constructor(e,t,n,i,r,o,a,c,l){super(e,t,n,i,r,o,a,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Gi{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),r=0;t.push(0);for(let o=1;o<=e;o++)n=this.getPoint(o/e),r+=n.distanceTo(i),t.push(r),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let i=0;const r=n.length;let o;t?o=t:o=e*n[r-1];let a=0,c=r-1,l;for(;a<=c;)if(i=Math.floor(a+(c-a)/2),l=n[i]-o,l<0)a=i+1;else if(l>0)c=i-1;else{c=i;break}if(i=c,n[i]===o)return i/(r-1);const u=n[i],d=n[i+1]-u,p=(o-u)/d;return(i+p)/(r-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);const o=this.getPoint(i),a=this.getPoint(r),c=t||(o.isVector2?new J:new E);return c.copy(a).sub(o).normalize(),c}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new E,i=[],r=[],o=[],a=new E,c=new Fe;for(let p=0;p<=e;p++){const f=p/e;i[p]=this.getTangentAt(f,new E)}r[0]=new E,o[0]=new E;let l=Number.MAX_VALUE;const u=Math.abs(i[0].x),h=Math.abs(i[0].y),d=Math.abs(i[0].z);u<=l&&(l=u,n.set(1,0,0)),h<=l&&(l=h,n.set(0,1,0)),d<=l&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],a),o[0].crossVectors(i[0],r[0]);for(let p=1;p<=e;p++){if(r[p]=r[p-1].clone(),o[p]=o[p-1].clone(),a.crossVectors(i[p-1],i[p]),a.length()>Number.EPSILON){a.normalize();const f=Math.acos(jt(i[p-1].dot(i[p]),-1,1));r[p].applyMatrix4(c.makeRotationAxis(a,f))}o[p].crossVectors(i[p],r[p])}if(t===!0){let p=Math.acos(jt(r[0].dot(r[e]),-1,1));p/=e,i[0].dot(a.crossVectors(r[0],r[e]))>0&&(p=-p);for(let f=1;f<=e;f++)r[f].applyMatrix4(c.makeRotationAxis(i[f],p*f)),o[f].crossVectors(i[f],r[f])}return{tangents:i,normals:r,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class jh extends Gi{constructor(e=0,t=0,n=1,i=1,r=0,o=Math.PI*2,a=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=o,this.aClockwise=a,this.aRotation=c}getPoint(e,t=new J){const n=t,i=Math.PI*2;let r=this.aEndAngle-this.aStartAngle;const o=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=i;for(;r>i;)r-=i;r<Number.EPSILON&&(o?r=0:r=i),this.aClockwise===!0&&!o&&(r===i?r=-i:r=r-i);const a=this.aStartAngle+e*r;let c=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){const u=Math.cos(this.aRotation),h=Math.sin(this.aRotation),d=c-this.aX,p=l-this.aY;c=d*u-p*h+this.aX,l=d*h+p*u+this.aY}return n.set(c,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class tv extends jh{constructor(e,t,n,i,r,o){super(e,t,n,n,i,r,o),this.isArcCurve=!0,this.type="ArcCurve"}}function mm(){let s=0,e=0,t=0,n=0;function i(r,o,a,c){s=r,e=a,t=-3*r+3*o-2*a-c,n=2*r-2*o+a+c}return{initCatmullRom:function(r,o,a,c,l){i(o,a,l*(a-r),l*(c-o))},initNonuniformCatmullRom:function(r,o,a,c,l,u,h){let d=(o-r)/l-(a-r)/(l+u)+(a-o)/u,p=(a-o)/u-(c-o)/(u+h)+(c-a)/h;d*=u,p*=u,i(o,a,d,p)},calc:function(r){const o=r*r,a=o*r;return s+e*r+t*o+n*a}}}const iu=new E,Np=new mm,Ep=new mm,Cp=new mm;class gm extends Gi{constructor(e=[],t=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=i}getPoint(e,t=new E){const n=t,i=this.points,r=i.length,o=(r-(this.closed?0:1))*e;let a=Math.floor(o),c=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/r)+1)*r:c===0&&a===r-1&&(a=r-2,c=1);let l,u;this.closed||a>0?l=i[(a-1)%r]:(iu.subVectors(i[0],i[1]).add(i[0]),l=iu);const h=i[a%r],d=i[(a+1)%r];if(this.closed||a+2<r?u=i[(a+2)%r]:(iu.subVectors(i[r-1],i[r-2]).add(i[r-1]),u=iu),this.curveType==="centripetal"||this.curveType==="chordal"){const p=this.curveType==="chordal"?.5:.25;let f=Math.pow(l.distanceToSquared(h),p),x=Math.pow(h.distanceToSquared(d),p),m=Math.pow(d.distanceToSquared(u),p);x<1e-4&&(x=1),f<1e-4&&(f=x),m<1e-4&&(m=x),Np.initNonuniformCatmullRom(l.x,h.x,d.x,u.x,f,x,m),Ep.initNonuniformCatmullRom(l.y,h.y,d.y,u.y,f,x,m),Cp.initNonuniformCatmullRom(l.z,h.z,d.z,u.z,f,x,m)}else this.curveType==="catmullrom"&&(Np.initCatmullRom(l.x,h.x,d.x,u.x,this.tension),Ep.initCatmullRom(l.y,h.y,d.y,u.y,this.tension),Cp.initCatmullRom(l.z,h.z,d.z,u.z,this.tension));return n.set(Np.calc(c),Ep.calc(c),Cp.calc(c)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(i.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const i=this.points[t];e.points.push(i.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(new E().fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function bx(s,e,t,n,i){const r=(n-e)*.5,o=(i-t)*.5,a=s*s,c=s*a;return(2*t-2*n+r+o)*c+(-3*t+3*n-2*r-o)*a+r*s+t}function iI(s,e){const t=1-s;return t*t*e}function sI(s,e){return 2*(1-s)*s*e}function rI(s,e){return s*s*e}function ja(s,e,t,n){return iI(s,e)+sI(s,t)+rI(s,n)}function oI(s,e){const t=1-s;return t*t*t*e}function aI(s,e){const t=1-s;return 3*t*t*s*e}function cI(s,e){return 3*(1-s)*s*s*e}function lI(s,e){return s*s*s*e}function Qa(s,e,t,n,i){return oI(s,e)+aI(s,t)+cI(s,n)+lI(s,i)}class xm extends Gi{constructor(e=new J,t=new J,n=new J,i=new J){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new J){const n=t,i=this.v0,r=this.v1,o=this.v2,a=this.v3;return n.set(Qa(e,i.x,r.x,o.x,a.x),Qa(e,i.y,r.y,o.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class nv extends Gi{constructor(e=new E,t=new E,n=new E,i=new E){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new E){const n=t,i=this.v0,r=this.v1,o=this.v2,a=this.v3;return n.set(Qa(e,i.x,r.x,o.x,a.x),Qa(e,i.y,r.y,o.y,a.y),Qa(e,i.z,r.z,o.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class _m extends Gi{constructor(e=new J,t=new J){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new J){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new J){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class iv extends Gi{constructor(e=new E,t=new E){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new E){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new E){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class ym extends Gi{constructor(e=new J,t=new J,n=new J){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new J){const n=t,i=this.v0,r=this.v1,o=this.v2;return n.set(ja(e,i.x,r.x,o.x),ja(e,i.y,r.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class vm extends Gi{constructor(e=new E,t=new E,n=new E){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new E){const n=t,i=this.v0,r=this.v1,o=this.v2;return n.set(ja(e,i.x,r.x,o.x),ja(e,i.y,r.y,o.y),ja(e,i.z,r.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Mm extends Gi{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new J){const n=t,i=this.points,r=(i.length-1)*e,o=Math.floor(r),a=r-o,c=i[o===0?o:o-1],l=i[o],u=i[o>i.length-2?i.length-1:o+1],h=i[o>i.length-3?i.length-1:o+2];return n.set(bx(a,c.x,l.x,u.x,h.x),bx(a,c.y,l.y,u.y,h.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const i=this.points[t];e.points.push(i.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(new J().fromArray(i))}return this}}var ch=Object.freeze({__proto__:null,ArcCurve:tv,CatmullRomCurve3:gm,CubicBezierCurve:xm,CubicBezierCurve3:nv,EllipseCurve:jh,LineCurve:_m,LineCurve3:iv,QuadraticBezierCurve:ym,QuadraticBezierCurve3:vm,SplineCurve:Mm});class sv extends Gi{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){const n=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new ch[n](t,e))}return this}getPoint(e,t){const n=e*this.getLength(),i=this.getCurveLengths();let r=0;for(;r<i.length;){if(i[r]>=n){const o=i[r]-n,a=this.curves[r],c=a.getLength(),l=c===0?0:1-o/c;return a.getPointAt(l,t)}r++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,i=this.curves.length;n<i;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let n;for(let i=0,r=this.curves;i<r.length;i++){const o=r[i],a=o.isEllipseCurve?e*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,c=o.getPoints(a);for(let l=0;l<c.length;l++){const u=c[l];n&&n.equals(u)||(t.push(u),n=u)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const i=e.curves[t];this.curves.push(i.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){const i=this.curves[t];e.curves.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const i=e.curves[t];this.curves.push(new ch[i.type]().fromJSON(i))}return this}}class Rc extends sv{constructor(e){super(),this.type="Path",this.currentPoint=new J,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const n=new _m(this.currentPoint.clone(),new J(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,i){const r=new ym(this.currentPoint.clone(),new J(e,t),new J(n,i));return this.curves.push(r),this.currentPoint.set(n,i),this}bezierCurveTo(e,t,n,i,r,o){const a=new xm(this.currentPoint.clone(),new J(e,t),new J(n,i),new J(r,o));return this.curves.push(a),this.currentPoint.set(r,o),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new Mm(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,i,r,o){const a=this.currentPoint.x,c=this.currentPoint.y;return this.absarc(e+a,t+c,n,i,r,o),this}absarc(e,t,n,i,r,o){return this.absellipse(e,t,n,n,i,r,o),this}ellipse(e,t,n,i,r,o,a,c){const l=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(e+l,t+u,n,i,r,o,a,c),this}absellipse(e,t,n,i,r,o,a,c){const l=new jh(e,t,n,i,r,o,a,c);if(this.curves.length>0){const h=l.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(l);const u=l.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class jc extends at{constructor(e=[new J(0,-.5),new J(.5,0),new J(0,.5)],t=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=jt(i,0,Math.PI*2);const r=[],o=[],a=[],c=[],l=[],u=1/t,h=new E,d=new J,p=new E,f=new E,x=new E;let m=0,g=0;for(let y=0;y<=e.length-1;y++)switch(y){case 0:m=e[y+1].x-e[y].x,g=e[y+1].y-e[y].y,p.x=g*1,p.y=-m,p.z=g*0,x.copy(p),p.normalize(),c.push(p.x,p.y,p.z);break;case e.length-1:c.push(x.x,x.y,x.z);break;default:m=e[y+1].x-e[y].x,g=e[y+1].y-e[y].y,p.x=g*1,p.y=-m,p.z=g*0,f.copy(p),p.x+=x.x,p.y+=x.y,p.z+=x.z,p.normalize(),c.push(p.x,p.y,p.z),x.copy(f)}for(let y=0;y<=t;y++){const _=n+y*u*i,v=Math.sin(_),I=Math.cos(_);for(let T=0;T<=e.length-1;T++){h.x=e[T].x*v,h.y=e[T].y,h.z=e[T].x*I,o.push(h.x,h.y,h.z),d.x=y/t,d.y=T/(e.length-1),a.push(d.x,d.y);const w=c[3*T+0]*v,C=c[3*T+1],F=c[3*T+0]*I;l.push(w,C,F)}}for(let y=0;y<t;y++)for(let _=0;_<e.length-1;_++){const v=_+y*e.length,I=v,T=v+e.length,w=v+e.length+1,C=v+1;r.push(I,T,C),r.push(w,C,T)}this.setIndex(r),this.setAttribute("position",new Ve(o,3)),this.setAttribute("uv",new Ve(a,2)),this.setAttribute("normal",new Ve(l,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new jc(e.points,e.segments,e.phiStart,e.phiLength)}}class Qh extends jc{constructor(e=1,t=1,n=4,i=8){const r=new Rc;r.absarc(0,-t/2,e,Math.PI*1.5,0),r.absarc(0,t/2,e,0,Math.PI*.5),super(r.getPoints(n),i),this.type="CapsuleGeometry",this.parameters={radius:e,length:t,capSegments:n,radialSegments:i}}static fromJSON(e){return new Qh(e.radius,e.length,e.capSegments,e.radialSegments)}}class ed extends at{constructor(e=1,t=32,n=0,i=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},t=Math.max(3,t);const r=[],o=[],a=[],c=[],l=new E,u=new J;o.push(0,0,0),a.push(0,0,1),c.push(.5,.5);for(let h=0,d=3;h<=t;h++,d+=3){const p=n+h/t*i;l.x=e*Math.cos(p),l.y=e*Math.sin(p),o.push(l.x,l.y,l.z),a.push(0,0,1),u.x=(o[d]/e+1)/2,u.y=(o[d+1]/e+1)/2,c.push(u.x,u.y)}for(let h=1;h<=t;h++)r.push(h,h+1,0);this.setIndex(r),this.setAttribute("position",new Ve(o,3)),this.setAttribute("normal",new Ve(a,3)),this.setAttribute("uv",new Ve(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ed(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class ao extends at{constructor(e=1,t=1,n=1,i=32,r=1,o=!1,a=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:r,openEnded:o,thetaStart:a,thetaLength:c};const l=this;i=Math.floor(i),r=Math.floor(r);const u=[],h=[],d=[],p=[];let f=0;const x=[],m=n/2;let g=0;y(),o===!1&&(e>0&&_(!0),t>0&&_(!1)),this.setIndex(u),this.setAttribute("position",new Ve(h,3)),this.setAttribute("normal",new Ve(d,3)),this.setAttribute("uv",new Ve(p,2));function y(){const v=new E,I=new E;let T=0;const w=(t-e)/n;for(let C=0;C<=r;C++){const F=[],M=C/r,b=M*(t-e)+e;for(let G=0;G<=i;G++){const W=G/i,$=W*c+a,ie=Math.sin($),q=Math.cos($);I.x=b*ie,I.y=-M*n+m,I.z=b*q,h.push(I.x,I.y,I.z),v.set(ie,w,q).normalize(),d.push(v.x,v.y,v.z),p.push(W,1-M),F.push(f++)}x.push(F)}for(let C=0;C<i;C++)for(let F=0;F<r;F++){const M=x[F][C],b=x[F+1][C],G=x[F+1][C+1],W=x[F][C+1];e>0&&(u.push(M,b,W),T+=3),t>0&&(u.push(b,G,W),T+=3)}l.addGroup(g,T,0),g+=T}function _(v){const I=f,T=new J,w=new E;let C=0;const F=v===!0?e:t,M=v===!0?1:-1;for(let G=1;G<=i;G++)h.push(0,m*M,0),d.push(0,M,0),p.push(.5,.5),f++;const b=f;for(let G=0;G<=i;G++){const $=G/i*c+a,ie=Math.cos($),q=Math.sin($);w.x=F*q,w.y=m*M,w.z=F*ie,h.push(w.x,w.y,w.z),d.push(0,M,0),T.x=ie*.5+.5,T.y=q*.5*M+.5,p.push(T.x,T.y),f++}for(let G=0;G<i;G++){const W=I+G,$=b+G;v===!0?u.push($,$+1,W):u.push($+1,$,W),C+=3}l.addGroup(g,C,v===!0?1:2),g+=C}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ao(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class td extends ao{constructor(e=1,t=1,n=32,i=1,r=!1,o=0,a=Math.PI*2){super(0,e,t,n,i,r,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:o,thetaLength:a}}static fromJSON(e){return new td(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class dr extends at{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};const r=[],o=[];a(i),l(n),u(),this.setAttribute("position",new Ve(r,3)),this.setAttribute("normal",new Ve(r.slice(),3)),this.setAttribute("uv",new Ve(o,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function a(y){const _=new E,v=new E,I=new E;for(let T=0;T<t.length;T+=3)p(t[T+0],_),p(t[T+1],v),p(t[T+2],I),c(_,v,I,y)}function c(y,_,v,I){const T=I+1,w=[];for(let C=0;C<=T;C++){w[C]=[];const F=y.clone().lerp(v,C/T),M=_.clone().lerp(v,C/T),b=T-C;for(let G=0;G<=b;G++)G===0&&C===T?w[C][G]=F:w[C][G]=F.clone().lerp(M,G/b)}for(let C=0;C<T;C++)for(let F=0;F<2*(T-C)-1;F++){const M=Math.floor(F/2);F%2===0?(d(w[C][M+1]),d(w[C+1][M]),d(w[C][M])):(d(w[C][M+1]),d(w[C+1][M+1]),d(w[C+1][M]))}}function l(y){const _=new E;for(let v=0;v<r.length;v+=3)_.x=r[v+0],_.y=r[v+1],_.z=r[v+2],_.normalize().multiplyScalar(y),r[v+0]=_.x,r[v+1]=_.y,r[v+2]=_.z}function u(){const y=new E;for(let _=0;_<r.length;_+=3){y.x=r[_+0],y.y=r[_+1],y.z=r[_+2];const v=m(y)/2/Math.PI+.5,I=g(y)/Math.PI+.5;o.push(v,1-I)}f(),h()}function h(){for(let y=0;y<o.length;y+=6){const _=o[y+0],v=o[y+2],I=o[y+4],T=Math.max(_,v,I),w=Math.min(_,v,I);T>.9&&w<.1&&(_<.2&&(o[y+0]+=1),v<.2&&(o[y+2]+=1),I<.2&&(o[y+4]+=1))}}function d(y){r.push(y.x,y.y,y.z)}function p(y,_){const v=y*3;_.x=e[v+0],_.y=e[v+1],_.z=e[v+2]}function f(){const y=new E,_=new E,v=new E,I=new E,T=new J,w=new J,C=new J;for(let F=0,M=0;F<r.length;F+=9,M+=6){y.set(r[F+0],r[F+1],r[F+2]),_.set(r[F+3],r[F+4],r[F+5]),v.set(r[F+6],r[F+7],r[F+8]),T.set(o[M+0],o[M+1]),w.set(o[M+2],o[M+3]),C.set(o[M+4],o[M+5]),I.copy(y).add(_).add(v).divideScalar(3);const b=m(I);x(T,M+0,y,b),x(w,M+2,_,b),x(C,M+4,v,b)}}function x(y,_,v,I){I<0&&y.x===1&&(o[_]=y.x-1),v.x===0&&v.z===0&&(o[_]=I/2/Math.PI+.5)}function m(y){return Math.atan2(y.z,-y.x)}function g(y){return Math.atan2(-y.y,Math.sqrt(y.x*y.x+y.z*y.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new dr(e.vertices,e.indices,e.radius,e.details)}}class nd extends dr{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=1/n,r=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(r,o,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new nd(e.radius,e.detail)}}const su=new E,ru=new E,Rp=new E,ou=new Zn;class Sm extends at{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const i=Math.pow(10,4),r=Math.cos(qr*t),o=e.getIndex(),a=e.getAttribute("position"),c=o?o.count:a.count,l=[0,0,0],u=["a","b","c"],h=new Array(3),d={},p=[];for(let f=0;f<c;f+=3){o?(l[0]=o.getX(f),l[1]=o.getX(f+1),l[2]=o.getX(f+2)):(l[0]=f,l[1]=f+1,l[2]=f+2);const{a:x,b:m,c:g}=ou;if(x.fromBufferAttribute(a,l[0]),m.fromBufferAttribute(a,l[1]),g.fromBufferAttribute(a,l[2]),ou.getNormal(Rp),h[0]=`${Math.round(x.x*i)},${Math.round(x.y*i)},${Math.round(x.z*i)}`,h[1]=`${Math.round(m.x*i)},${Math.round(m.y*i)},${Math.round(m.z*i)}`,h[2]=`${Math.round(g.x*i)},${Math.round(g.y*i)},${Math.round(g.z*i)}`,!(h[0]===h[1]||h[1]===h[2]||h[2]===h[0]))for(let y=0;y<3;y++){const _=(y+1)%3,v=h[y],I=h[_],T=ou[u[y]],w=ou[u[_]],C=`${v}_${I}`,F=`${I}_${v}`;F in d&&d[F]?(Rp.dot(d[F].normal)<=r&&(p.push(T.x,T.y,T.z),p.push(w.x,w.y,w.z)),d[F]=null):C in d||(d[C]={index0:l[y],index1:l[_],normal:Rp.clone()})}}for(const f in d)if(d[f]){const{index0:x,index1:m}=d[f];su.fromBufferAttribute(a,x),ru.fromBufferAttribute(a,m),p.push(su.x,su.y,su.z),p.push(ru.x,ru.y,ru.z)}this.setAttribute("position",new Ve(p,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class er extends Rc{constructor(e){super(e),this.uuid=bi(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,i=this.holes.length;n<i;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const i=e.holes[t];this.holes.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){const i=this.holes[t];e.holes.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const i=e.holes[t];this.holes.push(new Rc().fromJSON(i))}return this}}const uI={triangulate:function(s,e,t=2){const n=e&&e.length,i=n?e[0]*t:s.length;let r=rv(s,0,i,t,!0);const o=[];if(!r||r.next===r.prev)return o;let a,c,l,u,h,d,p;if(n&&(r=mI(s,e,r,t)),s.length>80*t){a=l=s[0],c=u=s[1];for(let f=t;f<i;f+=t)h=s[f],d=s[f+1],h<a&&(a=h),d<c&&(c=d),h>l&&(l=h),d>u&&(u=d);p=Math.max(l-a,u-c),p=p!==0?32767/p:0}return Ic(r,o,t,a,c,p,0),o}};function rv(s,e,t,n,i){let r,o;if(i===AI(s,e,t,n)>0)for(r=e;r<t;r+=n)o=wx(r,s[r],s[r+1],o);else for(r=t-n;r>=e;r-=n)o=wx(r,s[r],s[r+1],o);return o&&id(o,o.next)&&(Lc(o),o=o.next),o}function Qr(s,e){if(!s)return s;e||(e=s);let t=s,n;do if(n=!1,!t.steiner&&(id(t,t.next)||Zt(t.prev,t,t.next)===0)){if(Lc(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function Ic(s,e,t,n,i,r,o){if(!s)return;!o&&r&&vI(s,n,i,r);let a=s,c,l;for(;s.prev!==s.next;){if(c=s.prev,l=s.next,r?dI(s,n,i,r):hI(s)){e.push(c.i/t|0),e.push(s.i/t|0),e.push(l.i/t|0),Lc(s),s=l.next,a=l.next;continue}if(s=l,s===a){o?o===1?(s=pI(Qr(s),e,t),Ic(s,e,t,n,i,r,2)):o===2&&fI(s,e,t,n,i,r):Ic(Qr(s),e,t,n,i,r,1);break}}}function hI(s){const e=s.prev,t=s,n=s.next;if(Zt(e,t,n)>=0)return!1;const i=e.x,r=t.x,o=n.x,a=e.y,c=t.y,l=n.y,u=i<r?i<o?i:o:r<o?r:o,h=a<c?a<l?a:l:c<l?c:l,d=i>r?i>o?i:o:r>o?r:o,p=a>c?a>l?a:l:c>l?c:l;let f=n.next;for(;f!==e;){if(f.x>=u&&f.x<=d&&f.y>=h&&f.y<=p&&Ho(i,a,r,c,o,l,f.x,f.y)&&Zt(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function dI(s,e,t,n){const i=s.prev,r=s,o=s.next;if(Zt(i,r,o)>=0)return!1;const a=i.x,c=r.x,l=o.x,u=i.y,h=r.y,d=o.y,p=a<c?a<l?a:l:c<l?c:l,f=u<h?u<d?u:d:h<d?h:d,x=a>c?a>l?a:l:c>l?c:l,m=u>h?u>d?u:d:h>d?h:d,g=hf(p,f,e,t,n),y=hf(x,m,e,t,n);let _=s.prevZ,v=s.nextZ;for(;_&&_.z>=g&&v&&v.z<=y;){if(_.x>=p&&_.x<=x&&_.y>=f&&_.y<=m&&_!==i&&_!==o&&Ho(a,u,c,h,l,d,_.x,_.y)&&Zt(_.prev,_,_.next)>=0||(_=_.prevZ,v.x>=p&&v.x<=x&&v.y>=f&&v.y<=m&&v!==i&&v!==o&&Ho(a,u,c,h,l,d,v.x,v.y)&&Zt(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;_&&_.z>=g;){if(_.x>=p&&_.x<=x&&_.y>=f&&_.y<=m&&_!==i&&_!==o&&Ho(a,u,c,h,l,d,_.x,_.y)&&Zt(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;v&&v.z<=y;){if(v.x>=p&&v.x<=x&&v.y>=f&&v.y<=m&&v!==i&&v!==o&&Ho(a,u,c,h,l,d,v.x,v.y)&&Zt(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function pI(s,e,t){let n=s;do{const i=n.prev,r=n.next.next;!id(i,r)&&ov(i,n,n.next,r)&&Pc(i,r)&&Pc(r,i)&&(e.push(i.i/t|0),e.push(n.i/t|0),e.push(r.i/t|0),Lc(n),Lc(n.next),n=s=r),n=n.next}while(n!==s);return Qr(n)}function fI(s,e,t,n,i,r){let o=s;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&TI(o,a)){let c=av(o,a);o=Qr(o,o.next),c=Qr(c,c.next),Ic(o,e,t,n,i,r,0),Ic(c,e,t,n,i,r,0);return}a=a.next}o=o.next}while(o!==s)}function mI(s,e,t,n){const i=[];let r,o,a,c,l;for(r=0,o=e.length;r<o;r++)a=e[r]*n,c=r<o-1?e[r+1]*n:s.length,l=rv(s,a,c,n,!1),l===l.next&&(l.steiner=!0),i.push(SI(l));for(i.sort(gI),r=0;r<i.length;r++)t=xI(i[r],t);return t}function gI(s,e){return s.x-e.x}function xI(s,e){const t=_I(s,e);if(!t)return e;const n=av(t,s);return Qr(n,n.next),Qr(t,t.next)}function _I(s,e){let t=e,n=-1/0,i;const r=s.x,o=s.y;do{if(o<=t.y&&o>=t.next.y&&t.next.y!==t.y){const d=t.x+(o-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=r&&d>n&&(n=d,i=t.x<t.next.x?t:t.next,d===r))return i}t=t.next}while(t!==e);if(!i)return null;const a=i,c=i.x,l=i.y;let u=1/0,h;t=i;do r>=t.x&&t.x>=c&&r!==t.x&&Ho(o<l?r:n,o,c,l,o<l?n:r,o,t.x,t.y)&&(h=Math.abs(o-t.y)/(r-t.x),Pc(t,s)&&(h<u||h===u&&(t.x>i.x||t.x===i.x&&yI(i,t)))&&(i=t,u=h)),t=t.next;while(t!==a);return i}function yI(s,e){return Zt(s.prev,s,e.prev)<0&&Zt(e.next,s,s.next)<0}function vI(s,e,t,n){let i=s;do i.z===0&&(i.z=hf(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==s);i.prevZ.nextZ=null,i.prevZ=null,MI(i)}function MI(s){let e,t,n,i,r,o,a,c,l=1;do{for(t=s,s=null,r=null,o=0;t;){for(o++,n=t,a=0,e=0;e<l&&(a++,n=n.nextZ,!!n);e++);for(c=l;a>0||c>0&&n;)a!==0&&(c===0||!n||t.z<=n.z)?(i=t,t=t.nextZ,a--):(i=n,n=n.nextZ,c--),r?r.nextZ=i:s=i,i.prevZ=r,r=i;t=n}r.nextZ=null,l*=2}while(o>1);return s}function hf(s,e,t,n,i){return s=(s-t)*i|0,e=(e-n)*i|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,s|e<<1}function SI(s){let e=s,t=s;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==s);return t}function Ho(s,e,t,n,i,r,o,a){return(i-o)*(e-a)>=(s-o)*(r-a)&&(s-o)*(n-a)>=(t-o)*(e-a)&&(t-o)*(r-a)>=(i-o)*(n-a)}function TI(s,e){return s.next.i!==e.i&&s.prev.i!==e.i&&!bI(s,e)&&(Pc(s,e)&&Pc(e,s)&&wI(s,e)&&(Zt(s.prev,s,e.prev)||Zt(s,e.prev,e))||id(s,e)&&Zt(s.prev,s,s.next)>0&&Zt(e.prev,e,e.next)>0)}function Zt(s,e,t){return(e.y-s.y)*(t.x-e.x)-(e.x-s.x)*(t.y-e.y)}function id(s,e){return s.x===e.x&&s.y===e.y}function ov(s,e,t,n){const i=cu(Zt(s,e,t)),r=cu(Zt(s,e,n)),o=cu(Zt(t,n,s)),a=cu(Zt(t,n,e));return!!(i!==r&&o!==a||i===0&&au(s,t,e)||r===0&&au(s,n,e)||o===0&&au(t,s,n)||a===0&&au(t,e,n))}function au(s,e,t){return e.x<=Math.max(s.x,t.x)&&e.x>=Math.min(s.x,t.x)&&e.y<=Math.max(s.y,t.y)&&e.y>=Math.min(s.y,t.y)}function cu(s){return s>0?1:s<0?-1:0}function bI(s,e){let t=s;do{if(t.i!==s.i&&t.next.i!==s.i&&t.i!==e.i&&t.next.i!==e.i&&ov(t,t.next,s,e))return!0;t=t.next}while(t!==s);return!1}function Pc(s,e){return Zt(s.prev,s,s.next)<0?Zt(s,e,s.next)>=0&&Zt(s,s.prev,e)>=0:Zt(s,e,s.prev)<0||Zt(s,s.next,e)<0}function wI(s,e){let t=s,n=!1;const i=(s.x+e.x)/2,r=(s.y+e.y)/2;do t.y>r!=t.next.y>r&&t.next.y!==t.y&&i<(t.next.x-t.x)*(r-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==s);return n}function av(s,e){const t=new df(s.i,s.x,s.y),n=new df(e.i,e.x,e.y),i=s.next,r=e.prev;return s.next=e,e.prev=s,t.next=i,i.prev=t,n.next=t,t.prev=n,r.next=n,n.prev=r,n}function wx(s,e,t,n){const i=new df(s,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Lc(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function df(s,e,t){this.i=s,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function AI(s,e,t,n){let i=0;for(let r=e,o=t-n;r<t;r+=n)i+=(s[o]-s[r])*(s[r+1]+s[o+1]),o=r;return i}class ji{static area(e){const t=e.length;let n=0;for(let i=t-1,r=0;r<t;i=r++)n+=e[i].x*e[r].y-e[r].x*e[i].y;return n*.5}static isClockWise(e){return ji.area(e)<0}static triangulateShape(e,t){const n=[],i=[],r=[];Ax(e),Nx(n,e);let o=e.length;t.forEach(Ax);for(let c=0;c<t.length;c++)i.push(o),o+=t[c].length,Nx(n,t[c]);const a=uI.triangulate(n,i);for(let c=0;c<a.length;c+=3)r.push(a.slice(c,c+3));return r}}function Ax(s){const e=s.length;e>2&&s[e-1].equals(s[0])&&s.pop()}function Nx(s,e){for(let t=0;t<e.length;t++)s.push(e[t].x),s.push(e[t].y)}class Qc extends at{constructor(e=new er([new J(.5,.5),new J(-.5,.5),new J(-.5,-.5),new J(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,i=[],r=[];for(let a=0,c=e.length;a<c;a++){const l=e[a];o(l)}this.setAttribute("position",new Ve(i,3)),this.setAttribute("uv",new Ve(r,2)),this.computeVertexNormals();function o(a){const c=[],l=t.curveSegments!==void 0?t.curveSegments:12,u=t.steps!==void 0?t.steps:1,h=t.depth!==void 0?t.depth:1;let d=t.bevelEnabled!==void 0?t.bevelEnabled:!0,p=t.bevelThickness!==void 0?t.bevelThickness:.2,f=t.bevelSize!==void 0?t.bevelSize:p-.1,x=t.bevelOffset!==void 0?t.bevelOffset:0,m=t.bevelSegments!==void 0?t.bevelSegments:3;const g=t.extrudePath,y=t.UVGenerator!==void 0?t.UVGenerator:NI;let _,v=!1,I,T,w,C;g&&(_=g.getSpacedPoints(u),v=!0,d=!1,I=g.computeFrenetFrames(u,!1),T=new E,w=new E,C=new E),d||(m=0,p=0,f=0,x=0);const F=a.extractPoints(l);let M=F.shape;const b=F.holes;if(!ji.isClockWise(M)){M=M.reverse();for(let ae=0,P=b.length;ae<P;ae++){const Me=b[ae];ji.isClockWise(Me)&&(b[ae]=Me.reverse())}}const W=ji.triangulateShape(M,b),$=M;for(let ae=0,P=b.length;ae<P;ae++){const Me=b[ae];M=M.concat(Me)}function ie(ae,P,Me){return P||console.error("THREE.ExtrudeGeometry: vec does not exist"),ae.clone().addScaledVector(P,Me)}const q=M.length,he=W.length;function Q(ae,P,Me){let ye,de,Te;const qe=ae.x-P.x,Ie=ae.y-P.y,R=Me.x-ae.x,S=Me.y-ae.y,X=qe*qe+Ie*Ie,re=qe*S-Ie*R;if(Math.abs(re)>Number.EPSILON){const ce=Math.sqrt(X),se=Math.sqrt(R*R+S*S),ke=P.x-Ie/ce,be=P.y+qe/ce,De=Me.x-S/se,vt=Me.y+R/se,me=((De-ke)*S-(vt-be)*R)/(qe*S-Ie*R);ye=ke+qe*me-ae.x,de=be+Ie*me-ae.y;const Ue=ye*ye+de*de;if(Ue<=2)return new J(ye,de);Te=Math.sqrt(Ue/2)}else{let ce=!1;qe>Number.EPSILON?R>Number.EPSILON&&(ce=!0):qe<-Number.EPSILON?R<-Number.EPSILON&&(ce=!0):Math.sign(Ie)===Math.sign(S)&&(ce=!0),ce?(ye=-Ie,de=qe,Te=Math.sqrt(X)):(ye=qe,de=Ie,Te=Math.sqrt(X/2))}return new J(ye/Te,de/Te)}const we=[];for(let ae=0,P=$.length,Me=P-1,ye=ae+1;ae<P;ae++,Me++,ye++)Me===P&&(Me=0),ye===P&&(ye=0),we[ae]=Q($[ae],$[Me],$[ye]);const Ne=[];let Ee,Qe=we.concat();for(let ae=0,P=b.length;ae<P;ae++){const Me=b[ae];Ee=[];for(let ye=0,de=Me.length,Te=de-1,qe=ye+1;ye<de;ye++,Te++,qe++)Te===de&&(Te=0),qe===de&&(qe=0),Ee[ye]=Q(Me[ye],Me[Te],Me[qe]);Ne.push(Ee),Qe=Qe.concat(Ee)}for(let ae=0;ae<m;ae++){const P=ae/m,Me=p*Math.cos(P*Math.PI/2),ye=f*Math.sin(P*Math.PI/2)+x;for(let de=0,Te=$.length;de<Te;de++){const qe=ie($[de],we[de],ye);ge(qe.x,qe.y,-Me)}for(let de=0,Te=b.length;de<Te;de++){const qe=b[de];Ee=Ne[de];for(let Ie=0,R=qe.length;Ie<R;Ie++){const S=ie(qe[Ie],Ee[Ie],ye);ge(S.x,S.y,-Me)}}}const ht=f+x;for(let ae=0;ae<q;ae++){const P=d?ie(M[ae],Qe[ae],ht):M[ae];v?(w.copy(I.normals[0]).multiplyScalar(P.x),T.copy(I.binormals[0]).multiplyScalar(P.y),C.copy(_[0]).add(w).add(T),ge(C.x,C.y,C.z)):ge(P.x,P.y,0)}for(let ae=1;ae<=u;ae++)for(let P=0;P<q;P++){const Me=d?ie(M[P],Qe[P],ht):M[P];v?(w.copy(I.normals[ae]).multiplyScalar(Me.x),T.copy(I.binormals[ae]).multiplyScalar(Me.y),C.copy(_[ae]).add(w).add(T),ge(C.x,C.y,C.z)):ge(Me.x,Me.y,h/u*ae)}for(let ae=m-1;ae>=0;ae--){const P=ae/m,Me=p*Math.cos(P*Math.PI/2),ye=f*Math.sin(P*Math.PI/2)+x;for(let de=0,Te=$.length;de<Te;de++){const qe=ie($[de],we[de],ye);ge(qe.x,qe.y,h+Me)}for(let de=0,Te=b.length;de<Te;de++){const qe=b[de];Ee=Ne[de];for(let Ie=0,R=qe.length;Ie<R;Ie++){const S=ie(qe[Ie],Ee[Ie],ye);v?ge(S.x,S.y+_[u-1].y,_[u-1].x+Me):ge(S.x,S.y,h+Me)}}}ne(),ue();function ne(){const ae=i.length/3;if(d){let P=0,Me=q*P;for(let ye=0;ye<he;ye++){const de=W[ye];Ze(de[2]+Me,de[1]+Me,de[0]+Me)}P=u+m*2,Me=q*P;for(let ye=0;ye<he;ye++){const de=W[ye];Ze(de[0]+Me,de[1]+Me,de[2]+Me)}}else{for(let P=0;P<he;P++){const Me=W[P];Ze(Me[2],Me[1],Me[0])}for(let P=0;P<he;P++){const Me=W[P];Ze(Me[0]+q*u,Me[1]+q*u,Me[2]+q*u)}}n.addGroup(ae,i.length/3-ae,0)}function ue(){const ae=i.length/3;let P=0;Ae($,P),P+=$.length;for(let Me=0,ye=b.length;Me<ye;Me++){const de=b[Me];Ae(de,P),P+=de.length}n.addGroup(ae,i.length/3-ae,1)}function Ae(ae,P){let Me=ae.length;for(;--Me>=0;){const ye=Me;let de=Me-1;de<0&&(de=ae.length-1);for(let Te=0,qe=u+m*2;Te<qe;Te++){const Ie=q*Te,R=q*(Te+1),S=P+ye+Ie,X=P+de+Ie,re=P+de+R,ce=P+ye+R;Xe(S,X,re,ce)}}}function ge(ae,P,Me){c.push(ae),c.push(P),c.push(Me)}function Ze(ae,P,Me){Je(ae),Je(P),Je(Me);const ye=i.length/3,de=y.generateTopUV(n,i,ye-3,ye-2,ye-1);dt(de[0]),dt(de[1]),dt(de[2])}function Xe(ae,P,Me,ye){Je(ae),Je(P),Je(ye),Je(P),Je(Me),Je(ye);const de=i.length/3,Te=y.generateSideWallUV(n,i,de-6,de-3,de-2,de-1);dt(Te[0]),dt(Te[1]),dt(Te[3]),dt(Te[1]),dt(Te[2]),dt(Te[3])}function Je(ae){i.push(c[ae*3+0]),i.push(c[ae*3+1]),i.push(c[ae*3+2])}function dt(ae){r.push(ae.x),r.push(ae.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return EI(t,n,e)}static fromJSON(e,t){const n=[];for(let r=0,o=e.shapes.length;r<o;r++){const a=t[e.shapes[r]];n.push(a)}const i=e.options.extrudePath;return i!==void 0&&(e.options.extrudePath=new ch[i.type]().fromJSON(i)),new Qc(n,e.options)}}const NI={generateTopUV:function(s,e,t,n,i){const r=e[t*3],o=e[t*3+1],a=e[n*3],c=e[n*3+1],l=e[i*3],u=e[i*3+1];return[new J(r,o),new J(a,c),new J(l,u)]},generateSideWallUV:function(s,e,t,n,i,r){const o=e[t*3],a=e[t*3+1],c=e[t*3+2],l=e[n*3],u=e[n*3+1],h=e[n*3+2],d=e[i*3],p=e[i*3+1],f=e[i*3+2],x=e[r*3],m=e[r*3+1],g=e[r*3+2];return Math.abs(a-u)<Math.abs(o-l)?[new J(o,1-c),new J(l,1-h),new J(d,1-f),new J(x,1-g)]:[new J(a,1-c),new J(u,1-h),new J(p,1-f),new J(m,1-g)]}};function EI(s,e,t){if(t.shapes=[],Array.isArray(s))for(let n=0,i=s.length;n<i;n++){const r=s[n];t.shapes.push(r.uuid)}else t.shapes.push(s.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class sd extends dr{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],r=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(i,r,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new sd(e.radius,e.detail)}}class va extends dr{constructor(e=1,t=0){const n=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],i=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(n,i,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new va(e.radius,e.detail)}}class el extends at{constructor(e=.5,t=1,n=32,i=1,r=0,o=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:i,thetaStart:r,thetaLength:o},n=Math.max(3,n),i=Math.max(1,i);const a=[],c=[],l=[],u=[];let h=e;const d=(t-e)/i,p=new E,f=new J;for(let x=0;x<=i;x++){for(let m=0;m<=n;m++){const g=r+m/n*o;p.x=h*Math.cos(g),p.y=h*Math.sin(g),c.push(p.x,p.y,p.z),l.push(0,0,1),f.x=(p.x/t+1)/2,f.y=(p.y/t+1)/2,u.push(f.x,f.y)}h+=d}for(let x=0;x<i;x++){const m=x*(n+1);for(let g=0;g<n;g++){const y=g+m,_=y,v=y+n+1,I=y+n+2,T=y+1;a.push(_,v,T),a.push(v,I,T)}}this.setIndex(a),this.setAttribute("position",new Ve(c,3)),this.setAttribute("normal",new Ve(l,3)),this.setAttribute("uv",new Ve(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new el(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class rd extends at{constructor(e=new er([new J(0,.5),new J(-.5,-.5),new J(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const n=[],i=[],r=[],o=[];let a=0,c=0;if(Array.isArray(e)===!1)l(e);else for(let u=0;u<e.length;u++)l(e[u]),this.addGroup(a,c,u),a+=c,c=0;this.setIndex(n),this.setAttribute("position",new Ve(i,3)),this.setAttribute("normal",new Ve(r,3)),this.setAttribute("uv",new Ve(o,2));function l(u){const h=i.length/3,d=u.extractPoints(t);let p=d.shape;const f=d.holes;ji.isClockWise(p)===!1&&(p=p.reverse());for(let m=0,g=f.length;m<g;m++){const y=f[m];ji.isClockWise(y)===!0&&(f[m]=y.reverse())}const x=ji.triangulateShape(p,f);for(let m=0,g=f.length;m<g;m++){const y=f[m];p=p.concat(y)}for(let m=0,g=p.length;m<g;m++){const y=p[m];i.push(y.x,y.y,0),r.push(0,0,1),o.push(y.x,y.y)}for(let m=0,g=x.length;m<g;m++){const y=x[m],_=y[0]+h,v=y[1]+h,I=y[2]+h;n.push(_,v,I),c+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return CI(t,e)}static fromJSON(e,t){const n=[];for(let i=0,r=e.shapes.length;i<r;i++){const o=t[e.shapes[i]];n.push(o)}return new rd(n,e.curveSegments)}}function CI(s,e){if(e.shapes=[],Array.isArray(s))for(let t=0,n=s.length;t<n;t++){const i=s[t];e.shapes.push(i.uuid)}else e.shapes.push(s.uuid);return e}class Ma extends at{constructor(e=1,t=32,n=16,i=0,r=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:r,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const c=Math.min(o+a,Math.PI);let l=0;const u=[],h=new E,d=new E,p=[],f=[],x=[],m=[];for(let g=0;g<=n;g++){const y=[],_=g/n;let v=0;g===0&&o===0?v=.5/t:g===n&&c===Math.PI&&(v=-.5/t);for(let I=0;I<=t;I++){const T=I/t;h.x=-e*Math.cos(i+T*r)*Math.sin(o+_*a),h.y=e*Math.cos(o+_*a),h.z=e*Math.sin(i+T*r)*Math.sin(o+_*a),f.push(h.x,h.y,h.z),d.copy(h).normalize(),x.push(d.x,d.y,d.z),m.push(T+v,1-_),y.push(l++)}u.push(y)}for(let g=0;g<n;g++)for(let y=0;y<t;y++){const _=u[g][y+1],v=u[g][y],I=u[g+1][y],T=u[g+1][y+1];(g!==0||o>0)&&p.push(_,v,T),(g!==n-1||c<Math.PI)&&p.push(v,I,T)}this.setIndex(p),this.setAttribute("position",new Ve(f,3)),this.setAttribute("normal",new Ve(x,3)),this.setAttribute("uv",new Ve(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ma(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class od extends dr{constructor(e=1,t=0){const n=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],i=[2,1,0,0,3,2,1,3,0,2,3,1];super(n,i,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new od(e.radius,e.detail)}}class tl extends at{constructor(e=1,t=.4,n=12,i=48,r=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:i,arc:r},n=Math.floor(n),i=Math.floor(i);const o=[],a=[],c=[],l=[],u=new E,h=new E,d=new E;for(let p=0;p<=n;p++)for(let f=0;f<=i;f++){const x=f/i*r,m=p/n*Math.PI*2;h.x=(e+t*Math.cos(m))*Math.cos(x),h.y=(e+t*Math.cos(m))*Math.sin(x),h.z=t*Math.sin(m),a.push(h.x,h.y,h.z),u.x=e*Math.cos(x),u.y=e*Math.sin(x),d.subVectors(h,u).normalize(),c.push(d.x,d.y,d.z),l.push(f/i),l.push(p/n)}for(let p=1;p<=n;p++)for(let f=1;f<=i;f++){const x=(i+1)*p+f-1,m=(i+1)*(p-1)+f-1,g=(i+1)*(p-1)+f,y=(i+1)*p+f;o.push(x,m,y),o.push(m,g,y)}this.setIndex(o),this.setAttribute("position",new Ve(a,3)),this.setAttribute("normal",new Ve(c,3)),this.setAttribute("uv",new Ve(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new tl(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class ad extends at{constructor(e=1,t=.4,n=64,i=8,r=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:i,p:r,q:o},n=Math.floor(n),i=Math.floor(i);const a=[],c=[],l=[],u=[],h=new E,d=new E,p=new E,f=new E,x=new E,m=new E,g=new E;for(let _=0;_<=n;++_){const v=_/n*r*Math.PI*2;y(v,r,o,e,p),y(v+.01,r,o,e,f),m.subVectors(f,p),g.addVectors(f,p),x.crossVectors(m,g),g.crossVectors(x,m),x.normalize(),g.normalize();for(let I=0;I<=i;++I){const T=I/i*Math.PI*2,w=-t*Math.cos(T),C=t*Math.sin(T);h.x=p.x+(w*g.x+C*x.x),h.y=p.y+(w*g.y+C*x.y),h.z=p.z+(w*g.z+C*x.z),c.push(h.x,h.y,h.z),d.subVectors(h,p).normalize(),l.push(d.x,d.y,d.z),u.push(_/n),u.push(I/i)}}for(let _=1;_<=n;_++)for(let v=1;v<=i;v++){const I=(i+1)*(_-1)+(v-1),T=(i+1)*_+(v-1),w=(i+1)*_+v,C=(i+1)*(_-1)+v;a.push(I,T,C),a.push(T,w,C)}this.setIndex(a),this.setAttribute("position",new Ve(c,3)),this.setAttribute("normal",new Ve(l,3)),this.setAttribute("uv",new Ve(u,2));function y(_,v,I,T,w){const C=Math.cos(_),F=Math.sin(_),M=I/v*_,b=Math.cos(M);w.x=T*(2+b)*.5*C,w.y=T*(2+b)*F*.5,w.z=T*Math.sin(M)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ad(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class cd extends at{constructor(e=new vm(new E(-1,-1,0),new E(-1,1,0),new E(1,1,0)),t=64,n=1,i=8,r=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:i,closed:r};const o=e.computeFrenetFrames(t,r);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;const a=new E,c=new E,l=new J;let u=new E;const h=[],d=[],p=[],f=[];x(),this.setIndex(f),this.setAttribute("position",new Ve(h,3)),this.setAttribute("normal",new Ve(d,3)),this.setAttribute("uv",new Ve(p,2));function x(){for(let _=0;_<t;_++)m(_);m(r===!1?t:0),y(),g()}function m(_){u=e.getPointAt(_/t,u);const v=o.normals[_],I=o.binormals[_];for(let T=0;T<=i;T++){const w=T/i*Math.PI*2,C=Math.sin(w),F=-Math.cos(w);c.x=F*v.x+C*I.x,c.y=F*v.y+C*I.y,c.z=F*v.z+C*I.z,c.normalize(),d.push(c.x,c.y,c.z),a.x=u.x+n*c.x,a.y=u.y+n*c.y,a.z=u.z+n*c.z,h.push(a.x,a.y,a.z)}}function g(){for(let _=1;_<=t;_++)for(let v=1;v<=i;v++){const I=(i+1)*(_-1)+(v-1),T=(i+1)*_+(v-1),w=(i+1)*_+v,C=(i+1)*(_-1)+v;f.push(I,T,C),f.push(T,w,C)}}function y(){for(let _=0;_<=t;_++)for(let v=0;v<=i;v++)l.x=_/t,l.y=v/i,p.push(l.x,l.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new cd(new ch[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class Tm extends at{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],n=new Set,i=new E,r=new E;if(e.index!==null){const o=e.attributes.position,a=e.index;let c=e.groups;c.length===0&&(c=[{start:0,count:a.count,materialIndex:0}]);for(let l=0,u=c.length;l<u;++l){const h=c[l],d=h.start,p=h.count;for(let f=d,x=d+p;f<x;f+=3)for(let m=0;m<3;m++){const g=a.getX(f+m),y=a.getX(f+(m+1)%3);i.fromBufferAttribute(o,g),r.fromBufferAttribute(o,y),Ex(i,r,n)===!0&&(t.push(i.x,i.y,i.z),t.push(r.x,r.y,r.z))}}}else{const o=e.attributes.position;for(let a=0,c=o.count/3;a<c;a++)for(let l=0;l<3;l++){const u=3*a+l,h=3*a+(l+1)%3;i.fromBufferAttribute(o,u),r.fromBufferAttribute(o,h),Ex(i,r,n)===!0&&(t.push(i.x,i.y,i.z),t.push(r.x,r.y,r.z))}}this.setAttribute("position",new Ve(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function Ex(s,e,t){const n=`${s.x},${s.y},${s.z}-${e.x},${e.y},${e.z}`,i=`${e.x},${e.y},${e.z}-${s.x},${s.y},${s.z}`;return t.has(n)===!0||t.has(i)===!0?!1:(t.add(n),t.add(i),!0)}var Cx=Object.freeze({__proto__:null,BoxGeometry:_s,CapsuleGeometry:Qh,CircleGeometry:ed,ConeGeometry:td,CylinderGeometry:ao,DodecahedronGeometry:nd,EdgesGeometry:Sm,ExtrudeGeometry:Qc,IcosahedronGeometry:sd,LatheGeometry:jc,OctahedronGeometry:va,PlaneGeometry:so,PolyhedronGeometry:dr,RingGeometry:el,ShapeGeometry:rd,SphereGeometry:Ma,TetrahedronGeometry:od,TorusGeometry:tl,TorusKnotGeometry:ad,TubeGeometry:cd,WireframeGeometry:Tm});class ld extends mn{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new _e(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class bm extends ki{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class nl extends mn{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new _e(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new _e(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ms,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ui,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class ud extends nl{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new J(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return jt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new _e(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new _e(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new _e(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class hd extends mn{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new _e(16777215),this.specular=new _e(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new _e(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ms,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ui,this.combine=fa,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class wm extends mn{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new _e(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new _e(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ms,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class dd extends mn{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ms,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class pd extends mn{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new _e(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new _e(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ms,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ui,this.combine=fa,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Am extends mn{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new _e(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ms,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class fd extends Fn{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function Hr(s,e,t){return!s||!t&&s.constructor===e?s:typeof e.BYTES_PER_ELEMENT=="number"?new e(s):Array.prototype.slice.call(s)}function cv(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function lv(s){function e(i,r){return s[i]-s[r]}const t=s.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function pf(s,e,t){const n=s.length,i=new s.constructor(n);for(let r=0,o=0;o!==n;++r){const a=t[r]*e;for(let c=0;c!==e;++c)i[o++]=s[a+c]}return i}function Nm(s,e,t,n){let i=1,r=s[0];for(;r!==void 0&&r[n]===void 0;)r=s[i++];if(r===void 0)return;let o=r[n];if(o!==void 0)if(Array.isArray(o))do o=r[n],o!==void 0&&(e.push(r.time),t.push.apply(t,o)),r=s[i++];while(r!==void 0);else if(o.toArray!==void 0)do o=r[n],o!==void 0&&(e.push(r.time),o.toArray(t,t.length)),r=s[i++];while(r!==void 0);else do o=r[n],o!==void 0&&(e.push(r.time),t.push(o)),r=s[i++];while(r!==void 0)}function RI(s,e,t,n,i=30){const r=s.clone();r.name=e;const o=[];for(let c=0;c<r.tracks.length;++c){const l=r.tracks[c],u=l.getValueSize(),h=[],d=[];for(let p=0;p<l.times.length;++p){const f=l.times[p]*i;if(!(f<t||f>=n)){h.push(l.times[p]);for(let x=0;x<u;++x)d.push(l.values[p*u+x])}}h.length!==0&&(l.times=Hr(h,l.times.constructor),l.values=Hr(d,l.values.constructor),o.push(l))}r.tracks=o;let a=1/0;for(let c=0;c<r.tracks.length;++c)a>r.tracks[c].times[0]&&(a=r.tracks[c].times[0]);for(let c=0;c<r.tracks.length;++c)r.tracks[c].shift(-1*a);return r.resetDuration(),r}function II(s,e=0,t=s,n=30){n<=0&&(n=30);const i=t.tracks.length,r=e/n;for(let o=0;o<i;++o){const a=t.tracks[o],c=a.ValueTypeName;if(c==="bool"||c==="string")continue;const l=s.tracks.find(function(g){return g.name===a.name&&g.ValueTypeName===c});if(l===void 0)continue;let u=0;const h=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(u=h/3);let d=0;const p=l.getValueSize();l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(d=p/3);const f=a.times.length-1;let x;if(r<=a.times[0]){const g=u,y=h-u;x=a.values.slice(g,y)}else if(r>=a.times[f]){const g=f*h+u,y=g+h-u;x=a.values.slice(g,y)}else{const g=a.createInterpolant(),y=u,_=h-u;g.evaluate(r),x=g.resultBuffer.slice(y,_)}c==="quaternion"&&new Qn().fromArray(x).normalize().conjugate().toArray(x);const m=l.times.length;for(let g=0;g<m;++g){const y=g*p+d;if(c==="quaternion")Qn.multiplyQuaternionsFlat(l.values,y,x,0,l.values,y);else{const _=p-d*2;for(let v=0;v<_;++v)l.values[y+v]-=x[v]}}}return s.blendMode=Yf,s}const PI={convertArray:Hr,isTypedArray:cv,getKeyframeOrder:lv,sortedArray:pf,flattenJSON:Nm,subclip:RI,makeClipAdditive:II};class Sa{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let o;n:{i:if(!(e<i)){for(let a=n+2;;){if(i===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(r=i,i=t[++n],e<i)break t}o=t.length;break n}if(!(e>=r)){const a=t[1];e<a&&(n=2,r=a);for(let c=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===c)break;if(i=r,r=t[--n-1],e>=r)break t}o=n,n=0;break n}break e}for(;n<o;){const a=n+o>>>1;e<t[a]?o=a:n=a+1}if(i=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let o=0;o!==i;++o)t[o]=n[r+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class uv extends Sa{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Br,endingEnd:Br}}intervalChanged_(e,t,n){const i=this.parameterPositions;let r=e-2,o=e+1,a=i[r],c=i[o];if(a===void 0)switch(this.getSettings_().endingStart){case zr:r=e,a=2*t-n;break;case wc:r=i.length-2,a=t+i[r]-i[r+1];break;default:r=e,a=n}if(c===void 0)switch(this.getSettings_().endingEnd){case zr:o=e,c=2*n-t;break;case wc:o=1,c=n+i[1]-i[0];break;default:o=e-1,c=t}const l=(n-t)*.5,u=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(c-n),this._offsetPrev=r*u,this._offsetNext=o*u}interpolate_(e,t,n,i){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,u=this._offsetPrev,h=this._offsetNext,d=this._weightPrev,p=this._weightNext,f=(n-t)/(i-t),x=f*f,m=x*f,g=-d*m+2*d*x-d*f,y=(1+d)*m+(-1.5-2*d)*x+(-.5+d)*f+1,_=(-1-p)*m+(1.5+p)*x+.5*f,v=p*m-p*x;for(let I=0;I!==a;++I)r[I]=g*o[u+I]+y*o[l+I]+_*o[c+I]+v*o[h+I];return r}}class Em extends Sa{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,u=(n-t)/(i-t),h=1-u;for(let d=0;d!==a;++d)r[d]=o[l+d]*h+o[c+d]*u;return r}}class hv extends Sa{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class Hi{constructor(e,t,n,i){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Hr(t,this.TimeBufferType),this.values=Hr(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:Hr(e.times,Array),values:Hr(e.values,Array)};const i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new hv(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Em(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new uv(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case ia:t=this.InterpolantFactoryMethodDiscrete;break;case bc:t=this.InterpolantFactoryMethodLinear;break;case Eu:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return ia;case this.InterpolantFactoryMethodLinear:return bc;case this.InterpolantFactoryMethodSmooth:return Eu}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){const n=this.times,i=n.length;let r=0,o=i-1;for(;r!==i&&n[r]<e;)++r;for(;o!==-1&&n[o]>t;)--o;if(++o,r!==0||o!==i){r>=o&&(o=Math.max(o,1),r=o-1);const a=this.getValueSize();this.times=n.slice(r,o),this.values=this.values.slice(r*a,o*a)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,r=n.length;r===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==r;a++){const c=n[a];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,c),e=!1;break}if(o!==null&&o>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,c,o),e=!1;break}o=c}if(i!==void 0&&cv(i))for(let a=0,c=i.length;a!==c;++a){const l=i[a];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,l),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===Eu,r=e.length-1;let o=1;for(let a=1;a<r;++a){let c=!1;const l=e[a],u=e[a+1];if(l!==u&&(a!==1||l!==e[0]))if(i)c=!0;else{const h=a*n,d=h-n,p=h+n;for(let f=0;f!==n;++f){const x=t[h+f];if(x!==t[d+f]||x!==t[p+f]){c=!0;break}}}if(c){if(a!==o){e[o]=e[a];const h=a*n,d=o*n;for(let p=0;p!==n;++p)t[d+p]=t[h+p]}++o}}if(r>0){e[o]=e[r];for(let a=r*n,c=o*n,l=0;l!==n;++l)t[c+l]=t[a+l];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}Hi.prototype.TimeBufferType=Float32Array;Hi.prototype.ValueBufferType=Float32Array;Hi.prototype.DefaultInterpolation=bc;class co extends Hi{constructor(e,t,n){super(e,t,n)}}co.prototype.ValueTypeName="bool";co.prototype.ValueBufferType=Array;co.prototype.DefaultInterpolation=ia;co.prototype.InterpolantFactoryMethodLinear=void 0;co.prototype.InterpolantFactoryMethodSmooth=void 0;class md extends Hi{}md.prototype.ValueTypeName="color";class aa extends Hi{}aa.prototype.ValueTypeName="number";class dv extends Sa{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=(n-t)/(i-t);let l=e*a;for(let u=l+a;l!==u;l+=4)Qn.slerpFlat(r,0,o,l-a,o,l,c);return r}}class Ta extends Hi{InterpolantFactoryMethodLinear(e){return new dv(this.times,this.values,this.getValueSize(),e)}}Ta.prototype.ValueTypeName="quaternion";Ta.prototype.InterpolantFactoryMethodSmooth=void 0;class lo extends Hi{constructor(e,t,n){super(e,t,n)}}lo.prototype.ValueTypeName="string";lo.prototype.ValueBufferType=Array;lo.prototype.DefaultInterpolation=ia;lo.prototype.InterpolantFactoryMethodLinear=void 0;lo.prototype.InterpolantFactoryMethodSmooth=void 0;class ca extends Hi{}ca.prototype.ValueTypeName="vector";class la{constructor(e="",t=-1,n=[],i=zh){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=bi(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let o=0,a=n.length;o!==a;++o)t.push(DI(n[o]).scale(i));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let r=0,o=n.length;r!==o;++r)t.push(Hi.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const r=t.length,o=[];for(let a=0;a<r;a++){let c=[],l=[];c.push((a+r-1)%r,a,(a+1)%r),l.push(0,1,0);const u=lv(c);c=pf(c,1,u),l=pf(l,1,u),!i&&c[0]===0&&(c.push(r),l.push(l[0])),o.push(new aa(".morphTargetInfluences["+t[a].name+"]",c,l).scale(1/n))}return new this(e,-1,o)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const i={},r=/^([\w-]*?)([\d]+)$/;for(let a=0,c=e.length;a<c;a++){const l=e[a],u=l.name.match(r);if(u&&u.length>1){const h=u[1];let d=i[h];d||(i[h]=d=[]),d.push(l)}}const o=[];for(const a in i)o.push(this.CreateFromMorphTargetSequence(a,i[a],t,n));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(h,d,p,f,x){if(p.length!==0){const m=[],g=[];Nm(p,m,g,f),m.length!==0&&x.push(new h(d,m,g))}},i=[],r=e.name||"default",o=e.fps||30,a=e.blendMode;let c=e.length||-1;const l=e.hierarchy||[];for(let h=0;h<l.length;h++){const d=l[h].keys;if(!(!d||d.length===0))if(d[0].morphTargets){const p={};let f;for(f=0;f<d.length;f++)if(d[f].morphTargets)for(let x=0;x<d[f].morphTargets.length;x++)p[d[f].morphTargets[x]]=-1;for(const x in p){const m=[],g=[];for(let y=0;y!==d[f].morphTargets.length;++y){const _=d[f];m.push(_.time),g.push(_.morphTarget===x?1:0)}i.push(new aa(".morphTargetInfluence["+x+"]",m,g))}c=p.length*o}else{const p=".bones["+t[h].name+"]";n(ca,p+".position",d,"pos",i),n(Ta,p+".quaternion",d,"rot",i),n(ca,p+".scale",d,"scl",i)}}return i.length===0?null:new this(r,c,i,a)}resetDuration(){const e=this.tracks;let t=0;for(let n=0,i=e.length;n!==i;++n){const r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function LI(s){switch(s.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return aa;case"vector":case"vector2":case"vector3":case"vector4":return ca;case"color":return md;case"quaternion":return Ta;case"bool":case"boolean":return co;case"string":return lo}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+s)}function DI(s){if(s.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=LI(s.type);if(s.times===void 0){const t=[],n=[];Nm(s.keys,t,n,"value"),s.times=t,s.values=n}return e.parse!==void 0?e.parse(s):new e(s.name,s.times,s.values,s.interpolation)}const Rs={enabled:!1,files:{},add:function(s,e){this.enabled!==!1&&(this.files[s]=e)},get:function(s){if(this.enabled!==!1)return this.files[s]},remove:function(s){delete this.files[s]},clear:function(){this.files={}}};class gd{constructor(e,t,n){const i=this;let r=!1,o=0,a=0,c;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(u){a++,r===!1&&i.onStart!==void 0&&i.onStart(u,o,a),r=!0},this.itemEnd=function(u){o++,i.onProgress!==void 0&&i.onProgress(u,o,a),o===a&&(r=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(u){i.onError!==void 0&&i.onError(u)},this.resolveURL=function(u){return c?c(u):u},this.setURLModifier=function(u){return c=u,this},this.addHandler=function(u,h){return l.push(u,h),this},this.removeHandler=function(u){const h=l.indexOf(u);return h!==-1&&l.splice(h,2),this},this.getHandler=function(u){for(let h=0,d=l.length;h<d;h+=2){const p=l[h],f=l[h+1];if(p.global&&(p.lastIndex=0),p.test(u))return f}return null}}}const Cm=new gd;class Xn{constructor(e){this.manager=e!==void 0?e:Cm,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise(function(i,r){n.load(e,i,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}Xn.DEFAULT_MATERIAL_NAME="__DEFAULT";const As={};class UI extends Error{constructor(e,t){super(e),this.response=t}}class ts extends Xn{constructor(e){super(e)}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=Rs.get(e);if(r!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(r),this.manager.itemEnd(e)},0),r;if(As[e]!==void 0){As[e].push({onLoad:t,onProgress:n,onError:i});return}As[e]=[],As[e].push({onLoad:t,onProgress:n,onError:i});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,c=this.responseType;fetch(o).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;const u=As[e],h=l.body.getReader(),d=l.headers.get("X-File-Size")||l.headers.get("Content-Length"),p=d?parseInt(d):0,f=p!==0;let x=0;const m=new ReadableStream({start(g){y();function y(){h.read().then(({done:_,value:v})=>{if(_)g.close();else{x+=v.byteLength;const I=new ProgressEvent("progress",{lengthComputable:f,loaded:x,total:p});for(let T=0,w=u.length;T<w;T++){const C=u[T];C.onProgress&&C.onProgress(I)}g.enqueue(v),y()}},_=>{g.error(_)})}}});return new Response(m)}else throw new UI(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return l.json();default:if(a===void 0)return l.text();{const h=/charset="?([^;"\s]*)"?/i.exec(a),d=h&&h[1]?h[1].toLowerCase():void 0,p=new TextDecoder(d);return l.arrayBuffer().then(f=>p.decode(f))}}}).then(l=>{Rs.add(e,l);const u=As[e];delete As[e];for(let h=0,d=u.length;h<d;h++){const p=u[h];p.onLoad&&p.onLoad(l)}}).catch(l=>{const u=As[e];if(u===void 0)throw this.manager.itemError(e),l;delete As[e];for(let h=0,d=u.length;h<d;h++){const p=u[h];p.onError&&p.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class FI extends Xn{constructor(e){super(e)}load(e,t,n,i){const r=this,o=new ts(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{t(r.parse(JSON.parse(a)))}catch(c){i?i(c):console.error(c),r.manager.itemError(e)}},n,i)}parse(e){const t=[];for(let n=0;n<e.length;n++){const i=la.parse(e[n]);t.push(i)}return t}}class OI extends Xn{constructor(e){super(e)}load(e,t,n,i){const r=this,o=[],a=new Kc,c=new ts(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(r.withCredentials);let l=0;function u(h){c.load(e[h],function(d){const p=r.parse(d,!0);o[h]={width:p.width,height:p.height,format:p.format,mipmaps:p.mipmaps},l+=1,l===6&&(p.mipmapCount===1&&(a.minFilter=Ut),a.image=o,a.format=p.format,a.needsUpdate=!0,t&&t(a))},n,i)}if(Array.isArray(e))for(let h=0,d=e.length;h<d;++h)u(h);else c.load(e,function(h){const d=r.parse(h,!0);if(d.isCubemap){const p=d.mipmaps.length/d.mipmapCount;for(let f=0;f<p;f++){o[f]={mipmaps:[]};for(let x=0;x<d.mipmapCount;x++)o[f].mipmaps.push(d.mipmaps[f*d.mipmapCount+x]),o[f].format=d.format,o[f].width=d.width,o[f].height=d.height}a.image=o}else a.image.width=d.width,a.image.height=d.height,a.mipmaps=d.mipmaps;d.mipmapCount===1&&(a.minFilter=Ut),a.format=d.format,a.needsUpdate=!0,t&&t(a)},n,i);return a}}class Dc extends Xn{constructor(e){super(e)}load(e,t,n,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,o=Rs.get(e);if(o!==void 0)return r.manager.itemStart(e),setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0),o;const a=Cc("img");function c(){u(),Rs.add(e,this),t&&t(this),r.manager.itemEnd(e)}function l(h){u(),i&&i(h),r.manager.itemError(e),r.manager.itemEnd(e)}function u(){a.removeEventListener("load",c,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",c,!1),a.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),r.manager.itemStart(e),a.src=e,a}}class VI extends Xn{constructor(e){super(e)}load(e,t,n,i){const r=new io;r.colorSpace=kn;const o=new Dc(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let a=0;function c(l){o.load(e[l],function(u){r.images[l]=u,a++,a===6&&(r.needsUpdate=!0,t&&t(r))},void 0,i)}for(let l=0;l<e.length;++l)c(l);return r}}class pv extends Xn{constructor(e){super(e)}load(e,t,n,i){const r=this,o=new Oi,a=new ts(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(r.withCredentials),a.load(e,function(c){let l;try{l=r.parse(c)}catch(u){if(i!==void 0)i(u);else{console.error(u);return}}l.image!==void 0?o.image=l.image:l.data!==void 0&&(o.image.width=l.width,o.image.height=l.height,o.image.data=l.data),o.wrapS=l.wrapS!==void 0?l.wrapS:Si,o.wrapT=l.wrapT!==void 0?l.wrapT:Si,o.magFilter=l.magFilter!==void 0?l.magFilter:Ut,o.minFilter=l.minFilter!==void 0?l.minFilter:Ut,o.anisotropy=l.anisotropy!==void 0?l.anisotropy:1,l.colorSpace!==void 0&&(o.colorSpace=l.colorSpace),l.flipY!==void 0&&(o.flipY=l.flipY),l.format!==void 0&&(o.format=l.format),l.type!==void 0&&(o.type=l.type),l.mipmaps!==void 0&&(o.mipmaps=l.mipmaps,o.minFilter=Jn),l.mipmapCount===1&&(o.minFilter=Ut),l.generateMipmaps!==void 0&&(o.generateMipmaps=l.generateMipmaps),o.needsUpdate=!0,t&&t(o,l)},n,i),o}}class fv extends Xn{constructor(e){super(e)}load(e,t,n,i){const r=new Xt,o=new Dc(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){r.image=a,r.needsUpdate=!0,t!==void 0&&t(r)},n,i),r}}class pr extends yt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new _e(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}class xd extends pr{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(yt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new _e(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const Ip=new Fe,Rx=new E,Ix=new E;class Rm{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new J(512,512),this.map=null,this.mapPass=null,this.matrix=new Fe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new ga,this._frameExtents=new J(1,1),this._viewportCount=1,this._viewports=[new st(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;Rx.setFromMatrixPosition(e.matrixWorld),t.position.copy(Rx),Ix.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Ix),t.updateMatrixWorld(),Ip.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ip),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Ip)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class BI extends Rm{constructor(){super(new hn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=ra*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,r=e.distance||t.far;(n!==t.fov||i!==t.aspect||r!==t.far)&&(t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class il extends pr{constructor(e,t,n=0,i=Math.PI/3,r=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(yt.DEFAULT_UP),this.updateMatrix(),this.target=new yt,this.distance=n,this.angle=i,this.penumbra=r,this.decay=o,this.map=null,this.shadow=new BI}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const Px=new Fe,ka=new E,Pp=new E;class zI extends Rm{constructor(){super(new hn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new J(4,2),this._viewportCount=6,this._viewports=[new st(2,1,1,1),new st(0,1,1,1),new st(3,1,1,1),new st(1,1,1,1),new st(3,0,1,1),new st(1,0,1,1)],this._cubeDirections=[new E(1,0,0),new E(-1,0,0),new E(0,0,1),new E(0,0,-1),new E(0,1,0),new E(0,-1,0)],this._cubeUps=[new E(0,1,0),new E(0,1,0),new E(0,1,0),new E(0,1,0),new E(0,0,1),new E(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,i=this.matrix,r=e.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),ka.setFromMatrixPosition(e.matrixWorld),n.position.copy(ka),Pp.copy(n.position),Pp.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(Pp),n.updateMatrixWorld(),i.makeTranslation(-ka.x,-ka.y,-ka.z),Px.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Px)}}class _d extends pr{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new zI}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class kI extends Rm{constructor(){super(new ro(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class yd extends pr{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(yt.DEFAULT_UP),this.updateMatrix(),this.target=new yt,this.shadow=new kI}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class vd extends pr{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Im extends pr{constructor(e,t,n=10,i=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class mv{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new E)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const n=e.x,i=e.y,r=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.282095),t.addScaledVector(o[1],.488603*i),t.addScaledVector(o[2],.488603*r),t.addScaledVector(o[3],.488603*n),t.addScaledVector(o[4],1.092548*(n*i)),t.addScaledVector(o[5],1.092548*(i*r)),t.addScaledVector(o[6],.315392*(3*r*r-1)),t.addScaledVector(o[7],1.092548*(n*r)),t.addScaledVector(o[8],.546274*(n*n-i*i)),t}getIrradianceAt(e,t){const n=e.x,i=e.y,r=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.886227),t.addScaledVector(o[1],2*.511664*i),t.addScaledVector(o[2],2*.511664*r),t.addScaledVector(o[3],2*.511664*n),t.addScaledVector(o[4],2*.429043*n*i),t.addScaledVector(o[5],2*.429043*i*r),t.addScaledVector(o[6],.743125*r*r-.247708),t.addScaledVector(o[7],2*.429043*n*r),t.addScaledVector(o[8],.429043*(n*n-i*i)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].fromArray(e,t+i*3);return this}toArray(e=[],t=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].toArray(e,t+i*3);return e}static getBasisAt(e,t){const n=e.x,i=e.y,r=e.z;t[0]=.282095,t[1]=.488603*i,t[2]=.488603*r,t[3]=.488603*n,t[4]=1.092548*n*i,t[5]=1.092548*i*r,t[6]=.315392*(3*r*r-1),t[7]=1.092548*n*r,t[8]=.546274*(n*n-i*i)}}class Pm extends pr{constructor(e=new mv,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class sl extends Xn{constructor(e){super(e),this.textures={}}load(e,t,n,i){const r=this,o=new ts(r.manager);o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,function(a){try{t(r.parse(JSON.parse(a)))}catch(c){i?i(c):console.error(c),r.manager.itemError(e)}},n,i)}parse(e){const t=this.textures;function n(r){return t[r]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",r),t[r]}const i=this.createMaterialFromType(e.type);if(e.uuid!==void 0&&(i.uuid=e.uuid),e.name!==void 0&&(i.name=e.name),e.color!==void 0&&i.color!==void 0&&i.color.setHex(e.color),e.roughness!==void 0&&(i.roughness=e.roughness),e.metalness!==void 0&&(i.metalness=e.metalness),e.sheen!==void 0&&(i.sheen=e.sheen),e.sheenColor!==void 0&&(i.sheenColor=new _e().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(i.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&i.emissive!==void 0&&i.emissive.setHex(e.emissive),e.specular!==void 0&&i.specular!==void 0&&i.specular.setHex(e.specular),e.specularIntensity!==void 0&&(i.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&i.specularColor!==void 0&&i.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(i.shininess=e.shininess),e.clearcoat!==void 0&&(i.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(i.dispersion=e.dispersion),e.iridescence!==void 0&&(i.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(i.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(i.transmission=e.transmission),e.thickness!==void 0&&(i.thickness=e.thickness),e.attenuationDistance!==void 0&&(i.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&i.attenuationColor!==void 0&&i.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(i.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(i.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(i.fog=e.fog),e.flatShading!==void 0&&(i.flatShading=e.flatShading),e.blending!==void 0&&(i.blending=e.blending),e.combine!==void 0&&(i.combine=e.combine),e.side!==void 0&&(i.side=e.side),e.shadowSide!==void 0&&(i.shadowSide=e.shadowSide),e.opacity!==void 0&&(i.opacity=e.opacity),e.transparent!==void 0&&(i.transparent=e.transparent),e.alphaTest!==void 0&&(i.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(i.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(i.depthFunc=e.depthFunc),e.depthTest!==void 0&&(i.depthTest=e.depthTest),e.depthWrite!==void 0&&(i.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(i.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(i.blendSrc=e.blendSrc),e.blendDst!==void 0&&(i.blendDst=e.blendDst),e.blendEquation!==void 0&&(i.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(i.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(i.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(i.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&i.blendColor!==void 0&&i.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(i.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(i.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(i.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(i.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(i.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(i.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(i.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(i.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(i.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(i.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(i.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(i.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(i.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(i.rotation=e.rotation),e.linewidth!==void 0&&(i.linewidth=e.linewidth),e.dashSize!==void 0&&(i.dashSize=e.dashSize),e.gapSize!==void 0&&(i.gapSize=e.gapSize),e.scale!==void 0&&(i.scale=e.scale),e.polygonOffset!==void 0&&(i.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(i.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(i.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(i.dithering=e.dithering),e.alphaToCoverage!==void 0&&(i.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(i.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(i.forceSinglePass=e.forceSinglePass),e.visible!==void 0&&(i.visible=e.visible),e.toneMapped!==void 0&&(i.toneMapped=e.toneMapped),e.userData!==void 0&&(i.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?i.vertexColors=e.vertexColors>0:i.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const r in e.uniforms){const o=e.uniforms[r];switch(i.uniforms[r]={},o.type){case"t":i.uniforms[r].value=n(o.value);break;case"c":i.uniforms[r].value=new _e().setHex(o.value);break;case"v2":i.uniforms[r].value=new J().fromArray(o.value);break;case"v3":i.uniforms[r].value=new E().fromArray(o.value);break;case"v4":i.uniforms[r].value=new st().fromArray(o.value);break;case"m3":i.uniforms[r].value=new Ke().fromArray(o.value);break;case"m4":i.uniforms[r].value=new Fe().fromArray(o.value);break;default:i.uniforms[r].value=o.value}}if(e.defines!==void 0&&(i.defines=e.defines),e.vertexShader!==void 0&&(i.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(i.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(i.glslVersion=e.glslVersion),e.extensions!==void 0)for(const r in e.extensions)i.extensions[r]=e.extensions[r];if(e.lights!==void 0&&(i.lights=e.lights),e.clipping!==void 0&&(i.clipping=e.clipping),e.size!==void 0&&(i.size=e.size),e.sizeAttenuation!==void 0&&(i.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(i.map=n(e.map)),e.matcap!==void 0&&(i.matcap=n(e.matcap)),e.alphaMap!==void 0&&(i.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(i.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(i.bumpScale=e.bumpScale),e.normalMap!==void 0&&(i.normalMap=n(e.normalMap)),e.normalMapType!==void 0&&(i.normalMapType=e.normalMapType),e.normalScale!==void 0){let r=e.normalScale;Array.isArray(r)===!1&&(r=[r,r]),i.normalScale=new J().fromArray(r)}return e.displacementMap!==void 0&&(i.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(i.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(i.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(i.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(i.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(i.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(i.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(i.specularMap=n(e.specularMap)),e.specularIntensityMap!==void 0&&(i.specularIntensityMap=n(e.specularIntensityMap)),e.specularColorMap!==void 0&&(i.specularColorMap=n(e.specularColorMap)),e.envMap!==void 0&&(i.envMap=n(e.envMap)),e.envMapRotation!==void 0&&i.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(i.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(i.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(i.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(i.lightMap=n(e.lightMap)),e.lightMapIntensity!==void 0&&(i.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(i.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(i.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(i.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(i.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(i.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(i.clearcoatNormalScale=new J().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(i.iridescenceMap=n(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(i.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(i.transmissionMap=n(e.transmissionMap)),e.thicknessMap!==void 0&&(i.thicknessMap=n(e.thicknessMap)),e.anisotropyMap!==void 0&&(i.anisotropyMap=n(e.anisotropyMap)),e.sheenColorMap!==void 0&&(i.sheenColorMap=n(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(i.sheenRoughnessMap=n(e.sheenRoughnessMap)),i}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return sl.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:ld,SpriteMaterial:Zc,RawShaderMaterial:bm,ShaderMaterial:ki,PointsMaterial:ya,MeshPhysicalMaterial:ud,MeshStandardMaterial:nl,MeshPhongMaterial:hd,MeshToonMaterial:wm,MeshNormalMaterial:dd,MeshLambertMaterial:pd,MeshDepthMaterial:Yh,MeshDistanceMaterial:sm,MeshBasicMaterial:ss,MeshMatcapMaterial:Am,LineDashedMaterial:fd,LineBasicMaterial:Fn,Material:mn};return new t[e]}}class lh{static decodeText(e){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let n=0,i=e.length;n<i;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class Lm extends at{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class gv extends Xn{constructor(e){super(e)}load(e,t,n,i){const r=this,o=new ts(r.manager);o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,function(a){try{t(r.parse(JSON.parse(a)))}catch(c){i?i(c):console.error(c),r.manager.itemError(e)}},n,i)}parse(e){const t={},n={};function i(p,f){if(t[f]!==void 0)return t[f];const m=p.interleavedBuffers[f],g=r(p,m.buffer),y=ko(m.type,g),_=new _a(y,m.stride);return _.uuid=m.uuid,t[f]=_,_}function r(p,f){if(n[f]!==void 0)return n[f];const m=p.arrayBuffers[f],g=new Uint32Array(m).buffer;return n[f]=g,g}const o=e.isInstancedBufferGeometry?new Lm:new at,a=e.data.index;if(a!==void 0){const p=ko(a.type,a.array);o.setIndex(new At(p,1))}const c=e.data.attributes;for(const p in c){const f=c[p];let x;if(f.isInterleavedBufferAttribute){const m=i(e.data,f.data);x=new Ds(m,f.itemSize,f.offset,f.normalized)}else{const m=ko(f.type,f.array),g=f.isInstancedBufferAttribute?Us:At;x=new g(m,f.itemSize,f.normalized)}f.name!==void 0&&(x.name=f.name),f.usage!==void 0&&x.setUsage(f.usage),o.setAttribute(p,x)}const l=e.data.morphAttributes;if(l)for(const p in l){const f=l[p],x=[];for(let m=0,g=f.length;m<g;m++){const y=f[m];let _;if(y.isInterleavedBufferAttribute){const v=i(e.data,y.data);_=new Ds(v,y.itemSize,y.offset,y.normalized)}else{const v=ko(y.type,y.array);_=new At(v,y.itemSize,y.normalized)}y.name!==void 0&&(_.name=y.name),x.push(_)}o.morphAttributes[p]=x}e.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);const h=e.data.groups||e.data.drawcalls||e.data.offsets;if(h!==void 0)for(let p=0,f=h.length;p!==f;++p){const x=h[p];o.addGroup(x.start,x.count,x.materialIndex)}const d=e.data.boundingSphere;if(d!==void 0){const p=new E;d.center!==void 0&&p.fromArray(d.center),o.boundingSphere=new Dn(p,d.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}}class xv extends Xn{constructor(e){super(e)}load(e,t,n,i){const r=this,o=this.path===""?lh.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||o;const a=new ts(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){let l=null;try{l=JSON.parse(c)}catch(h){i!==void 0&&i(h),console.error("THREE:ObjectLoader: Can't parse "+e+".",h.message);return}const u=l.metadata;if(u===void 0||u.type===void 0||u.type.toLowerCase()==="geometry"){i!==void 0&&i(new Error("THREE.ObjectLoader: Can't load "+e)),console.error("THREE.ObjectLoader: Can't load "+e);return}r.parse(l,t)},n,i)}async loadAsync(e,t){const n=this,i=this.path===""?lh.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||i;const r=new ts(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials);const o=await r.loadAsync(e,t),a=JSON.parse(o),c=a.metadata;if(c===void 0||c.type===void 0||c.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await n.parseAsync(a)}parse(e,t){const n=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,i),o=this.parseImages(e.images,function(){t!==void 0&&t(l)}),a=this.parseTextures(e.textures,o),c=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,r,c,a,n),u=this.parseSkeletons(e.skeletons,l);if(this.bindSkeletons(l,u),this.bindLightTargets(l),t!==void 0){let h=!1;for(const d in o)if(o[d].data instanceof HTMLImageElement){h=!0;break}h===!1&&t(l)}return l}async parseAsync(e){const t=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),i=this.parseGeometries(e.geometries,n),r=await this.parseImagesAsync(e.images),o=this.parseTextures(e.textures,r),a=this.parseMaterials(e.materials,o),c=this.parseObject(e.object,i,a,o,t),l=this.parseSkeletons(e.skeletons,c);return this.bindSkeletons(c,l),this.bindLightTargets(c),c}parseShapes(e){const t={};if(e!==void 0)for(let n=0,i=e.length;n<i;n++){const r=new er().fromJSON(e[n]);t[r.uuid]=r}return t}parseSkeletons(e,t){const n={},i={};if(t.traverse(function(r){r.isBone&&(i[r.uuid]=r)}),e!==void 0)for(let r=0,o=e.length;r<o;r++){const a=new Jc().fromJSON(e[r],i);n[a.uuid]=a}return n}parseGeometries(e,t){const n={};if(e!==void 0){const i=new gv;for(let r=0,o=e.length;r<o;r++){let a;const c=e[r];switch(c.type){case"BufferGeometry":case"InstancedBufferGeometry":a=i.parse(c);break;default:c.type in Cx?a=Cx[c.type].fromJSON(c,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${c.type}"`)}a.uuid=c.uuid,c.name!==void 0&&(a.name=c.name),c.userData!==void 0&&(a.userData=c.userData),n[c.uuid]=a}}return n}parseMaterials(e,t){const n={},i={};if(e!==void 0){const r=new sl;r.setTextures(t);for(let o=0,a=e.length;o<a;o++){const c=e[o];n[c.uuid]===void 0&&(n[c.uuid]=r.parse(c)),i[c.uuid]=n[c.uuid]}}return i}parseAnimations(e){const t={};if(e!==void 0)for(let n=0;n<e.length;n++){const i=e[n],r=la.parse(i);t[r.uuid]=r}return t}parseImages(e,t){const n=this,i={};let r;function o(c){return n.manager.itemStart(c),r.load(c,function(){n.manager.itemEnd(c)},void 0,function(){n.manager.itemError(c),n.manager.itemEnd(c)})}function a(c){if(typeof c=="string"){const l=c,u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(l)?l:n.resourcePath+l;return o(u)}else return c.data?{data:ko(c.type,c.data),width:c.width,height:c.height}:null}if(e!==void 0&&e.length>0){const c=new gd(t);r=new Dc(c),r.setCrossOrigin(this.crossOrigin);for(let l=0,u=e.length;l<u;l++){const h=e[l],d=h.url;if(Array.isArray(d)){const p=[];for(let f=0,x=d.length;f<x;f++){const m=d[f],g=a(m);g!==null&&(g instanceof HTMLImageElement?p.push(g):p.push(new Oi(g.data,g.width,g.height)))}i[h.uuid]=new Js(p)}else{const p=a(h.url);i[h.uuid]=new Js(p)}}}return i}async parseImagesAsync(e){const t=this,n={};let i;async function r(o){if(typeof o=="string"){const a=o,c=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(a)?a:t.resourcePath+a;return await i.loadAsync(c)}else return o.data?{data:ko(o.type,o.data),width:o.width,height:o.height}:null}if(e!==void 0&&e.length>0){i=new Dc(this.manager),i.setCrossOrigin(this.crossOrigin);for(let o=0,a=e.length;o<a;o++){const c=e[o],l=c.url;if(Array.isArray(l)){const u=[];for(let h=0,d=l.length;h<d;h++){const p=l[h],f=await r(p);f!==null&&(f instanceof HTMLImageElement?u.push(f):u.push(new Oi(f.data,f.width,f.height)))}n[c.uuid]=new Js(u)}else{const u=await r(c.url);n[c.uuid]=new Js(u)}}}return n}parseTextures(e,t){function n(r,o){return typeof r=="number"?r:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",r),o[r])}const i={};if(e!==void 0)for(let r=0,o=e.length;r<o;r++){const a=e[r];a.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',a.uuid),t[a.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",a.image);const c=t[a.image],l=c.data;let u;Array.isArray(l)?(u=new io,l.length===6&&(u.needsUpdate=!0)):(l&&l.data?u=new Oi:u=new Xt,l&&(u.needsUpdate=!0)),u.source=c,u.uuid=a.uuid,a.name!==void 0&&(u.name=a.name),a.mapping!==void 0&&(u.mapping=n(a.mapping,GI)),a.channel!==void 0&&(u.channel=a.channel),a.offset!==void 0&&u.offset.fromArray(a.offset),a.repeat!==void 0&&u.repeat.fromArray(a.repeat),a.center!==void 0&&u.center.fromArray(a.center),a.rotation!==void 0&&(u.rotation=a.rotation),a.wrap!==void 0&&(u.wrapS=n(a.wrap[0],Lx),u.wrapT=n(a.wrap[1],Lx)),a.format!==void 0&&(u.format=a.format),a.internalFormat!==void 0&&(u.internalFormat=a.internalFormat),a.type!==void 0&&(u.type=a.type),a.colorSpace!==void 0&&(u.colorSpace=a.colorSpace),a.minFilter!==void 0&&(u.minFilter=n(a.minFilter,Dx)),a.magFilter!==void 0&&(u.magFilter=n(a.magFilter,Dx)),a.anisotropy!==void 0&&(u.anisotropy=a.anisotropy),a.flipY!==void 0&&(u.flipY=a.flipY),a.generateMipmaps!==void 0&&(u.generateMipmaps=a.generateMipmaps),a.premultiplyAlpha!==void 0&&(u.premultiplyAlpha=a.premultiplyAlpha),a.unpackAlignment!==void 0&&(u.unpackAlignment=a.unpackAlignment),a.compareFunction!==void 0&&(u.compareFunction=a.compareFunction),a.userData!==void 0&&(u.userData=a.userData),i[a.uuid]=u}return i}parseObject(e,t,n,i,r){let o;function a(d){return t[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",d),t[d]}function c(d){if(d!==void 0){if(Array.isArray(d)){const p=[];for(let f=0,x=d.length;f<x;f++){const m=d[f];n[m]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",m),p.push(n[m])}return p}return n[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",d),n[d]}}function l(d){return i[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",d),i[d]}let u,h;switch(e.type){case"Scene":o=new Jh,e.background!==void 0&&(Number.isInteger(e.background)?o.background=new _e(e.background):o.background=l(e.background)),e.environment!==void 0&&(o.environment=l(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?o.fog=new om(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(o.fog=new Zh(e.fog.color,e.fog.density)),e.fog.name!==""&&(o.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(o.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(o.backgroundIntensity=e.backgroundIntensity),e.backgroundRotation!==void 0&&o.backgroundRotation.fromArray(e.backgroundRotation),e.environmentIntensity!==void 0&&(o.environmentIntensity=e.environmentIntensity),e.environmentRotation!==void 0&&o.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":o=new hn(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(o.focus=e.focus),e.zoom!==void 0&&(o.zoom=e.zoom),e.filmGauge!==void 0&&(o.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(o.filmOffset=e.filmOffset),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"OrthographicCamera":o=new ro(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(o.zoom=e.zoom),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"AmbientLight":o=new vd(e.color,e.intensity);break;case"DirectionalLight":o=new yd(e.color,e.intensity),o.target=e.target||"";break;case"PointLight":o=new _d(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":o=new Im(e.color,e.intensity,e.width,e.height);break;case"SpotLight":o=new il(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),o.target=e.target||"";break;case"HemisphereLight":o=new xd(e.color,e.groundColor,e.intensity);break;case"LightProbe":o=new Pm().fromJSON(e);break;case"SkinnedMesh":u=a(e.geometry),h=c(e.material),o=new lm(u,h),e.bindMode!==void 0&&(o.bindMode=e.bindMode),e.bindMatrix!==void 0&&o.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(o.skeleton=e.skeleton);break;case"Mesh":u=a(e.geometry),h=c(e.material),o=new kt(u,h);break;case"InstancedMesh":u=a(e.geometry),h=c(e.material);const d=e.count,p=e.instanceMatrix,f=e.instanceColor;o=new um(u,h,d),o.instanceMatrix=new Us(new Float32Array(p.array),16),f!==void 0&&(o.instanceColor=new Us(new Float32Array(f.array),f.itemSize));break;case"BatchedMesh":u=a(e.geometry),h=c(e.material),o=new hm(e.maxInstanceCount,e.maxVertexCount,e.maxIndexCount,h),o.geometry=u,o.perObjectFrustumCulled=e.perObjectFrustumCulled,o.sortObjects=e.sortObjects,o._drawRanges=e.drawRanges,o._reservedRanges=e.reservedRanges,o._visibility=e.visibility,o._active=e.active,o._bounds=e.bounds.map(x=>{const m=new Hn;m.min.fromArray(x.boxMin),m.max.fromArray(x.boxMax);const g=new Dn;return g.radius=x.sphereRadius,g.center.fromArray(x.sphereCenter),{boxInitialized:x.boxInitialized,box:m,sphereInitialized:x.sphereInitialized,sphere:g}}),o._maxInstanceCount=e.maxInstanceCount,o._maxVertexCount=e.maxVertexCount,o._maxIndexCount=e.maxIndexCount,o._geometryInitialized=e.geometryInitialized,o._geometryCount=e.geometryCount,o._matricesTexture=l(e.matricesTexture.uuid),e.colorsTexture!==void 0&&(o._colorsTexture=l(e.colorsTexture.uuid));break;case"LOD":o=new cm;break;case"Line":o=new Fs(a(e.geometry),c(e.material));break;case"LineLoop":o=new dm(a(e.geometry),c(e.material));break;case"LineSegments":o=new rs(a(e.geometry),c(e.material));break;case"PointCloud":case"Points":o=new pm(a(e.geometry),c(e.material));break;case"Sprite":o=new am(c(e.material));break;case"Group":o=new Gr;break;case"Bone":o=new Kh;break;default:o=new yt}if(o.uuid=e.uuid,e.name!==void 0&&(o.name=e.name),e.matrix!==void 0?(o.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(o.matrixAutoUpdate=e.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(e.position!==void 0&&o.position.fromArray(e.position),e.rotation!==void 0&&o.rotation.fromArray(e.rotation),e.quaternion!==void 0&&o.quaternion.fromArray(e.quaternion),e.scale!==void 0&&o.scale.fromArray(e.scale)),e.up!==void 0&&o.up.fromArray(e.up),e.castShadow!==void 0&&(o.castShadow=e.castShadow),e.receiveShadow!==void 0&&(o.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(o.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(o.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(o.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(o.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&o.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(o.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(o.visible=e.visible),e.frustumCulled!==void 0&&(o.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(o.renderOrder=e.renderOrder),e.userData!==void 0&&(o.userData=e.userData),e.layers!==void 0&&(o.layers.mask=e.layers),e.children!==void 0){const d=e.children;for(let p=0;p<d.length;p++)o.add(this.parseObject(d[p],t,n,i,r))}if(e.animations!==void 0){const d=e.animations;for(let p=0;p<d.length;p++){const f=d[p];o.animations.push(r[f])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(o.autoUpdate=e.autoUpdate);const d=e.levels;for(let p=0;p<d.length;p++){const f=d[p],x=o.getObjectByProperty("uuid",f.object);x!==void 0&&o.addLevel(x,f.distance,f.hysteresis)}}return o}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(n){if(n.isSkinnedMesh===!0&&n.skeleton!==void 0){const i=t[n.skeleton];i===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",n.skeleton):n.bind(i,n.bindMatrix)}})}bindLightTargets(e){e.traverse(function(t){if(t.isDirectionalLight||t.isSpotLight){const n=t.target,i=e.getObjectByProperty("uuid",n);i!==void 0?t.target=i:t.target=new yt}})}}const GI={UVMapping:Ih,CubeReflectionMapping:wi,CubeRefractionMapping:Vi,EquirectangularReflectionMapping:ir,EquirectangularRefractionMapping:sr,CubeUVReflectionMapping:hr},Lx={RepeatWrapping:rr,ClampToEdgeWrapping:Si,MirroredRepeatWrapping:ea},Dx={NearestFilter:Qt,NearestMipmapNearestFilter:Ph,NearestMipmapLinearFilter:Cs,LinearFilter:Ut,LinearMipmapNearestFilter:js,LinearMipmapLinearFilter:Jn};class _v extends Xn{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,o=Rs.get(e);if(o!==void 0){if(r.manager.itemStart(e),o.then){o.then(l=>{t&&t(l),r.manager.itemEnd(e)}).catch(l=>{i&&i(l)});return}return setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0),o}const a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader;const c=fetch(e,a).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(l){return Rs.add(e,l),t&&t(l),r.manager.itemEnd(e),l}).catch(function(l){i&&i(l),Rs.remove(e),r.manager.itemError(e),r.manager.itemEnd(e)});Rs.add(e,c),r.manager.itemStart(e)}}let lu;class Md{static getContext(){return lu===void 0&&(lu=new(window.AudioContext||window.webkitAudioContext)),lu}static setContext(e){lu=e}}class yv extends Xn{constructor(e){super(e)}load(e,t,n,i){const r=this,o=new ts(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(c){try{const l=c.slice(0);Md.getContext().decodeAudioData(l,function(h){t(h)}).catch(a)}catch(l){a(l)}},n,i);function a(c){i?i(c):console.error(c),r.manager.itemError(e)}}}const Ux=new Fe,Fx=new Fe,Nr=new Fe;class Dm{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new hn,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new hn,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,Nr.copy(e.projectionMatrix);const i=t.eyeSep/2,r=i*t.near/t.focus,o=t.near*Math.tan(qr*t.fov*.5)/t.zoom;let a,c;Fx.elements[12]=-i,Ux.elements[12]=i,a=-o*t.aspect+r,c=o*t.aspect+r,Nr.elements[0]=2*t.near/(c-a),Nr.elements[8]=(c+a)/(c-a),this.cameraL.projectionMatrix.copy(Nr),a=-o*t.aspect-r,c=o*t.aspect-r,Nr.elements[0]=2*t.near/(c-a),Nr.elements[8]=(c+a)/(c-a),this.cameraR.projectionMatrix.copy(Nr)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(Fx),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(Ux)}}class Um{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Ox(),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=Ox();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function Ox(){return performance.now()}const as=new E,Vx=new Qn,HI=new E,Er=new E;let vv=class extends yt{constructor(){super(),this.type="AudioListener",this.context=Md.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Um}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(as,Vx,HI),!(!Number.isFinite(as.x)||!Number.isFinite(as.y)||!Number.isFinite(as.z)))if(Er.set(0,0,-1).applyQuaternion(Vx),t.positionX){const i=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(as.x,i),t.positionY.linearRampToValueAtTime(as.y,i),t.positionZ.linearRampToValueAtTime(as.z,i),t.forwardX.linearRampToValueAtTime(Er.x,i),t.forwardY.linearRampToValueAtTime(Er.y,i),t.forwardZ.linearRampToValueAtTime(Er.z,i),t.upX.linearRampToValueAtTime(n.x,i),t.upY.linearRampToValueAtTime(n.y,i),t.upZ.linearRampToValueAtTime(n.z,i)}else t.setPosition(as.x,as.y,as.z),t.setOrientation(Er.x,Er.y,Er.z,n.x,n.y,n.z)}};class Fm extends yt{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||(this.buffer?this.buffer.duration:Number.MAX_VALUE))),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(e=0){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,this.isPlaying===!0&&this.source.detune!==void 0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}}const Cr=new E,Bx=new Qn,WI=new E,Rr=new E;class Mv extends Fm{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,n){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=n,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(Cr,Bx,WI),Rr.set(0,0,1).applyQuaternion(Bx);const t=this.panner;if(t.positionX){const n=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Cr.x,n),t.positionY.linearRampToValueAtTime(Cr.y,n),t.positionZ.linearRampToValueAtTime(Cr.z,n),t.orientationX.linearRampToValueAtTime(Rr.x,n),t.orientationY.linearRampToValueAtTime(Rr.y,n),t.orientationZ.linearRampToValueAtTime(Rr.z,n)}else t.setPosition(Cr.x,Cr.y,Cr.z),t.setOrientation(Rr.x,Rr.y,Rr.z)}}class XI{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;const t=this.getFrequencyData();for(let n=0;n<t.length;n++)e+=t[n];return e/t.length}}class Sv{constructor(e,t,n){this.binding=e,this.valueSize=n;let i,r,o;switch(t){case"quaternion":i=this._slerp,r=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:i=this._lerp,r=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const n=this.buffer,i=this.valueSize,r=e*i+i;let o=this.cumulativeWeight;if(o===0){for(let a=0;a!==i;++a)n[r+a]=n[a];o=t}else{o+=t;const a=t/o;this._mixBufferRegion(n,r,0,a,i)}this.cumulativeWeight=o}accumulateAdditive(e){const t=this.buffer,n=this.valueSize,i=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,n=this.buffer,i=e*t+t,r=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const c=t*this._origIndex;this._mixBufferRegion(n,i,c,1-r,t)}o>0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let c=t,l=t+t;c!==l;++c)if(n[c]!==n[c+t]){a.setValue(n,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let r=n,o=i;r!==o;++r)t[r]=t[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,i,r){if(i>=.5)for(let o=0;o!==r;++o)e[t+o]=e[n+o]}_slerp(e,t,n,i){Qn.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){const o=this._workIndex*r;Qn.multiplyQuaternionsFlat(e,o,e,t,e,n),Qn.slerpFlat(e,t,e,t,e,o,i)}_lerp(e,t,n,i,r){const o=1-i;for(let a=0;a!==r;++a){const c=t+a;e[c]=e[c]*o+e[n+a]*i}}_lerpAdditive(e,t,n,i,r){for(let o=0;o!==r;++o){const a=t+o;e[a]=e[a]+e[n+o]*i}}}const Om="\\[\\]\\.:\\/",qI=new RegExp("["+Om+"]","g"),Vm="[^"+Om+"]",$I="[^"+Om.replace("\\.","")+"]",YI=/((?:WC+[\/:])*)/.source.replace("WC",Vm),ZI=/(WCOD+)?/.source.replace("WCOD",$I),JI=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Vm),KI=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Vm),jI=new RegExp("^"+YI+ZI+JI+KI+"$"),QI=["material","materials","bones","map"];class eP{constructor(e,t,n){const i=n||St.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class St{constructor(e,t,n){this.path=t,this.parsedPath=n||St.parseTrackName(t),this.node=St.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new St.Composite(e,t,n):new St(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(qI,"")}static parseTrackName(e){const t=jI.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const r=n.nodeName.substring(i+1);QI.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(r,o){for(let a=0;a<r.length;a++){const c=r[a];if(!o&&(c.name===t||c.uuid===t))return c;if(o&&c.userData&&c.userData.name===t)return c;const l=n(c.children,o);if(l)return l}return null},i=n(e.children);if(i)return i;{const r=n(e.children,!0);if(r)return r}}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,i=t.propertyName;let r=t.propertyIndex;if(e||(e=St.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let u=0;u<e.length;u++)if(e[u].name===l){l=u;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(l!==void 0){if(e[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}const o=e[i];if(o===void 0){const l=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+i+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=r}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}St.Composite=eP;St.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};St.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};St.prototype.GetterByBindingType=[St.prototype._getValue_direct,St.prototype._getValue_array,St.prototype._getValue_arrayElement,St.prototype._getValue_toArray];St.prototype.SetterByBindingTypeAndVersioning=[[St.prototype._setValue_direct,St.prototype._setValue_direct_setNeedsUpdate,St.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[St.prototype._setValue_array,St.prototype._setValue_array_setNeedsUpdate,St.prototype._setValue_array_setMatrixWorldNeedsUpdate],[St.prototype._setValue_arrayElement,St.prototype._setValue_arrayElement_setNeedsUpdate,St.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[St.prototype._setValue_fromArray,St.prototype._setValue_fromArray_setNeedsUpdate,St.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class tP{constructor(){this.isAnimationObjectGroup=!0,this.uuid=bi(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let n=0,i=arguments.length;n!==i;++n)e[arguments[n].uuid]=n;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){const e=this._objects,t=this._indicesByUUID,n=this._paths,i=this._parsedPaths,r=this._bindings,o=r.length;let a,c=e.length,l=this.nCachedObjects_;for(let u=0,h=arguments.length;u!==h;++u){const d=arguments[u],p=d.uuid;let f=t[p];if(f===void 0){f=c++,t[p]=f,e.push(d);for(let x=0,m=o;x!==m;++x)r[x].push(new St(d,n[x],i[x]))}else if(f<l){a=e[f];const x=--l,m=e[x];t[m.uuid]=f,e[f]=m,t[p]=x,e[x]=d;for(let g=0,y=o;g!==y;++g){const _=r[g],v=_[x];let I=_[f];_[f]=v,I===void 0&&(I=new St(d,n[g],i[g])),_[x]=I}}else e[f]!==a&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l}remove(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_;for(let o=0,a=arguments.length;o!==a;++o){const c=arguments[o],l=c.uuid,u=t[l];if(u!==void 0&&u>=r){const h=r++,d=e[h];t[d.uuid]=u,e[u]=d,t[l]=h,e[h]=c;for(let p=0,f=i;p!==f;++p){const x=n[p],m=x[h],g=x[u];x[u]=m,x[h]=g}}}this.nCachedObjects_=r}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_,o=e.length;for(let a=0,c=arguments.length;a!==c;++a){const l=arguments[a],u=l.uuid,h=t[u];if(h!==void 0)if(delete t[u],h<r){const d=--r,p=e[d],f=--o,x=e[f];t[p.uuid]=h,e[h]=p,t[x.uuid]=d,e[d]=x,e.pop();for(let m=0,g=i;m!==g;++m){const y=n[m],_=y[d],v=y[f];y[h]=_,y[d]=v,y.pop()}}else{const d=--o,p=e[d];d>0&&(t[p.uuid]=h),e[h]=p,e.pop();for(let f=0,x=i;f!==x;++f){const m=n[f];m[h]=m[d],m.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){const n=this._bindingsIndicesByPath;let i=n[e];const r=this._bindings;if(i!==void 0)return r[i];const o=this._paths,a=this._parsedPaths,c=this._objects,l=c.length,u=this.nCachedObjects_,h=new Array(l);i=r.length,n[e]=i,o.push(e),a.push(t),r.push(h);for(let d=u,p=c.length;d!==p;++d){const f=c[d];h[d]=new St(f,e,t)}return h}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){const i=this._paths,r=this._parsedPaths,o=this._bindings,a=o.length-1,c=o[a],l=e[a];t[l]=n,o[n]=c,o.pop(),r[n]=r[a],r.pop(),i[n]=i[a],i.pop()}}}class Tv{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;const r=t.tracks,o=r.length,a=new Array(o),c={endingStart:Br,endingEnd:Br};for(let l=0;l!==o;++l){const u=r[l].createInterpolant(null);a[l]=u,u.settings=c}this._interpolantSettings=c,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=$f,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){const i=this._clip.duration,r=e._clip.duration,o=r/i,a=i/r;e.warp(1,o,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const i=this._mixer,r=i.time,o=this.timeScale;let a=this._timeScaleInterpolant;a===null&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);const c=a.parameterPositions,l=a.sampleValues;return c[0]=r,c[1]=r+n,l[0]=e/o,l[1]=t/o,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled){this._updateWeight(e);return}const r=this._startTime;if(r!==null){const c=(e-r)*n;c<0||n===0?t=0:(this._startTime=null,t=n*c)}t*=this._updateTimeScale(e);const o=this._updateTime(t),a=this._updateWeight(e);if(a>0){const c=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case Yf:for(let u=0,h=c.length;u!==h;++u)c[u].evaluate(o),l[u].accumulateAdditive(a);break;case zh:default:for(let u=0,h=c.length;u!==h;++u)c[u].evaluate(o),l[u].accumulate(i,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(n!==null){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;if(n!==null){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let i=this.time+e,r=this._loopCount;const o=n===hy;if(e===0)return r===-1?i:o&&(r&1)===1?t-i:i;if(n===qf){r===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(r===-1&&(e>=0?(r=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),i>=t||i<0){const a=Math.floor(i/t);i-=t*a,r+=Math.abs(a);const c=this.repetitions-r;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(c===1){const l=e<0;this._setEndings(l,!l,o)}else this._setEndings(!1,!1,o);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=i;if(o&&(r&1)===1)return t-i}return i}_setEndings(e,t,n){const i=this._interpolantSettings;n?(i.endingStart=zr,i.endingEnd=zr):(e?i.endingStart=this.zeroSlopeAtStart?zr:Br:i.endingStart=wc,t?i.endingEnd=this.zeroSlopeAtEnd?zr:Br:i.endingEnd=wc)}_scheduleFading(e,t,n){const i=this._mixer,r=i.time;let o=this._weightInterpolant;o===null&&(o=i._lendControlInterpolant(),this._weightInterpolant=o);const a=o.parameterPositions,c=o.sampleValues;return a[0]=r,c[0]=t,a[1]=r+e,c[1]=n,this}}const nP=new Float32Array(1);class bv extends Ai{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,o=e._propertyBindings,a=e._interpolants,c=n.uuid,l=this._bindingsByRootAndName;let u=l[c];u===void 0&&(u={},l[c]=u);for(let h=0;h!==r;++h){const d=i[h],p=d.name;let f=u[p];if(f!==void 0)++f.referenceCount,o[h]=f;else{if(f=o[h],f!==void 0){f._cacheIndex===null&&(++f.referenceCount,this._addInactiveBinding(f,c,p));continue}const x=t&&t._propertyBindings[h].binding.parsedPath;f=new Sv(St.create(n,p,x),d.ValueTypeName,d.getValueSize()),++f.referenceCount,this._addInactiveBinding(f,c,p),o[h]=f}a[h].resultBuffer=f.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const n=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,n)}const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const r=t[n];r.useCount++===0&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const r=t[n];--r.useCount===0&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){const i=this._actions,r=this._actionsByClip;let o=r[t];if(o===void 0)o={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=o;else{const a=o.knownActions;e._byClipCacheIndex=a.length,a.push(e)}e._cacheIndex=i.length,i.push(e),o.actionByRoot[n]=e}_removeInactiveAction(e){const t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;const r=e._clip.uuid,o=this._actionsByClip,a=o[r],c=a.knownActions,l=c[c.length-1],u=e._byClipCacheIndex;l._byClipCacheIndex=u,c[u]=l,c.pop(),e._byClipCacheIndex=null;const h=a.actionByRoot,d=(e._localRoot||this._root).uuid;delete h[d],c.length===0&&delete o[r],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const r=t[n];--r.referenceCount===0&&this._removeInactiveBinding(r)}}_lendAction(e){const t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackAction(e){const t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_addInactiveBinding(e,t,n){const i=this._bindingsByRootAndName,r=this._bindings;let o=i[t];o===void 0&&(o={},i[t]=o),o[n]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){const t=this._bindings,n=e.binding,i=n.rootNode.uuid,r=n.path,o=this._bindingsByRootAndName,a=o[i],c=t[t.length-1],l=e._cacheIndex;c._cacheIndex=l,t[l]=c,t.pop(),delete a[r],Object.keys(a).length===0&&delete o[i]}_lendBinding(e){const t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackBinding(e){const t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let n=e[t];return n===void 0&&(n=new Em(new Float32Array(2),new Float32Array(2),1,nP),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){const t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,r=t[i];e.__cacheIndex=i,t[i]=e,r.__cacheIndex=n,t[n]=r}clipAction(e,t,n){const i=t||this._root,r=i.uuid;let o=typeof e=="string"?la.findByName(i,e):e;const a=o!==null?o.uuid:e,c=this._actionsByClip[a];let l=null;if(n===void 0&&(o!==null?n=o.blendMode:n=zh),c!==void 0){const h=c.actionByRoot[r];if(h!==void 0&&h.blendMode===n)return h;l=c.knownActions[0],o===null&&(o=l._clip)}if(o===null)return null;const u=new Tv(this,o,t,n);return this._bindAction(u,l),this._addInactiveAction(u,a,r),u}existingAction(e,t){const n=t||this._root,i=n.uuid,r=typeof e=="string"?la.findByName(n,e):e,o=r?r.uuid:e,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[i]||null}stopAllAction(){const e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),o=this._accuIndex^=1;for(let l=0;l!==n;++l)t[l]._update(i,e,r,o);const a=this._bindings,c=this._nActiveBindings;for(let l=0;l!==c;++l)a[l].apply(o);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,n=e.uuid,i=this._actionsByClip,r=i[n];if(r!==void 0){const o=r.knownActions;for(let a=0,c=o.length;a!==c;++a){const l=o[a];this._deactivateAction(l);const u=l._cacheIndex,h=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,h._cacheIndex=u,t[u]=h,t.pop(),this._removeInactiveBindingsForAction(l)}delete i[n]}}uncacheRoot(e){const t=e.uuid,n=this._actionsByClip;for(const o in n){const a=n[o].actionByRoot,c=a[t];c!==void 0&&(this._deactivateAction(c),this._removeInactiveAction(c))}const i=this._bindingsByRootAndName,r=i[t];if(r!==void 0)for(const o in r){const a=r[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(e,t){const n=this.existingAction(e,t);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}}let wv=class Av{constructor(e){this.value=e}clone(){return new Av(this.value.clone===void 0?this.value:this.value.clone())}},iP=0;class sP extends Ai{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:iP++}),this.name="",this.usage=sa,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(e){this.name=e.name,this.usage=e.usage;const t=e.uniforms;this.uniforms.length=0;for(let n=0,i=t.length;n<i;n++){const r=Array.isArray(t[n])?t[n]:[t[n]];for(let o=0;o<r.length;o++)this.uniforms.push(r[o].clone())}return this}clone(){return new this.constructor().copy(this)}}class Bm extends _a{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}class rP{constructor(e,t,n,i,r){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=n,this.elementSize=i,this.count=r,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}}const zx=new Fe;class Nv{constructor(e,t,n=0,i=1/0){this.ray=new no(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new $c,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return zx.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(zx),this}intersectObject(e,t=!0,n=[]){return ff(e,this,n,t),n.sort(kx),n}intersectObjects(e,t=!0,n=[]){for(let i=0,r=e.length;i<r;i++)ff(e[i],this,n,t);return n.sort(kx),n}}function kx(s,e){return s.distance-e.distance}function ff(s,e,t,n){let i=!0;if(s.layers.test(e.layers)&&s.raycast(e,t)===!1&&(i=!1),i===!0&&n===!0){const r=s.children;for(let o=0,a=r.length;o<a;o++)ff(r[o],e,t,!0)}}class Ev{constructor(e=1,t=0,n=0){return this.radius=e,this.phi=t,this.theta=n,this}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(jt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class oP{constructor(e=1,t=0,n=0){return this.radius=e,this.theta=t,this.y=n,this}set(e,t,n){return this.radius=e,this.theta=t,this.y=n,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+n*n),this.theta=Math.atan2(e,n),this.y=t,this}clone(){return new this.constructor().copy(this)}}class zm{constructor(e,t,n,i){zm.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,i){const r=this.elements;return r[0]=e,r[2]=t,r[1]=n,r[3]=i,this}}const Gx=new J;class aP{constructor(e=new J(1/0,1/0),t=new J(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Gx.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}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=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(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}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}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}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))}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}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Gx).distanceTo(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}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)}}const Hx=new E,uu=new E;class Cv{constructor(e=new E,t=new E){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Hx.subVectors(e,this.start),uu.subVectors(this.end,this.start);const n=uu.dot(uu);let r=uu.dot(Hx)/n;return t&&(r=jt(r,0,1)),r}closestPointToPoint(e,t,n){const i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const Wx=new E;class cP extends yt{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const n=new at,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,c=32;o<c;o++,a++){const l=o/c*Math.PI*2,u=a/c*Math.PI*2;i.push(Math.cos(l),Math.sin(l),1,Math.cos(u),Math.sin(u),1)}n.setAttribute("position",new Ve(i,3));const r=new Fn({fog:!1,toneMapped:!1});this.cone=new rs(n,r),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);const e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Wx.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Wx),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const qs=new E,hu=new Fe,Lp=new Fe;class lP extends rs{constructor(e){const t=Rv(e),n=new at,i=[],r=[],o=new _e(0,0,1),a=new _e(0,1,0);for(let l=0;l<t.length;l++){const u=t[l];u.parent&&u.parent.isBone&&(i.push(0,0,0),i.push(0,0,0),r.push(o.r,o.g,o.b),r.push(a.r,a.g,a.b))}n.setAttribute("position",new Ve(i,3)),n.setAttribute("color",new Ve(r,3));const c=new Fn({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(n,c),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){const t=this.bones,n=this.geometry,i=n.getAttribute("position");Lp.copy(this.root.matrixWorld).invert();for(let r=0,o=0;r<t.length;r++){const a=t[r];a.parent&&a.parent.isBone&&(hu.multiplyMatrices(Lp,a.matrixWorld),qs.setFromMatrixPosition(hu),i.setXYZ(o,qs.x,qs.y,qs.z),hu.multiplyMatrices(Lp,a.parent.matrixWorld),qs.setFromMatrixPosition(hu),i.setXYZ(o+1,qs.x,qs.y,qs.z),o+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}}function Rv(s){const e=[];s.isBone===!0&&e.push(s);for(let t=0;t<s.children.length;t++)e.push.apply(e,Rv(s.children[t]));return e}class uP extends kt{constructor(e,t,n){const i=new Ma(t,4,2),r=new ss({wireframe:!0,fog:!1,toneMapped:!1});super(i,r),this.light=e,this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const hP=new E,Xx=new _e,qx=new _e;class dP extends yt{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="HemisphereLightHelper";const i=new va(t);i.rotateY(Math.PI*.5),this.material=new ss({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const r=i.getAttribute("position"),o=new Float32Array(r.count*3);i.setAttribute("color",new At(o,3)),this.add(new kt(i,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");Xx.copy(this.light.color),qx.copy(this.light.groundColor);for(let n=0,i=t.count;n<i;n++){const r=n<i/2?Xx:qx;t.setXYZ(n,r.r,r.g,r.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(hP.setFromMatrixPosition(this.light.matrixWorld).negate())}}let Iv=class extends rs{constructor(e=10,t=10,n=4473924,i=8947848){n=new _e(n),i=new _e(i);const r=t/2,o=e/t,a=e/2,c=[],l=[];for(let d=0,p=0,f=-a;d<=t;d++,f+=o){c.push(-a,0,f,a,0,f),c.push(f,0,-a,f,0,a);const x=d===r?n:i;x.toArray(l,p),p+=3,x.toArray(l,p),p+=3,x.toArray(l,p),p+=3,x.toArray(l,p),p+=3}const u=new at;u.setAttribute("position",new Ve(c,3)),u.setAttribute("color",new Ve(l,3));const h=new Fn({vertexColors:!0,toneMapped:!1});super(u,h),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}};class pP extends rs{constructor(e=10,t=16,n=8,i=64,r=4473924,o=8947848){r=new _e(r),o=new _e(o);const a=[],c=[];if(t>1)for(let h=0;h<t;h++){const d=h/t*(Math.PI*2),p=Math.sin(d)*e,f=Math.cos(d)*e;a.push(0,0,0),a.push(p,0,f);const x=h&1?r:o;c.push(x.r,x.g,x.b),c.push(x.r,x.g,x.b)}for(let h=0;h<n;h++){const d=h&1?r:o,p=e-e/n*h;for(let f=0;f<i;f++){let x=f/i*(Math.PI*2),m=Math.sin(x)*p,g=Math.cos(x)*p;a.push(m,0,g),c.push(d.r,d.g,d.b),x=(f+1)/i*(Math.PI*2),m=Math.sin(x)*p,g=Math.cos(x)*p,a.push(m,0,g),c.push(d.r,d.g,d.b)}}const l=new at;l.setAttribute("position",new Ve(a,3)),l.setAttribute("color",new Ve(c,3));const u=new Fn({vertexColors:!0,toneMapped:!1});super(l,u),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const $x=new E,du=new E,Yx=new E;class Pv extends yt{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",t===void 0&&(t=1);let i=new at;i.setAttribute("position",new Ve([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const r=new Fn({fog:!1,toneMapped:!1});this.lightPlane=new Fs(i,r),this.add(this.lightPlane),i=new at,i.setAttribute("position",new Ve([0,0,0,0,0,1],3)),this.targetLine=new Fs(i,r),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),$x.setFromMatrixPosition(this.light.matrixWorld),du.setFromMatrixPosition(this.light.target.matrixWorld),Yx.subVectors(du,$x),this.lightPlane.lookAt(du),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(du),this.targetLine.scale.z=Yx.length()}}const pu=new E,Kt=new Yc;class Lv extends rs{constructor(e){const t=new at,n=new Fn({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],r=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(f,x){c(f),c(x)}function c(f){i.push(0,0,0),r.push(0,0,0),o[f]===void 0&&(o[f]=[]),o[f].push(i.length/3-1)}t.setAttribute("position",new Ve(i,3)),t.setAttribute("color",new Ve(r,3)),super(t,n),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();const l=new _e(16755200),u=new _e(16711680),h=new _e(43775),d=new _e(16777215),p=new _e(3355443);this.setColors(l,u,h,d,p)}setColors(e,t,n,i,r){const a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,n.r,n.g,n.b),a.setXYZ(33,n.r,n.g,n.b),a.setXYZ(34,n.r,n.g,n.b),a.setXYZ(35,n.r,n.g,n.b),a.setXYZ(36,n.r,n.g,n.b),a.setXYZ(37,n.r,n.g,n.b),a.setXYZ(38,i.r,i.g,i.b),a.setXYZ(39,i.r,i.g,i.b),a.setXYZ(40,r.r,r.g,r.b),a.setXYZ(41,r.r,r.g,r.b),a.setXYZ(42,r.r,r.g,r.b),a.setXYZ(43,r.r,r.g,r.b),a.setXYZ(44,r.r,r.g,r.b),a.setXYZ(45,r.r,r.g,r.b),a.setXYZ(46,r.r,r.g,r.b),a.setXYZ(47,r.r,r.g,r.b),a.setXYZ(48,r.r,r.g,r.b),a.setXYZ(49,r.r,r.g,r.b),a.needsUpdate=!0}update(){const e=this.geometry,t=this.pointMap,n=1,i=1;Kt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),nn("c",t,e,Kt,0,0,-1),nn("t",t,e,Kt,0,0,1),nn("n1",t,e,Kt,-n,-i,-1),nn("n2",t,e,Kt,n,-i,-1),nn("n3",t,e,Kt,-n,i,-1),nn("n4",t,e,Kt,n,i,-1),nn("f1",t,e,Kt,-n,-i,1),nn("f2",t,e,Kt,n,-i,1),nn("f3",t,e,Kt,-n,i,1),nn("f4",t,e,Kt,n,i,1),nn("u1",t,e,Kt,n*.7,i*1.1,-1),nn("u2",t,e,Kt,-n*.7,i*1.1,-1),nn("u3",t,e,Kt,0,i*2,-1),nn("cf1",t,e,Kt,-n,0,1),nn("cf2",t,e,Kt,n,0,1),nn("cf3",t,e,Kt,0,-i,1),nn("cf4",t,e,Kt,0,i,1),nn("cn1",t,e,Kt,-n,0,-1),nn("cn2",t,e,Kt,n,0,-1),nn("cn3",t,e,Kt,0,-i,-1),nn("cn4",t,e,Kt,0,i,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function nn(s,e,t,n,i,r,o){pu.set(i,r,o).unproject(n);const a=e[s];if(a!==void 0){const c=t.getAttribute("position");for(let l=0,u=a.length;l<u;l++)c.setXYZ(a[l],pu.x,pu.y,pu.z)}}const fu=new Hn;class Dv extends rs{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Float32Array(24),r=new at;r.setIndex(new At(n,1)),r.setAttribute("position",new At(i,3)),super(r,new Fn({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&fu.setFromObject(this.object),fu.isEmpty())return;const t=fu.min,n=fu.max,i=this.geometry.attributes.position,r=i.array;r[0]=n.x,r[1]=n.y,r[2]=n.z,r[3]=t.x,r[4]=n.y,r[5]=n.z,r[6]=t.x,r[7]=t.y,r[8]=n.z,r[9]=n.x,r[10]=t.y,r[11]=n.z,r[12]=n.x,r[13]=n.y,r[14]=t.z,r[15]=t.x,r[16]=n.y,r[17]=t.z,r[18]=t.x,r[19]=t.y,r[20]=t.z,r[21]=n.x,r[22]=t.y,r[23]=t.z,i.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Uv extends rs{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],r=new at;r.setIndex(new At(n,1)),r.setAttribute("position",new Ve(i,3)),super(r,new Fn({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}}class fP extends Fs{constructor(e,t=1,n=16776960){const i=n,r=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],o=new at;o.setAttribute("position",new Ve(r,3)),o.computeBoundingSphere(),super(o,new Fn({color:i,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const a=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],c=new at;c.setAttribute("position",new Ve(a,3)),c.computeBoundingSphere(),this.add(new kt(c,new ss({color:i,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const Zx=new E;let mu,Dp;class mP extends yt{constructor(e=new E(0,0,1),t=new E(0,0,0),n=1,i=16776960,r=n*.2,o=r*.2){super(),this.type="ArrowHelper",mu===void 0&&(mu=new at,mu.setAttribute("position",new Ve([0,0,0,0,1,0],3)),Dp=new ao(0,.5,1,5,1),Dp.translate(0,-.5,0)),this.position.copy(t),this.line=new Fs(mu,new Fn({color:i,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new kt(Dp,new ss({color:i,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(n,r,o)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Zx.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Zx,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}let Fv=class extends rs{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new at;i.setAttribute("position",new Ve(t,3)),i.setAttribute("color",new Ve(n,3));const r=new Fn({vertexColors:!0,toneMapped:!1});super(i,r),this.type="AxesHelper"}setColors(e,t,n){const i=new _e,r=this.geometry.attributes.color.array;return i.set(e),i.toArray(r,0),i.toArray(r,3),i.set(t),i.toArray(r,6),i.toArray(r,9),i.set(n),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};class Ov{constructor(){this.type="ShapePath",this.color=new _e,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Rc,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,i){return this.currentPath.quadraticCurveTo(e,t,n,i),this}bezierCurveTo(e,t,n,i,r,o){return this.currentPath.bezierCurveTo(e,t,n,i,r,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(g){const y=[];for(let _=0,v=g.length;_<v;_++){const I=g[_],T=new er;T.curves=I.curves,y.push(T)}return y}function n(g,y){const _=y.length;let v=!1;for(let I=_-1,T=0;T<_;I=T++){let w=y[I],C=y[T],F=C.x-w.x,M=C.y-w.y;if(Math.abs(M)>Number.EPSILON){if(M<0&&(w=y[T],F=-F,C=y[I],M=-M),g.y<w.y||g.y>C.y)continue;if(g.y===w.y){if(g.x===w.x)return!0}else{const b=M*(g.x-w.x)-F*(g.y-w.y);if(b===0)return!0;if(b<0)continue;v=!v}}else{if(g.y!==w.y)continue;if(C.x<=g.x&&g.x<=w.x||w.x<=g.x&&g.x<=C.x)return!0}}return v}const i=ji.isClockWise,r=this.subPaths;if(r.length===0)return[];let o,a,c;const l=[];if(r.length===1)return a=r[0],c=new er,c.curves=a.curves,l.push(c),l;let u=!i(r[0].getPoints());u=e?!u:u;const h=[],d=[];let p=[],f=0,x;d[f]=void 0,p[f]=[];for(let g=0,y=r.length;g<y;g++)a=r[g],x=a.getPoints(),o=i(x),o=e?!o:o,o?(!u&&d[f]&&f++,d[f]={s:new er,p:x},d[f].s.curves=a.curves,u&&f++,p[f]=[]):p[f].push({h:a,p:x[0]});if(!d[0])return t(r);if(d.length>1){let g=!1,y=0;for(let _=0,v=d.length;_<v;_++)h[_]=[];for(let _=0,v=d.length;_<v;_++){const I=p[_];for(let T=0;T<I.length;T++){const w=I[T];let C=!0;for(let F=0;F<d.length;F++)n(w.p,d[F].p)&&(_!==F&&y++,C?(C=!1,h[F].push(w)):g=!0);C&&h[_].push(w)}}y>0&&g===!1&&(p=h)}let m;for(let g=0,y=d.length;g<y;g++){c=d[g].s,l.push(c),m=p[g];for(let _=0,v=m.length;_<v;_++)c.holes.push(m[_].h)}return l}}class Vv extends Ai{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(){}disconnect(){}dispose(){}update(){}}class gP extends zi{constructor(e=1,t=1,n=1,i={}){console.warn('THREE.WebGLMultipleRenderTargets has been deprecated and will be removed in r172. Use THREE.WebGLRenderTarget and set the "count" parameter to enable MRT.'),super(e,t,{...i,count:n}),this.isWebGLMultipleRenderTargets=!0}get texture(){return this.textures}}const xP=["alphaMap","alphaTest","anisotropy","anisotropyMap","anisotropyRotation","aoMap","attenuationColor","attenuationDistance","bumpMap","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dispersion","displacementMap","emissive","emissiveMap","envMap","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThicknessMap","lightMap","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","roughness","roughnessMap","sheen","sheenColor","sheenColorMap","sheenRoughnessMap","shininess","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","thickness","transmission","transmissionMap"];class Bv{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=xP,this.renderId=0}firstInitialization(e){return this.renderObjects.has(e)===!1?(this.getRenderObjectData(e),!0):!1}getRenderObjectData(e){let t=this.renderObjects.get(e);return t===void 0&&(t={material:this.getMaterialData(e.material),worldMatrix:e.object.matrixWorld.clone()},e.object.center&&(t.center=e.object.center.clone()),e.object.morphTargetInfluences&&(t.morphTargetInfluences=e.object.morphTargetInfluences.slice()),e.bundle!==null&&(t.version=e.bundle.version),this.renderObjects.set(e,t)),t}containsNode(e){const t=e.material;for(const n in t)if(t[n]&&t[n].isNode)return!0;return e.renderer.nodes.modelViewMatrix!==null||e.renderer.nodes.modelNormalViewMatrix!==null}getMaterialData(e){const t={};for(const n of this.refreshUniforms){const i=e[n];i!=null&&(typeof i=="object"&&i.clone!==void 0?i.isTexture===!0?t[n]={id:i.id,version:i.version}:t[n]=i.clone():t[n]=i)}return t}equals(e){const{object:t,material:n}=e,i=this.getRenderObjectData(e);if(i.worldMatrix.equals(t.matrixWorld)!==!0)return i.worldMatrix.copy(t.matrixWorld),!1;const r=i.material;for(const o in r){const a=r[o],c=n[o];if(a.equals!==void 0){if(a.equals(c)===!1)return a.copy(c),!1}else if(c.isTexture===!0){if(a.id!==c.id||a.version!==c.version)return a.id=c.id,a.version=c.version,!1}else if(a!==c)return r[o]=c,!1}if(i.morphTargetInfluences){let o=!1;for(let a=0;a<i.morphTargetInfluences.length;a++)i.morphTargetInfluences[a]!==t.morphTargetInfluences[a]&&(o=!0);if(o)return!0}return i.center&&i.center.equals(t.center)===!1?(i.center.copy(t.center),!0):(e.bundle!==null&&(i.version=e.bundle.version),!0)}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e))return!0;const{renderId:n}=t;if(this.renderId!==n)return this.renderId=n,!0;const i=e.object.static===!0,r=e.bundle!==null&&e.bundle.static===!0&&this.getRenderObjectData(e).version===e.bundle.version;return i||r?!1:this.equals(e)!==!0}}function Uc(s,e=0){let t=3735928559^e,n=1103547991^e;if(s instanceof Array)for(let i=0,r;i<s.length;i++)r=s[i],t=Math.imul(t^r,2654435761),n=Math.imul(n^r,1597334677);else for(let i=0,r;i<s.length;i++)r=s.charCodeAt(i),t=Math.imul(t^r,2654435761),n=Math.imul(n^r,1597334677);return t=Math.imul(t^t>>>16,2246822507),t^=Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(t^t>>>13,3266489909),4294967296*(2097151&n)+(t>>>0)}const zv=s=>Uc(s),kv=s=>Uc(s),km=(...s)=>Uc(s);function Gm(s,e=!1){const t=[];s.isNode===!0&&(t.push(s.id),s=s.getSelf());for(const{property:n,childNode:i}of Fc(s))t.push(t,Uc(n.slice(0,-4)),i.getCacheKey(e));return Uc(t)}function*Fc(s,e=!1){for(const t in s){if(t.startsWith("_")===!0)continue;const n=s[t];if(Array.isArray(n)===!0)for(let i=0;i<n.length;i++){const r=n[i];r&&(r.isNode===!0||e&&typeof r.toJSON=="function")&&(yield{property:t,index:i,childNode:r})}else if(n&&n.isNode===!0)yield{property:t,childNode:n};else if(typeof n=="object")for(const i in n){const r=n[i];r&&(r.isNode===!0||e&&typeof r.toJSON=="function")&&(yield{property:t,index:i,childNode:r})}}}function Is(s){if(s==null)return null;const e=typeof s;return s.isNode===!0?"node":e==="number"?"float":e==="boolean"?"bool":e==="string"?"string":e==="function"?"shader":s.isVector2===!0?"vec2":s.isVector3===!0?"vec3":s.isVector4===!0?"vec4":s.isMatrix3===!0?"mat3":s.isMatrix4===!0?"mat4":s.isColor===!0?"color":s instanceof ArrayBuffer?"ArrayBuffer":null}function Hm(s,...e){const t=s?s.slice(-4):void 0;return e.length===1&&(t==="vec2"?e=[e[0],e[0]]:t==="vec3"?e=[e[0],e[0],e[0]]:t==="vec4"&&(e=[e[0],e[0],e[0],e[0]])),s==="color"?new _e(...e):t==="vec2"?new J(...e):t==="vec3"?new E(...e):t==="vec4"?new st(...e):t==="mat3"?new Ke(...e):t==="mat4"?new Fe(...e):s==="bool"?e[0]||!1:s==="float"||s==="int"||s==="uint"?e[0]||0:s==="string"?e[0]||"":s==="ArrayBuffer"?Xm(e[0]):null}function Wm(s){let e="";const t=new Uint8Array(s);for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e)}function Xm(s){return Uint8Array.from(atob(s),e=>e.charCodeAt(0)).buffer}var _P=Object.freeze({__proto__:null,arrayBufferToBase64:Wm,base64ToArrayBuffer:Xm,getCacheKey:Gm,getNodeChildren:Fc,getValueFromType:Hm,getValueType:Is,hash:km,hashArray:kv,hashString:zv});const mf={VERTEX:"vertex",FRAGMENT:"fragment"},We={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},yP={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},qm=["fragment","vertex"],gf=["setup","analyze","generate"],xf=[...qm,"compute"],ba=["x","y","z","w"];let vP=0;class Ye extends Ai{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=We.NONE,this.updateBeforeType=We.NONE,this.updateAfterType=We.NONE,this.uuid=Gh.generateUUID(),this.version=0,this._cacheKey=null,this._cacheKeyVersion=0,this.global=!1,this.isNode=!0,Object.defineProperty(this,"id",{value:vP++})}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,We.FRAME)}onRenderUpdate(e){return this.onUpdate(e,We.RENDER)}onObjectUpdate(e){return this.onUpdate(e,We.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of Fc(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e=e||this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=Gm(this,e),this._cacheKeyVersion=this.version),this._cacheKey}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){const t=this.getNodeType(e);return e.getElementType(t)}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}setup(e){const t=e.getNodeProperties(this);let n=0;for(const i of this.getChildren())t["node"+n++]=i;return null}analyze(e){if(e.increaseUsage(this)===1){const n=e.getNodeProperties(this);for(const i of Object.values(n))i&&i.isNode===!0&&i.build(e)}}generate(e,t){const{outputNode:n}=e.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const n=this.getShared(e);if(this!==n)return n.build(e,t);e.addNode(this),e.addChain(this);let i=null;const r=e.getBuildStage();if(r==="setup"){this.updateReference(e);const o=e.getNodeProperties(this);if(o.initialized!==!0){const a=e.stack.nodes.length;o.initialized=!0,o.outputNode=this.setup(e),o.outputNode!==null&&e.stack.nodes.length;for(const c of Object.values(o))c&&c.isNode===!0&&c.build(e)}}else if(r==="analyze")this.analyze(e);else if(r==="generate")if(this.generate.length===1){const a=this.getNodeType(e),c=e.getDataFromNode(this);i=c.snippet,i===void 0?(i=this.generate(e)||"",c.snippet=i):c.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),i=e.format(i,a,t)}else i=this.generate(e,t)||"";return e.removeChain(this),i}getSerializeChildren(){return Fc(this)}serialize(e){const t=this.getSerializeChildren(),n={};for(const{property:i,index:r,childNode:o}of t)r!==void 0?(n[i]===void 0&&(n[i]=Number.isInteger(r)?[]:{}),n[i][r]=o.toJSON(e.meta).uuid):n[i]=o.toJSON(e.meta).uuid;Object.keys(n).length>0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){const t=e.meta.nodes;for(const n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){const i=[];for(const r of e.inputNodes[n])i.push(t[r]);this[n]=i}else if(typeof e.inputNodes[n]=="object"){const i={};for(const r in e.inputNodes[n]){const o=e.inputNodes[n][r];i[r]=t[o]}this[n]=i}else{const i=e.inputNodes[n];this[n]=t[i]}}}toJSON(e){const{uuid:t,type:n}=this,i=e===void 0||typeof e=="string";i&&(e={textures:{},images:{},nodes:{}});let r=e.nodes[t];r===void 0&&(r={uuid:t,type:n,meta:e,metadata:{version:4.6,type:"Node",generator:"Node.toJSON"}},i!==!0&&(e.nodes[r.uuid]=r),this.serialize(r),delete r.meta);function o(a){const c=[];for(const l in a){const u=a[l];delete u.metadata,c.push(u)}return c}if(i){const a=o(e.textures),c=o(e.images),l=o(e.nodes);a.length>0&&(r.textures=a),c.length>0&&(r.images=c),l.length>0&&(r.nodes=l)}return r}}class fr extends Ye{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){const t=this.node.build(e),n=this.indexNode.build(e,"uint");return`${t}[ ${n} ]`}}class $m extends Ye{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let n=null;for(const i of this.convertTo.split("|"))(n===null||e.getTypeLength(t)===e.getTypeLength(i))&&(n=i);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const n=this.node,i=this.getNodeType(e),r=n.build(e,i);return e.format(r,i,t)}}class pt extends Ye{static get type(){return"TempNode"}constructor(e){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()==="generate"){const i=e.getVectorType(this.getNodeType(e,t)),r=e.getDataFromNode(this);if(r.propertyName!==void 0)return e.format(r.propertyName,i,t);if(i!=="void"&&t!=="void"&&this.hasDependencies(e)){const o=super.build(e,i),a=e.getVarFromNode(this,null,i),c=e.getPropertyName(a);return e.addLineFlowCode(`${c} = ${o}`,this),r.snippet=o,r.propertyName=c,e.format(r.propertyName,i,t)}}return super.build(e,t)}}class Gv extends pt{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType!==null?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0))}generate(e,t){const n=this.getNodeType(e),i=this.nodes,r=e.getComponentType(n),o=[];for(const c of i){let l=c.build(e);const u=e.getComponentType(c.getNodeType(e));u!==r&&(l=e.format(l,u,r)),o.push(l)}const a=`${e.getType(n)}( ${o.join(", ")} )`;return e.format(a,n,t)}}const MP=ba.join("");class uh extends Ye{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max(ba.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){const n=this.node,i=e.getTypeLength(n.getNodeType(e));let r=null;if(i>1){let o=null;this.getVectorLength()>=i&&(o=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const c=n.build(e,o);this.components.length===i&&this.components===MP.slice(0,this.components.length)?r=e.format(c,o,t):r=e.format(`${c}.${this.components}`,this.getNodeType(e),t)}else r=n.build(e,t);return r}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class Hv extends pt{static get type(){return"SetNode"}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:n,targetNode:i}=this,r=this.getNodeType(e),o=e.getTypeFromLength(n.length,i.getNodeType(e)),a=i.build(e,o),c=t.build(e,r),l=e.getTypeLength(r),u=[];for(let h=0;h<l;h++){const d=ba[h];d===n[0]?(u.push(a),h+=n.length-1):u.push(c+"."+d)}return`${e.getType(r)}( ${u.join(", ")} )`}}class SP extends pt{static get type(){return"FlipNode"}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{components:t,sourceNode:n}=this,i=this.getNodeType(e),r=n.build(e),o=e.getVarFromNode(this),a=e.getPropertyName(o);e.addLineFlowCode(a+" = "+r,this);const c=e.getTypeLength(i),l=[];let u=0;for(let h=0;h<c;h++){const d=ba[h];d===t[u]?(l.push("1.0 - "+(a+"."+d)),u++):l.push(a+"."+d)}return`${e.getType(i)}( ${l.join(", ")} )`}}class Ym extends Ye{static get type(){return"InputNode"}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return this.nodeType===null?Is(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=Is(this.value),e.nodeType=this.nodeType,e.valueType==="ArrayBuffer"&&(e.value=Wm(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?Hm(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){console.warn("Abstract function.")}}class Wi extends Ym{static get type(){return"ConstNode"}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){const n=this.getNodeType(e);return e.format(this.generateConst(e),n,t)}}let ua=null;const Wo=new Map;function te(s,e){if(Wo.has(s)){console.warn(`Redefinition of method chaining ${s}`);return}if(typeof e!="function")throw new Error(`Node element ${s} is not a function`);Wo.set(s,e)}const Wv=s=>s.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),Jx=s=>Wv(s).split("").sort().join(""),Xv={setup(s,e){const t=e.shift();return s(rl(t),...e)},get(s,e,t){if(typeof e=="string"&&s[e]===void 0){if(s.isStackNode!==!0&&e==="assign")return(...n)=>(ua.assign(t,...n),t);if(Wo.has(e)){const n=Wo.get(e);return s.isStackNode?(...i)=>t.add(n(...i)):(...i)=>n(t,...i)}else{if(e==="self")return s;if(e.endsWith("Assign")&&Wo.has(e.slice(0,e.length-6))){const n=Wo.get(e.slice(0,e.length-6));return s.isStackNode?(...i)=>t.assign(i[0],n(...i)):(...i)=>t.assign(n(t,...i))}else{if(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0)return e=Wv(e),H(new uh(t,e));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=Jx(e.slice(3).toLowerCase()),n=>H(new Hv(s,e,n));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=Jx(e.slice(4).toLowerCase()),()=>H(new SP(H(s),e));if(e==="width"||e==="height"||e==="depth")return e==="width"?e="x":e==="height"?e="y":e==="depth"&&(e="z"),H(new uh(s,e));if(/^\d+$/.test(e)===!0)return H(new fr(t,new Wi(Number(e),"uint")))}}}return Reflect.get(s,e,t)},set(s,e,t,n){return typeof e=="string"&&s[e]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0||e==="width"||e==="height"||e==="depth"||/^\d+$/.test(e)===!0)?(n[e].assign(t),!0):Reflect.set(s,e,t,n)}},Up=new WeakMap,Kx=new WeakMap,TP=function(s,e=null){const t=Is(s);if(t==="node"){let n=Up.get(s);return n===void 0&&(n=new Proxy(s,Xv),Up.set(s,n),Up.set(n,n)),n}else{if(e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string")return H(_f(s,e));if(t==="shader")return U(s)}return s},bP=function(s,e=null){for(const t in s)s[t]=H(s[t],e);return s},wP=function(s,e=null){const t=s.length;for(let n=0;n<t;n++)s[n]=H(s[n],e);return s},AP=function(s,e=null,t=null,n=null){const i=r=>H(n!==null?Object.assign(r,n):r);return e===null?(...r)=>i(new s(...$r(r))):t!==null?(t=H(t),(...r)=>i(new s(e,...$r(r),t))):(...r)=>i(new s(e,...$r(r)))},NP=function(s,...e){return H(new s(...$r(e)))};class EP extends Ye{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}call(e){const{shaderNode:t,inputNodes:n}=this,i=e.getNodeProperties(t);if(i.onceOutput)return i.onceOutput;let r=null;if(t.layout){let o=Kx.get(e.constructor);o===void 0&&(o=new WeakMap,Kx.set(e.constructor,o));let a=o.get(t);a===void 0&&(a=H(e.buildFunctionNode(t)),o.set(t,a)),e.currentFunctionNode!==null&&e.currentFunctionNode.includes.push(a),r=H(a.call(n))}else{const o=t.jsFunc,a=n!==null?o(n,e):o(e);r=H(a)}return t.once&&(i.onceOutput=r),r}getOutputNode(e){const t=e.getNodeProperties(this);return t.outputNode===null&&(t.outputNode=this.setupOutput(e)),t.outputNode}setup(e){return this.getOutputNode(e)}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}generate(e,t){return this.getOutputNode(e).build(e,t)}}class CP extends Ye{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}call(e=null){return rl(e),H(new EP(this,e))}setup(){return this.call()}}const RP=[!1,!0],IP=[0,1,2,3],PP=[-1,-2],qv=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],Zm=new Map;for(const s of RP)Zm.set(s,new Wi(s));const Jm=new Map;for(const s of IP)Jm.set(s,new Wi(s,"uint"));const Km=new Map([...Jm].map(s=>new Wi(s.value,"int")));for(const s of PP)Km.set(s,new Wi(s,"int"));const Sd=new Map([...Km].map(s=>new Wi(s.value)));for(const s of qv)Sd.set(s,new Wi(s));for(const s of qv)Sd.set(-s,new Wi(-s));const Td={bool:Zm,uint:Jm,ints:Km,float:Sd},jx=new Map([...Zm,...Sd]),_f=(s,e)=>jx.has(s)?jx.get(s):s.isNode===!0?s:new Wi(s,e),LP=s=>{try{return s.getNodeType()}catch{return}},un=function(s,e=null){return(...t)=>{if((t.length===0||!["bool","float","int","uint"].includes(s)&&t.every(i=>typeof i!="object"))&&(t=[Hm(s,...t)]),t.length===1&&e!==null&&e.has(t[0]))return H(e.get(t[0]));if(t.length===1){const i=_f(t[0],s);return LP(i)===s?H(i):H(new $m(i,s))}const n=t.map(i=>_f(i));return H(new Gv(n,s))}},Oc=s=>typeof s=="object"&&s!==null?s.value:s,$v=s=>s!=null?s.nodeType||s.convertTo||(typeof s=="string"?s:null):null;function ec(s,e){return new Proxy(new CP(s,e),Xv)}const H=(s,e=null)=>TP(s,e),rl=(s,e=null)=>new bP(s,e),$r=(s,e=null)=>new wP(s,e),K=(...s)=>new AP(...s),fe=(...s)=>new NP(...s),U=(s,e)=>{const t=new ec(s,e),n=(...i)=>{let r;return rl(i),i[0]&&i[0].isNode?r=[...i]:r=i[0],t.call(r)};return n.shaderNode=t,n.setLayout=i=>(t.setLayout(i),n),n.once=()=>(t.once=!0,n),n},DP=(...s)=>(console.warn("TSL.ShaderNode: tslFn() has been renamed to Fn()."),U(...s));te("toGlobal",s=>(s.global=!0,s));const Vc=s=>{ua=s},jm=()=>ua,Oe=(...s)=>ua.If(...s);function Yv(s){return ua&&ua.add(s),s}te("append",Yv);const Zv=new un("color"),A=new un("float",Td.float),L=new un("int",Td.ints),ve=new un("uint",Td.uint),cr=new un("bool",Td.bool),z=new un("vec2"),ls=new un("ivec2"),Jv=new un("uvec2"),Kv=new un("bvec2"),D=new un("vec3"),jv=new un("ivec3"),wa=new un("uvec3"),Qm=new un("bvec3"),oe=new un("vec4"),Qv=new un("ivec4"),eM=new un("uvec4"),tM=new un("bvec4"),ol=new un("mat2"),Tn=new un("mat3"),Yr=new un("mat4"),UP=(s="")=>H(new Wi(s,"string")),FP=s=>H(new Wi(s,"ArrayBuffer"));te("toColor",Zv);te("toFloat",A);te("toInt",L);te("toUint",ve);te("toBool",cr);te("toVec2",z);te("toIVec2",ls);te("toUVec2",Jv);te("toBVec2",Kv);te("toVec3",D);te("toIVec3",jv);te("toUVec3",wa);te("toBVec3",Qm);te("toVec4",oe);te("toIVec4",Qv);te("toUVec4",eM);te("toBVec4",tM);te("toMat2",ol);te("toMat3",Tn);te("toMat4",Yr);const nM=K(fr),iM=(s,e)=>H(new $m(H(s),e)),OP=(s,e)=>H(new uh(H(s),e));te("element",nM);te("convert",iM);class eg extends Ye{static get type(){return"UniformGroupNode"}constructor(e,t=!1,n=1){super("string"),this.name=e,this.version=0,this.shared=t,this.order=n,this.isUniformGroup=!0}set needsUpdate(e){e===!0&&this.version++}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const sM=s=>new eg(s),tg=(s,e=0)=>new eg(s,!0,e),VP=tg("frame"),_t=tg("render"),rM=sM("object");class uo extends Ym{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=rM}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){const n=this.getSelf();return e=e.bind(n),super.onUpdate(i=>{const r=e(i,n);r!==void 0&&(this.value=r)},t)}generate(e,t){const n=this.getNodeType(e),i=this.getUniformHash(e);let r=e.getNodeFromHash(i);r===void 0&&(e.setHashNode(this,i),r=this);const o=r.getInputType(e),a=e.getUniformFromNode(r,o,e.shaderStage,this.name||e.context.label),c=e.getPropertyName(a);return e.context.label!==void 0&&delete e.context.label,e.format(c,n,t)}}const pe=(s,e)=>{const t=$v(e||s),n=s&&s.isNode===!0?s.node&&s.node.value||s.value:s;return H(new uo(n,t))};class Nt extends Ye{static get type(){return"PropertyNode"}constructor(e,t=null,n=!1){super(e),this.name=t,this.varying=n,this.isPropertyNode=!0}getHash(e){return this.name||super.getHash(e)}isGlobal(){return!0}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}const ai=(s,e)=>H(new Nt(s,e)),Zi=(s,e)=>H(new Nt(s,e,!0)),Ct=fe(Nt,"vec4","DiffuseColor"),yf=fe(Nt,"vec3","EmissiveColor"),hs=fe(Nt,"float","Roughness"),Bc=fe(Nt,"float","Metalness"),hh=fe(Nt,"float","Clearcoat"),zc=fe(Nt,"float","ClearcoatRoughness"),Wr=fe(Nt,"vec3","Sheen"),bd=fe(Nt,"float","SheenRoughness"),wd=fe(Nt,"float","Iridescence"),ng=fe(Nt,"float","IridescenceIOR"),ig=fe(Nt,"float","IridescenceThickness"),dh=fe(Nt,"float","AlphaT"),Ys=fe(Nt,"float","Anisotropy"),tc=fe(Nt,"vec3","AnisotropyT"),Zr=fe(Nt,"vec3","AnisotropyB"),ri=fe(Nt,"color","SpecularColor"),kc=fe(Nt,"float","SpecularF90"),ph=fe(Nt,"float","Shininess"),sg=fe(Nt,"vec4","Output"),Jr=fe(Nt,"float","dashSize"),Gc=fe(Nt,"float","gapSize"),BP=fe(Nt,"float","pointWidth"),nc=fe(Nt,"float","IOR"),fh=fe(Nt,"float","Transmission"),rg=fe(Nt,"float","Thickness"),og=fe(Nt,"float","AttenuationDistance"),ag=fe(Nt,"color","AttenuationColor"),cg=fe(Nt,"float","Dispersion");class oM extends pt{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t}hasDependencies(){return!1}getNodeType(e,t){return t!=="void"?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(e.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){const n=e.getTypeLength(t.node.getNodeType(e));return ba.join("").slice(0,n)!==t.components}return!1}generate(e,t){const{targetNode:n,sourceNode:i}=this,r=this.needsSplitAssign(e),o=n.getNodeType(e),a=n.context({assign:!0}).build(e),c=i.build(e,o),l=i.getNodeType(e),u=e.getDataFromNode(this);let h;if(u.initialized===!0)t!=="void"&&(h=a);else if(r){const d=e.getVarFromNode(this,null,o),p=e.getPropertyName(d);e.addLineFlowCode(`${p} = ${c}`,this);const f=n.node.context({assign:!0}).build(e);for(let x=0;x<n.components.length;x++){const m=n.components[x];e.addLineFlowCode(`${f}.${m} = ${p}[ ${x} ]`,this)}t!=="void"&&(h=a)}else h=`${a} = ${c}`,(t==="void"||l==="void")&&(e.addLineFlowCode(h,this),t!=="void"&&(h=a));return u.initialized=!0,e.format(h,o,t)}}const aM=K(oM);te("assign",aM);class cM extends pt{static get type(){return"FunctionCallNode"}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}generate(e){const t=[],n=this.functionNode,i=n.getInputs(e),r=this.parameters;if(Array.isArray(r))for(let a=0;a<r.length;a++){const c=i[a],l=r[a];t.push(l.build(e,c.type))}else for(const a of i){const c=r[a.name];if(c!==void 0)t.push(c.build(e,a.type));else throw new Error(`FunctionCallNode: Input '${a.name}' not found in FunctionNode.`)}return`${n.build(e,"property")}( ${t.join(", ")} )`}}const lM=(s,...e)=>(e=e.length>1||e[0]&&e[0].isNode===!0?$r(e):rl(e[0]),H(new cM(H(s),e)));te("call",lM);class qt extends pt{static get type(){return"OperatorNode"}constructor(e,t,n,...i){if(super(),i.length>0){let r=new qt(e,t,n);for(let o=0;o<i.length-1;o++)r=new qt(e,r,i[o]);t=r,n=i[i.length-1]}this.op=e,this.aNode=t,this.bNode=n}getNodeType(e,t){const n=this.op,i=this.aNode,r=this.bNode,o=i.getNodeType(e),a=typeof r<"u"?r.getNodeType(e):null;if(o==="void"||a==="void")return"void";if(n==="%")return o;if(n==="~"||n==="&"||n==="|"||n==="^"||n===">>"||n==="<<")return e.getIntegerType(o);if(n==="!"||n==="=="||n==="&&"||n==="||"||n==="^^")return"bool";if(n==="<"||n===">"||n==="<="||n===">="){const c=t?e.getTypeLength(t):Math.max(e.getTypeLength(o),e.getTypeLength(a));return c>1?`bvec${c}`:"bool"}else return o==="float"&&e.isMatrix(a)?a:e.isMatrix(o)&&e.isVector(a)?e.getVectorFromMatrix(o):e.isVector(o)&&e.isMatrix(a)?e.getVectorFromMatrix(a):e.getTypeLength(a)>e.getTypeLength(o)?a:o}generate(e,t){const n=this.op,i=this.aNode,r=this.bNode,o=this.getNodeType(e,t);let a=null,c=null;o!=="void"?(a=i.getNodeType(e),c=typeof r<"u"?r.getNodeType(e):null,n==="<"||n===">"||n==="<="||n===">="||n==="=="?e.isVector(a)?c=a:a!==c&&(a=c="float"):n===">>"||n==="<<"?(a=o,c=e.changeComponentType(c,"uint")):e.isMatrix(a)&&e.isVector(c)?c=e.getVectorFromMatrix(a):e.isVector(a)&&e.isMatrix(c)?a=e.getVectorFromMatrix(c):a=c=o):a=c=o;const l=i.build(e,a),u=typeof r<"u"?r.build(e,c):null,h=e.getTypeLength(t),d=e.getFunctionOperator(n);if(t!=="void")return n==="<"&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThan",t)}( ${l}, ${u} )`,o,t):e.format(`( ${l} < ${u} )`,o,t):n==="<="&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThanEqual",t)}( ${l}, ${u} )`,o,t):e.format(`( ${l} <= ${u} )`,o,t):n===">"&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThan",t)}( ${l}, ${u} )`,o,t):e.format(`( ${l} > ${u} )`,o,t):n===">="&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThanEqual",t)}( ${l}, ${u} )`,o,t):e.format(`( ${l} >= ${u} )`,o,t):n==="!"||n==="~"?e.format(`(${n}${l})`,a,t):d?e.format(`${d}( ${l}, ${u} )`,o,t):e.format(`( ${l} ${n} ${u} )`,o,t);if(a!=="void")return d?e.format(`${d}( ${l}, ${u} )`,o,t):e.format(`${l} ${n} ${u}`,o,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const Wt=K(qt,"+"),Ft=K(qt,"-"),ot=K(qt,"*"),ns=K(qt,"/"),lg=K(qt,"%"),uM=K(qt,"=="),hM=K(qt,"!="),dM=K(qt,"<"),ug=K(qt,">"),pM=K(qt,"<="),fM=K(qt,">="),mM=K(qt,"&&"),gM=K(qt,"||"),xM=K(qt,"!"),_M=K(qt,"^^"),yM=K(qt,"&"),vM=K(qt,"~"),MM=K(qt,"|"),SM=K(qt,"^"),TM=K(qt,"<<"),bM=K(qt,">>");te("add",Wt);te("sub",Ft);te("mul",ot);te("div",ns);te("modInt",lg);te("equal",uM);te("notEqual",hM);te("lessThan",dM);te("greaterThan",ug);te("lessThanEqual",pM);te("greaterThanEqual",fM);te("and",mM);te("or",gM);te("not",xM);te("xor",_M);te("bitAnd",yM);te("bitNot",vM);te("bitOr",MM);te("bitXor",SM);te("shiftLeft",TM);te("shiftRight",bM);const wM=(...s)=>(console.warn("TSL.OperatorNode: .remainder() has been renamed to .modInt()."),lg(...s));te("remainder",wM);class V extends pt{static get type(){return"MathNode"}constructor(e,t,n=null,i=null){super(),this.method=e,this.aNode=t,this.bNode=n,this.cNode=i}getInputType(e){const t=this.aNode.getNodeType(e),n=this.bNode?this.bNode.getNodeType(e):null,i=this.cNode?this.cNode.getNodeType(e):null,r=e.isMatrix(t)?0:e.getTypeLength(t),o=e.isMatrix(n)?0:e.getTypeLength(n),a=e.isMatrix(i)?0:e.getTypeLength(i);return r>o&&r>a?t:o>a?n:a>r?i:t}getNodeType(e){const t=this.method;return t===V.LENGTH||t===V.DISTANCE||t===V.DOT?"float":t===V.CROSS?"vec3":t===V.ALL?"bool":t===V.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):t===V.MOD?this.aNode.getNodeType(e):this.getInputType(e)}generate(e,t){const n=this.method,i=this.getNodeType(e),r=this.getInputType(e),o=this.aNode,a=this.bNode,c=this.cNode,l=e.renderer.isWebGLRenderer===!0;if(n===V.TRANSFORM_DIRECTION){let u=o,h=a;e.isMatrix(u.getNodeType(e))?h=oe(D(h),0):u=oe(D(u),0);const d=ot(u,h).xyz;return vi(d).build(e,t)}else{if(n===V.NEGATE)return e.format("( - "+o.build(e,r)+" )",i,t);if(n===V.ONE_MINUS)return Ft(1,o).build(e,t);if(n===V.RECIPROCAL)return ns(1,o).build(e,t);if(n===V.DIFFERENCE)return Dt(Ft(o,a)).build(e,t);{const u=[];return n===V.CROSS||n===V.MOD?u.push(o.build(e,i),a.build(e,i)):l&&n===V.STEP?u.push(o.build(e,e.getTypeLength(o.getNodeType(e))===1?"float":r),a.build(e,r)):l&&(n===V.MIN||n===V.MAX)||n===V.MOD?u.push(o.build(e,r),a.build(e,e.getTypeLength(a.getNodeType(e))===1?"float":r)):n===V.REFRACT?u.push(o.build(e,r),a.build(e,r),c.build(e,"float")):n===V.MIX?u.push(o.build(e,r),a.build(e,r),c.build(e,e.getTypeLength(c.getNodeType(e))===1?"float":r)):(u.push(o.build(e,r)),a!==null&&u.push(a.build(e,r)),c!==null&&u.push(c.build(e,r))),e.format(`${e.getMethod(n,i)}( ${u.join(", ")} )`,i,t)}}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}V.ALL="all";V.ANY="any";V.EQUALS="equals";V.RADIANS="radians";V.DEGREES="degrees";V.EXP="exp";V.EXP2="exp2";V.LOG="log";V.LOG2="log2";V.SQRT="sqrt";V.INVERSE_SQRT="inversesqrt";V.FLOOR="floor";V.CEIL="ceil";V.NORMALIZE="normalize";V.FRACT="fract";V.SIN="sin";V.COS="cos";V.TAN="tan";V.ASIN="asin";V.ACOS="acos";V.ATAN="atan";V.ABS="abs";V.SIGN="sign";V.LENGTH="length";V.NEGATE="negate";V.ONE_MINUS="oneMinus";V.DFDX="dFdx";V.DFDY="dFdy";V.ROUND="round";V.RECIPROCAL="reciprocal";V.TRUNC="trunc";V.FWIDTH="fwidth";V.BITCAST="bitcast";V.TRANSPOSE="transpose";V.ATAN2="atan2";V.MIN="min";V.MAX="max";V.MOD="mod";V.STEP="step";V.REFLECT="reflect";V.DISTANCE="distance";V.DIFFERENCE="difference";V.DOT="dot";V.CROSS="cross";V.POW="pow";V.TRANSFORM_DIRECTION="transformDirection";V.MIX="mix";V.CLAMP="clamp";V.REFRACT="refract";V.SMOOTHSTEP="smoothstep";V.FACEFORWARD="faceforward";const AM=A(1e-6),zP=A(1e6),eo=A(Math.PI),kP=A(Math.PI*2),hg=K(V,V.ALL),NM=K(V,V.ANY),EM=K(V,V.EQUALS),CM=K(V,V.RADIANS),RM=K(V,V.DEGREES),dg=K(V,V.EXP),mh=K(V,V.EXP2),pg=K(V,V.LOG),al=K(V,V.LOG2),os=K(V,V.SQRT),IM=K(V,V.INVERSE_SQRT),mr=K(V,V.FLOOR),fg=K(V,V.CEIL),vi=K(V,V.NORMALIZE),gr=K(V,V.FRACT),Cn=K(V,V.SIN),Mi=K(V,V.COS),PM=K(V,V.TAN),LM=K(V,V.ASIN),gh=K(V,V.ACOS),DM=K(V,V.ATAN),Dt=K(V,V.ABS),cl=K(V,V.SIGN),Kr=K(V,V.LENGTH),UM=K(V,V.NEGATE),FM=K(V,V.ONE_MINUS),OM=K(V,V.DFDX),VM=K(V,V.DFDY),BM=K(V,V.ROUND),zM=K(V,V.RECIPROCAL),mg=K(V,V.TRUNC),kM=K(V,V.FWIDTH),GP=K(V,V.BITCAST),GM=K(V,V.TRANSPOSE),HM=K(V,V.ATAN2),Mn=K(V,V.MIN),ft=K(V,V.MAX),Ad=K(V,V.MOD),ll=K(V,V.STEP),WM=K(V,V.REFLECT),XM=K(V,V.DISTANCE),qM=K(V,V.DIFFERENCE),$t=K(V,V.DOT),Qo=K(V,V.CROSS),Kn=K(V,V.POW),gg=K(V,V.POW,2),$M=K(V,V.POW,3),YM=K(V,V.POW,4),ZM=K(V,V.TRANSFORM_DIRECTION),JM=s=>ot(cl(s),Kn(Dt(s),1/3)),xg=s=>$t(s,s),it=K(V,V.MIX),cn=(s,e=0,t=1)=>H(new V(V.CLAMP,H(s),H(e),H(t))),KM=s=>cn(s),_g=K(V,V.REFRACT),ti=K(V,V.SMOOTHSTEP),jM=K(V,V.FACEFORWARD),yg=U(([s])=>{const n=43758.5453,i=$t(s.xy,z(12.9898,78.233)),r=Ad(i,eo);return gr(Cn(r).mul(n))}),QM=(s,e,t)=>it(e,t,s),eS=(s,e,t)=>ti(e,t,s);te("all",hg);te("any",NM);te("equals",EM);te("radians",CM);te("degrees",RM);te("exp",dg);te("exp2",mh);te("log",pg);te("log2",al);te("sqrt",os);te("inverseSqrt",IM);te("floor",mr);te("ceil",fg);te("normalize",vi);te("fract",gr);te("sin",Cn);te("cos",Mi);te("tan",PM);te("asin",LM);te("acos",gh);te("atan",DM);te("abs",Dt);te("sign",cl);te("length",Kr);te("lengthSq",xg);te("negate",UM);te("oneMinus",FM);te("dFdx",OM);te("dFdy",VM);te("round",BM);te("reciprocal",zM);te("trunc",mg);te("fwidth",kM);te("atan2",HM);te("min",Mn);te("max",ft);te("mod",Ad);te("step",ll);te("reflect",WM);te("distance",XM);te("dot",$t);te("cross",Qo);te("pow",Kn);te("pow2",gg);te("pow3",$M);te("pow4",YM);te("transformDirection",ZM);te("mix",QM);te("clamp",cn);te("refract",_g);te("smoothstep",eS);te("faceForward",jM);te("difference",qM);te("saturate",KM);te("cbrt",JM);te("transpose",GM);te("rand",yg);class HP extends Ye{static get type(){return"ConditionalNode"}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}getNodeType(e){const t=this.ifNode.getNodeType(e);if(this.elseNode!==null){const n=this.elseNode.getNodeType(e);if(e.getTypeLength(n)>e.getTypeLength(t))return n}return t}setup(e){const t=this.condNode.cache(),n=this.ifNode.cache(),i=this.elseNode?this.elseNode.cache():null,r=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=r,i!==null&&(e.getDataFromNode(i).parentNodeBlock=r);const o=e.getNodeProperties(this);o.condNode=t,o.ifNode=n.context({nodeBlock:n}),o.elseNode=i?i.context({nodeBlock:i}):null}generate(e,t){const n=this.getNodeType(e),i=e.getDataFromNode(this);if(i.nodeProperty!==void 0)return i.nodeProperty;const{condNode:r,ifNode:o,elseNode:a}=e.getNodeProperties(this),c=t!=="void",l=c?ai(n).build(e):"";i.nodeProperty=l;const u=r.build(e,"bool");e.addFlowCode(`
3847
+ }`;class GR{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){const i=new Xt,r=e.properties.get(i);r.__webglTexture=t.texture,(t.depthNear!=n.depthNear||t.depthFar!=n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new ki({vertexShader:zR,fragmentShader:kR,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new kt(new ro(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class HR extends Ai{constructor(e,t){super();const n=this;let i=null,r=1,o=null,a="local-floor",c=1,l=null,u=null,h=null,d=null,p=null,f=null;const x=new GR,m=t.getContextAttributes();let g=null,y=null;const _=[],v=[],I=new J;let T=null;const w=new hn;w.layers.enable(1),w.viewport=new st;const C=new hn;C.layers.enable(2),C.viewport=new st;const F=[w,C],M=new rm;M.layers.enable(1),M.layers.enable(2);let b=null,G=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.controllerAutoUpdate=!0,this.getController=function(ne){let ue=_[ne];return ue===void 0&&(ue=new yp,_[ne]=ue),ue.getTargetRaySpace()},this.getControllerGrip=function(ne){let ue=_[ne];return ue===void 0&&(ue=new yp,_[ne]=ue),ue.getGripSpace()},this.getHand=function(ne){let ue=_[ne];return ue===void 0&&(ue=new yp,_[ne]=ue),ue.getHandSpace()};function W(ne){const ue=v.indexOf(ne.inputSource);if(ue===-1)return;const Ae=_[ue];Ae!==void 0&&(Ae.update(ne.inputSource,ne.frame,l||o),Ae.dispatchEvent({type:ne.type,data:ne.inputSource}))}function $(){i.removeEventListener("select",W),i.removeEventListener("selectstart",W),i.removeEventListener("selectend",W),i.removeEventListener("squeeze",W),i.removeEventListener("squeezestart",W),i.removeEventListener("squeezeend",W),i.removeEventListener("end",$),i.removeEventListener("inputsourceschange",ie);for(let ne=0;ne<_.length;ne++){const ue=v[ne];ue!==null&&(v[ne]=null,_[ne]&&_[ne].disconnect(ue))}b=null,G=null,x.reset(),e.setRenderTarget(g),p=null,d=null,h=null,i=null,y=null,ht.stop(),n.isPresenting=!1,e.setPixelRatio(T),e.setSize(I.width,I.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ne){r=ne,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ne){a=ne,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(ne){l=ne},this.getBaseLayer=function(){return d!==null?d:p},this.getBinding=function(){return h},this.getFrame=function(){return f},this.getSession=function(){return i},this.setSession=async function(ne){if(i=ne,i!==null){if(g=e.getRenderTarget(),i.addEventListener("select",W),i.addEventListener("selectstart",W),i.addEventListener("selectend",W),i.addEventListener("squeeze",W),i.addEventListener("squeezestart",W),i.addEventListener("squeezeend",W),i.addEventListener("end",$),i.addEventListener("inputsourceschange",ie),m.xrCompatible!==!0&&await t.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(I),typeof XRWebGLBinding<"u"&&"createProjectionLayer"in XRWebGLBinding.prototype){let Ae=null,ge=null,Ze=null;m.depth&&(Ze=m.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,Ae=m.stencil?ar:Qs,ge=m.stencil?or:Bi);const Xe={colorFormat:t.RGBA8,depthFormat:Ze,scaleFactor:r};h=new XRWebGLBinding(i,t),d=h.createProjectionLayer(Xe),i.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),y=new zi(d.textureWidth,d.textureHeight,{format:Rn,type:es,depthTexture:new ao(d.textureWidth,d.textureHeight,ge,void 0,void 0,void 0,void 0,void 0,void 0,Ae),stencilBuffer:m.stencil,colorSpace:e.outputColorSpace,samples:m.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1})}else{const Ae={antialias:m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:r};p=new XRWebGLLayer(i,t,Ae),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),y=new zi(p.framebufferWidth,p.framebufferHeight,{format:Rn,type:es,colorSpace:e.outputColorSpace,stencilBuffer:m.stencil})}y.isXRRenderTarget=!0,this.setFoveation(c),l=null,o=await i.requestReferenceSpace(a),ht.setContext(i),ht.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return x.getDepthTexture()};function ie(ne){for(let ue=0;ue<ne.removed.length;ue++){const Ae=ne.removed[ue],ge=v.indexOf(Ae);ge>=0&&(v[ge]=null,_[ge]&&_[ge].disconnect(Ae))}for(let ue=0;ue<ne.added.length;ue++){const Ae=ne.added[ue];let ge=v.indexOf(Ae);if(ge===-1){for(let Xe=0;Xe<_.length;Xe++)if(Xe>=v.length){v.push(Ae),ge=Xe;break}else if(v[Xe]===null){v[Xe]=Ae,ge=Xe;break}if(ge===-1)break}const Ze=_[ge];Ze&&Ze.connect(Ae)}}const q=new E,he=new E;function Q(ne,ue,Ae){q.setFromMatrixPosition(ue.matrixWorld),he.setFromMatrixPosition(Ae.matrixWorld);const ge=q.distanceTo(he),Ze=ue.projectionMatrix.elements,Xe=Ae.projectionMatrix.elements,Je=Ze[14]/(Ze[10]-1),dt=Ze[14]/(Ze[10]+1),ae=(Ze[9]+1)/Ze[5],P=(Ze[9]-1)/Ze[5],Me=(Ze[8]-1)/Ze[0],ye=(Xe[8]+1)/Xe[0],de=Je*Me,Te=Je*ye,qe=ge/(-Me+ye),Ie=qe*-Me;if(ue.matrixWorld.decompose(ne.position,ne.quaternion,ne.scale),ne.translateX(Ie),ne.translateZ(qe),ne.matrixWorld.compose(ne.position,ne.quaternion,ne.scale),ne.matrixWorldInverse.copy(ne.matrixWorld).invert(),Ze[10]===-1)ne.projectionMatrix.copy(ue.projectionMatrix),ne.projectionMatrixInverse.copy(ue.projectionMatrixInverse);else{const R=Je+qe,S=dt+qe,X=de-Ie,re=Te+(ge-Ie),ce=ae*dt/S*R,se=P*dt/S*R;ne.projectionMatrix.makePerspective(X,re,ce,se,R,S),ne.projectionMatrixInverse.copy(ne.projectionMatrix).invert()}}function we(ne,ue){ue===null?ne.matrixWorld.copy(ne.matrix):ne.matrixWorld.multiplyMatrices(ue.matrixWorld,ne.matrix),ne.matrixWorldInverse.copy(ne.matrixWorld).invert()}this.updateCamera=function(ne){if(i===null)return;let ue=ne.near,Ae=ne.far;x.texture!==null&&(x.depthNear>0&&(ue=x.depthNear),x.depthFar>0&&(Ae=x.depthFar)),M.near=C.near=w.near=ue,M.far=C.far=w.far=Ae,(b!==M.near||G!==M.far)&&(i.updateRenderState({depthNear:M.near,depthFar:M.far}),b=M.near,G=M.far);const ge=ne.parent,Ze=M.cameras;we(M,ge);for(let Xe=0;Xe<Ze.length;Xe++)we(Ze[Xe],ge);Ze.length===2?Q(M,w,C):M.projectionMatrix.copy(w.projectionMatrix),Ne(ne,M,ge)};function Ne(ne,ue,Ae){Ae===null?ne.matrix.copy(ue.matrixWorld):(ne.matrix.copy(Ae.matrixWorld),ne.matrix.invert(),ne.matrix.multiply(ue.matrixWorld)),ne.matrix.decompose(ne.position,ne.quaternion,ne.scale),ne.updateMatrixWorld(!0),ne.projectionMatrix.copy(ue.projectionMatrix),ne.projectionMatrixInverse.copy(ue.projectionMatrixInverse),ne.isPerspectiveCamera&&(ne.fov=ra*2*Math.atan(1/ne.projectionMatrix.elements[5]),ne.zoom=1)}this.getCamera=function(){return M},this.getFoveation=function(){if(!(d===null&&p===null))return c},this.setFoveation=function(ne){c=ne,d!==null&&(d.fixedFoveation=ne),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=ne)},this.hasDepthSensing=function(){return x.texture!==null},this.getDepthSensingMesh=function(){return x.getMesh(M)};let Ee=null;function Qe(ne,ue){if(u=ue.getViewerPose(l||o),f=ue,u!==null){const Ae=u.views;p!==null&&(e.setRenderTargetFramebuffer(y,p.framebuffer),e.setRenderTarget(y));let ge=!1;Ae.length!==M.cameras.length&&(M.cameras.length=0,ge=!0);for(let Xe=0;Xe<Ae.length;Xe++){const Je=Ae[Xe];let dt=null;if(p!==null)dt=p.getViewport(Je);else{const P=h.getViewSubImage(d,Je);dt=P.viewport,Xe===0&&(e.setRenderTargetTextures(y,P.colorTexture,d.ignoreDepthValues?void 0:P.depthStencilTexture),e.setRenderTarget(y))}let ae=F[Xe];ae===void 0&&(ae=new hn,ae.layers.enable(Xe),ae.viewport=new st,F[Xe]=ae),ae.matrix.fromArray(Je.transform.matrix),ae.matrix.decompose(ae.position,ae.quaternion,ae.scale),ae.projectionMatrix.fromArray(Je.projectionMatrix),ae.projectionMatrixInverse.copy(ae.projectionMatrix).invert(),ae.viewport.set(dt.x,dt.y,dt.width,dt.height),Xe===0&&(M.matrix.copy(ae.matrix),M.matrix.decompose(M.position,M.quaternion,M.scale)),ge===!0&&M.cameras.push(ae)}const Ze=i.enabledFeatures;if(Ze&&Ze.includes("depth-sensing")){const Xe=h.getDepthInformation(Ae[0]);Xe&&Xe.isValid&&Xe.texture&&x.init(e,Xe,i.renderState)}}if(n.controllerAutoUpdate)for(let Ae=0;Ae<_.length;Ae++){const ge=v[Ae],Ze=_[Ae];ge!==null&&Ze!==void 0&&Ze.update(ge,ue,l||o)}Ee&&Ee(ne,ue),ue.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:ue}),f=null}const ht=new Gy;ht.setAnimationLoop(Qe),this.setAnimationLoop=function(ne){Ee=ne},this.dispose=function(){}}}const Ar=new ui,WR=new Fe;function XR(s,e){function t(m,g){m.matrixAutoUpdate===!0&&m.updateMatrix(),g.value.copy(m.matrix)}function n(m,g){g.color.getRGB(m.fogColor.value,ky(s)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function i(m,g,y,_,v){g.isMeshBasicMaterial||g.isMeshLambertMaterial?r(m,g):g.isMeshToonMaterial?(r(m,g),h(m,g)):g.isMeshPhongMaterial?(r(m,g),u(m,g)):g.isMeshStandardMaterial?(r(m,g),d(m,g),g.isMeshPhysicalMaterial&&p(m,g,v)):g.isMeshMatcapMaterial?(r(m,g),f(m,g)):g.isMeshDepthMaterial?r(m,g):g.isMeshDistanceMaterial?(r(m,g),x(m,g)):g.isMeshNormalMaterial?r(m,g):g.isLineBasicMaterial?(o(m,g),g.isLineDashedMaterial&&a(m,g)):g.isPointsMaterial?c(m,g,y,_):g.isSpriteMaterial?l(m,g):g.isShadowMaterial?(m.color.value.copy(g.color),m.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function r(m,g){m.opacity.value=g.opacity,g.color&&m.diffuse.value.copy(g.color),g.emissive&&m.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(m.map.value=g.map,t(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.bumpMap&&(m.bumpMap.value=g.bumpMap,t(g.bumpMap,m.bumpMapTransform),m.bumpScale.value=g.bumpScale,g.side===ln&&(m.bumpScale.value*=-1)),g.normalMap&&(m.normalMap.value=g.normalMap,t(g.normalMap,m.normalMapTransform),m.normalScale.value.copy(g.normalScale),g.side===ln&&m.normalScale.value.negate()),g.displacementMap&&(m.displacementMap.value=g.displacementMap,t(g.displacementMap,m.displacementMapTransform),m.displacementScale.value=g.displacementScale,m.displacementBias.value=g.displacementBias),g.emissiveMap&&(m.emissiveMap.value=g.emissiveMap,t(g.emissiveMap,m.emissiveMapTransform)),g.specularMap&&(m.specularMap.value=g.specularMap,t(g.specularMap,m.specularMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);const y=e.get(g),_=y.envMap,v=y.envMapRotation;_&&(m.envMap.value=_,Ar.copy(v),Ar.x*=-1,Ar.y*=-1,Ar.z*=-1,_.isCubeTexture&&_.isRenderTargetTexture===!1&&(Ar.y*=-1,Ar.z*=-1),m.envMapRotation.value.setFromMatrix4(WR.makeRotationFromEuler(Ar)),m.flipEnvMap.value=_.isCubeTexture&&_.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap&&(m.lightMap.value=g.lightMap,m.lightMapIntensity.value=g.lightMapIntensity,t(g.lightMap,m.lightMapTransform)),g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,m.aoMapTransform))}function o(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform))}function a(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function c(m,g,y,_){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*y,m.scale.value=_*.5,g.map&&(m.map.value=g.map,t(g.map,m.uvTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function l(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function u(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function h(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function d(m,g){m.metalness.value=g.metalness,g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,m.metalnessMapTransform)),m.roughness.value=g.roughness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,m.roughnessMapTransform)),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function p(m,g,y){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,m.sheenColorMapTransform)),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,m.sheenRoughnessMapTransform))),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,m.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(m.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===ln&&m.clearcoatNormalScale.value.negate())),g.dispersion>0&&(m.dispersion.value=g.dispersion),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,m.iridescenceMapTransform)),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=y.texture,m.transmissionSamplerSize.value.set(y.width,y.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,m.transmissionMapTransform)),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(m.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(m.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,m.specularColorMapTransform)),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,m.specularIntensityMapTransform))}function f(m,g){g.matcap&&(m.matcap.value=g.matcap)}function x(m,g){const y=e.get(g).light;m.referencePosition.value.setFromMatrixPosition(y.matrixWorld),m.nearDistance.value=y.shadow.camera.near,m.farDistance.value=y.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function qR(s,e,t,n){let i={},r={},o=[];const a=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function c(y,_){const v=_.program;n.uniformBlockBinding(y,v)}function l(y,_){let v=i[y.id];v===void 0&&(f(y),v=u(y),i[y.id]=v,y.addEventListener("dispose",m));const I=_.program;n.updateUBOMapping(y,I);const T=e.render.frame;r[y.id]!==T&&(d(y),r[y.id]=T)}function u(y){const _=h();y.__bindingPointIndex=_;const v=s.createBuffer(),I=y.__size,T=y.usage;return s.bindBuffer(s.UNIFORM_BUFFER,v),s.bufferData(s.UNIFORM_BUFFER,I,T),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,_,v),v}function h(){for(let y=0;y<a;y++)if(o.indexOf(y)===-1)return o.push(y),y;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(y){const _=i[y.id],v=y.uniforms,I=y.__cache;s.bindBuffer(s.UNIFORM_BUFFER,_);for(let T=0,w=v.length;T<w;T++){const C=Array.isArray(v[T])?v[T]:[v[T]];for(let F=0,M=C.length;F<M;F++){const b=C[F];if(p(b,T,F,I)===!0){const G=b.__offset,W=Array.isArray(b.value)?b.value:[b.value];let $=0;for(let ie=0;ie<W.length;ie++){const q=W[ie],he=x(q);typeof q=="number"||typeof q=="boolean"?(b.__data[0]=q,s.bufferSubData(s.UNIFORM_BUFFER,G+$,b.__data)):q.isMatrix3?(b.__data[0]=q.elements[0],b.__data[1]=q.elements[1],b.__data[2]=q.elements[2],b.__data[3]=0,b.__data[4]=q.elements[3],b.__data[5]=q.elements[4],b.__data[6]=q.elements[5],b.__data[7]=0,b.__data[8]=q.elements[6],b.__data[9]=q.elements[7],b.__data[10]=q.elements[8],b.__data[11]=0):(q.toArray(b.__data,$),$+=he.storage/Float32Array.BYTES_PER_ELEMENT)}s.bufferSubData(s.UNIFORM_BUFFER,G,b.__data)}}}s.bindBuffer(s.UNIFORM_BUFFER,null)}function p(y,_,v,I){const T=y.value,w=_+"_"+v;if(I[w]===void 0)return typeof T=="number"||typeof T=="boolean"?I[w]=T:I[w]=T.clone(),!0;{const C=I[w];if(typeof T=="number"||typeof T=="boolean"){if(C!==T)return I[w]=T,!0}else if(C.equals(T)===!1)return C.copy(T),!0}return!1}function f(y){const _=y.uniforms;let v=0;const I=16;for(let w=0,C=_.length;w<C;w++){const F=Array.isArray(_[w])?_[w]:[_[w]];for(let M=0,b=F.length;M<b;M++){const G=F[M],W=Array.isArray(G.value)?G.value:[G.value];for(let $=0,ie=W.length;$<ie;$++){const q=W[$],he=x(q),Q=v%I,we=Q%he.boundary,Ne=Q+we;v+=we,Ne!==0&&I-Ne<he.storage&&(v+=I-Ne),G.__data=new Float32Array(he.storage/Float32Array.BYTES_PER_ELEMENT),G.__offset=v,v+=he.storage}}}const T=v%I;return T>0&&(v+=I-T),y.__size=v,y.__cache={},this}function x(y){const _={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(_.boundary=4,_.storage=4):y.isVector2?(_.boundary=8,_.storage=8):y.isVector3||y.isColor?(_.boundary=16,_.storage=12):y.isVector4?(_.boundary=16,_.storage=16):y.isMatrix3?(_.boundary=48,_.storage=48):y.isMatrix4?(_.boundary=64,_.storage=64):y.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",y),_}function m(y){const _=y.target;_.removeEventListener("dispose",m);const v=o.indexOf(_.__bindingPointIndex);o.splice(v,1),s.deleteBuffer(i[_.id]),delete i[_.id],delete r[_.id]}function g(){for(const y in i)s.deleteBuffer(i[y]);o=[],i={},r={}}return{bind:c,update:l,dispose:g}}class Yy{constructor(e={}){const{canvas:t=Fy(),context:n=null,depth:i=!0,stencil:r=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1}=e;this.isWebGLRenderer=!0;let d;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");d=n.getContextAttributes().alpha}else d=o;const p=new Uint32Array(4),f=new Int32Array(4);let x=null,m=null;const g=[],y=[];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._outputColorSpace=kn,this.toneMapping=Ti,this.toneMappingExposure=1;const _=this;let v=!1,I=0,T=0,w=null,C=-1,F=null;const M=new st,b=new st;let G=null;const W=new _e(0);let $=0,ie=t.width,q=t.height,he=1,Q=null,we=null;const Ne=new st(0,0,ie,q),Ee=new st(0,0,ie,q);let Qe=!1;const ht=new ga;let ne=!1,ue=!1;const Ae=new Fe,ge=new Fe,Ze=new E,Xe=new st,Je={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let dt=!1;function ae(){return w===null?he:1}let P=n;function Me(N,B){return t.getContext(N,B)}try{const N={alpha:!0,depth:i,stencil:r,antialias:a,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Ks}`),t.addEventListener("webglcontextlost",le,!1),t.addEventListener("webglcontextrestored",Ce,!1),t.addEventListener("webglcontextcreationerror",Le,!1),P===null){const B="webgl2";if(P=Me(B,N),P===null)throw Me(B)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(N){throw console.error("THREE.WebGLRenderer: "+N.message),N}let ye,de,Te,qe,Ie,R,S,X,re,ce,se,ke,be,De,vt,me,Ue,tt,nt,Be,Mt,ct,Ot,O;function Pe(){ye=new jE(P),ye.init(),ct=new $y(P,ye),de=new $E(P,ye,e,ct),Te=new PR(P),de.reverseDepthBuffer&&Te.buffers.depth.setReversed(!0),qe=new tC(P),Ie=new yR,R=new VR(P,ye,Te,Ie,de,ct,qe),S=new ZE(_),X=new KE(_),re=new l1(P),Ot=new XE(P,re),ce=new QE(P,re,qe,Ot),se=new iC(P,ce,re,qe),nt=new nC(P,de,R),me=new YE(Ie),ke=new _R(_,S,X,ye,de,Ot,me),be=new XR(_,Ie),De=new MR,vt=new NR(ye),tt=new WE(_,S,X,Te,se,d,c),Ue=new RR(_,se,de),O=new qR(P,qe,de,Te),Be=new qE(P,ye,qe),Mt=new eC(P,ye,qe),qe.programs=ke.programs,_.capabilities=de,_.extensions=ye,_.properties=Ie,_.renderLists=De,_.shadowMap=Ue,_.state=Te,_.info=qe}Pe();const ee=new HR(_,P);this.xr=ee,this.getContext=function(){return P},this.getContextAttributes=function(){return P.getContextAttributes()},this.forceContextLoss=function(){const N=ye.get("WEBGL_lose_context");N&&N.loseContext()},this.forceContextRestore=function(){const N=ye.get("WEBGL_lose_context");N&&N.restoreContext()},this.getPixelRatio=function(){return he},this.setPixelRatio=function(N){N!==void 0&&(he=N,this.setSize(ie,q,!1))},this.getSize=function(N){return N.set(ie,q)},this.setSize=function(N,B,Y=!0){if(ee.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}ie=N,q=B,t.width=Math.floor(N*he),t.height=Math.floor(B*he),Y===!0&&(t.style.width=N+"px",t.style.height=B+"px"),this.setViewport(0,0,N,B)},this.getDrawingBufferSize=function(N){return N.set(ie*he,q*he).floor()},this.setDrawingBufferSize=function(N,B,Y){ie=N,q=B,he=Y,t.width=Math.floor(N*Y),t.height=Math.floor(B*Y),this.setViewport(0,0,N,B)},this.getCurrentViewport=function(N){return N.copy(M)},this.getViewport=function(N){return N.copy(Ne)},this.setViewport=function(N,B,Y,Z){N.isVector4?Ne.set(N.x,N.y,N.z,N.w):Ne.set(N,B,Y,Z),Te.viewport(M.copy(Ne).multiplyScalar(he).round())},this.getScissor=function(N){return N.copy(Ee)},this.setScissor=function(N,B,Y,Z){N.isVector4?Ee.set(N.x,N.y,N.z,N.w):Ee.set(N,B,Y,Z),Te.scissor(b.copy(Ee).multiplyScalar(he).round())},this.getScissorTest=function(){return Qe},this.setScissorTest=function(N){Te.setScissorTest(Qe=N)},this.setOpaqueSort=function(N){Q=N},this.setTransparentSort=function(N){we=N},this.getClearColor=function(N){return N.copy(tt.getClearColor())},this.setClearColor=function(){tt.setClearColor.apply(tt,arguments)},this.getClearAlpha=function(){return tt.getClearAlpha()},this.setClearAlpha=function(){tt.setClearAlpha.apply(tt,arguments)},this.clear=function(N=!0,B=!0,Y=!0){let Z=0;if(N){let k=!1;if(w!==null){const xe=w.texture.format;k=xe===Bh||xe===Vh||xe===Wc}if(k){const xe=w.texture.type,Re=xe===es||xe===Bi||xe===ta||xe===or||xe===Lh||xe===Dh,ze=tt.getClearColor(),Ge=tt.getClearAlpha(),je=ze.r,et=ze.g,He=ze.b;Re?(p[0]=je,p[1]=et,p[2]=He,p[3]=Ge,P.clearBufferuiv(P.COLOR,0,p)):(f[0]=je,f[1]=et,f[2]=He,f[3]=Ge,P.clearBufferiv(P.COLOR,0,f))}else Z|=P.COLOR_BUFFER_BIT}B&&(Z|=P.DEPTH_BUFFER_BIT,P.clearDepth(this.capabilities.reverseDepthBuffer?0:1)),Y&&(Z|=P.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),P.clear(Z)},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",le,!1),t.removeEventListener("webglcontextrestored",Ce,!1),t.removeEventListener("webglcontextcreationerror",Le,!1),De.dispose(),vt.dispose(),Ie.dispose(),S.dispose(),X.dispose(),se.dispose(),Ot.dispose(),O.dispose(),ke.dispose(),ee.dispose(),ee.removeEventListener("sessionstart",u0),ee.removeEventListener("sessionend",h0),vr.stop()};function le(N){N.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),v=!0}function Ce(){console.log("THREE.WebGLRenderer: Context Restored."),v=!1;const N=qe.autoReset,B=Ue.enabled,Y=Ue.autoUpdate,Z=Ue.needsUpdate,k=Ue.type;Pe(),qe.autoReset=N,Ue.enabled=B,Ue.autoUpdate=Y,Ue.needsUpdate=Z,Ue.type=k}function Le(N){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",N.statusMessage)}function bt(N){const B=N.target;B.removeEventListener("dispose",bt),on(B)}function on(N){ni(N),Ie.remove(N)}function ni(N){const B=Ie.get(N).programs;B!==void 0&&(B.forEach(function(Y){ke.releaseProgram(Y)}),N.isShaderMaterial&&ke.releaseShaderCache(N))}this.renderBufferDirect=function(N,B,Y,Z,k,xe){B===null&&(B=Je);const Re=k.isMesh&&k.matrixWorld.determinant()<0,ze=Kw(N,B,Y,Z,k);Te.setMaterial(Z,Re);let Ge=Y.index,je=1;if(Z.wireframe===!0){if(Ge=ce.getWireframeAttribute(Y),Ge===void 0)return;je=2}const et=Y.drawRange,He=Y.attributes.position;let Lt=et.start*je,Gt=(et.start+et.count)*je;xe!==null&&(Lt=Math.max(Lt,xe.start*je),Gt=Math.min(Gt,(xe.start+xe.count)*je)),Ge!==null?(Lt=Math.max(Lt,0),Gt=Math.min(Gt,Ge.count)):He!=null&&(Lt=Math.max(Lt,0),Gt=Math.min(Gt,He.count));const Jt=Gt-Lt;if(Jt<0||Jt===1/0)return;Ot.setup(k,Z,ze,Y,Ge);let fi,Rt=Be;if(Ge!==null&&(fi=re.get(Ge),Rt=Mt,Rt.setIndex(fi)),k.isMesh)Z.wireframe===!0?(Te.setLineWidth(Z.wireframeLinewidth*ae()),Rt.setMode(P.LINES)):Rt.setMode(P.TRIANGLES);else if(k.isLine){let $e=Z.linewidth;$e===void 0&&($e=1),Te.setLineWidth($e*ae()),k.isLineSegments?Rt.setMode(P.LINES):k.isLineLoop?Rt.setMode(P.LINE_LOOP):Rt.setMode(P.LINE_STRIP)}else k.isPoints?Rt.setMode(P.POINTS):k.isSprite&&Rt.setMode(P.TRIANGLES);if(k.isBatchedMesh)if(k._multiDrawInstances!==null)Rt.renderMultiDrawInstances(k._multiDrawStarts,k._multiDrawCounts,k._multiDrawCount,k._multiDrawInstances);else if(ye.get("WEBGL_multi_draw"))Rt.renderMultiDraw(k._multiDrawStarts,k._multiDrawCounts,k._multiDrawCount);else{const $e=k._multiDrawStarts,An=k._multiDrawCounts,It=k._multiDrawCount,Xi=Ge?re.get(Ge).bytesPerElement:1,fo=Ie.get(Z).currentProgram.getUniforms();for(let mi=0;mi<It;mi++)fo.setValue(P,"_gl_DrawID",mi),Rt.render($e[mi]/Xi,An[mi])}else if(k.isInstancedMesh)Rt.renderInstances(Lt,Jt,k.count);else if(Y.isInstancedBufferGeometry){const $e=Y._maxInstanceCount!==void 0?Y._maxInstanceCount:1/0,An=Math.min(Y.instanceCount,$e);Rt.renderInstances(Lt,Jt,An)}else Rt.render(Lt,Jt)};function Et(N,B,Y){N.transparent===!0&&N.side===Ji&&N.forceSinglePass===!1?(N.side=ln,N.needsUpdate=!0,bl(N,B,Y),N.side=fs,N.needsUpdate=!0,bl(N,B,Y),N.side=Ji):bl(N,B,Y)}this.compile=function(N,B,Y=null){Y===null&&(Y=N),m=vt.get(Y),m.init(B),y.push(m),Y.traverseVisible(function(k){k.isLight&&k.layers.test(B.layers)&&(m.pushLight(k),k.castShadow&&m.pushShadow(k))}),N!==Y&&N.traverseVisible(function(k){k.isLight&&k.layers.test(B.layers)&&(m.pushLight(k),k.castShadow&&m.pushShadow(k))}),m.setupLights();const Z=new Set;return N.traverse(function(k){if(!(k.isMesh||k.isPoints||k.isLine||k.isSprite))return;const xe=k.material;if(xe)if(Array.isArray(xe))for(let Re=0;Re<xe.length;Re++){const ze=xe[Re];Et(ze,Y,k),Z.add(ze)}else Et(xe,Y,k),Z.add(xe)}),y.pop(),m=null,Z},this.compileAsync=function(N,B,Y=null){const Z=this.compile(N,B,Y);return new Promise(k=>{function xe(){if(Z.forEach(function(Re){Ie.get(Re).currentProgram.isReady()&&Z.delete(Re)}),Z.size===0){k(N);return}setTimeout(xe,10)}ye.get("KHR_parallel_shader_compile")!==null?xe():setTimeout(xe,10)})};let ii=null;function vs(N){ii&&ii(N)}function u0(){vr.stop()}function h0(){vr.start()}const vr=new Gy;vr.setAnimationLoop(vs),typeof self<"u"&&vr.setContext(self),this.setAnimationLoop=function(N){ii=N,ee.setAnimationLoop(N),N===null?vr.stop():vr.start()},ee.addEventListener("sessionstart",u0),ee.addEventListener("sessionend",h0),this.render=function(N,B){if(B!==void 0&&B.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(v===!0)return;if(N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),B.parent===null&&B.matrixWorldAutoUpdate===!0&&B.updateMatrixWorld(),ee.enabled===!0&&ee.isPresenting===!0&&(ee.cameraAutoUpdate===!0&&ee.updateCamera(B),B=ee.getCamera()),N.isScene===!0&&N.onBeforeRender(_,N,B,w),m=vt.get(N,y.length),m.init(B),y.push(m),ge.multiplyMatrices(B.projectionMatrix,B.matrixWorldInverse),ht.setFromProjectionMatrix(ge),ue=this.localClippingEnabled,ne=me.init(this.clippingPlanes,ue),x=De.get(N,g.length),x.init(),g.push(x),ee.enabled===!0&&ee.isPresenting===!0){const xe=_.xr.getDepthSensingMesh();xe!==null&&Gd(xe,B,-1/0,_.sortObjects)}Gd(N,B,0,_.sortObjects),x.finish(),_.sortObjects===!0&&x.sort(Q,we),dt=ee.enabled===!1||ee.isPresenting===!1||ee.hasDepthSensing()===!1,dt&&tt.addToRenderList(x,N),this.info.render.frame++,ne===!0&&me.beginShadows();const Y=m.state.shadowsArray;Ue.render(Y,N,B),ne===!0&&me.endShadows(),this.info.autoReset===!0&&this.info.reset();const Z=x.opaque,k=x.transmissive;if(m.setupLights(),B.isArrayCamera){const xe=B.cameras;if(k.length>0)for(let Re=0,ze=xe.length;Re<ze;Re++){const Ge=xe[Re];p0(Z,k,N,Ge)}dt&&tt.render(N);for(let Re=0,ze=xe.length;Re<ze;Re++){const Ge=xe[Re];d0(x,N,Ge,Ge.viewport)}}else k.length>0&&p0(Z,k,N,B),dt&&tt.render(N),d0(x,N,B);w!==null&&(R.updateMultisampleRenderTarget(w),R.updateRenderTargetMipmap(w)),N.isScene===!0&&N.onAfterRender(_,N,B),Ot.resetDefaultState(),C=-1,F=null,y.pop(),y.length>0?(m=y[y.length-1],ne===!0&&me.setGlobalState(_.clippingPlanes,m.state.camera)):m=null,g.pop(),g.length>0?x=g[g.length-1]:x=null};function Gd(N,B,Y,Z){if(N.visible===!1)return;if(N.layers.test(B.layers)){if(N.isGroup)Y=N.renderOrder;else if(N.isLOD)N.autoUpdate===!0&&N.update(B);else if(N.isLight)m.pushLight(N),N.castShadow&&m.pushShadow(N);else if(N.isSprite){if(!N.frustumCulled||ht.intersectsSprite(N)){Z&&Xe.setFromMatrixPosition(N.matrixWorld).applyMatrix4(ge);const Re=se.update(N),ze=N.material;ze.visible&&x.push(N,Re,ze,Y,Xe.z,null)}}else if((N.isMesh||N.isLine||N.isPoints)&&(!N.frustumCulled||ht.intersectsObject(N))){const Re=se.update(N),ze=N.material;if(Z&&(N.boundingSphere!==void 0?(N.boundingSphere===null&&N.computeBoundingSphere(),Xe.copy(N.boundingSphere.center)):(Re.boundingSphere===null&&Re.computeBoundingSphere(),Xe.copy(Re.boundingSphere.center)),Xe.applyMatrix4(N.matrixWorld).applyMatrix4(ge)),Array.isArray(ze)){const Ge=Re.groups;for(let je=0,et=Ge.length;je<et;je++){const He=Ge[je],Lt=ze[He.materialIndex];Lt&&Lt.visible&&x.push(N,Re,Lt,Y,Xe.z,He)}}else ze.visible&&x.push(N,Re,ze,Y,Xe.z,null)}}const xe=N.children;for(let Re=0,ze=xe.length;Re<ze;Re++)Gd(xe[Re],B,Y,Z)}function d0(N,B,Y,Z){const k=N.opaque,xe=N.transmissive,Re=N.transparent;m.setupLightsView(Y),ne===!0&&me.setGlobalState(_.clippingPlanes,Y),Z&&Te.viewport(M.copy(Z)),k.length>0&&Tl(k,B,Y),xe.length>0&&Tl(xe,B,Y),Re.length>0&&Tl(Re,B,Y),Te.buffers.depth.setTest(!0),Te.buffers.depth.setMask(!0),Te.buffers.color.setMask(!0),Te.setPolygonOffset(!1)}function p0(N,B,Y,Z){if((Y.isScene===!0?Y.overrideMaterial:null)!==null)return;m.state.transmissionRenderTarget[Z.id]===void 0&&(m.state.transmissionRenderTarget[Z.id]=new zi(1,1,{generateMipmaps:!0,type:ye.has("EXT_color_buffer_half_float")||ye.has("EXT_color_buffer_float")?Ln:es,minFilter:Jn,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:gt.workingColorSpace}));const xe=m.state.transmissionRenderTarget[Z.id],Re=Z.viewport||M;xe.setSize(Re.z,Re.w);const ze=_.getRenderTarget();_.setRenderTarget(xe),_.getClearColor(W),$=_.getClearAlpha(),$<1&&_.setClearColor(16777215,.5),_.clear(),dt&&tt.render(Y);const Ge=_.toneMapping;_.toneMapping=Ti;const je=Z.viewport;if(Z.viewport!==void 0&&(Z.viewport=void 0),m.setupLightsView(Z),ne===!0&&me.setGlobalState(_.clippingPlanes,Z),Tl(N,Y,Z),R.updateMultisampleRenderTarget(xe),R.updateRenderTargetMipmap(xe),ye.has("WEBGL_multisampled_render_to_texture")===!1){let et=!1;for(let He=0,Lt=B.length;He<Lt;He++){const Gt=B[He],Jt=Gt.object,fi=Gt.geometry,Rt=Gt.material,$e=Gt.group;if(Rt.side===Ji&&Jt.layers.test(Z.layers)){const An=Rt.side;Rt.side=ln,Rt.needsUpdate=!0,f0(Jt,Y,Z,fi,Rt,$e),Rt.side=An,Rt.needsUpdate=!0,et=!0}}et===!0&&(R.updateMultisampleRenderTarget(xe),R.updateRenderTargetMipmap(xe))}_.setRenderTarget(ze),_.setClearColor(W,$),je!==void 0&&(Z.viewport=je),_.toneMapping=Ge}function Tl(N,B,Y){const Z=B.isScene===!0?B.overrideMaterial:null;for(let k=0,xe=N.length;k<xe;k++){const Re=N[k],ze=Re.object,Ge=Re.geometry,je=Z===null?Re.material:Z,et=Re.group;ze.layers.test(Y.layers)&&f0(ze,B,Y,Ge,je,et)}}function f0(N,B,Y,Z,k,xe){N.onBeforeRender(_,B,Y,Z,k,xe),N.modelViewMatrix.multiplyMatrices(Y.matrixWorldInverse,N.matrixWorld),N.normalMatrix.getNormalMatrix(N.modelViewMatrix),k.onBeforeRender(_,B,Y,Z,N,xe),k.transparent===!0&&k.side===Ji&&k.forceSinglePass===!1?(k.side=ln,k.needsUpdate=!0,_.renderBufferDirect(Y,B,Z,k,N,xe),k.side=fs,k.needsUpdate=!0,_.renderBufferDirect(Y,B,Z,k,N,xe),k.side=Ji):_.renderBufferDirect(Y,B,Z,k,N,xe),N.onAfterRender(_,B,Y,Z,k,xe)}function bl(N,B,Y){B.isScene!==!0&&(B=Je);const Z=Ie.get(N),k=m.state.lights,xe=m.state.shadowsArray,Re=k.state.version,ze=ke.getParameters(N,k.state,xe,B,Y),Ge=ke.getProgramCacheKey(ze);let je=Z.programs;Z.environment=N.isMeshStandardMaterial?B.environment:null,Z.fog=B.fog,Z.envMap=(N.isMeshStandardMaterial?X:S).get(N.envMap||Z.environment),Z.envMapRotation=Z.environment!==null&&N.envMap===null?B.environmentRotation:N.envMapRotation,je===void 0&&(N.addEventListener("dispose",bt),je=new Map,Z.programs=je);let et=je.get(Ge);if(et!==void 0){if(Z.currentProgram===et&&Z.lightsStateVersion===Re)return g0(N,ze),et}else ze.uniforms=ke.getUniforms(N),N.onBuild(Y,ze,_),N.onBeforeCompile(ze,_),et=ke.acquireProgram(ze,Ge),je.set(Ge,et),Z.uniforms=ze.uniforms;const He=Z.uniforms;return(!N.isShaderMaterial&&!N.isRawShaderMaterial||N.clipping===!0)&&(He.clippingPlanes=me.uniform),g0(N,ze),Z.needsLights=Qw(N),Z.lightsStateVersion=Re,Z.needsLights&&(He.ambientLightColor.value=k.state.ambient,He.lightProbe.value=k.state.probe,He.directionalLights.value=k.state.directional,He.directionalLightShadows.value=k.state.directionalShadow,He.spotLights.value=k.state.spot,He.spotLightShadows.value=k.state.spotShadow,He.rectAreaLights.value=k.state.rectArea,He.ltc_1.value=k.state.rectAreaLTC1,He.ltc_2.value=k.state.rectAreaLTC2,He.pointLights.value=k.state.point,He.pointLightShadows.value=k.state.pointShadow,He.hemisphereLights.value=k.state.hemi,He.directionalShadowMap.value=k.state.directionalShadowMap,He.directionalShadowMatrix.value=k.state.directionalShadowMatrix,He.spotShadowMap.value=k.state.spotShadowMap,He.spotLightMatrix.value=k.state.spotLightMatrix,He.spotLightMap.value=k.state.spotLightMap,He.pointShadowMap.value=k.state.pointShadowMap,He.pointShadowMatrix.value=k.state.pointShadowMatrix),Z.currentProgram=et,Z.uniformsList=null,et}function m0(N){if(N.uniformsList===null){const B=N.currentProgram.getUniforms();N.uniformsList=Ru.seqWithValue(B.seq,N.uniforms)}return N.uniformsList}function g0(N,B){const Y=Ie.get(N);Y.outputColorSpace=B.outputColorSpace,Y.batching=B.batching,Y.batchingColor=B.batchingColor,Y.instancing=B.instancing,Y.instancingColor=B.instancingColor,Y.instancingMorph=B.instancingMorph,Y.skinning=B.skinning,Y.morphTargets=B.morphTargets,Y.morphNormals=B.morphNormals,Y.morphColors=B.morphColors,Y.morphTargetsCount=B.morphTargetsCount,Y.numClippingPlanes=B.numClippingPlanes,Y.numIntersection=B.numClipIntersection,Y.vertexAlphas=B.vertexAlphas,Y.vertexTangents=B.vertexTangents,Y.toneMapping=B.toneMapping}function Kw(N,B,Y,Z,k){B.isScene!==!0&&(B=Je),R.resetTextureUnits();const xe=B.fog,Re=Z.isMeshStandardMaterial?B.environment:null,ze=w===null?_.outputColorSpace:w.isXRRenderTarget===!0?w.texture.colorSpace:li,Ge=(Z.isMeshStandardMaterial?X:S).get(Z.envMap||Re),je=Z.vertexColors===!0&&!!Y.attributes.color&&Y.attributes.color.itemSize===4,et=!!Y.attributes.tangent&&(!!Z.normalMap||Z.anisotropy>0),He=!!Y.morphAttributes.position,Lt=!!Y.morphAttributes.normal,Gt=!!Y.morphAttributes.color;let Jt=Ti;Z.toneMapped&&(w===null||w.isXRRenderTarget===!0)&&(Jt=_.toneMapping);const fi=Y.morphAttributes.position||Y.morphAttributes.normal||Y.morphAttributes.color,Rt=fi!==void 0?fi.length:0,$e=Ie.get(Z),An=m.state.lights;if(ne===!0&&(ue===!0||N!==F)){const Ni=N===F&&Z.id===C;me.setState(Z,N,Ni)}let It=!1;Z.version===$e.__version?($e.needsLights&&$e.lightsStateVersion!==An.state.version||$e.outputColorSpace!==ze||k.isBatchedMesh&&$e.batching===!1||!k.isBatchedMesh&&$e.batching===!0||k.isBatchedMesh&&$e.batchingColor===!0&&k.colorTexture===null||k.isBatchedMesh&&$e.batchingColor===!1&&k.colorTexture!==null||k.isInstancedMesh&&$e.instancing===!1||!k.isInstancedMesh&&$e.instancing===!0||k.isSkinnedMesh&&$e.skinning===!1||!k.isSkinnedMesh&&$e.skinning===!0||k.isInstancedMesh&&$e.instancingColor===!0&&k.instanceColor===null||k.isInstancedMesh&&$e.instancingColor===!1&&k.instanceColor!==null||k.isInstancedMesh&&$e.instancingMorph===!0&&k.morphTexture===null||k.isInstancedMesh&&$e.instancingMorph===!1&&k.morphTexture!==null||$e.envMap!==Ge||Z.fog===!0&&$e.fog!==xe||$e.numClippingPlanes!==void 0&&($e.numClippingPlanes!==me.numPlanes||$e.numIntersection!==me.numIntersection)||$e.vertexAlphas!==je||$e.vertexTangents!==et||$e.morphTargets!==He||$e.morphNormals!==Lt||$e.morphColors!==Gt||$e.toneMapping!==Jt||$e.morphTargetsCount!==Rt)&&(It=!0):(It=!0,$e.__version=Z.version);let Xi=$e.currentProgram;It===!0&&(Xi=bl(Z,B,k));let fo=!1,mi=!1,Hd=!1;const tn=Xi.getUniforms(),Vs=$e.uniforms;if(Te.useProgram(Xi.program)&&(fo=!0,mi=!0,Hd=!0),Z.id!==C&&(C=Z.id,mi=!0),fo||F!==N){de.reverseDepthBuffer?(Ae.copy(N.projectionMatrix),UA(Ae),FA(Ae),tn.setValue(P,"projectionMatrix",Ae)):tn.setValue(P,"projectionMatrix",N.projectionMatrix),tn.setValue(P,"viewMatrix",N.matrixWorldInverse);const Ni=tn.map.cameraPosition;Ni!==void 0&&Ni.setValue(P,Ze.setFromMatrixPosition(N.matrixWorld)),de.logarithmicDepthBuffer&&tn.setValue(P,"logDepthBufFC",2/(Math.log(N.far+1)/Math.LN2)),(Z.isMeshPhongMaterial||Z.isMeshToonMaterial||Z.isMeshLambertMaterial||Z.isMeshBasicMaterial||Z.isMeshStandardMaterial||Z.isShaderMaterial)&&tn.setValue(P,"isOrthographic",N.isOrthographicCamera===!0),F!==N&&(F=N,mi=!0,Hd=!0)}if(k.isSkinnedMesh){tn.setOptional(P,k,"bindMatrix"),tn.setOptional(P,k,"bindMatrixInverse");const Ni=k.skeleton;Ni&&(Ni.boneTexture===null&&Ni.computeBoneTexture(),tn.setValue(P,"boneTexture",Ni.boneTexture,R))}k.isBatchedMesh&&(tn.setOptional(P,k,"batchingTexture"),tn.setValue(P,"batchingTexture",k._matricesTexture,R),tn.setOptional(P,k,"batchingIdTexture"),tn.setValue(P,"batchingIdTexture",k._indirectTexture,R),tn.setOptional(P,k,"batchingColorTexture"),k._colorsTexture!==null&&tn.setValue(P,"batchingColorTexture",k._colorsTexture,R));const Wd=Y.morphAttributes;if((Wd.position!==void 0||Wd.normal!==void 0||Wd.color!==void 0)&&nt.update(k,Y,Xi),(mi||$e.receiveShadow!==k.receiveShadow)&&($e.receiveShadow=k.receiveShadow,tn.setValue(P,"receiveShadow",k.receiveShadow)),Z.isMeshGouraudMaterial&&Z.envMap!==null&&(Vs.envMap.value=Ge,Vs.flipEnvMap.value=Ge.isCubeTexture&&Ge.isRenderTargetTexture===!1?-1:1),Z.isMeshStandardMaterial&&Z.envMap===null&&B.environment!==null&&(Vs.envMapIntensity.value=B.environmentIntensity),mi&&(tn.setValue(P,"toneMappingExposure",_.toneMappingExposure),$e.needsLights&&jw(Vs,Hd),xe&&Z.fog===!0&&be.refreshFogUniforms(Vs,xe),be.refreshMaterialUniforms(Vs,Z,he,q,m.state.transmissionRenderTarget[N.id]),Ru.upload(P,m0($e),Vs,R)),Z.isShaderMaterial&&Z.uniformsNeedUpdate===!0&&(Ru.upload(P,m0($e),Vs,R),Z.uniformsNeedUpdate=!1),Z.isSpriteMaterial&&tn.setValue(P,"center",k.center),tn.setValue(P,"modelViewMatrix",k.modelViewMatrix),tn.setValue(P,"normalMatrix",k.normalMatrix),tn.setValue(P,"modelMatrix",k.matrixWorld),Z.isShaderMaterial||Z.isRawShaderMaterial){const Ni=Z.uniformsGroups;for(let Xd=0,eA=Ni.length;Xd<eA;Xd++){const x0=Ni[Xd];O.update(x0,Xi),O.bind(x0,Xi)}}return Xi}function jw(N,B){N.ambientLightColor.needsUpdate=B,N.lightProbe.needsUpdate=B,N.directionalLights.needsUpdate=B,N.directionalLightShadows.needsUpdate=B,N.pointLights.needsUpdate=B,N.pointLightShadows.needsUpdate=B,N.spotLights.needsUpdate=B,N.spotLightShadows.needsUpdate=B,N.rectAreaLights.needsUpdate=B,N.hemisphereLights.needsUpdate=B}function Qw(N){return N.isMeshLambertMaterial||N.isMeshToonMaterial||N.isMeshPhongMaterial||N.isMeshStandardMaterial||N.isShadowMaterial||N.isShaderMaterial&&N.lights===!0}this.getActiveCubeFace=function(){return I},this.getActiveMipmapLevel=function(){return T},this.getRenderTarget=function(){return w},this.setRenderTargetTextures=function(N,B,Y){Ie.get(N.texture).__webglTexture=B,Ie.get(N.depthTexture).__webglTexture=Y;const Z=Ie.get(N);Z.__hasExternalTextures=!0,Z.__autoAllocateDepthBuffer=Y===void 0,Z.__autoAllocateDepthBuffer||ye.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),Z.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(N,B){const Y=Ie.get(N);Y.__webglFramebuffer=B,Y.__useDefaultFramebuffer=B===void 0},this.setRenderTarget=function(N,B=0,Y=0){w=N,I=B,T=Y;let Z=!0,k=null,xe=!1,Re=!1;if(N){const Ge=Ie.get(N);if(Ge.__useDefaultFramebuffer!==void 0)Te.bindFramebuffer(P.FRAMEBUFFER,null),Z=!1;else if(Ge.__webglFramebuffer===void 0)R.setupRenderTarget(N);else if(Ge.__hasExternalTextures)R.rebindTextures(N,Ie.get(N.texture).__webglTexture,Ie.get(N.depthTexture).__webglTexture);else if(N.depthBuffer){const He=N.depthTexture;if(Ge.__boundDepthTexture!==He){if(He!==null&&Ie.has(He)&&(N.width!==He.image.width||N.height!==He.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");R.setupDepthRenderbuffer(N)}}const je=N.texture;(je.isData3DTexture||je.isDataArrayTexture||je.isCompressedArrayTexture)&&(Re=!0);const et=Ie.get(N).__webglFramebuffer;N.isWebGLCubeRenderTarget?(Array.isArray(et[B])?k=et[B][Y]:k=et[B],xe=!0):N.samples>0&&R.useMultisampledRTT(N)===!1?k=Ie.get(N).__webglMultisampledFramebuffer:Array.isArray(et)?k=et[Y]:k=et,M.copy(N.viewport),b.copy(N.scissor),G=N.scissorTest}else M.copy(Ne).multiplyScalar(he).floor(),b.copy(Ee).multiplyScalar(he).floor(),G=Qe;if(Te.bindFramebuffer(P.FRAMEBUFFER,k)&&Z&&Te.drawBuffers(N,k),Te.viewport(M),Te.scissor(b),Te.setScissorTest(G),xe){const Ge=Ie.get(N.texture);P.framebufferTexture2D(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0,P.TEXTURE_CUBE_MAP_POSITIVE_X+B,Ge.__webglTexture,Y)}else if(Re){const Ge=Ie.get(N.texture),je=B||0;P.framebufferTextureLayer(P.FRAMEBUFFER,P.COLOR_ATTACHMENT0,Ge.__webglTexture,Y||0,je)}C=-1},this.readRenderTargetPixels=function(N,B,Y,Z,k,xe,Re){if(!(N&&N.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ze=Ie.get(N).__webglFramebuffer;if(N.isWebGLCubeRenderTarget&&Re!==void 0&&(ze=ze[Re]),ze){Te.bindFramebuffer(P.FRAMEBUFFER,ze);try{const Ge=N.texture,je=Ge.format,et=Ge.type;if(!de.textureFormatReadable(je)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!de.textureTypeReadable(et)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}B>=0&&B<=N.width-Z&&Y>=0&&Y<=N.height-k&&P.readPixels(B,Y,Z,k,ct.convert(je),ct.convert(et),xe)}finally{const Ge=w!==null?Ie.get(w).__webglFramebuffer:null;Te.bindFramebuffer(P.FRAMEBUFFER,Ge)}}},this.readRenderTargetPixelsAsync=async function(N,B,Y,Z,k,xe,Re){if(!(N&&N.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ze=Ie.get(N).__webglFramebuffer;if(N.isWebGLCubeRenderTarget&&Re!==void 0&&(ze=ze[Re]),ze){const Ge=N.texture,je=Ge.format,et=Ge.type;if(!de.textureFormatReadable(je))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!de.textureTypeReadable(et))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(B>=0&&B<=N.width-Z&&Y>=0&&Y<=N.height-k){Te.bindFramebuffer(P.FRAMEBUFFER,ze);const He=P.createBuffer();P.bindBuffer(P.PIXEL_PACK_BUFFER,He),P.bufferData(P.PIXEL_PACK_BUFFER,xe.byteLength,P.STREAM_READ),P.readPixels(B,Y,Z,k,ct.convert(je),ct.convert(et),0);const Lt=w!==null?Ie.get(w).__webglFramebuffer:null;Te.bindFramebuffer(P.FRAMEBUFFER,Lt);const Gt=P.fenceSync(P.SYNC_GPU_COMMANDS_COMPLETE,0);return P.flush(),await DA(P,Gt,4),P.bindBuffer(P.PIXEL_PACK_BUFFER,He),P.getBufferSubData(P.PIXEL_PACK_BUFFER,0,xe),P.deleteBuffer(He),P.deleteSync(Gt),xe}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(N,B=null,Y=0){N.isTexture!==!0&&(Cu("WebGLRenderer: copyFramebufferToTexture function signature has changed."),B=arguments[0]||null,N=arguments[1]);const Z=Math.pow(2,-Y),k=Math.floor(N.image.width*Z),xe=Math.floor(N.image.height*Z),Re=B!==null?B.x:0,ze=B!==null?B.y:0;R.setTexture2D(N,0),P.copyTexSubImage2D(P.TEXTURE_2D,Y,0,0,Re,ze,k,xe),Te.unbindTexture()},this.copyTextureToTexture=function(N,B,Y=null,Z=null,k=0){N.isTexture!==!0&&(Cu("WebGLRenderer: copyTextureToTexture function signature has changed."),Z=arguments[0]||null,N=arguments[1],B=arguments[2],k=arguments[3]||0,Y=null);let xe,Re,ze,Ge,je,et;Y!==null?(xe=Y.max.x-Y.min.x,Re=Y.max.y-Y.min.y,ze=Y.min.x,Ge=Y.min.y):(xe=N.image.width,Re=N.image.height,ze=0,Ge=0),Z!==null?(je=Z.x,et=Z.y):(je=0,et=0);const He=ct.convert(B.format),Lt=ct.convert(B.type);R.setTexture2D(B,0),P.pixelStorei(P.UNPACK_FLIP_Y_WEBGL,B.flipY),P.pixelStorei(P.UNPACK_PREMULTIPLY_ALPHA_WEBGL,B.premultiplyAlpha),P.pixelStorei(P.UNPACK_ALIGNMENT,B.unpackAlignment);const Gt=P.getParameter(P.UNPACK_ROW_LENGTH),Jt=P.getParameter(P.UNPACK_IMAGE_HEIGHT),fi=P.getParameter(P.UNPACK_SKIP_PIXELS),Rt=P.getParameter(P.UNPACK_SKIP_ROWS),$e=P.getParameter(P.UNPACK_SKIP_IMAGES),An=N.isCompressedTexture?N.mipmaps[k]:N.image;P.pixelStorei(P.UNPACK_ROW_LENGTH,An.width),P.pixelStorei(P.UNPACK_IMAGE_HEIGHT,An.height),P.pixelStorei(P.UNPACK_SKIP_PIXELS,ze),P.pixelStorei(P.UNPACK_SKIP_ROWS,Ge),N.isDataTexture?P.texSubImage2D(P.TEXTURE_2D,k,je,et,xe,Re,He,Lt,An.data):N.isCompressedTexture?P.compressedTexSubImage2D(P.TEXTURE_2D,k,je,et,An.width,An.height,He,An.data):P.texSubImage2D(P.TEXTURE_2D,k,je,et,xe,Re,He,Lt,An),P.pixelStorei(P.UNPACK_ROW_LENGTH,Gt),P.pixelStorei(P.UNPACK_IMAGE_HEIGHT,Jt),P.pixelStorei(P.UNPACK_SKIP_PIXELS,fi),P.pixelStorei(P.UNPACK_SKIP_ROWS,Rt),P.pixelStorei(P.UNPACK_SKIP_IMAGES,$e),k===0&&B.generateMipmaps&&P.generateMipmap(P.TEXTURE_2D),Te.unbindTexture()},this.copyTextureToTexture3D=function(N,B,Y=null,Z=null,k=0){N.isTexture!==!0&&(Cu("WebGLRenderer: copyTextureToTexture3D function signature has changed."),Y=arguments[0]||null,Z=arguments[1]||null,N=arguments[2],B=arguments[3],k=arguments[4]||0);let xe,Re,ze,Ge,je,et,He,Lt,Gt;const Jt=N.isCompressedTexture?N.mipmaps[k]:N.image;Y!==null?(xe=Y.max.x-Y.min.x,Re=Y.max.y-Y.min.y,ze=Y.max.z-Y.min.z,Ge=Y.min.x,je=Y.min.y,et=Y.min.z):(xe=Jt.width,Re=Jt.height,ze=Jt.depth,Ge=0,je=0,et=0),Z!==null?(He=Z.x,Lt=Z.y,Gt=Z.z):(He=0,Lt=0,Gt=0);const fi=ct.convert(B.format),Rt=ct.convert(B.type);let $e;if(B.isData3DTexture)R.setTexture3D(B,0),$e=P.TEXTURE_3D;else if(B.isDataArrayTexture||B.isCompressedArrayTexture)R.setTexture2DArray(B,0),$e=P.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}P.pixelStorei(P.UNPACK_FLIP_Y_WEBGL,B.flipY),P.pixelStorei(P.UNPACK_PREMULTIPLY_ALPHA_WEBGL,B.premultiplyAlpha),P.pixelStorei(P.UNPACK_ALIGNMENT,B.unpackAlignment);const An=P.getParameter(P.UNPACK_ROW_LENGTH),It=P.getParameter(P.UNPACK_IMAGE_HEIGHT),Xi=P.getParameter(P.UNPACK_SKIP_PIXELS),fo=P.getParameter(P.UNPACK_SKIP_ROWS),mi=P.getParameter(P.UNPACK_SKIP_IMAGES);P.pixelStorei(P.UNPACK_ROW_LENGTH,Jt.width),P.pixelStorei(P.UNPACK_IMAGE_HEIGHT,Jt.height),P.pixelStorei(P.UNPACK_SKIP_PIXELS,Ge),P.pixelStorei(P.UNPACK_SKIP_ROWS,je),P.pixelStorei(P.UNPACK_SKIP_IMAGES,et),N.isDataTexture||N.isData3DTexture?P.texSubImage3D($e,k,He,Lt,Gt,xe,Re,ze,fi,Rt,Jt.data):B.isCompressedArrayTexture?P.compressedTexSubImage3D($e,k,He,Lt,Gt,xe,Re,ze,fi,Jt.data):P.texSubImage3D($e,k,He,Lt,Gt,xe,Re,ze,fi,Rt,Jt),P.pixelStorei(P.UNPACK_ROW_LENGTH,An),P.pixelStorei(P.UNPACK_IMAGE_HEIGHT,It),P.pixelStorei(P.UNPACK_SKIP_PIXELS,Xi),P.pixelStorei(P.UNPACK_SKIP_ROWS,fo),P.pixelStorei(P.UNPACK_SKIP_IMAGES,mi),k===0&&B.generateMipmaps&&P.generateMipmap($e),Te.unbindTexture()},this.initRenderTarget=function(N){Ie.get(N).__webglFramebuffer===void 0&&R.setupRenderTarget(N)},this.initTexture=function(N){N.isCubeTexture?R.setTextureCube(N,0):N.isData3DTexture?R.setTexture3D(N,0):N.isDataArrayTexture||N.isCompressedArrayTexture?R.setTexture2DArray(N,0):R.setTexture2D(N,0),Te.unbindTexture()},this.resetState=function(){I=0,T=0,w=null,Te.reset(),Ot.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Di}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===kh?"display-p3":"srgb",t.unpackColorSpace=gt.workingColorSpace===Xc?"display-p3":"srgb"}}class Zh{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new _e(e),this.density=t}clone(){return new Zh(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}let om=class Zy{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new _e(e),this.near=t,this.far=n}clone(){return new Zy(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}};class Jh extends yt{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 ui,this.environmentIntensity=1,this.environmentRotation=new ui,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}}class _a{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=sa,this.updateRanges=[],this.version=0,this.uuid=bi()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=bi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=bi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const qn=new E;class Ds{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)qn.fromBufferAttribute(this,t),qn.applyMatrix4(e),this.setXYZ(t,qn.x,qn.y,qn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)qn.fromBufferAttribute(this,t),qn.applyNormalMatrix(e),this.setXYZ(t,qn.x,qn.y,qn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)qn.fromBufferAttribute(this,t),qn.transformDirection(e),this.setXYZ(t,qn.x,qn.y,qn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=Yn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=ut(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=ut(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=ut(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=ut(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=ut(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Yn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Yn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Yn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Yn(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=ut(t,this.array),n=ut(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=ut(t,this.array),n=ut(n,this.array),i=ut(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=ut(t,this.array),n=ut(n,this.array),i=ut(i,this.array),r=ut(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return new At(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Ds(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class Zc extends mn{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new _e(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let Co;const Da=new E,Ro=new E,Io=new E,Po=new J,Ua=new J,Jy=new Fe,Xl=new E,Fa=new E,ql=new E,rx=new J,vp=new J,ox=new J;class am extends yt{constructor(e=new Zc){if(super(),this.isSprite=!0,this.type="Sprite",Co===void 0){Co=new at;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new _a(t,5);Co.setIndex([0,1,2,0,2,3]),Co.setAttribute("position",new Ds(n,3,0,!1)),Co.setAttribute("uv",new Ds(n,2,3,!1))}this.geometry=Co,this.material=e,this.center=new J(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Ro.setFromMatrixScale(this.matrixWorld),Jy.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Io.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Ro.multiplyScalar(-Io.z);const n=this.material.rotation;let i,r;n!==0&&(r=Math.cos(n),i=Math.sin(n));const o=this.center;$l(Xl.set(-.5,-.5,0),Io,o,Ro,i,r),$l(Fa.set(.5,-.5,0),Io,o,Ro,i,r),$l(ql.set(.5,.5,0),Io,o,Ro,i,r),rx.set(0,0),vp.set(1,0),ox.set(1,1);let a=e.ray.intersectTriangle(Xl,Fa,ql,!1,Da);if(a===null&&($l(Fa.set(-.5,.5,0),Io,o,Ro,i,r),vp.set(0,1),a=e.ray.intersectTriangle(Xl,ql,Fa,!1,Da),a===null))return;const c=e.ray.origin.distanceTo(Da);c<e.near||c>e.far||t.push({distance:c,point:Da.clone(),uv:Zn.getInterpolation(Da,Xl,Fa,ql,rx,vp,ox,new J),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function $l(s,e,t,n,i,r){Po.subVectors(s,t).addScalar(.5).multiply(n),i!==void 0?(Ua.x=r*Po.x-i*Po.y,Ua.y=i*Po.x+r*Po.y):Ua.copy(Po),s.copy(e),s.x+=Ua.x,s.y+=Ua.y,s.applyMatrix4(Jy)}const Yl=new E,ax=new E;class cm extends yt{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let n=0,i=t.length;n<i;n++){const r=t[n];this.addLevel(r.object.clone(),r.distance,r.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,n=0){t=Math.abs(t);const i=this.levels;let r;for(r=0;r<i.length&&!(t<i[r].distance);r++);return i.splice(r,0,{distance:t,hysteresis:n,object:e}),this.add(e),this}removeLevel(e){const t=this.levels;for(let n=0;n<t.length;n++)if(t[n].distance===e){const i=t.splice(n,1);return this.remove(i[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let n,i;for(n=1,i=t.length;n<i;n++){let r=t[n].distance;if(t[n].object.visible&&(r-=r*t[n].hysteresis),e<r)break}return t[n-1].object}return null}raycast(e,t){if(this.levels.length>0){Yl.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(Yl);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Yl.setFromMatrixPosition(e.matrixWorld),ax.setFromMatrixPosition(this.matrixWorld);const n=Yl.distanceTo(ax)/e.zoom;t[0].object.visible=!0;let i,r;for(i=1,r=t.length;i<r;i++){let o=t[i].distance;if(t[i].object.visible&&(o-=o*t[i].hysteresis),n>=o)t[i-1].object.visible=!1,t[i].object.visible=!0;else break}for(this._currentLevel=i-1;i<r;i++)t[i].object.visible=!1}}toJSON(e){const t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];const n=this.levels;for(let i=0,r=n.length;i<r;i++){const o=n[i];t.object.levels.push({object:o.object.uuid,distance:o.distance,hysteresis:o.hysteresis})}return t}}const cx=new E,lx=new st,ux=new st,$R=new E,hx=new Fe,Zl=new E,Mp=new Dn,dx=new Fe,Sp=new io;class lm extends kt{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=af,this.bindMatrix=new Fe,this.bindMatrixInverse=new Fe,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Hn),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Zl),this.boundingBox.expandByPoint(Zl)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Dn),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Zl),this.boundingSphere.expandByPoint(Zl)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Mp.copy(this.boundingSphere),Mp.applyMatrix4(i),e.ray.intersectsSphere(Mp)!==!1&&(dx.copy(i).invert(),Sp.copy(e.ray).applyMatrix4(dx),!(this.boundingBox!==null&&Sp.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Sp)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new st,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);const r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===af?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===ly?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,i=this.geometry;lx.fromBufferAttribute(i.attributes.skinIndex,e),ux.fromBufferAttribute(i.attributes.skinWeight,e),cx.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let r=0;r<4;r++){const o=ux.getComponent(r);if(o!==0){const a=lx.getComponent(r);hx.multiplyMatrices(n.bones[a].matrixWorld,n.boneInverses[a]),t.addScaledVector($R.copy(cx).applyMatrix4(hx),o)}}return t.applyMatrix4(this.bindMatrixInverse)}}class Kh extends yt{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Oi extends Xt{constructor(e=null,t=1,n=1,i,r,o,a,c,l=Qt,u=Qt,h,d){super(null,o,a,c,l,u,i,r,h,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const px=new Fe,YR=new Fe;class Jc{constructor(e=[],t=[]){this.uuid=bi(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Fe)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new Fe;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,o=e.length;r<o;r++){const a=e[r]?e[r].matrixWorld:YR;px.multiplyMatrices(a,t[r]),px.toArray(n,r*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new Jc(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new Oi(t,e,e,Rn,Gn);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const i=this.bones[t];if(i.name===e)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){const r=e.bones[n];let o=t[r];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",r),o=new Kh),this.bones.push(o),this.boneInverses.push(new Fe().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){const o=t[i];e.bones.push(o.uuid);const a=n[i];e.boneInverses.push(a.toArray())}return e}}class Us extends At{constructor(e,t,n,i=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Lo=new Fe,fx=new Fe,Jl=[],mx=new Hn,ZR=new Fe,Oa=new kt,Va=new Dn;class um extends kt{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Us(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,ZR)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Hn),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Lo),mx.copy(e.boundingBox).applyMatrix4(Lo),this.boundingBox.union(mx)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Dn),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Lo),Va.copy(e.boundingSphere).applyMatrix4(Lo),this.boundingSphere.union(Va)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,o=e*r+1;for(let a=0;a<n.length;a++)n[a]=i[o+a]}raycast(e,t){const n=this.matrixWorld,i=this.count;if(Oa.geometry=this.geometry,Oa.material=this.material,Oa.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Va.copy(this.boundingSphere),Va.applyMatrix4(n),e.ray.intersectsSphere(Va)!==!1))for(let r=0;r<i;r++){this.getMatrixAt(r,Lo),fx.multiplyMatrices(n,Lo),Oa.matrixWorld=fx,Oa.raycast(e,Jl);for(let o=0,a=Jl.length;o<a;o++){const c=Jl[o];c.instanceId=r,c.object=this,t.push(c)}Jl.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Us(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const n=t.morphTargetInfluences,i=n.length+1;this.morphTexture===null&&(this.morphTexture=new Oi(new Float32Array(i*this.count),i,this.count,Hc,Gn));const r=this.morphTexture.source.data.data;let o=0;for(let l=0;l<n.length;l++)o+=n[l];const a=this.geometry.morphTargetsRelative?1:1-o,c=i*e;r[c]=a,r.set(n,c+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}}function JR(s,e){return s.z-e.z}function KR(s,e){return e.z-s.z}class jR{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,n){const i=this.pool,r=this.list;this.index>=i.length&&i.push({start:-1,count:-1,z:-1,index:-1});const o=i[this.index];r.push(o),this.index++,o.start=e.start,o.count=e.count,o.z=t,o.index=n}reset(){this.list.length=0,this.index=0}}const Xs=new Fe,Tp=new Fe,QR=new Fe,eI=new _e(1,1,1),gx=new Fe,bp=new ga,Kl=new Hn,Nr=new Dn,Ba=new E,xx=new E,tI=new E,wp=new jR,zn=new kt,jl=[];function nI(s,e,t=0){const n=e.itemSize;if(s.isInterleavedBufferAttribute||s.array.constructor!==e.array.constructor){const i=s.count;for(let r=0;r<i;r++)for(let o=0;o<n;o++)e.setComponent(r+t,o,s.getComponent(r,o))}else e.array.set(s.array,t*n);e.needsUpdate=!0}class hm extends kt{get maxInstanceCount(){return this._maxInstanceCount}constructor(e,t,n=t*2,i){super(new at,i),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._drawInfo=[],this._availableInstanceIds=[],this._drawRanges=[],this._reservedRanges=[],this._bounds=[],this._maxInstanceCount=e,this._maxVertexCount=t,this._maxIndexCount=n,this._geometryInitialized=!1,this._geometryCount=0,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._visibilityChanged=!0,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}_initMatricesTexture(){let e=Math.sqrt(this._maxInstanceCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4),n=new Oi(t,e,e,Rn,Gn);this._matricesTexture=n}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Uint32Array(e*e),n=new Oi(t,e,e,Wc,Bi);this._indirectTexture=n}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Float32Array(e*e*4).fill(1),n=new Oi(t,e,e,Rn,Gn);n.colorSpace=gt.workingColorSpace,this._colorsTexture=n}_initializeGeometry(e){const t=this.geometry,n=this._maxVertexCount,i=this._maxIndexCount;if(this._geometryInitialized===!1){for(const r in e.attributes){const o=e.getAttribute(r),{array:a,itemSize:c,normalized:l}=o,u=new a.constructor(n*c),h=new At(u,c,l);t.setAttribute(r,h)}if(e.getIndex()!==null){const r=n>65535?new Uint32Array(i):new Uint16Array(i);t.setIndex(new At(r,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const n in t.attributes){if(!e.hasAttribute(n))throw new Error(`BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const i=e.getAttribute(n),r=t.getAttribute(n);if(i.itemSize!==r.itemSize||i.normalized!==r.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Hn);const e=this.boundingBox,t=this._drawInfo;e.makeEmpty();for(let n=0,i=t.length;n<i;n++){if(t[n].active===!1)continue;const r=t[n].geometryIndex;this.getMatrixAt(n,Xs),this.getBoundingBoxAt(r,Kl).applyMatrix4(Xs),e.union(Kl)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Dn);const e=this.boundingSphere,t=this._drawInfo;e.makeEmpty();for(let n=0,i=t.length;n<i;n++){if(t[n].active===!1)continue;const r=t[n].geometryIndex;this.getMatrixAt(n,Xs),this.getBoundingSphereAt(r,Nr).applyMatrix4(Xs),e.union(Nr)}}addInstance(e){if(this._drawInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("BatchedMesh: Maximum item count reached.");const n={visible:!0,active:!0,geometryIndex:e};let i=null;this._availableInstanceIds.length>0?(i=this._availableInstanceIds.pop(),this._drawInfo[i]=n):(i=this._drawInfo.length,this._drawInfo.push(n));const r=this._matricesTexture,o=r.image.data;QR.toArray(o,i*16),r.needsUpdate=!0;const a=this._colorsTexture;return a&&(eI.toArray(a.image.data,i*4),a.needsUpdate=!0),i}addGeometry(e,t=-1,n=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._drawInfo.length>=this._maxInstanceCount)throw new Error("BatchedMesh: Maximum item count reached.");const i={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let r=null;const o=this._reservedRanges,a=this._drawRanges,c=this._bounds;this._geometryCount!==0&&(r=o[o.length-1]),t===-1?i.vertexCount=e.getAttribute("position").count:i.vertexCount=t,r===null?i.vertexStart=0:i.vertexStart=r.vertexStart+r.vertexCount;const l=e.getIndex(),u=l!==null;if(u&&(n===-1?i.indexCount=l.count:i.indexCount=n,r===null?i.indexStart=0:i.indexStart=r.indexStart+r.indexCount),i.indexStart!==-1&&i.indexStart+i.indexCount>this._maxIndexCount||i.vertexStart+i.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const h=this._geometryCount;return this._geometryCount++,o.push(i),a.push({start:u?i.indexStart:i.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new Hn,sphereInitialized:!1,sphere:new Dn}),this.setGeometryAt(h,e),h}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const n=this.geometry,i=n.getIndex()!==null,r=n.getIndex(),o=t.getIndex(),a=this._reservedRanges[e];if(i&&o.count>a.indexCount||t.attributes.position.count>a.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const c=a.vertexStart,l=a.vertexCount;for(const p in n.attributes){const f=t.getAttribute(p),x=n.getAttribute(p);nI(f,x,c);const m=f.itemSize;for(let g=f.count,y=l;g<y;g++){const _=c+g;for(let v=0;v<m;v++)x.setComponent(_,v,0)}x.needsUpdate=!0,x.addUpdateRange(c*m,l*m)}if(i){const p=a.indexStart;for(let f=0;f<o.count;f++)r.setX(p+f,c+o.getX(f));for(let f=o.count,x=a.indexCount;f<x;f++)r.setX(p+f,c);r.needsUpdate=!0,r.addUpdateRange(p,a.indexCount)}const u=this._bounds[e];t.boundingBox!==null?(u.box.copy(t.boundingBox),u.boxInitialized=!0):u.boxInitialized=!1,t.boundingSphere!==null?(u.sphere.copy(t.boundingSphere),u.sphereInitialized=!0):u.sphereInitialized=!1;const h=this._drawRanges[e],d=t.getAttribute("position");return h.count=i?o.count:d.count,this._visibilityChanged=!0,e}deleteInstance(e){const t=this._drawInfo;return e>=t.length||t[e].active===!1?this:(t[e].active=!1,this._availableInstanceIds.push(e),this._visibilityChanged=!0,this)}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;const n=this._bounds[e],i=n.box,r=this.geometry;if(n.boxInitialized===!1){i.makeEmpty();const o=r.index,a=r.attributes.position,c=this._drawRanges[e];for(let l=c.start,u=c.start+c.count;l<u;l++){let h=l;o&&(h=o.getX(h)),i.expandByPoint(Ba.fromBufferAttribute(a,h))}n.boxInitialized=!0}return t.copy(i),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;const n=this._bounds[e],i=n.sphere,r=this.geometry;if(n.sphereInitialized===!1){i.makeEmpty(),this.getBoundingBoxAt(e,Kl),Kl.getCenter(i.center);const o=r.index,a=r.attributes.position,c=this._drawRanges[e];let l=0;for(let u=c.start,h=c.start+c.count;u<h;u++){let d=u;o&&(d=o.getX(d)),Ba.fromBufferAttribute(a,d),l=Math.max(l,i.center.distanceToSquared(Ba))}i.radius=Math.sqrt(l),n.sphereInitialized=!0}return t.copy(i),t}setMatrixAt(e,t){const n=this._drawInfo,i=this._matricesTexture,r=this._matricesTexture.image.data;return e>=n.length||n[e].active===!1?this:(t.toArray(r,e*16),i.needsUpdate=!0,this)}getMatrixAt(e,t){const n=this._drawInfo,i=this._matricesTexture.image.data;return e>=n.length||n[e].active===!1?null:t.fromArray(i,e*16)}setColorAt(e,t){this._colorsTexture===null&&this._initColorsTexture();const n=this._colorsTexture,i=this._colorsTexture.image.data,r=this._drawInfo;return e>=r.length||r[e].active===!1?this:(t.toArray(i,e*4),n.needsUpdate=!0,this)}getColorAt(e,t){const n=this._colorsTexture.image.data,i=this._drawInfo;return e>=i.length||i[e].active===!1?null:t.fromArray(n,e*4)}setVisibleAt(e,t){const n=this._drawInfo;return e>=n.length||n[e].active===!1||n[e].visible===t?this:(n[e].visible=t,this._visibilityChanged=!0,this)}getVisibleAt(e){const t=this._drawInfo;return e>=t.length||t[e].active===!1?!1:t[e].visible}setGeometryIdAt(e,t){const n=this._drawInfo;return e>=n.length||n[e].active===!1||t<0||t>=this._geometryCount?null:(n[e].geometryIndex=t,this)}getGeometryIdAt(e){const t=this._drawInfo;return e>=t.length||t[e].active===!1?-1:t[e].geometryIndex}getGeometryRangeAt(e,t={}){if(e<0||e>=this._geometryCount)return null;const n=this._drawRanges[e];return t.start=n.start,t.count=n.count,t}raycast(e,t){const n=this._drawInfo,i=this._drawRanges,r=this.matrixWorld,o=this.geometry;zn.material=this.material,zn.geometry.index=o.index,zn.geometry.attributes=o.attributes,zn.geometry.boundingBox===null&&(zn.geometry.boundingBox=new Hn),zn.geometry.boundingSphere===null&&(zn.geometry.boundingSphere=new Dn);for(let a=0,c=n.length;a<c;a++){if(!n[a].visible||!n[a].active)continue;const l=n[a].geometryIndex,u=i[l];zn.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(a,zn.matrixWorld).premultiply(r),this.getBoundingBoxAt(l,zn.geometry.boundingBox),this.getBoundingSphereAt(l,zn.geometry.boundingSphere),zn.raycast(e,jl);for(let h=0,d=jl.length;h<d;h++){const p=jl[h];p.object=this,p.batchId=a,t.push(p)}jl.length=0}zn.material=null,zn.geometry.index=null,zn.geometry.attributes={},zn.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(t=>({...t})),this._reservedRanges=e._reservedRanges.map(t=>({...t})),this._drawInfo=e._drawInfo.map(t=>({...t})),this._bounds=e._bounds.map(t=>({boxInitialized:t.boxInitialized,box:t.box.clone(),sphereInitialized:t.sphereInitialized,sphere:t.sphere.clone()})),this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(e,t,n,i,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const o=i.getIndex(),a=o===null?1:o.array.BYTES_PER_ELEMENT,c=this._drawInfo,l=this._multiDrawStarts,u=this._multiDrawCounts,h=this._drawRanges,d=this.perObjectFrustumCulled,p=this._indirectTexture,f=p.image.data;d&&(gx.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),bp.setFromProjectionMatrix(gx,e.coordinateSystem));let x=0;if(this.sortObjects){Tp.copy(this.matrixWorld).invert(),Ba.setFromMatrixPosition(n.matrixWorld).applyMatrix4(Tp),xx.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(Tp);for(let y=0,_=c.length;y<_;y++)if(c[y].visible&&c[y].active){const v=c[y].geometryIndex;this.getMatrixAt(y,Xs),this.getBoundingSphereAt(v,Nr).applyMatrix4(Xs);let I=!1;if(d&&(I=!bp.intersectsSphere(Nr)),!I){const T=tI.subVectors(Nr.center,Ba).dot(xx);wp.push(h[v],T,y)}}const m=wp.list,g=this.customSort;g===null?m.sort(r.transparent?KR:JR):g.call(this,m,n);for(let y=0,_=m.length;y<_;y++){const v=m[y];l[x]=v.start*a,u[x]=v.count,f[x]=v.index,x++}wp.reset()}else for(let m=0,g=c.length;m<g;m++)if(c[m].visible&&c[m].active){const y=c[m].geometryIndex;let _=!1;if(d&&(this.getMatrixAt(m,Xs),this.getBoundingSphereAt(y,Nr).applyMatrix4(Xs),_=!bp.intersectsSphere(Nr)),!_){const v=h[y];l[x]=v.start*a,u[x]=v.count,f[x]=m,x++}}p.needsUpdate=!0,this._multiDrawCount=x,this._visibilityChanged=!1}onBeforeShadow(e,t,n,i,r,o){this.onBeforeRender(e,null,i,r,o)}}class Fn extends mn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new _e(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const oh=new E,ah=new E,_x=new Fe,za=new io,Ql=new Dn,Ap=new E,yx=new E;class Fs extends yt{constructor(e=new at,t=new Fn){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let i=1,r=t.count;i<r;i++)oh.fromBufferAttribute(t,i-1),ah.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=oh.distanceTo(ah);e.setAttribute("lineDistance",new Ve(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Ql.copy(n.boundingSphere),Ql.applyMatrix4(i),Ql.radius+=r,e.ray.intersectsSphere(Ql)===!1)return;_x.copy(i).invert(),za.copy(e.ray).applyMatrix4(_x);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=this.isLineSegments?2:1,u=n.index,d=n.attributes.position;if(u!==null){const p=Math.max(0,o.start),f=Math.min(u.count,o.start+o.count);for(let x=p,m=f-1;x<m;x+=l){const g=u.getX(x),y=u.getX(x+1),_=eu(this,e,za,c,g,y);_&&t.push(_)}if(this.isLineLoop){const x=u.getX(f-1),m=u.getX(p),g=eu(this,e,za,c,x,m);g&&t.push(g)}}else{const p=Math.max(0,o.start),f=Math.min(d.count,o.start+o.count);for(let x=p,m=f-1;x<m;x+=l){const g=eu(this,e,za,c,x,x+1);g&&t.push(g)}if(this.isLineLoop){const x=eu(this,e,za,c,f-1,p);x&&t.push(x)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r<o;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}function eu(s,e,t,n,i,r){const o=s.geometry.attributes.position;if(oh.fromBufferAttribute(o,i),ah.fromBufferAttribute(o,r),t.distanceSqToSegment(oh,ah,Ap,yx)>n)return;Ap.applyMatrix4(s.matrixWorld);const c=e.ray.origin.distanceTo(Ap);if(!(c<e.near||c>e.far))return{distance:c,point:yx.clone().applyMatrix4(s.matrixWorld),index:i,face:null,faceIndex:null,barycoord:null,object:s}}const vx=new E,Mx=new E;class rs extends Fs{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let i=0,r=t.count;i<r;i+=2)vx.fromBufferAttribute(t,i),Mx.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+vx.distanceTo(Mx);e.setAttribute("lineDistance",new Ve(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class dm extends Fs{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class ya extends mn{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new _e(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const Sx=new Fe,uf=new io,tu=new Dn,nu=new E;class pm extends yt{constructor(e=new at,t=new ya){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),tu.copy(n.boundingSphere),tu.applyMatrix4(i),tu.radius+=r,e.ray.intersectsSphere(tu)===!1)return;Sx.copy(i).invert(),uf.copy(e.ray).applyMatrix4(Sx);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=n.index,h=n.attributes.position;if(l!==null){const d=Math.max(0,o.start),p=Math.min(l.count,o.start+o.count);for(let f=d,x=p;f<x;f++){const m=l.getX(f);nu.fromBufferAttribute(h,m),Tx(nu,m,c,i,e,t,this)}}else{const d=Math.max(0,o.start),p=Math.min(h.count,o.start+o.count);for(let f=d,x=p;f<x;f++)nu.fromBufferAttribute(h,f),Tx(nu,f,c,i,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r<o;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}function Tx(s,e,t,n,i,r,o){const a=uf.distanceSqToPoint(s);if(a<t){const c=new E;uf.closestPointToPoint(s,c),c.applyMatrix4(n);const l=i.ray.origin.distanceTo(c);if(l<i.near||l>i.far)return;r.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:e,face:null,faceIndex:null,barycoord:null,object:o})}}class Ky extends Xt{constructor(e,t,n,i,r,o,a,c,l){super(e,t,n,i,r,o,a,c,l),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:Ut,this.magFilter=r!==void 0?r:Ut,this.generateMipmaps=!1;const u=this;function h(){u.needsUpdate=!0,e.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class fm extends Xt{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Qt,this.minFilter=Qt,this.generateMipmaps=!1,this.needsUpdate=!0}}class Kc extends Xt{constructor(e,t,n,i,r,o,a,c,l,u,h,d){super(null,o,a,c,l,u,i,r,h,d),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class jy extends Kc{constructor(e,t,n,i,r,o){super(e,t,n,r,o),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=Si,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Qy extends Kc{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,wi),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class ev extends Xt{constructor(e,t,n,i,r,o,a,c,l){super(e,t,n,i,r,o,a,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Gi{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),r=0;t.push(0);for(let o=1;o<=e;o++)n=this.getPoint(o/e),r+=n.distanceTo(i),t.push(r),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let i=0;const r=n.length;let o;t?o=t:o=e*n[r-1];let a=0,c=r-1,l;for(;a<=c;)if(i=Math.floor(a+(c-a)/2),l=n[i]-o,l<0)a=i+1;else if(l>0)c=i-1;else{c=i;break}if(i=c,n[i]===o)return i/(r-1);const u=n[i],d=n[i+1]-u,p=(o-u)/d;return(i+p)/(r-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);const o=this.getPoint(i),a=this.getPoint(r),c=t||(o.isVector2?new J:new E);return c.copy(a).sub(o).normalize(),c}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new E,i=[],r=[],o=[],a=new E,c=new Fe;for(let p=0;p<=e;p++){const f=p/e;i[p]=this.getTangentAt(f,new E)}r[0]=new E,o[0]=new E;let l=Number.MAX_VALUE;const u=Math.abs(i[0].x),h=Math.abs(i[0].y),d=Math.abs(i[0].z);u<=l&&(l=u,n.set(1,0,0)),h<=l&&(l=h,n.set(0,1,0)),d<=l&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],a),o[0].crossVectors(i[0],r[0]);for(let p=1;p<=e;p++){if(r[p]=r[p-1].clone(),o[p]=o[p-1].clone(),a.crossVectors(i[p-1],i[p]),a.length()>Number.EPSILON){a.normalize();const f=Math.acos(jt(i[p-1].dot(i[p]),-1,1));r[p].applyMatrix4(c.makeRotationAxis(a,f))}o[p].crossVectors(i[p],r[p])}if(t===!0){let p=Math.acos(jt(r[0].dot(r[e]),-1,1));p/=e,i[0].dot(a.crossVectors(r[0],r[e]))>0&&(p=-p);for(let f=1;f<=e;f++)r[f].applyMatrix4(c.makeRotationAxis(i[f],p*f)),o[f].crossVectors(i[f],r[f])}return{tangents:i,normals:r,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class jh extends Gi{constructor(e=0,t=0,n=1,i=1,r=0,o=Math.PI*2,a=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=o,this.aClockwise=a,this.aRotation=c}getPoint(e,t=new J){const n=t,i=Math.PI*2;let r=this.aEndAngle-this.aStartAngle;const o=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=i;for(;r>i;)r-=i;r<Number.EPSILON&&(o?r=0:r=i),this.aClockwise===!0&&!o&&(r===i?r=-i:r=r-i);const a=this.aStartAngle+e*r;let c=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){const u=Math.cos(this.aRotation),h=Math.sin(this.aRotation),d=c-this.aX,p=l-this.aY;c=d*u-p*h+this.aX,l=d*h+p*u+this.aY}return n.set(c,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class tv extends jh{constructor(e,t,n,i,r,o){super(e,t,n,n,i,r,o),this.isArcCurve=!0,this.type="ArcCurve"}}function mm(){let s=0,e=0,t=0,n=0;function i(r,o,a,c){s=r,e=a,t=-3*r+3*o-2*a-c,n=2*r-2*o+a+c}return{initCatmullRom:function(r,o,a,c,l){i(o,a,l*(a-r),l*(c-o))},initNonuniformCatmullRom:function(r,o,a,c,l,u,h){let d=(o-r)/l-(a-r)/(l+u)+(a-o)/u,p=(a-o)/u-(c-o)/(u+h)+(c-a)/h;d*=u,p*=u,i(o,a,d,p)},calc:function(r){const o=r*r,a=o*r;return s+e*r+t*o+n*a}}}const iu=new E,Np=new mm,Ep=new mm,Cp=new mm;class gm extends Gi{constructor(e=[],t=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=i}getPoint(e,t=new E){const n=t,i=this.points,r=i.length,o=(r-(this.closed?0:1))*e;let a=Math.floor(o),c=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/r)+1)*r:c===0&&a===r-1&&(a=r-2,c=1);let l,u;this.closed||a>0?l=i[(a-1)%r]:(iu.subVectors(i[0],i[1]).add(i[0]),l=iu);const h=i[a%r],d=i[(a+1)%r];if(this.closed||a+2<r?u=i[(a+2)%r]:(iu.subVectors(i[r-1],i[r-2]).add(i[r-1]),u=iu),this.curveType==="centripetal"||this.curveType==="chordal"){const p=this.curveType==="chordal"?.5:.25;let f=Math.pow(l.distanceToSquared(h),p),x=Math.pow(h.distanceToSquared(d),p),m=Math.pow(d.distanceToSquared(u),p);x<1e-4&&(x=1),f<1e-4&&(f=x),m<1e-4&&(m=x),Np.initNonuniformCatmullRom(l.x,h.x,d.x,u.x,f,x,m),Ep.initNonuniformCatmullRom(l.y,h.y,d.y,u.y,f,x,m),Cp.initNonuniformCatmullRom(l.z,h.z,d.z,u.z,f,x,m)}else this.curveType==="catmullrom"&&(Np.initCatmullRom(l.x,h.x,d.x,u.x,this.tension),Ep.initCatmullRom(l.y,h.y,d.y,u.y,this.tension),Cp.initCatmullRom(l.z,h.z,d.z,u.z,this.tension));return n.set(Np.calc(c),Ep.calc(c),Cp.calc(c)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(i.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const i=this.points[t];e.points.push(i.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(new E().fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function bx(s,e,t,n,i){const r=(n-e)*.5,o=(i-t)*.5,a=s*s,c=s*a;return(2*t-2*n+r+o)*c+(-3*t+3*n-2*r-o)*a+r*s+t}function iI(s,e){const t=1-s;return t*t*e}function sI(s,e){return 2*(1-s)*s*e}function rI(s,e){return s*s*e}function ja(s,e,t,n){return iI(s,e)+sI(s,t)+rI(s,n)}function oI(s,e){const t=1-s;return t*t*t*e}function aI(s,e){const t=1-s;return 3*t*t*s*e}function cI(s,e){return 3*(1-s)*s*s*e}function lI(s,e){return s*s*s*e}function Qa(s,e,t,n,i){return oI(s,e)+aI(s,t)+cI(s,n)+lI(s,i)}class xm extends Gi{constructor(e=new J,t=new J,n=new J,i=new J){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new J){const n=t,i=this.v0,r=this.v1,o=this.v2,a=this.v3;return n.set(Qa(e,i.x,r.x,o.x,a.x),Qa(e,i.y,r.y,o.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class nv extends Gi{constructor(e=new E,t=new E,n=new E,i=new E){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new E){const n=t,i=this.v0,r=this.v1,o=this.v2,a=this.v3;return n.set(Qa(e,i.x,r.x,o.x,a.x),Qa(e,i.y,r.y,o.y,a.y),Qa(e,i.z,r.z,o.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class _m extends Gi{constructor(e=new J,t=new J){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new J){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new J){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class iv extends Gi{constructor(e=new E,t=new E){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new E){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new E){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class ym extends Gi{constructor(e=new J,t=new J,n=new J){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new J){const n=t,i=this.v0,r=this.v1,o=this.v2;return n.set(ja(e,i.x,r.x,o.x),ja(e,i.y,r.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class vm extends Gi{constructor(e=new E,t=new E,n=new E){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new E){const n=t,i=this.v0,r=this.v1,o=this.v2;return n.set(ja(e,i.x,r.x,o.x),ja(e,i.y,r.y,o.y),ja(e,i.z,r.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Mm extends Gi{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new J){const n=t,i=this.points,r=(i.length-1)*e,o=Math.floor(r),a=r-o,c=i[o===0?o:o-1],l=i[o],u=i[o>i.length-2?i.length-1:o+1],h=i[o>i.length-3?i.length-1:o+2];return n.set(bx(a,c.x,l.x,u.x,h.x),bx(a,c.y,l.y,u.y,h.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const i=this.points[t];e.points.push(i.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(new J().fromArray(i))}return this}}var ch=Object.freeze({__proto__:null,ArcCurve:tv,CatmullRomCurve3:gm,CubicBezierCurve:xm,CubicBezierCurve3:nv,EllipseCurve:jh,LineCurve:_m,LineCurve3:iv,QuadraticBezierCurve:ym,QuadraticBezierCurve3:vm,SplineCurve:Mm});class sv extends Gi{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){const n=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new ch[n](t,e))}return this}getPoint(e,t){const n=e*this.getLength(),i=this.getCurveLengths();let r=0;for(;r<i.length;){if(i[r]>=n){const o=i[r]-n,a=this.curves[r],c=a.getLength(),l=c===0?0:1-o/c;return a.getPointAt(l,t)}r++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,i=this.curves.length;n<i;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let n;for(let i=0,r=this.curves;i<r.length;i++){const o=r[i],a=o.isEllipseCurve?e*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,c=o.getPoints(a);for(let l=0;l<c.length;l++){const u=c[l];n&&n.equals(u)||(t.push(u),n=u)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const i=e.curves[t];this.curves.push(i.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){const i=this.curves[t];e.curves.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const i=e.curves[t];this.curves.push(new ch[i.type]().fromJSON(i))}return this}}class Rc extends sv{constructor(e){super(),this.type="Path",this.currentPoint=new J,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const n=new _m(this.currentPoint.clone(),new J(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,i){const r=new ym(this.currentPoint.clone(),new J(e,t),new J(n,i));return this.curves.push(r),this.currentPoint.set(n,i),this}bezierCurveTo(e,t,n,i,r,o){const a=new xm(this.currentPoint.clone(),new J(e,t),new J(n,i),new J(r,o));return this.curves.push(a),this.currentPoint.set(r,o),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new Mm(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,i,r,o){const a=this.currentPoint.x,c=this.currentPoint.y;return this.absarc(e+a,t+c,n,i,r,o),this}absarc(e,t,n,i,r,o){return this.absellipse(e,t,n,n,i,r,o),this}ellipse(e,t,n,i,r,o,a,c){const l=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(e+l,t+u,n,i,r,o,a,c),this}absellipse(e,t,n,i,r,o,a,c){const l=new jh(e,t,n,i,r,o,a,c);if(this.curves.length>0){const h=l.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(l);const u=l.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class jc extends at{constructor(e=[new J(0,-.5),new J(.5,0),new J(0,.5)],t=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=jt(i,0,Math.PI*2);const r=[],o=[],a=[],c=[],l=[],u=1/t,h=new E,d=new J,p=new E,f=new E,x=new E;let m=0,g=0;for(let y=0;y<=e.length-1;y++)switch(y){case 0:m=e[y+1].x-e[y].x,g=e[y+1].y-e[y].y,p.x=g*1,p.y=-m,p.z=g*0,x.copy(p),p.normalize(),c.push(p.x,p.y,p.z);break;case e.length-1:c.push(x.x,x.y,x.z);break;default:m=e[y+1].x-e[y].x,g=e[y+1].y-e[y].y,p.x=g*1,p.y=-m,p.z=g*0,f.copy(p),p.x+=x.x,p.y+=x.y,p.z+=x.z,p.normalize(),c.push(p.x,p.y,p.z),x.copy(f)}for(let y=0;y<=t;y++){const _=n+y*u*i,v=Math.sin(_),I=Math.cos(_);for(let T=0;T<=e.length-1;T++){h.x=e[T].x*v,h.y=e[T].y,h.z=e[T].x*I,o.push(h.x,h.y,h.z),d.x=y/t,d.y=T/(e.length-1),a.push(d.x,d.y);const w=c[3*T+0]*v,C=c[3*T+1],F=c[3*T+0]*I;l.push(w,C,F)}}for(let y=0;y<t;y++)for(let _=0;_<e.length-1;_++){const v=_+y*e.length,I=v,T=v+e.length,w=v+e.length+1,C=v+1;r.push(I,T,C),r.push(w,C,T)}this.setIndex(r),this.setAttribute("position",new Ve(o,3)),this.setAttribute("uv",new Ve(a,2)),this.setAttribute("normal",new Ve(l,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new jc(e.points,e.segments,e.phiStart,e.phiLength)}}class Qh extends jc{constructor(e=1,t=1,n=4,i=8){const r=new Rc;r.absarc(0,-t/2,e,Math.PI*1.5,0),r.absarc(0,t/2,e,0,Math.PI*.5),super(r.getPoints(n),i),this.type="CapsuleGeometry",this.parameters={radius:e,length:t,capSegments:n,radialSegments:i}}static fromJSON(e){return new Qh(e.radius,e.length,e.capSegments,e.radialSegments)}}class ed extends at{constructor(e=1,t=32,n=0,i=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},t=Math.max(3,t);const r=[],o=[],a=[],c=[],l=new E,u=new J;o.push(0,0,0),a.push(0,0,1),c.push(.5,.5);for(let h=0,d=3;h<=t;h++,d+=3){const p=n+h/t*i;l.x=e*Math.cos(p),l.y=e*Math.sin(p),o.push(l.x,l.y,l.z),a.push(0,0,1),u.x=(o[d]/e+1)/2,u.y=(o[d+1]/e+1)/2,c.push(u.x,u.y)}for(let h=1;h<=t;h++)r.push(h,h+1,0);this.setIndex(r),this.setAttribute("position",new Ve(o,3)),this.setAttribute("normal",new Ve(a,3)),this.setAttribute("uv",new Ve(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ed(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class co extends at{constructor(e=1,t=1,n=1,i=32,r=1,o=!1,a=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:r,openEnded:o,thetaStart:a,thetaLength:c};const l=this;i=Math.floor(i),r=Math.floor(r);const u=[],h=[],d=[],p=[];let f=0;const x=[],m=n/2;let g=0;y(),o===!1&&(e>0&&_(!0),t>0&&_(!1)),this.setIndex(u),this.setAttribute("position",new Ve(h,3)),this.setAttribute("normal",new Ve(d,3)),this.setAttribute("uv",new Ve(p,2));function y(){const v=new E,I=new E;let T=0;const w=(t-e)/n;for(let C=0;C<=r;C++){const F=[],M=C/r,b=M*(t-e)+e;for(let G=0;G<=i;G++){const W=G/i,$=W*c+a,ie=Math.sin($),q=Math.cos($);I.x=b*ie,I.y=-M*n+m,I.z=b*q,h.push(I.x,I.y,I.z),v.set(ie,w,q).normalize(),d.push(v.x,v.y,v.z),p.push(W,1-M),F.push(f++)}x.push(F)}for(let C=0;C<i;C++)for(let F=0;F<r;F++){const M=x[F][C],b=x[F+1][C],G=x[F+1][C+1],W=x[F][C+1];e>0&&(u.push(M,b,W),T+=3),t>0&&(u.push(b,G,W),T+=3)}l.addGroup(g,T,0),g+=T}function _(v){const I=f,T=new J,w=new E;let C=0;const F=v===!0?e:t,M=v===!0?1:-1;for(let G=1;G<=i;G++)h.push(0,m*M,0),d.push(0,M,0),p.push(.5,.5),f++;const b=f;for(let G=0;G<=i;G++){const $=G/i*c+a,ie=Math.cos($),q=Math.sin($);w.x=F*q,w.y=m*M,w.z=F*ie,h.push(w.x,w.y,w.z),d.push(0,M,0),T.x=ie*.5+.5,T.y=q*.5*M+.5,p.push(T.x,T.y),f++}for(let G=0;G<i;G++){const W=I+G,$=b+G;v===!0?u.push($,$+1,W):u.push($+1,$,W),C+=3}l.addGroup(g,C,v===!0?1:2),g+=C}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new co(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class td extends co{constructor(e=1,t=1,n=32,i=1,r=!1,o=0,a=Math.PI*2){super(0,e,t,n,i,r,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:o,thetaLength:a}}static fromJSON(e){return new td(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class dr extends at{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};const r=[],o=[];a(i),l(n),u(),this.setAttribute("position",new Ve(r,3)),this.setAttribute("normal",new Ve(r.slice(),3)),this.setAttribute("uv",new Ve(o,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function a(y){const _=new E,v=new E,I=new E;for(let T=0;T<t.length;T+=3)p(t[T+0],_),p(t[T+1],v),p(t[T+2],I),c(_,v,I,y)}function c(y,_,v,I){const T=I+1,w=[];for(let C=0;C<=T;C++){w[C]=[];const F=y.clone().lerp(v,C/T),M=_.clone().lerp(v,C/T),b=T-C;for(let G=0;G<=b;G++)G===0&&C===T?w[C][G]=F:w[C][G]=F.clone().lerp(M,G/b)}for(let C=0;C<T;C++)for(let F=0;F<2*(T-C)-1;F++){const M=Math.floor(F/2);F%2===0?(d(w[C][M+1]),d(w[C+1][M]),d(w[C][M])):(d(w[C][M+1]),d(w[C+1][M+1]),d(w[C+1][M]))}}function l(y){const _=new E;for(let v=0;v<r.length;v+=3)_.x=r[v+0],_.y=r[v+1],_.z=r[v+2],_.normalize().multiplyScalar(y),r[v+0]=_.x,r[v+1]=_.y,r[v+2]=_.z}function u(){const y=new E;for(let _=0;_<r.length;_+=3){y.x=r[_+0],y.y=r[_+1],y.z=r[_+2];const v=m(y)/2/Math.PI+.5,I=g(y)/Math.PI+.5;o.push(v,1-I)}f(),h()}function h(){for(let y=0;y<o.length;y+=6){const _=o[y+0],v=o[y+2],I=o[y+4],T=Math.max(_,v,I),w=Math.min(_,v,I);T>.9&&w<.1&&(_<.2&&(o[y+0]+=1),v<.2&&(o[y+2]+=1),I<.2&&(o[y+4]+=1))}}function d(y){r.push(y.x,y.y,y.z)}function p(y,_){const v=y*3;_.x=e[v+0],_.y=e[v+1],_.z=e[v+2]}function f(){const y=new E,_=new E,v=new E,I=new E,T=new J,w=new J,C=new J;for(let F=0,M=0;F<r.length;F+=9,M+=6){y.set(r[F+0],r[F+1],r[F+2]),_.set(r[F+3],r[F+4],r[F+5]),v.set(r[F+6],r[F+7],r[F+8]),T.set(o[M+0],o[M+1]),w.set(o[M+2],o[M+3]),C.set(o[M+4],o[M+5]),I.copy(y).add(_).add(v).divideScalar(3);const b=m(I);x(T,M+0,y,b),x(w,M+2,_,b),x(C,M+4,v,b)}}function x(y,_,v,I){I<0&&y.x===1&&(o[_]=y.x-1),v.x===0&&v.z===0&&(o[_]=I/2/Math.PI+.5)}function m(y){return Math.atan2(y.z,-y.x)}function g(y){return Math.atan2(-y.y,Math.sqrt(y.x*y.x+y.z*y.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new dr(e.vertices,e.indices,e.radius,e.details)}}class nd extends dr{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=1/n,r=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(r,o,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new nd(e.radius,e.detail)}}const su=new E,ru=new E,Rp=new E,ou=new Zn;class Sm extends at{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const i=Math.pow(10,4),r=Math.cos($r*t),o=e.getIndex(),a=e.getAttribute("position"),c=o?o.count:a.count,l=[0,0,0],u=["a","b","c"],h=new Array(3),d={},p=[];for(let f=0;f<c;f+=3){o?(l[0]=o.getX(f),l[1]=o.getX(f+1),l[2]=o.getX(f+2)):(l[0]=f,l[1]=f+1,l[2]=f+2);const{a:x,b:m,c:g}=ou;if(x.fromBufferAttribute(a,l[0]),m.fromBufferAttribute(a,l[1]),g.fromBufferAttribute(a,l[2]),ou.getNormal(Rp),h[0]=`${Math.round(x.x*i)},${Math.round(x.y*i)},${Math.round(x.z*i)}`,h[1]=`${Math.round(m.x*i)},${Math.round(m.y*i)},${Math.round(m.z*i)}`,h[2]=`${Math.round(g.x*i)},${Math.round(g.y*i)},${Math.round(g.z*i)}`,!(h[0]===h[1]||h[1]===h[2]||h[2]===h[0]))for(let y=0;y<3;y++){const _=(y+1)%3,v=h[y],I=h[_],T=ou[u[y]],w=ou[u[_]],C=`${v}_${I}`,F=`${I}_${v}`;F in d&&d[F]?(Rp.dot(d[F].normal)<=r&&(p.push(T.x,T.y,T.z),p.push(w.x,w.y,w.z)),d[F]=null):C in d||(d[C]={index0:l[y],index1:l[_],normal:Rp.clone()})}}for(const f in d)if(d[f]){const{index0:x,index1:m}=d[f];su.fromBufferAttribute(a,x),ru.fromBufferAttribute(a,m),p.push(su.x,su.y,su.z),p.push(ru.x,ru.y,ru.z)}this.setAttribute("position",new Ve(p,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class er extends Rc{constructor(e){super(e),this.uuid=bi(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,i=this.holes.length;n<i;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const i=e.holes[t];this.holes.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){const i=this.holes[t];e.holes.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const i=e.holes[t];this.holes.push(new Rc().fromJSON(i))}return this}}const uI={triangulate:function(s,e,t=2){const n=e&&e.length,i=n?e[0]*t:s.length;let r=rv(s,0,i,t,!0);const o=[];if(!r||r.next===r.prev)return o;let a,c,l,u,h,d,p;if(n&&(r=mI(s,e,r,t)),s.length>80*t){a=l=s[0],c=u=s[1];for(let f=t;f<i;f+=t)h=s[f],d=s[f+1],h<a&&(a=h),d<c&&(c=d),h>l&&(l=h),d>u&&(u=d);p=Math.max(l-a,u-c),p=p!==0?32767/p:0}return Ic(r,o,t,a,c,p,0),o}};function rv(s,e,t,n,i){let r,o;if(i===AI(s,e,t,n)>0)for(r=e;r<t;r+=n)o=wx(r,s[r],s[r+1],o);else for(r=t-n;r>=e;r-=n)o=wx(r,s[r],s[r+1],o);return o&&id(o,o.next)&&(Lc(o),o=o.next),o}function eo(s,e){if(!s)return s;e||(e=s);let t=s,n;do if(n=!1,!t.steiner&&(id(t,t.next)||Zt(t.prev,t,t.next)===0)){if(Lc(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function Ic(s,e,t,n,i,r,o){if(!s)return;!o&&r&&vI(s,n,i,r);let a=s,c,l;for(;s.prev!==s.next;){if(c=s.prev,l=s.next,r?dI(s,n,i,r):hI(s)){e.push(c.i/t|0),e.push(s.i/t|0),e.push(l.i/t|0),Lc(s),s=l.next,a=l.next;continue}if(s=l,s===a){o?o===1?(s=pI(eo(s),e,t),Ic(s,e,t,n,i,r,2)):o===2&&fI(s,e,t,n,i,r):Ic(eo(s),e,t,n,i,r,1);break}}}function hI(s){const e=s.prev,t=s,n=s.next;if(Zt(e,t,n)>=0)return!1;const i=e.x,r=t.x,o=n.x,a=e.y,c=t.y,l=n.y,u=i<r?i<o?i:o:r<o?r:o,h=a<c?a<l?a:l:c<l?c:l,d=i>r?i>o?i:o:r>o?r:o,p=a>c?a>l?a:l:c>l?c:l;let f=n.next;for(;f!==e;){if(f.x>=u&&f.x<=d&&f.y>=h&&f.y<=p&&Ho(i,a,r,c,o,l,f.x,f.y)&&Zt(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function dI(s,e,t,n){const i=s.prev,r=s,o=s.next;if(Zt(i,r,o)>=0)return!1;const a=i.x,c=r.x,l=o.x,u=i.y,h=r.y,d=o.y,p=a<c?a<l?a:l:c<l?c:l,f=u<h?u<d?u:d:h<d?h:d,x=a>c?a>l?a:l:c>l?c:l,m=u>h?u>d?u:d:h>d?h:d,g=hf(p,f,e,t,n),y=hf(x,m,e,t,n);let _=s.prevZ,v=s.nextZ;for(;_&&_.z>=g&&v&&v.z<=y;){if(_.x>=p&&_.x<=x&&_.y>=f&&_.y<=m&&_!==i&&_!==o&&Ho(a,u,c,h,l,d,_.x,_.y)&&Zt(_.prev,_,_.next)>=0||(_=_.prevZ,v.x>=p&&v.x<=x&&v.y>=f&&v.y<=m&&v!==i&&v!==o&&Ho(a,u,c,h,l,d,v.x,v.y)&&Zt(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;_&&_.z>=g;){if(_.x>=p&&_.x<=x&&_.y>=f&&_.y<=m&&_!==i&&_!==o&&Ho(a,u,c,h,l,d,_.x,_.y)&&Zt(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;v&&v.z<=y;){if(v.x>=p&&v.x<=x&&v.y>=f&&v.y<=m&&v!==i&&v!==o&&Ho(a,u,c,h,l,d,v.x,v.y)&&Zt(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function pI(s,e,t){let n=s;do{const i=n.prev,r=n.next.next;!id(i,r)&&ov(i,n,n.next,r)&&Pc(i,r)&&Pc(r,i)&&(e.push(i.i/t|0),e.push(n.i/t|0),e.push(r.i/t|0),Lc(n),Lc(n.next),n=s=r),n=n.next}while(n!==s);return eo(n)}function fI(s,e,t,n,i,r){let o=s;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&TI(o,a)){let c=av(o,a);o=eo(o,o.next),c=eo(c,c.next),Ic(o,e,t,n,i,r,0),Ic(c,e,t,n,i,r,0);return}a=a.next}o=o.next}while(o!==s)}function mI(s,e,t,n){const i=[];let r,o,a,c,l;for(r=0,o=e.length;r<o;r++)a=e[r]*n,c=r<o-1?e[r+1]*n:s.length,l=rv(s,a,c,n,!1),l===l.next&&(l.steiner=!0),i.push(SI(l));for(i.sort(gI),r=0;r<i.length;r++)t=xI(i[r],t);return t}function gI(s,e){return s.x-e.x}function xI(s,e){const t=_I(s,e);if(!t)return e;const n=av(t,s);return eo(n,n.next),eo(t,t.next)}function _I(s,e){let t=e,n=-1/0,i;const r=s.x,o=s.y;do{if(o<=t.y&&o>=t.next.y&&t.next.y!==t.y){const d=t.x+(o-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=r&&d>n&&(n=d,i=t.x<t.next.x?t:t.next,d===r))return i}t=t.next}while(t!==e);if(!i)return null;const a=i,c=i.x,l=i.y;let u=1/0,h;t=i;do r>=t.x&&t.x>=c&&r!==t.x&&Ho(o<l?r:n,o,c,l,o<l?n:r,o,t.x,t.y)&&(h=Math.abs(o-t.y)/(r-t.x),Pc(t,s)&&(h<u||h===u&&(t.x>i.x||t.x===i.x&&yI(i,t)))&&(i=t,u=h)),t=t.next;while(t!==a);return i}function yI(s,e){return Zt(s.prev,s,e.prev)<0&&Zt(e.next,s,s.next)<0}function vI(s,e,t,n){let i=s;do i.z===0&&(i.z=hf(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==s);i.prevZ.nextZ=null,i.prevZ=null,MI(i)}function MI(s){let e,t,n,i,r,o,a,c,l=1;do{for(t=s,s=null,r=null,o=0;t;){for(o++,n=t,a=0,e=0;e<l&&(a++,n=n.nextZ,!!n);e++);for(c=l;a>0||c>0&&n;)a!==0&&(c===0||!n||t.z<=n.z)?(i=t,t=t.nextZ,a--):(i=n,n=n.nextZ,c--),r?r.nextZ=i:s=i,i.prevZ=r,r=i;t=n}r.nextZ=null,l*=2}while(o>1);return s}function hf(s,e,t,n,i){return s=(s-t)*i|0,e=(e-n)*i|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,s|e<<1}function SI(s){let e=s,t=s;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==s);return t}function Ho(s,e,t,n,i,r,o,a){return(i-o)*(e-a)>=(s-o)*(r-a)&&(s-o)*(n-a)>=(t-o)*(e-a)&&(t-o)*(r-a)>=(i-o)*(n-a)}function TI(s,e){return s.next.i!==e.i&&s.prev.i!==e.i&&!bI(s,e)&&(Pc(s,e)&&Pc(e,s)&&wI(s,e)&&(Zt(s.prev,s,e.prev)||Zt(s,e.prev,e))||id(s,e)&&Zt(s.prev,s,s.next)>0&&Zt(e.prev,e,e.next)>0)}function Zt(s,e,t){return(e.y-s.y)*(t.x-e.x)-(e.x-s.x)*(t.y-e.y)}function id(s,e){return s.x===e.x&&s.y===e.y}function ov(s,e,t,n){const i=cu(Zt(s,e,t)),r=cu(Zt(s,e,n)),o=cu(Zt(t,n,s)),a=cu(Zt(t,n,e));return!!(i!==r&&o!==a||i===0&&au(s,t,e)||r===0&&au(s,n,e)||o===0&&au(t,s,n)||a===0&&au(t,e,n))}function au(s,e,t){return e.x<=Math.max(s.x,t.x)&&e.x>=Math.min(s.x,t.x)&&e.y<=Math.max(s.y,t.y)&&e.y>=Math.min(s.y,t.y)}function cu(s){return s>0?1:s<0?-1:0}function bI(s,e){let t=s;do{if(t.i!==s.i&&t.next.i!==s.i&&t.i!==e.i&&t.next.i!==e.i&&ov(t,t.next,s,e))return!0;t=t.next}while(t!==s);return!1}function Pc(s,e){return Zt(s.prev,s,s.next)<0?Zt(s,e,s.next)>=0&&Zt(s,s.prev,e)>=0:Zt(s,e,s.prev)<0||Zt(s,s.next,e)<0}function wI(s,e){let t=s,n=!1;const i=(s.x+e.x)/2,r=(s.y+e.y)/2;do t.y>r!=t.next.y>r&&t.next.y!==t.y&&i<(t.next.x-t.x)*(r-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==s);return n}function av(s,e){const t=new df(s.i,s.x,s.y),n=new df(e.i,e.x,e.y),i=s.next,r=e.prev;return s.next=e,e.prev=s,t.next=i,i.prev=t,n.next=t,t.prev=n,r.next=n,n.prev=r,n}function wx(s,e,t,n){const i=new df(s,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Lc(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function df(s,e,t){this.i=s,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function AI(s,e,t,n){let i=0;for(let r=e,o=t-n;r<t;r+=n)i+=(s[o]-s[r])*(s[r+1]+s[o+1]),o=r;return i}class ji{static area(e){const t=e.length;let n=0;for(let i=t-1,r=0;r<t;i=r++)n+=e[i].x*e[r].y-e[r].x*e[i].y;return n*.5}static isClockWise(e){return ji.area(e)<0}static triangulateShape(e,t){const n=[],i=[],r=[];Ax(e),Nx(n,e);let o=e.length;t.forEach(Ax);for(let c=0;c<t.length;c++)i.push(o),o+=t[c].length,Nx(n,t[c]);const a=uI.triangulate(n,i);for(let c=0;c<a.length;c+=3)r.push(a.slice(c,c+3));return r}}function Ax(s){const e=s.length;e>2&&s[e-1].equals(s[0])&&s.pop()}function Nx(s,e){for(let t=0;t<e.length;t++)s.push(e[t].x),s.push(e[t].y)}class Qc extends at{constructor(e=new er([new J(.5,.5),new J(-.5,.5),new J(-.5,-.5),new J(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,i=[],r=[];for(let a=0,c=e.length;a<c;a++){const l=e[a];o(l)}this.setAttribute("position",new Ve(i,3)),this.setAttribute("uv",new Ve(r,2)),this.computeVertexNormals();function o(a){const c=[],l=t.curveSegments!==void 0?t.curveSegments:12,u=t.steps!==void 0?t.steps:1,h=t.depth!==void 0?t.depth:1;let d=t.bevelEnabled!==void 0?t.bevelEnabled:!0,p=t.bevelThickness!==void 0?t.bevelThickness:.2,f=t.bevelSize!==void 0?t.bevelSize:p-.1,x=t.bevelOffset!==void 0?t.bevelOffset:0,m=t.bevelSegments!==void 0?t.bevelSegments:3;const g=t.extrudePath,y=t.UVGenerator!==void 0?t.UVGenerator:NI;let _,v=!1,I,T,w,C;g&&(_=g.getSpacedPoints(u),v=!0,d=!1,I=g.computeFrenetFrames(u,!1),T=new E,w=new E,C=new E),d||(m=0,p=0,f=0,x=0);const F=a.extractPoints(l);let M=F.shape;const b=F.holes;if(!ji.isClockWise(M)){M=M.reverse();for(let ae=0,P=b.length;ae<P;ae++){const Me=b[ae];ji.isClockWise(Me)&&(b[ae]=Me.reverse())}}const W=ji.triangulateShape(M,b),$=M;for(let ae=0,P=b.length;ae<P;ae++){const Me=b[ae];M=M.concat(Me)}function ie(ae,P,Me){return P||console.error("THREE.ExtrudeGeometry: vec does not exist"),ae.clone().addScaledVector(P,Me)}const q=M.length,he=W.length;function Q(ae,P,Me){let ye,de,Te;const qe=ae.x-P.x,Ie=ae.y-P.y,R=Me.x-ae.x,S=Me.y-ae.y,X=qe*qe+Ie*Ie,re=qe*S-Ie*R;if(Math.abs(re)>Number.EPSILON){const ce=Math.sqrt(X),se=Math.sqrt(R*R+S*S),ke=P.x-Ie/ce,be=P.y+qe/ce,De=Me.x-S/se,vt=Me.y+R/se,me=((De-ke)*S-(vt-be)*R)/(qe*S-Ie*R);ye=ke+qe*me-ae.x,de=be+Ie*me-ae.y;const Ue=ye*ye+de*de;if(Ue<=2)return new J(ye,de);Te=Math.sqrt(Ue/2)}else{let ce=!1;qe>Number.EPSILON?R>Number.EPSILON&&(ce=!0):qe<-Number.EPSILON?R<-Number.EPSILON&&(ce=!0):Math.sign(Ie)===Math.sign(S)&&(ce=!0),ce?(ye=-Ie,de=qe,Te=Math.sqrt(X)):(ye=qe,de=Ie,Te=Math.sqrt(X/2))}return new J(ye/Te,de/Te)}const we=[];for(let ae=0,P=$.length,Me=P-1,ye=ae+1;ae<P;ae++,Me++,ye++)Me===P&&(Me=0),ye===P&&(ye=0),we[ae]=Q($[ae],$[Me],$[ye]);const Ne=[];let Ee,Qe=we.concat();for(let ae=0,P=b.length;ae<P;ae++){const Me=b[ae];Ee=[];for(let ye=0,de=Me.length,Te=de-1,qe=ye+1;ye<de;ye++,Te++,qe++)Te===de&&(Te=0),qe===de&&(qe=0),Ee[ye]=Q(Me[ye],Me[Te],Me[qe]);Ne.push(Ee),Qe=Qe.concat(Ee)}for(let ae=0;ae<m;ae++){const P=ae/m,Me=p*Math.cos(P*Math.PI/2),ye=f*Math.sin(P*Math.PI/2)+x;for(let de=0,Te=$.length;de<Te;de++){const qe=ie($[de],we[de],ye);ge(qe.x,qe.y,-Me)}for(let de=0,Te=b.length;de<Te;de++){const qe=b[de];Ee=Ne[de];for(let Ie=0,R=qe.length;Ie<R;Ie++){const S=ie(qe[Ie],Ee[Ie],ye);ge(S.x,S.y,-Me)}}}const ht=f+x;for(let ae=0;ae<q;ae++){const P=d?ie(M[ae],Qe[ae],ht):M[ae];v?(w.copy(I.normals[0]).multiplyScalar(P.x),T.copy(I.binormals[0]).multiplyScalar(P.y),C.copy(_[0]).add(w).add(T),ge(C.x,C.y,C.z)):ge(P.x,P.y,0)}for(let ae=1;ae<=u;ae++)for(let P=0;P<q;P++){const Me=d?ie(M[P],Qe[P],ht):M[P];v?(w.copy(I.normals[ae]).multiplyScalar(Me.x),T.copy(I.binormals[ae]).multiplyScalar(Me.y),C.copy(_[ae]).add(w).add(T),ge(C.x,C.y,C.z)):ge(Me.x,Me.y,h/u*ae)}for(let ae=m-1;ae>=0;ae--){const P=ae/m,Me=p*Math.cos(P*Math.PI/2),ye=f*Math.sin(P*Math.PI/2)+x;for(let de=0,Te=$.length;de<Te;de++){const qe=ie($[de],we[de],ye);ge(qe.x,qe.y,h+Me)}for(let de=0,Te=b.length;de<Te;de++){const qe=b[de];Ee=Ne[de];for(let Ie=0,R=qe.length;Ie<R;Ie++){const S=ie(qe[Ie],Ee[Ie],ye);v?ge(S.x,S.y+_[u-1].y,_[u-1].x+Me):ge(S.x,S.y,h+Me)}}}ne(),ue();function ne(){const ae=i.length/3;if(d){let P=0,Me=q*P;for(let ye=0;ye<he;ye++){const de=W[ye];Ze(de[2]+Me,de[1]+Me,de[0]+Me)}P=u+m*2,Me=q*P;for(let ye=0;ye<he;ye++){const de=W[ye];Ze(de[0]+Me,de[1]+Me,de[2]+Me)}}else{for(let P=0;P<he;P++){const Me=W[P];Ze(Me[2],Me[1],Me[0])}for(let P=0;P<he;P++){const Me=W[P];Ze(Me[0]+q*u,Me[1]+q*u,Me[2]+q*u)}}n.addGroup(ae,i.length/3-ae,0)}function ue(){const ae=i.length/3;let P=0;Ae($,P),P+=$.length;for(let Me=0,ye=b.length;Me<ye;Me++){const de=b[Me];Ae(de,P),P+=de.length}n.addGroup(ae,i.length/3-ae,1)}function Ae(ae,P){let Me=ae.length;for(;--Me>=0;){const ye=Me;let de=Me-1;de<0&&(de=ae.length-1);for(let Te=0,qe=u+m*2;Te<qe;Te++){const Ie=q*Te,R=q*(Te+1),S=P+ye+Ie,X=P+de+Ie,re=P+de+R,ce=P+ye+R;Xe(S,X,re,ce)}}}function ge(ae,P,Me){c.push(ae),c.push(P),c.push(Me)}function Ze(ae,P,Me){Je(ae),Je(P),Je(Me);const ye=i.length/3,de=y.generateTopUV(n,i,ye-3,ye-2,ye-1);dt(de[0]),dt(de[1]),dt(de[2])}function Xe(ae,P,Me,ye){Je(ae),Je(P),Je(ye),Je(P),Je(Me),Je(ye);const de=i.length/3,Te=y.generateSideWallUV(n,i,de-6,de-3,de-2,de-1);dt(Te[0]),dt(Te[1]),dt(Te[3]),dt(Te[1]),dt(Te[2]),dt(Te[3])}function Je(ae){i.push(c[ae*3+0]),i.push(c[ae*3+1]),i.push(c[ae*3+2])}function dt(ae){r.push(ae.x),r.push(ae.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return EI(t,n,e)}static fromJSON(e,t){const n=[];for(let r=0,o=e.shapes.length;r<o;r++){const a=t[e.shapes[r]];n.push(a)}const i=e.options.extrudePath;return i!==void 0&&(e.options.extrudePath=new ch[i.type]().fromJSON(i)),new Qc(n,e.options)}}const NI={generateTopUV:function(s,e,t,n,i){const r=e[t*3],o=e[t*3+1],a=e[n*3],c=e[n*3+1],l=e[i*3],u=e[i*3+1];return[new J(r,o),new J(a,c),new J(l,u)]},generateSideWallUV:function(s,e,t,n,i,r){const o=e[t*3],a=e[t*3+1],c=e[t*3+2],l=e[n*3],u=e[n*3+1],h=e[n*3+2],d=e[i*3],p=e[i*3+1],f=e[i*3+2],x=e[r*3],m=e[r*3+1],g=e[r*3+2];return Math.abs(a-u)<Math.abs(o-l)?[new J(o,1-c),new J(l,1-h),new J(d,1-f),new J(x,1-g)]:[new J(a,1-c),new J(u,1-h),new J(p,1-f),new J(m,1-g)]}};function EI(s,e,t){if(t.shapes=[],Array.isArray(s))for(let n=0,i=s.length;n<i;n++){const r=s[n];t.shapes.push(r.uuid)}else t.shapes.push(s.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class sd extends dr{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],r=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(i,r,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new sd(e.radius,e.detail)}}class va extends dr{constructor(e=1,t=0){const n=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],i=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(n,i,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new va(e.radius,e.detail)}}class el extends at{constructor(e=.5,t=1,n=32,i=1,r=0,o=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:i,thetaStart:r,thetaLength:o},n=Math.max(3,n),i=Math.max(1,i);const a=[],c=[],l=[],u=[];let h=e;const d=(t-e)/i,p=new E,f=new J;for(let x=0;x<=i;x++){for(let m=0;m<=n;m++){const g=r+m/n*o;p.x=h*Math.cos(g),p.y=h*Math.sin(g),c.push(p.x,p.y,p.z),l.push(0,0,1),f.x=(p.x/t+1)/2,f.y=(p.y/t+1)/2,u.push(f.x,f.y)}h+=d}for(let x=0;x<i;x++){const m=x*(n+1);for(let g=0;g<n;g++){const y=g+m,_=y,v=y+n+1,I=y+n+2,T=y+1;a.push(_,v,T),a.push(v,I,T)}}this.setIndex(a),this.setAttribute("position",new Ve(c,3)),this.setAttribute("normal",new Ve(l,3)),this.setAttribute("uv",new Ve(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new el(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class rd extends at{constructor(e=new er([new J(0,.5),new J(-.5,-.5),new J(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const n=[],i=[],r=[],o=[];let a=0,c=0;if(Array.isArray(e)===!1)l(e);else for(let u=0;u<e.length;u++)l(e[u]),this.addGroup(a,c,u),a+=c,c=0;this.setIndex(n),this.setAttribute("position",new Ve(i,3)),this.setAttribute("normal",new Ve(r,3)),this.setAttribute("uv",new Ve(o,2));function l(u){const h=i.length/3,d=u.extractPoints(t);let p=d.shape;const f=d.holes;ji.isClockWise(p)===!1&&(p=p.reverse());for(let m=0,g=f.length;m<g;m++){const y=f[m];ji.isClockWise(y)===!0&&(f[m]=y.reverse())}const x=ji.triangulateShape(p,f);for(let m=0,g=f.length;m<g;m++){const y=f[m];p=p.concat(y)}for(let m=0,g=p.length;m<g;m++){const y=p[m];i.push(y.x,y.y,0),r.push(0,0,1),o.push(y.x,y.y)}for(let m=0,g=x.length;m<g;m++){const y=x[m],_=y[0]+h,v=y[1]+h,I=y[2]+h;n.push(_,v,I),c+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return CI(t,e)}static fromJSON(e,t){const n=[];for(let i=0,r=e.shapes.length;i<r;i++){const o=t[e.shapes[i]];n.push(o)}return new rd(n,e.curveSegments)}}function CI(s,e){if(e.shapes=[],Array.isArray(s))for(let t=0,n=s.length;t<n;t++){const i=s[t];e.shapes.push(i.uuid)}else e.shapes.push(s.uuid);return e}class Ma extends at{constructor(e=1,t=32,n=16,i=0,r=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:r,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const c=Math.min(o+a,Math.PI);let l=0;const u=[],h=new E,d=new E,p=[],f=[],x=[],m=[];for(let g=0;g<=n;g++){const y=[],_=g/n;let v=0;g===0&&o===0?v=.5/t:g===n&&c===Math.PI&&(v=-.5/t);for(let I=0;I<=t;I++){const T=I/t;h.x=-e*Math.cos(i+T*r)*Math.sin(o+_*a),h.y=e*Math.cos(o+_*a),h.z=e*Math.sin(i+T*r)*Math.sin(o+_*a),f.push(h.x,h.y,h.z),d.copy(h).normalize(),x.push(d.x,d.y,d.z),m.push(T+v,1-_),y.push(l++)}u.push(y)}for(let g=0;g<n;g++)for(let y=0;y<t;y++){const _=u[g][y+1],v=u[g][y],I=u[g+1][y],T=u[g+1][y+1];(g!==0||o>0)&&p.push(_,v,T),(g!==n-1||c<Math.PI)&&p.push(v,I,T)}this.setIndex(p),this.setAttribute("position",new Ve(f,3)),this.setAttribute("normal",new Ve(x,3)),this.setAttribute("uv",new Ve(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ma(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class od extends dr{constructor(e=1,t=0){const n=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],i=[2,1,0,0,3,2,1,3,0,2,3,1];super(n,i,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new od(e.radius,e.detail)}}class tl extends at{constructor(e=1,t=.4,n=12,i=48,r=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:i,arc:r},n=Math.floor(n),i=Math.floor(i);const o=[],a=[],c=[],l=[],u=new E,h=new E,d=new E;for(let p=0;p<=n;p++)for(let f=0;f<=i;f++){const x=f/i*r,m=p/n*Math.PI*2;h.x=(e+t*Math.cos(m))*Math.cos(x),h.y=(e+t*Math.cos(m))*Math.sin(x),h.z=t*Math.sin(m),a.push(h.x,h.y,h.z),u.x=e*Math.cos(x),u.y=e*Math.sin(x),d.subVectors(h,u).normalize(),c.push(d.x,d.y,d.z),l.push(f/i),l.push(p/n)}for(let p=1;p<=n;p++)for(let f=1;f<=i;f++){const x=(i+1)*p+f-1,m=(i+1)*(p-1)+f-1,g=(i+1)*(p-1)+f,y=(i+1)*p+f;o.push(x,m,y),o.push(m,g,y)}this.setIndex(o),this.setAttribute("position",new Ve(a,3)),this.setAttribute("normal",new Ve(c,3)),this.setAttribute("uv",new Ve(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new tl(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class ad extends at{constructor(e=1,t=.4,n=64,i=8,r=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:i,p:r,q:o},n=Math.floor(n),i=Math.floor(i);const a=[],c=[],l=[],u=[],h=new E,d=new E,p=new E,f=new E,x=new E,m=new E,g=new E;for(let _=0;_<=n;++_){const v=_/n*r*Math.PI*2;y(v,r,o,e,p),y(v+.01,r,o,e,f),m.subVectors(f,p),g.addVectors(f,p),x.crossVectors(m,g),g.crossVectors(x,m),x.normalize(),g.normalize();for(let I=0;I<=i;++I){const T=I/i*Math.PI*2,w=-t*Math.cos(T),C=t*Math.sin(T);h.x=p.x+(w*g.x+C*x.x),h.y=p.y+(w*g.y+C*x.y),h.z=p.z+(w*g.z+C*x.z),c.push(h.x,h.y,h.z),d.subVectors(h,p).normalize(),l.push(d.x,d.y,d.z),u.push(_/n),u.push(I/i)}}for(let _=1;_<=n;_++)for(let v=1;v<=i;v++){const I=(i+1)*(_-1)+(v-1),T=(i+1)*_+(v-1),w=(i+1)*_+v,C=(i+1)*(_-1)+v;a.push(I,T,C),a.push(T,w,C)}this.setIndex(a),this.setAttribute("position",new Ve(c,3)),this.setAttribute("normal",new Ve(l,3)),this.setAttribute("uv",new Ve(u,2));function y(_,v,I,T,w){const C=Math.cos(_),F=Math.sin(_),M=I/v*_,b=Math.cos(M);w.x=T*(2+b)*.5*C,w.y=T*(2+b)*F*.5,w.z=T*Math.sin(M)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ad(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class cd extends at{constructor(e=new vm(new E(-1,-1,0),new E(-1,1,0),new E(1,1,0)),t=64,n=1,i=8,r=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:i,closed:r};const o=e.computeFrenetFrames(t,r);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;const a=new E,c=new E,l=new J;let u=new E;const h=[],d=[],p=[],f=[];x(),this.setIndex(f),this.setAttribute("position",new Ve(h,3)),this.setAttribute("normal",new Ve(d,3)),this.setAttribute("uv",new Ve(p,2));function x(){for(let _=0;_<t;_++)m(_);m(r===!1?t:0),y(),g()}function m(_){u=e.getPointAt(_/t,u);const v=o.normals[_],I=o.binormals[_];for(let T=0;T<=i;T++){const w=T/i*Math.PI*2,C=Math.sin(w),F=-Math.cos(w);c.x=F*v.x+C*I.x,c.y=F*v.y+C*I.y,c.z=F*v.z+C*I.z,c.normalize(),d.push(c.x,c.y,c.z),a.x=u.x+n*c.x,a.y=u.y+n*c.y,a.z=u.z+n*c.z,h.push(a.x,a.y,a.z)}}function g(){for(let _=1;_<=t;_++)for(let v=1;v<=i;v++){const I=(i+1)*(_-1)+(v-1),T=(i+1)*_+(v-1),w=(i+1)*_+v,C=(i+1)*(_-1)+v;f.push(I,T,C),f.push(T,w,C)}}function y(){for(let _=0;_<=t;_++)for(let v=0;v<=i;v++)l.x=_/t,l.y=v/i,p.push(l.x,l.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new cd(new ch[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class Tm extends at{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],n=new Set,i=new E,r=new E;if(e.index!==null){const o=e.attributes.position,a=e.index;let c=e.groups;c.length===0&&(c=[{start:0,count:a.count,materialIndex:0}]);for(let l=0,u=c.length;l<u;++l){const h=c[l],d=h.start,p=h.count;for(let f=d,x=d+p;f<x;f+=3)for(let m=0;m<3;m++){const g=a.getX(f+m),y=a.getX(f+(m+1)%3);i.fromBufferAttribute(o,g),r.fromBufferAttribute(o,y),Ex(i,r,n)===!0&&(t.push(i.x,i.y,i.z),t.push(r.x,r.y,r.z))}}}else{const o=e.attributes.position;for(let a=0,c=o.count/3;a<c;a++)for(let l=0;l<3;l++){const u=3*a+l,h=3*a+(l+1)%3;i.fromBufferAttribute(o,u),r.fromBufferAttribute(o,h),Ex(i,r,n)===!0&&(t.push(i.x,i.y,i.z),t.push(r.x,r.y,r.z))}}this.setAttribute("position",new Ve(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function Ex(s,e,t){const n=`${s.x},${s.y},${s.z}-${e.x},${e.y},${e.z}`,i=`${e.x},${e.y},${e.z}-${s.x},${s.y},${s.z}`;return t.has(n)===!0||t.has(i)===!0?!1:(t.add(n),t.add(i),!0)}var Cx=Object.freeze({__proto__:null,BoxGeometry:_s,CapsuleGeometry:Qh,CircleGeometry:ed,ConeGeometry:td,CylinderGeometry:co,DodecahedronGeometry:nd,EdgesGeometry:Sm,ExtrudeGeometry:Qc,IcosahedronGeometry:sd,LatheGeometry:jc,OctahedronGeometry:va,PlaneGeometry:ro,PolyhedronGeometry:dr,RingGeometry:el,ShapeGeometry:rd,SphereGeometry:Ma,TetrahedronGeometry:od,TorusGeometry:tl,TorusKnotGeometry:ad,TubeGeometry:cd,WireframeGeometry:Tm});class ld extends mn{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new _e(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class bm extends ki{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class nl extends mn{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new _e(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new _e(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ms,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ui,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class ud extends nl{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new J(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return jt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new _e(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new _e(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new _e(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class hd extends mn{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new _e(16777215),this.specular=new _e(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new _e(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ms,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ui,this.combine=fa,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class wm extends mn{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new _e(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new _e(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ms,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class dd extends mn{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ms,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class pd extends mn{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new _e(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new _e(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ms,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ui,this.combine=fa,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Am extends mn{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new _e(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ms,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class fd extends Fn{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function Wr(s,e,t){return!s||!t&&s.constructor===e?s:typeof e.BYTES_PER_ELEMENT=="number"?new e(s):Array.prototype.slice.call(s)}function cv(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function lv(s){function e(i,r){return s[i]-s[r]}const t=s.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function pf(s,e,t){const n=s.length,i=new s.constructor(n);for(let r=0,o=0;o!==n;++r){const a=t[r]*e;for(let c=0;c!==e;++c)i[o++]=s[a+c]}return i}function Nm(s,e,t,n){let i=1,r=s[0];for(;r!==void 0&&r[n]===void 0;)r=s[i++];if(r===void 0)return;let o=r[n];if(o!==void 0)if(Array.isArray(o))do o=r[n],o!==void 0&&(e.push(r.time),t.push.apply(t,o)),r=s[i++];while(r!==void 0);else if(o.toArray!==void 0)do o=r[n],o!==void 0&&(e.push(r.time),o.toArray(t,t.length)),r=s[i++];while(r!==void 0);else do o=r[n],o!==void 0&&(e.push(r.time),t.push(o)),r=s[i++];while(r!==void 0)}function RI(s,e,t,n,i=30){const r=s.clone();r.name=e;const o=[];for(let c=0;c<r.tracks.length;++c){const l=r.tracks[c],u=l.getValueSize(),h=[],d=[];for(let p=0;p<l.times.length;++p){const f=l.times[p]*i;if(!(f<t||f>=n)){h.push(l.times[p]);for(let x=0;x<u;++x)d.push(l.values[p*u+x])}}h.length!==0&&(l.times=Wr(h,l.times.constructor),l.values=Wr(d,l.values.constructor),o.push(l))}r.tracks=o;let a=1/0;for(let c=0;c<r.tracks.length;++c)a>r.tracks[c].times[0]&&(a=r.tracks[c].times[0]);for(let c=0;c<r.tracks.length;++c)r.tracks[c].shift(-1*a);return r.resetDuration(),r}function II(s,e=0,t=s,n=30){n<=0&&(n=30);const i=t.tracks.length,r=e/n;for(let o=0;o<i;++o){const a=t.tracks[o],c=a.ValueTypeName;if(c==="bool"||c==="string")continue;const l=s.tracks.find(function(g){return g.name===a.name&&g.ValueTypeName===c});if(l===void 0)continue;let u=0;const h=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(u=h/3);let d=0;const p=l.getValueSize();l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(d=p/3);const f=a.times.length-1;let x;if(r<=a.times[0]){const g=u,y=h-u;x=a.values.slice(g,y)}else if(r>=a.times[f]){const g=f*h+u,y=g+h-u;x=a.values.slice(g,y)}else{const g=a.createInterpolant(),y=u,_=h-u;g.evaluate(r),x=g.resultBuffer.slice(y,_)}c==="quaternion"&&new Qn().fromArray(x).normalize().conjugate().toArray(x);const m=l.times.length;for(let g=0;g<m;++g){const y=g*p+d;if(c==="quaternion")Qn.multiplyQuaternionsFlat(l.values,y,x,0,l.values,y);else{const _=p-d*2;for(let v=0;v<_;++v)l.values[y+v]-=x[v]}}}return s.blendMode=Yf,s}const PI={convertArray:Wr,isTypedArray:cv,getKeyframeOrder:lv,sortedArray:pf,flattenJSON:Nm,subclip:RI,makeClipAdditive:II};class Sa{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let o;n:{i:if(!(e<i)){for(let a=n+2;;){if(i===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(r=i,i=t[++n],e<i)break t}o=t.length;break n}if(!(e>=r)){const a=t[1];e<a&&(n=2,r=a);for(let c=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===c)break;if(i=r,r=t[--n-1],e>=r)break t}o=n,n=0;break n}break e}for(;n<o;){const a=n+o>>>1;e<t[a]?o=a:n=a+1}if(i=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let o=0;o!==i;++o)t[o]=n[r+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class uv extends Sa{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:zr,endingEnd:zr}}intervalChanged_(e,t,n){const i=this.parameterPositions;let r=e-2,o=e+1,a=i[r],c=i[o];if(a===void 0)switch(this.getSettings_().endingStart){case kr:r=e,a=2*t-n;break;case wc:r=i.length-2,a=t+i[r]-i[r+1];break;default:r=e,a=n}if(c===void 0)switch(this.getSettings_().endingEnd){case kr:o=e,c=2*n-t;break;case wc:o=1,c=n+i[1]-i[0];break;default:o=e-1,c=t}const l=(n-t)*.5,u=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(c-n),this._offsetPrev=r*u,this._offsetNext=o*u}interpolate_(e,t,n,i){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,u=this._offsetPrev,h=this._offsetNext,d=this._weightPrev,p=this._weightNext,f=(n-t)/(i-t),x=f*f,m=x*f,g=-d*m+2*d*x-d*f,y=(1+d)*m+(-1.5-2*d)*x+(-.5+d)*f+1,_=(-1-p)*m+(1.5+p)*x+.5*f,v=p*m-p*x;for(let I=0;I!==a;++I)r[I]=g*o[u+I]+y*o[l+I]+_*o[c+I]+v*o[h+I];return r}}class Em extends Sa{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,u=(n-t)/(i-t),h=1-u;for(let d=0;d!==a;++d)r[d]=o[l+d]*h+o[c+d]*u;return r}}class hv extends Sa{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class Hi{constructor(e,t,n,i){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Wr(t,this.TimeBufferType),this.values=Wr(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:Wr(e.times,Array),values:Wr(e.values,Array)};const i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new hv(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Em(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new uv(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case ia:t=this.InterpolantFactoryMethodDiscrete;break;case bc:t=this.InterpolantFactoryMethodLinear;break;case Eu:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return ia;case this.InterpolantFactoryMethodLinear:return bc;case this.InterpolantFactoryMethodSmooth:return Eu}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){const n=this.times,i=n.length;let r=0,o=i-1;for(;r!==i&&n[r]<e;)++r;for(;o!==-1&&n[o]>t;)--o;if(++o,r!==0||o!==i){r>=o&&(o=Math.max(o,1),r=o-1);const a=this.getValueSize();this.times=n.slice(r,o),this.values=this.values.slice(r*a,o*a)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,r=n.length;r===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==r;a++){const c=n[a];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,c),e=!1;break}if(o!==null&&o>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,c,o),e=!1;break}o=c}if(i!==void 0&&cv(i))for(let a=0,c=i.length;a!==c;++a){const l=i[a];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,l),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===Eu,r=e.length-1;let o=1;for(let a=1;a<r;++a){let c=!1;const l=e[a],u=e[a+1];if(l!==u&&(a!==1||l!==e[0]))if(i)c=!0;else{const h=a*n,d=h-n,p=h+n;for(let f=0;f!==n;++f){const x=t[h+f];if(x!==t[d+f]||x!==t[p+f]){c=!0;break}}}if(c){if(a!==o){e[o]=e[a];const h=a*n,d=o*n;for(let p=0;p!==n;++p)t[d+p]=t[h+p]}++o}}if(r>0){e[o]=e[r];for(let a=r*n,c=o*n,l=0;l!==n;++l)t[c+l]=t[a+l];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}Hi.prototype.TimeBufferType=Float32Array;Hi.prototype.ValueBufferType=Float32Array;Hi.prototype.DefaultInterpolation=bc;class pr extends Hi{constructor(e,t,n){super(e,t,n)}}pr.prototype.ValueTypeName="bool";pr.prototype.ValueBufferType=Array;pr.prototype.DefaultInterpolation=ia;pr.prototype.InterpolantFactoryMethodLinear=void 0;pr.prototype.InterpolantFactoryMethodSmooth=void 0;class md extends Hi{}md.prototype.ValueTypeName="color";class aa extends Hi{}aa.prototype.ValueTypeName="number";class dv extends Sa{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=(n-t)/(i-t);let l=e*a;for(let u=l+a;l!==u;l+=4)Qn.slerpFlat(r,0,o,l-a,o,l,c);return r}}class Ta extends Hi{InterpolantFactoryMethodLinear(e){return new dv(this.times,this.values,this.getValueSize(),e)}}Ta.prototype.ValueTypeName="quaternion";Ta.prototype.InterpolantFactoryMethodSmooth=void 0;class lo extends Hi{constructor(e,t,n){super(e,t,n)}}lo.prototype.ValueTypeName="string";lo.prototype.ValueBufferType=Array;lo.prototype.DefaultInterpolation=ia;lo.prototype.InterpolantFactoryMethodLinear=void 0;lo.prototype.InterpolantFactoryMethodSmooth=void 0;class ca extends Hi{}ca.prototype.ValueTypeName="vector";class la{constructor(e="",t=-1,n=[],i=zh){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=bi(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let o=0,a=n.length;o!==a;++o)t.push(DI(n[o]).scale(i));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let r=0,o=n.length;r!==o;++r)t.push(Hi.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const r=t.length,o=[];for(let a=0;a<r;a++){let c=[],l=[];c.push((a+r-1)%r,a,(a+1)%r),l.push(0,1,0);const u=lv(c);c=pf(c,1,u),l=pf(l,1,u),!i&&c[0]===0&&(c.push(r),l.push(l[0])),o.push(new aa(".morphTargetInfluences["+t[a].name+"]",c,l).scale(1/n))}return new this(e,-1,o)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const i={},r=/^([\w-]*?)([\d]+)$/;for(let a=0,c=e.length;a<c;a++){const l=e[a],u=l.name.match(r);if(u&&u.length>1){const h=u[1];let d=i[h];d||(i[h]=d=[]),d.push(l)}}const o=[];for(const a in i)o.push(this.CreateFromMorphTargetSequence(a,i[a],t,n));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(h,d,p,f,x){if(p.length!==0){const m=[],g=[];Nm(p,m,g,f),m.length!==0&&x.push(new h(d,m,g))}},i=[],r=e.name||"default",o=e.fps||30,a=e.blendMode;let c=e.length||-1;const l=e.hierarchy||[];for(let h=0;h<l.length;h++){const d=l[h].keys;if(!(!d||d.length===0))if(d[0].morphTargets){const p={};let f;for(f=0;f<d.length;f++)if(d[f].morphTargets)for(let x=0;x<d[f].morphTargets.length;x++)p[d[f].morphTargets[x]]=-1;for(const x in p){const m=[],g=[];for(let y=0;y!==d[f].morphTargets.length;++y){const _=d[f];m.push(_.time),g.push(_.morphTarget===x?1:0)}i.push(new aa(".morphTargetInfluence["+x+"]",m,g))}c=p.length*o}else{const p=".bones["+t[h].name+"]";n(ca,p+".position",d,"pos",i),n(Ta,p+".quaternion",d,"rot",i),n(ca,p+".scale",d,"scl",i)}}return i.length===0?null:new this(r,c,i,a)}resetDuration(){const e=this.tracks;let t=0;for(let n=0,i=e.length;n!==i;++n){const r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function LI(s){switch(s.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return aa;case"vector":case"vector2":case"vector3":case"vector4":return ca;case"color":return md;case"quaternion":return Ta;case"bool":case"boolean":return pr;case"string":return lo}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+s)}function DI(s){if(s.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=LI(s.type);if(s.times===void 0){const t=[],n=[];Nm(s.keys,t,n,"value"),s.times=t,s.values=n}return e.parse!==void 0?e.parse(s):new e(s.name,s.times,s.values,s.interpolation)}const Rs={enabled:!1,files:{},add:function(s,e){this.enabled!==!1&&(this.files[s]=e)},get:function(s){if(this.enabled!==!1)return this.files[s]},remove:function(s){delete this.files[s]},clear:function(){this.files={}}};class gd{constructor(e,t,n){const i=this;let r=!1,o=0,a=0,c;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(u){a++,r===!1&&i.onStart!==void 0&&i.onStart(u,o,a),r=!0},this.itemEnd=function(u){o++,i.onProgress!==void 0&&i.onProgress(u,o,a),o===a&&(r=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(u){i.onError!==void 0&&i.onError(u)},this.resolveURL=function(u){return c?c(u):u},this.setURLModifier=function(u){return c=u,this},this.addHandler=function(u,h){return l.push(u,h),this},this.removeHandler=function(u){const h=l.indexOf(u);return h!==-1&&l.splice(h,2),this},this.getHandler=function(u){for(let h=0,d=l.length;h<d;h+=2){const p=l[h],f=l[h+1];if(p.global&&(p.lastIndex=0),p.test(u))return f}return null}}}const Cm=new gd;class Xn{constructor(e){this.manager=e!==void 0?e:Cm,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise(function(i,r){n.load(e,i,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}Xn.DEFAULT_MATERIAL_NAME="__DEFAULT";const As={};class UI extends Error{constructor(e,t){super(e),this.response=t}}class ts extends Xn{constructor(e){super(e)}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=Rs.get(e);if(r!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(r),this.manager.itemEnd(e)},0),r;if(As[e]!==void 0){As[e].push({onLoad:t,onProgress:n,onError:i});return}As[e]=[],As[e].push({onLoad:t,onProgress:n,onError:i});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,c=this.responseType;fetch(o).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;const u=As[e],h=l.body.getReader(),d=l.headers.get("X-File-Size")||l.headers.get("Content-Length"),p=d?parseInt(d):0,f=p!==0;let x=0;const m=new ReadableStream({start(g){y();function y(){h.read().then(({done:_,value:v})=>{if(_)g.close();else{x+=v.byteLength;const I=new ProgressEvent("progress",{lengthComputable:f,loaded:x,total:p});for(let T=0,w=u.length;T<w;T++){const C=u[T];C.onProgress&&C.onProgress(I)}g.enqueue(v),y()}},_=>{g.error(_)})}}});return new Response(m)}else throw new UI(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return l.json();default:if(a===void 0)return l.text();{const h=/charset="?([^;"\s]*)"?/i.exec(a),d=h&&h[1]?h[1].toLowerCase():void 0,p=new TextDecoder(d);return l.arrayBuffer().then(f=>p.decode(f))}}}).then(l=>{Rs.add(e,l);const u=As[e];delete As[e];for(let h=0,d=u.length;h<d;h++){const p=u[h];p.onLoad&&p.onLoad(l)}}).catch(l=>{const u=As[e];if(u===void 0)throw this.manager.itemError(e),l;delete As[e];for(let h=0,d=u.length;h<d;h++){const p=u[h];p.onError&&p.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class FI extends Xn{constructor(e){super(e)}load(e,t,n,i){const r=this,o=new ts(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{t(r.parse(JSON.parse(a)))}catch(c){i?i(c):console.error(c),r.manager.itemError(e)}},n,i)}parse(e){const t=[];for(let n=0;n<e.length;n++){const i=la.parse(e[n]);t.push(i)}return t}}class OI extends Xn{constructor(e){super(e)}load(e,t,n,i){const r=this,o=[],a=new Kc,c=new ts(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(r.withCredentials);let l=0;function u(h){c.load(e[h],function(d){const p=r.parse(d,!0);o[h]={width:p.width,height:p.height,format:p.format,mipmaps:p.mipmaps},l+=1,l===6&&(p.mipmapCount===1&&(a.minFilter=Ut),a.image=o,a.format=p.format,a.needsUpdate=!0,t&&t(a))},n,i)}if(Array.isArray(e))for(let h=0,d=e.length;h<d;++h)u(h);else c.load(e,function(h){const d=r.parse(h,!0);if(d.isCubemap){const p=d.mipmaps.length/d.mipmapCount;for(let f=0;f<p;f++){o[f]={mipmaps:[]};for(let x=0;x<d.mipmapCount;x++)o[f].mipmaps.push(d.mipmaps[f*d.mipmapCount+x]),o[f].format=d.format,o[f].width=d.width,o[f].height=d.height}a.image=o}else a.image.width=d.width,a.image.height=d.height,a.mipmaps=d.mipmaps;d.mipmapCount===1&&(a.minFilter=Ut),a.format=d.format,a.needsUpdate=!0,t&&t(a)},n,i);return a}}class Dc extends Xn{constructor(e){super(e)}load(e,t,n,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,o=Rs.get(e);if(o!==void 0)return r.manager.itemStart(e),setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0),o;const a=Cc("img");function c(){u(),Rs.add(e,this),t&&t(this),r.manager.itemEnd(e)}function l(h){u(),i&&i(h),r.manager.itemError(e),r.manager.itemEnd(e)}function u(){a.removeEventListener("load",c,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",c,!1),a.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),r.manager.itemStart(e),a.src=e,a}}class VI extends Xn{constructor(e){super(e)}load(e,t,n,i){const r=new so;r.colorSpace=kn;const o=new Dc(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let a=0;function c(l){o.load(e[l],function(u){r.images[l]=u,a++,a===6&&(r.needsUpdate=!0,t&&t(r))},void 0,i)}for(let l=0;l<e.length;++l)c(l);return r}}class pv extends Xn{constructor(e){super(e)}load(e,t,n,i){const r=this,o=new Oi,a=new ts(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(r.withCredentials),a.load(e,function(c){let l;try{l=r.parse(c)}catch(u){if(i!==void 0)i(u);else{console.error(u);return}}l.image!==void 0?o.image=l.image:l.data!==void 0&&(o.image.width=l.width,o.image.height=l.height,o.image.data=l.data),o.wrapS=l.wrapS!==void 0?l.wrapS:Si,o.wrapT=l.wrapT!==void 0?l.wrapT:Si,o.magFilter=l.magFilter!==void 0?l.magFilter:Ut,o.minFilter=l.minFilter!==void 0?l.minFilter:Ut,o.anisotropy=l.anisotropy!==void 0?l.anisotropy:1,l.colorSpace!==void 0&&(o.colorSpace=l.colorSpace),l.flipY!==void 0&&(o.flipY=l.flipY),l.format!==void 0&&(o.format=l.format),l.type!==void 0&&(o.type=l.type),l.mipmaps!==void 0&&(o.mipmaps=l.mipmaps,o.minFilter=Jn),l.mipmapCount===1&&(o.minFilter=Ut),l.generateMipmaps!==void 0&&(o.generateMipmaps=l.generateMipmaps),o.needsUpdate=!0,t&&t(o,l)},n,i),o}}class fv extends Xn{constructor(e){super(e)}load(e,t,n,i){const r=new Xt,o=new Dc(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){r.image=a,r.needsUpdate=!0,t!==void 0&&t(r)},n,i),r}}class fr extends yt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new _e(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}class xd extends fr{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(yt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new _e(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const Ip=new Fe,Rx=new E,Ix=new E;class Rm{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new J(512,512),this.map=null,this.mapPass=null,this.matrix=new Fe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new ga,this._frameExtents=new J(1,1),this._viewportCount=1,this._viewports=[new st(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;Rx.setFromMatrixPosition(e.matrixWorld),t.position.copy(Rx),Ix.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Ix),t.updateMatrixWorld(),Ip.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ip),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Ip)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class BI extends Rm{constructor(){super(new hn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=ra*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,r=e.distance||t.far;(n!==t.fov||i!==t.aspect||r!==t.far)&&(t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class il extends fr{constructor(e,t,n=0,i=Math.PI/3,r=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(yt.DEFAULT_UP),this.updateMatrix(),this.target=new yt,this.distance=n,this.angle=i,this.penumbra=r,this.decay=o,this.map=null,this.shadow=new BI}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const Px=new Fe,ka=new E,Pp=new E;class zI extends Rm{constructor(){super(new hn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new J(4,2),this._viewportCount=6,this._viewports=[new st(2,1,1,1),new st(0,1,1,1),new st(3,1,1,1),new st(1,1,1,1),new st(3,0,1,1),new st(1,0,1,1)],this._cubeDirections=[new E(1,0,0),new E(-1,0,0),new E(0,0,1),new E(0,0,-1),new E(0,1,0),new E(0,-1,0)],this._cubeUps=[new E(0,1,0),new E(0,1,0),new E(0,1,0),new E(0,1,0),new E(0,0,1),new E(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,i=this.matrix,r=e.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),ka.setFromMatrixPosition(e.matrixWorld),n.position.copy(ka),Pp.copy(n.position),Pp.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(Pp),n.updateMatrixWorld(),i.makeTranslation(-ka.x,-ka.y,-ka.z),Px.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Px)}}class _d extends fr{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new zI}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class kI extends Rm{constructor(){super(new oo(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class yd extends fr{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(yt.DEFAULT_UP),this.updateMatrix(),this.target=new yt,this.shadow=new kI}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class vd extends fr{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Im extends fr{constructor(e,t,n=10,i=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class mv{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new E)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const n=e.x,i=e.y,r=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.282095),t.addScaledVector(o[1],.488603*i),t.addScaledVector(o[2],.488603*r),t.addScaledVector(o[3],.488603*n),t.addScaledVector(o[4],1.092548*(n*i)),t.addScaledVector(o[5],1.092548*(i*r)),t.addScaledVector(o[6],.315392*(3*r*r-1)),t.addScaledVector(o[7],1.092548*(n*r)),t.addScaledVector(o[8],.546274*(n*n-i*i)),t}getIrradianceAt(e,t){const n=e.x,i=e.y,r=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.886227),t.addScaledVector(o[1],2*.511664*i),t.addScaledVector(o[2],2*.511664*r),t.addScaledVector(o[3],2*.511664*n),t.addScaledVector(o[4],2*.429043*n*i),t.addScaledVector(o[5],2*.429043*i*r),t.addScaledVector(o[6],.743125*r*r-.247708),t.addScaledVector(o[7],2*.429043*n*r),t.addScaledVector(o[8],.429043*(n*n-i*i)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].fromArray(e,t+i*3);return this}toArray(e=[],t=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].toArray(e,t+i*3);return e}static getBasisAt(e,t){const n=e.x,i=e.y,r=e.z;t[0]=.282095,t[1]=.488603*i,t[2]=.488603*r,t[3]=.488603*n,t[4]=1.092548*n*i,t[5]=1.092548*i*r,t[6]=.315392*(3*r*r-1),t[7]=1.092548*n*r,t[8]=.546274*(n*n-i*i)}}class Pm extends fr{constructor(e=new mv,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class sl extends Xn{constructor(e){super(e),this.textures={}}load(e,t,n,i){const r=this,o=new ts(r.manager);o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,function(a){try{t(r.parse(JSON.parse(a)))}catch(c){i?i(c):console.error(c),r.manager.itemError(e)}},n,i)}parse(e){const t=this.textures;function n(r){return t[r]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",r),t[r]}const i=this.createMaterialFromType(e.type);if(e.uuid!==void 0&&(i.uuid=e.uuid),e.name!==void 0&&(i.name=e.name),e.color!==void 0&&i.color!==void 0&&i.color.setHex(e.color),e.roughness!==void 0&&(i.roughness=e.roughness),e.metalness!==void 0&&(i.metalness=e.metalness),e.sheen!==void 0&&(i.sheen=e.sheen),e.sheenColor!==void 0&&(i.sheenColor=new _e().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(i.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&i.emissive!==void 0&&i.emissive.setHex(e.emissive),e.specular!==void 0&&i.specular!==void 0&&i.specular.setHex(e.specular),e.specularIntensity!==void 0&&(i.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&i.specularColor!==void 0&&i.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(i.shininess=e.shininess),e.clearcoat!==void 0&&(i.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(i.dispersion=e.dispersion),e.iridescence!==void 0&&(i.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(i.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(i.transmission=e.transmission),e.thickness!==void 0&&(i.thickness=e.thickness),e.attenuationDistance!==void 0&&(i.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&i.attenuationColor!==void 0&&i.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(i.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(i.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(i.fog=e.fog),e.flatShading!==void 0&&(i.flatShading=e.flatShading),e.blending!==void 0&&(i.blending=e.blending),e.combine!==void 0&&(i.combine=e.combine),e.side!==void 0&&(i.side=e.side),e.shadowSide!==void 0&&(i.shadowSide=e.shadowSide),e.opacity!==void 0&&(i.opacity=e.opacity),e.transparent!==void 0&&(i.transparent=e.transparent),e.alphaTest!==void 0&&(i.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(i.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(i.depthFunc=e.depthFunc),e.depthTest!==void 0&&(i.depthTest=e.depthTest),e.depthWrite!==void 0&&(i.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(i.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(i.blendSrc=e.blendSrc),e.blendDst!==void 0&&(i.blendDst=e.blendDst),e.blendEquation!==void 0&&(i.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(i.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(i.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(i.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&i.blendColor!==void 0&&i.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(i.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(i.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(i.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(i.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(i.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(i.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(i.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(i.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(i.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(i.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(i.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(i.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(i.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(i.rotation=e.rotation),e.linewidth!==void 0&&(i.linewidth=e.linewidth),e.dashSize!==void 0&&(i.dashSize=e.dashSize),e.gapSize!==void 0&&(i.gapSize=e.gapSize),e.scale!==void 0&&(i.scale=e.scale),e.polygonOffset!==void 0&&(i.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(i.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(i.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(i.dithering=e.dithering),e.alphaToCoverage!==void 0&&(i.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(i.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(i.forceSinglePass=e.forceSinglePass),e.visible!==void 0&&(i.visible=e.visible),e.toneMapped!==void 0&&(i.toneMapped=e.toneMapped),e.userData!==void 0&&(i.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?i.vertexColors=e.vertexColors>0:i.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const r in e.uniforms){const o=e.uniforms[r];switch(i.uniforms[r]={},o.type){case"t":i.uniforms[r].value=n(o.value);break;case"c":i.uniforms[r].value=new _e().setHex(o.value);break;case"v2":i.uniforms[r].value=new J().fromArray(o.value);break;case"v3":i.uniforms[r].value=new E().fromArray(o.value);break;case"v4":i.uniforms[r].value=new st().fromArray(o.value);break;case"m3":i.uniforms[r].value=new Ke().fromArray(o.value);break;case"m4":i.uniforms[r].value=new Fe().fromArray(o.value);break;default:i.uniforms[r].value=o.value}}if(e.defines!==void 0&&(i.defines=e.defines),e.vertexShader!==void 0&&(i.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(i.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(i.glslVersion=e.glslVersion),e.extensions!==void 0)for(const r in e.extensions)i.extensions[r]=e.extensions[r];if(e.lights!==void 0&&(i.lights=e.lights),e.clipping!==void 0&&(i.clipping=e.clipping),e.size!==void 0&&(i.size=e.size),e.sizeAttenuation!==void 0&&(i.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(i.map=n(e.map)),e.matcap!==void 0&&(i.matcap=n(e.matcap)),e.alphaMap!==void 0&&(i.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(i.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(i.bumpScale=e.bumpScale),e.normalMap!==void 0&&(i.normalMap=n(e.normalMap)),e.normalMapType!==void 0&&(i.normalMapType=e.normalMapType),e.normalScale!==void 0){let r=e.normalScale;Array.isArray(r)===!1&&(r=[r,r]),i.normalScale=new J().fromArray(r)}return e.displacementMap!==void 0&&(i.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(i.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(i.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(i.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(i.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(i.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(i.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(i.specularMap=n(e.specularMap)),e.specularIntensityMap!==void 0&&(i.specularIntensityMap=n(e.specularIntensityMap)),e.specularColorMap!==void 0&&(i.specularColorMap=n(e.specularColorMap)),e.envMap!==void 0&&(i.envMap=n(e.envMap)),e.envMapRotation!==void 0&&i.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(i.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(i.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(i.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(i.lightMap=n(e.lightMap)),e.lightMapIntensity!==void 0&&(i.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(i.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(i.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(i.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(i.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(i.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(i.clearcoatNormalScale=new J().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(i.iridescenceMap=n(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(i.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(i.transmissionMap=n(e.transmissionMap)),e.thicknessMap!==void 0&&(i.thicknessMap=n(e.thicknessMap)),e.anisotropyMap!==void 0&&(i.anisotropyMap=n(e.anisotropyMap)),e.sheenColorMap!==void 0&&(i.sheenColorMap=n(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(i.sheenRoughnessMap=n(e.sheenRoughnessMap)),i}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return sl.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:ld,SpriteMaterial:Zc,RawShaderMaterial:bm,ShaderMaterial:ki,PointsMaterial:ya,MeshPhysicalMaterial:ud,MeshStandardMaterial:nl,MeshPhongMaterial:hd,MeshToonMaterial:wm,MeshNormalMaterial:dd,MeshLambertMaterial:pd,MeshDepthMaterial:Yh,MeshDistanceMaterial:sm,MeshBasicMaterial:ss,MeshMatcapMaterial:Am,LineDashedMaterial:fd,LineBasicMaterial:Fn,Material:mn};return new t[e]}}class lh{static decodeText(e){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let n=0,i=e.length;n<i;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class Lm extends at{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class gv extends Xn{constructor(e){super(e)}load(e,t,n,i){const r=this,o=new ts(r.manager);o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,function(a){try{t(r.parse(JSON.parse(a)))}catch(c){i?i(c):console.error(c),r.manager.itemError(e)}},n,i)}parse(e){const t={},n={};function i(p,f){if(t[f]!==void 0)return t[f];const m=p.interleavedBuffers[f],g=r(p,m.buffer),y=ko(m.type,g),_=new _a(y,m.stride);return _.uuid=m.uuid,t[f]=_,_}function r(p,f){if(n[f]!==void 0)return n[f];const m=p.arrayBuffers[f],g=new Uint32Array(m).buffer;return n[f]=g,g}const o=e.isInstancedBufferGeometry?new Lm:new at,a=e.data.index;if(a!==void 0){const p=ko(a.type,a.array);o.setIndex(new At(p,1))}const c=e.data.attributes;for(const p in c){const f=c[p];let x;if(f.isInterleavedBufferAttribute){const m=i(e.data,f.data);x=new Ds(m,f.itemSize,f.offset,f.normalized)}else{const m=ko(f.type,f.array),g=f.isInstancedBufferAttribute?Us:At;x=new g(m,f.itemSize,f.normalized)}f.name!==void 0&&(x.name=f.name),f.usage!==void 0&&x.setUsage(f.usage),o.setAttribute(p,x)}const l=e.data.morphAttributes;if(l)for(const p in l){const f=l[p],x=[];for(let m=0,g=f.length;m<g;m++){const y=f[m];let _;if(y.isInterleavedBufferAttribute){const v=i(e.data,y.data);_=new Ds(v,y.itemSize,y.offset,y.normalized)}else{const v=ko(y.type,y.array);_=new At(v,y.itemSize,y.normalized)}y.name!==void 0&&(_.name=y.name),x.push(_)}o.morphAttributes[p]=x}e.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);const h=e.data.groups||e.data.drawcalls||e.data.offsets;if(h!==void 0)for(let p=0,f=h.length;p!==f;++p){const x=h[p];o.addGroup(x.start,x.count,x.materialIndex)}const d=e.data.boundingSphere;if(d!==void 0){const p=new E;d.center!==void 0&&p.fromArray(d.center),o.boundingSphere=new Dn(p,d.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}}class xv extends Xn{constructor(e){super(e)}load(e,t,n,i){const r=this,o=this.path===""?lh.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||o;const a=new ts(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){let l=null;try{l=JSON.parse(c)}catch(h){i!==void 0&&i(h),console.error("THREE:ObjectLoader: Can't parse "+e+".",h.message);return}const u=l.metadata;if(u===void 0||u.type===void 0||u.type.toLowerCase()==="geometry"){i!==void 0&&i(new Error("THREE.ObjectLoader: Can't load "+e)),console.error("THREE.ObjectLoader: Can't load "+e);return}r.parse(l,t)},n,i)}async loadAsync(e,t){const n=this,i=this.path===""?lh.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||i;const r=new ts(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials);const o=await r.loadAsync(e,t),a=JSON.parse(o),c=a.metadata;if(c===void 0||c.type===void 0||c.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await n.parseAsync(a)}parse(e,t){const n=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,i),o=this.parseImages(e.images,function(){t!==void 0&&t(l)}),a=this.parseTextures(e.textures,o),c=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,r,c,a,n),u=this.parseSkeletons(e.skeletons,l);if(this.bindSkeletons(l,u),this.bindLightTargets(l),t!==void 0){let h=!1;for(const d in o)if(o[d].data instanceof HTMLImageElement){h=!0;break}h===!1&&t(l)}return l}async parseAsync(e){const t=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),i=this.parseGeometries(e.geometries,n),r=await this.parseImagesAsync(e.images),o=this.parseTextures(e.textures,r),a=this.parseMaterials(e.materials,o),c=this.parseObject(e.object,i,a,o,t),l=this.parseSkeletons(e.skeletons,c);return this.bindSkeletons(c,l),this.bindLightTargets(c),c}parseShapes(e){const t={};if(e!==void 0)for(let n=0,i=e.length;n<i;n++){const r=new er().fromJSON(e[n]);t[r.uuid]=r}return t}parseSkeletons(e,t){const n={},i={};if(t.traverse(function(r){r.isBone&&(i[r.uuid]=r)}),e!==void 0)for(let r=0,o=e.length;r<o;r++){const a=new Jc().fromJSON(e[r],i);n[a.uuid]=a}return n}parseGeometries(e,t){const n={};if(e!==void 0){const i=new gv;for(let r=0,o=e.length;r<o;r++){let a;const c=e[r];switch(c.type){case"BufferGeometry":case"InstancedBufferGeometry":a=i.parse(c);break;default:c.type in Cx?a=Cx[c.type].fromJSON(c,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${c.type}"`)}a.uuid=c.uuid,c.name!==void 0&&(a.name=c.name),c.userData!==void 0&&(a.userData=c.userData),n[c.uuid]=a}}return n}parseMaterials(e,t){const n={},i={};if(e!==void 0){const r=new sl;r.setTextures(t);for(let o=0,a=e.length;o<a;o++){const c=e[o];n[c.uuid]===void 0&&(n[c.uuid]=r.parse(c)),i[c.uuid]=n[c.uuid]}}return i}parseAnimations(e){const t={};if(e!==void 0)for(let n=0;n<e.length;n++){const i=e[n],r=la.parse(i);t[r.uuid]=r}return t}parseImages(e,t){const n=this,i={};let r;function o(c){return n.manager.itemStart(c),r.load(c,function(){n.manager.itemEnd(c)},void 0,function(){n.manager.itemError(c),n.manager.itemEnd(c)})}function a(c){if(typeof c=="string"){const l=c,u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(l)?l:n.resourcePath+l;return o(u)}else return c.data?{data:ko(c.type,c.data),width:c.width,height:c.height}:null}if(e!==void 0&&e.length>0){const c=new gd(t);r=new Dc(c),r.setCrossOrigin(this.crossOrigin);for(let l=0,u=e.length;l<u;l++){const h=e[l],d=h.url;if(Array.isArray(d)){const p=[];for(let f=0,x=d.length;f<x;f++){const m=d[f],g=a(m);g!==null&&(g instanceof HTMLImageElement?p.push(g):p.push(new Oi(g.data,g.width,g.height)))}i[h.uuid]=new Js(p)}else{const p=a(h.url);i[h.uuid]=new Js(p)}}}return i}async parseImagesAsync(e){const t=this,n={};let i;async function r(o){if(typeof o=="string"){const a=o,c=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(a)?a:t.resourcePath+a;return await i.loadAsync(c)}else return o.data?{data:ko(o.type,o.data),width:o.width,height:o.height}:null}if(e!==void 0&&e.length>0){i=new Dc(this.manager),i.setCrossOrigin(this.crossOrigin);for(let o=0,a=e.length;o<a;o++){const c=e[o],l=c.url;if(Array.isArray(l)){const u=[];for(let h=0,d=l.length;h<d;h++){const p=l[h],f=await r(p);f!==null&&(f instanceof HTMLImageElement?u.push(f):u.push(new Oi(f.data,f.width,f.height)))}n[c.uuid]=new Js(u)}else{const u=await r(c.url);n[c.uuid]=new Js(u)}}}return n}parseTextures(e,t){function n(r,o){return typeof r=="number"?r:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",r),o[r])}const i={};if(e!==void 0)for(let r=0,o=e.length;r<o;r++){const a=e[r];a.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',a.uuid),t[a.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",a.image);const c=t[a.image],l=c.data;let u;Array.isArray(l)?(u=new so,l.length===6&&(u.needsUpdate=!0)):(l&&l.data?u=new Oi:u=new Xt,l&&(u.needsUpdate=!0)),u.source=c,u.uuid=a.uuid,a.name!==void 0&&(u.name=a.name),a.mapping!==void 0&&(u.mapping=n(a.mapping,GI)),a.channel!==void 0&&(u.channel=a.channel),a.offset!==void 0&&u.offset.fromArray(a.offset),a.repeat!==void 0&&u.repeat.fromArray(a.repeat),a.center!==void 0&&u.center.fromArray(a.center),a.rotation!==void 0&&(u.rotation=a.rotation),a.wrap!==void 0&&(u.wrapS=n(a.wrap[0],Lx),u.wrapT=n(a.wrap[1],Lx)),a.format!==void 0&&(u.format=a.format),a.internalFormat!==void 0&&(u.internalFormat=a.internalFormat),a.type!==void 0&&(u.type=a.type),a.colorSpace!==void 0&&(u.colorSpace=a.colorSpace),a.minFilter!==void 0&&(u.minFilter=n(a.minFilter,Dx)),a.magFilter!==void 0&&(u.magFilter=n(a.magFilter,Dx)),a.anisotropy!==void 0&&(u.anisotropy=a.anisotropy),a.flipY!==void 0&&(u.flipY=a.flipY),a.generateMipmaps!==void 0&&(u.generateMipmaps=a.generateMipmaps),a.premultiplyAlpha!==void 0&&(u.premultiplyAlpha=a.premultiplyAlpha),a.unpackAlignment!==void 0&&(u.unpackAlignment=a.unpackAlignment),a.compareFunction!==void 0&&(u.compareFunction=a.compareFunction),a.userData!==void 0&&(u.userData=a.userData),i[a.uuid]=u}return i}parseObject(e,t,n,i,r){let o;function a(d){return t[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",d),t[d]}function c(d){if(d!==void 0){if(Array.isArray(d)){const p=[];for(let f=0,x=d.length;f<x;f++){const m=d[f];n[m]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",m),p.push(n[m])}return p}return n[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",d),n[d]}}function l(d){return i[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",d),i[d]}let u,h;switch(e.type){case"Scene":o=new Jh,e.background!==void 0&&(Number.isInteger(e.background)?o.background=new _e(e.background):o.background=l(e.background)),e.environment!==void 0&&(o.environment=l(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?o.fog=new om(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(o.fog=new Zh(e.fog.color,e.fog.density)),e.fog.name!==""&&(o.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(o.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(o.backgroundIntensity=e.backgroundIntensity),e.backgroundRotation!==void 0&&o.backgroundRotation.fromArray(e.backgroundRotation),e.environmentIntensity!==void 0&&(o.environmentIntensity=e.environmentIntensity),e.environmentRotation!==void 0&&o.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":o=new hn(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(o.focus=e.focus),e.zoom!==void 0&&(o.zoom=e.zoom),e.filmGauge!==void 0&&(o.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(o.filmOffset=e.filmOffset),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"OrthographicCamera":o=new oo(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(o.zoom=e.zoom),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"AmbientLight":o=new vd(e.color,e.intensity);break;case"DirectionalLight":o=new yd(e.color,e.intensity),o.target=e.target||"";break;case"PointLight":o=new _d(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":o=new Im(e.color,e.intensity,e.width,e.height);break;case"SpotLight":o=new il(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),o.target=e.target||"";break;case"HemisphereLight":o=new xd(e.color,e.groundColor,e.intensity);break;case"LightProbe":o=new Pm().fromJSON(e);break;case"SkinnedMesh":u=a(e.geometry),h=c(e.material),o=new lm(u,h),e.bindMode!==void 0&&(o.bindMode=e.bindMode),e.bindMatrix!==void 0&&o.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(o.skeleton=e.skeleton);break;case"Mesh":u=a(e.geometry),h=c(e.material),o=new kt(u,h);break;case"InstancedMesh":u=a(e.geometry),h=c(e.material);const d=e.count,p=e.instanceMatrix,f=e.instanceColor;o=new um(u,h,d),o.instanceMatrix=new Us(new Float32Array(p.array),16),f!==void 0&&(o.instanceColor=new Us(new Float32Array(f.array),f.itemSize));break;case"BatchedMesh":u=a(e.geometry),h=c(e.material),o=new hm(e.maxInstanceCount,e.maxVertexCount,e.maxIndexCount,h),o.geometry=u,o.perObjectFrustumCulled=e.perObjectFrustumCulled,o.sortObjects=e.sortObjects,o._drawRanges=e.drawRanges,o._reservedRanges=e.reservedRanges,o._visibility=e.visibility,o._active=e.active,o._bounds=e.bounds.map(x=>{const m=new Hn;m.min.fromArray(x.boxMin),m.max.fromArray(x.boxMax);const g=new Dn;return g.radius=x.sphereRadius,g.center.fromArray(x.sphereCenter),{boxInitialized:x.boxInitialized,box:m,sphereInitialized:x.sphereInitialized,sphere:g}}),o._maxInstanceCount=e.maxInstanceCount,o._maxVertexCount=e.maxVertexCount,o._maxIndexCount=e.maxIndexCount,o._geometryInitialized=e.geometryInitialized,o._geometryCount=e.geometryCount,o._matricesTexture=l(e.matricesTexture.uuid),e.colorsTexture!==void 0&&(o._colorsTexture=l(e.colorsTexture.uuid));break;case"LOD":o=new cm;break;case"Line":o=new Fs(a(e.geometry),c(e.material));break;case"LineLoop":o=new dm(a(e.geometry),c(e.material));break;case"LineSegments":o=new rs(a(e.geometry),c(e.material));break;case"PointCloud":case"Points":o=new pm(a(e.geometry),c(e.material));break;case"Sprite":o=new am(c(e.material));break;case"Group":o=new Hr;break;case"Bone":o=new Kh;break;default:o=new yt}if(o.uuid=e.uuid,e.name!==void 0&&(o.name=e.name),e.matrix!==void 0?(o.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(o.matrixAutoUpdate=e.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(e.position!==void 0&&o.position.fromArray(e.position),e.rotation!==void 0&&o.rotation.fromArray(e.rotation),e.quaternion!==void 0&&o.quaternion.fromArray(e.quaternion),e.scale!==void 0&&o.scale.fromArray(e.scale)),e.up!==void 0&&o.up.fromArray(e.up),e.castShadow!==void 0&&(o.castShadow=e.castShadow),e.receiveShadow!==void 0&&(o.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(o.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(o.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(o.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(o.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&o.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(o.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(o.visible=e.visible),e.frustumCulled!==void 0&&(o.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(o.renderOrder=e.renderOrder),e.userData!==void 0&&(o.userData=e.userData),e.layers!==void 0&&(o.layers.mask=e.layers),e.children!==void 0){const d=e.children;for(let p=0;p<d.length;p++)o.add(this.parseObject(d[p],t,n,i,r))}if(e.animations!==void 0){const d=e.animations;for(let p=0;p<d.length;p++){const f=d[p];o.animations.push(r[f])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(o.autoUpdate=e.autoUpdate);const d=e.levels;for(let p=0;p<d.length;p++){const f=d[p],x=o.getObjectByProperty("uuid",f.object);x!==void 0&&o.addLevel(x,f.distance,f.hysteresis)}}return o}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(n){if(n.isSkinnedMesh===!0&&n.skeleton!==void 0){const i=t[n.skeleton];i===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",n.skeleton):n.bind(i,n.bindMatrix)}})}bindLightTargets(e){e.traverse(function(t){if(t.isDirectionalLight||t.isSpotLight){const n=t.target,i=e.getObjectByProperty("uuid",n);i!==void 0?t.target=i:t.target=new yt}})}}const GI={UVMapping:Ih,CubeReflectionMapping:wi,CubeRefractionMapping:Vi,EquirectangularReflectionMapping:ir,EquirectangularRefractionMapping:sr,CubeUVReflectionMapping:hr},Lx={RepeatWrapping:rr,ClampToEdgeWrapping:Si,MirroredRepeatWrapping:ea},Dx={NearestFilter:Qt,NearestMipmapNearestFilter:Ph,NearestMipmapLinearFilter:Cs,LinearFilter:Ut,LinearMipmapNearestFilter:js,LinearMipmapLinearFilter:Jn};class _v extends Xn{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,o=Rs.get(e);if(o!==void 0){if(r.manager.itemStart(e),o.then){o.then(l=>{t&&t(l),r.manager.itemEnd(e)}).catch(l=>{i&&i(l)});return}return setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0),o}const a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader;const c=fetch(e,a).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(l){return Rs.add(e,l),t&&t(l),r.manager.itemEnd(e),l}).catch(function(l){i&&i(l),Rs.remove(e),r.manager.itemError(e),r.manager.itemEnd(e)});Rs.add(e,c),r.manager.itemStart(e)}}let lu;class Md{static getContext(){return lu===void 0&&(lu=new(window.AudioContext||window.webkitAudioContext)),lu}static setContext(e){lu=e}}class yv extends Xn{constructor(e){super(e)}load(e,t,n,i){const r=this,o=new ts(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(c){try{const l=c.slice(0);Md.getContext().decodeAudioData(l,function(h){t(h)}).catch(a)}catch(l){a(l)}},n,i);function a(c){i?i(c):console.error(c),r.manager.itemError(e)}}}const Ux=new Fe,Fx=new Fe,Er=new Fe;class Dm{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new hn,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new hn,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,Er.copy(e.projectionMatrix);const i=t.eyeSep/2,r=i*t.near/t.focus,o=t.near*Math.tan($r*t.fov*.5)/t.zoom;let a,c;Fx.elements[12]=-i,Ux.elements[12]=i,a=-o*t.aspect+r,c=o*t.aspect+r,Er.elements[0]=2*t.near/(c-a),Er.elements[8]=(c+a)/(c-a),this.cameraL.projectionMatrix.copy(Er),a=-o*t.aspect-r,c=o*t.aspect-r,Er.elements[0]=2*t.near/(c-a),Er.elements[8]=(c+a)/(c-a),this.cameraR.projectionMatrix.copy(Er)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(Fx),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(Ux)}}class Um{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Ox(),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=Ox();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function Ox(){return performance.now()}const as=new E,Vx=new Qn,HI=new E,Cr=new E;let vv=class extends yt{constructor(){super(),this.type="AudioListener",this.context=Md.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Um}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(as,Vx,HI),!(!Number.isFinite(as.x)||!Number.isFinite(as.y)||!Number.isFinite(as.z)))if(Cr.set(0,0,-1).applyQuaternion(Vx),t.positionX){const i=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(as.x,i),t.positionY.linearRampToValueAtTime(as.y,i),t.positionZ.linearRampToValueAtTime(as.z,i),t.forwardX.linearRampToValueAtTime(Cr.x,i),t.forwardY.linearRampToValueAtTime(Cr.y,i),t.forwardZ.linearRampToValueAtTime(Cr.z,i),t.upX.linearRampToValueAtTime(n.x,i),t.upY.linearRampToValueAtTime(n.y,i),t.upZ.linearRampToValueAtTime(n.z,i)}else t.setPosition(as.x,as.y,as.z),t.setOrientation(Cr.x,Cr.y,Cr.z,n.x,n.y,n.z)}};class Fm extends yt{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||(this.buffer?this.buffer.duration:Number.MAX_VALUE))),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(e=0){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,this.isPlaying===!0&&this.source.detune!==void 0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}}const Rr=new E,Bx=new Qn,WI=new E,Ir=new E;class Mv extends Fm{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,n){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=n,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(Rr,Bx,WI),Ir.set(0,0,1).applyQuaternion(Bx);const t=this.panner;if(t.positionX){const n=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Rr.x,n),t.positionY.linearRampToValueAtTime(Rr.y,n),t.positionZ.linearRampToValueAtTime(Rr.z,n),t.orientationX.linearRampToValueAtTime(Ir.x,n),t.orientationY.linearRampToValueAtTime(Ir.y,n),t.orientationZ.linearRampToValueAtTime(Ir.z,n)}else t.setPosition(Rr.x,Rr.y,Rr.z),t.setOrientation(Ir.x,Ir.y,Ir.z)}}class XI{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;const t=this.getFrequencyData();for(let n=0;n<t.length;n++)e+=t[n];return e/t.length}}class Sv{constructor(e,t,n){this.binding=e,this.valueSize=n;let i,r,o;switch(t){case"quaternion":i=this._slerp,r=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:i=this._lerp,r=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const n=this.buffer,i=this.valueSize,r=e*i+i;let o=this.cumulativeWeight;if(o===0){for(let a=0;a!==i;++a)n[r+a]=n[a];o=t}else{o+=t;const a=t/o;this._mixBufferRegion(n,r,0,a,i)}this.cumulativeWeight=o}accumulateAdditive(e){const t=this.buffer,n=this.valueSize,i=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,n=this.buffer,i=e*t+t,r=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const c=t*this._origIndex;this._mixBufferRegion(n,i,c,1-r,t)}o>0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let c=t,l=t+t;c!==l;++c)if(n[c]!==n[c+t]){a.setValue(n,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let r=n,o=i;r!==o;++r)t[r]=t[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,i,r){if(i>=.5)for(let o=0;o!==r;++o)e[t+o]=e[n+o]}_slerp(e,t,n,i){Qn.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){const o=this._workIndex*r;Qn.multiplyQuaternionsFlat(e,o,e,t,e,n),Qn.slerpFlat(e,t,e,t,e,o,i)}_lerp(e,t,n,i,r){const o=1-i;for(let a=0;a!==r;++a){const c=t+a;e[c]=e[c]*o+e[n+a]*i}}_lerpAdditive(e,t,n,i,r){for(let o=0;o!==r;++o){const a=t+o;e[a]=e[a]+e[n+o]*i}}}const Om="\\[\\]\\.:\\/",qI=new RegExp("["+Om+"]","g"),Vm="[^"+Om+"]",$I="[^"+Om.replace("\\.","")+"]",YI=/((?:WC+[\/:])*)/.source.replace("WC",Vm),ZI=/(WCOD+)?/.source.replace("WCOD",$I),JI=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Vm),KI=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Vm),jI=new RegExp("^"+YI+ZI+JI+KI+"$"),QI=["material","materials","bones","map"];class eP{constructor(e,t,n){const i=n||St.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class St{constructor(e,t,n){this.path=t,this.parsedPath=n||St.parseTrackName(t),this.node=St.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new St.Composite(e,t,n):new St(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(qI,"")}static parseTrackName(e){const t=jI.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const r=n.nodeName.substring(i+1);QI.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(r,o){for(let a=0;a<r.length;a++){const c=r[a];if(!o&&(c.name===t||c.uuid===t))return c;if(o&&c.userData&&c.userData.name===t)return c;const l=n(c.children,o);if(l)return l}return null},i=n(e.children);if(i)return i;{const r=n(e.children,!0);if(r)return r}}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,i=t.propertyName;let r=t.propertyIndex;if(e||(e=St.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let u=0;u<e.length;u++)if(e[u].name===l){l=u;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(l!==void 0){if(e[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}const o=e[i];if(o===void 0){const l=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+i+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=r}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}St.Composite=eP;St.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};St.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};St.prototype.GetterByBindingType=[St.prototype._getValue_direct,St.prototype._getValue_array,St.prototype._getValue_arrayElement,St.prototype._getValue_toArray];St.prototype.SetterByBindingTypeAndVersioning=[[St.prototype._setValue_direct,St.prototype._setValue_direct_setNeedsUpdate,St.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[St.prototype._setValue_array,St.prototype._setValue_array_setNeedsUpdate,St.prototype._setValue_array_setMatrixWorldNeedsUpdate],[St.prototype._setValue_arrayElement,St.prototype._setValue_arrayElement_setNeedsUpdate,St.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[St.prototype._setValue_fromArray,St.prototype._setValue_fromArray_setNeedsUpdate,St.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class tP{constructor(){this.isAnimationObjectGroup=!0,this.uuid=bi(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let n=0,i=arguments.length;n!==i;++n)e[arguments[n].uuid]=n;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){const e=this._objects,t=this._indicesByUUID,n=this._paths,i=this._parsedPaths,r=this._bindings,o=r.length;let a,c=e.length,l=this.nCachedObjects_;for(let u=0,h=arguments.length;u!==h;++u){const d=arguments[u],p=d.uuid;let f=t[p];if(f===void 0){f=c++,t[p]=f,e.push(d);for(let x=0,m=o;x!==m;++x)r[x].push(new St(d,n[x],i[x]))}else if(f<l){a=e[f];const x=--l,m=e[x];t[m.uuid]=f,e[f]=m,t[p]=x,e[x]=d;for(let g=0,y=o;g!==y;++g){const _=r[g],v=_[x];let I=_[f];_[f]=v,I===void 0&&(I=new St(d,n[g],i[g])),_[x]=I}}else e[f]!==a&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l}remove(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_;for(let o=0,a=arguments.length;o!==a;++o){const c=arguments[o],l=c.uuid,u=t[l];if(u!==void 0&&u>=r){const h=r++,d=e[h];t[d.uuid]=u,e[u]=d,t[l]=h,e[h]=c;for(let p=0,f=i;p!==f;++p){const x=n[p],m=x[h],g=x[u];x[u]=m,x[h]=g}}}this.nCachedObjects_=r}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_,o=e.length;for(let a=0,c=arguments.length;a!==c;++a){const l=arguments[a],u=l.uuid,h=t[u];if(h!==void 0)if(delete t[u],h<r){const d=--r,p=e[d],f=--o,x=e[f];t[p.uuid]=h,e[h]=p,t[x.uuid]=d,e[d]=x,e.pop();for(let m=0,g=i;m!==g;++m){const y=n[m],_=y[d],v=y[f];y[h]=_,y[d]=v,y.pop()}}else{const d=--o,p=e[d];d>0&&(t[p.uuid]=h),e[h]=p,e.pop();for(let f=0,x=i;f!==x;++f){const m=n[f];m[h]=m[d],m.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){const n=this._bindingsIndicesByPath;let i=n[e];const r=this._bindings;if(i!==void 0)return r[i];const o=this._paths,a=this._parsedPaths,c=this._objects,l=c.length,u=this.nCachedObjects_,h=new Array(l);i=r.length,n[e]=i,o.push(e),a.push(t),r.push(h);for(let d=u,p=c.length;d!==p;++d){const f=c[d];h[d]=new St(f,e,t)}return h}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){const i=this._paths,r=this._parsedPaths,o=this._bindings,a=o.length-1,c=o[a],l=e[a];t[l]=n,o[n]=c,o.pop(),r[n]=r[a],r.pop(),i[n]=i[a],i.pop()}}}class Tv{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;const r=t.tracks,o=r.length,a=new Array(o),c={endingStart:zr,endingEnd:zr};for(let l=0;l!==o;++l){const u=r[l].createInterpolant(null);a[l]=u,u.settings=c}this._interpolantSettings=c,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=$f,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){const i=this._clip.duration,r=e._clip.duration,o=r/i,a=i/r;e.warp(1,o,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const i=this._mixer,r=i.time,o=this.timeScale;let a=this._timeScaleInterpolant;a===null&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);const c=a.parameterPositions,l=a.sampleValues;return c[0]=r,c[1]=r+n,l[0]=e/o,l[1]=t/o,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled){this._updateWeight(e);return}const r=this._startTime;if(r!==null){const c=(e-r)*n;c<0||n===0?t=0:(this._startTime=null,t=n*c)}t*=this._updateTimeScale(e);const o=this._updateTime(t),a=this._updateWeight(e);if(a>0){const c=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case Yf:for(let u=0,h=c.length;u!==h;++u)c[u].evaluate(o),l[u].accumulateAdditive(a);break;case zh:default:for(let u=0,h=c.length;u!==h;++u)c[u].evaluate(o),l[u].accumulate(i,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(n!==null){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;if(n!==null){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let i=this.time+e,r=this._loopCount;const o=n===hy;if(e===0)return r===-1?i:o&&(r&1)===1?t-i:i;if(n===qf){r===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(r===-1&&(e>=0?(r=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),i>=t||i<0){const a=Math.floor(i/t);i-=t*a,r+=Math.abs(a);const c=this.repetitions-r;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(c===1){const l=e<0;this._setEndings(l,!l,o)}else this._setEndings(!1,!1,o);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=i;if(o&&(r&1)===1)return t-i}return i}_setEndings(e,t,n){const i=this._interpolantSettings;n?(i.endingStart=kr,i.endingEnd=kr):(e?i.endingStart=this.zeroSlopeAtStart?kr:zr:i.endingStart=wc,t?i.endingEnd=this.zeroSlopeAtEnd?kr:zr:i.endingEnd=wc)}_scheduleFading(e,t,n){const i=this._mixer,r=i.time;let o=this._weightInterpolant;o===null&&(o=i._lendControlInterpolant(),this._weightInterpolant=o);const a=o.parameterPositions,c=o.sampleValues;return a[0]=r,c[0]=t,a[1]=r+e,c[1]=n,this}}const nP=new Float32Array(1);class bv extends Ai{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,o=e._propertyBindings,a=e._interpolants,c=n.uuid,l=this._bindingsByRootAndName;let u=l[c];u===void 0&&(u={},l[c]=u);for(let h=0;h!==r;++h){const d=i[h],p=d.name;let f=u[p];if(f!==void 0)++f.referenceCount,o[h]=f;else{if(f=o[h],f!==void 0){f._cacheIndex===null&&(++f.referenceCount,this._addInactiveBinding(f,c,p));continue}const x=t&&t._propertyBindings[h].binding.parsedPath;f=new Sv(St.create(n,p,x),d.ValueTypeName,d.getValueSize()),++f.referenceCount,this._addInactiveBinding(f,c,p),o[h]=f}a[h].resultBuffer=f.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const n=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,n)}const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const r=t[n];r.useCount++===0&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const r=t[n];--r.useCount===0&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){const i=this._actions,r=this._actionsByClip;let o=r[t];if(o===void 0)o={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=o;else{const a=o.knownActions;e._byClipCacheIndex=a.length,a.push(e)}e._cacheIndex=i.length,i.push(e),o.actionByRoot[n]=e}_removeInactiveAction(e){const t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;const r=e._clip.uuid,o=this._actionsByClip,a=o[r],c=a.knownActions,l=c[c.length-1],u=e._byClipCacheIndex;l._byClipCacheIndex=u,c[u]=l,c.pop(),e._byClipCacheIndex=null;const h=a.actionByRoot,d=(e._localRoot||this._root).uuid;delete h[d],c.length===0&&delete o[r],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const r=t[n];--r.referenceCount===0&&this._removeInactiveBinding(r)}}_lendAction(e){const t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackAction(e){const t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_addInactiveBinding(e,t,n){const i=this._bindingsByRootAndName,r=this._bindings;let o=i[t];o===void 0&&(o={},i[t]=o),o[n]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){const t=this._bindings,n=e.binding,i=n.rootNode.uuid,r=n.path,o=this._bindingsByRootAndName,a=o[i],c=t[t.length-1],l=e._cacheIndex;c._cacheIndex=l,t[l]=c,t.pop(),delete a[r],Object.keys(a).length===0&&delete o[i]}_lendBinding(e){const t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackBinding(e){const t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let n=e[t];return n===void 0&&(n=new Em(new Float32Array(2),new Float32Array(2),1,nP),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){const t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,r=t[i];e.__cacheIndex=i,t[i]=e,r.__cacheIndex=n,t[n]=r}clipAction(e,t,n){const i=t||this._root,r=i.uuid;let o=typeof e=="string"?la.findByName(i,e):e;const a=o!==null?o.uuid:e,c=this._actionsByClip[a];let l=null;if(n===void 0&&(o!==null?n=o.blendMode:n=zh),c!==void 0){const h=c.actionByRoot[r];if(h!==void 0&&h.blendMode===n)return h;l=c.knownActions[0],o===null&&(o=l._clip)}if(o===null)return null;const u=new Tv(this,o,t,n);return this._bindAction(u,l),this._addInactiveAction(u,a,r),u}existingAction(e,t){const n=t||this._root,i=n.uuid,r=typeof e=="string"?la.findByName(n,e):e,o=r?r.uuid:e,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[i]||null}stopAllAction(){const e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),o=this._accuIndex^=1;for(let l=0;l!==n;++l)t[l]._update(i,e,r,o);const a=this._bindings,c=this._nActiveBindings;for(let l=0;l!==c;++l)a[l].apply(o);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,n=e.uuid,i=this._actionsByClip,r=i[n];if(r!==void 0){const o=r.knownActions;for(let a=0,c=o.length;a!==c;++a){const l=o[a];this._deactivateAction(l);const u=l._cacheIndex,h=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,h._cacheIndex=u,t[u]=h,t.pop(),this._removeInactiveBindingsForAction(l)}delete i[n]}}uncacheRoot(e){const t=e.uuid,n=this._actionsByClip;for(const o in n){const a=n[o].actionByRoot,c=a[t];c!==void 0&&(this._deactivateAction(c),this._removeInactiveAction(c))}const i=this._bindingsByRootAndName,r=i[t];if(r!==void 0)for(const o in r){const a=r[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(e,t){const n=this.existingAction(e,t);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}}let wv=class Av{constructor(e){this.value=e}clone(){return new Av(this.value.clone===void 0?this.value:this.value.clone())}},iP=0;class sP extends Ai{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:iP++}),this.name="",this.usage=sa,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(e){this.name=e.name,this.usage=e.usage;const t=e.uniforms;this.uniforms.length=0;for(let n=0,i=t.length;n<i;n++){const r=Array.isArray(t[n])?t[n]:[t[n]];for(let o=0;o<r.length;o++)this.uniforms.push(r[o].clone())}return this}clone(){return new this.constructor().copy(this)}}class Bm extends _a{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}class rP{constructor(e,t,n,i,r){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=n,this.elementSize=i,this.count=r,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}}const zx=new Fe;class Nv{constructor(e,t,n=0,i=1/0){this.ray=new io(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new $c,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return zx.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(zx),this}intersectObject(e,t=!0,n=[]){return ff(e,this,n,t),n.sort(kx),n}intersectObjects(e,t=!0,n=[]){for(let i=0,r=e.length;i<r;i++)ff(e[i],this,n,t);return n.sort(kx),n}}function kx(s,e){return s.distance-e.distance}function ff(s,e,t,n){let i=!0;if(s.layers.test(e.layers)&&s.raycast(e,t)===!1&&(i=!1),i===!0&&n===!0){const r=s.children;for(let o=0,a=r.length;o<a;o++)ff(r[o],e,t,!0)}}class Ev{constructor(e=1,t=0,n=0){return this.radius=e,this.phi=t,this.theta=n,this}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(jt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class oP{constructor(e=1,t=0,n=0){return this.radius=e,this.theta=t,this.y=n,this}set(e,t,n){return this.radius=e,this.theta=t,this.y=n,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+n*n),this.theta=Math.atan2(e,n),this.y=t,this}clone(){return new this.constructor().copy(this)}}class zm{constructor(e,t,n,i){zm.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,i){const r=this.elements;return r[0]=e,r[2]=t,r[1]=n,r[3]=i,this}}const Gx=new J;class aP{constructor(e=new J(1/0,1/0),t=new J(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Gx.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}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=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(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}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}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}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))}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}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Gx).distanceTo(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}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)}}const Hx=new E,uu=new E;class Cv{constructor(e=new E,t=new E){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Hx.subVectors(e,this.start),uu.subVectors(this.end,this.start);const n=uu.dot(uu);let r=uu.dot(Hx)/n;return t&&(r=jt(r,0,1)),r}closestPointToPoint(e,t,n){const i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const Wx=new E;class cP extends yt{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const n=new at,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,c=32;o<c;o++,a++){const l=o/c*Math.PI*2,u=a/c*Math.PI*2;i.push(Math.cos(l),Math.sin(l),1,Math.cos(u),Math.sin(u),1)}n.setAttribute("position",new Ve(i,3));const r=new Fn({fog:!1,toneMapped:!1});this.cone=new rs(n,r),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);const e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Wx.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Wx),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const qs=new E,hu=new Fe,Lp=new Fe;class lP extends rs{constructor(e){const t=Rv(e),n=new at,i=[],r=[],o=new _e(0,0,1),a=new _e(0,1,0);for(let l=0;l<t.length;l++){const u=t[l];u.parent&&u.parent.isBone&&(i.push(0,0,0),i.push(0,0,0),r.push(o.r,o.g,o.b),r.push(a.r,a.g,a.b))}n.setAttribute("position",new Ve(i,3)),n.setAttribute("color",new Ve(r,3));const c=new Fn({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(n,c),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){const t=this.bones,n=this.geometry,i=n.getAttribute("position");Lp.copy(this.root.matrixWorld).invert();for(let r=0,o=0;r<t.length;r++){const a=t[r];a.parent&&a.parent.isBone&&(hu.multiplyMatrices(Lp,a.matrixWorld),qs.setFromMatrixPosition(hu),i.setXYZ(o,qs.x,qs.y,qs.z),hu.multiplyMatrices(Lp,a.parent.matrixWorld),qs.setFromMatrixPosition(hu),i.setXYZ(o+1,qs.x,qs.y,qs.z),o+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}}function Rv(s){const e=[];s.isBone===!0&&e.push(s);for(let t=0;t<s.children.length;t++)e.push.apply(e,Rv(s.children[t]));return e}class uP extends kt{constructor(e,t,n){const i=new Ma(t,4,2),r=new ss({wireframe:!0,fog:!1,toneMapped:!1});super(i,r),this.light=e,this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const hP=new E,Xx=new _e,qx=new _e;class dP extends yt{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="HemisphereLightHelper";const i=new va(t);i.rotateY(Math.PI*.5),this.material=new ss({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const r=i.getAttribute("position"),o=new Float32Array(r.count*3);i.setAttribute("color",new At(o,3)),this.add(new kt(i,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");Xx.copy(this.light.color),qx.copy(this.light.groundColor);for(let n=0,i=t.count;n<i;n++){const r=n<i/2?Xx:qx;t.setXYZ(n,r.r,r.g,r.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(hP.setFromMatrixPosition(this.light.matrixWorld).negate())}}let Iv=class extends rs{constructor(e=10,t=10,n=4473924,i=8947848){n=new _e(n),i=new _e(i);const r=t/2,o=e/t,a=e/2,c=[],l=[];for(let d=0,p=0,f=-a;d<=t;d++,f+=o){c.push(-a,0,f,a,0,f),c.push(f,0,-a,f,0,a);const x=d===r?n:i;x.toArray(l,p),p+=3,x.toArray(l,p),p+=3,x.toArray(l,p),p+=3,x.toArray(l,p),p+=3}const u=new at;u.setAttribute("position",new Ve(c,3)),u.setAttribute("color",new Ve(l,3));const h=new Fn({vertexColors:!0,toneMapped:!1});super(u,h),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}};class pP extends rs{constructor(e=10,t=16,n=8,i=64,r=4473924,o=8947848){r=new _e(r),o=new _e(o);const a=[],c=[];if(t>1)for(let h=0;h<t;h++){const d=h/t*(Math.PI*2),p=Math.sin(d)*e,f=Math.cos(d)*e;a.push(0,0,0),a.push(p,0,f);const x=h&1?r:o;c.push(x.r,x.g,x.b),c.push(x.r,x.g,x.b)}for(let h=0;h<n;h++){const d=h&1?r:o,p=e-e/n*h;for(let f=0;f<i;f++){let x=f/i*(Math.PI*2),m=Math.sin(x)*p,g=Math.cos(x)*p;a.push(m,0,g),c.push(d.r,d.g,d.b),x=(f+1)/i*(Math.PI*2),m=Math.sin(x)*p,g=Math.cos(x)*p,a.push(m,0,g),c.push(d.r,d.g,d.b)}}const l=new at;l.setAttribute("position",new Ve(a,3)),l.setAttribute("color",new Ve(c,3));const u=new Fn({vertexColors:!0,toneMapped:!1});super(l,u),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const $x=new E,du=new E,Yx=new E;class Pv extends yt{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",t===void 0&&(t=1);let i=new at;i.setAttribute("position",new Ve([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const r=new Fn({fog:!1,toneMapped:!1});this.lightPlane=new Fs(i,r),this.add(this.lightPlane),i=new at,i.setAttribute("position",new Ve([0,0,0,0,0,1],3)),this.targetLine=new Fs(i,r),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),$x.setFromMatrixPosition(this.light.matrixWorld),du.setFromMatrixPosition(this.light.target.matrixWorld),Yx.subVectors(du,$x),this.lightPlane.lookAt(du),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(du),this.targetLine.scale.z=Yx.length()}}const pu=new E,Kt=new Yc;class Lv extends rs{constructor(e){const t=new at,n=new Fn({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],r=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(f,x){c(f),c(x)}function c(f){i.push(0,0,0),r.push(0,0,0),o[f]===void 0&&(o[f]=[]),o[f].push(i.length/3-1)}t.setAttribute("position",new Ve(i,3)),t.setAttribute("color",new Ve(r,3)),super(t,n),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();const l=new _e(16755200),u=new _e(16711680),h=new _e(43775),d=new _e(16777215),p=new _e(3355443);this.setColors(l,u,h,d,p)}setColors(e,t,n,i,r){const a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,n.r,n.g,n.b),a.setXYZ(33,n.r,n.g,n.b),a.setXYZ(34,n.r,n.g,n.b),a.setXYZ(35,n.r,n.g,n.b),a.setXYZ(36,n.r,n.g,n.b),a.setXYZ(37,n.r,n.g,n.b),a.setXYZ(38,i.r,i.g,i.b),a.setXYZ(39,i.r,i.g,i.b),a.setXYZ(40,r.r,r.g,r.b),a.setXYZ(41,r.r,r.g,r.b),a.setXYZ(42,r.r,r.g,r.b),a.setXYZ(43,r.r,r.g,r.b),a.setXYZ(44,r.r,r.g,r.b),a.setXYZ(45,r.r,r.g,r.b),a.setXYZ(46,r.r,r.g,r.b),a.setXYZ(47,r.r,r.g,r.b),a.setXYZ(48,r.r,r.g,r.b),a.setXYZ(49,r.r,r.g,r.b),a.needsUpdate=!0}update(){const e=this.geometry,t=this.pointMap,n=1,i=1;Kt.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),nn("c",t,e,Kt,0,0,-1),nn("t",t,e,Kt,0,0,1),nn("n1",t,e,Kt,-n,-i,-1),nn("n2",t,e,Kt,n,-i,-1),nn("n3",t,e,Kt,-n,i,-1),nn("n4",t,e,Kt,n,i,-1),nn("f1",t,e,Kt,-n,-i,1),nn("f2",t,e,Kt,n,-i,1),nn("f3",t,e,Kt,-n,i,1),nn("f4",t,e,Kt,n,i,1),nn("u1",t,e,Kt,n*.7,i*1.1,-1),nn("u2",t,e,Kt,-n*.7,i*1.1,-1),nn("u3",t,e,Kt,0,i*2,-1),nn("cf1",t,e,Kt,-n,0,1),nn("cf2",t,e,Kt,n,0,1),nn("cf3",t,e,Kt,0,-i,1),nn("cf4",t,e,Kt,0,i,1),nn("cn1",t,e,Kt,-n,0,-1),nn("cn2",t,e,Kt,n,0,-1),nn("cn3",t,e,Kt,0,-i,-1),nn("cn4",t,e,Kt,0,i,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function nn(s,e,t,n,i,r,o){pu.set(i,r,o).unproject(n);const a=e[s];if(a!==void 0){const c=t.getAttribute("position");for(let l=0,u=a.length;l<u;l++)c.setXYZ(a[l],pu.x,pu.y,pu.z)}}const fu=new Hn;class Dv extends rs{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Float32Array(24),r=new at;r.setIndex(new At(n,1)),r.setAttribute("position",new At(i,3)),super(r,new Fn({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&fu.setFromObject(this.object),fu.isEmpty())return;const t=fu.min,n=fu.max,i=this.geometry.attributes.position,r=i.array;r[0]=n.x,r[1]=n.y,r[2]=n.z,r[3]=t.x,r[4]=n.y,r[5]=n.z,r[6]=t.x,r[7]=t.y,r[8]=n.z,r[9]=n.x,r[10]=t.y,r[11]=n.z,r[12]=n.x,r[13]=n.y,r[14]=t.z,r[15]=t.x,r[16]=n.y,r[17]=t.z,r[18]=t.x,r[19]=t.y,r[20]=t.z,r[21]=n.x,r[22]=t.y,r[23]=t.z,i.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Uv extends rs{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],r=new at;r.setIndex(new At(n,1)),r.setAttribute("position",new Ve(i,3)),super(r,new Fn({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}}class fP extends Fs{constructor(e,t=1,n=16776960){const i=n,r=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],o=new at;o.setAttribute("position",new Ve(r,3)),o.computeBoundingSphere(),super(o,new Fn({color:i,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const a=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],c=new at;c.setAttribute("position",new Ve(a,3)),c.computeBoundingSphere(),this.add(new kt(c,new ss({color:i,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const Zx=new E;let mu,Dp;class mP extends yt{constructor(e=new E(0,0,1),t=new E(0,0,0),n=1,i=16776960,r=n*.2,o=r*.2){super(),this.type="ArrowHelper",mu===void 0&&(mu=new at,mu.setAttribute("position",new Ve([0,0,0,0,1,0],3)),Dp=new co(0,.5,1,5,1),Dp.translate(0,-.5,0)),this.position.copy(t),this.line=new Fs(mu,new Fn({color:i,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new kt(Dp,new ss({color:i,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(n,r,o)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Zx.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Zx,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}let Fv=class extends rs{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new at;i.setAttribute("position",new Ve(t,3)),i.setAttribute("color",new Ve(n,3));const r=new Fn({vertexColors:!0,toneMapped:!1});super(i,r),this.type="AxesHelper"}setColors(e,t,n){const i=new _e,r=this.geometry.attributes.color.array;return i.set(e),i.toArray(r,0),i.toArray(r,3),i.set(t),i.toArray(r,6),i.toArray(r,9),i.set(n),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};class Ov{constructor(){this.type="ShapePath",this.color=new _e,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Rc,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,i){return this.currentPath.quadraticCurveTo(e,t,n,i),this}bezierCurveTo(e,t,n,i,r,o){return this.currentPath.bezierCurveTo(e,t,n,i,r,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(g){const y=[];for(let _=0,v=g.length;_<v;_++){const I=g[_],T=new er;T.curves=I.curves,y.push(T)}return y}function n(g,y){const _=y.length;let v=!1;for(let I=_-1,T=0;T<_;I=T++){let w=y[I],C=y[T],F=C.x-w.x,M=C.y-w.y;if(Math.abs(M)>Number.EPSILON){if(M<0&&(w=y[T],F=-F,C=y[I],M=-M),g.y<w.y||g.y>C.y)continue;if(g.y===w.y){if(g.x===w.x)return!0}else{const b=M*(g.x-w.x)-F*(g.y-w.y);if(b===0)return!0;if(b<0)continue;v=!v}}else{if(g.y!==w.y)continue;if(C.x<=g.x&&g.x<=w.x||w.x<=g.x&&g.x<=C.x)return!0}}return v}const i=ji.isClockWise,r=this.subPaths;if(r.length===0)return[];let o,a,c;const l=[];if(r.length===1)return a=r[0],c=new er,c.curves=a.curves,l.push(c),l;let u=!i(r[0].getPoints());u=e?!u:u;const h=[],d=[];let p=[],f=0,x;d[f]=void 0,p[f]=[];for(let g=0,y=r.length;g<y;g++)a=r[g],x=a.getPoints(),o=i(x),o=e?!o:o,o?(!u&&d[f]&&f++,d[f]={s:new er,p:x},d[f].s.curves=a.curves,u&&f++,p[f]=[]):p[f].push({h:a,p:x[0]});if(!d[0])return t(r);if(d.length>1){let g=!1,y=0;for(let _=0,v=d.length;_<v;_++)h[_]=[];for(let _=0,v=d.length;_<v;_++){const I=p[_];for(let T=0;T<I.length;T++){const w=I[T];let C=!0;for(let F=0;F<d.length;F++)n(w.p,d[F].p)&&(_!==F&&y++,C?(C=!1,h[F].push(w)):g=!0);C&&h[_].push(w)}}y>0&&g===!1&&(p=h)}let m;for(let g=0,y=d.length;g<y;g++){c=d[g].s,l.push(c),m=p[g];for(let _=0,v=m.length;_<v;_++)c.holes.push(m[_].h)}return l}}class Vv extends Ai{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(){}disconnect(){}dispose(){}update(){}}class gP extends zi{constructor(e=1,t=1,n=1,i={}){console.warn('THREE.WebGLMultipleRenderTargets has been deprecated and will be removed in r172. Use THREE.WebGLRenderTarget and set the "count" parameter to enable MRT.'),super(e,t,{...i,count:n}),this.isWebGLMultipleRenderTargets=!0}get texture(){return this.textures}}const xP=["alphaMap","alphaTest","anisotropy","anisotropyMap","anisotropyRotation","aoMap","attenuationColor","attenuationDistance","bumpMap","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dispersion","displacementMap","emissive","emissiveMap","envMap","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThicknessMap","lightMap","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","roughness","roughnessMap","sheen","sheenColor","sheenColorMap","sheenRoughnessMap","shininess","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","thickness","transmission","transmissionMap"];class Bv{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=xP,this.renderId=0}firstInitialization(e){return this.renderObjects.has(e)===!1?(this.getRenderObjectData(e),!0):!1}getRenderObjectData(e){let t=this.renderObjects.get(e);return t===void 0&&(t={material:this.getMaterialData(e.material),worldMatrix:e.object.matrixWorld.clone()},e.object.center&&(t.center=e.object.center.clone()),e.object.morphTargetInfluences&&(t.morphTargetInfluences=e.object.morphTargetInfluences.slice()),e.bundle!==null&&(t.version=e.bundle.version),this.renderObjects.set(e,t)),t}containsNode(e){const t=e.material;for(const n in t)if(t[n]&&t[n].isNode)return!0;return e.renderer.nodes.modelViewMatrix!==null||e.renderer.nodes.modelNormalViewMatrix!==null}getMaterialData(e){const t={};for(const n of this.refreshUniforms){const i=e[n];i!=null&&(typeof i=="object"&&i.clone!==void 0?i.isTexture===!0?t[n]={id:i.id,version:i.version}:t[n]=i.clone():t[n]=i)}return t}equals(e){const{object:t,material:n}=e,i=this.getRenderObjectData(e);if(i.worldMatrix.equals(t.matrixWorld)!==!0)return i.worldMatrix.copy(t.matrixWorld),!1;const r=i.material;for(const o in r){const a=r[o],c=n[o];if(a.equals!==void 0){if(a.equals(c)===!1)return a.copy(c),!1}else if(c.isTexture===!0){if(a.id!==c.id||a.version!==c.version)return a.id=c.id,a.version=c.version,!1}else if(a!==c)return r[o]=c,!1}if(i.morphTargetInfluences){let o=!1;for(let a=0;a<i.morphTargetInfluences.length;a++)i.morphTargetInfluences[a]!==t.morphTargetInfluences[a]&&(o=!0);if(o)return!0}return i.center&&i.center.equals(t.center)===!1?(i.center.copy(t.center),!0):(e.bundle!==null&&(i.version=e.bundle.version),!0)}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e))return!0;const{renderId:n}=t;if(this.renderId!==n)return this.renderId=n,!0;const i=e.object.static===!0,r=e.bundle!==null&&e.bundle.static===!0&&this.getRenderObjectData(e).version===e.bundle.version;return i||r?!1:this.equals(e)!==!0}}function Uc(s,e=0){let t=3735928559^e,n=1103547991^e;if(s instanceof Array)for(let i=0,r;i<s.length;i++)r=s[i],t=Math.imul(t^r,2654435761),n=Math.imul(n^r,1597334677);else for(let i=0,r;i<s.length;i++)r=s.charCodeAt(i),t=Math.imul(t^r,2654435761),n=Math.imul(n^r,1597334677);return t=Math.imul(t^t>>>16,2246822507),t^=Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(t^t>>>13,3266489909),4294967296*(2097151&n)+(t>>>0)}const zv=s=>Uc(s),kv=s=>Uc(s),km=(...s)=>Uc(s);function Gm(s,e=!1){const t=[];s.isNode===!0&&(t.push(s.id),s=s.getSelf());for(const{property:n,childNode:i}of Fc(s))t.push(t,Uc(n.slice(0,-4)),i.getCacheKey(e));return Uc(t)}function*Fc(s,e=!1){for(const t in s){if(t.startsWith("_")===!0)continue;const n=s[t];if(Array.isArray(n)===!0)for(let i=0;i<n.length;i++){const r=n[i];r&&(r.isNode===!0||e&&typeof r.toJSON=="function")&&(yield{property:t,index:i,childNode:r})}else if(n&&n.isNode===!0)yield{property:t,childNode:n};else if(typeof n=="object")for(const i in n){const r=n[i];r&&(r.isNode===!0||e&&typeof r.toJSON=="function")&&(yield{property:t,index:i,childNode:r})}}}function Is(s){if(s==null)return null;const e=typeof s;return s.isNode===!0?"node":e==="number"?"float":e==="boolean"?"bool":e==="string"?"string":e==="function"?"shader":s.isVector2===!0?"vec2":s.isVector3===!0?"vec3":s.isVector4===!0?"vec4":s.isMatrix3===!0?"mat3":s.isMatrix4===!0?"mat4":s.isColor===!0?"color":s instanceof ArrayBuffer?"ArrayBuffer":null}function Hm(s,...e){const t=s?s.slice(-4):void 0;return e.length===1&&(t==="vec2"?e=[e[0],e[0]]:t==="vec3"?e=[e[0],e[0],e[0]]:t==="vec4"&&(e=[e[0],e[0],e[0],e[0]])),s==="color"?new _e(...e):t==="vec2"?new J(...e):t==="vec3"?new E(...e):t==="vec4"?new st(...e):t==="mat3"?new Ke(...e):t==="mat4"?new Fe(...e):s==="bool"?e[0]||!1:s==="float"||s==="int"||s==="uint"?e[0]||0:s==="string"?e[0]||"":s==="ArrayBuffer"?Xm(e[0]):null}function Wm(s){let e="";const t=new Uint8Array(s);for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e)}function Xm(s){return Uint8Array.from(atob(s),e=>e.charCodeAt(0)).buffer}var _P=Object.freeze({__proto__:null,arrayBufferToBase64:Wm,base64ToArrayBuffer:Xm,getCacheKey:Gm,getNodeChildren:Fc,getValueFromType:Hm,getValueType:Is,hash:km,hashArray:kv,hashString:zv});const mf={VERTEX:"vertex",FRAGMENT:"fragment"},We={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},yP={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},qm=["fragment","vertex"],gf=["setup","analyze","generate"],xf=[...qm,"compute"],ba=["x","y","z","w"];let vP=0;class Ye extends Ai{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=We.NONE,this.updateBeforeType=We.NONE,this.updateAfterType=We.NONE,this.uuid=Gh.generateUUID(),this.version=0,this._cacheKey=null,this._cacheKeyVersion=0,this.global=!1,this.isNode=!0,Object.defineProperty(this,"id",{value:vP++})}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,We.FRAME)}onRenderUpdate(e){return this.onUpdate(e,We.RENDER)}onObjectUpdate(e){return this.onUpdate(e,We.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of Fc(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e=e||this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=Gm(this,e),this._cacheKeyVersion=this.version),this._cacheKey}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){const t=this.getNodeType(e);return e.getElementType(t)}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}setup(e){const t=e.getNodeProperties(this);let n=0;for(const i of this.getChildren())t["node"+n++]=i;return null}analyze(e){if(e.increaseUsage(this)===1){const n=e.getNodeProperties(this);for(const i of Object.values(n))i&&i.isNode===!0&&i.build(e)}}generate(e,t){const{outputNode:n}=e.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const n=this.getShared(e);if(this!==n)return n.build(e,t);e.addNode(this),e.addChain(this);let i=null;const r=e.getBuildStage();if(r==="setup"){this.updateReference(e);const o=e.getNodeProperties(this);if(o.initialized!==!0){const a=e.stack.nodes.length;o.initialized=!0,o.outputNode=this.setup(e),o.outputNode!==null&&e.stack.nodes.length;for(const c of Object.values(o))c&&c.isNode===!0&&c.build(e)}}else if(r==="analyze")this.analyze(e);else if(r==="generate")if(this.generate.length===1){const a=this.getNodeType(e),c=e.getDataFromNode(this);i=c.snippet,i===void 0?(i=this.generate(e)||"",c.snippet=i):c.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),i=e.format(i,a,t)}else i=this.generate(e,t)||"";return e.removeChain(this),i}getSerializeChildren(){return Fc(this)}serialize(e){const t=this.getSerializeChildren(),n={};for(const{property:i,index:r,childNode:o}of t)r!==void 0?(n[i]===void 0&&(n[i]=Number.isInteger(r)?[]:{}),n[i][r]=o.toJSON(e.meta).uuid):n[i]=o.toJSON(e.meta).uuid;Object.keys(n).length>0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){const t=e.meta.nodes;for(const n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){const i=[];for(const r of e.inputNodes[n])i.push(t[r]);this[n]=i}else if(typeof e.inputNodes[n]=="object"){const i={};for(const r in e.inputNodes[n]){const o=e.inputNodes[n][r];i[r]=t[o]}this[n]=i}else{const i=e.inputNodes[n];this[n]=t[i]}}}toJSON(e){const{uuid:t,type:n}=this,i=e===void 0||typeof e=="string";i&&(e={textures:{},images:{},nodes:{}});let r=e.nodes[t];r===void 0&&(r={uuid:t,type:n,meta:e,metadata:{version:4.6,type:"Node",generator:"Node.toJSON"}},i!==!0&&(e.nodes[r.uuid]=r),this.serialize(r),delete r.meta);function o(a){const c=[];for(const l in a){const u=a[l];delete u.metadata,c.push(u)}return c}if(i){const a=o(e.textures),c=o(e.images),l=o(e.nodes);a.length>0&&(r.textures=a),c.length>0&&(r.images=c),l.length>0&&(r.nodes=l)}return r}}class mr extends Ye{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){const t=this.node.build(e),n=this.indexNode.build(e,"uint");return`${t}[ ${n} ]`}}class $m extends Ye{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let n=null;for(const i of this.convertTo.split("|"))(n===null||e.getTypeLength(t)===e.getTypeLength(i))&&(n=i);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const n=this.node,i=this.getNodeType(e),r=n.build(e,i);return e.format(r,i,t)}}class pt extends Ye{static get type(){return"TempNode"}constructor(e){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()==="generate"){const i=e.getVectorType(this.getNodeType(e,t)),r=e.getDataFromNode(this);if(r.propertyName!==void 0)return e.format(r.propertyName,i,t);if(i!=="void"&&t!=="void"&&this.hasDependencies(e)){const o=super.build(e,i),a=e.getVarFromNode(this,null,i),c=e.getPropertyName(a);return e.addLineFlowCode(`${c} = ${o}`,this),r.snippet=o,r.propertyName=c,e.format(r.propertyName,i,t)}}return super.build(e,t)}}class Gv extends pt{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType!==null?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0))}generate(e,t){const n=this.getNodeType(e),i=this.nodes,r=e.getComponentType(n),o=[];for(const c of i){let l=c.build(e);const u=e.getComponentType(c.getNodeType(e));u!==r&&(l=e.format(l,u,r)),o.push(l)}const a=`${e.getType(n)}( ${o.join(", ")} )`;return e.format(a,n,t)}}const MP=ba.join("");class uh extends Ye{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max(ba.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){const n=this.node,i=e.getTypeLength(n.getNodeType(e));let r=null;if(i>1){let o=null;this.getVectorLength()>=i&&(o=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const c=n.build(e,o);this.components.length===i&&this.components===MP.slice(0,this.components.length)?r=e.format(c,o,t):r=e.format(`${c}.${this.components}`,this.getNodeType(e),t)}else r=n.build(e,t);return r}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class Hv extends pt{static get type(){return"SetNode"}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:n,targetNode:i}=this,r=this.getNodeType(e),o=e.getTypeFromLength(n.length,i.getNodeType(e)),a=i.build(e,o),c=t.build(e,r),l=e.getTypeLength(r),u=[];for(let h=0;h<l;h++){const d=ba[h];d===n[0]?(u.push(a),h+=n.length-1):u.push(c+"."+d)}return`${e.getType(r)}( ${u.join(", ")} )`}}class SP extends pt{static get type(){return"FlipNode"}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{components:t,sourceNode:n}=this,i=this.getNodeType(e),r=n.build(e),o=e.getVarFromNode(this),a=e.getPropertyName(o);e.addLineFlowCode(a+" = "+r,this);const c=e.getTypeLength(i),l=[];let u=0;for(let h=0;h<c;h++){const d=ba[h];d===t[u]?(l.push("1.0 - "+(a+"."+d)),u++):l.push(a+"."+d)}return`${e.getType(i)}( ${l.join(", ")} )`}}class Ym extends Ye{static get type(){return"InputNode"}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return this.nodeType===null?Is(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=Is(this.value),e.nodeType=this.nodeType,e.valueType==="ArrayBuffer"&&(e.value=Wm(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?Hm(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){console.warn("Abstract function.")}}class Wi extends Ym{static get type(){return"ConstNode"}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){const n=this.getNodeType(e);return e.format(this.generateConst(e),n,t)}}let ua=null;const Wo=new Map;function te(s,e){if(Wo.has(s)){console.warn(`Redefinition of method chaining ${s}`);return}if(typeof e!="function")throw new Error(`Node element ${s} is not a function`);Wo.set(s,e)}const Wv=s=>s.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),Jx=s=>Wv(s).split("").sort().join(""),Xv={setup(s,e){const t=e.shift();return s(rl(t),...e)},get(s,e,t){if(typeof e=="string"&&s[e]===void 0){if(s.isStackNode!==!0&&e==="assign")return(...n)=>(ua.assign(t,...n),t);if(Wo.has(e)){const n=Wo.get(e);return s.isStackNode?(...i)=>t.add(n(...i)):(...i)=>n(t,...i)}else{if(e==="self")return s;if(e.endsWith("Assign")&&Wo.has(e.slice(0,e.length-6))){const n=Wo.get(e.slice(0,e.length-6));return s.isStackNode?(...i)=>t.assign(i[0],n(...i)):(...i)=>t.assign(n(t,...i))}else{if(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0)return e=Wv(e),H(new uh(t,e));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=Jx(e.slice(3).toLowerCase()),n=>H(new Hv(s,e,n));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=Jx(e.slice(4).toLowerCase()),()=>H(new SP(H(s),e));if(e==="width"||e==="height"||e==="depth")return e==="width"?e="x":e==="height"?e="y":e==="depth"&&(e="z"),H(new uh(s,e));if(/^\d+$/.test(e)===!0)return H(new mr(t,new Wi(Number(e),"uint")))}}}return Reflect.get(s,e,t)},set(s,e,t,n){return typeof e=="string"&&s[e]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0||e==="width"||e==="height"||e==="depth"||/^\d+$/.test(e)===!0)?(n[e].assign(t),!0):Reflect.set(s,e,t,n)}},Up=new WeakMap,Kx=new WeakMap,TP=function(s,e=null){const t=Is(s);if(t==="node"){let n=Up.get(s);return n===void 0&&(n=new Proxy(s,Xv),Up.set(s,n),Up.set(n,n)),n}else{if(e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string")return H(_f(s,e));if(t==="shader")return U(s)}return s},bP=function(s,e=null){for(const t in s)s[t]=H(s[t],e);return s},wP=function(s,e=null){const t=s.length;for(let n=0;n<t;n++)s[n]=H(s[n],e);return s},AP=function(s,e=null,t=null,n=null){const i=r=>H(n!==null?Object.assign(r,n):r);return e===null?(...r)=>i(new s(...Yr(r))):t!==null?(t=H(t),(...r)=>i(new s(e,...Yr(r),t))):(...r)=>i(new s(e,...Yr(r)))},NP=function(s,...e){return H(new s(...Yr(e)))};class EP extends Ye{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}call(e){const{shaderNode:t,inputNodes:n}=this,i=e.getNodeProperties(t);if(i.onceOutput)return i.onceOutput;let r=null;if(t.layout){let o=Kx.get(e.constructor);o===void 0&&(o=new WeakMap,Kx.set(e.constructor,o));let a=o.get(t);a===void 0&&(a=H(e.buildFunctionNode(t)),o.set(t,a)),e.currentFunctionNode!==null&&e.currentFunctionNode.includes.push(a),r=H(a.call(n))}else{const o=t.jsFunc,a=n!==null?o(n,e):o(e);r=H(a)}return t.once&&(i.onceOutput=r),r}getOutputNode(e){const t=e.getNodeProperties(this);return t.outputNode===null&&(t.outputNode=this.setupOutput(e)),t.outputNode}setup(e){return this.getOutputNode(e)}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}generate(e,t){return this.getOutputNode(e).build(e,t)}}class CP extends Ye{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}call(e=null){return rl(e),H(new EP(this,e))}setup(){return this.call()}}const RP=[!1,!0],IP=[0,1,2,3],PP=[-1,-2],qv=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],Zm=new Map;for(const s of RP)Zm.set(s,new Wi(s));const Jm=new Map;for(const s of IP)Jm.set(s,new Wi(s,"uint"));const Km=new Map([...Jm].map(s=>new Wi(s.value,"int")));for(const s of PP)Km.set(s,new Wi(s,"int"));const Sd=new Map([...Km].map(s=>new Wi(s.value)));for(const s of qv)Sd.set(s,new Wi(s));for(const s of qv)Sd.set(-s,new Wi(-s));const Td={bool:Zm,uint:Jm,ints:Km,float:Sd},jx=new Map([...Zm,...Sd]),_f=(s,e)=>jx.has(s)?jx.get(s):s.isNode===!0?s:new Wi(s,e),LP=s=>{try{return s.getNodeType()}catch{return}},un=function(s,e=null){return(...t)=>{if((t.length===0||!["bool","float","int","uint"].includes(s)&&t.every(i=>typeof i!="object"))&&(t=[Hm(s,...t)]),t.length===1&&e!==null&&e.has(t[0]))return H(e.get(t[0]));if(t.length===1){const i=_f(t[0],s);return LP(i)===s?H(i):H(new $m(i,s))}const n=t.map(i=>_f(i));return H(new Gv(n,s))}},Oc=s=>typeof s=="object"&&s!==null?s.value:s,$v=s=>s!=null?s.nodeType||s.convertTo||(typeof s=="string"?s:null):null;function ec(s,e){return new Proxy(new CP(s,e),Xv)}const H=(s,e=null)=>TP(s,e),rl=(s,e=null)=>new bP(s,e),Yr=(s,e=null)=>new wP(s,e),K=(...s)=>new AP(...s),fe=(...s)=>new NP(...s),U=(s,e)=>{const t=new ec(s,e),n=(...i)=>{let r;return rl(i),i[0]&&i[0].isNode?r=[...i]:r=i[0],t.call(r)};return n.shaderNode=t,n.setLayout=i=>(t.setLayout(i),n),n.once=()=>(t.once=!0,n),n},DP=(...s)=>(console.warn("TSL.ShaderNode: tslFn() has been renamed to Fn()."),U(...s));te("toGlobal",s=>(s.global=!0,s));const Vc=s=>{ua=s},jm=()=>ua,Oe=(...s)=>ua.If(...s);function Yv(s){return ua&&ua.add(s),s}te("append",Yv);const Zv=new un("color"),A=new un("float",Td.float),L=new un("int",Td.ints),ve=new un("uint",Td.uint),cr=new un("bool",Td.bool),z=new un("vec2"),ls=new un("ivec2"),Jv=new un("uvec2"),Kv=new un("bvec2"),D=new un("vec3"),jv=new un("ivec3"),wa=new un("uvec3"),Qm=new un("bvec3"),oe=new un("vec4"),Qv=new un("ivec4"),eM=new un("uvec4"),tM=new un("bvec4"),ol=new un("mat2"),Tn=new un("mat3"),Zr=new un("mat4"),UP=(s="")=>H(new Wi(s,"string")),FP=s=>H(new Wi(s,"ArrayBuffer"));te("toColor",Zv);te("toFloat",A);te("toInt",L);te("toUint",ve);te("toBool",cr);te("toVec2",z);te("toIVec2",ls);te("toUVec2",Jv);te("toBVec2",Kv);te("toVec3",D);te("toIVec3",jv);te("toUVec3",wa);te("toBVec3",Qm);te("toVec4",oe);te("toIVec4",Qv);te("toUVec4",eM);te("toBVec4",tM);te("toMat2",ol);te("toMat3",Tn);te("toMat4",Zr);const nM=K(mr),iM=(s,e)=>H(new $m(H(s),e)),OP=(s,e)=>H(new uh(H(s),e));te("element",nM);te("convert",iM);class eg extends Ye{static get type(){return"UniformGroupNode"}constructor(e,t=!1,n=1){super("string"),this.name=e,this.version=0,this.shared=t,this.order=n,this.isUniformGroup=!0}set needsUpdate(e){e===!0&&this.version++}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const sM=s=>new eg(s),tg=(s,e=0)=>new eg(s,!0,e),VP=tg("frame"),_t=tg("render"),rM=sM("object");class uo extends Ym{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=rM}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){const n=this.getSelf();return e=e.bind(n),super.onUpdate(i=>{const r=e(i,n);r!==void 0&&(this.value=r)},t)}generate(e,t){const n=this.getNodeType(e),i=this.getUniformHash(e);let r=e.getNodeFromHash(i);r===void 0&&(e.setHashNode(this,i),r=this);const o=r.getInputType(e),a=e.getUniformFromNode(r,o,e.shaderStage,this.name||e.context.label),c=e.getPropertyName(a);return e.context.label!==void 0&&delete e.context.label,e.format(c,n,t)}}const pe=(s,e)=>{const t=$v(e||s),n=s&&s.isNode===!0?s.node&&s.node.value||s.value:s;return H(new uo(n,t))};class Nt extends Ye{static get type(){return"PropertyNode"}constructor(e,t=null,n=!1){super(e),this.name=t,this.varying=n,this.isPropertyNode=!0}getHash(e){return this.name||super.getHash(e)}isGlobal(){return!0}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}const ai=(s,e)=>H(new Nt(s,e)),Zi=(s,e)=>H(new Nt(s,e,!0)),Ct=fe(Nt,"vec4","DiffuseColor"),yf=fe(Nt,"vec3","EmissiveColor"),hs=fe(Nt,"float","Roughness"),Bc=fe(Nt,"float","Metalness"),hh=fe(Nt,"float","Clearcoat"),zc=fe(Nt,"float","ClearcoatRoughness"),Xr=fe(Nt,"vec3","Sheen"),bd=fe(Nt,"float","SheenRoughness"),wd=fe(Nt,"float","Iridescence"),ng=fe(Nt,"float","IridescenceIOR"),ig=fe(Nt,"float","IridescenceThickness"),dh=fe(Nt,"float","AlphaT"),Ys=fe(Nt,"float","Anisotropy"),tc=fe(Nt,"vec3","AnisotropyT"),Jr=fe(Nt,"vec3","AnisotropyB"),ri=fe(Nt,"color","SpecularColor"),kc=fe(Nt,"float","SpecularF90"),ph=fe(Nt,"float","Shininess"),sg=fe(Nt,"vec4","Output"),Kr=fe(Nt,"float","dashSize"),Gc=fe(Nt,"float","gapSize"),BP=fe(Nt,"float","pointWidth"),nc=fe(Nt,"float","IOR"),fh=fe(Nt,"float","Transmission"),rg=fe(Nt,"float","Thickness"),og=fe(Nt,"float","AttenuationDistance"),ag=fe(Nt,"color","AttenuationColor"),cg=fe(Nt,"float","Dispersion");class oM extends pt{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t}hasDependencies(){return!1}getNodeType(e,t){return t!=="void"?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(e.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){const n=e.getTypeLength(t.node.getNodeType(e));return ba.join("").slice(0,n)!==t.components}return!1}generate(e,t){const{targetNode:n,sourceNode:i}=this,r=this.needsSplitAssign(e),o=n.getNodeType(e),a=n.context({assign:!0}).build(e),c=i.build(e,o),l=i.getNodeType(e),u=e.getDataFromNode(this);let h;if(u.initialized===!0)t!=="void"&&(h=a);else if(r){const d=e.getVarFromNode(this,null,o),p=e.getPropertyName(d);e.addLineFlowCode(`${p} = ${c}`,this);const f=n.node.context({assign:!0}).build(e);for(let x=0;x<n.components.length;x++){const m=n.components[x];e.addLineFlowCode(`${f}.${m} = ${p}[ ${x} ]`,this)}t!=="void"&&(h=a)}else h=`${a} = ${c}`,(t==="void"||l==="void")&&(e.addLineFlowCode(h,this),t!=="void"&&(h=a));return u.initialized=!0,e.format(h,o,t)}}const aM=K(oM);te("assign",aM);class cM extends pt{static get type(){return"FunctionCallNode"}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}generate(e){const t=[],n=this.functionNode,i=n.getInputs(e),r=this.parameters;if(Array.isArray(r))for(let a=0;a<r.length;a++){const c=i[a],l=r[a];t.push(l.build(e,c.type))}else for(const a of i){const c=r[a.name];if(c!==void 0)t.push(c.build(e,a.type));else throw new Error(`FunctionCallNode: Input '${a.name}' not found in FunctionNode.`)}return`${n.build(e,"property")}( ${t.join(", ")} )`}}const lM=(s,...e)=>(e=e.length>1||e[0]&&e[0].isNode===!0?Yr(e):rl(e[0]),H(new cM(H(s),e)));te("call",lM);class qt extends pt{static get type(){return"OperatorNode"}constructor(e,t,n,...i){if(super(),i.length>0){let r=new qt(e,t,n);for(let o=0;o<i.length-1;o++)r=new qt(e,r,i[o]);t=r,n=i[i.length-1]}this.op=e,this.aNode=t,this.bNode=n}getNodeType(e,t){const n=this.op,i=this.aNode,r=this.bNode,o=i.getNodeType(e),a=typeof r<"u"?r.getNodeType(e):null;if(o==="void"||a==="void")return"void";if(n==="%")return o;if(n==="~"||n==="&"||n==="|"||n==="^"||n===">>"||n==="<<")return e.getIntegerType(o);if(n==="!"||n==="=="||n==="&&"||n==="||"||n==="^^")return"bool";if(n==="<"||n===">"||n==="<="||n===">="){const c=t?e.getTypeLength(t):Math.max(e.getTypeLength(o),e.getTypeLength(a));return c>1?`bvec${c}`:"bool"}else return o==="float"&&e.isMatrix(a)?a:e.isMatrix(o)&&e.isVector(a)?e.getVectorFromMatrix(o):e.isVector(o)&&e.isMatrix(a)?e.getVectorFromMatrix(a):e.getTypeLength(a)>e.getTypeLength(o)?a:o}generate(e,t){const n=this.op,i=this.aNode,r=this.bNode,o=this.getNodeType(e,t);let a=null,c=null;o!=="void"?(a=i.getNodeType(e),c=typeof r<"u"?r.getNodeType(e):null,n==="<"||n===">"||n==="<="||n===">="||n==="=="?e.isVector(a)?c=a:a!==c&&(a=c="float"):n===">>"||n==="<<"?(a=o,c=e.changeComponentType(c,"uint")):e.isMatrix(a)&&e.isVector(c)?c=e.getVectorFromMatrix(a):e.isVector(a)&&e.isMatrix(c)?a=e.getVectorFromMatrix(c):a=c=o):a=c=o;const l=i.build(e,a),u=typeof r<"u"?r.build(e,c):null,h=e.getTypeLength(t),d=e.getFunctionOperator(n);if(t!=="void")return n==="<"&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThan",t)}( ${l}, ${u} )`,o,t):e.format(`( ${l} < ${u} )`,o,t):n==="<="&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThanEqual",t)}( ${l}, ${u} )`,o,t):e.format(`( ${l} <= ${u} )`,o,t):n===">"&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThan",t)}( ${l}, ${u} )`,o,t):e.format(`( ${l} > ${u} )`,o,t):n===">="&&h>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThanEqual",t)}( ${l}, ${u} )`,o,t):e.format(`( ${l} >= ${u} )`,o,t):n==="!"||n==="~"?e.format(`(${n}${l})`,a,t):d?e.format(`${d}( ${l}, ${u} )`,o,t):e.format(`( ${l} ${n} ${u} )`,o,t);if(a!=="void")return d?e.format(`${d}( ${l}, ${u} )`,o,t):e.format(`${l} ${n} ${u}`,o,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const Wt=K(qt,"+"),Ft=K(qt,"-"),ot=K(qt,"*"),ns=K(qt,"/"),lg=K(qt,"%"),uM=K(qt,"=="),hM=K(qt,"!="),dM=K(qt,"<"),ug=K(qt,">"),pM=K(qt,"<="),fM=K(qt,">="),mM=K(qt,"&&"),gM=K(qt,"||"),xM=K(qt,"!"),_M=K(qt,"^^"),yM=K(qt,"&"),vM=K(qt,"~"),MM=K(qt,"|"),SM=K(qt,"^"),TM=K(qt,"<<"),bM=K(qt,">>");te("add",Wt);te("sub",Ft);te("mul",ot);te("div",ns);te("modInt",lg);te("equal",uM);te("notEqual",hM);te("lessThan",dM);te("greaterThan",ug);te("lessThanEqual",pM);te("greaterThanEqual",fM);te("and",mM);te("or",gM);te("not",xM);te("xor",_M);te("bitAnd",yM);te("bitNot",vM);te("bitOr",MM);te("bitXor",SM);te("shiftLeft",TM);te("shiftRight",bM);const wM=(...s)=>(console.warn("TSL.OperatorNode: .remainder() has been renamed to .modInt()."),lg(...s));te("remainder",wM);class V extends pt{static get type(){return"MathNode"}constructor(e,t,n=null,i=null){super(),this.method=e,this.aNode=t,this.bNode=n,this.cNode=i}getInputType(e){const t=this.aNode.getNodeType(e),n=this.bNode?this.bNode.getNodeType(e):null,i=this.cNode?this.cNode.getNodeType(e):null,r=e.isMatrix(t)?0:e.getTypeLength(t),o=e.isMatrix(n)?0:e.getTypeLength(n),a=e.isMatrix(i)?0:e.getTypeLength(i);return r>o&&r>a?t:o>a?n:a>r?i:t}getNodeType(e){const t=this.method;return t===V.LENGTH||t===V.DISTANCE||t===V.DOT?"float":t===V.CROSS?"vec3":t===V.ALL?"bool":t===V.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):t===V.MOD?this.aNode.getNodeType(e):this.getInputType(e)}generate(e,t){const n=this.method,i=this.getNodeType(e),r=this.getInputType(e),o=this.aNode,a=this.bNode,c=this.cNode,l=e.renderer.isWebGLRenderer===!0;if(n===V.TRANSFORM_DIRECTION){let u=o,h=a;e.isMatrix(u.getNodeType(e))?h=oe(D(h),0):u=oe(D(u),0);const d=ot(u,h).xyz;return vi(d).build(e,t)}else{if(n===V.NEGATE)return e.format("( - "+o.build(e,r)+" )",i,t);if(n===V.ONE_MINUS)return Ft(1,o).build(e,t);if(n===V.RECIPROCAL)return ns(1,o).build(e,t);if(n===V.DIFFERENCE)return Dt(Ft(o,a)).build(e,t);{const u=[];return n===V.CROSS||n===V.MOD?u.push(o.build(e,i),a.build(e,i)):l&&n===V.STEP?u.push(o.build(e,e.getTypeLength(o.getNodeType(e))===1?"float":r),a.build(e,r)):l&&(n===V.MIN||n===V.MAX)||n===V.MOD?u.push(o.build(e,r),a.build(e,e.getTypeLength(a.getNodeType(e))===1?"float":r)):n===V.REFRACT?u.push(o.build(e,r),a.build(e,r),c.build(e,"float")):n===V.MIX?u.push(o.build(e,r),a.build(e,r),c.build(e,e.getTypeLength(c.getNodeType(e))===1?"float":r)):(u.push(o.build(e,r)),a!==null&&u.push(a.build(e,r)),c!==null&&u.push(c.build(e,r))),e.format(`${e.getMethod(n,i)}( ${u.join(", ")} )`,i,t)}}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}V.ALL="all";V.ANY="any";V.EQUALS="equals";V.RADIANS="radians";V.DEGREES="degrees";V.EXP="exp";V.EXP2="exp2";V.LOG="log";V.LOG2="log2";V.SQRT="sqrt";V.INVERSE_SQRT="inversesqrt";V.FLOOR="floor";V.CEIL="ceil";V.NORMALIZE="normalize";V.FRACT="fract";V.SIN="sin";V.COS="cos";V.TAN="tan";V.ASIN="asin";V.ACOS="acos";V.ATAN="atan";V.ABS="abs";V.SIGN="sign";V.LENGTH="length";V.NEGATE="negate";V.ONE_MINUS="oneMinus";V.DFDX="dFdx";V.DFDY="dFdy";V.ROUND="round";V.RECIPROCAL="reciprocal";V.TRUNC="trunc";V.FWIDTH="fwidth";V.BITCAST="bitcast";V.TRANSPOSE="transpose";V.ATAN2="atan2";V.MIN="min";V.MAX="max";V.MOD="mod";V.STEP="step";V.REFLECT="reflect";V.DISTANCE="distance";V.DIFFERENCE="difference";V.DOT="dot";V.CROSS="cross";V.POW="pow";V.TRANSFORM_DIRECTION="transformDirection";V.MIX="mix";V.CLAMP="clamp";V.REFRACT="refract";V.SMOOTHSTEP="smoothstep";V.FACEFORWARD="faceforward";const AM=A(1e-6),zP=A(1e6),to=A(Math.PI),kP=A(Math.PI*2),hg=K(V,V.ALL),NM=K(V,V.ANY),EM=K(V,V.EQUALS),CM=K(V,V.RADIANS),RM=K(V,V.DEGREES),dg=K(V,V.EXP),mh=K(V,V.EXP2),pg=K(V,V.LOG),al=K(V,V.LOG2),os=K(V,V.SQRT),IM=K(V,V.INVERSE_SQRT),gr=K(V,V.FLOOR),fg=K(V,V.CEIL),vi=K(V,V.NORMALIZE),xr=K(V,V.FRACT),Cn=K(V,V.SIN),Mi=K(V,V.COS),PM=K(V,V.TAN),LM=K(V,V.ASIN),gh=K(V,V.ACOS),DM=K(V,V.ATAN),Dt=K(V,V.ABS),cl=K(V,V.SIGN),jr=K(V,V.LENGTH),UM=K(V,V.NEGATE),FM=K(V,V.ONE_MINUS),OM=K(V,V.DFDX),VM=K(V,V.DFDY),BM=K(V,V.ROUND),zM=K(V,V.RECIPROCAL),mg=K(V,V.TRUNC),kM=K(V,V.FWIDTH),GP=K(V,V.BITCAST),GM=K(V,V.TRANSPOSE),HM=K(V,V.ATAN2),Mn=K(V,V.MIN),ft=K(V,V.MAX),Ad=K(V,V.MOD),ll=K(V,V.STEP),WM=K(V,V.REFLECT),XM=K(V,V.DISTANCE),qM=K(V,V.DIFFERENCE),$t=K(V,V.DOT),Qo=K(V,V.CROSS),Kn=K(V,V.POW),gg=K(V,V.POW,2),$M=K(V,V.POW,3),YM=K(V,V.POW,4),ZM=K(V,V.TRANSFORM_DIRECTION),JM=s=>ot(cl(s),Kn(Dt(s),1/3)),xg=s=>$t(s,s),it=K(V,V.MIX),cn=(s,e=0,t=1)=>H(new V(V.CLAMP,H(s),H(e),H(t))),KM=s=>cn(s),_g=K(V,V.REFRACT),ti=K(V,V.SMOOTHSTEP),jM=K(V,V.FACEFORWARD),yg=U(([s])=>{const n=43758.5453,i=$t(s.xy,z(12.9898,78.233)),r=Ad(i,to);return xr(Cn(r).mul(n))}),QM=(s,e,t)=>it(e,t,s),eS=(s,e,t)=>ti(e,t,s);te("all",hg);te("any",NM);te("equals",EM);te("radians",CM);te("degrees",RM);te("exp",dg);te("exp2",mh);te("log",pg);te("log2",al);te("sqrt",os);te("inverseSqrt",IM);te("floor",gr);te("ceil",fg);te("normalize",vi);te("fract",xr);te("sin",Cn);te("cos",Mi);te("tan",PM);te("asin",LM);te("acos",gh);te("atan",DM);te("abs",Dt);te("sign",cl);te("length",jr);te("lengthSq",xg);te("negate",UM);te("oneMinus",FM);te("dFdx",OM);te("dFdy",VM);te("round",BM);te("reciprocal",zM);te("trunc",mg);te("fwidth",kM);te("atan2",HM);te("min",Mn);te("max",ft);te("mod",Ad);te("step",ll);te("reflect",WM);te("distance",XM);te("dot",$t);te("cross",Qo);te("pow",Kn);te("pow2",gg);te("pow3",$M);te("pow4",YM);te("transformDirection",ZM);te("mix",QM);te("clamp",cn);te("refract",_g);te("smoothstep",eS);te("faceForward",jM);te("difference",qM);te("saturate",KM);te("cbrt",JM);te("transpose",GM);te("rand",yg);class HP extends Ye{static get type(){return"ConditionalNode"}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}getNodeType(e){const t=this.ifNode.getNodeType(e);if(this.elseNode!==null){const n=this.elseNode.getNodeType(e);if(e.getTypeLength(n)>e.getTypeLength(t))return n}return t}setup(e){const t=this.condNode.cache(),n=this.ifNode.cache(),i=this.elseNode?this.elseNode.cache():null,r=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=r,i!==null&&(e.getDataFromNode(i).parentNodeBlock=r);const o=e.getNodeProperties(this);o.condNode=t,o.ifNode=n.context({nodeBlock:n}),o.elseNode=i?i.context({nodeBlock:i}):null}generate(e,t){const n=this.getNodeType(e),i=e.getDataFromNode(this);if(i.nodeProperty!==void 0)return i.nodeProperty;const{condNode:r,ifNode:o,elseNode:a}=e.getNodeProperties(this),c=t!=="void",l=c?ai(n).build(e):"";i.nodeProperty=l;const u=r.build(e,"bool");e.addFlowCode(`
3848
3848
  ${e.tab}if ( ${u} ) {
3849
3849
 
3850
3850
  `).addFlowTab();let h=o.build(e,n);if(h&&(c?h=l+" = "+h+";":h="return "+h+";"),e.removeFlowTab().addFlowCode(e.tab+" "+h+`
@@ -3857,18 +3857,18 @@ ${e.tab}if ( ${u} ) {
3857
3857
 
3858
3858
  `)}else e.addFlowCode(`
3859
3859
 
3860
- `);return e.format(l,n,t)}}const In=K(HP);te("select",In);const tS=(...s)=>(console.warn("TSL.ConditionalNode: cond() has been renamed to select()."),In(...s));te("cond",tS);class vg extends Ye{static get type(){return"ContextNode"}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){this.node.build(e)}setup(e){const t=e.getContext();e.setContext({...e.context,...this.value});const n=this.node.build(e);return e.setContext(t),n}generate(e,t){const n=e.getContext();e.setContext({...e.context,...this.value});const i=this.node.build(e,t);return e.setContext(n),i}}const Mg=K(vg),nS=(s,e)=>Mg(s,{label:e});te("context",Mg);te("label",nS);class iS extends Ye{static get type(){return"VarNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){const{node:t,name:n}=this,i=e.getVarFromNode(this,n,e.getVectorType(this.getNodeType(e))),r=e.getPropertyName(i),o=t.build(e,i.type);return e.addLineFlowCode(`${r} = ${o}`,this),r}}const Sg=K(iS);te("temp",Sg);te("toVar",(...s)=>Sg(...s).append());class sS extends Ye{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0}isGlobal(){return!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let n=t.varying;if(n===void 0){const i=this.name,r=this.getNodeType(e);t.varying=n=e.getVaryingFromNode(this,i,r),t.node=this.node}return n.needsInterpolation||(n.needsInterpolation=e.shaderStage==="fragment"),n}setup(e){this.setupVarying(e)}analyze(e){return this.setupVarying(e),this.node.analyze(e)}generate(e){const t=e.getNodeProperties(this),n=this.setupVarying(e);if(t.propertyName===void 0){const i=this.getNodeType(e),r=e.getPropertyName(n,mf.VERTEX);e.flowNodeFromShaderStage(mf.VERTEX,this.node,i,r),t.propertyName=r}return e.getPropertyName(n)}}const Un=K(sS);te("varying",Un);const ul="WorkingColorSpace",Tg="OutputColorSpace";function Qx(s){let e=null;return s===li?e="Linear":s===kn&&(e="sRGB"),e}function xh(s,e){return Qx(s)+"To"+Qx(e)}class hl extends pt{static get type(){return"ColorSpaceNode"}constructor(e,t,n){super("vec4"),this.colorNode=e,this.source=t,this.target=n}getColorSpace(e,t){return t===ul?gt.workingColorSpace:t===Tg?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{renderer:t}=e,{colorNode:n}=this,i=this.getColorSpace(e,this.source),r=this.getColorSpace(e,this.target);if(i===r)return n;const o=xh(i,r);let a=null;const c=t.nodes.library.getColorSpaceFunction(o);return c!==null?a=oe(c(n.rgb),n.a):(console.error("ColorSpaceNode: Unsupported Color Space configuration.",o),a=n),a}}const rS=s=>H(new hl(H(s),ul,Tg)),oS=s=>H(new hl(H(s),Tg,ul)),aS=(s,e)=>H(new hl(H(s),ul,e)),bg=(s,e)=>H(new hl(H(s),e,ul));te("toOutputColorSpace",rS);te("toWorkingColorSpace",oS);te("workingToColorSpace",aS);te("colorSpaceToWorking",bg);let WP=class extends fr{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),n=this.referenceNode.getNodeType(),i=this.getNodeType();return e.format(t,n,i)}};class cS extends Ye{static get type(){return"ReferenceBaseNode"}constructor(e,t,n=null,i=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=i,this.properties=e.split("."),this.reference=n,this.node=null,this.group=null,this.updateType=We.OBJECT}setGroup(e){return this.group=e,this}element(e){return H(new WP(this,H(e)))}setNodeType(e){const t=pe(null,e).getSelf();this.group!==null&&t.setGroup(this.group),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let n=e[t[0]];for(let i=1;i<t.length;i++)n=n[t[i]];return n}updateReference(e){return this.reference=this.object!==null?this.object:e.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);const e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}}const XP=(s,e,t)=>H(new cS(s,e,t));class lS extends cS{static get type(){return"RendererReferenceNode"}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup(_t)}updateReference(e){return this.reference=this.renderer!==null?this.renderer:e.renderer,this.reference}}const uS=(s,e,t)=>H(new lS(s,e,t));class hS extends pt{static get type(){return"ToneMappingNode"}constructor(e,t=pS,n=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=n}getCacheKey(){return km(super.getCacheKey(),this.toneMapping)}setup(e){const t=this.colorNode||e.context.color,n=this.toneMapping;if(n===Ti)return t;let i=null;const r=e.renderer.nodes.library.getToneMappingFunction(n);return r!==null?i=oe(r(t.rgb,this.exposureNode),t.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",n),i=t),i}}const dS=(s,e,t)=>H(new hS(s,H(e),H(t))),pS=uS("toneMappingExposure","float");te("toneMapping",(s,e,t)=>dS(e,t,s));class fS extends Ym{static get type(){return"BufferAttributeNode"}constructor(e,t=null,n=0,i=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=i,this.usage=sa,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(this.bufferStride===0&&this.bufferOffset===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;const t=this.getNodeType(e),n=this.value,i=e.getTypeLength(t),r=this.bufferStride||i,o=this.bufferOffset,a=n.isInterleavedBuffer===!0?n:new _a(n,r),c=new Ds(a,i,o);a.setUsage(this.usage),this.attribute=c,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),n=e.getBufferAttributeFromNode(this,t),i=e.getPropertyName(n);let r=null;return e.shaderStage==="vertex"||e.shaderStage==="compute"?(this.name=i,r=i):r=Un(this).build(e,t),r}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}const dl=(s,e,t,n)=>H(new fS(s,e,t,n)),mS=(s,e,t,n)=>dl(s,e,t,n).setUsage(kr),_h=(s,e,t,n)=>dl(s,e,t,n).setInstanced(!0),vf=(s,e,t,n)=>mS(s,e,t,n).setInstanced(!0);te("toAttribute",s=>dl(s.value));class gS extends Ye{static get type(){return"ComputeNode"}constructor(e,t,n=[64]){super("void"),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=n,this.dispatchCount=0,this.version=1,this.updateBeforeType=We.OBJECT,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}updateDispatchCount(){const{count:e,workgroupSize:t}=this;let n=t[0];for(let i=1;i<t.length;i++)n*=t[i];this.dispatchCount=Math.ceil(e/n)}onInit(){}updateBefore({renderer:e}){e.compute(this)}generate(e){const{shaderStage:t}=e;if(t==="compute"){const n=this.computeNode.build(e,"void");n!==""&&e.addLineFlowCode(n,this)}}}const xS=(s,e,t)=>H(new gS(H(s),e,t));te("compute",xS);class _S extends Ye{static get type(){return"CacheNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){return this.node.getNodeType(e)}build(e,...t){const n=e.getCache(),i=e.getCacheFromNode(this,this.parent);e.setCache(i);const r=this.node.build(e,...t);return e.setCache(n),r}}const ic=(s,...e)=>H(new _S(H(s),...e));te("cache",ic);class yS extends Ye{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return t!==""&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}const vS=K(yS);te("bypass",vS);class wg extends Ye{static get type(){return"RemapNode"}constructor(e,t,n,i=A(0),r=A(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=n,this.outLowNode=i,this.outHighNode=r,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:n,outLowNode:i,outHighNode:r,doClamp:o}=this;let a=e.sub(t).div(n.sub(t));return o===!0&&(a=a.clamp()),a.mul(r.sub(i)).add(i)}}const MS=K(wg,null,null,{doClamp:!1}),SS=K(wg);te("remap",MS);te("remapClamp",SS);class TS extends Ye{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const n=this.getNodeType(e),i=this.snippet;if(n==="void")e.addLineFlowCode(i,this);else return e.format(`( ${i} )`,n,t)}}const lr=K(TS),bS=s=>(s?In(s,lr("discard")):lr("discard")).append(),qP=()=>lr("return").append();te("discard",bS);class wS extends pt{static get type(){return"RenderOutputNode"}constructor(e,t,n){super("vec4"),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=n,this.isRenderOutput=!0}setup({context:e}){let t=this.colorNode||e.color;const n=(this.toneMapping!==null?this.toneMapping:e.toneMapping)||Ti,i=(this.outputColorSpace!==null?this.outputColorSpace:e.outputColorSpace)||Li;return n!==Ti&&(t=t.toneMapping(n)),i!==Li&&i!==gt.workingColorSpace&&(t=t.workingToColorSpace(i)),t}}const AS=(s,e=null,t=null)=>H(new wS(H(s),e,t));te("renderOutput",AS);function $P(s){console.warn("THREE.TSLBase: AddNodeElement has been removed in favor of tree-shaking. Trying add",s)}class Ag extends Ye{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(t===null){const n=this.getAttributeName(e);if(e.hasGeometryAttribute(n)){const i=e.geometry.getAttribute(n);t=e.getTypeFromAttribute(i)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),n=this.getNodeType(e);if(e.hasGeometryAttribute(t)===!0){const r=e.geometry.getAttribute(t),o=e.getTypeFromAttribute(r),a=e.getAttribute(t,o);return e.shaderStage==="vertex"?e.format(a.name,o,n):Un(this).build(e,n)}else return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(n)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const vn=(s,e)=>H(new Ag(s,e)),rt=s=>vn("uv"+(s>0?s:""),"vec2");class NS extends Ye{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const n=this.textureNode.build(e,"property"),i=this.levelNode===null?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${n}, ${i} )`,this.getNodeType(e),t)}}const tr=K(NS);class ES extends uo{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=We.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,n=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(n&&n.width!==void 0){const{width:i,height:r}=n;this.value=Math.log2(Math.max(i,r))}}}const CS=K(ES);class gs extends uo{static get type(){return"TextureNode"}constructor(e,t=null,n=null,i=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=n,this.biasNode=i,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=We.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this.setUpdateMatrix(t===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return this.value.isDepthTexture===!0?"float":this.value.type===Bi?"uvec4":this.value.type===ma?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return rt(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=pe(this.value.matrix)),this._matrixUniform.mul(D(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?We.FRAME:We.NONE,this}setupUV(e,t){const n=this.value;return e.isFlipY()&&(n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0||n.isDepthTexture===!0)&&(this.sampler?t=t.flipY():t=t.setY(L(tr(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;let n=this.uvNode;(n===null||e.context.forceUVContext===!0)&&e.context.getUV&&(n=e.context.getUV(this)),n||(n=this.getDefaultUV()),this.updateMatrix===!0&&(n=this.getTransformedUV(n)),n=this.setupUV(e,n);let i=this.levelNode;i===null&&e.context.getTextureLevel&&(i=e.context.getTextureLevel(this)),t.uvNode=n,t.levelNode=i,t.biasNode=this.biasNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.depthNode=this.depthNode}generateUV(e,t){return t.build(e,this.sampler===!0?"vec2":"ivec2")}generateSnippet(e,t,n,i,r,o,a,c){const l=this.value;let u;return i?u=e.generateTextureLevel(l,t,n,i,o):r?u=e.generateTextureBias(l,t,n,r,o):c?u=e.generateTextureGrad(l,t,n,c,o):a?u=e.generateTextureCompare(l,t,n,a,o):this.sampler===!1?u=e.generateTextureLoad(l,t,n,o):u=e.generateTexture(l,t,n,o),u}generate(e,t){const n=e.getNodeProperties(this),i=this.value;if(!i||i.isTexture!==!0)throw new Error("TextureNode: Need a three.js texture.");const r=super.generate(e,"property");if(t==="sampler")return r+"_sampler";if(e.isReference(t))return r;{const o=e.getDataFromNode(this);let a=o.propertyName;if(a===void 0){const{uvNode:u,levelNode:h,biasNode:d,compareNode:p,depthNode:f,gradNode:x}=n,m=this.generateUV(e,u),g=h?h.build(e,"float"):null,y=d?d.build(e,"float"):null,_=f?f.build(e,"int"):null,v=p?p.build(e,"float"):null,I=x?[x[0].build(e,"vec2"),x[1].build(e,"vec2")]:null,T=e.getVarFromNode(this);a=e.getPropertyName(T);const w=this.generateSnippet(e,r,m,g,y,_,v,I);e.addLineFlowCode(`${a} = ${w}`,this),o.snippet=w,o.propertyName=a}let c=a;const l=this.getNodeType(e);return e.needsToWorkingColorSpace(i)&&(c=bg(lr(c,l),i.colorSpace).setup(e).build(e,l)),e.format(c,l,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){const t=this.clone();return t.uvNode=H(e),t.referenceNode=this.getSelf(),H(t)}blur(e){const t=this.clone();return t.biasNode=H(e).mul(CS(t)),t.referenceNode=this.getSelf(),H(t)}level(e){const t=this.clone();return t.levelNode=H(e),t.referenceNode=this.getSelf(),H(t)}size(e){return tr(this,e)}bias(e){const t=this.clone();return t.biasNode=H(e),t.referenceNode=this.getSelf(),H(t)}compare(e){const t=this.clone();return t.compareNode=H(e),t.referenceNode=this.getSelf(),H(t)}grad(e,t){const n=this.clone();return n.gradNode=[H(e),H(t)],n.referenceNode=this.getSelf(),H(n)}depth(e){const t=this.clone();return t.depthNode=H(e),t.referenceNode=this.getSelf(),H(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix()}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e}}const xt=K(gs),Ci=(...s)=>xt(...s).setSampler(!1),YP=s=>(s.isNode===!0?s:xt(s)).convert("sampler"),Vo=pe("float").label("cameraNear").setGroup(_t).onRenderUpdate(({camera:s})=>s.near),Bo=pe("float").label("cameraFar").setGroup(_t).onRenderUpdate(({camera:s})=>s.far),RS=pe("float").label("cameraLogDepth").setGroup(_t).onRenderUpdate(({camera:s})=>2/(Math.log(s.far+1)/Math.LN2)),ci=pe("mat4").label("cameraProjectionMatrix").setGroup(_t).onRenderUpdate(({camera:s})=>s.projectionMatrix),ZP=pe("mat4").label("cameraProjectionMatrixInverse").setGroup(_t).onRenderUpdate(({camera:s})=>s.projectionMatrixInverse),pi=pe("mat4").label("cameraViewMatrix").setGroup(_t).onRenderUpdate(({camera:s})=>s.matrixWorldInverse),JP=pe("mat4").label("cameraWorldMatrix").setGroup(_t).onRenderUpdate(({camera:s})=>s.matrixWorld),KP=pe("mat3").label("cameraNormalMatrix").setGroup(_t).onRenderUpdate(({camera:s})=>s.normalMatrix),Ng=pe(new E).label("cameraPosition").setGroup(_t).onRenderUpdate(({camera:s},e)=>e.value.setFromMatrixPosition(s.matrixWorld));class wt extends Ye{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=We.OBJECT,this._uniformNode=new uo(null)}getNodeType(){const e=this.scope;if(e===wt.WORLD_MATRIX)return"mat4";if(e===wt.POSITION||e===wt.VIEW_POSITION||e===wt.DIRECTION||e===wt.SCALE)return"vec3"}update(e){const t=this.object3d,n=this._uniformNode,i=this.scope;if(i===wt.WORLD_MATRIX)n.value=t.matrixWorld;else if(i===wt.POSITION)n.value=n.value||new E,n.value.setFromMatrixPosition(t.matrixWorld);else if(i===wt.SCALE)n.value=n.value||new E,n.value.setFromMatrixScale(t.matrixWorld);else if(i===wt.DIRECTION)n.value=n.value||new E,t.getWorldDirection(n.value);else if(i===wt.VIEW_POSITION){const r=e.camera;n.value=n.value||new E,n.value.setFromMatrixPosition(t.matrixWorld),n.value.applyMatrix4(r.matrixWorldInverse)}}generate(e){const t=this.scope;return t===wt.WORLD_MATRIX?this._uniformNode.nodeType="mat4":(t===wt.POSITION||t===wt.VIEW_POSITION||t===wt.DIRECTION||t===wt.SCALE)&&(this._uniformNode.nodeType="vec3"),this._uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}wt.WORLD_MATRIX="worldMatrix";wt.POSITION="position";wt.SCALE="scale";wt.VIEW_POSITION="viewPosition";wt.DIRECTION="direction";const jP=K(wt,wt.DIRECTION),QP=K(wt,wt.WORLD_MATRIX),eL=K(wt,wt.POSITION),tL=K(wt,wt.SCALE),nL=K(wt,wt.VIEW_POSITION);class is extends wt{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const iL=fe(is,is.DIRECTION),Ui=fe(is,is.WORLD_MATRIX),sL=fe(is,is.POSITION),rL=fe(is,is.SCALE),oL=fe(is,is.VIEW_POSITION),IS=pe(new Ke).onObjectUpdate(({object:s},e)=>e.value.getNormalMatrix(s.matrixWorld)),PS=pe(new Fe).onObjectUpdate(({object:s},e)=>e.value.copy(s.matrixWorld).invert()),xs=pi.mul(Ui).toVar("modelViewMatrix_2"),aL=U(s=>(s.context.isHighPrecisionModelViewMatrix=!0,pe("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highPrecisionModelViewMatrix"),cL=U(s=>{const e=s.context.isHighPrecisionModelViewMatrix;return pe("mat3").onObjectUpdate(({object:t,camera:n})=>(e!==!0&&t.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix)))}).once()().toVar("highPrecisionModelNormalMatrix"),Nn=vn("position","vec3"),en=Nn.varying("positionLocal"),yh=Nn.varying("positionPrevious"),vh=Ui.mul(en).xyz.varying("v_positionWorld"),Eg=en.transformDirection(Ui).varying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),Pn=xs.mul(en).xyz.varying("v_positionView"),Bt=Pn.negate().varying("v_positionViewDirection").normalize().toVar("positionViewDirection");class LS extends Ye{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){const{renderer:t,material:n}=e;return t.coordinateSystem===Di&&n.side===ln?"false":e.getFrontFacing()}}const DS=fe(LS),pl=A(DS).mul(2).sub(1),Nd=vn("normal","vec3"),hi=U(s=>s.geometry.hasAttribute("normal")===!1?(console.warn('TSL.NormalNode: Vertex attribute "normal" not found on geometry.'),D(0,1,0)):Nd,"vec3").once()().toVar("normalLocal"),US=Pn.dFdx().cross(Pn.dFdy()).normalize().toVar("normalFlat"),di=U(s=>{let e;return s.material.flatShading===!0?e=US:e=Un(Rg(hi),"v_normalView").normalize(),e},"vec3").once()().toVar("normalView"),Ed=Un(di.transformDirection(pi),"v_normalWorld").normalize().toVar("normalWorld"),Yt=U(s=>s.context.setupNormal(),"vec3").once()().mul(pl).toVar("transformedNormalView"),Cg=Yt.transformDirection(pi).toVar("transformedNormalWorld"),Xo=U(s=>s.context.setupClearcoatNormal(),"vec3").once()().mul(pl).toVar("transformedClearcoatNormalView"),FS=U(([s,e=Ui])=>{const t=Tn(e),n=s.div(D(t[0].dot(t[0]),t[1].dot(t[1]),t[2].dot(t[2])));return t.mul(n).xyz}),Rg=U(([s],e)=>{const t=e.renderer.nodes.modelNormalViewMatrix;if(t!==null)return t.transformDirection(s);const n=IS.mul(s);return pi.transformDirection(n)}),OS=pe(0).onReference(({material:s})=>s).onRenderUpdate(({material:s})=>s.refractionRatio),VS=Bt.negate().reflect(Yt),BS=Bt.negate().refract(Yt,OS),zS=VS.transformDirection(pi).toVar("reflectVector"),kS=BS.transformDirection(pi).toVar("reflectVector");class GS extends gs{static get type(){return"CubeTextureNode"}constructor(e,t=null,n=null,i=null){super(e,t,n,i),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===wi?zS:e.mapping===Vi?kS:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),D(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const n=this.value;return e.renderer.coordinateSystem===jr||!n.isRenderTargetTexture?D(t.x.negate(),t.yz):t}generateUV(e,t){return t.build(e,"vec3")}}const Cd=K(GS);class Rd extends uo{static get type(){return"BufferNode"}constructor(e,t,n=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=n}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const fl=(s,e,t)=>H(new Rd(s,e,t));class lL extends fr{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),n=this.getNodeType();return e.format(t,"vec4",n)}}class Ig extends Rd{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null,"vec4"),this.array=e,this.elementType=t,this._elementType=null,this._elementLength=0,this.updateType=We.RENDER,this.isArrayBufferNode=!0}getElementType(){return this.elementType||this._elementType}getElementLength(){return this._elementLength}update(){const{array:e,value:t}=this,n=this.getElementLength(),i=this.getElementType();if(n===1)for(let r=0;r<e.length;r++){const o=r*4;t[o]=e[r]}else if(i==="color")for(let r=0;r<e.length;r++){const o=r*4,a=e[r];t[o]=a.r,t[o+1]=a.g,t[o+2]=a.b||0}else for(let r=0;r<e.length;r++){const o=r*4,a=e[r];t[o]=a.x,t[o+1]=a.y,t[o+2]=a.z||0,t[o+3]=a.w||0}}setup(e){const t=this.array.length;this._elementType=this.elementType===null?Is(this.array[0]):this.elementType,this._elementLength=e.getTypeLength(this._elementType);let n=Float32Array;return this._elementType.charAt(0)==="i"?n=Int32Array:this._elementType.charAt(0)==="u"&&(n=Uint32Array),this.value=new n(t*4),this.bufferCount=t,this.bufferType=e.changeComponentType("vec4",e.getComponentType(this._elementType)),super.setup(e)}element(e){return H(new lL(this,H(e)))}}const ds=(s,e)=>H(new Ig(s,e)),uL=(s,e)=>(console.warn("TSL.UniformArrayNode: uniforms() has been renamed to uniformArray()."),H(new Ig(s,e)));class hL extends fr{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),n=this.referenceNode.getNodeType(),i=this.getNodeType();return e.format(t,n,i)}}class ml extends Ye{static get type(){return"ReferenceNode"}constructor(e,t,n=null,i=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=i,this.properties=e.split("."),this.reference=n,this.node=null,this.group=null,this.name=null,this.updateType=We.OBJECT}element(e){return H(new hL(this,H(e)))}setGroup(e){return this.group=e,this}label(e){return this.name=e,this}setNodeType(e){let t=null;this.count!==null?t=fl(null,e,this.count):Array.isArray(this.getValueFromReference())?t=ds(null,e):e==="texture"?t=xt(null):e==="cubeTexture"?t=Cd(null):t=pe(null,e),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.label(this.name),this.node=t.getSelf()}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let n=e[t[0]];for(let i=1;i<t.length;i++)n=n[t[i]];return n}updateReference(e){return this.reference=this.object!==null?this.object:e.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);const e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}}const dn=(s,e,t)=>H(new ml(s,e,t)),Mf=(s,e,t,n)=>H(new ml(s,e,n,t));class HS extends ml{static get type(){return"MaterialReferenceNode"}constructor(e,t,n=null){super(e,t,n),this.material=n,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material!==null?this.material:e.material,this.reference}}const Ki=(s,e,t)=>H(new HS(s,e,t)),Id=U(s=>(s.geometry.hasAttribute("tangent")===!1&&s.geometry.computeTangents(),vn("tangent","vec4")))(),gl=Id.xyz.toVar("tangentLocal"),xl=xs.mul(oe(gl,0)).xyz.varying("v_tangentView").normalize().toVar("tangentView"),WS=xl.transformDirection(pi).varying("v_tangentWorld").normalize().toVar("tangentWorld"),Pg=xl.toVar("transformedTangentView"),dL=Pg.transformDirection(pi).normalize().toVar("transformedTangentWorld"),_l=s=>s.mul(Id.w).xyz,pL=Un(_l(Nd.cross(Id)),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),fL=Un(_l(hi.cross(gl)),"v_bitangentLocal").normalize().toVar("bitangentLocal"),XS=Un(_l(di.cross(xl)),"v_bitangentView").normalize().toVar("bitangentView"),mL=Un(_l(Ed.cross(WS)),"v_bitangentWorld").normalize().toVar("bitangentWorld"),qS=_l(Yt.cross(Pg)).normalize().toVar("transformedBitangentView"),gL=qS.transformDirection(pi).normalize().toVar("transformedBitangentWorld"),Xr=Tn(xl,XS,di),$S=Bt.mul(Xr),xL=(s,e)=>s.sub($S.mul(e)),YS=(()=>{let s=Zr.cross(Bt);return s=s.cross(Zr).normalize(),s=it(s,Yt,Ys.mul(hs.oneMinus()).oneMinus().pow2().pow2()).normalize(),s})(),_L=U(s=>{const{eye_pos:e,surf_norm:t,mapN:n,uv:i}=s,r=e.dFdx(),o=e.dFdy(),a=i.dFdx(),c=i.dFdy(),l=t,u=o.cross(l),h=l.cross(r),d=u.mul(a.x).add(h.mul(c.x)),p=u.mul(a.y).add(h.mul(c.y)),f=d.dot(d).max(p.dot(p)),x=pl.mul(f.inverseSqrt());return Wt(d.mul(n.x,x),p.mul(n.y,x),l.mul(n.z)).normalize()});class ZS extends pt{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=ms}setup(e){const{normalMapType:t,scaleNode:n}=this;let i=this.node.mul(2).sub(1);n!==null&&(i=D(i.xy.mul(n),i.z));let r=null;return t===Kf?r=Rg(i):t===ms&&(e.hasGeometryAttribute("tangent")===!0?r=Xr.mul(i).normalize():r=_L({eye_pos:Pn,surf_norm:di,mapN:i,uv:rt()})),r}}const Sf=K(ZS),yL=U(({textureNode:s,bumpScale:e})=>{const t=i=>s.cache().context({getUV:r=>i(r.uvNode||rt()),forceUVContext:!0}),n=A(t(i=>i));return z(A(t(i=>i.add(i.dFdx()))).sub(n),A(t(i=>i.add(i.dFdy()))).sub(n)).mul(e)}),vL=U(s=>{const{surf_pos:e,surf_norm:t,dHdxy:n}=s,i=e.dFdx().normalize(),r=e.dFdy().normalize(),o=t,a=r.cross(o),c=o.cross(i),l=i.dot(a).mul(pl),u=l.sign().mul(n.x.mul(a).add(n.y.mul(c)));return l.abs().mul(t).sub(u).normalize()});class JS extends pt{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=this.scaleNode!==null?this.scaleNode:1,t=yL({textureNode:this.textureNode,bumpScale:e});return vL({surf_pos:Pn,surf_norm:di,dHdxy:t})}}const KS=K(JS),e_=new Map;class j extends Ye{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let n=e_.get(e);return n===void 0&&(n=Ki(e,t),e_.set(e,n)),n}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache(e==="map"?"map":e+"Map","texture")}setup(e){const t=e.context.material,n=this.scope;let i=null;if(n===j.COLOR){const r=t.color!==void 0?this.getColor(n):D();t.map&&t.map.isTexture===!0?i=r.mul(this.getTexture("map")):i=r}else if(n===j.OPACITY){const r=this.getFloat(n);t.alphaMap&&t.alphaMap.isTexture===!0?i=r.mul(this.getTexture("alpha")):i=r}else if(n===j.SPECULAR_STRENGTH)t.specularMap&&t.specularMap.isTexture===!0?i=this.getTexture("specular").r:i=A(1);else if(n===j.SPECULAR_INTENSITY){const r=this.getFloat(n);t.specularMap?i=r.mul(this.getTexture(n).a):i=r}else if(n===j.SPECULAR_COLOR){const r=this.getColor(n);t.specularColorMap&&t.specularColorMap.isTexture===!0?i=r.mul(this.getTexture(n).rgb):i=r}else if(n===j.ROUGHNESS){const r=this.getFloat(n);t.roughnessMap&&t.roughnessMap.isTexture===!0?i=r.mul(this.getTexture(n).g):i=r}else if(n===j.METALNESS){const r=this.getFloat(n);t.metalnessMap&&t.metalnessMap.isTexture===!0?i=r.mul(this.getTexture(n).b):i=r}else if(n===j.EMISSIVE){const r=this.getFloat("emissiveIntensity"),o=this.getColor(n).mul(r);t.emissiveMap&&t.emissiveMap.isTexture===!0?i=o.mul(this.getTexture(n)):i=o}else if(n===j.NORMAL)t.normalMap?(i=Sf(this.getTexture("normal"),this.getCache("normalScale","vec2")),i.normalMapType=t.normalMapType):t.bumpMap?i=KS(this.getTexture("bump").r,this.getFloat("bumpScale")):i=di;else if(n===j.CLEARCOAT){const r=this.getFloat(n);t.clearcoatMap&&t.clearcoatMap.isTexture===!0?i=r.mul(this.getTexture(n).r):i=r}else if(n===j.CLEARCOAT_ROUGHNESS){const r=this.getFloat(n);t.clearcoatRoughnessMap&&t.clearcoatRoughnessMap.isTexture===!0?i=r.mul(this.getTexture(n).r):i=r}else if(n===j.CLEARCOAT_NORMAL)t.clearcoatNormalMap?i=Sf(this.getTexture(n),this.getCache(n+"Scale","vec2")):i=di;else if(n===j.SHEEN){const r=this.getColor("sheenColor").mul(this.getFloat("sheen"));t.sheenColorMap&&t.sheenColorMap.isTexture===!0?i=r.mul(this.getTexture("sheenColor").rgb):i=r}else if(n===j.SHEEN_ROUGHNESS){const r=this.getFloat(n);t.sheenRoughnessMap&&t.sheenRoughnessMap.isTexture===!0?i=r.mul(this.getTexture(n).a):i=r,i=i.clamp(.07,1)}else if(n===j.ANISOTROPY)if(t.anisotropyMap&&t.anisotropyMap.isTexture===!0){const r=this.getTexture(n);i=ol(zo.x,zo.y,zo.y.negate(),zo.x).mul(r.rg.mul(2).sub(z(1)).normalize().mul(r.b))}else i=zo;else if(n===j.IRIDESCENCE_THICKNESS){const r=dn("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const o=dn("0","float",t.iridescenceThicknessRange);i=r.sub(o).mul(this.getTexture(n).g).add(o)}else i=r}else if(n===j.TRANSMISSION){const r=this.getFloat(n);t.transmissionMap?i=r.mul(this.getTexture(n).r):i=r}else if(n===j.THICKNESS){const r=this.getFloat(n);t.thicknessMap?i=r.mul(this.getTexture(n).g):i=r}else if(n===j.IOR)i=this.getFloat(n);else if(n===j.LIGHT_MAP)i=this.getTexture(n).rgb.mul(this.getFloat("lightMapIntensity"));else if(n===j.AO_MAP)i=this.getTexture(n).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else{const r=this.getNodeType(e);i=this.getCache(n,r)}return i}}j.ALPHA_TEST="alphaTest";j.COLOR="color";j.OPACITY="opacity";j.SHININESS="shininess";j.SPECULAR="specular";j.SPECULAR_STRENGTH="specularStrength";j.SPECULAR_INTENSITY="specularIntensity";j.SPECULAR_COLOR="specularColor";j.REFLECTIVITY="reflectivity";j.ROUGHNESS="roughness";j.METALNESS="metalness";j.NORMAL="normal";j.CLEARCOAT="clearcoat";j.CLEARCOAT_ROUGHNESS="clearcoatRoughness";j.CLEARCOAT_NORMAL="clearcoatNormal";j.EMISSIVE="emissive";j.ROTATION="rotation";j.SHEEN="sheen";j.SHEEN_ROUGHNESS="sheenRoughness";j.ANISOTROPY="anisotropy";j.IRIDESCENCE="iridescence";j.IRIDESCENCE_IOR="iridescenceIOR";j.IRIDESCENCE_THICKNESS="iridescenceThickness";j.IOR="ior";j.TRANSMISSION="transmission";j.THICKNESS="thickness";j.ATTENUATION_DISTANCE="attenuationDistance";j.ATTENUATION_COLOR="attenuationColor";j.LINE_SCALE="scale";j.LINE_DASH_SIZE="dashSize";j.LINE_GAP_SIZE="gapSize";j.LINE_WIDTH="linewidth";j.LINE_DASH_OFFSET="dashOffset";j.POINT_WIDTH="pointWidth";j.DISPERSION="dispersion";j.LIGHT_MAP="light";j.AO_MAP="ao";const jS=fe(j,j.ALPHA_TEST),ha=fe(j,j.COLOR),QS=fe(j,j.SHININESS),eT=fe(j,j.EMISSIVE),Pd=fe(j,j.OPACITY),tT=fe(j,j.SPECULAR),Tf=fe(j,j.SPECULAR_INTENSITY),nT=fe(j,j.SPECULAR_COLOR),sc=fe(j,j.SPECULAR_STRENGTH),Iu=fe(j,j.REFLECTIVITY),iT=fe(j,j.ROUGHNESS),sT=fe(j,j.METALNESS),rT=fe(j,j.NORMAL).context({getUV:null}),oT=fe(j,j.CLEARCOAT),aT=fe(j,j.CLEARCOAT_ROUGHNESS),cT=fe(j,j.CLEARCOAT_NORMAL).context({getUV:null}),lT=fe(j,j.ROTATION),uT=fe(j,j.SHEEN),hT=fe(j,j.SHEEN_ROUGHNESS),dT=fe(j,j.ANISOTROPY),pT=fe(j,j.IRIDESCENCE),fT=fe(j,j.IRIDESCENCE_IOR),mT=fe(j,j.IRIDESCENCE_THICKNESS),gT=fe(j,j.TRANSMISSION),xT=fe(j,j.THICKNESS),_T=fe(j,j.IOR),yT=fe(j,j.ATTENUATION_DISTANCE),vT=fe(j,j.ATTENUATION_COLOR),Mh=fe(j,j.LINE_SCALE),Lg=fe(j,j.LINE_DASH_SIZE),Dg=fe(j,j.LINE_GAP_SIZE),Pu=fe(j,j.LINE_WIDTH),bf=fe(j,j.LINE_DASH_OFFSET),MT=fe(j,j.POINT_WIDTH),ST=fe(j,j.DISPERSION),Ug=fe(j,j.LIGHT_MAP),TT=fe(j,j.AO_MAP),zo=pe(new J).onReference(function(s){return s.material}).onRenderUpdate(function({material:s}){this.value.set(s.anisotropy*Math.cos(s.anisotropyRotation),s.anisotropy*Math.sin(s.anisotropyRotation))});class bT extends pt{static get type(){return"ModelViewProjectionNode"}constructor(e=null){super("vec4"),this.positionNode=e}setup(e){if(e.shaderStage==="fragment")return Un(e.context.mvp);const t=this.positionNode||en,n=e.renderer.nodes.modelViewMatrix||xs;return ci.mul(n).mul(t)}}const wf=K(bT);class zt extends Ye{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isInstanceIndexNode=!0}generate(e){const t=this.getNodeType(e),n=this.scope;let i;if(n===zt.VERTEX)i=e.getVertexIndex();else if(n===zt.INSTANCE)i=e.getInstanceIndex();else if(n===zt.DRAW)i=e.getDrawIndex();else if(n===zt.INVOCATION_LOCAL)i=e.getInvocationLocalIndex();else if(n===zt.INVOCATION_SUBGROUP)i=e.getInvocationSubgroupIndex();else if(n===zt.SUBGROUP)i=e.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+n);let r;return e.shaderStage==="vertex"||e.shaderStage==="compute"?r=i:r=Un(this).build(e,t),r}}zt.VERTEX="vertex";zt.INSTANCE="instance";zt.SUBGROUP="subgroup";zt.INVOCATION_LOCAL="invocationLocal";zt.INVOCATION_SUBGROUP="invocationSubgroup";zt.DRAW="draw";const wT=fe(zt,zt.VERTEX),yl=fe(zt,zt.INSTANCE),ML=fe(zt,zt.SUBGROUP),SL=fe(zt,zt.INVOCATION_SUBGROUP),TL=fe(zt,zt.INVOCATION_LOCAL),AT=fe(zt,zt.DRAW);class NT extends Ye{static get type(){return"InstanceNode"}constructor(e){super("void"),this.instanceMesh=e,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=We.FRAME,this.buffer=null,this.bufferColor=null}setup(e){let t=this.instanceMatrixNode,n=this.instanceColorNode;const i=this.instanceMesh;if(t===null){const a=i.instanceMatrix;if(i.count<=1e3)t=fl(a.array,"mat4",Math.max(i.count,1)).element(yl);else{const c=new Bm(a.array,16,1);this.buffer=c;const l=a.usage===kr?vf:_h,u=[l(c,"vec4",16,0),l(c,"vec4",16,4),l(c,"vec4",16,8),l(c,"vec4",16,12)];t=Yr(...u)}this.instanceMatrixNode=t}const r=i.instanceColor;if(r&&n===null){const a=new Us(r.array,3),c=r.usage===kr?vf:_h;this.bufferColor=a,n=D(c(a,"vec3",3,0)),this.instanceColorNode=n}const o=t.mul(en).xyz;if(en.assign(o),e.hasGeometryAttribute("normal")){const a=FS(hi,t);hi.assign(a)}this.instanceColorNode!==null&&Zi("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMesh.instanceMatrix.usage!==kr&&this.buffer!=null&&this.instanceMesh.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMesh.instanceMatrix.version),this.instanceMesh.instanceColor&&this.instanceMesh.instanceColor.usage!==kr&&this.bufferColor!=null&&this.instanceMesh.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceMesh.instanceColor.version)}}const ET=K(NT);class CT extends Ye{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){this.batchingIdNode===null&&(e.getDrawIndex()===null?this.batchingIdNode=yl:this.batchingIdNode=AT);const n=U(([f])=>{const x=tr(Ci(this.batchMesh._indirectTexture),0),m=L(f).modInt(L(x)),g=L(f).div(L(x));return Ci(this.batchMesh._indirectTexture,ls(m,g)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(L(this.batchingIdNode)),i=this.batchMesh._matricesTexture,r=tr(Ci(i),0),o=A(n).mul(4).toInt().toVar(),a=o.modInt(r),c=o.div(L(r)),l=Yr(Ci(i,ls(a,c)),Ci(i,ls(a.add(1),c)),Ci(i,ls(a.add(2),c)),Ci(i,ls(a.add(3),c))),u=this.batchMesh._colorsTexture;if(u!==null){const x=U(([m])=>{const g=tr(Ci(u),0).x,y=m,_=y.modInt(g),v=y.div(g);return Ci(u,ls(_,v)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]})(n);Zi("vec3","vBatchColor").assign(x)}const h=Tn(l);en.assign(l.mul(en));const d=hi.div(D(h[0].dot(h[0]),h[1].dot(h[1]),h[2].dot(h[2]))),p=h.mul(d).xyz;hi.assign(p),e.hasGeometryAttribute("tangent")&&gl.mulAssign(h)}}const RT=K(CT),t_=new WeakMap;class Fg extends Ye{static get type(){return"SkinningNode"}constructor(e,t=!1){super("void"),this.skinnedMesh=e,this.useReference=t,this.updateType=We.OBJECT,this.skinIndexNode=vn("skinIndex","uvec4"),this.skinWeightNode=vn("skinWeight","vec4");let n,i,r;t?(n=dn("bindMatrix","mat4"),i=dn("bindMatrixInverse","mat4"),r=Mf("skeleton.boneMatrices","mat4",e.skeleton.bones.length)):(n=pe(e.bindMatrix,"mat4"),i=pe(e.bindMatrixInverse,"mat4"),r=fl(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length)),this.bindMatrixNode=n,this.bindMatrixInverseNode=i,this.boneMatricesNode=r,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=en){const{skinIndexNode:n,skinWeightNode:i,bindMatrixNode:r,bindMatrixInverseNode:o}=this,a=e.element(n.x),c=e.element(n.y),l=e.element(n.z),u=e.element(n.w),h=r.mul(t),d=Wt(a.mul(i.x).mul(h),c.mul(i.y).mul(h),l.mul(i.z).mul(h),u.mul(i.w).mul(h));return o.mul(d).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=hi){const{skinIndexNode:n,skinWeightNode:i,bindMatrixNode:r,bindMatrixInverseNode:o}=this,a=e.element(n.x),c=e.element(n.y),l=e.element(n.z),u=e.element(n.w);let h=Wt(i.x.mul(a),i.y.mul(c),i.z.mul(l),i.w.mul(u));return h=o.mul(h).mul(r),h.transformDirection(t).xyz}getPreviousSkinnedPosition(e){const t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=Mf("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,yh)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")}setup(e){this.needsPreviousBoneMatrices(e)&&yh.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(en.assign(t),e.hasGeometryAttribute("normal")){const n=this.getSkinnedNormal();hi.assign(n),e.hasGeometryAttribute("tangent")&&gl.assign(n)}}generate(e,t){if(t!=="void")return en.build(e,t)}update(e){const n=(this.useReference?e.object:this.skinnedMesh).skeleton;t_.get(n)!==e.frameId&&(t_.set(n,e.frameId),this.previousBoneMatricesNode!==null&&n.previousBoneMatrices.set(n.boneMatrices),n.update())}}const bL=s=>H(new Fg(s)),IT=s=>H(new Fg(s,!0));class PT extends Ye{static get type(){return"LoopNode"}constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){const t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;const n={};for(let r=0,o=this.params.length-1;r<o;r++){const a=this.params[r],c=a.isNode!==!0&&a.name||this.getVarName(r),l=a.isNode!==!0&&a.type||"int";n[c]=lr(c,l)}const i=e.addStack();return t.returnsNode=this.params[this.params.length-1](n,i,e),t.stackNode=i,e.removeStack(),t}getNodeType(e){const{returnsNode:t}=this.getProperties(e);return t?t.getNodeType(e):"void"}setup(e){this.getProperties(e)}generate(e){const t=this.getProperties(e),n=this.params,i=t.stackNode;for(let a=0,c=n.length-1;a<c;a++){const l=n[a];let u=null,h=null,d=null,p=null,f=null,x=null;l.isNode?(p="int",d=this.getVarName(a),u="0",h=l.build(e,p),f="<"):(p=l.type||"int",d=l.name||this.getVarName(a),u=l.start,h=l.end,f=l.condition,x=l.update,typeof u=="number"?u=u.toString():u&&u.isNode&&(u=u.build(e,p)),typeof h=="number"?h=h.toString():h&&h.isNode&&(h=h.build(e,p)),u!==void 0&&h===void 0?(u=u+" - 1",h="0",f=">="):h!==void 0&&u===void 0&&(u="0",f="<"),f===void 0&&(Number(u)>Number(h)?f=">=":f="<"));const m={start:u,end:h},g=m.start,y=m.end;let _="",v="",I="";x||(p==="int"||p==="uint"?f.includes("<")?x="++":x="--":f.includes("<")?x="+= 1.":x="-= 1."),_+=e.getVar(p,d)+" = "+g,v+=d+" "+f+" "+y,I+=d+" "+x;const T=`for ( ${_}; ${v}; ${I} )`;e.addFlowCode((a===0?`
3860
+ `);return e.format(l,n,t)}}const In=K(HP);te("select",In);const tS=(...s)=>(console.warn("TSL.ConditionalNode: cond() has been renamed to select()."),In(...s));te("cond",tS);class vg extends Ye{static get type(){return"ContextNode"}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){this.node.build(e)}setup(e){const t=e.getContext();e.setContext({...e.context,...this.value});const n=this.node.build(e);return e.setContext(t),n}generate(e,t){const n=e.getContext();e.setContext({...e.context,...this.value});const i=this.node.build(e,t);return e.setContext(n),i}}const Mg=K(vg),nS=(s,e)=>Mg(s,{label:e});te("context",Mg);te("label",nS);class iS extends Ye{static get type(){return"VarNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){const{node:t,name:n}=this,i=e.getVarFromNode(this,n,e.getVectorType(this.getNodeType(e))),r=e.getPropertyName(i),o=t.build(e,i.type);return e.addLineFlowCode(`${r} = ${o}`,this),r}}const Sg=K(iS);te("temp",Sg);te("toVar",(...s)=>Sg(...s).append());class sS extends Ye{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0}isGlobal(){return!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let n=t.varying;if(n===void 0){const i=this.name,r=this.getNodeType(e);t.varying=n=e.getVaryingFromNode(this,i,r),t.node=this.node}return n.needsInterpolation||(n.needsInterpolation=e.shaderStage==="fragment"),n}setup(e){this.setupVarying(e)}analyze(e){return this.setupVarying(e),this.node.analyze(e)}generate(e){const t=e.getNodeProperties(this),n=this.setupVarying(e);if(t.propertyName===void 0){const i=this.getNodeType(e),r=e.getPropertyName(n,mf.VERTEX);e.flowNodeFromShaderStage(mf.VERTEX,this.node,i,r),t.propertyName=r}return e.getPropertyName(n)}}const Un=K(sS);te("varying",Un);const ul="WorkingColorSpace",Tg="OutputColorSpace";function Qx(s){let e=null;return s===li?e="Linear":s===kn&&(e="sRGB"),e}function xh(s,e){return Qx(s)+"To"+Qx(e)}class hl extends pt{static get type(){return"ColorSpaceNode"}constructor(e,t,n){super("vec4"),this.colorNode=e,this.source=t,this.target=n}getColorSpace(e,t){return t===ul?gt.workingColorSpace:t===Tg?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{renderer:t}=e,{colorNode:n}=this,i=this.getColorSpace(e,this.source),r=this.getColorSpace(e,this.target);if(i===r)return n;const o=xh(i,r);let a=null;const c=t.nodes.library.getColorSpaceFunction(o);return c!==null?a=oe(c(n.rgb),n.a):(console.error("ColorSpaceNode: Unsupported Color Space configuration.",o),a=n),a}}const rS=s=>H(new hl(H(s),ul,Tg)),oS=s=>H(new hl(H(s),Tg,ul)),aS=(s,e)=>H(new hl(H(s),ul,e)),bg=(s,e)=>H(new hl(H(s),e,ul));te("toOutputColorSpace",rS);te("toWorkingColorSpace",oS);te("workingToColorSpace",aS);te("colorSpaceToWorking",bg);let WP=class extends mr{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),n=this.referenceNode.getNodeType(),i=this.getNodeType();return e.format(t,n,i)}};class cS extends Ye{static get type(){return"ReferenceBaseNode"}constructor(e,t,n=null,i=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=i,this.properties=e.split("."),this.reference=n,this.node=null,this.group=null,this.updateType=We.OBJECT}setGroup(e){return this.group=e,this}element(e){return H(new WP(this,H(e)))}setNodeType(e){const t=pe(null,e).getSelf();this.group!==null&&t.setGroup(this.group),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let n=e[t[0]];for(let i=1;i<t.length;i++)n=n[t[i]];return n}updateReference(e){return this.reference=this.object!==null?this.object:e.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);const e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}}const XP=(s,e,t)=>H(new cS(s,e,t));class lS extends cS{static get type(){return"RendererReferenceNode"}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup(_t)}updateReference(e){return this.reference=this.renderer!==null?this.renderer:e.renderer,this.reference}}const uS=(s,e,t)=>H(new lS(s,e,t));class hS extends pt{static get type(){return"ToneMappingNode"}constructor(e,t=pS,n=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=n}getCacheKey(){return km(super.getCacheKey(),this.toneMapping)}setup(e){const t=this.colorNode||e.context.color,n=this.toneMapping;if(n===Ti)return t;let i=null;const r=e.renderer.nodes.library.getToneMappingFunction(n);return r!==null?i=oe(r(t.rgb,this.exposureNode),t.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",n),i=t),i}}const dS=(s,e,t)=>H(new hS(s,H(e),H(t))),pS=uS("toneMappingExposure","float");te("toneMapping",(s,e,t)=>dS(e,t,s));class fS extends Ym{static get type(){return"BufferAttributeNode"}constructor(e,t=null,n=0,i=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=i,this.usage=sa,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(this.bufferStride===0&&this.bufferOffset===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;const t=this.getNodeType(e),n=this.value,i=e.getTypeLength(t),r=this.bufferStride||i,o=this.bufferOffset,a=n.isInterleavedBuffer===!0?n:new _a(n,r),c=new Ds(a,i,o);a.setUsage(this.usage),this.attribute=c,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),n=e.getBufferAttributeFromNode(this,t),i=e.getPropertyName(n);let r=null;return e.shaderStage==="vertex"||e.shaderStage==="compute"?(this.name=i,r=i):r=Un(this).build(e,t),r}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}const dl=(s,e,t,n)=>H(new fS(s,e,t,n)),mS=(s,e,t,n)=>dl(s,e,t,n).setUsage(Gr),_h=(s,e,t,n)=>dl(s,e,t,n).setInstanced(!0),vf=(s,e,t,n)=>mS(s,e,t,n).setInstanced(!0);te("toAttribute",s=>dl(s.value));class gS extends Ye{static get type(){return"ComputeNode"}constructor(e,t,n=[64]){super("void"),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=n,this.dispatchCount=0,this.version=1,this.updateBeforeType=We.OBJECT,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}updateDispatchCount(){const{count:e,workgroupSize:t}=this;let n=t[0];for(let i=1;i<t.length;i++)n*=t[i];this.dispatchCount=Math.ceil(e/n)}onInit(){}updateBefore({renderer:e}){e.compute(this)}generate(e){const{shaderStage:t}=e;if(t==="compute"){const n=this.computeNode.build(e,"void");n!==""&&e.addLineFlowCode(n,this)}}}const xS=(s,e,t)=>H(new gS(H(s),e,t));te("compute",xS);class _S extends Ye{static get type(){return"CacheNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){return this.node.getNodeType(e)}build(e,...t){const n=e.getCache(),i=e.getCacheFromNode(this,this.parent);e.setCache(i);const r=this.node.build(e,...t);return e.setCache(n),r}}const ic=(s,...e)=>H(new _S(H(s),...e));te("cache",ic);class yS extends Ye{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return t!==""&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}const vS=K(yS);te("bypass",vS);class wg extends Ye{static get type(){return"RemapNode"}constructor(e,t,n,i=A(0),r=A(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=n,this.outLowNode=i,this.outHighNode=r,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:n,outLowNode:i,outHighNode:r,doClamp:o}=this;let a=e.sub(t).div(n.sub(t));return o===!0&&(a=a.clamp()),a.mul(r.sub(i)).add(i)}}const MS=K(wg,null,null,{doClamp:!1}),SS=K(wg);te("remap",MS);te("remapClamp",SS);class TS extends Ye{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const n=this.getNodeType(e),i=this.snippet;if(n==="void")e.addLineFlowCode(i,this);else return e.format(`( ${i} )`,n,t)}}const lr=K(TS),bS=s=>(s?In(s,lr("discard")):lr("discard")).append(),qP=()=>lr("return").append();te("discard",bS);class wS extends pt{static get type(){return"RenderOutputNode"}constructor(e,t,n){super("vec4"),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=n,this.isRenderOutput=!0}setup({context:e}){let t=this.colorNode||e.color;const n=(this.toneMapping!==null?this.toneMapping:e.toneMapping)||Ti,i=(this.outputColorSpace!==null?this.outputColorSpace:e.outputColorSpace)||Li;return n!==Ti&&(t=t.toneMapping(n)),i!==Li&&i!==gt.workingColorSpace&&(t=t.workingToColorSpace(i)),t}}const AS=(s,e=null,t=null)=>H(new wS(H(s),e,t));te("renderOutput",AS);function $P(s){console.warn("THREE.TSLBase: AddNodeElement has been removed in favor of tree-shaking. Trying add",s)}class Ag extends Ye{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(t===null){const n=this.getAttributeName(e);if(e.hasGeometryAttribute(n)){const i=e.geometry.getAttribute(n);t=e.getTypeFromAttribute(i)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),n=this.getNodeType(e);if(e.hasGeometryAttribute(t)===!0){const r=e.geometry.getAttribute(t),o=e.getTypeFromAttribute(r),a=e.getAttribute(t,o);return e.shaderStage==="vertex"?e.format(a.name,o,n):Un(this).build(e,n)}else return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(n)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const vn=(s,e)=>H(new Ag(s,e)),rt=s=>vn("uv"+(s>0?s:""),"vec2");class NS extends Ye{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const n=this.textureNode.build(e,"property"),i=this.levelNode===null?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${n}, ${i} )`,this.getNodeType(e),t)}}const tr=K(NS);class ES extends uo{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=We.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,n=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(n&&n.width!==void 0){const{width:i,height:r}=n;this.value=Math.log2(Math.max(i,r))}}}const CS=K(ES);class gs extends uo{static get type(){return"TextureNode"}constructor(e,t=null,n=null,i=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=n,this.biasNode=i,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=We.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this.setUpdateMatrix(t===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return this.value.isDepthTexture===!0?"float":this.value.type===Bi?"uvec4":this.value.type===ma?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return rt(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=pe(this.value.matrix)),this._matrixUniform.mul(D(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?We.FRAME:We.NONE,this}setupUV(e,t){const n=this.value;return e.isFlipY()&&(n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0||n.isDepthTexture===!0)&&(this.sampler?t=t.flipY():t=t.setY(L(tr(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;let n=this.uvNode;(n===null||e.context.forceUVContext===!0)&&e.context.getUV&&(n=e.context.getUV(this)),n||(n=this.getDefaultUV()),this.updateMatrix===!0&&(n=this.getTransformedUV(n)),n=this.setupUV(e,n);let i=this.levelNode;i===null&&e.context.getTextureLevel&&(i=e.context.getTextureLevel(this)),t.uvNode=n,t.levelNode=i,t.biasNode=this.biasNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.depthNode=this.depthNode}generateUV(e,t){return t.build(e,this.sampler===!0?"vec2":"ivec2")}generateSnippet(e,t,n,i,r,o,a,c){const l=this.value;let u;return i?u=e.generateTextureLevel(l,t,n,i,o):r?u=e.generateTextureBias(l,t,n,r,o):c?u=e.generateTextureGrad(l,t,n,c,o):a?u=e.generateTextureCompare(l,t,n,a,o):this.sampler===!1?u=e.generateTextureLoad(l,t,n,o):u=e.generateTexture(l,t,n,o),u}generate(e,t){const n=e.getNodeProperties(this),i=this.value;if(!i||i.isTexture!==!0)throw new Error("TextureNode: Need a three.js texture.");const r=super.generate(e,"property");if(t==="sampler")return r+"_sampler";if(e.isReference(t))return r;{const o=e.getDataFromNode(this);let a=o.propertyName;if(a===void 0){const{uvNode:u,levelNode:h,biasNode:d,compareNode:p,depthNode:f,gradNode:x}=n,m=this.generateUV(e,u),g=h?h.build(e,"float"):null,y=d?d.build(e,"float"):null,_=f?f.build(e,"int"):null,v=p?p.build(e,"float"):null,I=x?[x[0].build(e,"vec2"),x[1].build(e,"vec2")]:null,T=e.getVarFromNode(this);a=e.getPropertyName(T);const w=this.generateSnippet(e,r,m,g,y,_,v,I);e.addLineFlowCode(`${a} = ${w}`,this),o.snippet=w,o.propertyName=a}let c=a;const l=this.getNodeType(e);return e.needsToWorkingColorSpace(i)&&(c=bg(lr(c,l),i.colorSpace).setup(e).build(e,l)),e.format(c,l,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){const t=this.clone();return t.uvNode=H(e),t.referenceNode=this.getSelf(),H(t)}blur(e){const t=this.clone();return t.biasNode=H(e).mul(CS(t)),t.referenceNode=this.getSelf(),H(t)}level(e){const t=this.clone();return t.levelNode=H(e),t.referenceNode=this.getSelf(),H(t)}size(e){return tr(this,e)}bias(e){const t=this.clone();return t.biasNode=H(e),t.referenceNode=this.getSelf(),H(t)}compare(e){const t=this.clone();return t.compareNode=H(e),t.referenceNode=this.getSelf(),H(t)}grad(e,t){const n=this.clone();return n.gradNode=[H(e),H(t)],n.referenceNode=this.getSelf(),H(n)}depth(e){const t=this.clone();return t.depthNode=H(e),t.referenceNode=this.getSelf(),H(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix()}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e}}const xt=K(gs),Ci=(...s)=>xt(...s).setSampler(!1),YP=s=>(s.isNode===!0?s:xt(s)).convert("sampler"),Vo=pe("float").label("cameraNear").setGroup(_t).onRenderUpdate(({camera:s})=>s.near),Bo=pe("float").label("cameraFar").setGroup(_t).onRenderUpdate(({camera:s})=>s.far),RS=pe("float").label("cameraLogDepth").setGroup(_t).onRenderUpdate(({camera:s})=>2/(Math.log(s.far+1)/Math.LN2)),ci=pe("mat4").label("cameraProjectionMatrix").setGroup(_t).onRenderUpdate(({camera:s})=>s.projectionMatrix),ZP=pe("mat4").label("cameraProjectionMatrixInverse").setGroup(_t).onRenderUpdate(({camera:s})=>s.projectionMatrixInverse),pi=pe("mat4").label("cameraViewMatrix").setGroup(_t).onRenderUpdate(({camera:s})=>s.matrixWorldInverse),JP=pe("mat4").label("cameraWorldMatrix").setGroup(_t).onRenderUpdate(({camera:s})=>s.matrixWorld),KP=pe("mat3").label("cameraNormalMatrix").setGroup(_t).onRenderUpdate(({camera:s})=>s.normalMatrix),Ng=pe(new E).label("cameraPosition").setGroup(_t).onRenderUpdate(({camera:s},e)=>e.value.setFromMatrixPosition(s.matrixWorld));class wt extends Ye{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=We.OBJECT,this._uniformNode=new uo(null)}getNodeType(){const e=this.scope;if(e===wt.WORLD_MATRIX)return"mat4";if(e===wt.POSITION||e===wt.VIEW_POSITION||e===wt.DIRECTION||e===wt.SCALE)return"vec3"}update(e){const t=this.object3d,n=this._uniformNode,i=this.scope;if(i===wt.WORLD_MATRIX)n.value=t.matrixWorld;else if(i===wt.POSITION)n.value=n.value||new E,n.value.setFromMatrixPosition(t.matrixWorld);else if(i===wt.SCALE)n.value=n.value||new E,n.value.setFromMatrixScale(t.matrixWorld);else if(i===wt.DIRECTION)n.value=n.value||new E,t.getWorldDirection(n.value);else if(i===wt.VIEW_POSITION){const r=e.camera;n.value=n.value||new E,n.value.setFromMatrixPosition(t.matrixWorld),n.value.applyMatrix4(r.matrixWorldInverse)}}generate(e){const t=this.scope;return t===wt.WORLD_MATRIX?this._uniformNode.nodeType="mat4":(t===wt.POSITION||t===wt.VIEW_POSITION||t===wt.DIRECTION||t===wt.SCALE)&&(this._uniformNode.nodeType="vec3"),this._uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}wt.WORLD_MATRIX="worldMatrix";wt.POSITION="position";wt.SCALE="scale";wt.VIEW_POSITION="viewPosition";wt.DIRECTION="direction";const jP=K(wt,wt.DIRECTION),QP=K(wt,wt.WORLD_MATRIX),eL=K(wt,wt.POSITION),tL=K(wt,wt.SCALE),nL=K(wt,wt.VIEW_POSITION);class is extends wt{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const iL=fe(is,is.DIRECTION),Ui=fe(is,is.WORLD_MATRIX),sL=fe(is,is.POSITION),rL=fe(is,is.SCALE),oL=fe(is,is.VIEW_POSITION),IS=pe(new Ke).onObjectUpdate(({object:s},e)=>e.value.getNormalMatrix(s.matrixWorld)),PS=pe(new Fe).onObjectUpdate(({object:s},e)=>e.value.copy(s.matrixWorld).invert()),xs=pi.mul(Ui).toVar("modelViewMatrix_2"),aL=U(s=>(s.context.isHighPrecisionModelViewMatrix=!0,pe("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highPrecisionModelViewMatrix"),cL=U(s=>{const e=s.context.isHighPrecisionModelViewMatrix;return pe("mat3").onObjectUpdate(({object:t,camera:n})=>(e!==!0&&t.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix)))}).once()().toVar("highPrecisionModelNormalMatrix"),Nn=vn("position","vec3"),en=Nn.varying("positionLocal"),yh=Nn.varying("positionPrevious"),vh=Ui.mul(en).xyz.varying("v_positionWorld"),Eg=en.transformDirection(Ui).varying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),Pn=xs.mul(en).xyz.varying("v_positionView"),Bt=Pn.negate().varying("v_positionViewDirection").normalize().toVar("positionViewDirection");class LS extends Ye{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){const{renderer:t,material:n}=e;return t.coordinateSystem===Di&&n.side===ln?"false":e.getFrontFacing()}}const DS=fe(LS),pl=A(DS).mul(2).sub(1),Nd=vn("normal","vec3"),hi=U(s=>s.geometry.hasAttribute("normal")===!1?(console.warn('TSL.NormalNode: Vertex attribute "normal" not found on geometry.'),D(0,1,0)):Nd,"vec3").once()().toVar("normalLocal"),US=Pn.dFdx().cross(Pn.dFdy()).normalize().toVar("normalFlat"),di=U(s=>{let e;return s.material.flatShading===!0?e=US:e=Un(Rg(hi),"v_normalView").normalize(),e},"vec3").once()().toVar("normalView"),Ed=Un(di.transformDirection(pi),"v_normalWorld").normalize().toVar("normalWorld"),Yt=U(s=>s.context.setupNormal(),"vec3").once()().mul(pl).toVar("transformedNormalView"),Cg=Yt.transformDirection(pi).toVar("transformedNormalWorld"),Xo=U(s=>s.context.setupClearcoatNormal(),"vec3").once()().mul(pl).toVar("transformedClearcoatNormalView"),FS=U(([s,e=Ui])=>{const t=Tn(e),n=s.div(D(t[0].dot(t[0]),t[1].dot(t[1]),t[2].dot(t[2])));return t.mul(n).xyz}),Rg=U(([s],e)=>{const t=e.renderer.nodes.modelNormalViewMatrix;if(t!==null)return t.transformDirection(s);const n=IS.mul(s);return pi.transformDirection(n)}),OS=pe(0).onReference(({material:s})=>s).onRenderUpdate(({material:s})=>s.refractionRatio),VS=Bt.negate().reflect(Yt),BS=Bt.negate().refract(Yt,OS),zS=VS.transformDirection(pi).toVar("reflectVector"),kS=BS.transformDirection(pi).toVar("reflectVector");class GS extends gs{static get type(){return"CubeTextureNode"}constructor(e,t=null,n=null,i=null){super(e,t,n,i),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===wi?zS:e.mapping===Vi?kS:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),D(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const n=this.value;return e.renderer.coordinateSystem===Qr||!n.isRenderTargetTexture?D(t.x.negate(),t.yz):t}generateUV(e,t){return t.build(e,"vec3")}}const Cd=K(GS);class Rd extends uo{static get type(){return"BufferNode"}constructor(e,t,n=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=n}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const fl=(s,e,t)=>H(new Rd(s,e,t));class lL extends mr{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),n=this.getNodeType();return e.format(t,"vec4",n)}}class Ig extends Rd{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null,"vec4"),this.array=e,this.elementType=t,this._elementType=null,this._elementLength=0,this.updateType=We.RENDER,this.isArrayBufferNode=!0}getElementType(){return this.elementType||this._elementType}getElementLength(){return this._elementLength}update(){const{array:e,value:t}=this,n=this.getElementLength(),i=this.getElementType();if(n===1)for(let r=0;r<e.length;r++){const o=r*4;t[o]=e[r]}else if(i==="color")for(let r=0;r<e.length;r++){const o=r*4,a=e[r];t[o]=a.r,t[o+1]=a.g,t[o+2]=a.b||0}else for(let r=0;r<e.length;r++){const o=r*4,a=e[r];t[o]=a.x,t[o+1]=a.y,t[o+2]=a.z||0,t[o+3]=a.w||0}}setup(e){const t=this.array.length;this._elementType=this.elementType===null?Is(this.array[0]):this.elementType,this._elementLength=e.getTypeLength(this._elementType);let n=Float32Array;return this._elementType.charAt(0)==="i"?n=Int32Array:this._elementType.charAt(0)==="u"&&(n=Uint32Array),this.value=new n(t*4),this.bufferCount=t,this.bufferType=e.changeComponentType("vec4",e.getComponentType(this._elementType)),super.setup(e)}element(e){return H(new lL(this,H(e)))}}const ds=(s,e)=>H(new Ig(s,e)),uL=(s,e)=>(console.warn("TSL.UniformArrayNode: uniforms() has been renamed to uniformArray()."),H(new Ig(s,e)));class hL extends mr{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),n=this.referenceNode.getNodeType(),i=this.getNodeType();return e.format(t,n,i)}}class ml extends Ye{static get type(){return"ReferenceNode"}constructor(e,t,n=null,i=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=i,this.properties=e.split("."),this.reference=n,this.node=null,this.group=null,this.name=null,this.updateType=We.OBJECT}element(e){return H(new hL(this,H(e)))}setGroup(e){return this.group=e,this}label(e){return this.name=e,this}setNodeType(e){let t=null;this.count!==null?t=fl(null,e,this.count):Array.isArray(this.getValueFromReference())?t=ds(null,e):e==="texture"?t=xt(null):e==="cubeTexture"?t=Cd(null):t=pe(null,e),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.label(this.name),this.node=t.getSelf()}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let n=e[t[0]];for(let i=1;i<t.length;i++)n=n[t[i]];return n}updateReference(e){return this.reference=this.object!==null?this.object:e.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);const e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}}const dn=(s,e,t)=>H(new ml(s,e,t)),Mf=(s,e,t,n)=>H(new ml(s,e,n,t));class HS extends ml{static get type(){return"MaterialReferenceNode"}constructor(e,t,n=null){super(e,t,n),this.material=n,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material!==null?this.material:e.material,this.reference}}const Ki=(s,e,t)=>H(new HS(s,e,t)),Id=U(s=>(s.geometry.hasAttribute("tangent")===!1&&s.geometry.computeTangents(),vn("tangent","vec4")))(),gl=Id.xyz.toVar("tangentLocal"),xl=xs.mul(oe(gl,0)).xyz.varying("v_tangentView").normalize().toVar("tangentView"),WS=xl.transformDirection(pi).varying("v_tangentWorld").normalize().toVar("tangentWorld"),Pg=xl.toVar("transformedTangentView"),dL=Pg.transformDirection(pi).normalize().toVar("transformedTangentWorld"),_l=s=>s.mul(Id.w).xyz,pL=Un(_l(Nd.cross(Id)),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),fL=Un(_l(hi.cross(gl)),"v_bitangentLocal").normalize().toVar("bitangentLocal"),XS=Un(_l(di.cross(xl)),"v_bitangentView").normalize().toVar("bitangentView"),mL=Un(_l(Ed.cross(WS)),"v_bitangentWorld").normalize().toVar("bitangentWorld"),qS=_l(Yt.cross(Pg)).normalize().toVar("transformedBitangentView"),gL=qS.transformDirection(pi).normalize().toVar("transformedBitangentWorld"),qr=Tn(xl,XS,di),$S=Bt.mul(qr),xL=(s,e)=>s.sub($S.mul(e)),YS=(()=>{let s=Jr.cross(Bt);return s=s.cross(Jr).normalize(),s=it(s,Yt,Ys.mul(hs.oneMinus()).oneMinus().pow2().pow2()).normalize(),s})(),_L=U(s=>{const{eye_pos:e,surf_norm:t,mapN:n,uv:i}=s,r=e.dFdx(),o=e.dFdy(),a=i.dFdx(),c=i.dFdy(),l=t,u=o.cross(l),h=l.cross(r),d=u.mul(a.x).add(h.mul(c.x)),p=u.mul(a.y).add(h.mul(c.y)),f=d.dot(d).max(p.dot(p)),x=pl.mul(f.inverseSqrt());return Wt(d.mul(n.x,x),p.mul(n.y,x),l.mul(n.z)).normalize()});class ZS extends pt{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=ms}setup(e){const{normalMapType:t,scaleNode:n}=this;let i=this.node.mul(2).sub(1);n!==null&&(i=D(i.xy.mul(n),i.z));let r=null;return t===Kf?r=Rg(i):t===ms&&(e.hasGeometryAttribute("tangent")===!0?r=qr.mul(i).normalize():r=_L({eye_pos:Pn,surf_norm:di,mapN:i,uv:rt()})),r}}const Sf=K(ZS),yL=U(({textureNode:s,bumpScale:e})=>{const t=i=>s.cache().context({getUV:r=>i(r.uvNode||rt()),forceUVContext:!0}),n=A(t(i=>i));return z(A(t(i=>i.add(i.dFdx()))).sub(n),A(t(i=>i.add(i.dFdy()))).sub(n)).mul(e)}),vL=U(s=>{const{surf_pos:e,surf_norm:t,dHdxy:n}=s,i=e.dFdx().normalize(),r=e.dFdy().normalize(),o=t,a=r.cross(o),c=o.cross(i),l=i.dot(a).mul(pl),u=l.sign().mul(n.x.mul(a).add(n.y.mul(c)));return l.abs().mul(t).sub(u).normalize()});class JS extends pt{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=this.scaleNode!==null?this.scaleNode:1,t=yL({textureNode:this.textureNode,bumpScale:e});return vL({surf_pos:Pn,surf_norm:di,dHdxy:t})}}const KS=K(JS),e_=new Map;class j extends Ye{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let n=e_.get(e);return n===void 0&&(n=Ki(e,t),e_.set(e,n)),n}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache(e==="map"?"map":e+"Map","texture")}setup(e){const t=e.context.material,n=this.scope;let i=null;if(n===j.COLOR){const r=t.color!==void 0?this.getColor(n):D();t.map&&t.map.isTexture===!0?i=r.mul(this.getTexture("map")):i=r}else if(n===j.OPACITY){const r=this.getFloat(n);t.alphaMap&&t.alphaMap.isTexture===!0?i=r.mul(this.getTexture("alpha")):i=r}else if(n===j.SPECULAR_STRENGTH)t.specularMap&&t.specularMap.isTexture===!0?i=this.getTexture("specular").r:i=A(1);else if(n===j.SPECULAR_INTENSITY){const r=this.getFloat(n);t.specularMap?i=r.mul(this.getTexture(n).a):i=r}else if(n===j.SPECULAR_COLOR){const r=this.getColor(n);t.specularColorMap&&t.specularColorMap.isTexture===!0?i=r.mul(this.getTexture(n).rgb):i=r}else if(n===j.ROUGHNESS){const r=this.getFloat(n);t.roughnessMap&&t.roughnessMap.isTexture===!0?i=r.mul(this.getTexture(n).g):i=r}else if(n===j.METALNESS){const r=this.getFloat(n);t.metalnessMap&&t.metalnessMap.isTexture===!0?i=r.mul(this.getTexture(n).b):i=r}else if(n===j.EMISSIVE){const r=this.getFloat("emissiveIntensity"),o=this.getColor(n).mul(r);t.emissiveMap&&t.emissiveMap.isTexture===!0?i=o.mul(this.getTexture(n)):i=o}else if(n===j.NORMAL)t.normalMap?(i=Sf(this.getTexture("normal"),this.getCache("normalScale","vec2")),i.normalMapType=t.normalMapType):t.bumpMap?i=KS(this.getTexture("bump").r,this.getFloat("bumpScale")):i=di;else if(n===j.CLEARCOAT){const r=this.getFloat(n);t.clearcoatMap&&t.clearcoatMap.isTexture===!0?i=r.mul(this.getTexture(n).r):i=r}else if(n===j.CLEARCOAT_ROUGHNESS){const r=this.getFloat(n);t.clearcoatRoughnessMap&&t.clearcoatRoughnessMap.isTexture===!0?i=r.mul(this.getTexture(n).r):i=r}else if(n===j.CLEARCOAT_NORMAL)t.clearcoatNormalMap?i=Sf(this.getTexture(n),this.getCache(n+"Scale","vec2")):i=di;else if(n===j.SHEEN){const r=this.getColor("sheenColor").mul(this.getFloat("sheen"));t.sheenColorMap&&t.sheenColorMap.isTexture===!0?i=r.mul(this.getTexture("sheenColor").rgb):i=r}else if(n===j.SHEEN_ROUGHNESS){const r=this.getFloat(n);t.sheenRoughnessMap&&t.sheenRoughnessMap.isTexture===!0?i=r.mul(this.getTexture(n).a):i=r,i=i.clamp(.07,1)}else if(n===j.ANISOTROPY)if(t.anisotropyMap&&t.anisotropyMap.isTexture===!0){const r=this.getTexture(n);i=ol(zo.x,zo.y,zo.y.negate(),zo.x).mul(r.rg.mul(2).sub(z(1)).normalize().mul(r.b))}else i=zo;else if(n===j.IRIDESCENCE_THICKNESS){const r=dn("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const o=dn("0","float",t.iridescenceThicknessRange);i=r.sub(o).mul(this.getTexture(n).g).add(o)}else i=r}else if(n===j.TRANSMISSION){const r=this.getFloat(n);t.transmissionMap?i=r.mul(this.getTexture(n).r):i=r}else if(n===j.THICKNESS){const r=this.getFloat(n);t.thicknessMap?i=r.mul(this.getTexture(n).g):i=r}else if(n===j.IOR)i=this.getFloat(n);else if(n===j.LIGHT_MAP)i=this.getTexture(n).rgb.mul(this.getFloat("lightMapIntensity"));else if(n===j.AO_MAP)i=this.getTexture(n).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else{const r=this.getNodeType(e);i=this.getCache(n,r)}return i}}j.ALPHA_TEST="alphaTest";j.COLOR="color";j.OPACITY="opacity";j.SHININESS="shininess";j.SPECULAR="specular";j.SPECULAR_STRENGTH="specularStrength";j.SPECULAR_INTENSITY="specularIntensity";j.SPECULAR_COLOR="specularColor";j.REFLECTIVITY="reflectivity";j.ROUGHNESS="roughness";j.METALNESS="metalness";j.NORMAL="normal";j.CLEARCOAT="clearcoat";j.CLEARCOAT_ROUGHNESS="clearcoatRoughness";j.CLEARCOAT_NORMAL="clearcoatNormal";j.EMISSIVE="emissive";j.ROTATION="rotation";j.SHEEN="sheen";j.SHEEN_ROUGHNESS="sheenRoughness";j.ANISOTROPY="anisotropy";j.IRIDESCENCE="iridescence";j.IRIDESCENCE_IOR="iridescenceIOR";j.IRIDESCENCE_THICKNESS="iridescenceThickness";j.IOR="ior";j.TRANSMISSION="transmission";j.THICKNESS="thickness";j.ATTENUATION_DISTANCE="attenuationDistance";j.ATTENUATION_COLOR="attenuationColor";j.LINE_SCALE="scale";j.LINE_DASH_SIZE="dashSize";j.LINE_GAP_SIZE="gapSize";j.LINE_WIDTH="linewidth";j.LINE_DASH_OFFSET="dashOffset";j.POINT_WIDTH="pointWidth";j.DISPERSION="dispersion";j.LIGHT_MAP="light";j.AO_MAP="ao";const jS=fe(j,j.ALPHA_TEST),ha=fe(j,j.COLOR),QS=fe(j,j.SHININESS),eT=fe(j,j.EMISSIVE),Pd=fe(j,j.OPACITY),tT=fe(j,j.SPECULAR),Tf=fe(j,j.SPECULAR_INTENSITY),nT=fe(j,j.SPECULAR_COLOR),sc=fe(j,j.SPECULAR_STRENGTH),Iu=fe(j,j.REFLECTIVITY),iT=fe(j,j.ROUGHNESS),sT=fe(j,j.METALNESS),rT=fe(j,j.NORMAL).context({getUV:null}),oT=fe(j,j.CLEARCOAT),aT=fe(j,j.CLEARCOAT_ROUGHNESS),cT=fe(j,j.CLEARCOAT_NORMAL).context({getUV:null}),lT=fe(j,j.ROTATION),uT=fe(j,j.SHEEN),hT=fe(j,j.SHEEN_ROUGHNESS),dT=fe(j,j.ANISOTROPY),pT=fe(j,j.IRIDESCENCE),fT=fe(j,j.IRIDESCENCE_IOR),mT=fe(j,j.IRIDESCENCE_THICKNESS),gT=fe(j,j.TRANSMISSION),xT=fe(j,j.THICKNESS),_T=fe(j,j.IOR),yT=fe(j,j.ATTENUATION_DISTANCE),vT=fe(j,j.ATTENUATION_COLOR),Mh=fe(j,j.LINE_SCALE),Lg=fe(j,j.LINE_DASH_SIZE),Dg=fe(j,j.LINE_GAP_SIZE),Pu=fe(j,j.LINE_WIDTH),bf=fe(j,j.LINE_DASH_OFFSET),MT=fe(j,j.POINT_WIDTH),ST=fe(j,j.DISPERSION),Ug=fe(j,j.LIGHT_MAP),TT=fe(j,j.AO_MAP),zo=pe(new J).onReference(function(s){return s.material}).onRenderUpdate(function({material:s}){this.value.set(s.anisotropy*Math.cos(s.anisotropyRotation),s.anisotropy*Math.sin(s.anisotropyRotation))});class bT extends pt{static get type(){return"ModelViewProjectionNode"}constructor(e=null){super("vec4"),this.positionNode=e}setup(e){if(e.shaderStage==="fragment")return Un(e.context.mvp);const t=this.positionNode||en,n=e.renderer.nodes.modelViewMatrix||xs;return ci.mul(n).mul(t)}}const wf=K(bT);class zt extends Ye{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isInstanceIndexNode=!0}generate(e){const t=this.getNodeType(e),n=this.scope;let i;if(n===zt.VERTEX)i=e.getVertexIndex();else if(n===zt.INSTANCE)i=e.getInstanceIndex();else if(n===zt.DRAW)i=e.getDrawIndex();else if(n===zt.INVOCATION_LOCAL)i=e.getInvocationLocalIndex();else if(n===zt.INVOCATION_SUBGROUP)i=e.getInvocationSubgroupIndex();else if(n===zt.SUBGROUP)i=e.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+n);let r;return e.shaderStage==="vertex"||e.shaderStage==="compute"?r=i:r=Un(this).build(e,t),r}}zt.VERTEX="vertex";zt.INSTANCE="instance";zt.SUBGROUP="subgroup";zt.INVOCATION_LOCAL="invocationLocal";zt.INVOCATION_SUBGROUP="invocationSubgroup";zt.DRAW="draw";const wT=fe(zt,zt.VERTEX),yl=fe(zt,zt.INSTANCE),ML=fe(zt,zt.SUBGROUP),SL=fe(zt,zt.INVOCATION_SUBGROUP),TL=fe(zt,zt.INVOCATION_LOCAL),AT=fe(zt,zt.DRAW);class NT extends Ye{static get type(){return"InstanceNode"}constructor(e){super("void"),this.instanceMesh=e,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=We.FRAME,this.buffer=null,this.bufferColor=null}setup(e){let t=this.instanceMatrixNode,n=this.instanceColorNode;const i=this.instanceMesh;if(t===null){const a=i.instanceMatrix;if(i.count<=1e3)t=fl(a.array,"mat4",Math.max(i.count,1)).element(yl);else{const c=new Bm(a.array,16,1);this.buffer=c;const l=a.usage===Gr?vf:_h,u=[l(c,"vec4",16,0),l(c,"vec4",16,4),l(c,"vec4",16,8),l(c,"vec4",16,12)];t=Zr(...u)}this.instanceMatrixNode=t}const r=i.instanceColor;if(r&&n===null){const a=new Us(r.array,3),c=r.usage===Gr?vf:_h;this.bufferColor=a,n=D(c(a,"vec3",3,0)),this.instanceColorNode=n}const o=t.mul(en).xyz;if(en.assign(o),e.hasGeometryAttribute("normal")){const a=FS(hi,t);hi.assign(a)}this.instanceColorNode!==null&&Zi("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMesh.instanceMatrix.usage!==Gr&&this.buffer!=null&&this.instanceMesh.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMesh.instanceMatrix.version),this.instanceMesh.instanceColor&&this.instanceMesh.instanceColor.usage!==Gr&&this.bufferColor!=null&&this.instanceMesh.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceMesh.instanceColor.version)}}const ET=K(NT);class CT extends Ye{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){this.batchingIdNode===null&&(e.getDrawIndex()===null?this.batchingIdNode=yl:this.batchingIdNode=AT);const n=U(([f])=>{const x=tr(Ci(this.batchMesh._indirectTexture),0),m=L(f).modInt(L(x)),g=L(f).div(L(x));return Ci(this.batchMesh._indirectTexture,ls(m,g)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(L(this.batchingIdNode)),i=this.batchMesh._matricesTexture,r=tr(Ci(i),0),o=A(n).mul(4).toInt().toVar(),a=o.modInt(r),c=o.div(L(r)),l=Zr(Ci(i,ls(a,c)),Ci(i,ls(a.add(1),c)),Ci(i,ls(a.add(2),c)),Ci(i,ls(a.add(3),c))),u=this.batchMesh._colorsTexture;if(u!==null){const x=U(([m])=>{const g=tr(Ci(u),0).x,y=m,_=y.modInt(g),v=y.div(g);return Ci(u,ls(_,v)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]})(n);Zi("vec3","vBatchColor").assign(x)}const h=Tn(l);en.assign(l.mul(en));const d=hi.div(D(h[0].dot(h[0]),h[1].dot(h[1]),h[2].dot(h[2]))),p=h.mul(d).xyz;hi.assign(p),e.hasGeometryAttribute("tangent")&&gl.mulAssign(h)}}const RT=K(CT),t_=new WeakMap;class Fg extends Ye{static get type(){return"SkinningNode"}constructor(e,t=!1){super("void"),this.skinnedMesh=e,this.useReference=t,this.updateType=We.OBJECT,this.skinIndexNode=vn("skinIndex","uvec4"),this.skinWeightNode=vn("skinWeight","vec4");let n,i,r;t?(n=dn("bindMatrix","mat4"),i=dn("bindMatrixInverse","mat4"),r=Mf("skeleton.boneMatrices","mat4",e.skeleton.bones.length)):(n=pe(e.bindMatrix,"mat4"),i=pe(e.bindMatrixInverse,"mat4"),r=fl(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length)),this.bindMatrixNode=n,this.bindMatrixInverseNode=i,this.boneMatricesNode=r,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=en){const{skinIndexNode:n,skinWeightNode:i,bindMatrixNode:r,bindMatrixInverseNode:o}=this,a=e.element(n.x),c=e.element(n.y),l=e.element(n.z),u=e.element(n.w),h=r.mul(t),d=Wt(a.mul(i.x).mul(h),c.mul(i.y).mul(h),l.mul(i.z).mul(h),u.mul(i.w).mul(h));return o.mul(d).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=hi){const{skinIndexNode:n,skinWeightNode:i,bindMatrixNode:r,bindMatrixInverseNode:o}=this,a=e.element(n.x),c=e.element(n.y),l=e.element(n.z),u=e.element(n.w);let h=Wt(i.x.mul(a),i.y.mul(c),i.z.mul(l),i.w.mul(u));return h=o.mul(h).mul(r),h.transformDirection(t).xyz}getPreviousSkinnedPosition(e){const t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=Mf("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,yh)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")}setup(e){this.needsPreviousBoneMatrices(e)&&yh.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(en.assign(t),e.hasGeometryAttribute("normal")){const n=this.getSkinnedNormal();hi.assign(n),e.hasGeometryAttribute("tangent")&&gl.assign(n)}}generate(e,t){if(t!=="void")return en.build(e,t)}update(e){const n=(this.useReference?e.object:this.skinnedMesh).skeleton;t_.get(n)!==e.frameId&&(t_.set(n,e.frameId),this.previousBoneMatricesNode!==null&&n.previousBoneMatrices.set(n.boneMatrices),n.update())}}const bL=s=>H(new Fg(s)),IT=s=>H(new Fg(s,!0));class PT extends Ye{static get type(){return"LoopNode"}constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){const t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;const n={};for(let r=0,o=this.params.length-1;r<o;r++){const a=this.params[r],c=a.isNode!==!0&&a.name||this.getVarName(r),l=a.isNode!==!0&&a.type||"int";n[c]=lr(c,l)}const i=e.addStack();return t.returnsNode=this.params[this.params.length-1](n,i,e),t.stackNode=i,e.removeStack(),t}getNodeType(e){const{returnsNode:t}=this.getProperties(e);return t?t.getNodeType(e):"void"}setup(e){this.getProperties(e)}generate(e){const t=this.getProperties(e),n=this.params,i=t.stackNode;for(let a=0,c=n.length-1;a<c;a++){const l=n[a];let u=null,h=null,d=null,p=null,f=null,x=null;l.isNode?(p="int",d=this.getVarName(a),u="0",h=l.build(e,p),f="<"):(p=l.type||"int",d=l.name||this.getVarName(a),u=l.start,h=l.end,f=l.condition,x=l.update,typeof u=="number"?u=u.toString():u&&u.isNode&&(u=u.build(e,p)),typeof h=="number"?h=h.toString():h&&h.isNode&&(h=h.build(e,p)),u!==void 0&&h===void 0?(u=u+" - 1",h="0",f=">="):h!==void 0&&u===void 0&&(u="0",f="<"),f===void 0&&(Number(u)>Number(h)?f=">=":f="<"));const m={start:u,end:h},g=m.start,y=m.end;let _="",v="",I="";x||(p==="int"||p==="uint"?f.includes("<")?x="++":x="--":f.includes("<")?x="+= 1.":x="-= 1."),_+=e.getVar(p,d)+" = "+g,v+=d+" "+f+" "+y,I+=d+" "+x;const T=`for ( ${_}; ${v}; ${I} )`;e.addFlowCode((a===0?`
3861
3861
  `:"")+e.tab+T+` {
3862
3862
 
3863
3863
  `).addFlowTab()}const r=i.build(e,"void"),o=t.returnsNode?t.returnsNode.build(e):"";e.removeFlowTab().addFlowCode(`
3864
3864
  `+e.tab+r);for(let a=0,c=this.params.length-1;a<c;a++)e.addFlowCode((a===0?"":e.tab)+`}
3865
3865
 
3866
- `).removeFlowTab();return e.addFlowTab(),o}}const mt=(...s)=>H(new PT($r(s,"int"))).append(),wL=()=>lr("continue").append(),Ld=()=>lr("break").append(),AL=(...s)=>(console.warn("TSL.LoopNode: loop() has been renamed to Loop()."),mt(...s)),Fp=new WeakMap,_i=new st,n_=U(({bufferMap:s,influence:e,stride:t,width:n,depth:i,offset:r})=>{const o=L(wT).mul(t).add(r),a=o.div(n),c=o.sub(a.mul(n));return Ci(s,ls(c,a)).depth(i).mul(e)});function NL(s){const e=s.morphAttributes.position!==void 0,t=s.morphAttributes.normal!==void 0,n=s.morphAttributes.color!==void 0,i=s.morphAttributes.position||s.morphAttributes.normal||s.morphAttributes.color,r=i!==void 0?i.length:0;let o=Fp.get(s);if(o===void 0||o.count!==r){let g=function(){x.dispose(),Fp.delete(s),s.removeEventListener("dispose",g)};o!==void 0&&o.texture.dispose();const a=s.morphAttributes.position||[],c=s.morphAttributes.normal||[],l=s.morphAttributes.color||[];let u=0;e===!0&&(u=1),t===!0&&(u=2),n===!0&&(u=3);let h=s.attributes.position.count*u,d=1;const p=4096;h>p&&(d=Math.ceil(h/p),h=p);const f=new Float32Array(h*d*4*r),x=new qc(f,h,d,r);x.type=Gn,x.needsUpdate=!0;const m=u*4;for(let y=0;y<r;y++){const _=a[y],v=c[y],I=l[y],T=h*d*4*y;for(let w=0;w<_.count;w++){const C=w*m;e===!0&&(_i.fromBufferAttribute(_,w),f[T+C+0]=_i.x,f[T+C+1]=_i.y,f[T+C+2]=_i.z,f[T+C+3]=0),t===!0&&(_i.fromBufferAttribute(v,w),f[T+C+4]=_i.x,f[T+C+5]=_i.y,f[T+C+6]=_i.z,f[T+C+7]=0),n===!0&&(_i.fromBufferAttribute(I,w),f[T+C+8]=_i.x,f[T+C+9]=_i.y,f[T+C+10]=_i.z,f[T+C+11]=I.itemSize===4?_i.w:1)}}o={count:r,texture:x,stride:u,size:new J(h,d)},Fp.set(s,o),s.addEventListener("dispose",g)}return o}class LT extends Ye{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=pe(1),this.updateType=We.OBJECT}setup(e){const{geometry:t}=e,n=t.morphAttributes.position!==void 0,i=t.hasAttribute("normal")&&t.morphAttributes.normal!==void 0,r=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,o=r!==void 0?r.length:0,{texture:a,stride:c,size:l}=NL(t);n===!0&&en.mulAssign(this.morphBaseInfluence),i===!0&&hi.mulAssign(this.morphBaseInfluence);const u=L(l.width);mt(o,({i:h})=>{const d=A(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?d.assign(Ci(this.mesh.morphTexture,ls(L(h).add(1),L(yl))).r):d.assign(dn("morphTargetInfluences","float").element(h).toVar()),n===!0&&en.addAssign(n_({bufferMap:a,influence:d,stride:c,width:u,depth:h,offset:L(0)})),i===!0&&hi.addAssign(n_({bufferMap:a,influence:d,stride:c,width:u,depth:h,offset:L(1)}))})}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((t,n)=>t+n,0)}}const DT=K(LT),EL=s=>s.sort((e,t)=>e.id-t.id),CL=(s,e)=>{for(const t of e)if(t.isAnalyticLightNode&&t.light.id===s)return t;return null},Op=new WeakMap;class UT extends Ye{static get type(){return"LightsNode"}constructor(e=[]){super("vec3"),this.totalDiffuseNode=D().toVar("totalDiffuse"),this.totalSpecularNode=D().toVar("totalSpecular"),this.outgoingLightNode=D().toVar("outgoingLight"),this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this.global=!0}getHash(e){if(this._lightNodesHash===null){this._lightNodes===null&&this.setupLightsNode(e);const t=[];for(const n of this._lightNodes)t.push(n.getHash());this._lightNodesHash="lights-"+t.join(",")}return this._lightNodesHash}analyze(e){const t=e.getDataFromNode(this);for(const n of t.nodes)n.build(e)}setupLightsNode(e){const t=[],n=this._lightNodes,i=EL(this._lights),r=e.renderer.nodes.library;for(const o of i)if(o.isNode)t.push(H(o));else{let a=null;if(n!==null&&(a=CL(o.id,n)),a===null){const c=r.getLightNodeClass(o.constructor);if(c===null){console.warn(`LightsNode.setupNodeLights: Light node not found for ${o.constructor.name}`);continue}let l=null;Op.has(o)?l=Op.get(o):(l=new c(o),Op.set(o,l)),t.push(l)}}this._lightNodes=t}setup(e){this._lightNodes===null&&this.setupLightsNode(e);const t=e.context,n=t.lightingModel;let i=this.outgoingLightNode;if(n){const{_lightNodes:r,totalDiffuseNode:o,totalSpecularNode:a}=this;t.outgoingLight=i;const c=e.addStack(),l=e.getDataFromNode(this);l.nodes=c.nodes,n.start(t,c,e);for(const g of r)g.build(e);n.indirect(t,c,e);const{backdrop:u,backdropAlpha:h}=t,{directDiffuse:d,directSpecular:p,indirectDiffuse:f,indirectSpecular:x}=t.reflectedLight;let m=d.add(f);u!==null&&(h!==null?m=D(h.mix(m,u)):m=D(u),t.material.transparent=!0),o.assign(m),a.assign(p.add(x)),i.assign(o.add(a)),n.finish(t,c,e),i=i.bypass(e.removeStack())}return i}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}}const FT=K(UT);class ho extends Ye{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}generate(){console.warn("Abstract function.")}}class OT extends ho{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class VT extends vg{static get type(){return"LightingContextNode"}constructor(e,t=null,n=null,i=null){super(e),this.lightingModel=t,this.backdropNode=n,this.backdropAlphaNode=i,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,n=D().toVar("directDiffuse"),i=D().toVar("directSpecular"),r=D().toVar("indirectDiffuse"),o=D().toVar("indirectSpecular"),a={directDiffuse:n,directSpecular:i,indirectDiffuse:r,indirectSpecular:o};return{radiance:D().toVar("radiance"),irradiance:D().toVar("irradiance"),iblIrradiance:D().toVar("iblIrradiance"),ambientOcclusion:A(1).toVar("ambientOcclusion"),reflectedLight:a,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const BT=K(VT);class zT extends ho{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let Ga,Ha;class sn extends Ye{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===sn.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=We.NONE;return(this.scope===sn.SIZE||this.scope===sn.VIEWPORT)&&(e=We.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===sn.VIEWPORT?t!==null?Ha.copy(t.viewport):(e.getViewport(Ha),Ha.multiplyScalar(e.getPixelRatio())):t!==null?(Ga.width=t.width,Ga.height=t.height):e.getDrawingBufferSize(Ga)}setup(){const e=this.scope;let t=null;return e===sn.SIZE?t=pe(Ga||(Ga=new J)):e===sn.VIEWPORT?t=pe(Ha||(Ha=new st)):t=z(Aa.div(da)),t}generate(e){if(this.scope===sn.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const n=e.getNodeProperties(da).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${n}.y - ${t}.y )`}return t}return super.generate(e)}}sn.COORDINATE="coordinate";sn.VIEWPORT="viewport";sn.SIZE="size";sn.UV="uv";const xr=fe(sn,sn.UV),da=fe(sn,sn.SIZE),Aa=fe(sn,sn.COORDINATE),Ls=fe(sn,sn.VIEWPORT),kT=Ls.zw,GT=Aa.sub(Ls.xy),RL=GT.div(kT),IL=U(()=>(console.warn('TSL.ViewportNode: "viewportResolution" is deprecated. Use "screenSize" instead.'),da),"vec2").once()(),PL=U(()=>(console.warn('TSL.ViewportNode: "viewportTopLeft" is deprecated. Use "screenUV" instead.'),xr),"vec2").once()(),LL=U(()=>(console.warn('TSL.ViewportNode: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.'),xr.flipY()),"vec2").once()(),Wa=new J;class vl extends gs{static get type(){return"ViewportTextureNode"}constructor(e=xr,t=null,n=null){n===null&&(n=new fm,n.minFilter=Jn),super(n,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=We.FRAME}updateBefore(e){const t=e.renderer;t.getDrawingBufferSize(Wa);const n=this.value;(n.image.width!==Wa.width||n.image.height!==Wa.height)&&(n.image.width=Wa.width,n.image.height=Wa.height,n.needsUpdate=!0);const i=n.generateMipmaps;n.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(n),n.generateMipmaps=i}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const DL=K(vl),HT=K(vl,null,null,{generateMipmaps:!0});let Vp=null;class WT extends vl{static get type(){return"ViewportDepthTextureNode"}constructor(e=xr,t=null){Vp===null&&(Vp=new oo),super(e,t,Vp)}}const Og=K(WT);class jn extends Ye{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===jn.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,n=this.valueNode;let i=null;if(t===jn.DEPTH_BASE)n!==null&&(i=qT().assign(n));else if(t===jn.DEPTH)e.isPerspectiveCamera?i=XT(Pn.z,Vo,Bo):i=rc(Pn.z,Vo,Bo);else if(t===jn.LINEAR_DEPTH)if(n!==null)if(e.isPerspectiveCamera){const r=Vg(n,Vo,Bo);i=rc(r,Vo,Bo)}else i=n;else i=rc(Pn.z,Vo,Bo);return i}}jn.DEPTH_BASE="depthBase";jn.DEPTH="depth";jn.LINEAR_DEPTH="linearDepth";const rc=(s,e,t)=>s.add(e).div(e.sub(t)),UL=(s,e,t)=>e.sub(t).mul(s).sub(e),XT=(s,e,t)=>e.add(s).mul(t).div(t.sub(e).mul(s)),Vg=(s,e,t)=>e.mul(t).div(t.sub(e).mul(s).sub(t)),qT=K(jn,jn.DEPTH_BASE),Bg=fe(jn,jn.DEPTH),Sh=K(jn,jn.LINEAR_DEPTH),FL=Sh(Og());Bg.assign=s=>qT(s);class ur extends Ye{static get type(){return"ClippingNode"}constructor(e=ur.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{localClipIntersection:n,localClippingCount:i,globalClippingCount:r}=t,o=r+i,a=n?o-i:o;return this.scope===ur.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(t.planes,o,a):this.setupDefault(t.planes,o,a)}setupAlphaToCoverage(e,t,n){return U(()=>{const i=ds(e),r=ai("float","distanceToPlane"),o=ai("float","distanceToGradient"),a=ai("float","clipOpacity");a.assign(1);let c;if(mt(n,({i:l})=>{c=i.element(l),r.assign(Pn.dot(c.xyz).negate().add(c.w)),o.assign(r.fwidth().div(2)),a.mulAssign(ti(o.negate(),o,r)),a.equal(0).discard()}),n<t){const l=ai("float","unionclipOpacity");l.assign(1),mt({start:n,end:t},({i:u})=>{c=i.element(u),r.assign(Pn.dot(c.xyz).negate().add(c.w)),o.assign(r.fwidth().div(2)),l.mulAssign(ti(o.negate(),o,r).oneMinus())}),a.mulAssign(l.oneMinus())}Ct.a.mulAssign(a),Ct.a.equal(0).discard()})()}setupDefault(e,t,n){return U(()=>{const i=ds(e);let r;if(mt(n,({i:o})=>{r=i.element(o),Pn.dot(r.xyz).greaterThan(r.w).discard()}),n<t){const o=ai("bool","clipped");o.assign(!0),mt({start:n,end:t},({i:a})=>{r=i.element(a),o.assign(Pn.dot(r.xyz).greaterThan(r.w).and(o))}),o.discard()}})()}}ur.ALPHA_TO_COVERAGE="alphaToCoverage";ur.DEFAULT="default";const OL=()=>H(new ur),VL=()=>H(new ur(ur.ALPHA_TO_COVERAGE));class Tt extends mn{static get type(){return"NodeMaterial"}constructor(){super(),this.isNodeMaterial=!0,this.type=this.constructor.type,this.forceSinglePass=!1,this.fog=!0,this.lights=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.positionNode=null,this.depthNode=null,this.shadowNode=null,this.shadowPositionNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null}customProgramCacheKey(){return this.type+Gm(this)}build(e){this.setup(e)}setupObserver(e){return new Bv(e)}setup(e){e.context.setupNormal=()=>this.setupNormal(e),e.addStack(),e.stack.outputNode=this.vertexNode||this.setupPosition(e),e.addFlow("vertex",e.removeStack()),e.addStack();let t;const n=this.setupClipping(e);if(this.depthWrite===!0&&this.setupDepth(e),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);const i=this.setupLighting(e);n!==null&&e.stack.add(n);const r=oe(i,Ct.a).max(0);if(t=this.setupOutput(e,r),sg.assign(t),this.outputNode!==null&&(t=this.outputNode),e.renderer.getRenderTarget()!==null){const a=e.renderer.getMRT(),c=this.mrtNode;a!==null?(t=a,c!==null&&(t=a.merge(c))):c!==null&&(t=c)}}else{let i=this.fragmentNode;i.isOutputStructNode!==!0&&(i=oe(i)),t=this.setupOutput(e,i)}e.stack.outputNode=t,e.addFlow("fragment",e.removeStack()),e.monitor=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;const{globalClippingCount:t,localClippingCount:n}=e.clippingContext;let i=null;if(t||n){const r=e.renderer.samples;this.alphaToCoverage&&r>1?i=VL():e.stack.add(OL())}return i}setupDepth(e){const{renderer:t}=e;let n=this.depthNode;if(n===null){const i="getMRT"in t&&t.getMRT();i&&i.has("depth")?n=i.get("depth"):t.logarithmicDepthBuffer===!0&&(n=wf().w.add(1).log2().mul(RS).mul(.5))}n!==null&&Bg.assign(n).append()}setupPosition(e){const{object:t}=e,n=t.geometry;if(e.addStack(),(n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&DT(t).append(),t.isSkinnedMesh===!0&&IT(t).append(),this.displacementMap){const r=Ki("displacementMap","texture"),o=Ki("displacementScale","float"),a=Ki("displacementBias","float");en.addAssign(hi.normalize().mul(r.x.mul(o).add(a)))}t.isBatchedMesh&&RT(t).append(),t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&ET(t).append(),this.positionNode!==null&&en.assign(this.positionNode);const i=wf();return e.context.vertex=e.removeStack(),e.context.mvp=i,i}setupDiffuseColor({object:e,geometry:t}){let n=this.colorNode?oe(this.colorNode):ha;this.vertexColors===!0&&t.hasAttribute("color")&&(n=oe(n.xyz.mul(vn("color","vec3")),n.a)),e.instanceColor&&(n=Zi("vec3","vInstanceColor").mul(n)),e.isBatchedMesh&&e._colorsTexture&&(n=Zi("vec3","vBatchColor").mul(n)),Ct.assign(n);const i=this.opacityNode?A(this.opacityNode):Pd;if(Ct.a.assign(Ct.a.mul(i)),this.alphaTestNode!==null||this.alphaTest>0){const r=this.alphaTestNode!==null?A(this.alphaTestNode):jS;Ct.a.lessThanEqual(r).discard()}this.transparent===!1&&this.blending===Ps&&this.alphaToCoverage===!1&&Ct.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?D(0):Ct.rgb}setupNormal(){return this.normalNode?D(this.normalNode):rT}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?Ki("envMap","cubeTexture"):Ki("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new zT(Ug)),t}setupLights(e){const t=[],n=this.setupEnvironment(e);n&&n.isLightingNode&&t.push(n);const i=this.setupLightMap(e);if(i&&i.isLightingNode&&t.push(i),this.aoNode!==null||e.material.aoMap){const o=this.aoNode!==null?this.aoNode:TT;t.push(new OT(o))}let r=this.lightsNode||e.lightsNode;return t.length>0&&(r=FT([...r.getLights(),...t])),r}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:n,backdropAlphaNode:i,emissiveNode:r}=this,a=this.lights===!0||this.lightsNode!==null?this.setupLights(e):null;let c=this.setupOutgoingLight(e);if(a&&a.getScope().getLights().length>0){const l=this.setupLightingModel(e);c=BT(a,l,n,i)}else n!==null&&(c=D(i!==null?it(c,n,i):n));return(r&&r.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(yf.assign(D(r||eT)),c=c.add(yf)),c}setupOutput(e,t){if(this.fog===!0){const n=e.fogNode;n&&(t=oe(n.mix(t.rgb,n.colorNode),t.a))}return t}setDefaultValues(e){for(const n in e){const i=e[n];this[n]===void 0&&(this[n]=i,i&&i.clone&&(this[n]=i.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const n in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,n)===void 0&&t[n].get!==void 0&&Object.defineProperty(this.constructor.prototype,n,t[n])}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{},nodes:{}});const n=mn.prototype.toJSON.call(this,e),i=Fc(this);n.inputNodes={};for(const{property:o,childNode:a}of i)n.inputNodes[o]=a.toJSON(e).uuid;function r(o){const a=[];for(const c in o){const l=o[c];delete l.metadata,a.push(l)}return a}if(t){const o=r(e.textures),a=r(e.images),c=r(e.nodes);o.length>0&&(n.textures=o),a.length>0&&(n.images=a),c.length>0&&(n.nodes=c)}return n}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.positionNode=e.positionNode,this.depthNode=e.depthNode,this.shadowNode=e.shadowNode,this.shadowPositionNode=e.shadowPositionNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}}const BL=new ya;class zL extends Tt{static get type(){return"InstancedPointsNodeMaterial"}constructor(e={}){super(),this.lights=!1,this.useAlphaToCoverage=!0,this.useColor=e.vertexColors,this.pointWidth=1,this.pointColorNode=null,this.pointWidthNode=null,this.setDefaultValues(BL),this.setValues(e)}setup(e){this.setupShaders(e),super.setup(e)}setupShaders({renderer:e}){const t=this.alphaToCoverage,n=this.useColor;this.vertexNode=U(()=>{const i=vn("instancePosition").xyz,r=oe(xs.mul(oe(i,1))),o=Ls.z.div(Ls.w),a=ci.mul(r),c=Nn.xy.toVar();return c.mulAssign(this.pointWidthNode?this.pointWidthNode:MT),c.assign(c.div(Ls.z)),c.y.assign(c.y.mul(o)),c.assign(c.mul(a.w)),a.addAssign(oe(c,0,0)),a})(),this.fragmentNode=U(()=>{const i=A(1).toVar(),r=xg(rt().mul(2).sub(1));if(t&&e.samples>1){const a=A(r.fwidth()).toVar();i.assign(ti(a.oneMinus(),a.add(1),r).oneMinus())}else r.greaterThan(1).discard();let o;return this.pointColorNode?o=this.pointColorNode:n?o=vn("instanceColor").mul(ha):o=ha,i.mulAssign(Pd),oe(o,i)})()}get alphaToCoverage(){return this.useAlphaToCoverage}set alphaToCoverage(e){this.useAlphaToCoverage!==e&&(this.useAlphaToCoverage=e,this.needsUpdate=!0)}}const kL=new Fn;class GL extends Tt{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.lights=!1,this.setDefaultValues(kL),this.setValues(e)}}const HL=new fd;class WL extends Tt{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.lights=!1,this.setDefaultValues(HL),this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode,t=this.dashScaleNode?A(this.dashScaleNode):Mh,n=this.dashSizeNode?A(this.dashSizeNode):Lg,i=this.dashSizeNode?A(this.dashGapNode):Dg;Jr.assign(n),Gc.assign(i);const r=Un(vn("lineDistance").mul(t));(e?r.add(e):r).mod(Jr.add(Gc)).greaterThan(Jr).discard()}}const XL=new fd;class qL extends Tt{static get type(){return"Line2NodeMaterial"}constructor(e={}){super(),this.lights=!1,this.setDefaultValues(XL),this.useAlphaToCoverage=!0,this.useColor=e.vertexColors,this.useDash=e.dashed,this.useWorldUnits=!1,this.dashOffset=0,this.lineWidth=1,this.lineColorNode=null,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setup(e){this.setupShaders(e),super.setup(e)}setupShaders({renderer:e}){const t=this.alphaToCoverage,n=this.useColor,i=this.dashed,r=this.worldUnits,o=U(({start:c,end:l})=>{const u=ci.element(2).element(2),p=ci.element(3).element(2).mul(-.5).div(u).sub(c.z).div(l.z.sub(c.z));return oe(it(c.xyz,l.xyz,p),l.w)}).setLayout({name:"trimSegment",type:"vec4",inputs:[{name:"start",type:"vec4"},{name:"end",type:"vec4"}]});this.vertexNode=U(()=>{const c=vn("instanceStart"),l=vn("instanceEnd"),u=oe(xs.mul(oe(c,1))).toVar("start"),h=oe(xs.mul(oe(l,1))).toVar("end");r&&(Zi("vec3","worldStart").assign(u.xyz),Zi("vec3","worldEnd").assign(h.xyz));const d=Ls.z.div(Ls.w),p=ci.element(2).element(3).equal(-1);Oe(p,()=>{Oe(u.z.lessThan(0).and(h.z.greaterThan(0)),()=>{h.assign(o({start:u,end:h}))}).ElseIf(h.z.lessThan(0).and(u.z.greaterThanEqual(0)),()=>{u.assign(o({start:h,end:u}))})});const f=ci.mul(u),x=ci.mul(h),m=f.xyz.div(f.w),g=x.xyz.div(x.w),y=g.xy.sub(m.xy).toVar();y.x.assign(y.x.mul(d)),y.assign(y.normalize());const _=oe().toVar();if(r){const v=h.xyz.sub(u.xyz).normalize(),I=it(u.xyz,h.xyz,.5).normalize(),T=v.cross(I).normalize(),w=v.cross(T),C=Zi("vec4","worldPos");C.assign(Nn.y.lessThan(.5).select(u,h));const F=Pu.mul(.5);C.addAssign(oe(Nn.x.lessThan(0).select(T.mul(F),T.mul(F).negate()),0)),i||(C.addAssign(oe(Nn.y.lessThan(.5).select(v.mul(F).negate(),v.mul(F)),0)),C.addAssign(oe(w.mul(F),0)),Oe(Nn.y.greaterThan(1).or(Nn.y.lessThan(0)),()=>{C.subAssign(oe(w.mul(2).mul(F),0))})),_.assign(ci.mul(C));const M=D().toVar();M.assign(Nn.y.lessThan(.5).select(m,g)),_.z.assign(M.z.mul(_.w))}else{const v=z(y.y,y.x.negate()).toVar("offset");y.x.assign(y.x.div(d)),v.x.assign(v.x.div(d)),v.assign(Nn.x.lessThan(0).select(v.negate(),v)),Oe(Nn.y.lessThan(0),()=>{v.assign(v.sub(y))}).ElseIf(Nn.y.greaterThan(1),()=>{v.assign(v.add(y))}),v.assign(v.mul(Pu)),v.assign(v.div(Ls.w)),_.assign(Nn.y.lessThan(.5).select(f,x)),v.assign(v.mul(_.w)),_.assign(_.add(oe(v,0,0)))}return _})();const a=U(({p1:c,p2:l,p3:u,p4:h})=>{const d=c.sub(u),p=h.sub(u),f=l.sub(c),x=d.dot(p),m=p.dot(f),g=d.dot(f),y=p.dot(p),v=f.dot(f).mul(y).sub(m.mul(m)),T=x.mul(m).sub(g.mul(y)).div(v).clamp(),w=x.add(m.mul(T)).div(y).clamp();return z(T,w)});this.fragmentNode=U(()=>{const c=rt();if(i){const h=this.offsetNode?A(this.offsetNodeNode):bf,d=this.dashScaleNode?A(this.dashScaleNode):Mh,p=this.dashSizeNode?A(this.dashSizeNode):Lg,f=this.dashSizeNode?A(this.dashGapNode):Dg;Jr.assign(p),Gc.assign(f);const x=vn("instanceDistanceStart"),m=vn("instanceDistanceEnd"),g=Nn.y.lessThan(.5).select(d.mul(x),Mh.mul(m)),y=Un(g.add(bf)),_=h?y.add(h):y;c.y.lessThan(-1).or(c.y.greaterThan(1)).discard(),_.mod(Jr.add(Gc)).greaterThan(Jr).discard()}const l=A(1).toVar("alpha");if(r){const h=Zi("vec3","worldStart"),d=Zi("vec3","worldEnd"),p=Zi("vec4","worldPos").xyz.normalize().mul(1e5),f=d.sub(h),x=a({p1:h,p2:d,p3:D(0,0,0),p4:p}),m=h.add(f.mul(x.x)),g=p.mul(x.y),v=m.sub(g).length().div(Pu);if(!i)if(t&&e.samples>1){const I=v.fwidth();l.assign(ti(I.negate().add(.5),I.add(.5),v).oneMinus())}else v.greaterThan(.5).discard()}else if(t&&e.samples>1){const h=c.x,d=c.y.greaterThan(0).select(c.y.sub(1),c.y.add(1)),p=h.mul(h).add(d.mul(d)),f=A(p.fwidth()).toVar("dlen");Oe(c.y.abs().greaterThan(1),()=>{l.assign(ti(f.oneMinus(),f.add(1),p).oneMinus())})}else Oe(c.y.abs().greaterThan(1),()=>{const h=c.x,d=c.y.greaterThan(0).select(c.y.sub(1),c.y.add(1));h.mul(h).add(d.mul(d)).greaterThan(1).discard()});let u;if(this.lineColorNode)u=this.lineColorNode;else if(n){const h=vn("instanceColorStart"),d=vn("instanceColorEnd");u=Nn.y.lessThan(.5).select(h,d).mul(ha)}else u=ha;return oe(u,l)})()}get worldUnits(){return this.useWorldUnits}set worldUnits(e){this.useWorldUnits!==e&&(this.useWorldUnits=e,this.needsUpdate=!0)}get dashed(){return this.useDash}set dashed(e){this.useDash!==e&&(this.useDash=e,this.needsUpdate=!0)}get alphaToCoverage(){return this.useAlphaToCoverage}set alphaToCoverage(e){this.useAlphaToCoverage!==e&&(this.useAlphaToCoverage=e,this.needsUpdate=!0)}}const $T=s=>H(s).mul(.5).add(.5),$L=s=>H(s).mul(2).sub(1),YL=new dd;class ZL extends Tt{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.lights=!1,this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(YL),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?A(this.opacityNode):Pd;Ct.assign(oe($T(Yt),e))}}class YT extends pt{static get type(){return"EquirectUVNode"}constructor(e=Eg){super("vec2"),this.dirNode=e}setup(){const e=this.dirNode,t=e.z.atan2(e.x).mul(1/(Math.PI*2)).add(.5),n=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return z(t,n)}}const zg=K(YT);class ZT extends qh{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){const n=t.minFilter,i=t.generateMipmaps;t.generateMipmaps=!0,this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const r=new _s(5,5,5),o=zg(Eg),a=new Tt;a.colorNode=xt(t,o,0),a.side=ln,a.blending=Fi;const c=new kt(r,a),l=new Jh;l.add(c),t.minFilter===Jn&&(t.minFilter=Ut);const u=new Xh(1,10,this),h=e.getMRT();return e.setMRT(null),u.update(e,l),e.setMRT(h),t.minFilter=n,t.currentGenerateMipmaps=i,c.geometry.dispose(),c.material.dispose(),this}}const oc=new WeakMap;class JL extends pt{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=Cd();const t=new io;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=We.RENDER}updateBefore(e){const{renderer:t,material:n}=e,i=this.envNode;if(i.isTextureNode||i.isMaterialReferenceNode){const r=i.isTextureNode?i.value:n[i.property];if(r&&r.isTexture){const o=r.mapping;if(o===ir||o===sr){if(oc.has(r)){const a=oc.get(r);i_(a,r.mapping),this._cubeTexture=a}else{const a=r.image;if(KL(a)){const c=new ZT(a.height);c.fromEquirectangularTexture(t,r),i_(c.texture,r.mapping),this._cubeTexture=c.texture,oc.set(r,c.texture),r.addEventListener("dispose",JT)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function KL(s){return s==null?!1:s.height>0}function JT(s){const e=s.target;e.removeEventListener("dispose",JT);const t=oc.get(e);t!==void 0&&(oc.delete(e),t.dispose())}function i_(s,e){e===ir?s.mapping=wi:e===sr&&(s.mapping=Vi)}const jL=K(JL);class Dd extends ho{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=jL(this.envNode)}}class QL extends ho{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=A(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class Ml{start(){}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class KT extends Ml{constructor(){super()}indirect(e,t,n){const i=e.ambientOcclusion,r=e.reflectedLight,o=n.context.irradianceLightMap;r.indirectDiffuse.assign(oe(0)),o?r.indirectDiffuse.addAssign(o):r.indirectDiffuse.addAssign(oe(1,1,1,0)),r.indirectDiffuse.mulAssign(i),r.indirectDiffuse.mulAssign(Ct.rgb)}finish(e,t,n){const i=n.material,r=e.outgoingLight,o=n.context.environment;if(o)switch(i.combine){case fa:r.rgb.assign(it(r.rgb,r.rgb.mul(o.rgb),sc.mul(Iu)));break;case Of:r.rgb.assign(it(r.rgb,o.rgb,sc.mul(Iu)));break;case Vf:r.rgb.addAssign(o.rgb.mul(sc.mul(Iu)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",i.combine);break}}}const e2=new ss;class t2 extends Tt{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(e2),this.setValues(e)}setupNormal(){return di}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new Dd(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new QL(Ug)),t}setupOutgoingLight(){return Ct.rgb}setupLightingModel(){return new KT}}const pa=U(({f0:s,f90:e,dotVH:t})=>{const n=t.mul(-5.55473).sub(6.98316).mul(t).exp2();return s.mul(n.oneMinus()).add(e.mul(n))}),to=U(s=>s.diffuseColor.mul(1/Math.PI)),n2=()=>A(.25),i2=U(({dotNH:s})=>ph.mul(A(.5)).add(1).mul(A(1/Math.PI)).mul(s.pow(ph))),s2=U(({lightDirection:s})=>{const e=s.add(Bt).normalize(),t=Yt.dot(e).clamp(),n=Bt.dot(e).clamp(),i=pa({f0:ri,f90:1,dotVH:n}),r=n2(),o=i2({dotNH:t});return i.mul(r).mul(o)});class kg extends KT{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:n}){const r=Yt.dot(e).clamp().mul(t);n.directDiffuse.addAssign(r.mul(to({diffuseColor:Ct.rgb}))),this.specular===!0&&n.directSpecular.addAssign(r.mul(s2({lightDirection:e})).mul(sc))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:n}){n.indirectDiffuse.addAssign(t.mul(to({diffuseColor:Ct}))),n.indirectDiffuse.mulAssign(e)}}const r2=new pd;class o2 extends Tt{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(r2),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new Dd(t):null}setupLightingModel(){return new kg(!1)}}const a2=new hd;class c2 extends Tt{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(a2),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new Dd(t):null}setupLightingModel(){return new kg}setupVariants(){const e=(this.shininessNode?A(this.shininessNode):QS).max(1e-4);ph.assign(e);const t=this.specularNode||tT;ri.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const jT=U(()=>{const s=di.dFdx().abs().max(di.dFdy().abs());return s.x.max(s.y).max(s.z)}),Gg=U(s=>{const{roughness:e}=s,t=jT();let n=e.max(.0525);return n=n.add(t),n=n.min(1),n}),QT=U(({alpha:s,dotNL:e,dotNV:t})=>{const n=s.pow2(),i=e.mul(n.add(n.oneMinus().mul(t.pow2())).sqrt()),r=t.mul(n.add(n.oneMinus().mul(e.pow2())).sqrt());return ns(.5,i.add(r).max(AM))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),l2=U(({alphaT:s,alphaB:e,dotTV:t,dotBV:n,dotTL:i,dotBL:r,dotNV:o,dotNL:a})=>{const c=a.mul(D(s.mul(t),e.mul(n),o).length()),l=o.mul(D(s.mul(i),e.mul(r),a).length());return ns(.5,c.add(l)).saturate()}).setLayout({name:"V_GGX_SmithCorrelated_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotTV",type:"float",qualifier:"in"},{name:"dotBV",type:"float",qualifier:"in"},{name:"dotTL",type:"float",qualifier:"in"},{name:"dotBL",type:"float",qualifier:"in"},{name:"dotNV",type:"float",qualifier:"in"},{name:"dotNL",type:"float",qualifier:"in"}]}),eb=U(({alpha:s,dotNH:e})=>{const t=s.pow2(),n=e.pow2().mul(t.oneMinus()).oneMinus();return t.div(n.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),u2=A(1/Math.PI),h2=U(({alphaT:s,alphaB:e,dotNH:t,dotTH:n,dotBH:i})=>{const r=s.mul(e),o=D(e.mul(n),s.mul(i),r.mul(t)),a=o.dot(o),c=r.div(a);return u2.mul(r.mul(c.pow2()))}).setLayout({name:"D_GGX_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotNH",type:"float",qualifier:"in"},{name:"dotTH",type:"float",qualifier:"in"},{name:"dotBH",type:"float",qualifier:"in"}]}),Af=U(s=>{const{lightDirection:e,f0:t,f90:n,roughness:i,f:r,USE_IRIDESCENCE:o,USE_ANISOTROPY:a}=s,c=s.normalView||Yt,l=i.pow2(),u=e.add(Bt).normalize(),h=c.dot(e).clamp(),d=c.dot(Bt).clamp(),p=c.dot(u).clamp(),f=Bt.dot(u).clamp();let x=pa({f0:t,f90:n,dotVH:f}),m,g;if(Oc(o)&&(x=wd.mix(x,r)),Oc(a)){const y=tc.dot(e),_=tc.dot(Bt),v=tc.dot(u),I=Zr.dot(e),T=Zr.dot(Bt),w=Zr.dot(u);m=l2({alphaT:dh,alphaB:l,dotTV:_,dotBV:T,dotTL:y,dotBL:I,dotNV:d,dotNL:h}),g=h2({alphaT:dh,alphaB:l,dotNH:p,dotTH:v,dotBH:w})}else m=QT({alpha:l,dotNL:h,dotNV:d}),g=eb({alpha:l,dotNH:p});return x.mul(m).mul(g)}),Hg=U(({roughness:s,dotNV:e})=>{const t=oe(-1,-.0275,-.572,.022),n=oe(1,.0425,1.04,-.04),i=s.mul(t).add(n),r=i.x.mul(i.x).min(e.mul(-9.28).exp2()).mul(i.x).add(i.y);return z(-1.04,1.04).mul(r).add(i.zw)}).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),tb=U(s=>{const{dotNV:e,specularColor:t,specularF90:n,roughness:i}=s,r=Hg({dotNV:e,roughness:i});return t.mul(r.x).add(n.mul(r.y))}),nb=U(({f:s,f90:e,dotVH:t})=>{const n=t.oneMinus().saturate(),i=n.mul(n),r=n.mul(i,i).clamp(0,.9999);return s.sub(D(e).mul(r)).div(r.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),d2=U(({roughness:s,dotNH:e})=>{const t=s.pow2(),n=A(1).div(t),r=e.pow2().oneMinus().max(.0078125);return A(2).add(n).mul(r.pow(n.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),p2=U(({dotNV:s,dotNL:e})=>A(1).div(A(4).mul(e.add(s).sub(e.mul(s))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),f2=U(({lightDirection:s})=>{const e=s.add(Bt).normalize(),t=Yt.dot(s).clamp(),n=Yt.dot(Bt).clamp(),i=Yt.dot(e).clamp(),r=d2({roughness:bd,dotNH:i}),o=p2({dotNV:n,dotNL:t});return Wr.mul(r).mul(o)}),m2=U(({N:s,V:e,roughness:t})=>{const r=.0078125,o=s.dot(e).saturate(),a=z(t,o.oneMinus().sqrt());return a.assign(a.mul(.984375).add(r)),a}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),g2=U(({f:s})=>{const e=s.length();return ft(e.mul(e).add(s.z).div(e.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),gu=U(({v1:s,v2:e})=>{const t=s.dot(e),n=t.abs().toVar(),i=n.mul(.0145206).add(.4965155).mul(n).add(.8543985).toVar(),r=n.add(4.1616724).mul(n).add(3.417594).toVar(),o=i.div(r),a=t.greaterThan(0).select(o,ft(t.mul(t).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(o));return s.cross(e).mul(a)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),s_=U(({N:s,V:e,P:t,mInv:n,p0:i,p1:r,p2:o,p3:a})=>{const c=r.sub(i).toVar(),l=a.sub(i).toVar(),u=c.cross(l),h=D().toVar();return Oe(u.dot(t.sub(i)).greaterThanEqual(0),()=>{const d=e.sub(s.mul(e.dot(s))).normalize(),p=s.cross(d).negate(),f=n.mul(Tn(d,p,s).transpose()).toVar(),x=f.mul(i.sub(t)).normalize().toVar(),m=f.mul(r.sub(t)).normalize().toVar(),g=f.mul(o.sub(t)).normalize().toVar(),y=f.mul(a.sub(t)).normalize().toVar(),_=D(0).toVar();_.addAssign(gu({v1:x,v2:m})),_.addAssign(gu({v1:m,v2:g})),_.addAssign(gu({v1:g,v2:y})),_.addAssign(gu({v1:y,v2:x})),h.assign(D(g2({f:_})))}),h}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"P",type:"vec3"},{name:"mInv",type:"mat3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),Ud=1/6,ib=s=>ot(Ud,ot(s,ot(s,s.negate().add(3)).sub(3)).add(1)),Nf=s=>ot(Ud,ot(s,ot(s,ot(3,s).sub(6))).add(4)),sb=s=>ot(Ud,ot(s,ot(s,ot(-3,s).add(3)).add(3)).add(1)),Ef=s=>ot(Ud,Kn(s,3)),r_=s=>ib(s).add(Nf(s)),o_=s=>sb(s).add(Ef(s)),a_=s=>Wt(-1,Nf(s).div(ib(s).add(Nf(s)))),c_=s=>Wt(1,Ef(s).div(sb(s).add(Ef(s)))),l_=(s,e,t)=>{const n=s.uvNode,i=ot(n,e.zw).add(.5),r=mr(i),o=gr(i),a=r_(o.x),c=o_(o.x),l=a_(o.x),u=c_(o.x),h=a_(o.y),d=c_(o.y),p=z(r.x.add(l),r.y.add(h)).sub(.5).mul(e.xy),f=z(r.x.add(u),r.y.add(h)).sub(.5).mul(e.xy),x=z(r.x.add(l),r.y.add(d)).sub(.5).mul(e.xy),m=z(r.x.add(u),r.y.add(d)).sub(.5).mul(e.xy),g=r_(o.y).mul(Wt(a.mul(s.uv(p).level(t)),c.mul(s.uv(f).level(t)))),y=o_(o.y).mul(Wt(a.mul(s.uv(x).level(t)),c.mul(s.uv(m).level(t))));return g.add(y)},rb=U(([s,e=A(3)])=>{const t=z(s.size(L(e))),n=z(s.size(L(e.add(1)))),i=ns(1,t),r=ns(1,n),o=l_(s,oe(i,t),mr(e)),a=l_(s,oe(r,n),fg(e));return gr(e).mix(o,a)}),u_=U(([s,e,t,n,i])=>{const r=D(_g(e.negate(),vi(s),ns(1,n))),o=D(Kr(i[0].xyz),Kr(i[1].xyz),Kr(i[2].xyz));return vi(r).mul(t.mul(o))}).setLayout({name:"getVolumeTransmissionRay",type:"vec3",inputs:[{name:"n",type:"vec3"},{name:"v",type:"vec3"},{name:"thickness",type:"float"},{name:"ior",type:"float"},{name:"modelMatrix",type:"mat4"}]}),x2=U(([s,e])=>s.mul(cn(e.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),_2=HT(),h_=U(([s,e,t])=>{const n=_2.uv(s),i=al(A(da.x)).mul(x2(e,t));return rb(n,i)}),d_=U(([s,e,t])=>(Oe(t.notEqual(0),()=>{const n=pg(e).negate().div(t);return dg(n.negate().mul(s))}),D(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),y2=U(([s,e,t,n,i,r,o,a,c,l,u,h,d,p,f])=>{let x,m;if(f){x=oe().toVar(),m=D().toVar();const I=u.sub(1).mul(f.mul(.025)),T=D(u.sub(I),u,u.add(I));mt({start:0,end:3},({i:w})=>{const C=T.element(w),F=u_(s,e,h,C,a),M=o.add(F),b=l.mul(c.mul(oe(M,1))),G=z(b.xy.div(b.w)).toVar();G.addAssign(1),G.divAssign(2),G.assign(z(G.x,G.y.oneMinus()));const W=h_(G,t,C);x.element(w).assign(W.element(w)),x.a.addAssign(W.a),m.element(w).assign(n.element(w).mul(d_(Kr(F),d,p).element(w)))}),x.a.divAssign(3)}else{const I=u_(s,e,h,u,a),T=o.add(I),w=l.mul(c.mul(oe(T,1))),C=z(w.xy.div(w.w)).toVar();C.addAssign(1),C.divAssign(2),C.assign(z(C.x,C.y.oneMinus())),x=h_(C,t,u),m=n.mul(d_(Kr(I),d,p))}const g=m.rgb.mul(x.rgb),y=s.dot(e).clamp(),_=D(tb({dotNV:y,specularColor:i,specularF90:r,roughness:t})),v=m.r.add(m.g,m.b).div(3);return oe(_.oneMinus().mul(g),x.a.oneMinus().mul(v).oneMinus())}),v2=Tn(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),M2=s=>{const e=s.sqrt();return D(1).add(e).div(D(1).sub(e))},p_=(s,e)=>s.sub(e).div(s.add(e)).pow2(),S2=(s,e)=>{const t=s.mul(2*Math.PI*1e-9),n=D(54856e-17,44201e-17,52481e-17),i=D(1681e3,1795300,2208400),r=D(43278e5,93046e5,66121e5),o=A(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(t.mul(2239900).add(e.x).cos()).mul(t.pow2().mul(-45282e5).exp());let a=n.mul(r.mul(2*Math.PI).sqrt()).mul(i.mul(t).add(e).cos()).mul(t.pow2().negate().mul(r).exp());return a=D(a.x.add(o),a.y,a.z).div(10685e-11),v2.mul(a)},T2=U(({outsideIOR:s,eta2:e,cosTheta1:t,thinFilmThickness:n,baseF0:i})=>{const r=it(s,e,ti(0,.03,n)),o=s.div(r).pow2().mul(A(1).sub(t.pow2())),c=A(1).sub(o).sqrt(),l=p_(r,s),u=pa({f0:l,f90:1,dotVH:t}),h=u.oneMinus(),d=r.lessThan(s).select(Math.PI,0),p=A(Math.PI).sub(d),f=M2(i.clamp(0,.9999)),x=p_(f,r.toVec3()),m=pa({f0:x,f90:1,dotVH:c}),g=D(f.x.lessThan(r).select(Math.PI,0),f.y.lessThan(r).select(Math.PI,0),f.z.lessThan(r).select(Math.PI,0)),y=r.mul(n,c,2),_=D(p).add(g),v=u.mul(m).clamp(1e-5,.9999),I=v.sqrt(),T=h.pow2().mul(m).div(D(1).sub(v));let C=u.add(T),F=T.sub(h);for(let M=1;M<=2;++M){F=F.mul(I);const b=S2(A(M).mul(y),A(M).mul(_)).mul(2);C=C.add(F.mul(b))}return C.max(D(0))}).setLayout({name:"evalIridescence",type:"vec3",inputs:[{name:"outsideIOR",type:"float"},{name:"eta2",type:"float"},{name:"cosTheta1",type:"float"},{name:"thinFilmThickness",type:"float"},{name:"baseF0",type:"vec3"}]}),b2=U(({normal:s,viewDir:e,roughness:t})=>{const n=s.dot(e).saturate(),i=t.pow2(),r=In(t.lessThan(.25),A(-339.2).mul(i).add(A(161.4).mul(t)).sub(25.9),A(-8.48).mul(i).add(A(14.3).mul(t)).sub(9.95)),o=In(t.lessThan(.25),A(44).mul(i).sub(A(23.7).mul(t)).add(3.26),A(1.97).mul(i).sub(A(3.27).mul(t)).add(.72));return In(t.lessThan(.25),0,A(.1).mul(t).sub(.025)).add(r.mul(n).add(o).exp()).mul(1/Math.PI).saturate()}),Bp=D(.04),zp=A(1);class Fd extends Ml{constructor(e=!1,t=!1,n=!1,i=!1,r=!1,o=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=n,this.anisotropy=i,this.transmission=r,this.dispersion=o,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null}start(e){if(this.clearcoat===!0&&(this.clearcoatRadiance=D().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=D().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=D().toVar("clearcoatSpecularIndirect")),this.sheen===!0&&(this.sheenSpecularDirect=D().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=D().toVar("sheenSpecularIndirect")),this.iridescence===!0){const t=Yt.dot(Bt).clamp();this.iridescenceFresnel=T2({outsideIOR:A(1),eta2:ng,cosTheta1:t,thinFilmThickness:ig,baseF0:ri}),this.iridescenceF0=nb({f:this.iridescenceFresnel,f90:1,dotVH:t})}if(this.transmission===!0){const t=vh,n=Ng.sub(vh).normalize(),i=Cg;e.backdrop=y2(i,n,hs,Ct,ri,kc,t,Ui,pi,ci,nc,rg,ag,og,this.dispersion?cg:null),e.backdropAlpha=fh,Ct.a.mulAssign(it(1,e.backdrop.a,fh))}}computeMultiscattering(e,t,n){const i=Yt.dot(Bt).clamp(),r=Hg({roughness:hs,dotNV:i}),a=(this.iridescenceF0?wd.mix(ri,this.iridescenceF0):ri).mul(r.x).add(n.mul(r.y)),l=r.x.add(r.y).oneMinus(),u=ri.add(ri.oneMinus().mul(.047619)),h=a.mul(u).div(l.mul(u).oneMinus());e.addAssign(a),t.addAssign(h.mul(l))}direct({lightDirection:e,lightColor:t,reflectedLight:n}){const r=Yt.dot(e).clamp().mul(t);if(this.sheen===!0&&this.sheenSpecularDirect.addAssign(r.mul(f2({lightDirection:e}))),this.clearcoat===!0){const a=Xo.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(a.mul(Af({lightDirection:e,f0:Bp,f90:zp,roughness:zc,normalView:Xo})))}n.directDiffuse.addAssign(r.mul(to({diffuseColor:Ct.rgb}))),n.directSpecular.addAssign(r.mul(Af({lightDirection:e,f0:ri,f90:1,roughness:hs,iridescence:this.iridescence,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:n,halfHeight:i,reflectedLight:r,ltc_1:o,ltc_2:a}){const c=t.add(n).sub(i),l=t.sub(n).sub(i),u=t.sub(n).add(i),h=t.add(n).add(i),d=Yt,p=Bt,f=Pn.toVar(),x=m2({N:d,V:p,roughness:hs}),m=o.uv(x).toVar(),g=a.uv(x).toVar(),y=Tn(D(m.x,0,m.y),D(0,1,0),D(m.z,0,m.w)).toVar(),_=ri.mul(g.x).add(ri.oneMinus().mul(g.y)).toVar();r.directSpecular.addAssign(e.mul(_).mul(s_({N:d,V:p,P:f,mInv:y,p0:c,p1:l,p2:u,p3:h}))),r.directDiffuse.addAssign(e.mul(Ct).mul(s_({N:d,V:p,P:f,mInv:Tn(1,0,0,0,1,0,0,0,1),p0:c,p1:l,p2:u,p3:h})))}indirect(e,t,n){this.indirectDiffuse(e,t,n),this.indirectSpecular(e,t,n),this.ambientOcclusion(e,t,n)}indirectDiffuse({irradiance:e,reflectedLight:t}){t.indirectDiffuse.addAssign(e.mul(to({diffuseColor:Ct})))}indirectSpecular({radiance:e,iblIrradiance:t,reflectedLight:n}){if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(t.mul(Wr,b2({normal:Yt,viewDir:Bt,roughness:bd}))),this.clearcoat===!0){const l=Xo.dot(Bt).clamp(),u=tb({dotNV:l,specularColor:Bp,specularF90:zp,roughness:zc});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(u))}const i=D().toVar("singleScattering"),r=D().toVar("multiScattering"),o=t.mul(1/Math.PI);this.computeMultiscattering(i,r,kc);const a=i.add(r),c=Ct.mul(a.r.max(a.g).max(a.b).oneMinus());n.indirectSpecular.addAssign(e.mul(i)),n.indirectSpecular.addAssign(r.mul(o)),n.indirectDiffuse.addAssign(c.mul(o))}ambientOcclusion({ambientOcclusion:e,reflectedLight:t}){const i=Yt.dot(Bt).clamp().add(e),r=hs.mul(-16).oneMinus().negate().exp2(),o=e.sub(i.pow(r).oneMinus()).clamp();this.clearcoat===!0&&this.clearcoatSpecularIndirect.mulAssign(e),this.sheen===!0&&this.sheenSpecularIndirect.mulAssign(e),t.indirectDiffuse.mulAssign(e),t.indirectSpecular.mulAssign(o)}finish(e){const{outgoingLight:t}=e;if(this.clearcoat===!0){const n=Xo.dot(Bt).clamp(),i=pa({dotVH:n,f0:Bp,f90:zp}),r=t.mul(hh.mul(i).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(hh));t.assign(r)}if(this.sheen===!0){const n=Wr.r.max(Wr.g).max(Wr.b).mul(.157).oneMinus(),i=t.mul(n).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(i)}}}const f_=A(1),Cf=A(-2),xu=A(.8),kp=A(-1),_u=A(.4),Gp=A(2),yu=A(.305),Hp=A(3),m_=A(.21),w2=A(4),g_=A(4),A2=A(16),N2=U(([s])=>{const e=D(Dt(s)).toVar(),t=A(-1).toVar();return Oe(e.x.greaterThan(e.z),()=>{Oe(e.x.greaterThan(e.y),()=>{t.assign(In(s.x.greaterThan(0),0,3))}).Else(()=>{t.assign(In(s.y.greaterThan(0),1,4))})}).Else(()=>{Oe(e.z.greaterThan(e.y),()=>{t.assign(In(s.z.greaterThan(0),2,5))}).Else(()=>{t.assign(In(s.y.greaterThan(0),1,4))})}),t}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),E2=U(([s,e])=>{const t=z().toVar();return Oe(e.equal(0),()=>{t.assign(z(s.z,s.y).div(Dt(s.x)))}).ElseIf(e.equal(1),()=>{t.assign(z(s.x.negate(),s.z.negate()).div(Dt(s.y)))}).ElseIf(e.equal(2),()=>{t.assign(z(s.x.negate(),s.y).div(Dt(s.z)))}).ElseIf(e.equal(3),()=>{t.assign(z(s.z.negate(),s.y).div(Dt(s.x)))}).ElseIf(e.equal(4),()=>{t.assign(z(s.x.negate(),s.z).div(Dt(s.y)))}).Else(()=>{t.assign(z(s.x,s.y).div(Dt(s.z)))}),ot(.5,t.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),C2=U(([s])=>{const e=A(0).toVar();return Oe(s.greaterThanEqual(xu),()=>{e.assign(f_.sub(s).mul(kp.sub(Cf)).div(f_.sub(xu)).add(Cf))}).ElseIf(s.greaterThanEqual(_u),()=>{e.assign(xu.sub(s).mul(Gp.sub(kp)).div(xu.sub(_u)).add(kp))}).ElseIf(s.greaterThanEqual(yu),()=>{e.assign(_u.sub(s).mul(Hp.sub(Gp)).div(_u.sub(yu)).add(Gp))}).ElseIf(s.greaterThanEqual(m_),()=>{e.assign(yu.sub(s).mul(w2.sub(Hp)).div(yu.sub(m_)).add(Hp))}).Else(()=>{e.assign(A(-2).mul(al(ot(1.16,s))))}),e}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),ob=U(([s,e])=>{const t=s.toVar();t.assign(ot(2,t).sub(1));const n=D(t,1).toVar();return Oe(e.equal(0),()=>{n.assign(n.zyx)}).ElseIf(e.equal(1),()=>{n.assign(n.xzy),n.xz.mulAssign(-1)}).ElseIf(e.equal(2),()=>{n.x.mulAssign(-1)}).ElseIf(e.equal(3),()=>{n.assign(n.zyx),n.xz.mulAssign(-1)}).ElseIf(e.equal(4),()=>{n.assign(n.xzy),n.xy.mulAssign(-1)}).ElseIf(e.equal(5),()=>{n.z.mulAssign(-1)}),n}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),ab=U(([s,e,t,n,i,r])=>{const o=A(t),a=D(e),c=cn(C2(o),Cf,r),l=gr(c),u=mr(c),h=D(Rf(s,a,u,n,i,r)).toVar();return Oe(l.notEqual(0),()=>{const d=D(Rf(s,a,u.add(1),n,i,r)).toVar();h.assign(it(h,d,l))}),h}),Rf=U(([s,e,t,n,i,r])=>{const o=A(t).toVar(),a=D(e),c=A(N2(a)).toVar(),l=A(ft(g_.sub(o),0)).toVar();o.assign(ft(o,g_));const u=A(mh(o)).toVar(),h=z(E2(a,c).mul(u.sub(2)).add(1)).toVar();return Oe(c.greaterThan(2),()=>{h.y.addAssign(u),c.subAssign(3)}),h.x.addAssign(c.mul(u)),h.x.addAssign(l.mul(ot(3,A2))),h.y.addAssign(ot(4,mh(r).sub(u))),h.x.mulAssign(n),h.y.mulAssign(i),s.uv(h).grad(z(),z())}),Wp=U(({envMap:s,mipInt:e,outputDirection:t,theta:n,axis:i,CUBEUV_TEXEL_WIDTH:r,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:a})=>{const c=Mi(n),l=t.mul(c).add(i.cross(t).mul(Cn(n))).add(i.mul(i.dot(t).mul(c.oneMinus())));return Rf(s,l,e,r,o,a)}),cb=U(({n:s,latitudinal:e,poleAxis:t,outputDirection:n,weights:i,samples:r,dTheta:o,mipInt:a,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h})=>{const d=D(In(e,t,Qo(t,n))).toVar();Oe(hg(d.equals(D(0))),()=>{d.assign(D(n.z,0,n.x.negate()))}),d.assign(vi(d));const p=D().toVar();return p.addAssign(i.element(L(0)).mul(Wp({theta:0,axis:d,outputDirection:n,mipInt:a,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h}))),mt({start:L(1),end:s},({i:f})=>{Oe(f.greaterThanEqual(r),()=>{Ld()});const x=A(o.mul(A(f))).toVar();p.addAssign(i.element(f).mul(Wp({theta:x.mul(-1),axis:d,outputDirection:n,mipInt:a,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h}))),p.addAssign(i.element(f).mul(Wp({theta:x,axis:d,outputDirection:n,mipInt:a,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h})))}),oe(p,1)});let Th=null;const x_=new WeakMap;function R2(s){const e=Math.log2(s)-2,t=1/s;return{texelWidth:1/(3*Math.max(Math.pow(2,e),112)),texelHeight:t,maxMip:e}}function I2(s){let e=x_.get(s);if((e!==void 0?e.pmremVersion:-1)!==s.pmremVersion){const n=s.image;if(s.isCubeTexture)if(P2(n))e=Th.fromCubemap(s,e);else return null;else if(L2(n))e=Th.fromEquirectangular(s,e);else return null;e.pmremVersion=s.pmremVersion,x_.set(s,e)}return e.texture}class lb extends pt{static get type(){return"PMREMNode"}constructor(e,t=null,n=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=n,this._generator=null;const i=new Xt;i.isRenderTargetTexture=!0,this._texture=xt(i),this._width=pe(0),this._height=pe(0),this._maxMip=pe(0),this.updateBeforeType=We.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=R2(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(){let e=this._pmrem;const t=e?e.pmremVersion:-1,n=this._value;t!==n.pmremVersion&&(n.isPMREMTexture===!0?e=n:e=I2(n),e!==null&&(this._pmrem=e,this.updateFromTexture(e)))}setup(e){Th===null&&(Th=e.createPMREMGenerator()),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this));const n=this.value;e.renderer.coordinateSystem===Di&&n.isPMREMTexture!==!0&&n.isRenderTargetTexture===!0&&(t=D(t.x.negate(),t.yz));let i=this.levelNode;return i===null&&e.context.getTextureLevel&&(i=e.context.getTextureLevel(this)),ab(this._texture,t,i,this._width,this._height,this._maxMip)}}function P2(s){if(s==null)return!1;let e=0;const t=6;for(let n=0;n<t;n++)s[n]!==void 0&&e++;return e===t}function L2(s){return s==null?!1:s.height>0}const ub=K(lb),__=new WeakMap;class hb extends ho{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let n=this.envNode;if(n.isTextureNode||n.isMaterialReferenceNode){const p=n.isTextureNode?n.value:t[n.property];let f=__.get(p);f===void 0&&(f=ub(p),__.set(p,f)),n=f}const r=t.envMap?dn("envMapIntensity","float",e.material):dn("environmentIntensity","float",e.scene),a=t.useAnisotropy===!0||t.anisotropy>0?YS:Yt,c=n.context(y_(hs,a)).mul(r),l=n.context(D2(Cg)).mul(Math.PI).mul(r),u=ic(c),h=ic(l);e.context.radiance.addAssign(u),e.context.iblIrradiance.addAssign(h);const d=e.context.lightingModel.clearcoatRadiance;if(d){const p=n.context(y_(zc,Xo)).mul(r),f=ic(p);d.addAssign(f)}}}const y_=(s,e)=>{let t=null;return{getUV:()=>(t===null&&(t=Bt.negate().reflect(e),t=s.mul(s).mix(t,e).normalize(),t=t.transformDirection(pi)),t),getTextureLevel:()=>s}},D2=s=>({getUV:()=>s,getTextureLevel:()=>A(1)}),U2=new nl;class db extends Tt{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(U2),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new hb(t):null}setupLightingModel(){return new Fd}setupSpecular(){const e=it(D(.04),Ct.rgb,Bc);ri.assign(e),kc.assign(1)}setupVariants(){const e=this.metalnessNode?A(this.metalnessNode):sT;Bc.assign(e);let t=this.roughnessNode?A(this.roughnessNode):iT;t=Gg({roughness:t}),hs.assign(t),this.setupSpecular(),Ct.assign(oe(Ct.rgb.mul(e.oneMinus()),Ct.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const F2=new ud;class pb extends db{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(F2),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||this.clearcoatNode!==null}get useIridescence(){return this.iridescence>0||this.iridescenceNode!==null}get useSheen(){return this.sheen>0||this.sheenNode!==null}get useAnisotropy(){return this.anisotropy>0||this.anisotropyNode!==null}get useTransmission(){return this.transmission>0||this.transmissionNode!==null}get useDispersion(){return this.dispersion>0||this.dispersionNode!==null}setupSpecular(){const e=this.iorNode?A(this.iorNode):_T;nc.assign(e),ri.assign(it(Mn(gg(nc.sub(1).div(nc.add(1))).mul(nT),D(1)).mul(Tf),Ct.rgb,Bc)),kc.assign(it(Tf,1,Bc))}setupLightingModel(){return new Fd(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const t=this.clearcoatNode?A(this.clearcoatNode):oT,n=this.clearcoatRoughnessNode?A(this.clearcoatRoughnessNode):aT;hh.assign(t),zc.assign(Gg({roughness:n}))}if(this.useSheen){const t=this.sheenNode?D(this.sheenNode):uT,n=this.sheenRoughnessNode?A(this.sheenRoughnessNode):hT;Wr.assign(t),bd.assign(n)}if(this.useIridescence){const t=this.iridescenceNode?A(this.iridescenceNode):pT,n=this.iridescenceIORNode?A(this.iridescenceIORNode):fT,i=this.iridescenceThicknessNode?A(this.iridescenceThicknessNode):mT;wd.assign(t),ng.assign(n),ig.assign(i)}if(this.useAnisotropy){const t=(this.anisotropyNode?z(this.anisotropyNode):dT).toVar();Ys.assign(t.length()),Oe(Ys.equal(0),()=>{t.assign(z(1,0))}).Else(()=>{t.divAssign(z(Ys)),Ys.assign(Ys.saturate())}),dh.assign(Ys.pow2().mix(hs.pow2(),1)),tc.assign(Xr[0].mul(t.x).add(Xr[1].mul(t.y))),Zr.assign(Xr[1].mul(t.x).sub(Xr[0].mul(t.y)))}if(this.useTransmission){const t=this.transmissionNode?A(this.transmissionNode):gT,n=this.thicknessNode?A(this.thicknessNode):xT,i=this.attenuationDistanceNode?A(this.attenuationDistanceNode):yT,r=this.attenuationColorNode?D(this.attenuationColorNode):vT;if(fh.assign(t),rg.assign(n),og.assign(i),ag.assign(r),this.useDispersion){const o=this.dispersionNode?A(this.dispersionNode):ST;cg.assign(o)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?D(this.clearcoatNormalNode):cT}setup(e){e.context.setupClearcoatNormal=()=>this.setupClearcoatNormal(e),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}class O2 extends Fd{constructor(e,t,n,i){super(e,t,n),this.useSSS=i}direct({lightDirection:e,lightColor:t,reflectedLight:n},i,r){if(this.useSSS===!0){const o=r.material,{thicknessColorNode:a,thicknessDistortionNode:c,thicknessAmbientNode:l,thicknessAttenuationNode:u,thicknessPowerNode:h,thicknessScaleNode:d}=o,p=e.add(Yt.mul(c)).normalize(),f=A(Bt.dot(p.negate()).saturate().pow(h).mul(d)),x=D(f.add(l).mul(a));n.directDiffuse.addAssign(x.mul(u.mul(t)))}super.direct({lightDirection:e,lightColor:t,reflectedLight:n},i,r)}}class V2 extends pb{static get type(){return"MeshSSSNodeMaterial"}constructor(e){super(e),this.thicknessColorNode=null,this.thicknessDistortionNode=A(.1),this.thicknessAmbientNode=A(0),this.thicknessAttenuationNode=A(.1),this.thicknessPowerNode=A(2),this.thicknessScaleNode=A(10)}get useSSS(){return this.thicknessColorNode!==null}setupLightingModel(){return new O2(this.useClearcoat,this.useSheen,this.useIridescence,this.useSSS)}copy(e){return this.thicknessColorNode=e.thicknessColorNode,this.thicknessDistortionNode=e.thicknessDistortionNode,this.thicknessAmbientNode=e.thicknessAmbientNode,this.thicknessAttenuationNode=e.thicknessAttenuationNode,this.thicknessPowerNode=e.thicknessPowerNode,this.thicknessScaleNode=e.thicknessScaleNode,super.copy(e)}}const B2=U(({normal:s,lightDirection:e,builder:t})=>{const n=s.dot(e),i=z(n.mul(.5).add(.5),0);if(t.material.gradientMap){const r=Ki("gradientMap","texture").context({getUV:()=>i});return D(r.r)}else{const r=i.fwidth().mul(.5);return it(D(.7),D(1),ti(A(.7).sub(r.x),A(.7).add(r.x),i.x))}});class z2 extends Ml{direct({lightDirection:e,lightColor:t,reflectedLight:n},i,r){const o=B2({normal:Nd,lightDirection:e,builder:r}).mul(t);n.directDiffuse.addAssign(o.mul(to({diffuseColor:Ct.rgb})))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:n}){n.indirectDiffuse.addAssign(t.mul(to({diffuseColor:Ct}))),n.indirectDiffuse.mulAssign(e)}}const k2=new wm;class G2 extends Tt{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(k2),this.setValues(e)}setupLightingModel(){return new z2}}class fb extends pt{static get type(){return"MatcapUVNode"}constructor(){super("vec2")}setup(){const e=D(Bt.z,0,Bt.x.negate()).normalize(),t=Bt.cross(e);return z(e.dot(Yt),t.dot(Yt)).mul(.495).add(.5)}}const mb=fe(fb),H2=new Am;class W2 extends Tt{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.lights=!1,this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(H2),this.setValues(e)}setupVariants(e){const t=mb;let n;e.material.matcap?n=Ki("matcap","texture").context({getUV:()=>t}):n=D(it(.2,.8,t.y)),Ct.rgb.mulAssign(n.rgb)}}const X2=new ya;class q2 extends Tt{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.isPointsNodeMaterial=!0,this.lights=!1,this.transparent=!0,this.sizeNode=null,this.setDefaultValues(X2),this.setValues(e)}copy(e){return this.sizeNode=e.sizeNode,super.copy(e)}}class gb extends pt{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:n}=this;if(this.getNodeType(e)==="vec2"){const r=t.cos(),o=t.sin();return ol(r,o,o.negate(),r).mul(n)}else{const r=t,o=Yr(oe(1,0,0,0),oe(0,Mi(r.x),Cn(r.x).negate(),0),oe(0,Cn(r.x),Mi(r.x),0),oe(0,0,0,1)),a=Yr(oe(Mi(r.y),0,Cn(r.y),0),oe(0,1,0,0),oe(Cn(r.y).negate(),0,Mi(r.y),0),oe(0,0,0,1)),c=Yr(oe(Mi(r.z),Cn(r.z).negate(),0,0),oe(Cn(r.z),Mi(r.z),0,0),oe(0,0,1,0),oe(0,0,0,1));return o.mul(a).mul(c).mul(oe(n,1)).xyz}}}const Wg=K(gb),$2=new Zc;class Y2 extends Tt{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this.lights=!1,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.setDefaultValues($2),this.setValues(e)}setupPosition({object:e,camera:t,context:n}){const i=this.sizeAttenuation,{positionNode:r,rotationNode:o,scaleNode:a}=this,c=en;let l=xs.mul(D(r||0)),u=z(Ui[0].xyz.length(),Ui[1].xyz.length());a!==null&&(u=u.mul(a)),!i&&t.isPerspectiveCamera&&(u=u.mul(l.z.negate()));let h=c.xy;if(e.center&&e.center.isVector2===!0){const x=XP("center","vec2");h=h.sub(x.sub(.5))}h=h.mul(u);const d=A(o||lT),p=Wg(h,d);l=oe(l.xy.add(p),l.zw);const f=ci.mul(l);return n.vertex=c,f}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}class Z2 extends Ml{constructor(){super(),this.shadowNode=A(1).toVar("shadowMask")}direct({shadowMask:e}){this.shadowNode.mulAssign(e)}finish(e){Ct.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(Ct.rgb)}}const J2=new ld;class K2 extends Tt{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.setDefaultValues(J2),this.setValues(e)}setupLightingModel(){return new Z2}}const j2=U(({texture:s,uv:e})=>{const n=D().toVar();return Oe(e.x.lessThan(1e-4),()=>{n.assign(D(1,0,0))}).ElseIf(e.y.lessThan(1e-4),()=>{n.assign(D(0,1,0))}).ElseIf(e.z.lessThan(1e-4),()=>{n.assign(D(0,0,1))}).ElseIf(e.x.greaterThan(1-1e-4),()=>{n.assign(D(-1,0,0))}).ElseIf(e.y.greaterThan(1-1e-4),()=>{n.assign(D(0,-1,0))}).ElseIf(e.z.greaterThan(1-1e-4),()=>{n.assign(D(0,0,-1))}).Else(()=>{const r=s.uv(e.add(D(-.01,0,0))).r.sub(s.uv(e.add(D(.01,0,0))).r),o=s.uv(e.add(D(0,-.01,0))).r.sub(s.uv(e.add(D(0,.01,0))).r),a=s.uv(e.add(D(0,0,-.01))).r.sub(s.uv(e.add(D(0,0,.01))).r);n.assign(D(r,o,a))}),n.normalize()});class xb extends gs{static get type(){return"Texture3DNode"}constructor(e,t=null,n=null){super(e,t,n),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return D(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){return t}generateUV(e,t){return t.build(e,"vec3")}normal(e){return j2({texture:this,uv:e})}}const _b=K(xb);class Q2 extends Tt{static get type(){return"VolumeNodeMaterial"}constructor(e={}){super(),this.lights=!1,this.isVolumeNodeMaterial=!0,this.testNode=null,this.setValues(e)}setup(e){const t=_b(this.map,null,0),n=U(({orig:i,dir:r})=>{const o=D(-.5),a=D(.5),c=r.reciprocal(),l=o.sub(i).mul(c),u=a.sub(i).mul(c),h=Mn(l,u),d=ft(l,u),p=ft(h.x,ft(h.y,h.z)),f=Mn(d.x,Mn(d.y,d.z));return z(p,f)});this.fragmentNode=U(()=>{const i=Un(D(PS.mul(oe(Ng,1)))),o=Un(Nn.sub(i)).normalize(),a=z(n({orig:i,dir:o})).toVar();a.x.greaterThan(a.y).discard(),a.assign(z(ft(a.x,0),a.y));const c=D(i.add(a.x.mul(o))).toVar(),l=D(o.abs().reciprocal()).toVar(),u=A(Mn(l.x,Mn(l.y,l.z))).toVar("delta");u.divAssign(Ki("steps","float"));const h=oe(Ki("base","color"),0).toVar();return mt({type:"float",start:a.x,end:a.y,update:"+= delta"},()=>{const d=ai("float","d").assign(t.uv(c.add(.5)).r);this.testNode!==null?this.testNode({map:t,mapValue:d,probe:c,finalColor:h}).append():(h.a.assign(1),Ld()),c.addAssign(o.mul(u))}),h.a.equal(0).discard(),oe(h)})(),super.setup(e)}}class yb extends Xn{constructor(e){super(e),this.textures={},this.nodes={}}load(e,t,n,i){const r=new ts(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,o=>{try{t(this.parse(JSON.parse(o)))}catch(a){i?i(a):console.error(a),this.manager.itemError(e)}},n,i)}parseNodes(e){const t={};if(e!==void 0){for(const i of e){const{uuid:r,type:o}=i;t[r]=this.createNodeFromType(o),t[r].uuid=r}const n={nodes:t,textures:this.textures};for(const i of e)i.meta=n,t[i.uuid].deserialize(i),delete i.meta}return t}parse(e){const t=this.createNodeFromType(e.type);t.uuid=e.uuid;const i={nodes:this.parseNodes(e.nodes),textures:this.textures};return e.meta=i,t.deserialize(e),delete e.meta,t}setTextures(e){return this.textures=e,this}setNodes(e){return this.nodes=e,this}createNodeFromType(e){return this.nodes[e]===void 0?(console.error("THREE.NodeLoader: Node type not found:",e),A()):H(new this.nodes[e])}}class vb extends sl{constructor(e){super(e),this.nodes={},this.nodeMaterials={}}parse(e){const t=super.parse(e),n=this.nodes,i=e.inputNodes;for(const r in i){const o=i[r];t[r]=n[o]}return t}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}createMaterialFromType(e){const t=this.nodeMaterials[e];return t!==void 0?new t:super.createMaterialFromType(e)}}class e3 extends xv{constructor(e){super(e),this.nodes={},this.nodeMaterials={},this._nodesJSON=null}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}parse(e,t){this._nodesJSON=e.nodes;const n=super.parse(e,t);return this._nodesJSON=null,n}parseNodes(e,t){if(e!==void 0){const n=new yb;return n.setNodes(this.nodes),n.setTextures(t),n.parseNodes(e)}return{}}parseMaterials(e,t){const n={};if(e!==void 0){const i=this.parseNodes(this._nodesJSON,t),r=new vb;r.setTextures(t),r.setNodes(i),r.setNodeMaterials(this.nodeMaterials);for(let o=0,a=e.length;o<a;o++){const c=e[o];n[c.uuid]=r.parse(c)}}return n}}class If{constructor(e,t,n=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=n}}class Mb{constructor(e,t,n){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=n.getSelf()}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class Xg{constructor(e,t){this.isNodeVar=!0,this.name=e,this.type=t}}class Sb extends Xg{constructor(e,t){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0}}class Tb{constructor(e,t,n=""){this.name=e,this.type=t,this.code=n,Object.defineProperty(this,"isNodeCode",{value:!0})}}let t3=0;class Lu{constructor(e=null){this.id=t3++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return t===void 0&&this.parent!==null&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class qg extends Nt{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}const n3=(s,e)=>H(new qg(s,e));class $g extends Ye{static get type(){return"CodeNode"}constructor(e="",t=[],n=""){super("code"),this.isCodeNode=!0,this.code=e,this.language=n,this.includes=t}isGlobal(){return!0}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const i of t)i.build(e);const n=e.getCodeFromNode(this,this.getNodeType(e));return n.code=this.code,n.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}const Od=K($g),i3=(s,e)=>Od(s,e,"js"),s3=(s,e)=>Od(s,e,"wgsl"),r3=(s,e)=>Od(s,e,"glsl");class Yg extends $g{static get type(){return"FunctionNode"}constructor(e="",t=[],n=""){super(e,t,n)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let n=t.nodeFunction;return n===void 0&&(n=e.parser.parseFunction(this.code),t.nodeFunction=n),n}generate(e,t){super.generate(e);const n=this.getNodeFunction(e),i=n.name,r=n.type,o=e.getCodeFromNode(this,r);i!==""&&(o.name=i);const a=e.getPropertyName(o),c=this.getNodeFunction(e).getCode(a);return o.code=c+`
3867
- `,t==="property"?a:e.format(`${a}()`,r,t)}}const bb=(s,e=[],t="")=>{for(let r=0;r<e.length;r++){const o=e[r];typeof o=="function"&&(e[r]=o.functionNode)}const n=H(new Yg(s,e,t)),i=(...r)=>n.call(...r);return i.functionNode=n,i},o3=(s,e)=>bb(s,e,"glsl"),a3=(s,e)=>bb(s,e,"wgsl");class po{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0}setValue(e){this.value=e}getValue(){return this.value}}class c3 extends po{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class l3 extends po{constructor(e,t=new J){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class u3 extends po{constructor(e,t=new E){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class h3 extends po{constructor(e,t=new st){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class d3 extends po{constructor(e,t=new _e){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class p3 extends po{constructor(e,t=new Ke){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class f3 extends po{constructor(e,t=new Fe){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class m3 extends c3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class g3 extends l3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class x3 extends u3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class _3 extends h3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class y3 extends d3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class v3 extends p3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class M3 extends f3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class wb extends Ye{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}add(e){return this.nodes.push(e),this}If(e,t){const n=new ec(t);return this._currentCond=In(e,n),this.add(this._currentCond)}ElseIf(e,t){const n=new ec(t),i=In(e,n);return this._currentCond.elseNode=i,this._currentCond=i,this}Else(e){return this._currentCond.elseNode=new ec(e),this}build(e,...t){const n=jm();Vc(this);for(const i of this.nodes)i.build(e,"void");return Vc(n),this.outputNode?this.outputNode.build(e,...t):super.build(e,...t)}else(...e){return console.warn("TSL.StackNode: .else() has been renamed to .Else()."),this.Else(...e)}elseif(...e){return console.warn("TSL.StackNode: .elseif() has been renamed to .ElseIf()."),this.ElseIf(...e)}}const Du=K(wb);class S3{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let n=0;n<e.length;n++)if(t=t.get(e[n]),t===void 0)return;return t.get(e[e.length-1])}set(e,t){let n=this.weakMap;for(let i=0;i<e.length;i++){const r=e[i];n.has(r)===!1&&n.set(r,new WeakMap),n=n.get(r)}return n.set(e[e.length-1],t)}delete(e){let t=this.weakMap;for(let n=0;n<e.length;n++)if(t=t.get(e[n]),t===void 0)return!1;return t.delete(e[e.length-1])}}const qo=4,v_=[.125,.215,.35,.446,.526,.582],Vr=20,Xp=new ro(-1,1,1,-1,0,1),T3=new hn(90,1),M_=new _e;let qp=null,$p=0,Yp=0;const Fr=(1+Math.sqrt(5))/2,Do=1/Fr,S_=[new E(-Fr,Do,0),new E(Fr,Do,0),new E(-Do,0,Fr),new E(Do,0,Fr),new E(0,Fr,-Do),new E(0,Fr,Do),new E(-1,1,-1),new E(1,1,-1),new E(-1,1,1),new E(1,1,1)],b3=[3,1,5,0,4,2],Zp=ob(rt(),vn("faceIndex")).normalize(),Zg=D(Zp.x,Zp.y.negate(),Zp.z);class w3{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}fromScene(e,t=0,n=.1,i=100){qp=this._renderer.getRenderTarget(),$p=this._renderer.getActiveCubeFace(),Yp=this._renderer.getActiveMipmapLevel(),this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(e,n,i,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=b_(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=w_(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(qp,$p,Yp),e.scissorTest=!1,vu(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===wi||e.mapping===Vi?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),qp=this._renderer.getRenderTarget(),$p=this._renderer.getActiveCubeFace(),Yp=this._renderer.getActiveMipmapLevel();const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Ut,minFilter:Ut,generateMipmaps:!1,type:Ln,format:Rn,colorSpace:li},i=T_(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=T_(e,t,n);const{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas,lodMeshes:this._lodMeshes}=A3(r)),this._blurMaterial=N3(r,e,t)}return i}async _compileMaterial(e){const t=new kt(this._lodPlanes[0],e);await this._renderer.compile(t,Xp)}_sceneToCubeUV(e,t,n,i){const r=T3;r.near=t,r.far=n;const o=[-1,1,-1,-1,-1,-1],a=[1,1,1,-1,-1,-1],c=this._renderer,l=c.autoClear;c.getClearColor(M_),c.autoClear=!1;let u=this._backgroundBox;if(u===null){const p=new ss({name:"PMREM.Background",side:ln,depthWrite:!1,depthTest:!1});u=new kt(new _s,p)}let h=!1;const d=e.background;d?d.isColor&&(u.material.color.copy(d),e.background=null,h=!0):(u.material.color.copy(M_),h=!0),c.setRenderTarget(i),c.clear(),h&&c.render(u,r);for(let p=0;p<6;p++){const f=p%3;f===0?(r.up.set(0,o[p],0),r.lookAt(a[p],0,0)):f===1?(r.up.set(0,0,o[p]),r.lookAt(0,a[p],0)):(r.up.set(0,o[p],0),r.lookAt(0,0,a[p]));const x=this._cubeSize;vu(i,f*x,p>2?x:0,x,x),c.render(e,r)}c.autoClear=l,e.background=d}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===wi||e.mapping===Vi;i?this._cubemapMaterial===null&&(this._cubemapMaterial=b_(e)):this._equirectMaterial===null&&(this._equirectMaterial=w_(e));const r=i?this._cubemapMaterial:this._equirectMaterial;r.fragmentNode.value=e;const o=this._lodMeshes[0];o.material=r;const a=this._cubeSize;vu(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(o,Xp)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const i=this._lodPlanes.length;for(let r=1;r<i;r++){const o=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),a=S_[(i-r-1)%S_.length];this._blur(e,r-1,r,o,a)}t.autoClear=n}_blur(e,t,n,i,r){const o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,i,"latitudinal",r),this._halfBlur(o,e,n,n,i,"longitudinal",r)}_halfBlur(e,t,n,i,r,o,a){const c=this._renderer,l=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const u=3,h=this._lodMeshes[i];h.material=l;const d=l.uniforms,p=this._sizeLods[n]-1,f=isFinite(r)?Math.PI/(2*p):2*Math.PI/(2*Vr-1),x=r/f,m=isFinite(r)?1+Math.floor(u*x):Vr;m>Vr&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Vr}`);const g=[];let y=0;for(let w=0;w<Vr;++w){const C=w/x,F=Math.exp(-C*C/2);g.push(F),w===0?y+=F:w<m&&(y+=2*F)}for(let w=0;w<g.length;w++)g[w]=g[w]/y;e.texture.frame=(e.texture.frame||0)+1,d.envMap.value=e.texture,d.samples.value=m,d.weights.array=g,d.latitudinal.value=o==="latitudinal"?1:0,a&&(d.poleAxis.value=a);const{_lodMax:_}=this;d.dTheta.value=f,d.mipInt.value=_-n;const v=this._sizeLods[i],I=3*v*(i>_-qo?i-_+qo:0),T=4*(this._cubeSize-v);vu(t,I,T,3*v,2*v),c.setRenderTarget(t),c.render(h,Xp)}}function A3(s){const e=[],t=[],n=[],i=[];let r=s;const o=s-qo+1+v_.length;for(let a=0;a<o;a++){const c=Math.pow(2,r);t.push(c);let l=1/c;a>s-qo?l=v_[a-s+qo-1]:a===0&&(l=0),n.push(l);const u=1/(c-2),h=-u,d=1+u,p=[h,h,d,h,d,d,h,h,d,d,h,d],f=6,x=6,m=3,g=2,y=1,_=new Float32Array(m*x*f),v=new Float32Array(g*x*f),I=new Float32Array(y*x*f);for(let w=0;w<f;w++){const C=w%3*2/3-1,F=w>2?0:-1,M=[C,F,0,C+2/3,F,0,C+2/3,F+1,0,C,F,0,C+2/3,F+1,0,C,F+1,0],b=b3[w];_.set(M,m*x*b),v.set(p,g*x*b);const G=[b,b,b,b,b,b];I.set(G,y*x*b)}const T=new at;T.setAttribute("position",new At(_,m)),T.setAttribute("uv",new At(v,g)),T.setAttribute("faceIndex",new At(I,y)),e.push(T),i.push(new kt(T,null)),r>qo&&r--}return{lodPlanes:e,sizeLods:t,sigmas:n,lodMeshes:i}}function T_(s,e,t){const n=new fn(s,e,t);return n.texture.mapping=hr,n.texture.name="PMREM.cubeUv",n.texture.isPMREMTexture=!0,n.scissorTest=!0,n}function vu(s,e,t,n,i){s.viewport.set(e,t,n,i),s.scissor.set(e,t,n,i)}function Jg(s){const e=new Tt;return e.depthTest=!1,e.depthWrite=!1,e.blending=Fi,e.name=`PMREM_${s}`,e}function N3(s,e,t){const n=ds(new Array(Vr).fill(0)),i=pe(new E(0,1,0)),r=pe(0),o=A(Vr),a=pe(0),c=pe(1),l=xt(null),u=pe(0),h=A(1/e),d=A(1/t),p=A(s),f={n:o,latitudinal:a,weights:n,poleAxis:i,outputDirection:Zg,dTheta:r,samples:c,envMap:l,mipInt:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:p},x=Jg("blur");return x.uniforms=f,x.fragmentNode=cb({...f,latitudinal:a.equal(1)}),x}function b_(s){const e=Jg("cubemap");return e.fragmentNode=Cd(s,Zg),e}function w_(s){const e=Jg("equirect");return e.fragmentNode=xt(s,zg(Zg),0),e}let E3=0;class A_{constructor(e="",t=[],n=0,i=[]){this.name=e,this.bindings=t,this.index=n,this.bindingsReference=i,this.id=E3++}}const N_=new WeakMap,C3=new Map([[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),R3=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),Mu=s=>(s=Number(s),s+(s%1?"":".0"));class Ab{constructor(e,t,n){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=n,this.scene=null,this.camera=null,this.nodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.monitor=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.flow={code:""},this.chaining=[],this.stack=Du(),this.stacks=[],this.tab=" ",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new Lu,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.useComparisonMethod=!1}getBindGroupsCache(){let e=N_.get(this.renderer);return e===void 0&&(e=new S3,N_.set(this.renderer,e)),e}createRenderTarget(e,t,n){return new fn(e,t,n)}createCubeRenderTarget(e,t){return new ZT(e,t)}createPMREMGenerator(){return new w3(this.renderer)}includes(e){return this.nodes.includes(e)}_getBindGroup(e,t){const n=this.getBindGroupsCache(),i=[];let r=!0;for(const a of t)i.push(a),r=r&&a.groupNode.shared!==!0;let o;return r?(o=n.get(i),o===void 0&&(o=new A_(e,i,this.bindingsIndexes[e].group,i),n.set(i,o))):o=new A_(e,i,this.bindingsIndexes[e].group,i),o}getBindGroupArray(e,t){const n=this.bindings[t];let i=n[e];return i===void 0&&(this.bindingsIndexes[e]===void 0&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),n[e]=i=[]),i}getBindings(){let e=this.bindGroups;if(e===null){const t={},n=this.bindings;for(const i of xf)for(const r in n[i]){const o=n[i][r];(t[r]||(t[r]=[])).push(...o)}e=[];for(const i in t){const r=t[i],o=this._getBindGroup(i,r);e.push(o)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort((t,n)=>t.bindings[0].groupNode.order-n.bindings[0].groupNode.order);for(let t=0;t<e.length;t++){const n=e[t];this.bindingsIndexes[n.name].group=t,n.index=t}}setHashNode(e,t){this.hashNodes[t]=e}addNode(e){this.nodes.includes(e)===!1&&(this.nodes.push(e),this.setHashNode(e,e.getHash(this)))}buildUpdateNodes(){for(const e of this.nodes){const t=e.getUpdateType(),n=e.getUpdateBeforeType(),i=e.getUpdateAfterType();t!==We.NONE&&this.updateNodes.push(e.getSelf()),n!==We.NONE&&this.updateBeforeNodes.push(e.getSelf()),i!==We.NONE&&this.updateAfterNodes.push(e.getSelf())}}get currentNode(){return this.chaining[this.chaining.length-1]}isFilteredTexture(e){return e.magFilter===Ut||e.magFilter===js||e.magFilter===Cs||e.magFilter===Jn||e.minFilter===Ut||e.minFilter===js||e.minFilter===Cs||e.minFilter===Jn}addChain(e){this.chaining.push(e)}removeChain(e){if(this.chaining.pop()!==e)throw new Error("NodeBuilder: Invalid node chaining!")}getMethod(e){return e}getNodeFromHash(e){return this.hashNodes[e]}addFlow(e,t){return this.flowNodes[e].push(t),t}setContext(e){this.context=e}getContext(){return this.context}getSharedContext(){return{...this.context},this.context}setCache(e){this.cache=e}getCache(){return this.cache}getCacheFromNode(e,t=!0){const n=this.getDataFromNode(e);return n.cache===void 0&&(n.cache=new Lu(t?this.getCache():null)),n.cache}isAvailable(){return!1}getVertexIndex(){console.warn("Abstract function.")}getInstanceIndex(){console.warn("Abstract function.")}getDrawIndex(){console.warn("Abstract function.")}getFrontFacing(){console.warn("Abstract function.")}getFragCoord(){console.warn("Abstract function.")}isFlipY(){return!1}increaseUsage(e){const t=this.getDataFromNode(e);return t.usageCount=t.usageCount===void 0?1:t.usageCount+1,t.usageCount}generateTexture(){console.warn("Abstract function.")}generateTextureLod(){console.warn("Abstract function.")}generateConst(e,t=null){if(t===null&&(e==="float"||e==="int"||e==="uint"?t=0:e==="bool"?t=!1:e==="color"?t=new _e:e==="vec2"?t=new J:e==="vec3"?t=new E:e==="vec4"&&(t=new st)),e==="float")return Mu(t);if(e==="int")return`${Math.round(t)}`;if(e==="uint")return t>=0?`${Math.round(t)}u`:"0u";if(e==="bool")return t?"true":"false";if(e==="color")return`${this.getType("vec3")}( ${Mu(t.r)}, ${Mu(t.g)}, ${Mu(t.b)} )`;const n=this.getTypeLength(e),i=this.getComponentType(e),r=o=>this.generateConst(i,o);if(n===2)return`${this.getType(e)}( ${r(t.x)}, ${r(t.y)} )`;if(n===3)return`${this.getType(e)}( ${r(t.x)}, ${r(t.y)}, ${r(t.z)} )`;if(n===4)return`${this.getType(e)}( ${r(t.x)}, ${r(t.y)}, ${r(t.z)}, ${r(t.w)} )`;if(n>4&&t&&(t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(r).join(", ")} )`;if(n>4)return`${this.getType(e)}()`;throw new Error(`NodeBuilder: Type '${e}' not found in generate constant attempt.`)}getType(e){return e==="color"?"vec3":e}hasGeometryAttribute(e){return this.geometry&&this.geometry.getAttribute(e)!==void 0}getAttribute(e,t){const n=this.attributes;for(const r of n)if(r.name===e)return r;const i=new If(e,t);return n.push(i),i}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return e==="void"||e==="property"||e==="sampler"||e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="depthTexture"||e==="texture3D"}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;if(e.isDataTexture){if(t===ma)return"int";if(t===Bi)return"uint"}return"float"}getElementType(e){return e==="mat2"?"vec2":e==="mat3"?"vec3":e==="mat4"?"vec4":this.getComponentType(e)}getComponentType(e){if(e=this.getVectorType(e),e==="float"||e==="bool"||e==="int"||e==="uint")return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return t===null?null:t[1]==="b"?"bool":t[1]==="i"?"int":t[1]==="u"?"uint":"float"}getVectorType(e){return e==="color"?"vec3":e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="texture3D"?"vec4":e}getTypeFromLength(e,t="float"){if(e===1)return t;const n=C3.get(e);return(t==="float"?"":t[0])+n}getTypeFromArray(e){return R3.get(e.constructor)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const n=t.array,i=e.itemSize,r=e.normalized;let o;return!(e instanceof zy)&&r!==!0&&(o=this.getTypeFromArray(n)),this.getTypeFromLength(i,o)}getTypeLength(e){const t=this.getVectorType(e),n=/vec([2-4])/.exec(t);return n!==null?Number(n[1]):t==="float"||t==="bool"||t==="int"||t==="uint"?1:/mat2/.test(e)===!0?4:/mat3/.test(e)===!0?9:/mat4/.test(e)===!0?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return t==="int"||t==="uint"?e:this.changeComponentType(e,"int")}addStack(){return this.stack=Du(this.stack),this.stacks.push(jm()||this.stack),Vc(this.stack),this.stack}removeStack(){const e=this.stack;return this.stack=e.parent,Vc(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,n=null){n=n===null?e.isGlobal(this)?this.globalCache:this.cache:n;let i=n.getData(e);return i===void 0&&(i={},n.setData(e,i)),i[t]===void 0&&(i[t]={}),i[t]}getNodeProperties(e,t="any"){const n=this.getDataFromNode(e,t);return n.properties||(n.properties={outputNode:null})}getBufferAttributeFromNode(e,t){const n=this.getDataFromNode(e);let i=n.bufferAttribute;if(i===void 0){const r=this.uniforms.index++;i=new If("nodeAttribute"+r,t,e),this.bufferAttributes.push(i),n.bufferAttribute=i}return i}getStructTypeFromNode(e,t=this.shaderStage){const n=this.getDataFromNode(e,t);if(n.structType===void 0){const i=this.structs.index++;e.name=`StructType${i}`,this.structs[t].push(e),n.structType=e}return e}getUniformFromNode(e,t,n=this.shaderStage,i=null){i==="in"&&(console.warn('NodeBuilder: "in" is a reserved word, using "inValue" instead.',e,i),e.name="inValue",i=e.name);const r=this.getDataFromNode(e,n,this.globalCache);let o=r.uniform;if(o===void 0){const a=this.uniforms.index++;o=new Mb(i||"nodeUniform"+a,t,e),this.uniforms[n].push(o),r.uniform=o}return o}getVarFromNode(e,t=null,n=e.getNodeType(this),i=this.shaderStage){const r=this.getDataFromNode(e,i);let o=r.variable;if(o===void 0){const a=this.vars[i]||(this.vars[i]=[]);t===null&&(t="nodeVar"+a.length),o=new Xg(t,n),a.push(o),r.variable=o}return o}getVaryingFromNode(e,t=null,n=e.getNodeType(this)){const i=this.getDataFromNode(e,"any");let r=i.varying;if(r===void 0){const o=this.varyings,a=o.length;t===null&&(t="nodeVarying"+a),r=new Sb(t,n),o.push(r),i.varying=r}return r}getCodeFromNode(e,t,n=this.shaderStage){const i=this.getDataFromNode(e);let r=i.code;if(r===void 0){const o=this.codes[n]||(this.codes[n]=[]),a=o.length;r=new Tb("nodeCode"+a,t),o.push(r),i.code=r}return r}addFlowCodeHierarchy(e,t){const{flowCodes:n,flowCodeBlock:i}=this.getDataFromNode(e);let r=!0,o=t;for(;o;){if(i.get(o)===!0){r=!1;break}o=this.getDataFromNode(o).parentNodeBlock}if(r)for(const a of n)this.addLineFlowCode(a)}addLineFlowCodeBlock(e,t,n){const i=this.getDataFromNode(e),r=i.flowCodes||(i.flowCodes=[]),o=i.flowCodeBlock||(i.flowCodeBlock=new WeakMap);r.push(t),o.set(n,!0)}addLineFlowCode(e,t=null){return e===""?this:(t!==null&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e=e+`;
3866
+ `).removeFlowTab();return e.addFlowTab(),o}}const mt=(...s)=>H(new PT(Yr(s,"int"))).append(),wL=()=>lr("continue").append(),Ld=()=>lr("break").append(),AL=(...s)=>(console.warn("TSL.LoopNode: loop() has been renamed to Loop()."),mt(...s)),Fp=new WeakMap,_i=new st,n_=U(({bufferMap:s,influence:e,stride:t,width:n,depth:i,offset:r})=>{const o=L(wT).mul(t).add(r),a=o.div(n),c=o.sub(a.mul(n));return Ci(s,ls(c,a)).depth(i).mul(e)});function NL(s){const e=s.morphAttributes.position!==void 0,t=s.morphAttributes.normal!==void 0,n=s.morphAttributes.color!==void 0,i=s.morphAttributes.position||s.morphAttributes.normal||s.morphAttributes.color,r=i!==void 0?i.length:0;let o=Fp.get(s);if(o===void 0||o.count!==r){let g=function(){x.dispose(),Fp.delete(s),s.removeEventListener("dispose",g)};o!==void 0&&o.texture.dispose();const a=s.morphAttributes.position||[],c=s.morphAttributes.normal||[],l=s.morphAttributes.color||[];let u=0;e===!0&&(u=1),t===!0&&(u=2),n===!0&&(u=3);let h=s.attributes.position.count*u,d=1;const p=4096;h>p&&(d=Math.ceil(h/p),h=p);const f=new Float32Array(h*d*4*r),x=new qc(f,h,d,r);x.type=Gn,x.needsUpdate=!0;const m=u*4;for(let y=0;y<r;y++){const _=a[y],v=c[y],I=l[y],T=h*d*4*y;for(let w=0;w<_.count;w++){const C=w*m;e===!0&&(_i.fromBufferAttribute(_,w),f[T+C+0]=_i.x,f[T+C+1]=_i.y,f[T+C+2]=_i.z,f[T+C+3]=0),t===!0&&(_i.fromBufferAttribute(v,w),f[T+C+4]=_i.x,f[T+C+5]=_i.y,f[T+C+6]=_i.z,f[T+C+7]=0),n===!0&&(_i.fromBufferAttribute(I,w),f[T+C+8]=_i.x,f[T+C+9]=_i.y,f[T+C+10]=_i.z,f[T+C+11]=I.itemSize===4?_i.w:1)}}o={count:r,texture:x,stride:u,size:new J(h,d)},Fp.set(s,o),s.addEventListener("dispose",g)}return o}class LT extends Ye{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=pe(1),this.updateType=We.OBJECT}setup(e){const{geometry:t}=e,n=t.morphAttributes.position!==void 0,i=t.hasAttribute("normal")&&t.morphAttributes.normal!==void 0,r=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,o=r!==void 0?r.length:0,{texture:a,stride:c,size:l}=NL(t);n===!0&&en.mulAssign(this.morphBaseInfluence),i===!0&&hi.mulAssign(this.morphBaseInfluence);const u=L(l.width);mt(o,({i:h})=>{const d=A(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?d.assign(Ci(this.mesh.morphTexture,ls(L(h).add(1),L(yl))).r):d.assign(dn("morphTargetInfluences","float").element(h).toVar()),n===!0&&en.addAssign(n_({bufferMap:a,influence:d,stride:c,width:u,depth:h,offset:L(0)})),i===!0&&hi.addAssign(n_({bufferMap:a,influence:d,stride:c,width:u,depth:h,offset:L(1)}))})}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((t,n)=>t+n,0)}}const DT=K(LT),EL=s=>s.sort((e,t)=>e.id-t.id),CL=(s,e)=>{for(const t of e)if(t.isAnalyticLightNode&&t.light.id===s)return t;return null},Op=new WeakMap;class UT extends Ye{static get type(){return"LightsNode"}constructor(e=[]){super("vec3"),this.totalDiffuseNode=D().toVar("totalDiffuse"),this.totalSpecularNode=D().toVar("totalSpecular"),this.outgoingLightNode=D().toVar("outgoingLight"),this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this.global=!0}getHash(e){if(this._lightNodesHash===null){this._lightNodes===null&&this.setupLightsNode(e);const t=[];for(const n of this._lightNodes)t.push(n.getHash());this._lightNodesHash="lights-"+t.join(",")}return this._lightNodesHash}analyze(e){const t=e.getDataFromNode(this);for(const n of t.nodes)n.build(e)}setupLightsNode(e){const t=[],n=this._lightNodes,i=EL(this._lights),r=e.renderer.nodes.library;for(const o of i)if(o.isNode)t.push(H(o));else{let a=null;if(n!==null&&(a=CL(o.id,n)),a===null){const c=r.getLightNodeClass(o.constructor);if(c===null){console.warn(`LightsNode.setupNodeLights: Light node not found for ${o.constructor.name}`);continue}let l=null;Op.has(o)?l=Op.get(o):(l=new c(o),Op.set(o,l)),t.push(l)}}this._lightNodes=t}setup(e){this._lightNodes===null&&this.setupLightsNode(e);const t=e.context,n=t.lightingModel;let i=this.outgoingLightNode;if(n){const{_lightNodes:r,totalDiffuseNode:o,totalSpecularNode:a}=this;t.outgoingLight=i;const c=e.addStack(),l=e.getDataFromNode(this);l.nodes=c.nodes,n.start(t,c,e);for(const g of r)g.build(e);n.indirect(t,c,e);const{backdrop:u,backdropAlpha:h}=t,{directDiffuse:d,directSpecular:p,indirectDiffuse:f,indirectSpecular:x}=t.reflectedLight;let m=d.add(f);u!==null&&(h!==null?m=D(h.mix(m,u)):m=D(u),t.material.transparent=!0),o.assign(m),a.assign(p.add(x)),i.assign(o.add(a)),n.finish(t,c,e),i=i.bypass(e.removeStack())}return i}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}}const FT=K(UT);class ho extends Ye{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}generate(){console.warn("Abstract function.")}}class OT extends ho{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class VT extends vg{static get type(){return"LightingContextNode"}constructor(e,t=null,n=null,i=null){super(e),this.lightingModel=t,this.backdropNode=n,this.backdropAlphaNode=i,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,n=D().toVar("directDiffuse"),i=D().toVar("directSpecular"),r=D().toVar("indirectDiffuse"),o=D().toVar("indirectSpecular"),a={directDiffuse:n,directSpecular:i,indirectDiffuse:r,indirectSpecular:o};return{radiance:D().toVar("radiance"),irradiance:D().toVar("irradiance"),iblIrradiance:D().toVar("iblIrradiance"),ambientOcclusion:A(1).toVar("ambientOcclusion"),reflectedLight:a,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const BT=K(VT);class zT extends ho{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let Ga,Ha;class sn extends Ye{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===sn.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=We.NONE;return(this.scope===sn.SIZE||this.scope===sn.VIEWPORT)&&(e=We.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===sn.VIEWPORT?t!==null?Ha.copy(t.viewport):(e.getViewport(Ha),Ha.multiplyScalar(e.getPixelRatio())):t!==null?(Ga.width=t.width,Ga.height=t.height):e.getDrawingBufferSize(Ga)}setup(){const e=this.scope;let t=null;return e===sn.SIZE?t=pe(Ga||(Ga=new J)):e===sn.VIEWPORT?t=pe(Ha||(Ha=new st)):t=z(Aa.div(da)),t}generate(e){if(this.scope===sn.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const n=e.getNodeProperties(da).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${n}.y - ${t}.y )`}return t}return super.generate(e)}}sn.COORDINATE="coordinate";sn.VIEWPORT="viewport";sn.SIZE="size";sn.UV="uv";const _r=fe(sn,sn.UV),da=fe(sn,sn.SIZE),Aa=fe(sn,sn.COORDINATE),Ls=fe(sn,sn.VIEWPORT),kT=Ls.zw,GT=Aa.sub(Ls.xy),RL=GT.div(kT),IL=U(()=>(console.warn('TSL.ViewportNode: "viewportResolution" is deprecated. Use "screenSize" instead.'),da),"vec2").once()(),PL=U(()=>(console.warn('TSL.ViewportNode: "viewportTopLeft" is deprecated. Use "screenUV" instead.'),_r),"vec2").once()(),LL=U(()=>(console.warn('TSL.ViewportNode: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.'),_r.flipY()),"vec2").once()(),Wa=new J;class vl extends gs{static get type(){return"ViewportTextureNode"}constructor(e=_r,t=null,n=null){n===null&&(n=new fm,n.minFilter=Jn),super(n,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=We.FRAME}updateBefore(e){const t=e.renderer;t.getDrawingBufferSize(Wa);const n=this.value;(n.image.width!==Wa.width||n.image.height!==Wa.height)&&(n.image.width=Wa.width,n.image.height=Wa.height,n.needsUpdate=!0);const i=n.generateMipmaps;n.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(n),n.generateMipmaps=i}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const DL=K(vl),HT=K(vl,null,null,{generateMipmaps:!0});let Vp=null;class WT extends vl{static get type(){return"ViewportDepthTextureNode"}constructor(e=_r,t=null){Vp===null&&(Vp=new ao),super(e,t,Vp)}}const Og=K(WT);class jn extends Ye{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===jn.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,n=this.valueNode;let i=null;if(t===jn.DEPTH_BASE)n!==null&&(i=qT().assign(n));else if(t===jn.DEPTH)e.isPerspectiveCamera?i=XT(Pn.z,Vo,Bo):i=rc(Pn.z,Vo,Bo);else if(t===jn.LINEAR_DEPTH)if(n!==null)if(e.isPerspectiveCamera){const r=Vg(n,Vo,Bo);i=rc(r,Vo,Bo)}else i=n;else i=rc(Pn.z,Vo,Bo);return i}}jn.DEPTH_BASE="depthBase";jn.DEPTH="depth";jn.LINEAR_DEPTH="linearDepth";const rc=(s,e,t)=>s.add(e).div(e.sub(t)),UL=(s,e,t)=>e.sub(t).mul(s).sub(e),XT=(s,e,t)=>e.add(s).mul(t).div(t.sub(e).mul(s)),Vg=(s,e,t)=>e.mul(t).div(t.sub(e).mul(s).sub(t)),qT=K(jn,jn.DEPTH_BASE),Bg=fe(jn,jn.DEPTH),Sh=K(jn,jn.LINEAR_DEPTH),FL=Sh(Og());Bg.assign=s=>qT(s);class ur extends Ye{static get type(){return"ClippingNode"}constructor(e=ur.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{localClipIntersection:n,localClippingCount:i,globalClippingCount:r}=t,o=r+i,a=n?o-i:o;return this.scope===ur.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(t.planes,o,a):this.setupDefault(t.planes,o,a)}setupAlphaToCoverage(e,t,n){return U(()=>{const i=ds(e),r=ai("float","distanceToPlane"),o=ai("float","distanceToGradient"),a=ai("float","clipOpacity");a.assign(1);let c;if(mt(n,({i:l})=>{c=i.element(l),r.assign(Pn.dot(c.xyz).negate().add(c.w)),o.assign(r.fwidth().div(2)),a.mulAssign(ti(o.negate(),o,r)),a.equal(0).discard()}),n<t){const l=ai("float","unionclipOpacity");l.assign(1),mt({start:n,end:t},({i:u})=>{c=i.element(u),r.assign(Pn.dot(c.xyz).negate().add(c.w)),o.assign(r.fwidth().div(2)),l.mulAssign(ti(o.negate(),o,r).oneMinus())}),a.mulAssign(l.oneMinus())}Ct.a.mulAssign(a),Ct.a.equal(0).discard()})()}setupDefault(e,t,n){return U(()=>{const i=ds(e);let r;if(mt(n,({i:o})=>{r=i.element(o),Pn.dot(r.xyz).greaterThan(r.w).discard()}),n<t){const o=ai("bool","clipped");o.assign(!0),mt({start:n,end:t},({i:a})=>{r=i.element(a),o.assign(Pn.dot(r.xyz).greaterThan(r.w).and(o))}),o.discard()}})()}}ur.ALPHA_TO_COVERAGE="alphaToCoverage";ur.DEFAULT="default";const OL=()=>H(new ur),VL=()=>H(new ur(ur.ALPHA_TO_COVERAGE));class Tt extends mn{static get type(){return"NodeMaterial"}constructor(){super(),this.isNodeMaterial=!0,this.type=this.constructor.type,this.forceSinglePass=!1,this.fog=!0,this.lights=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.positionNode=null,this.depthNode=null,this.shadowNode=null,this.shadowPositionNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null}customProgramCacheKey(){return this.type+Gm(this)}build(e){this.setup(e)}setupObserver(e){return new Bv(e)}setup(e){e.context.setupNormal=()=>this.setupNormal(e),e.addStack(),e.stack.outputNode=this.vertexNode||this.setupPosition(e),e.addFlow("vertex",e.removeStack()),e.addStack();let t;const n=this.setupClipping(e);if(this.depthWrite===!0&&this.setupDepth(e),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);const i=this.setupLighting(e);n!==null&&e.stack.add(n);const r=oe(i,Ct.a).max(0);if(t=this.setupOutput(e,r),sg.assign(t),this.outputNode!==null&&(t=this.outputNode),e.renderer.getRenderTarget()!==null){const a=e.renderer.getMRT(),c=this.mrtNode;a!==null?(t=a,c!==null&&(t=a.merge(c))):c!==null&&(t=c)}}else{let i=this.fragmentNode;i.isOutputStructNode!==!0&&(i=oe(i)),t=this.setupOutput(e,i)}e.stack.outputNode=t,e.addFlow("fragment",e.removeStack()),e.monitor=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;const{globalClippingCount:t,localClippingCount:n}=e.clippingContext;let i=null;if(t||n){const r=e.renderer.samples;this.alphaToCoverage&&r>1?i=VL():e.stack.add(OL())}return i}setupDepth(e){const{renderer:t}=e;let n=this.depthNode;if(n===null){const i="getMRT"in t&&t.getMRT();i&&i.has("depth")?n=i.get("depth"):t.logarithmicDepthBuffer===!0&&(n=wf().w.add(1).log2().mul(RS).mul(.5))}n!==null&&Bg.assign(n).append()}setupPosition(e){const{object:t}=e,n=t.geometry;if(e.addStack(),(n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&DT(t).append(),t.isSkinnedMesh===!0&&IT(t).append(),this.displacementMap){const r=Ki("displacementMap","texture"),o=Ki("displacementScale","float"),a=Ki("displacementBias","float");en.addAssign(hi.normalize().mul(r.x.mul(o).add(a)))}t.isBatchedMesh&&RT(t).append(),t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&ET(t).append(),this.positionNode!==null&&en.assign(this.positionNode);const i=wf();return e.context.vertex=e.removeStack(),e.context.mvp=i,i}setupDiffuseColor({object:e,geometry:t}){let n=this.colorNode?oe(this.colorNode):ha;this.vertexColors===!0&&t.hasAttribute("color")&&(n=oe(n.xyz.mul(vn("color","vec3")),n.a)),e.instanceColor&&(n=Zi("vec3","vInstanceColor").mul(n)),e.isBatchedMesh&&e._colorsTexture&&(n=Zi("vec3","vBatchColor").mul(n)),Ct.assign(n);const i=this.opacityNode?A(this.opacityNode):Pd;if(Ct.a.assign(Ct.a.mul(i)),this.alphaTestNode!==null||this.alphaTest>0){const r=this.alphaTestNode!==null?A(this.alphaTestNode):jS;Ct.a.lessThanEqual(r).discard()}this.transparent===!1&&this.blending===Ps&&this.alphaToCoverage===!1&&Ct.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?D(0):Ct.rgb}setupNormal(){return this.normalNode?D(this.normalNode):rT}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?Ki("envMap","cubeTexture"):Ki("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new zT(Ug)),t}setupLights(e){const t=[],n=this.setupEnvironment(e);n&&n.isLightingNode&&t.push(n);const i=this.setupLightMap(e);if(i&&i.isLightingNode&&t.push(i),this.aoNode!==null||e.material.aoMap){const o=this.aoNode!==null?this.aoNode:TT;t.push(new OT(o))}let r=this.lightsNode||e.lightsNode;return t.length>0&&(r=FT([...r.getLights(),...t])),r}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:n,backdropAlphaNode:i,emissiveNode:r}=this,a=this.lights===!0||this.lightsNode!==null?this.setupLights(e):null;let c=this.setupOutgoingLight(e);if(a&&a.getScope().getLights().length>0){const l=this.setupLightingModel(e);c=BT(a,l,n,i)}else n!==null&&(c=D(i!==null?it(c,n,i):n));return(r&&r.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(yf.assign(D(r||eT)),c=c.add(yf)),c}setupOutput(e,t){if(this.fog===!0){const n=e.fogNode;n&&(t=oe(n.mix(t.rgb,n.colorNode),t.a))}return t}setDefaultValues(e){for(const n in e){const i=e[n];this[n]===void 0&&(this[n]=i,i&&i.clone&&(this[n]=i.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const n in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,n)===void 0&&t[n].get!==void 0&&Object.defineProperty(this.constructor.prototype,n,t[n])}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{},nodes:{}});const n=mn.prototype.toJSON.call(this,e),i=Fc(this);n.inputNodes={};for(const{property:o,childNode:a}of i)n.inputNodes[o]=a.toJSON(e).uuid;function r(o){const a=[];for(const c in o){const l=o[c];delete l.metadata,a.push(l)}return a}if(t){const o=r(e.textures),a=r(e.images),c=r(e.nodes);o.length>0&&(n.textures=o),a.length>0&&(n.images=a),c.length>0&&(n.nodes=c)}return n}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.positionNode=e.positionNode,this.depthNode=e.depthNode,this.shadowNode=e.shadowNode,this.shadowPositionNode=e.shadowPositionNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}}const BL=new ya;class zL extends Tt{static get type(){return"InstancedPointsNodeMaterial"}constructor(e={}){super(),this.lights=!1,this.useAlphaToCoverage=!0,this.useColor=e.vertexColors,this.pointWidth=1,this.pointColorNode=null,this.pointWidthNode=null,this.setDefaultValues(BL),this.setValues(e)}setup(e){this.setupShaders(e),super.setup(e)}setupShaders({renderer:e}){const t=this.alphaToCoverage,n=this.useColor;this.vertexNode=U(()=>{const i=vn("instancePosition").xyz,r=oe(xs.mul(oe(i,1))),o=Ls.z.div(Ls.w),a=ci.mul(r),c=Nn.xy.toVar();return c.mulAssign(this.pointWidthNode?this.pointWidthNode:MT),c.assign(c.div(Ls.z)),c.y.assign(c.y.mul(o)),c.assign(c.mul(a.w)),a.addAssign(oe(c,0,0)),a})(),this.fragmentNode=U(()=>{const i=A(1).toVar(),r=xg(rt().mul(2).sub(1));if(t&&e.samples>1){const a=A(r.fwidth()).toVar();i.assign(ti(a.oneMinus(),a.add(1),r).oneMinus())}else r.greaterThan(1).discard();let o;return this.pointColorNode?o=this.pointColorNode:n?o=vn("instanceColor").mul(ha):o=ha,i.mulAssign(Pd),oe(o,i)})()}get alphaToCoverage(){return this.useAlphaToCoverage}set alphaToCoverage(e){this.useAlphaToCoverage!==e&&(this.useAlphaToCoverage=e,this.needsUpdate=!0)}}const kL=new Fn;class GL extends Tt{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.lights=!1,this.setDefaultValues(kL),this.setValues(e)}}const HL=new fd;class WL extends Tt{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.lights=!1,this.setDefaultValues(HL),this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode,t=this.dashScaleNode?A(this.dashScaleNode):Mh,n=this.dashSizeNode?A(this.dashSizeNode):Lg,i=this.dashSizeNode?A(this.dashGapNode):Dg;Kr.assign(n),Gc.assign(i);const r=Un(vn("lineDistance").mul(t));(e?r.add(e):r).mod(Kr.add(Gc)).greaterThan(Kr).discard()}}const XL=new fd;class qL extends Tt{static get type(){return"Line2NodeMaterial"}constructor(e={}){super(),this.lights=!1,this.setDefaultValues(XL),this.useAlphaToCoverage=!0,this.useColor=e.vertexColors,this.useDash=e.dashed,this.useWorldUnits=!1,this.dashOffset=0,this.lineWidth=1,this.lineColorNode=null,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setup(e){this.setupShaders(e),super.setup(e)}setupShaders({renderer:e}){const t=this.alphaToCoverage,n=this.useColor,i=this.dashed,r=this.worldUnits,o=U(({start:c,end:l})=>{const u=ci.element(2).element(2),p=ci.element(3).element(2).mul(-.5).div(u).sub(c.z).div(l.z.sub(c.z));return oe(it(c.xyz,l.xyz,p),l.w)}).setLayout({name:"trimSegment",type:"vec4",inputs:[{name:"start",type:"vec4"},{name:"end",type:"vec4"}]});this.vertexNode=U(()=>{const c=vn("instanceStart"),l=vn("instanceEnd"),u=oe(xs.mul(oe(c,1))).toVar("start"),h=oe(xs.mul(oe(l,1))).toVar("end");r&&(Zi("vec3","worldStart").assign(u.xyz),Zi("vec3","worldEnd").assign(h.xyz));const d=Ls.z.div(Ls.w),p=ci.element(2).element(3).equal(-1);Oe(p,()=>{Oe(u.z.lessThan(0).and(h.z.greaterThan(0)),()=>{h.assign(o({start:u,end:h}))}).ElseIf(h.z.lessThan(0).and(u.z.greaterThanEqual(0)),()=>{u.assign(o({start:h,end:u}))})});const f=ci.mul(u),x=ci.mul(h),m=f.xyz.div(f.w),g=x.xyz.div(x.w),y=g.xy.sub(m.xy).toVar();y.x.assign(y.x.mul(d)),y.assign(y.normalize());const _=oe().toVar();if(r){const v=h.xyz.sub(u.xyz).normalize(),I=it(u.xyz,h.xyz,.5).normalize(),T=v.cross(I).normalize(),w=v.cross(T),C=Zi("vec4","worldPos");C.assign(Nn.y.lessThan(.5).select(u,h));const F=Pu.mul(.5);C.addAssign(oe(Nn.x.lessThan(0).select(T.mul(F),T.mul(F).negate()),0)),i||(C.addAssign(oe(Nn.y.lessThan(.5).select(v.mul(F).negate(),v.mul(F)),0)),C.addAssign(oe(w.mul(F),0)),Oe(Nn.y.greaterThan(1).or(Nn.y.lessThan(0)),()=>{C.subAssign(oe(w.mul(2).mul(F),0))})),_.assign(ci.mul(C));const M=D().toVar();M.assign(Nn.y.lessThan(.5).select(m,g)),_.z.assign(M.z.mul(_.w))}else{const v=z(y.y,y.x.negate()).toVar("offset");y.x.assign(y.x.div(d)),v.x.assign(v.x.div(d)),v.assign(Nn.x.lessThan(0).select(v.negate(),v)),Oe(Nn.y.lessThan(0),()=>{v.assign(v.sub(y))}).ElseIf(Nn.y.greaterThan(1),()=>{v.assign(v.add(y))}),v.assign(v.mul(Pu)),v.assign(v.div(Ls.w)),_.assign(Nn.y.lessThan(.5).select(f,x)),v.assign(v.mul(_.w)),_.assign(_.add(oe(v,0,0)))}return _})();const a=U(({p1:c,p2:l,p3:u,p4:h})=>{const d=c.sub(u),p=h.sub(u),f=l.sub(c),x=d.dot(p),m=p.dot(f),g=d.dot(f),y=p.dot(p),v=f.dot(f).mul(y).sub(m.mul(m)),T=x.mul(m).sub(g.mul(y)).div(v).clamp(),w=x.add(m.mul(T)).div(y).clamp();return z(T,w)});this.fragmentNode=U(()=>{const c=rt();if(i){const h=this.offsetNode?A(this.offsetNodeNode):bf,d=this.dashScaleNode?A(this.dashScaleNode):Mh,p=this.dashSizeNode?A(this.dashSizeNode):Lg,f=this.dashSizeNode?A(this.dashGapNode):Dg;Kr.assign(p),Gc.assign(f);const x=vn("instanceDistanceStart"),m=vn("instanceDistanceEnd"),g=Nn.y.lessThan(.5).select(d.mul(x),Mh.mul(m)),y=Un(g.add(bf)),_=h?y.add(h):y;c.y.lessThan(-1).or(c.y.greaterThan(1)).discard(),_.mod(Kr.add(Gc)).greaterThan(Kr).discard()}const l=A(1).toVar("alpha");if(r){const h=Zi("vec3","worldStart"),d=Zi("vec3","worldEnd"),p=Zi("vec4","worldPos").xyz.normalize().mul(1e5),f=d.sub(h),x=a({p1:h,p2:d,p3:D(0,0,0),p4:p}),m=h.add(f.mul(x.x)),g=p.mul(x.y),v=m.sub(g).length().div(Pu);if(!i)if(t&&e.samples>1){const I=v.fwidth();l.assign(ti(I.negate().add(.5),I.add(.5),v).oneMinus())}else v.greaterThan(.5).discard()}else if(t&&e.samples>1){const h=c.x,d=c.y.greaterThan(0).select(c.y.sub(1),c.y.add(1)),p=h.mul(h).add(d.mul(d)),f=A(p.fwidth()).toVar("dlen");Oe(c.y.abs().greaterThan(1),()=>{l.assign(ti(f.oneMinus(),f.add(1),p).oneMinus())})}else Oe(c.y.abs().greaterThan(1),()=>{const h=c.x,d=c.y.greaterThan(0).select(c.y.sub(1),c.y.add(1));h.mul(h).add(d.mul(d)).greaterThan(1).discard()});let u;if(this.lineColorNode)u=this.lineColorNode;else if(n){const h=vn("instanceColorStart"),d=vn("instanceColorEnd");u=Nn.y.lessThan(.5).select(h,d).mul(ha)}else u=ha;return oe(u,l)})()}get worldUnits(){return this.useWorldUnits}set worldUnits(e){this.useWorldUnits!==e&&(this.useWorldUnits=e,this.needsUpdate=!0)}get dashed(){return this.useDash}set dashed(e){this.useDash!==e&&(this.useDash=e,this.needsUpdate=!0)}get alphaToCoverage(){return this.useAlphaToCoverage}set alphaToCoverage(e){this.useAlphaToCoverage!==e&&(this.useAlphaToCoverage=e,this.needsUpdate=!0)}}const $T=s=>H(s).mul(.5).add(.5),$L=s=>H(s).mul(2).sub(1),YL=new dd;class ZL extends Tt{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.lights=!1,this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(YL),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?A(this.opacityNode):Pd;Ct.assign(oe($T(Yt),e))}}class YT extends pt{static get type(){return"EquirectUVNode"}constructor(e=Eg){super("vec2"),this.dirNode=e}setup(){const e=this.dirNode,t=e.z.atan2(e.x).mul(1/(Math.PI*2)).add(.5),n=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return z(t,n)}}const zg=K(YT);class ZT extends qh{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){const n=t.minFilter,i=t.generateMipmaps;t.generateMipmaps=!0,this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const r=new _s(5,5,5),o=zg(Eg),a=new Tt;a.colorNode=xt(t,o,0),a.side=ln,a.blending=Fi;const c=new kt(r,a),l=new Jh;l.add(c),t.minFilter===Jn&&(t.minFilter=Ut);const u=new Xh(1,10,this),h=e.getMRT();return e.setMRT(null),u.update(e,l),e.setMRT(h),t.minFilter=n,t.currentGenerateMipmaps=i,c.geometry.dispose(),c.material.dispose(),this}}const oc=new WeakMap;class JL extends pt{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=Cd();const t=new so;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=We.RENDER}updateBefore(e){const{renderer:t,material:n}=e,i=this.envNode;if(i.isTextureNode||i.isMaterialReferenceNode){const r=i.isTextureNode?i.value:n[i.property];if(r&&r.isTexture){const o=r.mapping;if(o===ir||o===sr){if(oc.has(r)){const a=oc.get(r);i_(a,r.mapping),this._cubeTexture=a}else{const a=r.image;if(KL(a)){const c=new ZT(a.height);c.fromEquirectangularTexture(t,r),i_(c.texture,r.mapping),this._cubeTexture=c.texture,oc.set(r,c.texture),r.addEventListener("dispose",JT)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function KL(s){return s==null?!1:s.height>0}function JT(s){const e=s.target;e.removeEventListener("dispose",JT);const t=oc.get(e);t!==void 0&&(oc.delete(e),t.dispose())}function i_(s,e){e===ir?s.mapping=wi:e===sr&&(s.mapping=Vi)}const jL=K(JL);class Dd extends ho{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=jL(this.envNode)}}class QL extends ho{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=A(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class Ml{start(){}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class KT extends Ml{constructor(){super()}indirect(e,t,n){const i=e.ambientOcclusion,r=e.reflectedLight,o=n.context.irradianceLightMap;r.indirectDiffuse.assign(oe(0)),o?r.indirectDiffuse.addAssign(o):r.indirectDiffuse.addAssign(oe(1,1,1,0)),r.indirectDiffuse.mulAssign(i),r.indirectDiffuse.mulAssign(Ct.rgb)}finish(e,t,n){const i=n.material,r=e.outgoingLight,o=n.context.environment;if(o)switch(i.combine){case fa:r.rgb.assign(it(r.rgb,r.rgb.mul(o.rgb),sc.mul(Iu)));break;case Of:r.rgb.assign(it(r.rgb,o.rgb,sc.mul(Iu)));break;case Vf:r.rgb.addAssign(o.rgb.mul(sc.mul(Iu)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",i.combine);break}}}const e2=new ss;class t2 extends Tt{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(e2),this.setValues(e)}setupNormal(){return di}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new Dd(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new QL(Ug)),t}setupOutgoingLight(){return Ct.rgb}setupLightingModel(){return new KT}}const pa=U(({f0:s,f90:e,dotVH:t})=>{const n=t.mul(-5.55473).sub(6.98316).mul(t).exp2();return s.mul(n.oneMinus()).add(e.mul(n))}),no=U(s=>s.diffuseColor.mul(1/Math.PI)),n2=()=>A(.25),i2=U(({dotNH:s})=>ph.mul(A(.5)).add(1).mul(A(1/Math.PI)).mul(s.pow(ph))),s2=U(({lightDirection:s})=>{const e=s.add(Bt).normalize(),t=Yt.dot(e).clamp(),n=Bt.dot(e).clamp(),i=pa({f0:ri,f90:1,dotVH:n}),r=n2(),o=i2({dotNH:t});return i.mul(r).mul(o)});class kg extends KT{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:n}){const r=Yt.dot(e).clamp().mul(t);n.directDiffuse.addAssign(r.mul(no({diffuseColor:Ct.rgb}))),this.specular===!0&&n.directSpecular.addAssign(r.mul(s2({lightDirection:e})).mul(sc))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:n}){n.indirectDiffuse.addAssign(t.mul(no({diffuseColor:Ct}))),n.indirectDiffuse.mulAssign(e)}}const r2=new pd;class o2 extends Tt{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(r2),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new Dd(t):null}setupLightingModel(){return new kg(!1)}}const a2=new hd;class c2 extends Tt{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(a2),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new Dd(t):null}setupLightingModel(){return new kg}setupVariants(){const e=(this.shininessNode?A(this.shininessNode):QS).max(1e-4);ph.assign(e);const t=this.specularNode||tT;ri.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const jT=U(()=>{const s=di.dFdx().abs().max(di.dFdy().abs());return s.x.max(s.y).max(s.z)}),Gg=U(s=>{const{roughness:e}=s,t=jT();let n=e.max(.0525);return n=n.add(t),n=n.min(1),n}),QT=U(({alpha:s,dotNL:e,dotNV:t})=>{const n=s.pow2(),i=e.mul(n.add(n.oneMinus().mul(t.pow2())).sqrt()),r=t.mul(n.add(n.oneMinus().mul(e.pow2())).sqrt());return ns(.5,i.add(r).max(AM))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),l2=U(({alphaT:s,alphaB:e,dotTV:t,dotBV:n,dotTL:i,dotBL:r,dotNV:o,dotNL:a})=>{const c=a.mul(D(s.mul(t),e.mul(n),o).length()),l=o.mul(D(s.mul(i),e.mul(r),a).length());return ns(.5,c.add(l)).saturate()}).setLayout({name:"V_GGX_SmithCorrelated_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotTV",type:"float",qualifier:"in"},{name:"dotBV",type:"float",qualifier:"in"},{name:"dotTL",type:"float",qualifier:"in"},{name:"dotBL",type:"float",qualifier:"in"},{name:"dotNV",type:"float",qualifier:"in"},{name:"dotNL",type:"float",qualifier:"in"}]}),eb=U(({alpha:s,dotNH:e})=>{const t=s.pow2(),n=e.pow2().mul(t.oneMinus()).oneMinus();return t.div(n.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),u2=A(1/Math.PI),h2=U(({alphaT:s,alphaB:e,dotNH:t,dotTH:n,dotBH:i})=>{const r=s.mul(e),o=D(e.mul(n),s.mul(i),r.mul(t)),a=o.dot(o),c=r.div(a);return u2.mul(r.mul(c.pow2()))}).setLayout({name:"D_GGX_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotNH",type:"float",qualifier:"in"},{name:"dotTH",type:"float",qualifier:"in"},{name:"dotBH",type:"float",qualifier:"in"}]}),Af=U(s=>{const{lightDirection:e,f0:t,f90:n,roughness:i,f:r,USE_IRIDESCENCE:o,USE_ANISOTROPY:a}=s,c=s.normalView||Yt,l=i.pow2(),u=e.add(Bt).normalize(),h=c.dot(e).clamp(),d=c.dot(Bt).clamp(),p=c.dot(u).clamp(),f=Bt.dot(u).clamp();let x=pa({f0:t,f90:n,dotVH:f}),m,g;if(Oc(o)&&(x=wd.mix(x,r)),Oc(a)){const y=tc.dot(e),_=tc.dot(Bt),v=tc.dot(u),I=Jr.dot(e),T=Jr.dot(Bt),w=Jr.dot(u);m=l2({alphaT:dh,alphaB:l,dotTV:_,dotBV:T,dotTL:y,dotBL:I,dotNV:d,dotNL:h}),g=h2({alphaT:dh,alphaB:l,dotNH:p,dotTH:v,dotBH:w})}else m=QT({alpha:l,dotNL:h,dotNV:d}),g=eb({alpha:l,dotNH:p});return x.mul(m).mul(g)}),Hg=U(({roughness:s,dotNV:e})=>{const t=oe(-1,-.0275,-.572,.022),n=oe(1,.0425,1.04,-.04),i=s.mul(t).add(n),r=i.x.mul(i.x).min(e.mul(-9.28).exp2()).mul(i.x).add(i.y);return z(-1.04,1.04).mul(r).add(i.zw)}).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),tb=U(s=>{const{dotNV:e,specularColor:t,specularF90:n,roughness:i}=s,r=Hg({dotNV:e,roughness:i});return t.mul(r.x).add(n.mul(r.y))}),nb=U(({f:s,f90:e,dotVH:t})=>{const n=t.oneMinus().saturate(),i=n.mul(n),r=n.mul(i,i).clamp(0,.9999);return s.sub(D(e).mul(r)).div(r.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),d2=U(({roughness:s,dotNH:e})=>{const t=s.pow2(),n=A(1).div(t),r=e.pow2().oneMinus().max(.0078125);return A(2).add(n).mul(r.pow(n.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),p2=U(({dotNV:s,dotNL:e})=>A(1).div(A(4).mul(e.add(s).sub(e.mul(s))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),f2=U(({lightDirection:s})=>{const e=s.add(Bt).normalize(),t=Yt.dot(s).clamp(),n=Yt.dot(Bt).clamp(),i=Yt.dot(e).clamp(),r=d2({roughness:bd,dotNH:i}),o=p2({dotNV:n,dotNL:t});return Xr.mul(r).mul(o)}),m2=U(({N:s,V:e,roughness:t})=>{const r=.0078125,o=s.dot(e).saturate(),a=z(t,o.oneMinus().sqrt());return a.assign(a.mul(.984375).add(r)),a}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),g2=U(({f:s})=>{const e=s.length();return ft(e.mul(e).add(s.z).div(e.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),gu=U(({v1:s,v2:e})=>{const t=s.dot(e),n=t.abs().toVar(),i=n.mul(.0145206).add(.4965155).mul(n).add(.8543985).toVar(),r=n.add(4.1616724).mul(n).add(3.417594).toVar(),o=i.div(r),a=t.greaterThan(0).select(o,ft(t.mul(t).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(o));return s.cross(e).mul(a)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),s_=U(({N:s,V:e,P:t,mInv:n,p0:i,p1:r,p2:o,p3:a})=>{const c=r.sub(i).toVar(),l=a.sub(i).toVar(),u=c.cross(l),h=D().toVar();return Oe(u.dot(t.sub(i)).greaterThanEqual(0),()=>{const d=e.sub(s.mul(e.dot(s))).normalize(),p=s.cross(d).negate(),f=n.mul(Tn(d,p,s).transpose()).toVar(),x=f.mul(i.sub(t)).normalize().toVar(),m=f.mul(r.sub(t)).normalize().toVar(),g=f.mul(o.sub(t)).normalize().toVar(),y=f.mul(a.sub(t)).normalize().toVar(),_=D(0).toVar();_.addAssign(gu({v1:x,v2:m})),_.addAssign(gu({v1:m,v2:g})),_.addAssign(gu({v1:g,v2:y})),_.addAssign(gu({v1:y,v2:x})),h.assign(D(g2({f:_})))}),h}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"P",type:"vec3"},{name:"mInv",type:"mat3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),Ud=1/6,ib=s=>ot(Ud,ot(s,ot(s,s.negate().add(3)).sub(3)).add(1)),Nf=s=>ot(Ud,ot(s,ot(s,ot(3,s).sub(6))).add(4)),sb=s=>ot(Ud,ot(s,ot(s,ot(-3,s).add(3)).add(3)).add(1)),Ef=s=>ot(Ud,Kn(s,3)),r_=s=>ib(s).add(Nf(s)),o_=s=>sb(s).add(Ef(s)),a_=s=>Wt(-1,Nf(s).div(ib(s).add(Nf(s)))),c_=s=>Wt(1,Ef(s).div(sb(s).add(Ef(s)))),l_=(s,e,t)=>{const n=s.uvNode,i=ot(n,e.zw).add(.5),r=gr(i),o=xr(i),a=r_(o.x),c=o_(o.x),l=a_(o.x),u=c_(o.x),h=a_(o.y),d=c_(o.y),p=z(r.x.add(l),r.y.add(h)).sub(.5).mul(e.xy),f=z(r.x.add(u),r.y.add(h)).sub(.5).mul(e.xy),x=z(r.x.add(l),r.y.add(d)).sub(.5).mul(e.xy),m=z(r.x.add(u),r.y.add(d)).sub(.5).mul(e.xy),g=r_(o.y).mul(Wt(a.mul(s.uv(p).level(t)),c.mul(s.uv(f).level(t)))),y=o_(o.y).mul(Wt(a.mul(s.uv(x).level(t)),c.mul(s.uv(m).level(t))));return g.add(y)},rb=U(([s,e=A(3)])=>{const t=z(s.size(L(e))),n=z(s.size(L(e.add(1)))),i=ns(1,t),r=ns(1,n),o=l_(s,oe(i,t),gr(e)),a=l_(s,oe(r,n),fg(e));return xr(e).mix(o,a)}),u_=U(([s,e,t,n,i])=>{const r=D(_g(e.negate(),vi(s),ns(1,n))),o=D(jr(i[0].xyz),jr(i[1].xyz),jr(i[2].xyz));return vi(r).mul(t.mul(o))}).setLayout({name:"getVolumeTransmissionRay",type:"vec3",inputs:[{name:"n",type:"vec3"},{name:"v",type:"vec3"},{name:"thickness",type:"float"},{name:"ior",type:"float"},{name:"modelMatrix",type:"mat4"}]}),x2=U(([s,e])=>s.mul(cn(e.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),_2=HT(),h_=U(([s,e,t])=>{const n=_2.uv(s),i=al(A(da.x)).mul(x2(e,t));return rb(n,i)}),d_=U(([s,e,t])=>(Oe(t.notEqual(0),()=>{const n=pg(e).negate().div(t);return dg(n.negate().mul(s))}),D(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),y2=U(([s,e,t,n,i,r,o,a,c,l,u,h,d,p,f])=>{let x,m;if(f){x=oe().toVar(),m=D().toVar();const I=u.sub(1).mul(f.mul(.025)),T=D(u.sub(I),u,u.add(I));mt({start:0,end:3},({i:w})=>{const C=T.element(w),F=u_(s,e,h,C,a),M=o.add(F),b=l.mul(c.mul(oe(M,1))),G=z(b.xy.div(b.w)).toVar();G.addAssign(1),G.divAssign(2),G.assign(z(G.x,G.y.oneMinus()));const W=h_(G,t,C);x.element(w).assign(W.element(w)),x.a.addAssign(W.a),m.element(w).assign(n.element(w).mul(d_(jr(F),d,p).element(w)))}),x.a.divAssign(3)}else{const I=u_(s,e,h,u,a),T=o.add(I),w=l.mul(c.mul(oe(T,1))),C=z(w.xy.div(w.w)).toVar();C.addAssign(1),C.divAssign(2),C.assign(z(C.x,C.y.oneMinus())),x=h_(C,t,u),m=n.mul(d_(jr(I),d,p))}const g=m.rgb.mul(x.rgb),y=s.dot(e).clamp(),_=D(tb({dotNV:y,specularColor:i,specularF90:r,roughness:t})),v=m.r.add(m.g,m.b).div(3);return oe(_.oneMinus().mul(g),x.a.oneMinus().mul(v).oneMinus())}),v2=Tn(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),M2=s=>{const e=s.sqrt();return D(1).add(e).div(D(1).sub(e))},p_=(s,e)=>s.sub(e).div(s.add(e)).pow2(),S2=(s,e)=>{const t=s.mul(2*Math.PI*1e-9),n=D(54856e-17,44201e-17,52481e-17),i=D(1681e3,1795300,2208400),r=D(43278e5,93046e5,66121e5),o=A(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(t.mul(2239900).add(e.x).cos()).mul(t.pow2().mul(-45282e5).exp());let a=n.mul(r.mul(2*Math.PI).sqrt()).mul(i.mul(t).add(e).cos()).mul(t.pow2().negate().mul(r).exp());return a=D(a.x.add(o),a.y,a.z).div(10685e-11),v2.mul(a)},T2=U(({outsideIOR:s,eta2:e,cosTheta1:t,thinFilmThickness:n,baseF0:i})=>{const r=it(s,e,ti(0,.03,n)),o=s.div(r).pow2().mul(A(1).sub(t.pow2())),c=A(1).sub(o).sqrt(),l=p_(r,s),u=pa({f0:l,f90:1,dotVH:t}),h=u.oneMinus(),d=r.lessThan(s).select(Math.PI,0),p=A(Math.PI).sub(d),f=M2(i.clamp(0,.9999)),x=p_(f,r.toVec3()),m=pa({f0:x,f90:1,dotVH:c}),g=D(f.x.lessThan(r).select(Math.PI,0),f.y.lessThan(r).select(Math.PI,0),f.z.lessThan(r).select(Math.PI,0)),y=r.mul(n,c,2),_=D(p).add(g),v=u.mul(m).clamp(1e-5,.9999),I=v.sqrt(),T=h.pow2().mul(m).div(D(1).sub(v));let C=u.add(T),F=T.sub(h);for(let M=1;M<=2;++M){F=F.mul(I);const b=S2(A(M).mul(y),A(M).mul(_)).mul(2);C=C.add(F.mul(b))}return C.max(D(0))}).setLayout({name:"evalIridescence",type:"vec3",inputs:[{name:"outsideIOR",type:"float"},{name:"eta2",type:"float"},{name:"cosTheta1",type:"float"},{name:"thinFilmThickness",type:"float"},{name:"baseF0",type:"vec3"}]}),b2=U(({normal:s,viewDir:e,roughness:t})=>{const n=s.dot(e).saturate(),i=t.pow2(),r=In(t.lessThan(.25),A(-339.2).mul(i).add(A(161.4).mul(t)).sub(25.9),A(-8.48).mul(i).add(A(14.3).mul(t)).sub(9.95)),o=In(t.lessThan(.25),A(44).mul(i).sub(A(23.7).mul(t)).add(3.26),A(1.97).mul(i).sub(A(3.27).mul(t)).add(.72));return In(t.lessThan(.25),0,A(.1).mul(t).sub(.025)).add(r.mul(n).add(o).exp()).mul(1/Math.PI).saturate()}),Bp=D(.04),zp=A(1);class Fd extends Ml{constructor(e=!1,t=!1,n=!1,i=!1,r=!1,o=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=n,this.anisotropy=i,this.transmission=r,this.dispersion=o,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null}start(e){if(this.clearcoat===!0&&(this.clearcoatRadiance=D().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=D().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=D().toVar("clearcoatSpecularIndirect")),this.sheen===!0&&(this.sheenSpecularDirect=D().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=D().toVar("sheenSpecularIndirect")),this.iridescence===!0){const t=Yt.dot(Bt).clamp();this.iridescenceFresnel=T2({outsideIOR:A(1),eta2:ng,cosTheta1:t,thinFilmThickness:ig,baseF0:ri}),this.iridescenceF0=nb({f:this.iridescenceFresnel,f90:1,dotVH:t})}if(this.transmission===!0){const t=vh,n=Ng.sub(vh).normalize(),i=Cg;e.backdrop=y2(i,n,hs,Ct,ri,kc,t,Ui,pi,ci,nc,rg,ag,og,this.dispersion?cg:null),e.backdropAlpha=fh,Ct.a.mulAssign(it(1,e.backdrop.a,fh))}}computeMultiscattering(e,t,n){const i=Yt.dot(Bt).clamp(),r=Hg({roughness:hs,dotNV:i}),a=(this.iridescenceF0?wd.mix(ri,this.iridescenceF0):ri).mul(r.x).add(n.mul(r.y)),l=r.x.add(r.y).oneMinus(),u=ri.add(ri.oneMinus().mul(.047619)),h=a.mul(u).div(l.mul(u).oneMinus());e.addAssign(a),t.addAssign(h.mul(l))}direct({lightDirection:e,lightColor:t,reflectedLight:n}){const r=Yt.dot(e).clamp().mul(t);if(this.sheen===!0&&this.sheenSpecularDirect.addAssign(r.mul(f2({lightDirection:e}))),this.clearcoat===!0){const a=Xo.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(a.mul(Af({lightDirection:e,f0:Bp,f90:zp,roughness:zc,normalView:Xo})))}n.directDiffuse.addAssign(r.mul(no({diffuseColor:Ct.rgb}))),n.directSpecular.addAssign(r.mul(Af({lightDirection:e,f0:ri,f90:1,roughness:hs,iridescence:this.iridescence,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:n,halfHeight:i,reflectedLight:r,ltc_1:o,ltc_2:a}){const c=t.add(n).sub(i),l=t.sub(n).sub(i),u=t.sub(n).add(i),h=t.add(n).add(i),d=Yt,p=Bt,f=Pn.toVar(),x=m2({N:d,V:p,roughness:hs}),m=o.uv(x).toVar(),g=a.uv(x).toVar(),y=Tn(D(m.x,0,m.y),D(0,1,0),D(m.z,0,m.w)).toVar(),_=ri.mul(g.x).add(ri.oneMinus().mul(g.y)).toVar();r.directSpecular.addAssign(e.mul(_).mul(s_({N:d,V:p,P:f,mInv:y,p0:c,p1:l,p2:u,p3:h}))),r.directDiffuse.addAssign(e.mul(Ct).mul(s_({N:d,V:p,P:f,mInv:Tn(1,0,0,0,1,0,0,0,1),p0:c,p1:l,p2:u,p3:h})))}indirect(e,t,n){this.indirectDiffuse(e,t,n),this.indirectSpecular(e,t,n),this.ambientOcclusion(e,t,n)}indirectDiffuse({irradiance:e,reflectedLight:t}){t.indirectDiffuse.addAssign(e.mul(no({diffuseColor:Ct})))}indirectSpecular({radiance:e,iblIrradiance:t,reflectedLight:n}){if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(t.mul(Xr,b2({normal:Yt,viewDir:Bt,roughness:bd}))),this.clearcoat===!0){const l=Xo.dot(Bt).clamp(),u=tb({dotNV:l,specularColor:Bp,specularF90:zp,roughness:zc});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(u))}const i=D().toVar("singleScattering"),r=D().toVar("multiScattering"),o=t.mul(1/Math.PI);this.computeMultiscattering(i,r,kc);const a=i.add(r),c=Ct.mul(a.r.max(a.g).max(a.b).oneMinus());n.indirectSpecular.addAssign(e.mul(i)),n.indirectSpecular.addAssign(r.mul(o)),n.indirectDiffuse.addAssign(c.mul(o))}ambientOcclusion({ambientOcclusion:e,reflectedLight:t}){const i=Yt.dot(Bt).clamp().add(e),r=hs.mul(-16).oneMinus().negate().exp2(),o=e.sub(i.pow(r).oneMinus()).clamp();this.clearcoat===!0&&this.clearcoatSpecularIndirect.mulAssign(e),this.sheen===!0&&this.sheenSpecularIndirect.mulAssign(e),t.indirectDiffuse.mulAssign(e),t.indirectSpecular.mulAssign(o)}finish(e){const{outgoingLight:t}=e;if(this.clearcoat===!0){const n=Xo.dot(Bt).clamp(),i=pa({dotVH:n,f0:Bp,f90:zp}),r=t.mul(hh.mul(i).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(hh));t.assign(r)}if(this.sheen===!0){const n=Xr.r.max(Xr.g).max(Xr.b).mul(.157).oneMinus(),i=t.mul(n).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(i)}}}const f_=A(1),Cf=A(-2),xu=A(.8),kp=A(-1),_u=A(.4),Gp=A(2),yu=A(.305),Hp=A(3),m_=A(.21),w2=A(4),g_=A(4),A2=A(16),N2=U(([s])=>{const e=D(Dt(s)).toVar(),t=A(-1).toVar();return Oe(e.x.greaterThan(e.z),()=>{Oe(e.x.greaterThan(e.y),()=>{t.assign(In(s.x.greaterThan(0),0,3))}).Else(()=>{t.assign(In(s.y.greaterThan(0),1,4))})}).Else(()=>{Oe(e.z.greaterThan(e.y),()=>{t.assign(In(s.z.greaterThan(0),2,5))}).Else(()=>{t.assign(In(s.y.greaterThan(0),1,4))})}),t}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),E2=U(([s,e])=>{const t=z().toVar();return Oe(e.equal(0),()=>{t.assign(z(s.z,s.y).div(Dt(s.x)))}).ElseIf(e.equal(1),()=>{t.assign(z(s.x.negate(),s.z.negate()).div(Dt(s.y)))}).ElseIf(e.equal(2),()=>{t.assign(z(s.x.negate(),s.y).div(Dt(s.z)))}).ElseIf(e.equal(3),()=>{t.assign(z(s.z.negate(),s.y).div(Dt(s.x)))}).ElseIf(e.equal(4),()=>{t.assign(z(s.x.negate(),s.z).div(Dt(s.y)))}).Else(()=>{t.assign(z(s.x,s.y).div(Dt(s.z)))}),ot(.5,t.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),C2=U(([s])=>{const e=A(0).toVar();return Oe(s.greaterThanEqual(xu),()=>{e.assign(f_.sub(s).mul(kp.sub(Cf)).div(f_.sub(xu)).add(Cf))}).ElseIf(s.greaterThanEqual(_u),()=>{e.assign(xu.sub(s).mul(Gp.sub(kp)).div(xu.sub(_u)).add(kp))}).ElseIf(s.greaterThanEqual(yu),()=>{e.assign(_u.sub(s).mul(Hp.sub(Gp)).div(_u.sub(yu)).add(Gp))}).ElseIf(s.greaterThanEqual(m_),()=>{e.assign(yu.sub(s).mul(w2.sub(Hp)).div(yu.sub(m_)).add(Hp))}).Else(()=>{e.assign(A(-2).mul(al(ot(1.16,s))))}),e}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),ob=U(([s,e])=>{const t=s.toVar();t.assign(ot(2,t).sub(1));const n=D(t,1).toVar();return Oe(e.equal(0),()=>{n.assign(n.zyx)}).ElseIf(e.equal(1),()=>{n.assign(n.xzy),n.xz.mulAssign(-1)}).ElseIf(e.equal(2),()=>{n.x.mulAssign(-1)}).ElseIf(e.equal(3),()=>{n.assign(n.zyx),n.xz.mulAssign(-1)}).ElseIf(e.equal(4),()=>{n.assign(n.xzy),n.xy.mulAssign(-1)}).ElseIf(e.equal(5),()=>{n.z.mulAssign(-1)}),n}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),ab=U(([s,e,t,n,i,r])=>{const o=A(t),a=D(e),c=cn(C2(o),Cf,r),l=xr(c),u=gr(c),h=D(Rf(s,a,u,n,i,r)).toVar();return Oe(l.notEqual(0),()=>{const d=D(Rf(s,a,u.add(1),n,i,r)).toVar();h.assign(it(h,d,l))}),h}),Rf=U(([s,e,t,n,i,r])=>{const o=A(t).toVar(),a=D(e),c=A(N2(a)).toVar(),l=A(ft(g_.sub(o),0)).toVar();o.assign(ft(o,g_));const u=A(mh(o)).toVar(),h=z(E2(a,c).mul(u.sub(2)).add(1)).toVar();return Oe(c.greaterThan(2),()=>{h.y.addAssign(u),c.subAssign(3)}),h.x.addAssign(c.mul(u)),h.x.addAssign(l.mul(ot(3,A2))),h.y.addAssign(ot(4,mh(r).sub(u))),h.x.mulAssign(n),h.y.mulAssign(i),s.uv(h).grad(z(),z())}),Wp=U(({envMap:s,mipInt:e,outputDirection:t,theta:n,axis:i,CUBEUV_TEXEL_WIDTH:r,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:a})=>{const c=Mi(n),l=t.mul(c).add(i.cross(t).mul(Cn(n))).add(i.mul(i.dot(t).mul(c.oneMinus())));return Rf(s,l,e,r,o,a)}),cb=U(({n:s,latitudinal:e,poleAxis:t,outputDirection:n,weights:i,samples:r,dTheta:o,mipInt:a,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h})=>{const d=D(In(e,t,Qo(t,n))).toVar();Oe(hg(d.equals(D(0))),()=>{d.assign(D(n.z,0,n.x.negate()))}),d.assign(vi(d));const p=D().toVar();return p.addAssign(i.element(L(0)).mul(Wp({theta:0,axis:d,outputDirection:n,mipInt:a,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h}))),mt({start:L(1),end:s},({i:f})=>{Oe(f.greaterThanEqual(r),()=>{Ld()});const x=A(o.mul(A(f))).toVar();p.addAssign(i.element(f).mul(Wp({theta:x.mul(-1),axis:d,outputDirection:n,mipInt:a,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h}))),p.addAssign(i.element(f).mul(Wp({theta:x,axis:d,outputDirection:n,mipInt:a,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:h})))}),oe(p,1)});let Th=null;const x_=new WeakMap;function R2(s){const e=Math.log2(s)-2,t=1/s;return{texelWidth:1/(3*Math.max(Math.pow(2,e),112)),texelHeight:t,maxMip:e}}function I2(s){let e=x_.get(s);if((e!==void 0?e.pmremVersion:-1)!==s.pmremVersion){const n=s.image;if(s.isCubeTexture)if(P2(n))e=Th.fromCubemap(s,e);else return null;else if(L2(n))e=Th.fromEquirectangular(s,e);else return null;e.pmremVersion=s.pmremVersion,x_.set(s,e)}return e.texture}class lb extends pt{static get type(){return"PMREMNode"}constructor(e,t=null,n=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=n,this._generator=null;const i=new Xt;i.isRenderTargetTexture=!0,this._texture=xt(i),this._width=pe(0),this._height=pe(0),this._maxMip=pe(0),this.updateBeforeType=We.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=R2(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(){let e=this._pmrem;const t=e?e.pmremVersion:-1,n=this._value;t!==n.pmremVersion&&(n.isPMREMTexture===!0?e=n:e=I2(n),e!==null&&(this._pmrem=e,this.updateFromTexture(e)))}setup(e){Th===null&&(Th=e.createPMREMGenerator()),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this));const n=this.value;e.renderer.coordinateSystem===Di&&n.isPMREMTexture!==!0&&n.isRenderTargetTexture===!0&&(t=D(t.x.negate(),t.yz));let i=this.levelNode;return i===null&&e.context.getTextureLevel&&(i=e.context.getTextureLevel(this)),ab(this._texture,t,i,this._width,this._height,this._maxMip)}}function P2(s){if(s==null)return!1;let e=0;const t=6;for(let n=0;n<t;n++)s[n]!==void 0&&e++;return e===t}function L2(s){return s==null?!1:s.height>0}const ub=K(lb),__=new WeakMap;class hb extends ho{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let n=this.envNode;if(n.isTextureNode||n.isMaterialReferenceNode){const p=n.isTextureNode?n.value:t[n.property];let f=__.get(p);f===void 0&&(f=ub(p),__.set(p,f)),n=f}const r=t.envMap?dn("envMapIntensity","float",e.material):dn("environmentIntensity","float",e.scene),a=t.useAnisotropy===!0||t.anisotropy>0?YS:Yt,c=n.context(y_(hs,a)).mul(r),l=n.context(D2(Cg)).mul(Math.PI).mul(r),u=ic(c),h=ic(l);e.context.radiance.addAssign(u),e.context.iblIrradiance.addAssign(h);const d=e.context.lightingModel.clearcoatRadiance;if(d){const p=n.context(y_(zc,Xo)).mul(r),f=ic(p);d.addAssign(f)}}}const y_=(s,e)=>{let t=null;return{getUV:()=>(t===null&&(t=Bt.negate().reflect(e),t=s.mul(s).mix(t,e).normalize(),t=t.transformDirection(pi)),t),getTextureLevel:()=>s}},D2=s=>({getUV:()=>s,getTextureLevel:()=>A(1)}),U2=new nl;class db extends Tt{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(U2),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new hb(t):null}setupLightingModel(){return new Fd}setupSpecular(){const e=it(D(.04),Ct.rgb,Bc);ri.assign(e),kc.assign(1)}setupVariants(){const e=this.metalnessNode?A(this.metalnessNode):sT;Bc.assign(e);let t=this.roughnessNode?A(this.roughnessNode):iT;t=Gg({roughness:t}),hs.assign(t),this.setupSpecular(),Ct.assign(oe(Ct.rgb.mul(e.oneMinus()),Ct.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const F2=new ud;class pb extends db{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(F2),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||this.clearcoatNode!==null}get useIridescence(){return this.iridescence>0||this.iridescenceNode!==null}get useSheen(){return this.sheen>0||this.sheenNode!==null}get useAnisotropy(){return this.anisotropy>0||this.anisotropyNode!==null}get useTransmission(){return this.transmission>0||this.transmissionNode!==null}get useDispersion(){return this.dispersion>0||this.dispersionNode!==null}setupSpecular(){const e=this.iorNode?A(this.iorNode):_T;nc.assign(e),ri.assign(it(Mn(gg(nc.sub(1).div(nc.add(1))).mul(nT),D(1)).mul(Tf),Ct.rgb,Bc)),kc.assign(it(Tf,1,Bc))}setupLightingModel(){return new Fd(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const t=this.clearcoatNode?A(this.clearcoatNode):oT,n=this.clearcoatRoughnessNode?A(this.clearcoatRoughnessNode):aT;hh.assign(t),zc.assign(Gg({roughness:n}))}if(this.useSheen){const t=this.sheenNode?D(this.sheenNode):uT,n=this.sheenRoughnessNode?A(this.sheenRoughnessNode):hT;Xr.assign(t),bd.assign(n)}if(this.useIridescence){const t=this.iridescenceNode?A(this.iridescenceNode):pT,n=this.iridescenceIORNode?A(this.iridescenceIORNode):fT,i=this.iridescenceThicknessNode?A(this.iridescenceThicknessNode):mT;wd.assign(t),ng.assign(n),ig.assign(i)}if(this.useAnisotropy){const t=(this.anisotropyNode?z(this.anisotropyNode):dT).toVar();Ys.assign(t.length()),Oe(Ys.equal(0),()=>{t.assign(z(1,0))}).Else(()=>{t.divAssign(z(Ys)),Ys.assign(Ys.saturate())}),dh.assign(Ys.pow2().mix(hs.pow2(),1)),tc.assign(qr[0].mul(t.x).add(qr[1].mul(t.y))),Jr.assign(qr[1].mul(t.x).sub(qr[0].mul(t.y)))}if(this.useTransmission){const t=this.transmissionNode?A(this.transmissionNode):gT,n=this.thicknessNode?A(this.thicknessNode):xT,i=this.attenuationDistanceNode?A(this.attenuationDistanceNode):yT,r=this.attenuationColorNode?D(this.attenuationColorNode):vT;if(fh.assign(t),rg.assign(n),og.assign(i),ag.assign(r),this.useDispersion){const o=this.dispersionNode?A(this.dispersionNode):ST;cg.assign(o)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?D(this.clearcoatNormalNode):cT}setup(e){e.context.setupClearcoatNormal=()=>this.setupClearcoatNormal(e),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}class O2 extends Fd{constructor(e,t,n,i){super(e,t,n),this.useSSS=i}direct({lightDirection:e,lightColor:t,reflectedLight:n},i,r){if(this.useSSS===!0){const o=r.material,{thicknessColorNode:a,thicknessDistortionNode:c,thicknessAmbientNode:l,thicknessAttenuationNode:u,thicknessPowerNode:h,thicknessScaleNode:d}=o,p=e.add(Yt.mul(c)).normalize(),f=A(Bt.dot(p.negate()).saturate().pow(h).mul(d)),x=D(f.add(l).mul(a));n.directDiffuse.addAssign(x.mul(u.mul(t)))}super.direct({lightDirection:e,lightColor:t,reflectedLight:n},i,r)}}class V2 extends pb{static get type(){return"MeshSSSNodeMaterial"}constructor(e){super(e),this.thicknessColorNode=null,this.thicknessDistortionNode=A(.1),this.thicknessAmbientNode=A(0),this.thicknessAttenuationNode=A(.1),this.thicknessPowerNode=A(2),this.thicknessScaleNode=A(10)}get useSSS(){return this.thicknessColorNode!==null}setupLightingModel(){return new O2(this.useClearcoat,this.useSheen,this.useIridescence,this.useSSS)}copy(e){return this.thicknessColorNode=e.thicknessColorNode,this.thicknessDistortionNode=e.thicknessDistortionNode,this.thicknessAmbientNode=e.thicknessAmbientNode,this.thicknessAttenuationNode=e.thicknessAttenuationNode,this.thicknessPowerNode=e.thicknessPowerNode,this.thicknessScaleNode=e.thicknessScaleNode,super.copy(e)}}const B2=U(({normal:s,lightDirection:e,builder:t})=>{const n=s.dot(e),i=z(n.mul(.5).add(.5),0);if(t.material.gradientMap){const r=Ki("gradientMap","texture").context({getUV:()=>i});return D(r.r)}else{const r=i.fwidth().mul(.5);return it(D(.7),D(1),ti(A(.7).sub(r.x),A(.7).add(r.x),i.x))}});class z2 extends Ml{direct({lightDirection:e,lightColor:t,reflectedLight:n},i,r){const o=B2({normal:Nd,lightDirection:e,builder:r}).mul(t);n.directDiffuse.addAssign(o.mul(no({diffuseColor:Ct.rgb})))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:n}){n.indirectDiffuse.addAssign(t.mul(no({diffuseColor:Ct}))),n.indirectDiffuse.mulAssign(e)}}const k2=new wm;class G2 extends Tt{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(k2),this.setValues(e)}setupLightingModel(){return new z2}}class fb extends pt{static get type(){return"MatcapUVNode"}constructor(){super("vec2")}setup(){const e=D(Bt.z,0,Bt.x.negate()).normalize(),t=Bt.cross(e);return z(e.dot(Yt),t.dot(Yt)).mul(.495).add(.5)}}const mb=fe(fb),H2=new Am;class W2 extends Tt{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.lights=!1,this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(H2),this.setValues(e)}setupVariants(e){const t=mb;let n;e.material.matcap?n=Ki("matcap","texture").context({getUV:()=>t}):n=D(it(.2,.8,t.y)),Ct.rgb.mulAssign(n.rgb)}}const X2=new ya;class q2 extends Tt{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.isPointsNodeMaterial=!0,this.lights=!1,this.transparent=!0,this.sizeNode=null,this.setDefaultValues(X2),this.setValues(e)}copy(e){return this.sizeNode=e.sizeNode,super.copy(e)}}class gb extends pt{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:n}=this;if(this.getNodeType(e)==="vec2"){const r=t.cos(),o=t.sin();return ol(r,o,o.negate(),r).mul(n)}else{const r=t,o=Zr(oe(1,0,0,0),oe(0,Mi(r.x),Cn(r.x).negate(),0),oe(0,Cn(r.x),Mi(r.x),0),oe(0,0,0,1)),a=Zr(oe(Mi(r.y),0,Cn(r.y),0),oe(0,1,0,0),oe(Cn(r.y).negate(),0,Mi(r.y),0),oe(0,0,0,1)),c=Zr(oe(Mi(r.z),Cn(r.z).negate(),0,0),oe(Cn(r.z),Mi(r.z),0,0),oe(0,0,1,0),oe(0,0,0,1));return o.mul(a).mul(c).mul(oe(n,1)).xyz}}}const Wg=K(gb),$2=new Zc;class Y2 extends Tt{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this.lights=!1,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.setDefaultValues($2),this.setValues(e)}setupPosition({object:e,camera:t,context:n}){const i=this.sizeAttenuation,{positionNode:r,rotationNode:o,scaleNode:a}=this,c=en;let l=xs.mul(D(r||0)),u=z(Ui[0].xyz.length(),Ui[1].xyz.length());a!==null&&(u=u.mul(a)),!i&&t.isPerspectiveCamera&&(u=u.mul(l.z.negate()));let h=c.xy;if(e.center&&e.center.isVector2===!0){const x=XP("center","vec2");h=h.sub(x.sub(.5))}h=h.mul(u);const d=A(o||lT),p=Wg(h,d);l=oe(l.xy.add(p),l.zw);const f=ci.mul(l);return n.vertex=c,f}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}class Z2 extends Ml{constructor(){super(),this.shadowNode=A(1).toVar("shadowMask")}direct({shadowMask:e}){this.shadowNode.mulAssign(e)}finish(e){Ct.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(Ct.rgb)}}const J2=new ld;class K2 extends Tt{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.setDefaultValues(J2),this.setValues(e)}setupLightingModel(){return new Z2}}const j2=U(({texture:s,uv:e})=>{const n=D().toVar();return Oe(e.x.lessThan(1e-4),()=>{n.assign(D(1,0,0))}).ElseIf(e.y.lessThan(1e-4),()=>{n.assign(D(0,1,0))}).ElseIf(e.z.lessThan(1e-4),()=>{n.assign(D(0,0,1))}).ElseIf(e.x.greaterThan(1-1e-4),()=>{n.assign(D(-1,0,0))}).ElseIf(e.y.greaterThan(1-1e-4),()=>{n.assign(D(0,-1,0))}).ElseIf(e.z.greaterThan(1-1e-4),()=>{n.assign(D(0,0,-1))}).Else(()=>{const r=s.uv(e.add(D(-.01,0,0))).r.sub(s.uv(e.add(D(.01,0,0))).r),o=s.uv(e.add(D(0,-.01,0))).r.sub(s.uv(e.add(D(0,.01,0))).r),a=s.uv(e.add(D(0,0,-.01))).r.sub(s.uv(e.add(D(0,0,.01))).r);n.assign(D(r,o,a))}),n.normalize()});class xb extends gs{static get type(){return"Texture3DNode"}constructor(e,t=null,n=null){super(e,t,n),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return D(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){return t}generateUV(e,t){return t.build(e,"vec3")}normal(e){return j2({texture:this,uv:e})}}const _b=K(xb);class Q2 extends Tt{static get type(){return"VolumeNodeMaterial"}constructor(e={}){super(),this.lights=!1,this.isVolumeNodeMaterial=!0,this.testNode=null,this.setValues(e)}setup(e){const t=_b(this.map,null,0),n=U(({orig:i,dir:r})=>{const o=D(-.5),a=D(.5),c=r.reciprocal(),l=o.sub(i).mul(c),u=a.sub(i).mul(c),h=Mn(l,u),d=ft(l,u),p=ft(h.x,ft(h.y,h.z)),f=Mn(d.x,Mn(d.y,d.z));return z(p,f)});this.fragmentNode=U(()=>{const i=Un(D(PS.mul(oe(Ng,1)))),o=Un(Nn.sub(i)).normalize(),a=z(n({orig:i,dir:o})).toVar();a.x.greaterThan(a.y).discard(),a.assign(z(ft(a.x,0),a.y));const c=D(i.add(a.x.mul(o))).toVar(),l=D(o.abs().reciprocal()).toVar(),u=A(Mn(l.x,Mn(l.y,l.z))).toVar("delta");u.divAssign(Ki("steps","float"));const h=oe(Ki("base","color"),0).toVar();return mt({type:"float",start:a.x,end:a.y,update:"+= delta"},()=>{const d=ai("float","d").assign(t.uv(c.add(.5)).r);this.testNode!==null?this.testNode({map:t,mapValue:d,probe:c,finalColor:h}).append():(h.a.assign(1),Ld()),c.addAssign(o.mul(u))}),h.a.equal(0).discard(),oe(h)})(),super.setup(e)}}class yb extends Xn{constructor(e){super(e),this.textures={},this.nodes={}}load(e,t,n,i){const r=new ts(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,o=>{try{t(this.parse(JSON.parse(o)))}catch(a){i?i(a):console.error(a),this.manager.itemError(e)}},n,i)}parseNodes(e){const t={};if(e!==void 0){for(const i of e){const{uuid:r,type:o}=i;t[r]=this.createNodeFromType(o),t[r].uuid=r}const n={nodes:t,textures:this.textures};for(const i of e)i.meta=n,t[i.uuid].deserialize(i),delete i.meta}return t}parse(e){const t=this.createNodeFromType(e.type);t.uuid=e.uuid;const i={nodes:this.parseNodes(e.nodes),textures:this.textures};return e.meta=i,t.deserialize(e),delete e.meta,t}setTextures(e){return this.textures=e,this}setNodes(e){return this.nodes=e,this}createNodeFromType(e){return this.nodes[e]===void 0?(console.error("THREE.NodeLoader: Node type not found:",e),A()):H(new this.nodes[e])}}class vb extends sl{constructor(e){super(e),this.nodes={},this.nodeMaterials={}}parse(e){const t=super.parse(e),n=this.nodes,i=e.inputNodes;for(const r in i){const o=i[r];t[r]=n[o]}return t}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}createMaterialFromType(e){const t=this.nodeMaterials[e];return t!==void 0?new t:super.createMaterialFromType(e)}}class e3 extends xv{constructor(e){super(e),this.nodes={},this.nodeMaterials={},this._nodesJSON=null}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}parse(e,t){this._nodesJSON=e.nodes;const n=super.parse(e,t);return this._nodesJSON=null,n}parseNodes(e,t){if(e!==void 0){const n=new yb;return n.setNodes(this.nodes),n.setTextures(t),n.parseNodes(e)}return{}}parseMaterials(e,t){const n={};if(e!==void 0){const i=this.parseNodes(this._nodesJSON,t),r=new vb;r.setTextures(t),r.setNodes(i),r.setNodeMaterials(this.nodeMaterials);for(let o=0,a=e.length;o<a;o++){const c=e[o];n[c.uuid]=r.parse(c)}}return n}}class If{constructor(e,t,n=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=n}}class Mb{constructor(e,t,n){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=n.getSelf()}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class Xg{constructor(e,t){this.isNodeVar=!0,this.name=e,this.type=t}}class Sb extends Xg{constructor(e,t){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0}}class Tb{constructor(e,t,n=""){this.name=e,this.type=t,this.code=n,Object.defineProperty(this,"isNodeCode",{value:!0})}}let t3=0;class Lu{constructor(e=null){this.id=t3++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return t===void 0&&this.parent!==null&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class qg extends Nt{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}const n3=(s,e)=>H(new qg(s,e));class $g extends Ye{static get type(){return"CodeNode"}constructor(e="",t=[],n=""){super("code"),this.isCodeNode=!0,this.code=e,this.language=n,this.includes=t}isGlobal(){return!0}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const i of t)i.build(e);const n=e.getCodeFromNode(this,this.getNodeType(e));return n.code=this.code,n.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}const Od=K($g),i3=(s,e)=>Od(s,e,"js"),s3=(s,e)=>Od(s,e,"wgsl"),r3=(s,e)=>Od(s,e,"glsl");class Yg extends $g{static get type(){return"FunctionNode"}constructor(e="",t=[],n=""){super(e,t,n)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let n=t.nodeFunction;return n===void 0&&(n=e.parser.parseFunction(this.code),t.nodeFunction=n),n}generate(e,t){super.generate(e);const n=this.getNodeFunction(e),i=n.name,r=n.type,o=e.getCodeFromNode(this,r);i!==""&&(o.name=i);const a=e.getPropertyName(o),c=this.getNodeFunction(e).getCode(a);return o.code=c+`
3867
+ `,t==="property"?a:e.format(`${a}()`,r,t)}}const bb=(s,e=[],t="")=>{for(let r=0;r<e.length;r++){const o=e[r];typeof o=="function"&&(e[r]=o.functionNode)}const n=H(new Yg(s,e,t)),i=(...r)=>n.call(...r);return i.functionNode=n,i},o3=(s,e)=>bb(s,e,"glsl"),a3=(s,e)=>bb(s,e,"wgsl");class po{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0}setValue(e){this.value=e}getValue(){return this.value}}class c3 extends po{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class l3 extends po{constructor(e,t=new J){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class u3 extends po{constructor(e,t=new E){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class h3 extends po{constructor(e,t=new st){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class d3 extends po{constructor(e,t=new _e){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class p3 extends po{constructor(e,t=new Ke){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class f3 extends po{constructor(e,t=new Fe){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class m3 extends c3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class g3 extends l3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class x3 extends u3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class _3 extends h3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class y3 extends d3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class v3 extends p3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class M3 extends f3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class wb extends Ye{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}add(e){return this.nodes.push(e),this}If(e,t){const n=new ec(t);return this._currentCond=In(e,n),this.add(this._currentCond)}ElseIf(e,t){const n=new ec(t),i=In(e,n);return this._currentCond.elseNode=i,this._currentCond=i,this}Else(e){return this._currentCond.elseNode=new ec(e),this}build(e,...t){const n=jm();Vc(this);for(const i of this.nodes)i.build(e,"void");return Vc(n),this.outputNode?this.outputNode.build(e,...t):super.build(e,...t)}else(...e){return console.warn("TSL.StackNode: .else() has been renamed to .Else()."),this.Else(...e)}elseif(...e){return console.warn("TSL.StackNode: .elseif() has been renamed to .ElseIf()."),this.ElseIf(...e)}}const Du=K(wb);class S3{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let n=0;n<e.length;n++)if(t=t.get(e[n]),t===void 0)return;return t.get(e[e.length-1])}set(e,t){let n=this.weakMap;for(let i=0;i<e.length;i++){const r=e[i];n.has(r)===!1&&n.set(r,new WeakMap),n=n.get(r)}return n.set(e[e.length-1],t)}delete(e){let t=this.weakMap;for(let n=0;n<e.length;n++)if(t=t.get(e[n]),t===void 0)return!1;return t.delete(e[e.length-1])}}const qo=4,v_=[.125,.215,.35,.446,.526,.582],Br=20,Xp=new oo(-1,1,1,-1,0,1),T3=new hn(90,1),M_=new _e;let qp=null,$p=0,Yp=0;const Or=(1+Math.sqrt(5))/2,Do=1/Or,S_=[new E(-Or,Do,0),new E(Or,Do,0),new E(-Do,0,Or),new E(Do,0,Or),new E(0,Or,-Do),new E(0,Or,Do),new E(-1,1,-1),new E(1,1,-1),new E(-1,1,1),new E(1,1,1)],b3=[3,1,5,0,4,2],Zp=ob(rt(),vn("faceIndex")).normalize(),Zg=D(Zp.x,Zp.y.negate(),Zp.z);class w3{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}fromScene(e,t=0,n=.1,i=100){qp=this._renderer.getRenderTarget(),$p=this._renderer.getActiveCubeFace(),Yp=this._renderer.getActiveMipmapLevel(),this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(e,n,i,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=b_(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=w_(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(qp,$p,Yp),e.scissorTest=!1,vu(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===wi||e.mapping===Vi?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),qp=this._renderer.getRenderTarget(),$p=this._renderer.getActiveCubeFace(),Yp=this._renderer.getActiveMipmapLevel();const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Ut,minFilter:Ut,generateMipmaps:!1,type:Ln,format:Rn,colorSpace:li},i=T_(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=T_(e,t,n);const{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas,lodMeshes:this._lodMeshes}=A3(r)),this._blurMaterial=N3(r,e,t)}return i}async _compileMaterial(e){const t=new kt(this._lodPlanes[0],e);await this._renderer.compile(t,Xp)}_sceneToCubeUV(e,t,n,i){const r=T3;r.near=t,r.far=n;const o=[-1,1,-1,-1,-1,-1],a=[1,1,1,-1,-1,-1],c=this._renderer,l=c.autoClear;c.getClearColor(M_),c.autoClear=!1;let u=this._backgroundBox;if(u===null){const p=new ss({name:"PMREM.Background",side:ln,depthWrite:!1,depthTest:!1});u=new kt(new _s,p)}let h=!1;const d=e.background;d?d.isColor&&(u.material.color.copy(d),e.background=null,h=!0):(u.material.color.copy(M_),h=!0),c.setRenderTarget(i),c.clear(),h&&c.render(u,r);for(let p=0;p<6;p++){const f=p%3;f===0?(r.up.set(0,o[p],0),r.lookAt(a[p],0,0)):f===1?(r.up.set(0,0,o[p]),r.lookAt(0,a[p],0)):(r.up.set(0,o[p],0),r.lookAt(0,0,a[p]));const x=this._cubeSize;vu(i,f*x,p>2?x:0,x,x),c.render(e,r)}c.autoClear=l,e.background=d}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===wi||e.mapping===Vi;i?this._cubemapMaterial===null&&(this._cubemapMaterial=b_(e)):this._equirectMaterial===null&&(this._equirectMaterial=w_(e));const r=i?this._cubemapMaterial:this._equirectMaterial;r.fragmentNode.value=e;const o=this._lodMeshes[0];o.material=r;const a=this._cubeSize;vu(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(o,Xp)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const i=this._lodPlanes.length;for(let r=1;r<i;r++){const o=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),a=S_[(i-r-1)%S_.length];this._blur(e,r-1,r,o,a)}t.autoClear=n}_blur(e,t,n,i,r){const o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,i,"latitudinal",r),this._halfBlur(o,e,n,n,i,"longitudinal",r)}_halfBlur(e,t,n,i,r,o,a){const c=this._renderer,l=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const u=3,h=this._lodMeshes[i];h.material=l;const d=l.uniforms,p=this._sizeLods[n]-1,f=isFinite(r)?Math.PI/(2*p):2*Math.PI/(2*Br-1),x=r/f,m=isFinite(r)?1+Math.floor(u*x):Br;m>Br&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Br}`);const g=[];let y=0;for(let w=0;w<Br;++w){const C=w/x,F=Math.exp(-C*C/2);g.push(F),w===0?y+=F:w<m&&(y+=2*F)}for(let w=0;w<g.length;w++)g[w]=g[w]/y;e.texture.frame=(e.texture.frame||0)+1,d.envMap.value=e.texture,d.samples.value=m,d.weights.array=g,d.latitudinal.value=o==="latitudinal"?1:0,a&&(d.poleAxis.value=a);const{_lodMax:_}=this;d.dTheta.value=f,d.mipInt.value=_-n;const v=this._sizeLods[i],I=3*v*(i>_-qo?i-_+qo:0),T=4*(this._cubeSize-v);vu(t,I,T,3*v,2*v),c.setRenderTarget(t),c.render(h,Xp)}}function A3(s){const e=[],t=[],n=[],i=[];let r=s;const o=s-qo+1+v_.length;for(let a=0;a<o;a++){const c=Math.pow(2,r);t.push(c);let l=1/c;a>s-qo?l=v_[a-s+qo-1]:a===0&&(l=0),n.push(l);const u=1/(c-2),h=-u,d=1+u,p=[h,h,d,h,d,d,h,h,d,d,h,d],f=6,x=6,m=3,g=2,y=1,_=new Float32Array(m*x*f),v=new Float32Array(g*x*f),I=new Float32Array(y*x*f);for(let w=0;w<f;w++){const C=w%3*2/3-1,F=w>2?0:-1,M=[C,F,0,C+2/3,F,0,C+2/3,F+1,0,C,F,0,C+2/3,F+1,0,C,F+1,0],b=b3[w];_.set(M,m*x*b),v.set(p,g*x*b);const G=[b,b,b,b,b,b];I.set(G,y*x*b)}const T=new at;T.setAttribute("position",new At(_,m)),T.setAttribute("uv",new At(v,g)),T.setAttribute("faceIndex",new At(I,y)),e.push(T),i.push(new kt(T,null)),r>qo&&r--}return{lodPlanes:e,sizeLods:t,sigmas:n,lodMeshes:i}}function T_(s,e,t){const n=new fn(s,e,t);return n.texture.mapping=hr,n.texture.name="PMREM.cubeUv",n.texture.isPMREMTexture=!0,n.scissorTest=!0,n}function vu(s,e,t,n,i){s.viewport.set(e,t,n,i),s.scissor.set(e,t,n,i)}function Jg(s){const e=new Tt;return e.depthTest=!1,e.depthWrite=!1,e.blending=Fi,e.name=`PMREM_${s}`,e}function N3(s,e,t){const n=ds(new Array(Br).fill(0)),i=pe(new E(0,1,0)),r=pe(0),o=A(Br),a=pe(0),c=pe(1),l=xt(null),u=pe(0),h=A(1/e),d=A(1/t),p=A(s),f={n:o,latitudinal:a,weights:n,poleAxis:i,outputDirection:Zg,dTheta:r,samples:c,envMap:l,mipInt:u,CUBEUV_TEXEL_WIDTH:h,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:p},x=Jg("blur");return x.uniforms=f,x.fragmentNode=cb({...f,latitudinal:a.equal(1)}),x}function b_(s){const e=Jg("cubemap");return e.fragmentNode=Cd(s,Zg),e}function w_(s){const e=Jg("equirect");return e.fragmentNode=xt(s,zg(Zg),0),e}let E3=0;class A_{constructor(e="",t=[],n=0,i=[]){this.name=e,this.bindings=t,this.index=n,this.bindingsReference=i,this.id=E3++}}const N_=new WeakMap,C3=new Map([[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),R3=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),Mu=s=>(s=Number(s),s+(s%1?"":".0"));class Ab{constructor(e,t,n){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=n,this.scene=null,this.camera=null,this.nodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.monitor=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.flow={code:""},this.chaining=[],this.stack=Du(),this.stacks=[],this.tab=" ",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new Lu,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.useComparisonMethod=!1}getBindGroupsCache(){let e=N_.get(this.renderer);return e===void 0&&(e=new S3,N_.set(this.renderer,e)),e}createRenderTarget(e,t,n){return new fn(e,t,n)}createCubeRenderTarget(e,t){return new ZT(e,t)}createPMREMGenerator(){return new w3(this.renderer)}includes(e){return this.nodes.includes(e)}_getBindGroup(e,t){const n=this.getBindGroupsCache(),i=[];let r=!0;for(const a of t)i.push(a),r=r&&a.groupNode.shared!==!0;let o;return r?(o=n.get(i),o===void 0&&(o=new A_(e,i,this.bindingsIndexes[e].group,i),n.set(i,o))):o=new A_(e,i,this.bindingsIndexes[e].group,i),o}getBindGroupArray(e,t){const n=this.bindings[t];let i=n[e];return i===void 0&&(this.bindingsIndexes[e]===void 0&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),n[e]=i=[]),i}getBindings(){let e=this.bindGroups;if(e===null){const t={},n=this.bindings;for(const i of xf)for(const r in n[i]){const o=n[i][r];(t[r]||(t[r]=[])).push(...o)}e=[];for(const i in t){const r=t[i],o=this._getBindGroup(i,r);e.push(o)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort((t,n)=>t.bindings[0].groupNode.order-n.bindings[0].groupNode.order);for(let t=0;t<e.length;t++){const n=e[t];this.bindingsIndexes[n.name].group=t,n.index=t}}setHashNode(e,t){this.hashNodes[t]=e}addNode(e){this.nodes.includes(e)===!1&&(this.nodes.push(e),this.setHashNode(e,e.getHash(this)))}buildUpdateNodes(){for(const e of this.nodes){const t=e.getUpdateType(),n=e.getUpdateBeforeType(),i=e.getUpdateAfterType();t!==We.NONE&&this.updateNodes.push(e.getSelf()),n!==We.NONE&&this.updateBeforeNodes.push(e.getSelf()),i!==We.NONE&&this.updateAfterNodes.push(e.getSelf())}}get currentNode(){return this.chaining[this.chaining.length-1]}isFilteredTexture(e){return e.magFilter===Ut||e.magFilter===js||e.magFilter===Cs||e.magFilter===Jn||e.minFilter===Ut||e.minFilter===js||e.minFilter===Cs||e.minFilter===Jn}addChain(e){this.chaining.push(e)}removeChain(e){if(this.chaining.pop()!==e)throw new Error("NodeBuilder: Invalid node chaining!")}getMethod(e){return e}getNodeFromHash(e){return this.hashNodes[e]}addFlow(e,t){return this.flowNodes[e].push(t),t}setContext(e){this.context=e}getContext(){return this.context}getSharedContext(){return{...this.context},this.context}setCache(e){this.cache=e}getCache(){return this.cache}getCacheFromNode(e,t=!0){const n=this.getDataFromNode(e);return n.cache===void 0&&(n.cache=new Lu(t?this.getCache():null)),n.cache}isAvailable(){return!1}getVertexIndex(){console.warn("Abstract function.")}getInstanceIndex(){console.warn("Abstract function.")}getDrawIndex(){console.warn("Abstract function.")}getFrontFacing(){console.warn("Abstract function.")}getFragCoord(){console.warn("Abstract function.")}isFlipY(){return!1}increaseUsage(e){const t=this.getDataFromNode(e);return t.usageCount=t.usageCount===void 0?1:t.usageCount+1,t.usageCount}generateTexture(){console.warn("Abstract function.")}generateTextureLod(){console.warn("Abstract function.")}generateConst(e,t=null){if(t===null&&(e==="float"||e==="int"||e==="uint"?t=0:e==="bool"?t=!1:e==="color"?t=new _e:e==="vec2"?t=new J:e==="vec3"?t=new E:e==="vec4"&&(t=new st)),e==="float")return Mu(t);if(e==="int")return`${Math.round(t)}`;if(e==="uint")return t>=0?`${Math.round(t)}u`:"0u";if(e==="bool")return t?"true":"false";if(e==="color")return`${this.getType("vec3")}( ${Mu(t.r)}, ${Mu(t.g)}, ${Mu(t.b)} )`;const n=this.getTypeLength(e),i=this.getComponentType(e),r=o=>this.generateConst(i,o);if(n===2)return`${this.getType(e)}( ${r(t.x)}, ${r(t.y)} )`;if(n===3)return`${this.getType(e)}( ${r(t.x)}, ${r(t.y)}, ${r(t.z)} )`;if(n===4)return`${this.getType(e)}( ${r(t.x)}, ${r(t.y)}, ${r(t.z)}, ${r(t.w)} )`;if(n>4&&t&&(t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(r).join(", ")} )`;if(n>4)return`${this.getType(e)}()`;throw new Error(`NodeBuilder: Type '${e}' not found in generate constant attempt.`)}getType(e){return e==="color"?"vec3":e}hasGeometryAttribute(e){return this.geometry&&this.geometry.getAttribute(e)!==void 0}getAttribute(e,t){const n=this.attributes;for(const r of n)if(r.name===e)return r;const i=new If(e,t);return n.push(i),i}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return e==="void"||e==="property"||e==="sampler"||e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="depthTexture"||e==="texture3D"}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;if(e.isDataTexture){if(t===ma)return"int";if(t===Bi)return"uint"}return"float"}getElementType(e){return e==="mat2"?"vec2":e==="mat3"?"vec3":e==="mat4"?"vec4":this.getComponentType(e)}getComponentType(e){if(e=this.getVectorType(e),e==="float"||e==="bool"||e==="int"||e==="uint")return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return t===null?null:t[1]==="b"?"bool":t[1]==="i"?"int":t[1]==="u"?"uint":"float"}getVectorType(e){return e==="color"?"vec3":e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="texture3D"?"vec4":e}getTypeFromLength(e,t="float"){if(e===1)return t;const n=C3.get(e);return(t==="float"?"":t[0])+n}getTypeFromArray(e){return R3.get(e.constructor)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const n=t.array,i=e.itemSize,r=e.normalized;let o;return!(e instanceof zy)&&r!==!0&&(o=this.getTypeFromArray(n)),this.getTypeFromLength(i,o)}getTypeLength(e){const t=this.getVectorType(e),n=/vec([2-4])/.exec(t);return n!==null?Number(n[1]):t==="float"||t==="bool"||t==="int"||t==="uint"?1:/mat2/.test(e)===!0?4:/mat3/.test(e)===!0?9:/mat4/.test(e)===!0?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return t==="int"||t==="uint"?e:this.changeComponentType(e,"int")}addStack(){return this.stack=Du(this.stack),this.stacks.push(jm()||this.stack),Vc(this.stack),this.stack}removeStack(){const e=this.stack;return this.stack=e.parent,Vc(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,n=null){n=n===null?e.isGlobal(this)?this.globalCache:this.cache:n;let i=n.getData(e);return i===void 0&&(i={},n.setData(e,i)),i[t]===void 0&&(i[t]={}),i[t]}getNodeProperties(e,t="any"){const n=this.getDataFromNode(e,t);return n.properties||(n.properties={outputNode:null})}getBufferAttributeFromNode(e,t){const n=this.getDataFromNode(e);let i=n.bufferAttribute;if(i===void 0){const r=this.uniforms.index++;i=new If("nodeAttribute"+r,t,e),this.bufferAttributes.push(i),n.bufferAttribute=i}return i}getStructTypeFromNode(e,t=this.shaderStage){const n=this.getDataFromNode(e,t);if(n.structType===void 0){const i=this.structs.index++;e.name=`StructType${i}`,this.structs[t].push(e),n.structType=e}return e}getUniformFromNode(e,t,n=this.shaderStage,i=null){i==="in"&&(console.warn('NodeBuilder: "in" is a reserved word, using "inValue" instead.',e,i),e.name="inValue",i=e.name);const r=this.getDataFromNode(e,n,this.globalCache);let o=r.uniform;if(o===void 0){const a=this.uniforms.index++;o=new Mb(i||"nodeUniform"+a,t,e),this.uniforms[n].push(o),r.uniform=o}return o}getVarFromNode(e,t=null,n=e.getNodeType(this),i=this.shaderStage){const r=this.getDataFromNode(e,i);let o=r.variable;if(o===void 0){const a=this.vars[i]||(this.vars[i]=[]);t===null&&(t="nodeVar"+a.length),o=new Xg(t,n),a.push(o),r.variable=o}return o}getVaryingFromNode(e,t=null,n=e.getNodeType(this)){const i=this.getDataFromNode(e,"any");let r=i.varying;if(r===void 0){const o=this.varyings,a=o.length;t===null&&(t="nodeVarying"+a),r=new Sb(t,n),o.push(r),i.varying=r}return r}getCodeFromNode(e,t,n=this.shaderStage){const i=this.getDataFromNode(e);let r=i.code;if(r===void 0){const o=this.codes[n]||(this.codes[n]=[]),a=o.length;r=new Tb("nodeCode"+a,t),o.push(r),i.code=r}return r}addFlowCodeHierarchy(e,t){const{flowCodes:n,flowCodeBlock:i}=this.getDataFromNode(e);let r=!0,o=t;for(;o;){if(i.get(o)===!0){r=!1;break}o=this.getDataFromNode(o).parentNodeBlock}if(r)for(const a of n)this.addLineFlowCode(a)}addLineFlowCodeBlock(e,t,n){const i=this.getDataFromNode(e),r=i.flowCodes||(i.flowCodes=[]),o=i.flowCodeBlock||(i.flowCodeBlock=new WeakMap);r.push(t),o.set(n,!0)}addLineFlowCode(e,t=null){return e===""?this:(t!==null&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e=e+`;
3868
3868
  `),this.flow.code+=e,this)}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+=" ",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){const t=e.getNodeType(this),n=this.flowChildNode(e,t);return this.flowsData.set(e,n),n}buildFunctionNode(e){const t=new Yg,n=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=n,t}flowShaderNode(e){const t=e.layout,n={[Symbol.iterator](){let o=0;const a=Object.values(this);return{next:()=>({value:a[o],done:o++>=a.length})}}};for(const o of t.inputs)n[o.name]=new qg(o.type,o.name);e.layout=null;const i=e.call(n),r=this.flowStagesNode(i,t.type);return e.layout=t,r}flowStagesNode(e,t=null){const n=this.flow,i=this.vars,r=this.cache,o=this.buildStage,a=this.stack,c={code:""};this.flow=c,this.vars={},this.cache=new Lu,this.stack=Du();for(const l of gf)this.setBuildStage(l),c.result=e.build(this,t);return c.vars=this.getVars(this.shaderStage),this.flow=n,this.vars=i,this.cache=r,this.stack=a,this.setBuildStage(o),c}getFunctionOperator(){return null}flowChildNode(e,t=null){const n=this.flow,i={code:""};return this.flow=i,i.result=e.build(this,t),this.flow=n,i}flowNodeFromShaderStage(e,t,n=null,i=null){const r=this.shaderStage;this.setShaderStage(e);const o=this.flowChildNode(t,n);return i!==null&&(o.code+=`${this.tab+i} = ${o.result};
3869
3869
  `),this.flowCode[e]=this.flowCode[e]+o.code,this.setShaderStage(r),o}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){console.warn("Abstract function.")}getVaryings(){console.warn("Abstract function.")}getVar(e,t){return`${this.getType(e)} ${t}`}getVars(e){let t="";const n=this.vars[e];if(n!==void 0)for(const i of n)t+=`${this.getVar(i.type,i.name)}; `;return t}getUniforms(){console.warn("Abstract function.")}getCodes(e){const t=this.codes[e];let n="";if(t!==void 0)for(const i of t)n+=i.code+`
3870
3870
  `;return n}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){console.warn("Abstract function.")}build(){const{object:e,material:t,renderer:n}=this;if(t!==null){let i=n.nodes.library.fromMaterial(t);i===null&&(console.error(`NodeMaterial: Material "${t.type}" is not compatible.`),i=new Tt),i.build(this)}else this.addFlow("compute",e);for(const i of gf){this.setBuildStage(i),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(const r of xf){this.setShaderStage(r);const o=this.flowNodes[r];for(const a of o)i==="generate"?this.flowNode(a):a.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getNodeUniform(e,t){if(t==="float"||t==="int"||t==="uint")return new m3(e);if(t==="vec2"||t==="ivec2"||t==="uvec2")return new g3(e);if(t==="vec3"||t==="ivec3"||t==="uvec3")return new x3(e);if(t==="vec4"||t==="ivec4"||t==="uvec4")return new _3(e);if(t==="color")return new y3(e);if(t==="mat3")return new v3(e);if(t==="mat4")return new M3(e);throw new Error(`Uniform "${t}" not declared.`)}createNodeMaterial(e="NodeMaterial"){throw new Error(`THREE.NodeBuilder: createNodeMaterial() was deprecated. Use new ${e}() instead.`)}format(e,t,n){if(t=this.getVectorType(t),n=this.getVectorType(n),t===n||n===null||this.isReference(n))return e;const i=this.getTypeLength(t),r=this.getTypeLength(n);return i===16&&r===9?`${this.getType(n)}(${e}[0].xyz, ${e}[1].xyz, ${e}[2].xyz)`:i===9&&r===4?`${this.getType(n)}(${e}[0].xy, ${e}[1].xy)`:i>4||r>4||r===0?e:i===r?`${this.getType(n)}( ${e} )`:i>r?this.format(`${e}.${"xyz".slice(0,r)}`,this.getTypeFromLength(r,this.getComponentType(t)),n):r===4&&i>1?`${this.getType(n)}( ${this.format(e,t,"vec3")}, 1.0 )`:i===2?`${this.getType(n)}( ${this.format(e,t,"vec2")}, 0.0 )`:(i===1&&r>1&&t!==this.getComponentType(n)&&(e=`${this.getType(this.getComponentType(n))}( ${e} )`),`${this.getType(n)}( ${e} )`)}getSignature(){return`// Three.js r${Ks} - Node System
3871
- `}}class Nb{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.startTime=null,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let n=e.get(t);return n===void 0&&(n={renderMap:new WeakMap,frameMap:new WeakMap},e.set(t,n)),n}updateBeforeNode(e){const t=e.getUpdateBeforeType(),n=e.updateReference(this);if(t===We.FRAME){const{frameMap:i}=this._getMaps(this.updateBeforeMap,n);i.get(n)!==this.frameId&&e.updateBefore(this)!==!1&&i.set(n,this.frameId)}else if(t===We.RENDER){const{renderMap:i}=this._getMaps(this.updateBeforeMap,n);i.get(n)!==this.renderId&&e.updateBefore(this)!==!1&&i.set(n,this.renderId)}else t===We.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),n=e.updateReference(this);if(t===We.FRAME){const{frameMap:i}=this._getMaps(this.updateAfterMap,n);i.get(n)!==this.frameId&&e.updateAfter(this)!==!1&&i.set(n,this.frameId)}else if(t===We.RENDER){const{renderMap:i}=this._getMaps(this.updateAfterMap,n);i.get(n)!==this.renderId&&e.updateAfter(this)!==!1&&i.set(n,this.renderId)}else t===We.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),n=e.updateReference(this);if(t===We.FRAME){const{frameMap:i}=this._getMaps(this.updateMap,n);i.get(n)!==this.frameId&&e.update(this)!==!1&&i.set(n,this.frameId)}else if(t===We.RENDER){const{renderMap:i}=this._getMaps(this.updateMap,n);i.get(n)!==this.renderId&&e.update(this)!==!1&&i.set(n,this.renderId)}else t===We.OBJECT&&e.update(this)}update(){this.frameId++,this.lastTime===void 0&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class Kg{constructor(e,t,n=null,i="",r=!1){this.type=e,this.name=t,this.count=n,this.qualifier=i,this.isConst=r}}Kg.isNodeFunctionInput=!0;class I3 extends Ye{static get type(){return"StructTypeNode"}constructor(e){super(),this.types=e,this.isStructTypeNode=!0}getMemberTypes(){return this.types}}class jg extends Ye{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}setup(e){super.setup(e);const t=this.members,n=[];for(let i=0;i<t.length;i++)n.push(t[i].getNodeType(e));this.nodeType=e.getStructTypeFromNode(new I3(n)).name}generate(e,t){const n=e.getOutputStructName(),i=this.members,r=n!==""?n+".":"";for(let o=0;o<i.length;o++){const a=i[o].build(e,t);e.addLineFlowCode(`${r}m${o} = ${a}`,this)}return n}}const P3=K(jg);function Qg(s,e){for(let t=0;t<s.length;t++)if(s[t].name===e)return t;return-1}class Eb extends jg{static get type(){return"MRTNode"}constructor(e){super(),this.outputNodes=e,this.isMRTNode=!0}has(e){return this.outputNodes[e]!==void 0}get(e){return this.outputNodes[e]}merge(e){const t={...this.outputNodes,...e.outputNodes};return Vd(t)}setup(e){const t=this.outputNodes,n=e.renderer.getRenderTarget(),i=[],r=n.textures;for(const o in t){const a=Qg(r,o);i[a]=oe(t[o])}return this.members=i,super.setup(e)}}const Vd=K(Eb);class Cb extends Ye{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(e){const t=this.parametersNodes;let n=this._candidateFnCall;if(n===null){let i=null,r=-1;for(const o of this.functionNodes){const c=o.shaderNode.layout;if(c===null)throw new Error("FunctionOverloadingNode: FunctionNode must be a layout.");const l=c.inputs;if(t.length===l.length){let u=0;for(let h=0;h<t.length;h++){const d=t[h],p=l[h];d.getNodeType(e)===p.type?u++:u=0}u>r&&(i=o,r=u)}}this._candidateFnCall=n=i(...t)}return n}}const L3=K(Cb),On=s=>(...e)=>L3(s,...e);class Sn extends uo{static get type(){return"TimerNode"}constructor(e=Sn.LOCAL,t=1,n=0){super(n),this.scope=e,this.scale=t,this.updateType=We.FRAME}update(e){const t=this.scope,n=this.scale;t===Sn.LOCAL?this.value+=e.deltaTime*n:t===Sn.DELTA?this.value=e.deltaTime*n:t===Sn.FRAME?this.value=e.frameId:this.value=e.time*n}serialize(e){super.serialize(e),e.scope=this.scope,e.scale=this.scale}deserialize(e){super.deserialize(e),this.scope=e.scope,this.scale=e.scale}}Sn.LOCAL="local";Sn.GLOBAL="global";Sn.DELTA="delta";Sn.FRAME="frame";const e0=(s,e=0)=>H(new Sn(Sn.LOCAL,s,e)),D3=(s,e=0)=>H(new Sn(Sn.GLOBAL,s,e)),U3=(s,e=0)=>H(new Sn(Sn.DELTA,s,e)),F3=fe(Sn,Sn.FRAME).toUint();class pn extends Ye{static get type(){return"OscNode"}constructor(e=pn.SINE,t=e0()){super(),this.method=e,this.timeNode=t}getNodeType(e){return this.timeNode.getNodeType(e)}setup(){const e=this.method,t=H(this.timeNode);let n=null;return e===pn.SINE?n=t.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5):e===pn.SQUARE?n=t.fract().round():e===pn.TRIANGLE?n=t.add(.5).fract().mul(2).sub(1).abs():e===pn.SAWTOOTH&&(n=t.fract()),n}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}pn.SINE="sine";pn.SQUARE="square";pn.TRIANGLE="triangle";pn.SAWTOOTH="sawtooth";const O3=K(pn,pn.SINE),V3=K(pn,pn.SQUARE),B3=K(pn,pn.TRIANGLE),z3=K(pn,pn.SAWTOOTH);class Rb extends Ye{static get type(){return"SpriteSheetUVNode"}constructor(e,t=rt(),n=A(0)){super("vec2"),this.countNode=e,this.uvNode=t,this.frameNode=n}setup(){const{frameNode:e,uvNode:t,countNode:n}=this,{width:i,height:r}=n,o=e.mod(i.mul(r)).floor(),a=o.mod(i),c=r.sub(o.add(1).div(i).ceil()),l=n.reciprocal(),u=z(a,c);return t.add(u).mul(l)}}const k3=K(Rb);class Ib extends fr{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}setup(e){return e.isAvailable("storageBuffer")===!1&&this.node.bufferObject===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let n;const i=e.context.assign;if(e.isAvailable("storageBuffer")===!1?this.node.bufferObject===!0&&i!==!0?n=e.generatePBO(this):n=this.node.build(e):n=super.generate(e),i!==!0){const r=this.getNodeType(e);n=e.format(n,r,t)}return n}}const G3=K(Ib);class Pb extends Ye{static get type(){return"TriplanarTexturesNode"}constructor(e,t=null,n=null,i=A(1),r=en,o=hi){super("vec4"),this.textureXNode=e,this.textureYNode=t,this.textureZNode=n,this.scaleNode=i,this.positionNode=r,this.normalNode=o}setup(){const{textureXNode:e,textureYNode:t,textureZNode:n,scaleNode:i,positionNode:r,normalNode:o}=this;let a=o.abs().normalize();a=a.div(a.dot(D(1)));const c=r.yz.mul(i),l=r.zx.mul(i),u=r.xy.mul(i),h=e.value,d=t!==null?t.value:h,p=n!==null?n.value:h,f=xt(h,c).mul(a.x),x=xt(d,l).mul(a.y),m=xt(p,u).mul(a.z);return Wt(f,x,m)}}const Lb=K(Pb),H3=(...s)=>Lb(...s),Uo=new cs,Ir=new E,Fo=new E,Jp=new E,Xa=new Fe,Su=new E(0,0,-1),Ns=new st,qa=new E,Tu=new E,$a=new st,bu=new J,E_=new fn,W3=xr.flipX();let Kp=!1;class Db extends gs{static get type(){return"ReflectorNode"}constructor(e={}){super(E_.texture,W3);const{target:t=new yt,resolution:n=1,generateMipmaps:i=!1,bounces:r=!0}=e;this.target=t,this.resolution=n,this.generateMipmaps=i,this.bounces=r,this.updateBeforeType=r?We.RENDER:We.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new WeakMap}_updateResolution(e,t){const n=this.resolution;t.getDrawingBufferSize(bu),e.setSize(Math.round(bu.width*n),Math.round(bu.height*n))}setup(e){return this._updateResolution(E_,e.renderer),super.setup(e)}getTextureNode(){return this.textureNode}getVirtualCamera(e){let t=this.virtualCameras.get(e);return t===void 0&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return t===void 0&&(t=new fn(0,0,{type:Ln}),this.generateMipmaps===!0&&(t.texture.minFilter=uy,t.texture.generateMipmaps=!0),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&Kp)return!1;Kp=!0;const{scene:t,camera:n,renderer:i,material:r}=e,{target:o}=this,a=this.getVirtualCamera(n),c=this.getRenderTarget(a);if(i.getDrawingBufferSize(bu),this._updateResolution(c,i),Fo.setFromMatrixPosition(o.matrixWorld),Jp.setFromMatrixPosition(n.matrixWorld),Xa.extractRotation(o.matrixWorld),Ir.set(0,0,1),Ir.applyMatrix4(Xa),qa.subVectors(Fo,Jp),qa.dot(Ir)>0)return;qa.reflect(Ir).negate(),qa.add(Fo),Xa.extractRotation(n.matrixWorld),Su.set(0,0,-1),Su.applyMatrix4(Xa),Su.add(Jp),Tu.subVectors(Fo,Su),Tu.reflect(Ir).negate(),Tu.add(Fo),a.coordinateSystem=n.coordinateSystem,a.position.copy(qa),a.up.set(0,1,0),a.up.applyMatrix4(Xa),a.up.reflect(Ir),a.lookAt(Tu),a.near=n.near,a.far=n.far,a.updateMatrixWorld(),a.projectionMatrix.copy(n.projectionMatrix),Uo.setFromNormalAndCoplanarPoint(Ir,Fo),Uo.applyMatrix4(a.matrixWorldInverse),Ns.set(Uo.normal.x,Uo.normal.y,Uo.normal.z,Uo.constant);const l=a.projectionMatrix;$a.x=(Math.sign(Ns.x)+l.elements[8])/l.elements[0],$a.y=(Math.sign(Ns.y)+l.elements[9])/l.elements[5],$a.z=-1,$a.w=(1+l.elements[10])/l.elements[14],Ns.multiplyScalar(1/Ns.dot($a));const u=0;l.elements[2]=Ns.x,l.elements[6]=Ns.y,l.elements[10]=Ns.z-u,l.elements[14]=Ns.w,this.value=c.texture,r.visible=!1;const h=i.getRenderTarget(),d=i.getMRT();i.setMRT(null),i.setRenderTarget(c),i.render(t,a),i.setMRT(d),i.setRenderTarget(h),r.visible=!0,Kp=!1}}const X3=s=>H(new Db(s)),jp=new ro(-1,1,1,-1,0,1);class q3 extends at{constructor(e=!1){super();const t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new Ve([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Ve(t,2))}}const $3=new q3;class ys extends kt{constructor(e=null){super($3,e),this.camera=jp,this.isQuadMesh=!0}renderAsync(e){return e.renderAsync(this,jp)}render(e){e.render(this,jp)}}const Y3=new J;class Ub extends gs{static get type(){return"RTTNode"}constructor(e,t=null,n=null,i={type:Ln}){const r=new fn(t,n,i);super(r.texture,rt()),this.node=e,this.width=t,this.height=n,this.renderTarget=r,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this.updateMap=new WeakMap,this._rttNode=null,this._quadMesh=new ys(new Tt),this.updateBeforeType=We.RENDER}get autoSize(){return this.width===null}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;const n=e*this.pixelRatio,i=t*this.pixelRatio;this.renderTarget.setSize(n,i),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(this.textureNeedsUpdate===!1&&this.autoUpdate===!1)return;if(this.textureNeedsUpdate=!1,this.autoSize===!0){this.pixelRatio=e.getPixelRatio();const n=e.getSize(Y3);this.setSize(n.width,n.height)}this._quadMesh.material.fragmentNode=this._rttNode;const t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){const e=new gs(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const Fb=(s,...e)=>H(new Ub(H(s),...e)),ei=(s,...e)=>s.isTextureNode?s:Fb(s,...e);class Ob extends Ag{static get type(){return"VertexColorNode"}constructor(e=0){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e),n=e.hasGeometryAttribute(t);let i;return n===!0?i=super.generate(e):i=e.generateConst(this.nodeType,new st(1,1,1,1)),i}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const Z3=(...s)=>H(new Ob(...s));class Vb extends Ye{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const J3=fe(Vb);class Qi extends Ye{static get type(){return"SceneNode"}constructor(e=Qi.BACKGROUND_BLURRINESS,t=null){super(),this.scope=e,this.scene=t}setup(e){const t=this.scope,n=this.scene!==null?this.scene:e.scene;let i;return t===Qi.BACKGROUND_BLURRINESS?i=dn("backgroundBlurriness","float",n):t===Qi.BACKGROUND_INTENSITY?i=dn("backgroundIntensity","float",n):console.error("THREE.SceneNode: Unknown scope:",t),i}}Qi.BACKGROUND_BLURRINESS="backgroundBlurriness";Qi.BACKGROUND_INTENSITY="backgroundIntensity";const K3=fe(Qi,Qi.BACKGROUND_BLURRINESS),j3=fe(Qi,Qi.BACKGROUND_INTENSITY),C_={Storage:"storage",ReadOnlyStorage:"read-only-storage"},Qp={WriteOnly:"write-only",ReadOnly:"read-only"};class t0 extends Rd{static get type(){return"StorageBufferNode"}constructor(e,t,n=0){super(e,t,n),this.isStorageBufferNode=!0,this.access=C_.Storage,this.isAtomic=!1,this.bufferObject=!1,this.bufferCount=n,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(this.bufferCount===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return"storageBuffer"}element(e){return G3(this,e)}setBufferObject(e){return this.bufferObject=e,this}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(C_.ReadOnlyStorage)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}generate(e){if(e.isAvailable("storageBuffer"))return super.generate(e);const t=this.getNodeType(e);this._attribute===null&&(this._attribute=dl(this.value),this._varying=Un(this._attribute));const n=this._varying.build(e,t);return e.registerTransform(n,this._attribute),n}}const Q3=(s,e,t)=>H(new t0(s,e,t)),eD=(s,e,t)=>H(new t0(s,e,t).setBufferObject(!0));class Bb extends gs{static get type(){return"StorageTextureNode"}constructor(e,t,n=null){super(e,t),this.storeNode=n,this.isStorageTextureNode=!0,this.access=Qp.WriteOnly}getInputType(){return"storageTexture"}setup(e){super.setup(e);const t=e.getNodeProperties(this);t.storeNode=this.storeNode}setAccess(e){return this.access=e,this}generate(e,t){let n;return this.storeNode!==null?n=this.generateStore(e):n=super.generate(e,t),n}toReadOnly(){return this.setAccess(Qp.ReadOnly)}toWriteOnly(){return this.setAccess(Qp.WriteOnly)}generateStore(e){const t=e.getNodeProperties(this),{uvNode:n,storeNode:i}=t,r=super.generate(e,"property"),o=n.build(e,"uvec2"),a=i.build(e,"vec4"),c=e.generateTextureStore(e,r,o,a);e.addLineFlowCode(c,this)}}const zb=K(Bb),tD=(s,e,t)=>{const n=zb(s,e,t);return t!==null&&n.append(),n};class kb extends ml{static get type(){return"UserDataNode"}constructor(e,t,n=null){super(e,t,n),this.userData=n}updateReference(e){return this.reference=this.userData!==null?this.userData:e.object.userData,this.reference}}const nD=(s,e,t)=>H(new kb(s,e,t));class Gb extends pt{static get type(){return"PosterizeNode"}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){const{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}}const iD=K(Gb);let ef=null;class Hb extends vl{static get type(){return"ViewportSharedTextureNode"}constructor(e=xr,t=null){ef===null&&(ef=new fm),super(e,t,ef)}updateReference(){return this}}const sD=K(Hb),rD=new J;class Wb extends gs{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return e.object.isQuadMesh&&this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class R_ extends Wb{static get type(){return"PassMultipleTextureNode"}constructor(e,t,n=!1){super(e,null),this.textureName=t,this.previousTexture=n}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}}class bn extends pt{static get type(){return"PassNode"}constructor(e,t,n,i={}){super("vec4"),this.scope=e,this.scene=t,this.camera=n,this.options=i,this._pixelRatio=1,this._width=1,this._height=1;const r=new oo;r.isRenderTargetTexture=!0,r.name="depth";const o=new fn(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Ln,...i});o.texture.name="output",o.depthTexture=r,this.renderTarget=o,this.updateBeforeType=We.FRAME,this._textures={output:o.texture,depth:r},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=pe(0),this._cameraFar=pe(0),this._mrt=null,this.isPassNode=!0}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}isGlobal(){return!0}getTexture(e){let t=this._textures[e];return t===void 0&&(t=this.renderTarget.texture.clone(),t.isRenderTargetTexture=!0,t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)),t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),t.isRenderTargetTexture=!0,this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(t!==void 0){const n=this._textures[e],i=this.renderTarget.textures.indexOf(n);this.renderTarget.textures[i]=t,this._textures[e]=t,this._previousTextures[e]=n,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return t===void 0&&(this._textureNodes[e]=t=H(new R_(this,e)),this._textureNodes[e].updateTexture()),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),this._previousTextureNodes[e]=t=H(new R_(this,e,!0)),this._previousTextureNodes[e].updateTexture()),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(t===void 0){const n=this._cameraNear,i=this._cameraFar;this._viewZNodes[e]=t=Vg(this.getTextureNode(e),n,i)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(t===void 0){const n=this._cameraNear,i=this._cameraFar,r=this.getViewZNode(e);this._linearDepthNodes[e]=t=rc(r,n,i)}return t}setup({renderer:e}){return this.renderTarget.samples=this.options.samples===void 0?e.samples:this.options.samples,e.backend.isWebGLBackend===!0&&(this.renderTarget.samples=0),this.renderTarget.depthTexture.isMultisampleRenderTargetTexture=this.renderTarget.samples>1,this.scope===bn.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:n,camera:i}=this;this._pixelRatio=t.getPixelRatio();const r=t.getSize(rD);this.setSize(r.width,r.height);const o=t.getRenderTarget(),a=t.getMRT();this._cameraNear.value=i.near,this._cameraFar.value=i.far;for(const c in this._previousTextures)this.toggleTexture(c);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(n,i),t.setRenderTarget(o),t.setMRT(a)}setSize(e,t){this._width=e,this._height=t;const n=this._width*this._pixelRatio,i=this._height*this._pixelRatio;this.renderTarget.setSize(n,i)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}bn.COLOR="color";bn.DEPTH="depth";const oD=(s,e,t)=>H(new bn(bn.COLOR,s,e,t)),Na=(s,e)=>H(new Wb(s,e)),aD=(s,e)=>H(new bn(bn.DEPTH,s,e)),I_=new ys,P_=new ys;class Xb extends pt{static get type(){return"GaussianBlurNode"}constructor(e,t=null,n=2){super("vec4"),this.textureNode=e,this.directionNode=t,this.sigma=n,this._invSize=pe(new J),this._passDirection=pe(new J),this._horizontalRT=new fn,this._horizontalRT.texture.name="GaussianBlurNode.horizontal",this._verticalRT=new fn,this._verticalRT.texture.name="GaussianBlurNode.vertical",this._textureNode=Na(this,this._verticalRT.texture),this.updateBeforeType=We.RENDER,this.resolution=new J(1,1)}setSize(e,t){e=Math.max(Math.round(e*this.resolution.x),1),t=Math.max(Math.round(t*this.resolution.y),1),this._invSize.value.set(1/e,1/t),this._horizontalRT.setSize(e,t),this._verticalRT.setSize(e,t)}updateBefore(e){const{renderer:t}=e,n=this.textureNode,i=n.value,r=t.getRenderTarget(),o=t.getMRT(),a=n.value;I_.material=this._material,P_.material=this._material,this.setSize(i.image.width,i.image.height);const c=i.type;this._horizontalRT.texture.type=c,this._verticalRT.texture.type=c,t.setMRT(null),t.setRenderTarget(this._horizontalRT),this._passDirection.value.set(1,0),I_.render(t),n.value=this._horizontalRT.texture,t.setRenderTarget(this._verticalRT),this._passDirection.value.set(0,1),P_.render(t),t.setRenderTarget(r),t.setMRT(o),n.value=a}getTextureNode(){return this._textureNode}setup(e){const t=this.textureNode;if(t.isTextureNode!==!0)return console.error("GaussianBlurNode requires a TextureNode."),oe();const n=t.uvNode||rt(),i=z(this.directionNode||1),r=l=>t.uv(l),o=U(()=>{const l=3+2*this.sigma,u=this._getCoefficients(l),h=this._invSize,d=i.mul(this._passDirection),p=A(u[0]).toVar(),f=oe(r(n).mul(p)).toVar();for(let x=1;x<l;x++){const m=A(x),g=A(u[x]),y=z(d.mul(h.mul(m))).toVar(),_=oe(r(n.add(y))),v=oe(r(n.sub(y)));f.addAssign(_.add(v).mul(g)),p.addAssign(ot(2,g))}return f.div(p)}),a=this._material||(this._material=new Tt);a.fragmentNode=o().context(e.getSharedContext()),a.name="Gaussian_blur",a.needsUpdate=!0;const c=e.getNodeProperties(this);return c.textureNode=t,this._textureNode}dispose(){this._horizontalRT.dispose(),this._verticalRT.dispose()}_getCoefficients(e){const t=[];for(let n=0;n<e;n++)t.push(.39894*Math.exp(-.5*n*n/(e*e))/e);return t}}const cD=(s,e,t)=>H(new Xb(ei(s),e,t)),tf=new J,L_=new ys;class qb extends pt{static get type(){return"AfterImageNode"}constructor(e,t=.96){super(e),this.textureNode=e,this.textureNodeOld=xt(),this.damp=pe(t),this._compRT=new fn,this._compRT.texture.name="AfterImageNode.comp",this._oldRT=new fn,this._oldRT.texture.name="AfterImageNode.old",this._textureNode=Na(this,this._compRT.texture),this.updateBeforeType=We.RENDER}getTextureNode(){return this._textureNode}setSize(e,t){this._compRT.setSize(e,t),this._oldRT.setSize(e,t)}updateBefore(e){const{renderer:t}=e,n=this.textureNode,r=n.value.type;this._compRT.texture.type=r,this._oldRT.texture.type=r,t.getDrawingBufferSize(tf),this.setSize(tf.x,tf.y);const o=t.getRenderTarget(),a=n.value;this.textureNodeOld.value=this._oldRT.texture,t.setRenderTarget(this._compRT),L_.render(t);const c=this._oldRT;this._oldRT=this._compRT,this._compRT=c,t.setRenderTarget(o),n.value=a}setup(e){const t=this.textureNode,n=this.textureNodeOld,i=t.uvNode||rt();n.uvNode=i;const r=u=>t.uv(u),o=U(([u,h])=>{const d=A(h).toVar(),p=oe(u).toVar();return ft(cl(p.sub(d)),0)}),a=U(()=>{const u=oe(n),h=oe(r(i));return u.mulAssign(this.damp.mul(o(u,.1))),ft(h,u)}),c=this._materialComposed||(this._materialComposed=new Tt);c.name="AfterImage",c.fragmentNode=a(),L_.material=c;const l=e.getNodeProperties(this);return l.textureNode=t,this._textureNode}dispose(){this._compRT.dispose(),this._oldRT.dispose()}}const lD=(s,e)=>H(new qb(ei(s),e)),uD=U(([s])=>En(s.rgb)),hD=U(([s,e=A(1)])=>e.mix(En(s.rgb),s.rgb)),dD=U(([s,e=A(1)])=>{const t=Wt(s.r,s.g,s.b).div(3),n=s.r.max(s.g.max(s.b)),i=n.sub(t).mul(e).mul(-3);return it(s.rgb,n,i)}),pD=U(([s,e=A(1)])=>{const t=D(.57735,.57735,.57735),n=e.cos();return D(s.rgb.mul(n).add(t.cross(s.rgb).mul(e.sin()).add(t.mul($t(t,s.rgb).mul(n.oneMinus())))))}),fD=new E,En=(s,e=D(...gt.getLuminanceCoefficients(fD)))=>$t(s,e),$b=(s,e)=>it(D(0),s,En(s).sub(e).max(0)),D_=new ys;class Yb extends pt{static get type(){return"AnamorphicNode"}constructor(e,t,n,i){super("vec4"),this.textureNode=e,this.tresholdNode=t,this.scaleNode=n,this.colorNode=D(.1,0,1),this.samples=i,this.resolution=new J(1,1),this._renderTarget=new fn,this._renderTarget.texture.name="anamorphic",this._invSize=pe(new J),this._textureNode=Na(this,this._renderTarget.texture),this.updateBeforeType=We.RENDER}getTextureNode(){return this._textureNode}setSize(e,t){this._invSize.value.set(1/e,1/t),e=Math.max(Math.round(e*this.resolution.x),1),t=Math.max(Math.round(t*this.resolution.y),1),this._renderTarget.setSize(e,t)}updateBefore(e){const{renderer:t}=e,n=this.textureNode,i=n.value;this._renderTarget.texture.type=i.type;const r=t.getRenderTarget(),o=n.value;D_.material=this._material,this.setSize(i.image.width,i.image.height),t.setRenderTarget(this._renderTarget),D_.render(t),t.setRenderTarget(r),n.value=o}setup(e){const t=this.textureNode,n=t.uvNode||rt(),i=c=>t.uv(c),r=U(()=>{const c=this.samples,l=Math.floor(c/2),u=D(0).toVar();return mt({start:-l,end:l},({i:h})=>{const d=A(h).abs().div(l).oneMinus(),p=z(n.x.add(this._invSize.x.mul(h).mul(this.scaleNode)),n.y),f=i(p),x=$b(f,this.tresholdNode).mul(d);u.addAssign(x)}),u.mul(this.colorNode)}),o=this._material||(this._material=new Tt);o.name="Anamorphic",o.fragmentNode=r();const a=e.getNodeProperties(this);return a.textureNode=t,this._textureNode}dispose(){this._renderTarget.dispose()}}const mD=(s,e=.9,t=3,n=32)=>H(new Yb(ei(s),H(e),H(t),n));class Zb extends pt{static get type(){return"SobelOperatorNode"}constructor(e){super(),this.textureNode=e,this.updateBeforeType=We.RENDER,this._invSize=pe(new J)}updateBefore(){const e=this.textureNode.value;this._invSize.value.set(1/e.image.width,1/e.image.height)}setup(){const{textureNode:e}=this,t=e.uvNode||rt(),n=o=>e.uv(o);return U(()=>{const o=this._invSize,a=Tn(-1,-2,-1,0,0,0,1,2,1),c=Tn(-1,0,1,-2,0,2,-1,0,1),l=En(n(t.add(o.mul(z(-1,-1)))).xyz),u=En(n(t.add(o.mul(z(-1,0)))).xyz),h=En(n(t.add(o.mul(z(-1,1)))).xyz),d=En(n(t.add(o.mul(z(0,-1)))).xyz),p=En(n(t.add(o.mul(z(0,0)))).xyz),f=En(n(t.add(o.mul(z(0,1)))).xyz),x=En(n(t.add(o.mul(z(1,-1)))).xyz),m=En(n(t.add(o.mul(z(1,0)))).xyz),g=En(n(t.add(o.mul(z(1,1)))).xyz),y=Wt(a[0][0].mul(l),a[1][0].mul(d),a[2][0].mul(x),a[0][1].mul(u),a[1][1].mul(p),a[2][1].mul(m),a[0][2].mul(h),a[1][2].mul(f),a[2][2].mul(g)),_=Wt(c[0][0].mul(l),c[1][0].mul(d),c[2][0].mul(x),c[0][1].mul(u),c[1][1].mul(p),c[2][1].mul(m),c[0][2].mul(h),c[1][2].mul(f),c[2][2].mul(g)),v=y.mul(y).add(_.mul(_)).sqrt();return oe(D(v),1)})()}}const gD=s=>H(new Zb(ei(s)));class Jb extends pt{static get type(){return"DepthOfFieldNode"}constructor(e,t,n,i,r){super(),this.textureNode=e,this.viewZNode=t,this.focusNode=n,this.apertureNode=i,this.maxblurNode=r,this._aspect=pe(0),this.updateBeforeType=We.RENDER}updateBefore(){const e=this.textureNode.value;this._aspect.value=e.image.width/e.image.height}setup(){const e=this.textureNode,t=e.uvNode||rt(),n=o=>e.uv(o);return U(()=>{const o=z(1,this._aspect),a=this.focusNode.add(this.viewZNode),c=z(cn(a.mul(this.apertureNode),this.maxblurNode.negate(),this.maxblurNode)),l=c.mul(.9),u=c.mul(.7),h=c.mul(.4);let d=oe(0);return d=d.add(n(t)),d=d.add(n(t.add(z(0,.4).mul(o).mul(c)))),d=d.add(n(t.add(z(.15,.37).mul(o).mul(c)))),d=d.add(n(t.add(z(.29,.29).mul(o).mul(c)))),d=d.add(n(t.add(z(-.37,.15).mul(o).mul(c)))),d=d.add(n(t.add(z(.4,0).mul(o).mul(c)))),d=d.add(n(t.add(z(.37,-.15).mul(o).mul(c)))),d=d.add(n(t.add(z(.29,-.29).mul(o).mul(c)))),d=d.add(n(t.add(z(-.15,-.37).mul(o).mul(c)))),d=d.add(n(t.add(z(0,-.4).mul(o).mul(c)))),d=d.add(n(t.add(z(-.15,.37).mul(o).mul(c)))),d=d.add(n(t.add(z(-.29,.29).mul(o).mul(c)))),d=d.add(n(t.add(z(.37,.15).mul(o).mul(c)))),d=d.add(n(t.add(z(-.4,0).mul(o).mul(c)))),d=d.add(n(t.add(z(-.37,-.15).mul(o).mul(c)))),d=d.add(n(t.add(z(-.29,-.29).mul(o).mul(c)))),d=d.add(n(t.add(z(.15,-.37).mul(o).mul(c)))),d=d.add(n(t.add(z(.15,.37).mul(o).mul(l)))),d=d.add(n(t.add(z(-.37,.15).mul(o).mul(l)))),d=d.add(n(t.add(z(.37,-.15).mul(o).mul(l)))),d=d.add(n(t.add(z(-.15,-.37).mul(o).mul(l)))),d=d.add(n(t.add(z(-.15,.37).mul(o).mul(l)))),d=d.add(n(t.add(z(.37,.15).mul(o).mul(l)))),d=d.add(n(t.add(z(-.37,-.15).mul(o).mul(l)))),d=d.add(n(t.add(z(.15,-.37).mul(o).mul(l)))),d=d.add(n(t.add(z(.29,.29).mul(o).mul(u)))),d=d.add(n(t.add(z(.4,0).mul(o).mul(u)))),d=d.add(n(t.add(z(.29,-.29).mul(o).mul(u)))),d=d.add(n(t.add(z(0,-.4).mul(o).mul(u)))),d=d.add(n(t.add(z(-.29,.29).mul(o).mul(u)))),d=d.add(n(t.add(z(-.4,0).mul(o).mul(u)))),d=d.add(n(t.add(z(-.29,-.29).mul(o).mul(u)))),d=d.add(n(t.add(z(0,.4).mul(o).mul(u)))),d=d.add(n(t.add(z(.29,.29).mul(o).mul(h)))),d=d.add(n(t.add(z(.4,0).mul(o).mul(h)))),d=d.add(n(t.add(z(.29,-.29).mul(o).mul(h)))),d=d.add(n(t.add(z(0,-.4).mul(o).mul(h)))),d=d.add(n(t.add(z(-.29,.29).mul(o).mul(h)))),d=d.add(n(t.add(z(-.4,0).mul(o).mul(h)))),d=d.add(n(t.add(z(-.29,-.29).mul(o).mul(h)))),d=d.add(n(t.add(z(0,.4).mul(o).mul(h)))),d=d.div(41),d.a=1,oe(d)})()}}const xD=(s,e,t=1,n=.025,i=1)=>H(new Jb(ei(s),H(e),H(t),H(n),H(i)));class Kb extends pt{static get type(){return"DotScreenNode"}constructor(e,t=new J(.5,.5),n=1.57,i=1){super("vec4"),this.inputNode=e,this.center=pe(t),this.angle=pe(n),this.scale=pe(i)}setup(){const e=this.inputNode,t=U(()=>{const r=Cn(this.angle),o=Mi(this.angle),a=rt().mul(da).sub(this.center),c=z(o.mul(a.x).sub(r.mul(a.y)),r.mul(a.x).add(o.mul(a.y))).mul(this.scale);return Cn(c.x).mul(Cn(c.y)).mul(4)});return U(()=>{const r=e,o=Wt(r.r,r.g,r.b).div(3);return oe(D(o.mul(10).sub(5).add(t())),r.a)})()}}const _D=(s,e,t,n)=>H(new Kb(H(s),e,t,n));class jb extends pt{static get type(){return"RGBShiftNode"}constructor(e,t=.005,n=0){super("vec4"),this.textureNode=e,this.amount=pe(t),this.angle=pe(n)}setup(){const{textureNode:e}=this,t=e.uvNode||rt(),n=r=>e.uv(r);return U(()=>{const r=z(Mi(this.angle),Cn(this.angle)).mul(this.amount),o=n(t.add(r)),a=n(t),c=n(t.sub(r));return oe(o.r,a.g,c.b,a.a)})()}}const yD=(s,e,t)=>H(new jb(ei(s),e,t));class Qb extends pt{static get type(){return"FilmNode"}constructor(e,t=null,n=null){super(),this.inputNode=e,this.intensityNode=t,this.uvNode=n}setup(){const e=this.uvNode||rt();return U(()=>{const i=this.inputNode.rgb,r=yg(gr(e.add(e0())));let o=i.add(i.mul(cn(r.add(.1),0,1)));return this.intensityNode!==null&&(o=it(i,o,this.intensityNode)),oe(o,this.inputNode.a)})()}}const vD=K(Qb);class ew extends pt{static get type(){return"Lut3DNode"}constructor(e,t,n,i){super(),this.inputNode=e,this.lutNode=t,this.size=pe(n),this.intensityNode=i}setup(){const{inputNode:e,lutNode:t}=this,n=o=>t.uv(o);return U(()=>{const o=e,a=A(1).div(this.size),c=A(.5).div(this.size),l=D(c).add(o.rgb.mul(A(1).sub(a))),u=oe(n(l).rgb,o.a);return oe(it(o,u,this.intensityNode))})()}}const MD=(s,e,t,n)=>H(new ew(H(s),H(e),t,H(n))),U_=new ys,F_=new _e,SD=new J;class tw extends pt{static get type(){return"GTAONode"}constructor(e,t,n){super(),this.depthNode=e,this.normalNode=t,this.radius=pe(.25),this.resolution=pe(new J),this.thickness=pe(1),this.distanceExponent=pe(1),this.distanceFallOff=pe(1),this.scale=pe(1),this.noiseNode=xt(TD()),this.cameraProjectionMatrix=pe(n.projectionMatrix),this.cameraProjectionMatrixInverse=pe(n.projectionMatrixInverse),this.SAMPLES=pe(16),this._aoRenderTarget=new fn,this._aoRenderTarget.texture.name="GTAONode.AO",this._material=null,this._textureNode=Na(this,this._aoRenderTarget.texture),this.updateBeforeType=We.FRAME}getTextureNode(){return this._textureNode}setSize(e,t){this.resolution.value.set(e,t),this._aoRenderTarget.setSize(e,t)}updateBefore(e){const{renderer:t}=e,n=t.getDrawingBufferSize(SD),i=t.getRenderTarget(),r=t.getMRT();t.getClearColor(F_);const o=t.getClearAlpha();U_.material=this._material,this.setSize(n.width,n.height),t.setMRT(null),t.setClearColor(16777215,1),t.setRenderTarget(this._aoRenderTarget),U_.render(t),t.setRenderTarget(i),t.setMRT(r),t.setClearColor(F_,o)}setup(e){const t=rt(),n=l=>this.depthNode.uv(l).x,i=l=>this.noiseNode.uv(l),r=U(([l])=>{const u=this.cameraProjectionMatrix.mul(oe(l,1));let h=u.xy.div(u.w).mul(.5).add(.5).toVar();h=z(h.x,h.y.oneMinus());const d=n(h);return D(h,d)}),o=U(([l,u])=>{l=z(l.x,l.y.oneMinus()).mul(2).sub(1);const h=oe(D(l,u),1),d=oe(this.cameraProjectionMatrixInverse.mul(h));return d.xyz.div(d.w)}),a=U(()=>{const l=n(t);l.greaterThanEqual(1).discard();const u=o(t,l),h=this.normalNode.rgb.normalize(),d=this.radius,p=tr(this.noiseNode,0);let f=z(t.x,t.y.oneMinus());f=f.mul(this.resolution.div(p));const x=i(f),m=x.xyz.mul(2).sub(1),g=D(m.xy,0).normalize(),y=D(g.y.mul(-1),g.x,0),_=Tn(g,y,D(0,0,1)),v=this.SAMPLES.lessThan(30).select(3,5),I=Wt(this.SAMPLES,v.sub(1)).div(v),T=A(0).toVar();return mt({start:L(0),end:v,type:"int",condition:"<"},({i:w})=>{const C=A(w).div(A(v)).mul(eo),F=oe(Mi(C),Cn(C),0,Wt(.5,ot(.5,x.w)));F.xyz=vi(_.mul(F.xyz));const M=vi(u.xyz.negate()),b=vi(Qo(F.xyz,M)),G=Qo(b,M),W=vi(h.sub(b.mul($t(h,b)))),$=Qo(W,b),ie=z($t(M,$),$t(M,$.negate())).toVar();mt({end:I,type:"int",name:"j",condition:"<"},({j:Qe})=>{const ht=F.xyz.mul(d).mul(F.w).mul(Kn(ns(A(Qe).add(1),A(I)),this.distanceExponent)),ne=r(u.add(ht)),Ae=o(ne.xy,ne.z).sub(u);Oe(Dt(Ae.z).lessThan(this.thickness),()=>{const Je=$t(M,vi(Ae));ie.x.addAssign(ft(0,ot(Je.sub(ie.x),it(1,A(2).div(A(Qe).add(2)),this.distanceFallOff))))});const ge=r(u.sub(ht)),Xe=o(ge.xy,ge.z).sub(u);Oe(Dt(Xe.z).lessThan(this.thickness),()=>{const Je=$t(M,vi(Xe));ie.y.addAssign(ft(0,ot(Je.sub(ie.y),it(1,A(2).div(A(Qe).add(2)),this.distanceFallOff))))})});const q=os(Ft(1,ie.mul(ie))),he=$t(W,G),Q=$t(W,M),we=ot(.5,gh(ie.y).sub(gh(ie.x)).add(q.x.mul(ie.x).sub(q.y.mul(ie.y)))),Ne=ot(.5,Ft(2,ie.x.mul(ie.x)).sub(ie.y.mul(ie.y))),Ee=he.mul(we).add(Q.mul(Ne));T.addAssign(Ee)}),T.assign(cn(T.div(v),0,1)),T.assign(Kn(T,this.scale)),oe(D(T),1)}),c=this._material||(this._material=new Tt);return c.fragmentNode=a().context(e.getSharedContext()),c.name="GTAO",c.needsUpdate=!0,this._textureNode}dispose(){this._aoRenderTarget.dispose()}}function TD(s=5){const e=Math.floor(s)%2===0?Math.floor(s)+1:Math.floor(s),t=bD(e),n=t.length,i=new Uint8Array(n*4);for(let o=0;o<n;++o){const a=t[o],c=2*Math.PI*a/n,l=new E(Math.cos(c),Math.sin(c),0).normalize();i[o*4]=(l.x*.5+.5)*255,i[o*4+1]=(l.y*.5+.5)*255,i[o*4+2]=127,i[o*4+3]=255}const r=new Oi(i,e,e);return r.wrapS=rr,r.wrapT=rr,r.needsUpdate=!0,r}function bD(s){const e=Math.floor(s)%2===0?Math.floor(s)+1:Math.floor(s),t=e*e,n=Array(t).fill(0);let i=Math.floor(e/2),r=e-1;for(let o=1;o<=t;){if(i===-1&&r===e?(r=e-2,i=0):(r===e&&(r=0),i<0&&(i=e-1)),n[i*e+r]!==0){r-=2,i++;continue}else n[i*e+r]=o++;r++,i--}return n}const wD=(s,e,t)=>H(new tw(H(s),H(e),t));class nw extends pt{static get type(){return"DenoiseNode"}constructor(e,t,n,i,r){super(),this.textureNode=e,this.depthNode=t,this.normalNode=n,this.noiseNode=i,this.cameraProjectionMatrixInverse=pe(r.projectionMatrixInverse),this.lumaPhi=pe(5),this.depthPhi=pe(5),this.normalPhi=pe(5),this.radius=pe(5),this.index=pe(0),this._resolution=pe(new J),this._sampleVectors=ds(AD(16,2,1)),this.updateBeforeType=We.RENDER}updateBefore(){const e=this.textureNode.value;this._resolution.value.set(e.image.width,e.image.height)}setup(){const e=rt(),t=h=>this.textureNode.uv(h),n=h=>this.depthNode.uv(h).x,i=h=>this.normalNode.uv(h),r=h=>this.noiseNode.uv(h),o=U(([h,d])=>{h=z(h.x,h.y.oneMinus()).mul(2).sub(1);const p=oe(D(h,d),1),f=oe(this.cameraProjectionMatrixInverse.mul(p));return f.xyz.div(f.w)}),a=U(([h,d,p,f])=>{const x=t(f),m=n(f),g=i(f).rgb.normalize(),y=x.rgb,_=o(f,m),v=$t(d,g).toVar(),I=Kn(ft(v,0),this.normalPhi).toVar(),T=Dt(En(y).sub(En(h))).toVar(),w=ft(A(1).sub(T.div(this.lumaPhi)),0).toVar(),C=Dt($t(p.sub(_),d)).toVar(),F=ft(A(1).sub(C.div(this.depthPhi)),0),M=w.mul(F).mul(I);return oe(y.mul(M),M)}),c=U(([h])=>{const d=n(h),p=i(h).rgb.normalize(),f=t(h);Oe(d.greaterThanEqual(1).or($t(p,p).equal(0)),()=>f);const x=D(f.rgb),m=o(h,d),g=tr(this.noiseNode,0);let y=z(h.x,h.y.oneMinus());y=y.mul(this._resolution.div(g));const _=r(y),v=Cn(_.element(this.index.mod(4).mul(2).mul(eo))),I=Mi(_.element(this.index.mod(4).mul(2).mul(eo))),T=z(v,I),w=ol(T.x,T.y.negate(),T.x,T.y),C=A(1).toVar(),F=D(f.rgb).toVar();return mt({start:L(0),end:L(16),type:"int",condition:"<"},({i:M})=>{const b=this._sampleVectors.element(M).toVar(),G=w.mul(b.xy.mul(A(1).add(b.z.mul(this.radius.sub(1))))).div(this._resolution).toVar(),W=h.add(G).toVar(),$=a(x,p,m,W);F.addAssign($.xyz),C.addAssign($.w)}),Oe(C.greaterThan(A(0)),()=>{F.divAssign(C)}),oe(F,f.a)}).setLayout({name:"denoise",type:"vec4",inputs:[{name:"uv",type:"vec2"}]});return U(()=>c(e))()}}function AD(s,e,t){const n=ND(s,e,t),i=[];for(let r=0;r<s;r++){const o=n[r];i.push(o)}return i}function ND(s,e,t){const n=[];for(let i=0;i<s;i++){const r=2*Math.PI*e*i/s,o=Math.pow(i/(s-1),t);n.push(new E(Math.cos(r),Math.sin(r),o))}return n}const ED=(s,e,t,n,i)=>H(new nw(ei(s),H(e),H(t),H(n),i));class iw extends pt{static get type(){return"FXAANode"}constructor(e){super(),this.textureNode=e,this.updateBeforeType=We.RENDER,this._invSize=pe(new J)}updateBefore(){const e=this.textureNode.value;this._invSize.value.set(1/e.image.width,1/e.image.height)}setup(){const e=this.textureNode.bias(-100),t=e.uvNode||rt(),n=u=>e.uv(u),i=(u,h,d)=>e.uv(u.add(h.mul(d))),r=L(5),o=U(([u,h])=>{const d=oe(h).toVar(),p=oe(u).toVar(),f=oe(Dt(p.sub(d))).toVar();return ft(ft(ft(f.r,f.g),f.b),f.a)}),a=U(([u,h,d,p])=>{const f=n(u).toVar(),x=i(u,z(0,-1),h.xy).toVar(),m=i(u,z(1,0),h.xy).toVar(),g=i(u,z(0,1),h.xy).toVar(),y=i(u,z(-1,0),h.xy).toVar(),_=o(f,g).toVar(),v=o(f,x).toVar(),I=o(f,m).toVar(),T=o(f,y).toVar(),w=ft(_,ft(v,ft(I,T))).toVar();Oe(w.lessThan(d),()=>f);const C=Ft(_.add(v),I.add(T)).toVar();C.mulAssign(p),Oe(Dt(C).lessThan(.3),()=>{const ht=I.greaterThan(T).select(1,-1).toVar(),ne=v.greaterThan(_).select(1,-1).toVar(),ue=z(ht,ne).toVar(),Ae=i(u,z(ue.x,ue.y),h.xy),ge=o(f,Ae).toVar(),Ze=i(u,z(ue.x.negate(),ue.y.negate()),h.xy),Xe=o(f,Ze).toVar();C.assign(Xe.sub(ge)),C.mulAssign(p),Oe(Dt(C).lessThan(.3),()=>{const Je=g.add(x).add(m).add(y);return it(f,Je.mul(.25),.4)})});const F=z().toVar();Oe(C.lessThanEqual(0),()=>{g.assign(y),x.assign(m),F.x.assign(0),F.y.assign(h.y)}).Else(()=>{F.x.assign(h.x),F.y.assign(0)});const M=o(f,g).toVar(),b=o(f,x).toVar();Oe(M.lessThanEqual(b),()=>{g.assign(x)});const G=L(0).toVar(),W=L(0).toVar(),$=A(0).toVar(),ie=A(0).toVar(),q=z(u).toVar(),he=z(u).toVar(),Q=L(0).toVar(),we=L(0).toVar();mt(r,({i:ht})=>{const ne=ht.add(1).toVar();Oe(G.equal(0),()=>{$.addAssign(ne),q.assign(u.add(F.mul($)));const ue=n(q.xy),Ae=o(ue,f).toVar(),ge=o(ue,g).toVar();Oe(Ae.greaterThan(ge),()=>{G.assign(1)}),Q.assign(ht)}),Oe(W.equal(0),()=>{ie.addAssign(ne),he.assign(u.sub(F.mul(ie)));const ue=n(he.xy),Ae=o(ue,f).toVar(),ge=o(ue,g).toVar();Oe(Ae.greaterThan(ge),()=>{W.assign(1)}),we.assign(ht)}),Oe(G.equal(1).or(W.equal(1)),()=>{Ld()})}),Oe(G.equal(0).and(W.equal(0)),()=>f);const Ne=A(1).toVar(),Ee=A(1).toVar();Oe(G.equal(1),()=>{Ne.assign(A(Q).div(A(r.sub(1))))}),Oe(W.equal(1),()=>{Ee.assign(A(we).div(A(r.sub(1))))});const Qe=Mn(Ne,Ee);return Qe.assign(Kn(Qe,.5)),Qe.assign(A(1).sub(Qe)),it(f,g,Qe.mul(.5))}).setLayout({name:"FxaaPixelShader",type:"vec4",inputs:[{name:"uv",type:"vec2"},{name:"fxaaQualityRcpFrame",type:"vec2"},{name:"fxaaQualityEdgeThreshold",type:"float"},{name:"fxaaQualityinvEdgeThreshold",type:"float"}]});return U(()=>{const u=A(.2),h=A(1).div(u);return a(t,this._invSize,u,h)})()}}const CD=s=>H(new iw(ei(s))),Pr=new ys,RD=new _e(0,0,0),O_=new _e,ID=new J,PD=new J(1,0),LD=new J(0,1);class sw extends pt{static get type(){return"BloomNode"}constructor(e,t=1,n=0,i=0){super(),this.inputNode=e,this.strength=pe(t),this.radius=pe(n),this.threshold=pe(i),this.smoothWidth=pe(.01),this._renderTargetsHorizontal=[],this._renderTargetsVertical=[],this._nMips=5,this._renderTargetBright=new fn(1,1,{type:Ln}),this._renderTargetBright.texture.name="UnrealBloomPass.bright",this._renderTargetBright.texture.generateMipmaps=!1;for(let r=0;r<this._nMips;r++){const o=new fn(1,1,{type:Ln});o.texture.name="UnrealBloomPass.h"+r,o.texture.generateMipmaps=!1,this._renderTargetsHorizontal.push(o);const a=new fn(1,1,{type:Ln});a.texture.name="UnrealBloomPass.v"+r,a.texture.generateMipmaps=!1,this._renderTargetsVertical.push(a)}this._compositeMaterial=null,this._highPassFilterMaterial=null,this._separableBlurMaterials=[],this._textureNodeBright=xt(this._renderTargetBright.texture),this._textureNodeBlur0=xt(this._renderTargetsVertical[0].texture),this._textureNodeBlur1=xt(this._renderTargetsVertical[1].texture),this._textureNodeBlur2=xt(this._renderTargetsVertical[2].texture),this._textureNodeBlur3=xt(this._renderTargetsVertical[3].texture),this._textureNodeBlur4=xt(this._renderTargetsVertical[4].texture),this._textureOutput=Na(this,this._renderTargetsHorizontal[0].texture),this.updateBeforeType=We.FRAME}getTextureNode(){return this._textureOutput}setSize(e,t){let n=Math.round(e/2),i=Math.round(t/2);this._renderTargetBright.setSize(n,i);for(let r=0;r<this._nMips;r++)this._renderTargetsHorizontal[r].setSize(n,i),this._renderTargetsVertical[r].setSize(n,i),this._separableBlurMaterials[r].invSize.value.set(1/n,1/i),n=Math.round(n/2),i=Math.round(i/2)}updateBefore(e){const{renderer:t}=e,n=t.getDrawingBufferSize(ID);this.setSize(n.width,n.height);const i=t.getRenderTarget(),r=t.getMRT();t.getClearColor(O_);const o=t.getClearAlpha();this.setSize(n.width,n.height),t.setMRT(null),t.setClearColor(RD,0),t.setRenderTarget(this._renderTargetBright),Pr.material=this._highPassFilterMaterial,Pr.render(t);let a=this._renderTargetBright;for(let c=0;c<this._nMips;c++)Pr.material=this._separableBlurMaterials[c],this._separableBlurMaterials[c].colorTexture.value=a.texture,this._separableBlurMaterials[c].direction.value=PD,t.setRenderTarget(this._renderTargetsHorizontal[c]),t.clear(),Pr.render(t),this._separableBlurMaterials[c].colorTexture.value=this._renderTargetsHorizontal[c].texture,this._separableBlurMaterials[c].direction.value=LD,t.setRenderTarget(this._renderTargetsVertical[c]),t.clear(),Pr.render(t),a=this._renderTargetsVertical[c];t.setRenderTarget(this._renderTargetsHorizontal[0]),t.clear(),Pr.material=this._compositeMaterial,Pr.render(t),t.setRenderTarget(i),t.setMRT(r),t.setClearColor(O_,o)}setup(e){const t=U(()=>{const c=this.inputNode,l=En(c.rgb),u=ti(this.threshold,this.threshold.add(this.smoothWidth),l);return it(oe(0),c,u)});this._highPassFilterMaterial=this._highPassFilterMaterial||new Tt,this._highPassFilterMaterial.fragmentNode=t().context(e.getSharedContext()),this._highPassFilterMaterial.name="Bloom_highPass",this._highPassFilterMaterial.needsUpdate=!0;const n=[3,5,7,9,11];for(let c=0;c<this._nMips;c++)this._separableBlurMaterials.push(this._getSeperableBlurMaterial(e,n[c]));const i=ds([1,.8,.6,.4,.2]),r=ds([new E(1,1,1),new E(1,1,1),new E(1,1,1),new E(1,1,1),new E(1,1,1)]),o=U(([c,l])=>{const u=A(1.2).sub(c);return it(c,u,l)}).setLayout({name:"lerpBloomFactor",type:"float",inputs:[{name:"factor",type:"float"},{name:"radius",type:"float"}]}),a=U(()=>{const c=o(i.element(0),this.radius).mul(oe(r.element(0),1)).mul(this._textureNodeBlur0),l=o(i.element(1),this.radius).mul(oe(r.element(1),1)).mul(this._textureNodeBlur1),u=o(i.element(2),this.radius).mul(oe(r.element(2),1)).mul(this._textureNodeBlur2),h=o(i.element(3),this.radius).mul(oe(r.element(3),1)).mul(this._textureNodeBlur3),d=o(i.element(4),this.radius).mul(oe(r.element(4),1)).mul(this._textureNodeBlur4);return c.add(l).add(u).add(h).add(d).mul(this.strength)});return this._compositeMaterial=this._compositeMaterial||new Tt,this._compositeMaterial.fragmentNode=a().context(e.getSharedContext()),this._compositeMaterial.name="Bloom_comp",this._compositeMaterial.needsUpdate=!0,this._textureOutput}dispose(){for(let e=0;e<this._renderTargetsHorizontal.length;e++)this._renderTargetsHorizontal[e].dispose();for(let e=0;e<this._renderTargetsVertical.length;e++)this._renderTargetsVertical[e].dispose();this._renderTargetBright.dispose()}_getSeperableBlurMaterial(e,t){const n=[];for(let d=0;d<t;d++)n.push(.39894*Math.exp(-.5*d*d/(t*t))/t);const i=xt(),r=ds(n),o=pe(new J),a=pe(new J(.5,.5)),c=rt(),l=d=>i.uv(d),u=U(()=>{const d=r.element(0).toVar(),p=l(c).rgb.mul(d).toVar();return mt({start:L(1),end:L(t),type:"int",condition:"<"},({i:f})=>{const x=A(f),m=r.element(f),g=a.mul(o).mul(x),y=l(c.add(g)).rgb,_=l(c.sub(g)).rgb;p.addAssign(Wt(y,_).mul(m)),d.addAssign(A(2).mul(m))}),oe(p.div(d),1)}),h=new Tt;return h.fragmentNode=u().context(e.getSharedContext()),h.name="Bloom_seperable",h.needsUpdate=!0,h.colorTexture=i,h.direction=a,h.invSize=o,h}}const DD=(s,e,t,n)=>H(new sw(H(s),e,t,n));class rw extends pt{static get type(){return"TransitionNode"}constructor(e,t,n,i,r,o){super(),this.textureNodeA=e,this.textureNodeB=t,this.mixTextureNode=n,this.mixRatioNode=i,this.thresholdNode=r,this.useTextureNode=o}setup(){const{textureNodeA:e,textureNodeB:t,mixTextureNode:n,mixRatioNode:i,thresholdNode:r,useTextureNode:o}=this,a=u=>{const h=u.uvNode||rt();return u.uv(h)};return U(()=>{const u=a(e),h=a(t),d=oe().toVar();return Oe(o.equal(L(1)),()=>{const p=a(n),f=i.mul(r.mul(2).add(1)).sub(r),x=cn(Ft(p.r,f).mul(A(1).div(r)),0,1);d.assign(it(u,h,x))}).Else(()=>{d.assign(it(h,u,i))}),d})()}}const UD=(s,e,t,n=0,i=.1,r=0)=>H(new rw(ei(s),ei(e),ei(t),H(n),H(i),H(r)));class FD extends pt{static get type(){return"PixelationNode"}constructor(e,t,n,i,r,o){super(),this.textureNode=e,this.depthNode=t,this.normalNode=n,this.pixelSize=i,this.normalEdgeStrength=r,this.depthEdgeStrength=o,this._resolution=pe(new st),this.updateBeforeType=We.RENDER}updateBefore(){const e=this.textureNode.value,t=e.image.width,n=e.image.height;this._resolution.value.set(t,n,1/t,1/n)}setup(){const{textureNode:e,depthNode:t,normalNode:n}=this,i=e.uvNode||rt(),r=t.uvNode||rt(),o=n.uvNode||rt(),a=()=>e.uv(i),c=(x,m)=>t.uv(r.add(z(x,m).mul(this._resolution.zw))).r,l=(x,m)=>n.uv(o.add(z(x,m).mul(this._resolution.zw))).rgb.normalize(),u=x=>{const m=ai("float","diff");return m.addAssign(cn(c(1,0).sub(x))),m.addAssign(cn(c(-1,0).sub(x))),m.addAssign(cn(c(0,1).sub(x))),m.addAssign(cn(c(0,-1).sub(x))),mr(ti(.01,.02,m).mul(2)).div(2)},h=(x,m,g,y)=>{const _=c(x,m).sub(g),v=l(x,m),I=D(1,1,1),T=$t(y.sub(v),I),w=cn(ti(-.01,.01,T),0,1),C=cn(cl(_.mul(.25).add(.0025)),0,1);return A(1).sub($t(y,v)).mul(C).mul(w)},d=(x,m)=>{const g=ai("float","indicator");return g.addAssign(h(0,-1,x,m)),g.addAssign(h(0,1,x,m)),g.addAssign(h(-1,0,x,m)),g.addAssign(h(1,0,x,m)),ll(.1,g)};return U(()=>{const x=a(),m=ai("float","depth"),g=ai("vec3","normal");Oe(this.depthEdgeStrength.greaterThan(0).or(this.normalEdgeStrength.greaterThan(0)),()=>{m.assign(c(0,0)),g.assign(l(0,0))});const y=ai("float","dei");Oe(this.depthEdgeStrength.greaterThan(0),()=>{y.assign(u(m))});const _=ai("float","nei");Oe(this.normalEdgeStrength.greaterThan(0),()=>{_.assign(d(m,g))});const v=y.greaterThan(0).select(A(1).sub(y.mul(this.depthEdgeStrength)),_.mul(this.normalEdgeStrength).add(1));return x.mul(v)})()}}const OD=(s,e,t,n=6,i=.3,r=.4)=>H(new FD(ei(s),ei(e),ei(t),H(n),H(i),H(r)));class ow extends bn{static get type(){return"PixelationPassNode"}constructor(e,t,n=6,i=.3,r=.4){super("color",e,t,{minFilter:Qt,magFilter:Qt}),this.pixelSize=n,this.normalEdgeStrength=i,this.depthEdgeStrength=r,this.isPixelationPassNode=!0,this._mrt=Vd({output:sg,normal:di})}setSize(e,t){const n=this.pixelSize.value?this.pixelSize.value:this.pixelSize,i=Math.floor(e/n),r=Math.floor(t/n);super.setSize(i,r)}setup(){const e=super.getTextureNode("output"),t=super.getTextureNode("depth"),n=super.getTextureNode("normal");return OD(e,t,n,this.pixelSize,this.normalEdgeStrength,this.depthEdgeStrength)}}const VD=(s,e,t,n,i)=>H(new ow(s,e,t,n,i)),BD=new J;class aw extends bn{static get type(){return"SSAAPassNode"}constructor(e,t){super(bn.COLOR,e,t),this.isSSAAPassNode=!0,this.sampleLevel=4,this.unbiased=!0,this.clearColor=new _e(0),this.clearAlpha=0,this._currentClearColor=new _e,this.sampleWeight=pe(1),this.sampleRenderTarget=null,this._quadMesh=new ys}updateBefore(e){const{renderer:t}=e,{scene:n,camera:i}=this;this._pixelRatio=t.getPixelRatio();const r=t.getSize(BD);this.setSize(r.width,r.height),this.sampleRenderTarget.setSize(this.renderTarget.width,this.renderTarget.height),t.getClearColor(this._currentClearColor);const o=t.getClearAlpha(),a=t.getRenderTarget(),c=t.getMRT(),l=t.autoClear;this._cameraNear.value=i.near,this._cameraFar.value=i.far,t.setMRT(this.getMRT()),t.autoClear=!1;const u=zD[Math.max(0,Math.min(this.sampleLevel,5))],h=1/u.length,d=1/32,p={fullWidth:this.renderTarget.width,fullHeight:this.renderTarget.height,offsetX:0,offsetY:0,width:this.renderTarget.width,height:this.renderTarget.height},f=Object.assign({},i.view);f.enabled&&Object.assign(p,f);for(let x=0;x<u.length;x++){const m=u[x];if(i.setViewOffset&&i.setViewOffset(p.fullWidth,p.fullHeight,p.offsetX+m[0]*.0625,p.offsetY+m[1]*.0625,p.width,p.height),this.sampleWeight.value=h,this.unbiased){const g=-.5+(x+.5)/u.length;this.sampleWeight.value+=d*g}t.setClearColor(this.clearColor,this.clearAlpha),t.setRenderTarget(this.sampleRenderTarget),t.clear(),t.render(n,i),t.setRenderTarget(this.renderTarget),x===0&&(t.setClearColor(0,0),t.clear()),this._quadMesh.render(t)}t.copyTextureToTexture(this.sampleRenderTarget.depthTexture,this.renderTarget.depthTexture),i.setViewOffset&&f.enabled?i.setViewOffset(f.fullWidth,f.fullHeight,f.offsetX,f.offsetY,f.width,f.height):i.clearViewOffset&&i.clearViewOffset(),t.setRenderTarget(a),t.setMRT(c),t.autoClear=l,t.setClearColor(this._currentClearColor,o)}setup(e){this.sampleRenderTarget===null&&(this.sampleRenderTarget=this.renderTarget.clone());let t;const n=this.getMRT();if(n!==null){const i={};for(const r in n.outputNodes){const o=Qg(this.sampleRenderTarget.textures,r);o>=0&&(i[r]=xt(this.sampleRenderTarget.textures[o]).mul(this.sampleWeight))}t=Vd(i)}else t=xt(this.sampleRenderTarget.texture).mul(this.sampleWeight);return this._quadMesh.material=new Tt,this._quadMesh.material.fragmentNode=t,this._quadMesh.material.transparent=!0,this._quadMesh.material.depthTest=!1,this._quadMesh.material.depthWrite=!1,this._quadMesh.material.premultipliedAlpha=!0,this._quadMesh.material.blending=cc,this._quadMesh.material.normals=!1,this._quadMesh.material.name="SSAA",super.setup(e)}dispose(){super.dispose(),this.sampleRenderTarget!==null&&this.sampleRenderTarget.dispose()}}const zD=[[[0,0]],[[4,4],[-4,-4]],[[-2,-6],[6,-2],[-6,2],[2,6]],[[1,-3],[-1,3],[5,1],[-3,-5],[-5,5],[-7,-1],[3,7],[7,-7]],[[1,1],[-1,-3],[-3,2],[4,-1],[-5,-2],[2,5],[5,3],[3,-5],[-2,6],[0,-7],[-4,-6],[-6,4],[-8,0],[7,-4],[6,7],[-7,-8]],[[-4,-7],[-7,-5],[-3,-5],[-5,-4],[-1,-4],[-2,-2],[-6,-1],[-4,0],[-7,1],[-1,2],[-6,3],[-3,3],[-7,6],[-3,6],[-5,7],[-1,7],[5,-7],[1,-6],[6,-5],[4,-4],[2,-3],[7,-2],[1,-1],[4,-1],[2,1],[6,2],[0,4],[4,4],[2,5],[7,5],[5,6],[3,7]]],kD=(s,e)=>H(new aw(s,e)),GD=new J;class cw extends bn{static get type(){return"StereoPassNode"}constructor(e,t){super(bn.COLOR,e,t),this.isStereoPassNode=!0,this.stereo=new Dm,this.stereo.aspect=.5}updateBefore(e){const{renderer:t}=e,{scene:n,camera:i,stereo:r,renderTarget:o}=this;this._pixelRatio=t.getPixelRatio(),r.cameraL.coordinateSystem=t.coordinateSystem,r.cameraR.coordinateSystem=t.coordinateSystem,r.update(i);const a=t.getSize(GD);this.setSize(a.width,a.height);const c=t.autoClear;t.autoClear=!1;const l=t.getRenderTarget(),u=t.getMRT();this._cameraNear.value=i.near,this._cameraFar.value=i.far;for(const h in this._previousTextures)this.toggleTexture(h);t.setRenderTarget(o),t.setMRT(this._mrt),t.clear(),o.scissorTest=!0,o.scissor.set(0,0,o.width/2,o.height),o.viewport.set(0,0,o.width/2,o.height),t.render(n,r.cameraL),o.scissor.set(o.width/2,0,o.width/2,o.height),o.viewport.set(o.width/2,0,o.width/2,o.height),t.render(n,r.cameraR),o.scissorTest=!1,t.setRenderTarget(l),t.setMRT(u),t.autoClear=c}}const HD=(s,e)=>H(new cw(s,e)),WD=new J,V_=new ys;class lw extends bn{static get type(){return"StereoCompositePassNode"}constructor(e,t){super(bn.COLOR,e,t),this.isStereoCompositePassNode=!0,this.stereo=new Dm;const n={minFilter:Ut,magFilter:Qt,type:Ln};this._renderTargetL=new fn(1,1,n),this._renderTargetR=new fn(1,1,n),this._mapLeft=xt(this._renderTargetL.texture),this._mapRight=xt(this._renderTargetR.texture),this._material=null}updateStereoCamera(e){this.stereo.cameraL.coordinateSystem=e,this.stereo.cameraR.coordinateSystem=e,this.stereo.update(this.camera)}setSize(e,t){super.setSize(e,t),this._renderTargetL.setSize(this.renderTarget.width,this.renderTarget.height),this._renderTargetR.setSize(this.renderTarget.width,this.renderTarget.height)}updateBefore(e){const{renderer:t}=e,{scene:n,stereo:i,renderTarget:r}=this;this._pixelRatio=t.getPixelRatio(),this.updateStereoCamera(t.coordinateSystem);const o=t.getSize(WD);this.setSize(o.width,o.height);const a=t.getRenderTarget();t.setRenderTarget(this._renderTargetL),t.render(n,i.cameraL),t.setRenderTarget(this._renderTargetR),t.render(n,i.cameraR),t.setRenderTarget(r),V_.material=this._material,V_.render(t),t.setRenderTarget(a)}dispose(){super.dispose(),this._renderTargetL.dispose(),this._renderTargetR.dispose(),this._material!==null&&this._material.dispose()}}class uw extends lw{static get type(){return"AnaglyphPassNode"}constructor(e,t){super(e,t),this.isAnaglyphPassNode=!0,this._colorMatrixLeft=pe(new Ke().fromArray([.4561,-.0400822,-.0152161,.500484,-.0378246,-.0205971,.176381,-.0157589,-.00546856])),this._colorMatrixRight=pe(new Ke().fromArray([-.0434706,.378476,-.0721527,-.0879388,.73364,-.112961,-.00155529,-.0184503,1.2264]))}setup(e){const t=rt(),n=U(()=>{const r=this._mapLeft.uv(t),o=this._mapRight.uv(t),a=cn(this._colorMatrixLeft.mul(r.rgb).add(this._colorMatrixRight.mul(o.rgb)));return oe(a.rgb,ft(r.a,o.a))}),i=this._material||(this._material=new Tt);return i.fragmentNode=n().context(e.getSharedContext()),i.name="Anaglyph",i.needsUpdate=!0,super.setup(e)}}const XD=(s,e)=>H(new uw(s,e));class hw extends lw{static get type(){return"ParallaxBarrierPassNode"}constructor(e,t){super(e,t),this.isParallaxBarrierPassNode=!0}setup(e){const t=rt(),n=U(()=>{const r=oe().toVar();return Oe(Ad(Aa.y,2).greaterThan(1),()=>{r.assign(this._mapLeft.uv(t))}).Else(()=>{r.assign(this._mapRight.uv(t))}),r}),i=this._material||(this._material=new Tt);return i.fragmentNode=n().context(e.getSharedContext()),i.needsUpdate=!0,super.setup(e)}}const qD=(s,e)=>H(new hw(s,e));class dw extends bn{static get type(){return"ToonOutlinePassNode"}constructor(e,t,n,i,r){super(bn.COLOR,e,t),this.colorNode=n,this.thicknessNode=i,this.alphaNode=r,this._materialCache=new WeakMap}updateBefore(e){const{renderer:t}=e,n=t.getRenderObjectFunction();t.setRenderObjectFunction((i,r,o,a,c,l,u)=>{if((c.isMeshToonMaterial||c.isMeshToonNodeMaterial)&&c.wireframe===!1){const h=this._getOutlineMaterial(c);t.renderObject(i,r,o,a,h,l,u)}t.renderObject(i,r,o,a,c,l,u)}),super.updateBefore(e),t.setRenderObjectFunction(n)}_createMaterial(){const e=new Tt;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=ln;const t=hi.negate(),n=ci.mul(xs),i=A(1),r=n.mul(oe(en,1)),o=n.mul(oe(en.add(t),1)),a=vi(r.sub(o));return e.vertexNode=r.add(a.mul(this.thicknessNode).mul(r.w).mul(i)),e.colorNode=oe(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return t===void 0&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}}const $D=(s,e,t=new _e(0,0,0),n=.003,i=1)=>H(new dw(s,e,H(t),H(n),H(i)));class pw extends Ye{static get type(){return"ScriptableValueNode"}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outpuType=null,this.events=new Ai,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return this.outputType!==null}set value(e){this._value!==e&&(this._cache&&this.inputType==="URL"&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=e,this.events.dispatchEvent({type:"change"}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:"refresh"})}getValue(){const e=this.value;if(e&&this._cache===null&&this.inputType==="URL"&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&e.value!==null&&e.value!==void 0&&((this.inputType==="URL"||this.inputType==="String")&&typeof e.value=="string"||this.inputType==="Number"&&typeof e.value=="number"||this.inputType==="Vector2"&&e.value.isVector2||this.inputType==="Vector3"&&e.value.isVector3||this.inputType==="Vector4"&&e.value.isVector4||this.inputType==="Color"&&e.value.isColor||this.inputType==="Matrix3"&&e.value.isMatrix3||this.inputType==="Matrix4"&&e.value.isMatrix4))return e.value;return this._cache||e}getNodeType(e){return this.value&&this.value.isNode?this.value.getNodeType(e):"float"}setup(){return this.value&&this.value.isNode?this.value:A()}serialize(e){super.serialize(e),this.value!==null?this.inputType==="ArrayBuffer"?e.value=Wm(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null:e.value=null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;e.value!==null&&(e.inputType==="ArrayBuffer"?t=Xm(e.value):e.inputType==="Texture"?t=e.meta.textures[e.value]:t=e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}}const Uu=K(pw);class fw extends Map{get(e,t=null,...n){if(this.has(e))return super.get(e);if(t!==null){const i=t(...n);return this.set(e,i),i}}}class YD{constructor(e){this.scriptableNode=e}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(e){return this.scriptableNode.getInputLayout(e)}get(e){const t=this.parameters[e];return t?t.getValue():null}}const Fu=new fw;class mw extends Ye{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new fw,this._output=Uu(),this._outputs={},this._source=this.source,this._method=null,this._object=null,this._value=null,this._needsOutputUpdate=!0,this.onRefresh=this.onRefresh.bind(this),this.isScriptableNode=!0}get source(){return this.codeNode?this.codeNode.code:""}setLocal(e,t){return this._local.set(e,t)}getLocal(e){return this._local.get(e)}onRefresh(){this._refresh()}getInputLayout(e){for(const t of this.getLayout())if(t.inputType&&(t.id===e||t.name===e))return t}getOutputLayout(e){for(const t of this.getLayout())if(t.outputType&&(t.id===e||t.name===e))return t}setOutput(e,t){const n=this._outputs;return n[e]===void 0?n[e]=Uu(t):n[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){const n=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),n[e]=t,n[e].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),n[e]=t,n[e].events.addEventListener("refresh",this.onRefresh)):n[e]===void 0?(n[e]=Uu(t),n[e].events.addEventListener("refresh",this.onRefresh)):n[e].value=t,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(e){let t=this.parameters[e];return t&&(t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.removeEventListener("refresh",this.onRefresh)),this}clearParameters(){for(const e of Object.keys(this.parameters))this.deleteParameter(e);return this.needsUpdate=!0,this}call(e,...t){const i=this.getObject()[e];if(typeof i=="function")return i(...t)}async callAsync(e,...t){const i=this.getObject()[e];if(typeof i=="function")return i.constructor.name==="AsyncFunction"?await i(...t):i(...t)}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){e!==null?this.getOutput(e).refresh():this._refresh()}getObject(){if(this.needsUpdate&&this.dispose(),this._object!==null)return this._object;const e=()=>this.refresh(),t=(l,u)=>this.setOutput(l,u),n=new YD(this),i=Fu.get("THREE"),r=Fu.get("TSL"),o=this.getMethod(this.codeNode),a=[n,this._local,Fu,e,t,i,r];this._object=o(...a);const c=this._object.layout;if(c&&(c.cache===!1&&this._local.clear(),this._output.outputType=c.outputType||null,Array.isArray(c.elements)))for(const l of c.elements){const u=l.id||l.name;l.inputType&&(this.getParameter(u)===void 0&&this.setParameter(u,null),this.getParameter(u).inputType=l.inputType),l.outputType&&(this.getOutput(u)===void 0&&this.setOutput(u,null),this.getOutput(u).outputType=l.outputType)}return this._object}deserialize(e){super.deserialize(e);for(const t in this.parameters){let n=this.parameters[t];n.isScriptableNode&&(n=n.getDefaultOutput()),n.events.addEventListener("refresh",this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){const e=this.getDefaultOutput().value;return e&&e.isNode?e:A()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),this._method!==null)return this._method;const e=["parameters","local","global","refresh","setOutput","THREE","TSL"],n=["layout","init","main","dispose"].join(", "),i="var "+n+`; var output = {};
3871
+ `}}class Nb{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.startTime=null,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let n=e.get(t);return n===void 0&&(n={renderMap:new WeakMap,frameMap:new WeakMap},e.set(t,n)),n}updateBeforeNode(e){const t=e.getUpdateBeforeType(),n=e.updateReference(this);if(t===We.FRAME){const{frameMap:i}=this._getMaps(this.updateBeforeMap,n);i.get(n)!==this.frameId&&e.updateBefore(this)!==!1&&i.set(n,this.frameId)}else if(t===We.RENDER){const{renderMap:i}=this._getMaps(this.updateBeforeMap,n);i.get(n)!==this.renderId&&e.updateBefore(this)!==!1&&i.set(n,this.renderId)}else t===We.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),n=e.updateReference(this);if(t===We.FRAME){const{frameMap:i}=this._getMaps(this.updateAfterMap,n);i.get(n)!==this.frameId&&e.updateAfter(this)!==!1&&i.set(n,this.frameId)}else if(t===We.RENDER){const{renderMap:i}=this._getMaps(this.updateAfterMap,n);i.get(n)!==this.renderId&&e.updateAfter(this)!==!1&&i.set(n,this.renderId)}else t===We.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),n=e.updateReference(this);if(t===We.FRAME){const{frameMap:i}=this._getMaps(this.updateMap,n);i.get(n)!==this.frameId&&e.update(this)!==!1&&i.set(n,this.frameId)}else if(t===We.RENDER){const{renderMap:i}=this._getMaps(this.updateMap,n);i.get(n)!==this.renderId&&e.update(this)!==!1&&i.set(n,this.renderId)}else t===We.OBJECT&&e.update(this)}update(){this.frameId++,this.lastTime===void 0&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class Kg{constructor(e,t,n=null,i="",r=!1){this.type=e,this.name=t,this.count=n,this.qualifier=i,this.isConst=r}}Kg.isNodeFunctionInput=!0;class I3 extends Ye{static get type(){return"StructTypeNode"}constructor(e){super(),this.types=e,this.isStructTypeNode=!0}getMemberTypes(){return this.types}}class jg extends Ye{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}setup(e){super.setup(e);const t=this.members,n=[];for(let i=0;i<t.length;i++)n.push(t[i].getNodeType(e));this.nodeType=e.getStructTypeFromNode(new I3(n)).name}generate(e,t){const n=e.getOutputStructName(),i=this.members,r=n!==""?n+".":"";for(let o=0;o<i.length;o++){const a=i[o].build(e,t);e.addLineFlowCode(`${r}m${o} = ${a}`,this)}return n}}const P3=K(jg);function Qg(s,e){for(let t=0;t<s.length;t++)if(s[t].name===e)return t;return-1}class Eb extends jg{static get type(){return"MRTNode"}constructor(e){super(),this.outputNodes=e,this.isMRTNode=!0}has(e){return this.outputNodes[e]!==void 0}get(e){return this.outputNodes[e]}merge(e){const t={...this.outputNodes,...e.outputNodes};return Vd(t)}setup(e){const t=this.outputNodes,n=e.renderer.getRenderTarget(),i=[],r=n.textures;for(const o in t){const a=Qg(r,o);i[a]=oe(t[o])}return this.members=i,super.setup(e)}}const Vd=K(Eb);class Cb extends Ye{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(e){const t=this.parametersNodes;let n=this._candidateFnCall;if(n===null){let i=null,r=-1;for(const o of this.functionNodes){const c=o.shaderNode.layout;if(c===null)throw new Error("FunctionOverloadingNode: FunctionNode must be a layout.");const l=c.inputs;if(t.length===l.length){let u=0;for(let h=0;h<t.length;h++){const d=t[h],p=l[h];d.getNodeType(e)===p.type?u++:u=0}u>r&&(i=o,r=u)}}this._candidateFnCall=n=i(...t)}return n}}const L3=K(Cb),On=s=>(...e)=>L3(s,...e);class Sn extends uo{static get type(){return"TimerNode"}constructor(e=Sn.LOCAL,t=1,n=0){super(n),this.scope=e,this.scale=t,this.updateType=We.FRAME}update(e){const t=this.scope,n=this.scale;t===Sn.LOCAL?this.value+=e.deltaTime*n:t===Sn.DELTA?this.value=e.deltaTime*n:t===Sn.FRAME?this.value=e.frameId:this.value=e.time*n}serialize(e){super.serialize(e),e.scope=this.scope,e.scale=this.scale}deserialize(e){super.deserialize(e),this.scope=e.scope,this.scale=e.scale}}Sn.LOCAL="local";Sn.GLOBAL="global";Sn.DELTA="delta";Sn.FRAME="frame";const e0=(s,e=0)=>H(new Sn(Sn.LOCAL,s,e)),D3=(s,e=0)=>H(new Sn(Sn.GLOBAL,s,e)),U3=(s,e=0)=>H(new Sn(Sn.DELTA,s,e)),F3=fe(Sn,Sn.FRAME).toUint();class pn extends Ye{static get type(){return"OscNode"}constructor(e=pn.SINE,t=e0()){super(),this.method=e,this.timeNode=t}getNodeType(e){return this.timeNode.getNodeType(e)}setup(){const e=this.method,t=H(this.timeNode);let n=null;return e===pn.SINE?n=t.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5):e===pn.SQUARE?n=t.fract().round():e===pn.TRIANGLE?n=t.add(.5).fract().mul(2).sub(1).abs():e===pn.SAWTOOTH&&(n=t.fract()),n}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}pn.SINE="sine";pn.SQUARE="square";pn.TRIANGLE="triangle";pn.SAWTOOTH="sawtooth";const O3=K(pn,pn.SINE),V3=K(pn,pn.SQUARE),B3=K(pn,pn.TRIANGLE),z3=K(pn,pn.SAWTOOTH);class Rb extends Ye{static get type(){return"SpriteSheetUVNode"}constructor(e,t=rt(),n=A(0)){super("vec2"),this.countNode=e,this.uvNode=t,this.frameNode=n}setup(){const{frameNode:e,uvNode:t,countNode:n}=this,{width:i,height:r}=n,o=e.mod(i.mul(r)).floor(),a=o.mod(i),c=r.sub(o.add(1).div(i).ceil()),l=n.reciprocal(),u=z(a,c);return t.add(u).mul(l)}}const k3=K(Rb);class Ib extends mr{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}setup(e){return e.isAvailable("storageBuffer")===!1&&this.node.bufferObject===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let n;const i=e.context.assign;if(e.isAvailable("storageBuffer")===!1?this.node.bufferObject===!0&&i!==!0?n=e.generatePBO(this):n=this.node.build(e):n=super.generate(e),i!==!0){const r=this.getNodeType(e);n=e.format(n,r,t)}return n}}const G3=K(Ib);class Pb extends Ye{static get type(){return"TriplanarTexturesNode"}constructor(e,t=null,n=null,i=A(1),r=en,o=hi){super("vec4"),this.textureXNode=e,this.textureYNode=t,this.textureZNode=n,this.scaleNode=i,this.positionNode=r,this.normalNode=o}setup(){const{textureXNode:e,textureYNode:t,textureZNode:n,scaleNode:i,positionNode:r,normalNode:o}=this;let a=o.abs().normalize();a=a.div(a.dot(D(1)));const c=r.yz.mul(i),l=r.zx.mul(i),u=r.xy.mul(i),h=e.value,d=t!==null?t.value:h,p=n!==null?n.value:h,f=xt(h,c).mul(a.x),x=xt(d,l).mul(a.y),m=xt(p,u).mul(a.z);return Wt(f,x,m)}}const Lb=K(Pb),H3=(...s)=>Lb(...s),Uo=new cs,Pr=new E,Fo=new E,Jp=new E,Xa=new Fe,Su=new E(0,0,-1),Ns=new st,qa=new E,Tu=new E,$a=new st,bu=new J,E_=new fn,W3=_r.flipX();let Kp=!1;class Db extends gs{static get type(){return"ReflectorNode"}constructor(e={}){super(E_.texture,W3);const{target:t=new yt,resolution:n=1,generateMipmaps:i=!1,bounces:r=!0}=e;this.target=t,this.resolution=n,this.generateMipmaps=i,this.bounces=r,this.updateBeforeType=r?We.RENDER:We.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new WeakMap}_updateResolution(e,t){const n=this.resolution;t.getDrawingBufferSize(bu),e.setSize(Math.round(bu.width*n),Math.round(bu.height*n))}setup(e){return this._updateResolution(E_,e.renderer),super.setup(e)}getTextureNode(){return this.textureNode}getVirtualCamera(e){let t=this.virtualCameras.get(e);return t===void 0&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return t===void 0&&(t=new fn(0,0,{type:Ln}),this.generateMipmaps===!0&&(t.texture.minFilter=uy,t.texture.generateMipmaps=!0),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&Kp)return!1;Kp=!0;const{scene:t,camera:n,renderer:i,material:r}=e,{target:o}=this,a=this.getVirtualCamera(n),c=this.getRenderTarget(a);if(i.getDrawingBufferSize(bu),this._updateResolution(c,i),Fo.setFromMatrixPosition(o.matrixWorld),Jp.setFromMatrixPosition(n.matrixWorld),Xa.extractRotation(o.matrixWorld),Pr.set(0,0,1),Pr.applyMatrix4(Xa),qa.subVectors(Fo,Jp),qa.dot(Pr)>0)return;qa.reflect(Pr).negate(),qa.add(Fo),Xa.extractRotation(n.matrixWorld),Su.set(0,0,-1),Su.applyMatrix4(Xa),Su.add(Jp),Tu.subVectors(Fo,Su),Tu.reflect(Pr).negate(),Tu.add(Fo),a.coordinateSystem=n.coordinateSystem,a.position.copy(qa),a.up.set(0,1,0),a.up.applyMatrix4(Xa),a.up.reflect(Pr),a.lookAt(Tu),a.near=n.near,a.far=n.far,a.updateMatrixWorld(),a.projectionMatrix.copy(n.projectionMatrix),Uo.setFromNormalAndCoplanarPoint(Pr,Fo),Uo.applyMatrix4(a.matrixWorldInverse),Ns.set(Uo.normal.x,Uo.normal.y,Uo.normal.z,Uo.constant);const l=a.projectionMatrix;$a.x=(Math.sign(Ns.x)+l.elements[8])/l.elements[0],$a.y=(Math.sign(Ns.y)+l.elements[9])/l.elements[5],$a.z=-1,$a.w=(1+l.elements[10])/l.elements[14],Ns.multiplyScalar(1/Ns.dot($a));const u=0;l.elements[2]=Ns.x,l.elements[6]=Ns.y,l.elements[10]=Ns.z-u,l.elements[14]=Ns.w,this.value=c.texture,r.visible=!1;const h=i.getRenderTarget(),d=i.getMRT();i.setMRT(null),i.setRenderTarget(c),i.render(t,a),i.setMRT(d),i.setRenderTarget(h),r.visible=!0,Kp=!1}}const X3=s=>H(new Db(s)),jp=new oo(-1,1,1,-1,0,1);class q3 extends at{constructor(e=!1){super();const t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new Ve([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Ve(t,2))}}const $3=new q3;class ys extends kt{constructor(e=null){super($3,e),this.camera=jp,this.isQuadMesh=!0}renderAsync(e){return e.renderAsync(this,jp)}render(e){e.render(this,jp)}}const Y3=new J;class Ub extends gs{static get type(){return"RTTNode"}constructor(e,t=null,n=null,i={type:Ln}){const r=new fn(t,n,i);super(r.texture,rt()),this.node=e,this.width=t,this.height=n,this.renderTarget=r,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this.updateMap=new WeakMap,this._rttNode=null,this._quadMesh=new ys(new Tt),this.updateBeforeType=We.RENDER}get autoSize(){return this.width===null}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;const n=e*this.pixelRatio,i=t*this.pixelRatio;this.renderTarget.setSize(n,i),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(this.textureNeedsUpdate===!1&&this.autoUpdate===!1)return;if(this.textureNeedsUpdate=!1,this.autoSize===!0){this.pixelRatio=e.getPixelRatio();const n=e.getSize(Y3);this.setSize(n.width,n.height)}this._quadMesh.material.fragmentNode=this._rttNode;const t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){const e=new gs(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const Fb=(s,...e)=>H(new Ub(H(s),...e)),ei=(s,...e)=>s.isTextureNode?s:Fb(s,...e);class Ob extends Ag{static get type(){return"VertexColorNode"}constructor(e=0){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e),n=e.hasGeometryAttribute(t);let i;return n===!0?i=super.generate(e):i=e.generateConst(this.nodeType,new st(1,1,1,1)),i}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const Z3=(...s)=>H(new Ob(...s));class Vb extends Ye{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const J3=fe(Vb);class Qi extends Ye{static get type(){return"SceneNode"}constructor(e=Qi.BACKGROUND_BLURRINESS,t=null){super(),this.scope=e,this.scene=t}setup(e){const t=this.scope,n=this.scene!==null?this.scene:e.scene;let i;return t===Qi.BACKGROUND_BLURRINESS?i=dn("backgroundBlurriness","float",n):t===Qi.BACKGROUND_INTENSITY?i=dn("backgroundIntensity","float",n):console.error("THREE.SceneNode: Unknown scope:",t),i}}Qi.BACKGROUND_BLURRINESS="backgroundBlurriness";Qi.BACKGROUND_INTENSITY="backgroundIntensity";const K3=fe(Qi,Qi.BACKGROUND_BLURRINESS),j3=fe(Qi,Qi.BACKGROUND_INTENSITY),C_={Storage:"storage",ReadOnlyStorage:"read-only-storage"},Qp={WriteOnly:"write-only",ReadOnly:"read-only"};class t0 extends Rd{static get type(){return"StorageBufferNode"}constructor(e,t,n=0){super(e,t,n),this.isStorageBufferNode=!0,this.access=C_.Storage,this.isAtomic=!1,this.bufferObject=!1,this.bufferCount=n,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(this.bufferCount===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return"storageBuffer"}element(e){return G3(this,e)}setBufferObject(e){return this.bufferObject=e,this}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(C_.ReadOnlyStorage)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}generate(e){if(e.isAvailable("storageBuffer"))return super.generate(e);const t=this.getNodeType(e);this._attribute===null&&(this._attribute=dl(this.value),this._varying=Un(this._attribute));const n=this._varying.build(e,t);return e.registerTransform(n,this._attribute),n}}const Q3=(s,e,t)=>H(new t0(s,e,t)),eD=(s,e,t)=>H(new t0(s,e,t).setBufferObject(!0));class Bb extends gs{static get type(){return"StorageTextureNode"}constructor(e,t,n=null){super(e,t),this.storeNode=n,this.isStorageTextureNode=!0,this.access=Qp.WriteOnly}getInputType(){return"storageTexture"}setup(e){super.setup(e);const t=e.getNodeProperties(this);t.storeNode=this.storeNode}setAccess(e){return this.access=e,this}generate(e,t){let n;return this.storeNode!==null?n=this.generateStore(e):n=super.generate(e,t),n}toReadOnly(){return this.setAccess(Qp.ReadOnly)}toWriteOnly(){return this.setAccess(Qp.WriteOnly)}generateStore(e){const t=e.getNodeProperties(this),{uvNode:n,storeNode:i}=t,r=super.generate(e,"property"),o=n.build(e,"uvec2"),a=i.build(e,"vec4"),c=e.generateTextureStore(e,r,o,a);e.addLineFlowCode(c,this)}}const zb=K(Bb),tD=(s,e,t)=>{const n=zb(s,e,t);return t!==null&&n.append(),n};class kb extends ml{static get type(){return"UserDataNode"}constructor(e,t,n=null){super(e,t,n),this.userData=n}updateReference(e){return this.reference=this.userData!==null?this.userData:e.object.userData,this.reference}}const nD=(s,e,t)=>H(new kb(s,e,t));class Gb extends pt{static get type(){return"PosterizeNode"}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){const{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}}const iD=K(Gb);let ef=null;class Hb extends vl{static get type(){return"ViewportSharedTextureNode"}constructor(e=_r,t=null){ef===null&&(ef=new fm),super(e,t,ef)}updateReference(){return this}}const sD=K(Hb),rD=new J;class Wb extends gs{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return e.object.isQuadMesh&&this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class R_ extends Wb{static get type(){return"PassMultipleTextureNode"}constructor(e,t,n=!1){super(e,null),this.textureName=t,this.previousTexture=n}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}}class bn extends pt{static get type(){return"PassNode"}constructor(e,t,n,i={}){super("vec4"),this.scope=e,this.scene=t,this.camera=n,this.options=i,this._pixelRatio=1,this._width=1,this._height=1;const r=new ao;r.isRenderTargetTexture=!0,r.name="depth";const o=new fn(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Ln,...i});o.texture.name="output",o.depthTexture=r,this.renderTarget=o,this.updateBeforeType=We.FRAME,this._textures={output:o.texture,depth:r},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=pe(0),this._cameraFar=pe(0),this._mrt=null,this.isPassNode=!0}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}isGlobal(){return!0}getTexture(e){let t=this._textures[e];return t===void 0&&(t=this.renderTarget.texture.clone(),t.isRenderTargetTexture=!0,t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)),t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),t.isRenderTargetTexture=!0,this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(t!==void 0){const n=this._textures[e],i=this.renderTarget.textures.indexOf(n);this.renderTarget.textures[i]=t,this._textures[e]=t,this._previousTextures[e]=n,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return t===void 0&&(this._textureNodes[e]=t=H(new R_(this,e)),this._textureNodes[e].updateTexture()),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),this._previousTextureNodes[e]=t=H(new R_(this,e,!0)),this._previousTextureNodes[e].updateTexture()),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(t===void 0){const n=this._cameraNear,i=this._cameraFar;this._viewZNodes[e]=t=Vg(this.getTextureNode(e),n,i)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(t===void 0){const n=this._cameraNear,i=this._cameraFar,r=this.getViewZNode(e);this._linearDepthNodes[e]=t=rc(r,n,i)}return t}setup({renderer:e}){return this.renderTarget.samples=this.options.samples===void 0?e.samples:this.options.samples,e.backend.isWebGLBackend===!0&&(this.renderTarget.samples=0),this.renderTarget.depthTexture.isMultisampleRenderTargetTexture=this.renderTarget.samples>1,this.scope===bn.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:n,camera:i}=this;this._pixelRatio=t.getPixelRatio();const r=t.getSize(rD);this.setSize(r.width,r.height);const o=t.getRenderTarget(),a=t.getMRT();this._cameraNear.value=i.near,this._cameraFar.value=i.far;for(const c in this._previousTextures)this.toggleTexture(c);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(n,i),t.setRenderTarget(o),t.setMRT(a)}setSize(e,t){this._width=e,this._height=t;const n=this._width*this._pixelRatio,i=this._height*this._pixelRatio;this.renderTarget.setSize(n,i)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}bn.COLOR="color";bn.DEPTH="depth";const oD=(s,e,t)=>H(new bn(bn.COLOR,s,e,t)),Na=(s,e)=>H(new Wb(s,e)),aD=(s,e)=>H(new bn(bn.DEPTH,s,e)),I_=new ys,P_=new ys;class Xb extends pt{static get type(){return"GaussianBlurNode"}constructor(e,t=null,n=2){super("vec4"),this.textureNode=e,this.directionNode=t,this.sigma=n,this._invSize=pe(new J),this._passDirection=pe(new J),this._horizontalRT=new fn,this._horizontalRT.texture.name="GaussianBlurNode.horizontal",this._verticalRT=new fn,this._verticalRT.texture.name="GaussianBlurNode.vertical",this._textureNode=Na(this,this._verticalRT.texture),this.updateBeforeType=We.RENDER,this.resolution=new J(1,1)}setSize(e,t){e=Math.max(Math.round(e*this.resolution.x),1),t=Math.max(Math.round(t*this.resolution.y),1),this._invSize.value.set(1/e,1/t),this._horizontalRT.setSize(e,t),this._verticalRT.setSize(e,t)}updateBefore(e){const{renderer:t}=e,n=this.textureNode,i=n.value,r=t.getRenderTarget(),o=t.getMRT(),a=n.value;I_.material=this._material,P_.material=this._material,this.setSize(i.image.width,i.image.height);const c=i.type;this._horizontalRT.texture.type=c,this._verticalRT.texture.type=c,t.setMRT(null),t.setRenderTarget(this._horizontalRT),this._passDirection.value.set(1,0),I_.render(t),n.value=this._horizontalRT.texture,t.setRenderTarget(this._verticalRT),this._passDirection.value.set(0,1),P_.render(t),t.setRenderTarget(r),t.setMRT(o),n.value=a}getTextureNode(){return this._textureNode}setup(e){const t=this.textureNode;if(t.isTextureNode!==!0)return console.error("GaussianBlurNode requires a TextureNode."),oe();const n=t.uvNode||rt(),i=z(this.directionNode||1),r=l=>t.uv(l),o=U(()=>{const l=3+2*this.sigma,u=this._getCoefficients(l),h=this._invSize,d=i.mul(this._passDirection),p=A(u[0]).toVar(),f=oe(r(n).mul(p)).toVar();for(let x=1;x<l;x++){const m=A(x),g=A(u[x]),y=z(d.mul(h.mul(m))).toVar(),_=oe(r(n.add(y))),v=oe(r(n.sub(y)));f.addAssign(_.add(v).mul(g)),p.addAssign(ot(2,g))}return f.div(p)}),a=this._material||(this._material=new Tt);a.fragmentNode=o().context(e.getSharedContext()),a.name="Gaussian_blur",a.needsUpdate=!0;const c=e.getNodeProperties(this);return c.textureNode=t,this._textureNode}dispose(){this._horizontalRT.dispose(),this._verticalRT.dispose()}_getCoefficients(e){const t=[];for(let n=0;n<e;n++)t.push(.39894*Math.exp(-.5*n*n/(e*e))/e);return t}}const cD=(s,e,t)=>H(new Xb(ei(s),e,t)),tf=new J,L_=new ys;class qb extends pt{static get type(){return"AfterImageNode"}constructor(e,t=.96){super(e),this.textureNode=e,this.textureNodeOld=xt(),this.damp=pe(t),this._compRT=new fn,this._compRT.texture.name="AfterImageNode.comp",this._oldRT=new fn,this._oldRT.texture.name="AfterImageNode.old",this._textureNode=Na(this,this._compRT.texture),this.updateBeforeType=We.RENDER}getTextureNode(){return this._textureNode}setSize(e,t){this._compRT.setSize(e,t),this._oldRT.setSize(e,t)}updateBefore(e){const{renderer:t}=e,n=this.textureNode,r=n.value.type;this._compRT.texture.type=r,this._oldRT.texture.type=r,t.getDrawingBufferSize(tf),this.setSize(tf.x,tf.y);const o=t.getRenderTarget(),a=n.value;this.textureNodeOld.value=this._oldRT.texture,t.setRenderTarget(this._compRT),L_.render(t);const c=this._oldRT;this._oldRT=this._compRT,this._compRT=c,t.setRenderTarget(o),n.value=a}setup(e){const t=this.textureNode,n=this.textureNodeOld,i=t.uvNode||rt();n.uvNode=i;const r=u=>t.uv(u),o=U(([u,h])=>{const d=A(h).toVar(),p=oe(u).toVar();return ft(cl(p.sub(d)),0)}),a=U(()=>{const u=oe(n),h=oe(r(i));return u.mulAssign(this.damp.mul(o(u,.1))),ft(h,u)}),c=this._materialComposed||(this._materialComposed=new Tt);c.name="AfterImage",c.fragmentNode=a(),L_.material=c;const l=e.getNodeProperties(this);return l.textureNode=t,this._textureNode}dispose(){this._compRT.dispose(),this._oldRT.dispose()}}const lD=(s,e)=>H(new qb(ei(s),e)),uD=U(([s])=>En(s.rgb)),hD=U(([s,e=A(1)])=>e.mix(En(s.rgb),s.rgb)),dD=U(([s,e=A(1)])=>{const t=Wt(s.r,s.g,s.b).div(3),n=s.r.max(s.g.max(s.b)),i=n.sub(t).mul(e).mul(-3);return it(s.rgb,n,i)}),pD=U(([s,e=A(1)])=>{const t=D(.57735,.57735,.57735),n=e.cos();return D(s.rgb.mul(n).add(t.cross(s.rgb).mul(e.sin()).add(t.mul($t(t,s.rgb).mul(n.oneMinus())))))}),fD=new E,En=(s,e=D(...gt.getLuminanceCoefficients(fD)))=>$t(s,e),$b=(s,e)=>it(D(0),s,En(s).sub(e).max(0)),D_=new ys;class Yb extends pt{static get type(){return"AnamorphicNode"}constructor(e,t,n,i){super("vec4"),this.textureNode=e,this.tresholdNode=t,this.scaleNode=n,this.colorNode=D(.1,0,1),this.samples=i,this.resolution=new J(1,1),this._renderTarget=new fn,this._renderTarget.texture.name="anamorphic",this._invSize=pe(new J),this._textureNode=Na(this,this._renderTarget.texture),this.updateBeforeType=We.RENDER}getTextureNode(){return this._textureNode}setSize(e,t){this._invSize.value.set(1/e,1/t),e=Math.max(Math.round(e*this.resolution.x),1),t=Math.max(Math.round(t*this.resolution.y),1),this._renderTarget.setSize(e,t)}updateBefore(e){const{renderer:t}=e,n=this.textureNode,i=n.value;this._renderTarget.texture.type=i.type;const r=t.getRenderTarget(),o=n.value;D_.material=this._material,this.setSize(i.image.width,i.image.height),t.setRenderTarget(this._renderTarget),D_.render(t),t.setRenderTarget(r),n.value=o}setup(e){const t=this.textureNode,n=t.uvNode||rt(),i=c=>t.uv(c),r=U(()=>{const c=this.samples,l=Math.floor(c/2),u=D(0).toVar();return mt({start:-l,end:l},({i:h})=>{const d=A(h).abs().div(l).oneMinus(),p=z(n.x.add(this._invSize.x.mul(h).mul(this.scaleNode)),n.y),f=i(p),x=$b(f,this.tresholdNode).mul(d);u.addAssign(x)}),u.mul(this.colorNode)}),o=this._material||(this._material=new Tt);o.name="Anamorphic",o.fragmentNode=r();const a=e.getNodeProperties(this);return a.textureNode=t,this._textureNode}dispose(){this._renderTarget.dispose()}}const mD=(s,e=.9,t=3,n=32)=>H(new Yb(ei(s),H(e),H(t),n));class Zb extends pt{static get type(){return"SobelOperatorNode"}constructor(e){super(),this.textureNode=e,this.updateBeforeType=We.RENDER,this._invSize=pe(new J)}updateBefore(){const e=this.textureNode.value;this._invSize.value.set(1/e.image.width,1/e.image.height)}setup(){const{textureNode:e}=this,t=e.uvNode||rt(),n=o=>e.uv(o);return U(()=>{const o=this._invSize,a=Tn(-1,-2,-1,0,0,0,1,2,1),c=Tn(-1,0,1,-2,0,2,-1,0,1),l=En(n(t.add(o.mul(z(-1,-1)))).xyz),u=En(n(t.add(o.mul(z(-1,0)))).xyz),h=En(n(t.add(o.mul(z(-1,1)))).xyz),d=En(n(t.add(o.mul(z(0,-1)))).xyz),p=En(n(t.add(o.mul(z(0,0)))).xyz),f=En(n(t.add(o.mul(z(0,1)))).xyz),x=En(n(t.add(o.mul(z(1,-1)))).xyz),m=En(n(t.add(o.mul(z(1,0)))).xyz),g=En(n(t.add(o.mul(z(1,1)))).xyz),y=Wt(a[0][0].mul(l),a[1][0].mul(d),a[2][0].mul(x),a[0][1].mul(u),a[1][1].mul(p),a[2][1].mul(m),a[0][2].mul(h),a[1][2].mul(f),a[2][2].mul(g)),_=Wt(c[0][0].mul(l),c[1][0].mul(d),c[2][0].mul(x),c[0][1].mul(u),c[1][1].mul(p),c[2][1].mul(m),c[0][2].mul(h),c[1][2].mul(f),c[2][2].mul(g)),v=y.mul(y).add(_.mul(_)).sqrt();return oe(D(v),1)})()}}const gD=s=>H(new Zb(ei(s)));class Jb extends pt{static get type(){return"DepthOfFieldNode"}constructor(e,t,n,i,r){super(),this.textureNode=e,this.viewZNode=t,this.focusNode=n,this.apertureNode=i,this.maxblurNode=r,this._aspect=pe(0),this.updateBeforeType=We.RENDER}updateBefore(){const e=this.textureNode.value;this._aspect.value=e.image.width/e.image.height}setup(){const e=this.textureNode,t=e.uvNode||rt(),n=o=>e.uv(o);return U(()=>{const o=z(1,this._aspect),a=this.focusNode.add(this.viewZNode),c=z(cn(a.mul(this.apertureNode),this.maxblurNode.negate(),this.maxblurNode)),l=c.mul(.9),u=c.mul(.7),h=c.mul(.4);let d=oe(0);return d=d.add(n(t)),d=d.add(n(t.add(z(0,.4).mul(o).mul(c)))),d=d.add(n(t.add(z(.15,.37).mul(o).mul(c)))),d=d.add(n(t.add(z(.29,.29).mul(o).mul(c)))),d=d.add(n(t.add(z(-.37,.15).mul(o).mul(c)))),d=d.add(n(t.add(z(.4,0).mul(o).mul(c)))),d=d.add(n(t.add(z(.37,-.15).mul(o).mul(c)))),d=d.add(n(t.add(z(.29,-.29).mul(o).mul(c)))),d=d.add(n(t.add(z(-.15,-.37).mul(o).mul(c)))),d=d.add(n(t.add(z(0,-.4).mul(o).mul(c)))),d=d.add(n(t.add(z(-.15,.37).mul(o).mul(c)))),d=d.add(n(t.add(z(-.29,.29).mul(o).mul(c)))),d=d.add(n(t.add(z(.37,.15).mul(o).mul(c)))),d=d.add(n(t.add(z(-.4,0).mul(o).mul(c)))),d=d.add(n(t.add(z(-.37,-.15).mul(o).mul(c)))),d=d.add(n(t.add(z(-.29,-.29).mul(o).mul(c)))),d=d.add(n(t.add(z(.15,-.37).mul(o).mul(c)))),d=d.add(n(t.add(z(.15,.37).mul(o).mul(l)))),d=d.add(n(t.add(z(-.37,.15).mul(o).mul(l)))),d=d.add(n(t.add(z(.37,-.15).mul(o).mul(l)))),d=d.add(n(t.add(z(-.15,-.37).mul(o).mul(l)))),d=d.add(n(t.add(z(-.15,.37).mul(o).mul(l)))),d=d.add(n(t.add(z(.37,.15).mul(o).mul(l)))),d=d.add(n(t.add(z(-.37,-.15).mul(o).mul(l)))),d=d.add(n(t.add(z(.15,-.37).mul(o).mul(l)))),d=d.add(n(t.add(z(.29,.29).mul(o).mul(u)))),d=d.add(n(t.add(z(.4,0).mul(o).mul(u)))),d=d.add(n(t.add(z(.29,-.29).mul(o).mul(u)))),d=d.add(n(t.add(z(0,-.4).mul(o).mul(u)))),d=d.add(n(t.add(z(-.29,.29).mul(o).mul(u)))),d=d.add(n(t.add(z(-.4,0).mul(o).mul(u)))),d=d.add(n(t.add(z(-.29,-.29).mul(o).mul(u)))),d=d.add(n(t.add(z(0,.4).mul(o).mul(u)))),d=d.add(n(t.add(z(.29,.29).mul(o).mul(h)))),d=d.add(n(t.add(z(.4,0).mul(o).mul(h)))),d=d.add(n(t.add(z(.29,-.29).mul(o).mul(h)))),d=d.add(n(t.add(z(0,-.4).mul(o).mul(h)))),d=d.add(n(t.add(z(-.29,.29).mul(o).mul(h)))),d=d.add(n(t.add(z(-.4,0).mul(o).mul(h)))),d=d.add(n(t.add(z(-.29,-.29).mul(o).mul(h)))),d=d.add(n(t.add(z(0,.4).mul(o).mul(h)))),d=d.div(41),d.a=1,oe(d)})()}}const xD=(s,e,t=1,n=.025,i=1)=>H(new Jb(ei(s),H(e),H(t),H(n),H(i)));class Kb extends pt{static get type(){return"DotScreenNode"}constructor(e,t=new J(.5,.5),n=1.57,i=1){super("vec4"),this.inputNode=e,this.center=pe(t),this.angle=pe(n),this.scale=pe(i)}setup(){const e=this.inputNode,t=U(()=>{const r=Cn(this.angle),o=Mi(this.angle),a=rt().mul(da).sub(this.center),c=z(o.mul(a.x).sub(r.mul(a.y)),r.mul(a.x).add(o.mul(a.y))).mul(this.scale);return Cn(c.x).mul(Cn(c.y)).mul(4)});return U(()=>{const r=e,o=Wt(r.r,r.g,r.b).div(3);return oe(D(o.mul(10).sub(5).add(t())),r.a)})()}}const _D=(s,e,t,n)=>H(new Kb(H(s),e,t,n));class jb extends pt{static get type(){return"RGBShiftNode"}constructor(e,t=.005,n=0){super("vec4"),this.textureNode=e,this.amount=pe(t),this.angle=pe(n)}setup(){const{textureNode:e}=this,t=e.uvNode||rt(),n=r=>e.uv(r);return U(()=>{const r=z(Mi(this.angle),Cn(this.angle)).mul(this.amount),o=n(t.add(r)),a=n(t),c=n(t.sub(r));return oe(o.r,a.g,c.b,a.a)})()}}const yD=(s,e,t)=>H(new jb(ei(s),e,t));class Qb extends pt{static get type(){return"FilmNode"}constructor(e,t=null,n=null){super(),this.inputNode=e,this.intensityNode=t,this.uvNode=n}setup(){const e=this.uvNode||rt();return U(()=>{const i=this.inputNode.rgb,r=yg(xr(e.add(e0())));let o=i.add(i.mul(cn(r.add(.1),0,1)));return this.intensityNode!==null&&(o=it(i,o,this.intensityNode)),oe(o,this.inputNode.a)})()}}const vD=K(Qb);class ew extends pt{static get type(){return"Lut3DNode"}constructor(e,t,n,i){super(),this.inputNode=e,this.lutNode=t,this.size=pe(n),this.intensityNode=i}setup(){const{inputNode:e,lutNode:t}=this,n=o=>t.uv(o);return U(()=>{const o=e,a=A(1).div(this.size),c=A(.5).div(this.size),l=D(c).add(o.rgb.mul(A(1).sub(a))),u=oe(n(l).rgb,o.a);return oe(it(o,u,this.intensityNode))})()}}const MD=(s,e,t,n)=>H(new ew(H(s),H(e),t,H(n))),U_=new ys,F_=new _e,SD=new J;class tw extends pt{static get type(){return"GTAONode"}constructor(e,t,n){super(),this.depthNode=e,this.normalNode=t,this.radius=pe(.25),this.resolution=pe(new J),this.thickness=pe(1),this.distanceExponent=pe(1),this.distanceFallOff=pe(1),this.scale=pe(1),this.noiseNode=xt(TD()),this.cameraProjectionMatrix=pe(n.projectionMatrix),this.cameraProjectionMatrixInverse=pe(n.projectionMatrixInverse),this.SAMPLES=pe(16),this._aoRenderTarget=new fn,this._aoRenderTarget.texture.name="GTAONode.AO",this._material=null,this._textureNode=Na(this,this._aoRenderTarget.texture),this.updateBeforeType=We.FRAME}getTextureNode(){return this._textureNode}setSize(e,t){this.resolution.value.set(e,t),this._aoRenderTarget.setSize(e,t)}updateBefore(e){const{renderer:t}=e,n=t.getDrawingBufferSize(SD),i=t.getRenderTarget(),r=t.getMRT();t.getClearColor(F_);const o=t.getClearAlpha();U_.material=this._material,this.setSize(n.width,n.height),t.setMRT(null),t.setClearColor(16777215,1),t.setRenderTarget(this._aoRenderTarget),U_.render(t),t.setRenderTarget(i),t.setMRT(r),t.setClearColor(F_,o)}setup(e){const t=rt(),n=l=>this.depthNode.uv(l).x,i=l=>this.noiseNode.uv(l),r=U(([l])=>{const u=this.cameraProjectionMatrix.mul(oe(l,1));let h=u.xy.div(u.w).mul(.5).add(.5).toVar();h=z(h.x,h.y.oneMinus());const d=n(h);return D(h,d)}),o=U(([l,u])=>{l=z(l.x,l.y.oneMinus()).mul(2).sub(1);const h=oe(D(l,u),1),d=oe(this.cameraProjectionMatrixInverse.mul(h));return d.xyz.div(d.w)}),a=U(()=>{const l=n(t);l.greaterThanEqual(1).discard();const u=o(t,l),h=this.normalNode.rgb.normalize(),d=this.radius,p=tr(this.noiseNode,0);let f=z(t.x,t.y.oneMinus());f=f.mul(this.resolution.div(p));const x=i(f),m=x.xyz.mul(2).sub(1),g=D(m.xy,0).normalize(),y=D(g.y.mul(-1),g.x,0),_=Tn(g,y,D(0,0,1)),v=this.SAMPLES.lessThan(30).select(3,5),I=Wt(this.SAMPLES,v.sub(1)).div(v),T=A(0).toVar();return mt({start:L(0),end:v,type:"int",condition:"<"},({i:w})=>{const C=A(w).div(A(v)).mul(to),F=oe(Mi(C),Cn(C),0,Wt(.5,ot(.5,x.w)));F.xyz=vi(_.mul(F.xyz));const M=vi(u.xyz.negate()),b=vi(Qo(F.xyz,M)),G=Qo(b,M),W=vi(h.sub(b.mul($t(h,b)))),$=Qo(W,b),ie=z($t(M,$),$t(M,$.negate())).toVar();mt({end:I,type:"int",name:"j",condition:"<"},({j:Qe})=>{const ht=F.xyz.mul(d).mul(F.w).mul(Kn(ns(A(Qe).add(1),A(I)),this.distanceExponent)),ne=r(u.add(ht)),Ae=o(ne.xy,ne.z).sub(u);Oe(Dt(Ae.z).lessThan(this.thickness),()=>{const Je=$t(M,vi(Ae));ie.x.addAssign(ft(0,ot(Je.sub(ie.x),it(1,A(2).div(A(Qe).add(2)),this.distanceFallOff))))});const ge=r(u.sub(ht)),Xe=o(ge.xy,ge.z).sub(u);Oe(Dt(Xe.z).lessThan(this.thickness),()=>{const Je=$t(M,vi(Xe));ie.y.addAssign(ft(0,ot(Je.sub(ie.y),it(1,A(2).div(A(Qe).add(2)),this.distanceFallOff))))})});const q=os(Ft(1,ie.mul(ie))),he=$t(W,G),Q=$t(W,M),we=ot(.5,gh(ie.y).sub(gh(ie.x)).add(q.x.mul(ie.x).sub(q.y.mul(ie.y)))),Ne=ot(.5,Ft(2,ie.x.mul(ie.x)).sub(ie.y.mul(ie.y))),Ee=he.mul(we).add(Q.mul(Ne));T.addAssign(Ee)}),T.assign(cn(T.div(v),0,1)),T.assign(Kn(T,this.scale)),oe(D(T),1)}),c=this._material||(this._material=new Tt);return c.fragmentNode=a().context(e.getSharedContext()),c.name="GTAO",c.needsUpdate=!0,this._textureNode}dispose(){this._aoRenderTarget.dispose()}}function TD(s=5){const e=Math.floor(s)%2===0?Math.floor(s)+1:Math.floor(s),t=bD(e),n=t.length,i=new Uint8Array(n*4);for(let o=0;o<n;++o){const a=t[o],c=2*Math.PI*a/n,l=new E(Math.cos(c),Math.sin(c),0).normalize();i[o*4]=(l.x*.5+.5)*255,i[o*4+1]=(l.y*.5+.5)*255,i[o*4+2]=127,i[o*4+3]=255}const r=new Oi(i,e,e);return r.wrapS=rr,r.wrapT=rr,r.needsUpdate=!0,r}function bD(s){const e=Math.floor(s)%2===0?Math.floor(s)+1:Math.floor(s),t=e*e,n=Array(t).fill(0);let i=Math.floor(e/2),r=e-1;for(let o=1;o<=t;){if(i===-1&&r===e?(r=e-2,i=0):(r===e&&(r=0),i<0&&(i=e-1)),n[i*e+r]!==0){r-=2,i++;continue}else n[i*e+r]=o++;r++,i--}return n}const wD=(s,e,t)=>H(new tw(H(s),H(e),t));class nw extends pt{static get type(){return"DenoiseNode"}constructor(e,t,n,i,r){super(),this.textureNode=e,this.depthNode=t,this.normalNode=n,this.noiseNode=i,this.cameraProjectionMatrixInverse=pe(r.projectionMatrixInverse),this.lumaPhi=pe(5),this.depthPhi=pe(5),this.normalPhi=pe(5),this.radius=pe(5),this.index=pe(0),this._resolution=pe(new J),this._sampleVectors=ds(AD(16,2,1)),this.updateBeforeType=We.RENDER}updateBefore(){const e=this.textureNode.value;this._resolution.value.set(e.image.width,e.image.height)}setup(){const e=rt(),t=h=>this.textureNode.uv(h),n=h=>this.depthNode.uv(h).x,i=h=>this.normalNode.uv(h),r=h=>this.noiseNode.uv(h),o=U(([h,d])=>{h=z(h.x,h.y.oneMinus()).mul(2).sub(1);const p=oe(D(h,d),1),f=oe(this.cameraProjectionMatrixInverse.mul(p));return f.xyz.div(f.w)}),a=U(([h,d,p,f])=>{const x=t(f),m=n(f),g=i(f).rgb.normalize(),y=x.rgb,_=o(f,m),v=$t(d,g).toVar(),I=Kn(ft(v,0),this.normalPhi).toVar(),T=Dt(En(y).sub(En(h))).toVar(),w=ft(A(1).sub(T.div(this.lumaPhi)),0).toVar(),C=Dt($t(p.sub(_),d)).toVar(),F=ft(A(1).sub(C.div(this.depthPhi)),0),M=w.mul(F).mul(I);return oe(y.mul(M),M)}),c=U(([h])=>{const d=n(h),p=i(h).rgb.normalize(),f=t(h);Oe(d.greaterThanEqual(1).or($t(p,p).equal(0)),()=>f);const x=D(f.rgb),m=o(h,d),g=tr(this.noiseNode,0);let y=z(h.x,h.y.oneMinus());y=y.mul(this._resolution.div(g));const _=r(y),v=Cn(_.element(this.index.mod(4).mul(2).mul(to))),I=Mi(_.element(this.index.mod(4).mul(2).mul(to))),T=z(v,I),w=ol(T.x,T.y.negate(),T.x,T.y),C=A(1).toVar(),F=D(f.rgb).toVar();return mt({start:L(0),end:L(16),type:"int",condition:"<"},({i:M})=>{const b=this._sampleVectors.element(M).toVar(),G=w.mul(b.xy.mul(A(1).add(b.z.mul(this.radius.sub(1))))).div(this._resolution).toVar(),W=h.add(G).toVar(),$=a(x,p,m,W);F.addAssign($.xyz),C.addAssign($.w)}),Oe(C.greaterThan(A(0)),()=>{F.divAssign(C)}),oe(F,f.a)}).setLayout({name:"denoise",type:"vec4",inputs:[{name:"uv",type:"vec2"}]});return U(()=>c(e))()}}function AD(s,e,t){const n=ND(s,e,t),i=[];for(let r=0;r<s;r++){const o=n[r];i.push(o)}return i}function ND(s,e,t){const n=[];for(let i=0;i<s;i++){const r=2*Math.PI*e*i/s,o=Math.pow(i/(s-1),t);n.push(new E(Math.cos(r),Math.sin(r),o))}return n}const ED=(s,e,t,n,i)=>H(new nw(ei(s),H(e),H(t),H(n),i));class iw extends pt{static get type(){return"FXAANode"}constructor(e){super(),this.textureNode=e,this.updateBeforeType=We.RENDER,this._invSize=pe(new J)}updateBefore(){const e=this.textureNode.value;this._invSize.value.set(1/e.image.width,1/e.image.height)}setup(){const e=this.textureNode.bias(-100),t=e.uvNode||rt(),n=u=>e.uv(u),i=(u,h,d)=>e.uv(u.add(h.mul(d))),r=L(5),o=U(([u,h])=>{const d=oe(h).toVar(),p=oe(u).toVar(),f=oe(Dt(p.sub(d))).toVar();return ft(ft(ft(f.r,f.g),f.b),f.a)}),a=U(([u,h,d,p])=>{const f=n(u).toVar(),x=i(u,z(0,-1),h.xy).toVar(),m=i(u,z(1,0),h.xy).toVar(),g=i(u,z(0,1),h.xy).toVar(),y=i(u,z(-1,0),h.xy).toVar(),_=o(f,g).toVar(),v=o(f,x).toVar(),I=o(f,m).toVar(),T=o(f,y).toVar(),w=ft(_,ft(v,ft(I,T))).toVar();Oe(w.lessThan(d),()=>f);const C=Ft(_.add(v),I.add(T)).toVar();C.mulAssign(p),Oe(Dt(C).lessThan(.3),()=>{const ht=I.greaterThan(T).select(1,-1).toVar(),ne=v.greaterThan(_).select(1,-1).toVar(),ue=z(ht,ne).toVar(),Ae=i(u,z(ue.x,ue.y),h.xy),ge=o(f,Ae).toVar(),Ze=i(u,z(ue.x.negate(),ue.y.negate()),h.xy),Xe=o(f,Ze).toVar();C.assign(Xe.sub(ge)),C.mulAssign(p),Oe(Dt(C).lessThan(.3),()=>{const Je=g.add(x).add(m).add(y);return it(f,Je.mul(.25),.4)})});const F=z().toVar();Oe(C.lessThanEqual(0),()=>{g.assign(y),x.assign(m),F.x.assign(0),F.y.assign(h.y)}).Else(()=>{F.x.assign(h.x),F.y.assign(0)});const M=o(f,g).toVar(),b=o(f,x).toVar();Oe(M.lessThanEqual(b),()=>{g.assign(x)});const G=L(0).toVar(),W=L(0).toVar(),$=A(0).toVar(),ie=A(0).toVar(),q=z(u).toVar(),he=z(u).toVar(),Q=L(0).toVar(),we=L(0).toVar();mt(r,({i:ht})=>{const ne=ht.add(1).toVar();Oe(G.equal(0),()=>{$.addAssign(ne),q.assign(u.add(F.mul($)));const ue=n(q.xy),Ae=o(ue,f).toVar(),ge=o(ue,g).toVar();Oe(Ae.greaterThan(ge),()=>{G.assign(1)}),Q.assign(ht)}),Oe(W.equal(0),()=>{ie.addAssign(ne),he.assign(u.sub(F.mul(ie)));const ue=n(he.xy),Ae=o(ue,f).toVar(),ge=o(ue,g).toVar();Oe(Ae.greaterThan(ge),()=>{W.assign(1)}),we.assign(ht)}),Oe(G.equal(1).or(W.equal(1)),()=>{Ld()})}),Oe(G.equal(0).and(W.equal(0)),()=>f);const Ne=A(1).toVar(),Ee=A(1).toVar();Oe(G.equal(1),()=>{Ne.assign(A(Q).div(A(r.sub(1))))}),Oe(W.equal(1),()=>{Ee.assign(A(we).div(A(r.sub(1))))});const Qe=Mn(Ne,Ee);return Qe.assign(Kn(Qe,.5)),Qe.assign(A(1).sub(Qe)),it(f,g,Qe.mul(.5))}).setLayout({name:"FxaaPixelShader",type:"vec4",inputs:[{name:"uv",type:"vec2"},{name:"fxaaQualityRcpFrame",type:"vec2"},{name:"fxaaQualityEdgeThreshold",type:"float"},{name:"fxaaQualityinvEdgeThreshold",type:"float"}]});return U(()=>{const u=A(.2),h=A(1).div(u);return a(t,this._invSize,u,h)})()}}const CD=s=>H(new iw(ei(s))),Lr=new ys,RD=new _e(0,0,0),O_=new _e,ID=new J,PD=new J(1,0),LD=new J(0,1);class sw extends pt{static get type(){return"BloomNode"}constructor(e,t=1,n=0,i=0){super(),this.inputNode=e,this.strength=pe(t),this.radius=pe(n),this.threshold=pe(i),this.smoothWidth=pe(.01),this._renderTargetsHorizontal=[],this._renderTargetsVertical=[],this._nMips=5,this._renderTargetBright=new fn(1,1,{type:Ln}),this._renderTargetBright.texture.name="UnrealBloomPass.bright",this._renderTargetBright.texture.generateMipmaps=!1;for(let r=0;r<this._nMips;r++){const o=new fn(1,1,{type:Ln});o.texture.name="UnrealBloomPass.h"+r,o.texture.generateMipmaps=!1,this._renderTargetsHorizontal.push(o);const a=new fn(1,1,{type:Ln});a.texture.name="UnrealBloomPass.v"+r,a.texture.generateMipmaps=!1,this._renderTargetsVertical.push(a)}this._compositeMaterial=null,this._highPassFilterMaterial=null,this._separableBlurMaterials=[],this._textureNodeBright=xt(this._renderTargetBright.texture),this._textureNodeBlur0=xt(this._renderTargetsVertical[0].texture),this._textureNodeBlur1=xt(this._renderTargetsVertical[1].texture),this._textureNodeBlur2=xt(this._renderTargetsVertical[2].texture),this._textureNodeBlur3=xt(this._renderTargetsVertical[3].texture),this._textureNodeBlur4=xt(this._renderTargetsVertical[4].texture),this._textureOutput=Na(this,this._renderTargetsHorizontal[0].texture),this.updateBeforeType=We.FRAME}getTextureNode(){return this._textureOutput}setSize(e,t){let n=Math.round(e/2),i=Math.round(t/2);this._renderTargetBright.setSize(n,i);for(let r=0;r<this._nMips;r++)this._renderTargetsHorizontal[r].setSize(n,i),this._renderTargetsVertical[r].setSize(n,i),this._separableBlurMaterials[r].invSize.value.set(1/n,1/i),n=Math.round(n/2),i=Math.round(i/2)}updateBefore(e){const{renderer:t}=e,n=t.getDrawingBufferSize(ID);this.setSize(n.width,n.height);const i=t.getRenderTarget(),r=t.getMRT();t.getClearColor(O_);const o=t.getClearAlpha();this.setSize(n.width,n.height),t.setMRT(null),t.setClearColor(RD,0),t.setRenderTarget(this._renderTargetBright),Lr.material=this._highPassFilterMaterial,Lr.render(t);let a=this._renderTargetBright;for(let c=0;c<this._nMips;c++)Lr.material=this._separableBlurMaterials[c],this._separableBlurMaterials[c].colorTexture.value=a.texture,this._separableBlurMaterials[c].direction.value=PD,t.setRenderTarget(this._renderTargetsHorizontal[c]),t.clear(),Lr.render(t),this._separableBlurMaterials[c].colorTexture.value=this._renderTargetsHorizontal[c].texture,this._separableBlurMaterials[c].direction.value=LD,t.setRenderTarget(this._renderTargetsVertical[c]),t.clear(),Lr.render(t),a=this._renderTargetsVertical[c];t.setRenderTarget(this._renderTargetsHorizontal[0]),t.clear(),Lr.material=this._compositeMaterial,Lr.render(t),t.setRenderTarget(i),t.setMRT(r),t.setClearColor(O_,o)}setup(e){const t=U(()=>{const c=this.inputNode,l=En(c.rgb),u=ti(this.threshold,this.threshold.add(this.smoothWidth),l);return it(oe(0),c,u)});this._highPassFilterMaterial=this._highPassFilterMaterial||new Tt,this._highPassFilterMaterial.fragmentNode=t().context(e.getSharedContext()),this._highPassFilterMaterial.name="Bloom_highPass",this._highPassFilterMaterial.needsUpdate=!0;const n=[3,5,7,9,11];for(let c=0;c<this._nMips;c++)this._separableBlurMaterials.push(this._getSeperableBlurMaterial(e,n[c]));const i=ds([1,.8,.6,.4,.2]),r=ds([new E(1,1,1),new E(1,1,1),new E(1,1,1),new E(1,1,1),new E(1,1,1)]),o=U(([c,l])=>{const u=A(1.2).sub(c);return it(c,u,l)}).setLayout({name:"lerpBloomFactor",type:"float",inputs:[{name:"factor",type:"float"},{name:"radius",type:"float"}]}),a=U(()=>{const c=o(i.element(0),this.radius).mul(oe(r.element(0),1)).mul(this._textureNodeBlur0),l=o(i.element(1),this.radius).mul(oe(r.element(1),1)).mul(this._textureNodeBlur1),u=o(i.element(2),this.radius).mul(oe(r.element(2),1)).mul(this._textureNodeBlur2),h=o(i.element(3),this.radius).mul(oe(r.element(3),1)).mul(this._textureNodeBlur3),d=o(i.element(4),this.radius).mul(oe(r.element(4),1)).mul(this._textureNodeBlur4);return c.add(l).add(u).add(h).add(d).mul(this.strength)});return this._compositeMaterial=this._compositeMaterial||new Tt,this._compositeMaterial.fragmentNode=a().context(e.getSharedContext()),this._compositeMaterial.name="Bloom_comp",this._compositeMaterial.needsUpdate=!0,this._textureOutput}dispose(){for(let e=0;e<this._renderTargetsHorizontal.length;e++)this._renderTargetsHorizontal[e].dispose();for(let e=0;e<this._renderTargetsVertical.length;e++)this._renderTargetsVertical[e].dispose();this._renderTargetBright.dispose()}_getSeperableBlurMaterial(e,t){const n=[];for(let d=0;d<t;d++)n.push(.39894*Math.exp(-.5*d*d/(t*t))/t);const i=xt(),r=ds(n),o=pe(new J),a=pe(new J(.5,.5)),c=rt(),l=d=>i.uv(d),u=U(()=>{const d=r.element(0).toVar(),p=l(c).rgb.mul(d).toVar();return mt({start:L(1),end:L(t),type:"int",condition:"<"},({i:f})=>{const x=A(f),m=r.element(f),g=a.mul(o).mul(x),y=l(c.add(g)).rgb,_=l(c.sub(g)).rgb;p.addAssign(Wt(y,_).mul(m)),d.addAssign(A(2).mul(m))}),oe(p.div(d),1)}),h=new Tt;return h.fragmentNode=u().context(e.getSharedContext()),h.name="Bloom_seperable",h.needsUpdate=!0,h.colorTexture=i,h.direction=a,h.invSize=o,h}}const DD=(s,e,t,n)=>H(new sw(H(s),e,t,n));class rw extends pt{static get type(){return"TransitionNode"}constructor(e,t,n,i,r,o){super(),this.textureNodeA=e,this.textureNodeB=t,this.mixTextureNode=n,this.mixRatioNode=i,this.thresholdNode=r,this.useTextureNode=o}setup(){const{textureNodeA:e,textureNodeB:t,mixTextureNode:n,mixRatioNode:i,thresholdNode:r,useTextureNode:o}=this,a=u=>{const h=u.uvNode||rt();return u.uv(h)};return U(()=>{const u=a(e),h=a(t),d=oe().toVar();return Oe(o.equal(L(1)),()=>{const p=a(n),f=i.mul(r.mul(2).add(1)).sub(r),x=cn(Ft(p.r,f).mul(A(1).div(r)),0,1);d.assign(it(u,h,x))}).Else(()=>{d.assign(it(h,u,i))}),d})()}}const UD=(s,e,t,n=0,i=.1,r=0)=>H(new rw(ei(s),ei(e),ei(t),H(n),H(i),H(r)));class FD extends pt{static get type(){return"PixelationNode"}constructor(e,t,n,i,r,o){super(),this.textureNode=e,this.depthNode=t,this.normalNode=n,this.pixelSize=i,this.normalEdgeStrength=r,this.depthEdgeStrength=o,this._resolution=pe(new st),this.updateBeforeType=We.RENDER}updateBefore(){const e=this.textureNode.value,t=e.image.width,n=e.image.height;this._resolution.value.set(t,n,1/t,1/n)}setup(){const{textureNode:e,depthNode:t,normalNode:n}=this,i=e.uvNode||rt(),r=t.uvNode||rt(),o=n.uvNode||rt(),a=()=>e.uv(i),c=(x,m)=>t.uv(r.add(z(x,m).mul(this._resolution.zw))).r,l=(x,m)=>n.uv(o.add(z(x,m).mul(this._resolution.zw))).rgb.normalize(),u=x=>{const m=ai("float","diff");return m.addAssign(cn(c(1,0).sub(x))),m.addAssign(cn(c(-1,0).sub(x))),m.addAssign(cn(c(0,1).sub(x))),m.addAssign(cn(c(0,-1).sub(x))),gr(ti(.01,.02,m).mul(2)).div(2)},h=(x,m,g,y)=>{const _=c(x,m).sub(g),v=l(x,m),I=D(1,1,1),T=$t(y.sub(v),I),w=cn(ti(-.01,.01,T),0,1),C=cn(cl(_.mul(.25).add(.0025)),0,1);return A(1).sub($t(y,v)).mul(C).mul(w)},d=(x,m)=>{const g=ai("float","indicator");return g.addAssign(h(0,-1,x,m)),g.addAssign(h(0,1,x,m)),g.addAssign(h(-1,0,x,m)),g.addAssign(h(1,0,x,m)),ll(.1,g)};return U(()=>{const x=a(),m=ai("float","depth"),g=ai("vec3","normal");Oe(this.depthEdgeStrength.greaterThan(0).or(this.normalEdgeStrength.greaterThan(0)),()=>{m.assign(c(0,0)),g.assign(l(0,0))});const y=ai("float","dei");Oe(this.depthEdgeStrength.greaterThan(0),()=>{y.assign(u(m))});const _=ai("float","nei");Oe(this.normalEdgeStrength.greaterThan(0),()=>{_.assign(d(m,g))});const v=y.greaterThan(0).select(A(1).sub(y.mul(this.depthEdgeStrength)),_.mul(this.normalEdgeStrength).add(1));return x.mul(v)})()}}const OD=(s,e,t,n=6,i=.3,r=.4)=>H(new FD(ei(s),ei(e),ei(t),H(n),H(i),H(r)));class ow extends bn{static get type(){return"PixelationPassNode"}constructor(e,t,n=6,i=.3,r=.4){super("color",e,t,{minFilter:Qt,magFilter:Qt}),this.pixelSize=n,this.normalEdgeStrength=i,this.depthEdgeStrength=r,this.isPixelationPassNode=!0,this._mrt=Vd({output:sg,normal:di})}setSize(e,t){const n=this.pixelSize.value?this.pixelSize.value:this.pixelSize,i=Math.floor(e/n),r=Math.floor(t/n);super.setSize(i,r)}setup(){const e=super.getTextureNode("output"),t=super.getTextureNode("depth"),n=super.getTextureNode("normal");return OD(e,t,n,this.pixelSize,this.normalEdgeStrength,this.depthEdgeStrength)}}const VD=(s,e,t,n,i)=>H(new ow(s,e,t,n,i)),BD=new J;class aw extends bn{static get type(){return"SSAAPassNode"}constructor(e,t){super(bn.COLOR,e,t),this.isSSAAPassNode=!0,this.sampleLevel=4,this.unbiased=!0,this.clearColor=new _e(0),this.clearAlpha=0,this._currentClearColor=new _e,this.sampleWeight=pe(1),this.sampleRenderTarget=null,this._quadMesh=new ys}updateBefore(e){const{renderer:t}=e,{scene:n,camera:i}=this;this._pixelRatio=t.getPixelRatio();const r=t.getSize(BD);this.setSize(r.width,r.height),this.sampleRenderTarget.setSize(this.renderTarget.width,this.renderTarget.height),t.getClearColor(this._currentClearColor);const o=t.getClearAlpha(),a=t.getRenderTarget(),c=t.getMRT(),l=t.autoClear;this._cameraNear.value=i.near,this._cameraFar.value=i.far,t.setMRT(this.getMRT()),t.autoClear=!1;const u=zD[Math.max(0,Math.min(this.sampleLevel,5))],h=1/u.length,d=1/32,p={fullWidth:this.renderTarget.width,fullHeight:this.renderTarget.height,offsetX:0,offsetY:0,width:this.renderTarget.width,height:this.renderTarget.height},f=Object.assign({},i.view);f.enabled&&Object.assign(p,f);for(let x=0;x<u.length;x++){const m=u[x];if(i.setViewOffset&&i.setViewOffset(p.fullWidth,p.fullHeight,p.offsetX+m[0]*.0625,p.offsetY+m[1]*.0625,p.width,p.height),this.sampleWeight.value=h,this.unbiased){const g=-.5+(x+.5)/u.length;this.sampleWeight.value+=d*g}t.setClearColor(this.clearColor,this.clearAlpha),t.setRenderTarget(this.sampleRenderTarget),t.clear(),t.render(n,i),t.setRenderTarget(this.renderTarget),x===0&&(t.setClearColor(0,0),t.clear()),this._quadMesh.render(t)}t.copyTextureToTexture(this.sampleRenderTarget.depthTexture,this.renderTarget.depthTexture),i.setViewOffset&&f.enabled?i.setViewOffset(f.fullWidth,f.fullHeight,f.offsetX,f.offsetY,f.width,f.height):i.clearViewOffset&&i.clearViewOffset(),t.setRenderTarget(a),t.setMRT(c),t.autoClear=l,t.setClearColor(this._currentClearColor,o)}setup(e){this.sampleRenderTarget===null&&(this.sampleRenderTarget=this.renderTarget.clone());let t;const n=this.getMRT();if(n!==null){const i={};for(const r in n.outputNodes){const o=Qg(this.sampleRenderTarget.textures,r);o>=0&&(i[r]=xt(this.sampleRenderTarget.textures[o]).mul(this.sampleWeight))}t=Vd(i)}else t=xt(this.sampleRenderTarget.texture).mul(this.sampleWeight);return this._quadMesh.material=new Tt,this._quadMesh.material.fragmentNode=t,this._quadMesh.material.transparent=!0,this._quadMesh.material.depthTest=!1,this._quadMesh.material.depthWrite=!1,this._quadMesh.material.premultipliedAlpha=!0,this._quadMesh.material.blending=cc,this._quadMesh.material.normals=!1,this._quadMesh.material.name="SSAA",super.setup(e)}dispose(){super.dispose(),this.sampleRenderTarget!==null&&this.sampleRenderTarget.dispose()}}const zD=[[[0,0]],[[4,4],[-4,-4]],[[-2,-6],[6,-2],[-6,2],[2,6]],[[1,-3],[-1,3],[5,1],[-3,-5],[-5,5],[-7,-1],[3,7],[7,-7]],[[1,1],[-1,-3],[-3,2],[4,-1],[-5,-2],[2,5],[5,3],[3,-5],[-2,6],[0,-7],[-4,-6],[-6,4],[-8,0],[7,-4],[6,7],[-7,-8]],[[-4,-7],[-7,-5],[-3,-5],[-5,-4],[-1,-4],[-2,-2],[-6,-1],[-4,0],[-7,1],[-1,2],[-6,3],[-3,3],[-7,6],[-3,6],[-5,7],[-1,7],[5,-7],[1,-6],[6,-5],[4,-4],[2,-3],[7,-2],[1,-1],[4,-1],[2,1],[6,2],[0,4],[4,4],[2,5],[7,5],[5,6],[3,7]]],kD=(s,e)=>H(new aw(s,e)),GD=new J;class cw extends bn{static get type(){return"StereoPassNode"}constructor(e,t){super(bn.COLOR,e,t),this.isStereoPassNode=!0,this.stereo=new Dm,this.stereo.aspect=.5}updateBefore(e){const{renderer:t}=e,{scene:n,camera:i,stereo:r,renderTarget:o}=this;this._pixelRatio=t.getPixelRatio(),r.cameraL.coordinateSystem=t.coordinateSystem,r.cameraR.coordinateSystem=t.coordinateSystem,r.update(i);const a=t.getSize(GD);this.setSize(a.width,a.height);const c=t.autoClear;t.autoClear=!1;const l=t.getRenderTarget(),u=t.getMRT();this._cameraNear.value=i.near,this._cameraFar.value=i.far;for(const h in this._previousTextures)this.toggleTexture(h);t.setRenderTarget(o),t.setMRT(this._mrt),t.clear(),o.scissorTest=!0,o.scissor.set(0,0,o.width/2,o.height),o.viewport.set(0,0,o.width/2,o.height),t.render(n,r.cameraL),o.scissor.set(o.width/2,0,o.width/2,o.height),o.viewport.set(o.width/2,0,o.width/2,o.height),t.render(n,r.cameraR),o.scissorTest=!1,t.setRenderTarget(l),t.setMRT(u),t.autoClear=c}}const HD=(s,e)=>H(new cw(s,e)),WD=new J,V_=new ys;class lw extends bn{static get type(){return"StereoCompositePassNode"}constructor(e,t){super(bn.COLOR,e,t),this.isStereoCompositePassNode=!0,this.stereo=new Dm;const n={minFilter:Ut,magFilter:Qt,type:Ln};this._renderTargetL=new fn(1,1,n),this._renderTargetR=new fn(1,1,n),this._mapLeft=xt(this._renderTargetL.texture),this._mapRight=xt(this._renderTargetR.texture),this._material=null}updateStereoCamera(e){this.stereo.cameraL.coordinateSystem=e,this.stereo.cameraR.coordinateSystem=e,this.stereo.update(this.camera)}setSize(e,t){super.setSize(e,t),this._renderTargetL.setSize(this.renderTarget.width,this.renderTarget.height),this._renderTargetR.setSize(this.renderTarget.width,this.renderTarget.height)}updateBefore(e){const{renderer:t}=e,{scene:n,stereo:i,renderTarget:r}=this;this._pixelRatio=t.getPixelRatio(),this.updateStereoCamera(t.coordinateSystem);const o=t.getSize(WD);this.setSize(o.width,o.height);const a=t.getRenderTarget();t.setRenderTarget(this._renderTargetL),t.render(n,i.cameraL),t.setRenderTarget(this._renderTargetR),t.render(n,i.cameraR),t.setRenderTarget(r),V_.material=this._material,V_.render(t),t.setRenderTarget(a)}dispose(){super.dispose(),this._renderTargetL.dispose(),this._renderTargetR.dispose(),this._material!==null&&this._material.dispose()}}class uw extends lw{static get type(){return"AnaglyphPassNode"}constructor(e,t){super(e,t),this.isAnaglyphPassNode=!0,this._colorMatrixLeft=pe(new Ke().fromArray([.4561,-.0400822,-.0152161,.500484,-.0378246,-.0205971,.176381,-.0157589,-.00546856])),this._colorMatrixRight=pe(new Ke().fromArray([-.0434706,.378476,-.0721527,-.0879388,.73364,-.112961,-.00155529,-.0184503,1.2264]))}setup(e){const t=rt(),n=U(()=>{const r=this._mapLeft.uv(t),o=this._mapRight.uv(t),a=cn(this._colorMatrixLeft.mul(r.rgb).add(this._colorMatrixRight.mul(o.rgb)));return oe(a.rgb,ft(r.a,o.a))}),i=this._material||(this._material=new Tt);return i.fragmentNode=n().context(e.getSharedContext()),i.name="Anaglyph",i.needsUpdate=!0,super.setup(e)}}const XD=(s,e)=>H(new uw(s,e));class hw extends lw{static get type(){return"ParallaxBarrierPassNode"}constructor(e,t){super(e,t),this.isParallaxBarrierPassNode=!0}setup(e){const t=rt(),n=U(()=>{const r=oe().toVar();return Oe(Ad(Aa.y,2).greaterThan(1),()=>{r.assign(this._mapLeft.uv(t))}).Else(()=>{r.assign(this._mapRight.uv(t))}),r}),i=this._material||(this._material=new Tt);return i.fragmentNode=n().context(e.getSharedContext()),i.needsUpdate=!0,super.setup(e)}}const qD=(s,e)=>H(new hw(s,e));class dw extends bn{static get type(){return"ToonOutlinePassNode"}constructor(e,t,n,i,r){super(bn.COLOR,e,t),this.colorNode=n,this.thicknessNode=i,this.alphaNode=r,this._materialCache=new WeakMap}updateBefore(e){const{renderer:t}=e,n=t.getRenderObjectFunction();t.setRenderObjectFunction((i,r,o,a,c,l,u)=>{if((c.isMeshToonMaterial||c.isMeshToonNodeMaterial)&&c.wireframe===!1){const h=this._getOutlineMaterial(c);t.renderObject(i,r,o,a,h,l,u)}t.renderObject(i,r,o,a,c,l,u)}),super.updateBefore(e),t.setRenderObjectFunction(n)}_createMaterial(){const e=new Tt;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=ln;const t=hi.negate(),n=ci.mul(xs),i=A(1),r=n.mul(oe(en,1)),o=n.mul(oe(en.add(t),1)),a=vi(r.sub(o));return e.vertexNode=r.add(a.mul(this.thicknessNode).mul(r.w).mul(i)),e.colorNode=oe(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return t===void 0&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}}const $D=(s,e,t=new _e(0,0,0),n=.003,i=1)=>H(new dw(s,e,H(t),H(n),H(i)));class pw extends Ye{static get type(){return"ScriptableValueNode"}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outpuType=null,this.events=new Ai,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return this.outputType!==null}set value(e){this._value!==e&&(this._cache&&this.inputType==="URL"&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=e,this.events.dispatchEvent({type:"change"}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:"refresh"})}getValue(){const e=this.value;if(e&&this._cache===null&&this.inputType==="URL"&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&e.value!==null&&e.value!==void 0&&((this.inputType==="URL"||this.inputType==="String")&&typeof e.value=="string"||this.inputType==="Number"&&typeof e.value=="number"||this.inputType==="Vector2"&&e.value.isVector2||this.inputType==="Vector3"&&e.value.isVector3||this.inputType==="Vector4"&&e.value.isVector4||this.inputType==="Color"&&e.value.isColor||this.inputType==="Matrix3"&&e.value.isMatrix3||this.inputType==="Matrix4"&&e.value.isMatrix4))return e.value;return this._cache||e}getNodeType(e){return this.value&&this.value.isNode?this.value.getNodeType(e):"float"}setup(){return this.value&&this.value.isNode?this.value:A()}serialize(e){super.serialize(e),this.value!==null?this.inputType==="ArrayBuffer"?e.value=Wm(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null:e.value=null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;e.value!==null&&(e.inputType==="ArrayBuffer"?t=Xm(e.value):e.inputType==="Texture"?t=e.meta.textures[e.value]:t=e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}}const Uu=K(pw);class fw extends Map{get(e,t=null,...n){if(this.has(e))return super.get(e);if(t!==null){const i=t(...n);return this.set(e,i),i}}}class YD{constructor(e){this.scriptableNode=e}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(e){return this.scriptableNode.getInputLayout(e)}get(e){const t=this.parameters[e];return t?t.getValue():null}}const Fu=new fw;class mw extends Ye{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new fw,this._output=Uu(),this._outputs={},this._source=this.source,this._method=null,this._object=null,this._value=null,this._needsOutputUpdate=!0,this.onRefresh=this.onRefresh.bind(this),this.isScriptableNode=!0}get source(){return this.codeNode?this.codeNode.code:""}setLocal(e,t){return this._local.set(e,t)}getLocal(e){return this._local.get(e)}onRefresh(){this._refresh()}getInputLayout(e){for(const t of this.getLayout())if(t.inputType&&(t.id===e||t.name===e))return t}getOutputLayout(e){for(const t of this.getLayout())if(t.outputType&&(t.id===e||t.name===e))return t}setOutput(e,t){const n=this._outputs;return n[e]===void 0?n[e]=Uu(t):n[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){const n=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),n[e]=t,n[e].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),n[e]=t,n[e].events.addEventListener("refresh",this.onRefresh)):n[e]===void 0?(n[e]=Uu(t),n[e].events.addEventListener("refresh",this.onRefresh)):n[e].value=t,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(e){let t=this.parameters[e];return t&&(t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.removeEventListener("refresh",this.onRefresh)),this}clearParameters(){for(const e of Object.keys(this.parameters))this.deleteParameter(e);return this.needsUpdate=!0,this}call(e,...t){const i=this.getObject()[e];if(typeof i=="function")return i(...t)}async callAsync(e,...t){const i=this.getObject()[e];if(typeof i=="function")return i.constructor.name==="AsyncFunction"?await i(...t):i(...t)}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){e!==null?this.getOutput(e).refresh():this._refresh()}getObject(){if(this.needsUpdate&&this.dispose(),this._object!==null)return this._object;const e=()=>this.refresh(),t=(l,u)=>this.setOutput(l,u),n=new YD(this),i=Fu.get("THREE"),r=Fu.get("TSL"),o=this.getMethod(this.codeNode),a=[n,this._local,Fu,e,t,i,r];this._object=o(...a);const c=this._object.layout;if(c&&(c.cache===!1&&this._local.clear(),this._output.outputType=c.outputType||null,Array.isArray(c.elements)))for(const l of c.elements){const u=l.id||l.name;l.inputType&&(this.getParameter(u)===void 0&&this.setParameter(u,null),this.getParameter(u).inputType=l.inputType),l.outputType&&(this.getOutput(u)===void 0&&this.setOutput(u,null),this.getOutput(u).outputType=l.outputType)}return this._object}deserialize(e){super.deserialize(e);for(const t in this.parameters){let n=this.parameters[t];n.isScriptableNode&&(n=n.getDefaultOutput()),n.events.addEventListener("refresh",this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){const e=this.getDefaultOutput().value;return e&&e.isNode?e:A()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),this._method!==null)return this._method;const e=["parameters","local","global","refresh","setOutput","THREE","TSL"],n=["layout","init","main","dispose"].join(", "),i="var "+n+`; var output = {};
3872
3872
  `,r=`
3873
- return { ...output, `+n+" };",o=i+this.codeNode.code+r;return this._method=new Function(...e,o),this._method}dispose(){this._method!==null&&(this._object&&typeof this._object.dispose=="function"&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(e){const t=[zv(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(const n in this.parameters)t.push(this.parameters[n].getCacheKey(e));return kv(t)}set needsUpdate(e){e===!0&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return this.codeNode===null?this:(this._needsOutputUpdate===!0&&(this._value=this.call("main"),this._needsOutputUpdate=!1),this._output.value=this._value,this)}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}}const ZD=K(mw);class Bd extends Ye{static get type(){return"FogNode"}constructor(e,t){super("float"),this.isFogNode=!0,this.colorNode=e,this.factorNode=t}getViewZNode(e){let t;const n=e.context.getViewZ;return n!==void 0&&(t=n(this)),(t||Pn.z).negate()}setup(){return this.factorNode}}const JD=K(Bd);class gw extends Bd{static get type(){return"FogRangeNode"}constructor(e,t,n){super(e),this.isFogRangeNode=!0,this.nearNode=t,this.farNode=n}setup(e){const t=this.getViewZNode(e);return ti(this.nearNode,this.farNode,t)}}const KD=K(gw);class xw extends Bd{static get type(){return"FogExp2Node"}constructor(e,t){super(e),this.isFogExp2Node=!0,this.densityNode=t}setup(e){const t=this.getViewZNode(e),n=this.densityNode;return n.mul(n,t,t).negate().exp().oneMinus()}}const jD=K(xw);let Lr=null,Dr=null;class _w extends Ye{static get type(){return"RangeNode"}constructor(e=A(),t=A()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=e.getTypeLength(Is(this.minNode.value)),n=e.getTypeLength(Is(this.maxNode.value));return t>n?t:n}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}setup(e){const t=e.object;let n=null;if(t.count>1){const i=this.minNode.value,r=this.maxNode.value,o=e.getTypeLength(Is(i)),a=e.getTypeLength(Is(r));Lr=Lr||new st,Dr=Dr||new st,Lr.setScalar(0),Dr.setScalar(0),o===1?Lr.setScalar(i):i.isColor?Lr.set(i.r,i.g,i.b):Lr.set(i.x,i.y,i.z||0,i.w||0),a===1?Dr.setScalar(r):r.isColor?Dr.set(r.r,r.g,r.b):Dr.set(r.x,r.y,r.z||0,r.w||0);const c=4,l=c*t.count,u=new Float32Array(l);for(let d=0;d<l;d++){const p=d%c,f=Lr.getComponent(p),x=Dr.getComponent(p);u[d]=Gh.lerp(f,x,Math.random())}const h=this.getNodeType(e);if(t.count<=4096)n=fl(u,"vec4",t.count).element(yl).convert(h);else{const d=new Us(u,4);e.geometry.setAttribute("__range"+this.id,d),n=_h(d).convert(h)}}else n=A(0);return n}}const QD=K(_w),eU=U(({depthTexture:s,shadowCoord:e})=>xt(s,e.xy).compare(e.z)),tU=U(({depthTexture:s,shadowCoord:e,shadow:t})=>{const n=(x,m)=>xt(s,x).compare(m),i=dn("mapSize","vec2",t).setGroup(_t),r=dn("radius","float",t).setGroup(_t),o=z(1).div(i),a=o.x.negate().mul(r),c=o.y.negate().mul(r),l=o.x.mul(r),u=o.y.mul(r),h=a.div(2),d=c.div(2),p=l.div(2),f=u.div(2);return Wt(n(e.xy.add(z(a,c)),e.z),n(e.xy.add(z(0,c)),e.z),n(e.xy.add(z(l,c)),e.z),n(e.xy.add(z(h,d)),e.z),n(e.xy.add(z(0,d)),e.z),n(e.xy.add(z(p,d)),e.z),n(e.xy.add(z(a,0)),e.z),n(e.xy.add(z(h,0)),e.z),n(e.xy,e.z),n(e.xy.add(z(p,0)),e.z),n(e.xy.add(z(l,0)),e.z),n(e.xy.add(z(h,f)),e.z),n(e.xy.add(z(0,f)),e.z),n(e.xy.add(z(p,f)),e.z),n(e.xy.add(z(a,u)),e.z),n(e.xy.add(z(0,u)),e.z),n(e.xy.add(z(l,u)),e.z)).mul(1/17)}),nU=U(({depthTexture:s,shadowCoord:e,shadow:t})=>{const n=(u,h)=>xt(s,u).compare(h),i=dn("mapSize","vec2",t).setGroup(_t),r=z(1).div(i),o=r.x,a=r.y,c=e.xy,l=gr(c.mul(i).add(.5));return c.subAssign(l.mul(r)),Wt(n(c,e.z),n(c.add(z(o,0)),e.z),n(c.add(z(0,a)),e.z),n(c.add(r),e.z),it(n(c.add(z(o.negate(),0)),e.z),n(c.add(z(o.mul(2),0)),e.z),l.x),it(n(c.add(z(o.negate(),a)),e.z),n(c.add(z(o.mul(2),a)),e.z),l.x),it(n(c.add(z(0,a.negate())),e.z),n(c.add(z(0,a.mul(2))),e.z),l.y),it(n(c.add(z(o,a.negate())),e.z),n(c.add(z(o,a.mul(2))),e.z),l.y),it(it(n(c.add(z(o.negate(),a.negate())),e.z),n(c.add(z(o.mul(2),a.negate())),e.z),l.x),it(n(c.add(z(o.negate(),a.mul(2))),e.z),n(c.add(z(o.mul(2),a.mul(2))),e.z),l.x),l.y)).mul(1/9)}),iU=U(({depthTexture:s,shadowCoord:e})=>{const t=A(1).toVar(),n=xt(s).uv(e.xy).rg,i=ll(e.z,n.x);return Oe(i.notEqual(A(1)),()=>{const r=e.z.sub(n.x),o=ft(0,n.y.mul(n.y));let a=o.div(o.add(r.mul(r)));a=cn(Ft(a,.3).div(.95-.3)),t.assign(cn(ft(i,a)))}),t}),sU=U(({samples:s,radius:e,size:t,shadowPass:n})=>{const i=A(0).toVar(),r=A(0).toVar(),o=s.lessThanEqual(A(1)).select(A(0),A(2).div(s.sub(1))),a=s.lessThanEqual(A(1)).select(A(0),A(-1));mt({start:L(0),end:L(s),type:"int",condition:"<"},({i:l})=>{const u=a.add(A(l).mul(o)),h=n.uv(Wt(Aa.xy,z(0,u).mul(e)).div(t)).x;i.addAssign(h),r.addAssign(h.mul(h))}),i.divAssign(s),r.divAssign(s);const c=os(r.sub(i.mul(i)));return z(i,c)}),rU=U(({samples:s,radius:e,size:t,shadowPass:n})=>{const i=A(0).toVar(),r=A(0).toVar(),o=s.lessThanEqual(A(1)).select(A(0),A(2).div(s.sub(1))),a=s.lessThanEqual(A(1)).select(A(0),A(-1));mt({start:L(0),end:L(s),type:"int",condition:"<"},({i:l})=>{const u=a.add(A(l).mul(o)),h=n.uv(Wt(Aa.xy,z(u,0).mul(e)).div(t));i.addAssign(h.x),r.addAssign(Wt(h.y.mul(h.y),h.x.mul(h.x)))}),i.divAssign(s),r.divAssign(s);const c=os(r.sub(i.mul(i)));return z(i,c)}),oU=[eU,tU,nU,iU];let Oo=null;const wu=new ys;class _r extends ho{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.updateType=We.FRAME,this.light=e,this.color=new _e,this.colorNode=pe(this.color).setGroup(_t),this.baseColorNode=null,this.shadowMap=null,this.shadowNode=null,this.shadowColorNode=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this.isAnalyticLightNode=!0}getCacheKey(){return km(super.getCacheKey(),this.light.id,this.light.castShadow?1:0)}getHash(){return this.light.uuid}setupShadow(e){const{object:t,renderer:n}=e;if(n.shadowMap.enabled===!1)return;let i=this.shadowColorNode;if(i===null){Oo===null&&(Oo=new Tt,Oo.fragmentNode=oe(0,0,0,1),Oo.isShadowNodeMaterial=!0,Oo.name="ShadowMaterial");const r=n.shadowMap.type,o=this.light.shadow,a=new oo;a.compareFunction=jf;const c=e.createRenderTarget(o.mapSize.width,o.mapSize.height);if(c.depthTexture=a,o.camera.updateProjectionMatrix(),r===oi){a.compareFunction=null,this.vsmShadowMapVertical=e.createRenderTarget(o.mapSize.width,o.mapSize.height,{format:na,type:Ln}),this.vsmShadowMapHorizontal=e.createRenderTarget(o.mapSize.width,o.mapSize.height,{format:na,type:Ln});const _=xt(a),v=xt(this.vsmShadowMapVertical.texture),I=dn("blurSamples","float",o).setGroup(_t),T=dn("radius","float",o).setGroup(_t),w=dn("mapSize","vec2",o).setGroup(_t);let C=this.vsmMaterialVertical||(this.vsmMaterialVertical=new Tt);C.fragmentNode=sU({samples:I,radius:T,size:w,shadowPass:_}).context(e.getSharedContext()),C.name="VSMVertical",C=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new Tt),C.fragmentNode=rU({samples:I,radius:T,size:w,shadowPass:v}).context(e.getSharedContext()),C.name="VSMHorizontal"}const l=dn("intensity","float",o).setGroup(_t),u=dn("bias","float",o).setGroup(_t),h=dn("normalBias","float",o).setGroup(_t),d=t.material.shadowPositionNode||vh;let p=pe(o.matrix).setGroup(_t).mul(d.add(Ed.mul(h)));p=p.xyz.div(p.w);let f=p.z.add(u);n.coordinateSystem===jr&&(f=f.mul(2).sub(1)),p=D(p.x,p.y.oneMinus(),f);const x=p.x.greaterThanEqual(0).and(p.x.lessThanEqual(1)).and(p.y.greaterThanEqual(0)).and(p.y.lessThanEqual(1)).and(p.z.lessThanEqual(1)),m=o.filterNode||oU[n.shadowMap.type]||null;if(m===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const g=xt(c.texture,p),y=x.select(m({depthTexture:r===oi?this.vsmShadowMapHorizontal.texture:a,shadowCoord:p,shadow:o}),A(1));this.shadowMap=c,this.light.shadow.map=c,this.shadowNode=y,this.shadowColorNode=i=this.colorNode.mul(it(1,y.rgb.mix(g,1),l.mul(g.a))),this.baseColorNode=this.colorNode}this.colorNode=i,this.updateBeforeType=We.RENDER}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):this.shadowNode!==null&&this.disposeShadow()}updateShadow(e){const{shadowMap:t,light:n}=this,{renderer:i,scene:r,camera:o}=e,a=i.shadowMap.type,c=t.depthTexture.version;this._depthVersionCached=c;const l=r.overrideMaterial;r.overrideMaterial=Oo,t.setSize(n.shadow.mapSize.width,n.shadow.mapSize.height),n.shadow.updateMatrices(n),n.shadow.camera.layers.mask=o.layers.mask;const u=i.getRenderTarget(),h=i.getRenderObjectFunction();i.setRenderObjectFunction((d,...p)=>{(d.castShadow===!0||d.receiveShadow&&a===oi)&&i.renderObject(d,...p)}),i.setRenderTarget(t),i.render(r,n.shadow.camera),i.setRenderObjectFunction(h),n.isPointLight!==!0&&a===oi&&this.vsmPass(e,n),i.setRenderTarget(u),r.overrideMaterial=l}vsmPass(e,t){const{renderer:n}=e;this.vsmShadowMapVertical.setSize(t.shadow.mapSize.width,t.shadow.mapSize.height),this.vsmShadowMapHorizontal.setSize(t.shadow.mapSize.width,t.shadow.mapSize.height),n.setRenderTarget(this.vsmShadowMapVertical),wu.material=this.vsmMaterialVertical,wu.render(n),n.setRenderTarget(this.vsmShadowMapHorizontal),wu.material=this.vsmMaterialHorizontal,wu.render(n)}disposeShadow(){this.shadowMap.dispose(),this.shadowMap=null,this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null),this.shadowNode=null,this.shadowColorNode=null,this.baseColorNode=null,this.updateBeforeType=We.NONE}updateBefore(e){const t=this.light.shadow;(t.needsUpdate||t.autoUpdate)&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const n0=U(s=>{const{lightDistance:e,cutoffDistance:t,decayExponent:n}=s,i=e.pow(n).max(.01).reciprocal();return t.greaterThan(0).select(i.mul(e.div(t).pow4().oneMinus().clamp().pow2()),i)});let Au;function i0(s){Au=Au||new WeakMap;let e=Au.get(s);return e===void 0&&Au.set(s,e={}),e}function s0(s){const e=i0(s);return e.position||(e.position=pe(new E).setGroup(_t).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(s.matrixWorld)))}function yw(s){const e=i0(s);return e.targetPosition||(e.targetPosition=pe(new E).setGroup(_t).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(s.target.matrixWorld)))}function zd(s){const e=i0(s);return e.viewPosition||(e.viewPosition=pe(new E).setGroup(_t).onRenderUpdate(({camera:t},n)=>{n.value=n.value||new E,n.value.setFromMatrixPosition(s.matrixWorld),n.value.applyMatrix4(t.matrixWorldInverse)}))}const r0=s=>pi.transformDirection(s0(s).sub(yw(s))),aU=U(([s])=>{const e=s.toUint().mul(747796405).add(2891336453),t=e.shiftRight(e.shiftRight(28).add(4)).bitXor(e).mul(277803737);return t.shiftRight(22).bitXor(t).toFloat().mul(1/2**32)}),Pf=(s,e)=>Kn(ot(4,s.mul(Ft(1,s))),e),cU=(s,e)=>s.lessThan(.5)?Pf(s.mul(2),e).div(2):Ft(1,Pf(ot(Ft(1,s),2),e).div(2)),lU=(s,e,t)=>Kn(ns(Kn(s,e),Wt(Kn(s,e),Kn(Ft(1,s),t))),1/e),uU=(s,e)=>Cn(eo.mul(e.mul(s).sub(1))).div(eo.mul(e.mul(s).sub(1))),us=U(([s])=>s.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),vw=U(([s])=>D(us(s.z.add(us(s.y.mul(1)))),us(s.z.add(us(s.x.mul(1)))),us(s.y.add(us(s.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),hU=U(([s,e,t])=>{const n=D(s).toVar(),i=A(1.4).toVar(),r=A(0).toVar(),o=D(n).toVar();return mt({start:A(0),end:A(3),type:"float",condition:"<="},()=>{const a=D(vw(o.mul(2))).toVar();n.addAssign(a.add(t.mul(A(.1).mul(e)))),o.mulAssign(1.8),i.mulAssign(1.5),n.mulAssign(1.2);const c=A(us(n.z.add(us(n.x.add(us(n.y)))))).toVar();r.addAssign(c.div(i)),o.addAssign(.14)}),r}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"p",type:"vec3"},{name:"spd",type:"float"},{name:"time",type:"float"}]}),dU=U(([s,e,t=z(.5)])=>Wg(s.sub(t),e).add(t)),pU=U(([s,e,t=z(.5)])=>{const n=s.sub(t),i=n.dot(n),o=i.mul(i).mul(e);return s.add(n.mul(o))}),fU=U(({position:s=null,horizontal:e=!0,vertical:t=!1})=>{let n;s!==null?(n=Ui.toVar(),n[3][0]=s.x,n[3][1]=s.y,n[3][2]=s.z):n=Ui;const i=pi.mul(n);return Oc(e)&&(i[0][0]=Ui[0].length(),i[0][1]=0,i[0][2]=0),Oc(t)&&(i[1][0]=0,i[1][1]=Ui[1].length(),i[1][2]=0),i[2][0]=0,i[2][1]=0,i[2][2]=1,ci.mul(i).mul(en)}),mU=U(([s=null])=>{const e=Sh();return Sh(Og(s)).sub(e).lessThan(0).select(xr,s)}),B_=new WeakMap;class gU extends pt{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.updateType=We.OBJECT,this.updateAfterType=We.OBJECT,this.previousModelWorldMatrix=pe(new Fe),this.previousProjectionMatrix=pe(new Fe).setGroup(_t),this.previousCameraViewMatrix=pe(new Fe)}update({frameId:e,camera:t,object:n}){const i=z_(n);this.previousModelWorldMatrix.value.copy(i);const r=Mw(t);r.frameId!==e&&(r.frameId=e,r.previousProjectionMatrix===void 0?(r.previousProjectionMatrix=new Fe,r.previousCameraViewMatrix=new Fe,r.currentProjectionMatrix=new Fe,r.currentCameraViewMatrix=new Fe,r.previousProjectionMatrix.copy(t.projectionMatrix),r.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(r.previousProjectionMatrix.copy(r.currentProjectionMatrix),r.previousCameraViewMatrix.copy(r.currentCameraViewMatrix)),r.currentProjectionMatrix.copy(t.projectionMatrix),r.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(r.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(r.previousCameraViewMatrix))}updateAfter({object:e}){z_(e).copy(e.matrixWorld)}setup(){const e=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),t=ci.mul(xs).mul(en),n=this.previousProjectionMatrix.mul(e).mul(yh),i=t.xy.div(t.w),r=n.xy.div(n.w);return Ft(i,r)}}function Mw(s){let e=B_.get(s);return e===void 0&&(e={},B_.set(s,e)),e}function z_(s,e=0){const t=Mw(s);let n=t[e];return n===void 0&&(t[e]=n=new Fe),n}const xU=fe(gU),_U=U(([s,e])=>Mn(1,s.oneMinus().div(e)).oneMinus()).setLayout({name:"burnBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),yU=U(([s,e])=>Mn(s.div(e.oneMinus()),1)).setLayout({name:"dodgeBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),vU=U(([s,e])=>s.oneMinus().mul(e.oneMinus()).oneMinus()).setLayout({name:"screenBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),MU=U(([s,e])=>it(s.mul(2).mul(e),s.oneMinus().mul(2).mul(e.oneMinus()).oneMinus(),ll(.5,s))).setLayout({name:"overlayBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),SU=U(([s,e,t=L(16)])=>{const n=a=>s.uv(a),i=rt(),r=n(i).toVar(),o=A(t);return mt({start:L(1),end:t,type:"int",condition:"<="},({i:a})=>{const c=e.mul(A(a).div(o.sub(1)).sub(.5));r.addAssign(n(i.add(c)))}),r.divAssign(o),r}),TU=U(([s,e=1])=>{const t=s,n=En(t.rgb),i=D(n),r=Mn(1,ft(0,A(10).mul(n.sub(.45)))),o=i.mul(t.rgb).mul(2),a=A(2).mul(i.oneMinus()).mul(t.rgb.oneMinus()).oneMinus(),c=it(o,a,r),l=t.a.mul(e),u=l.mul(c.rgb);return u.addAssign(t.rgb.mul(l.oneMinus())),oe(u,t.a)}),bU=U(([s])=>{const e=D(s);return oe($t(e,D(.393,.769,.189)),$t(e,D(.349,.686,.168)),$t(e,D(.272,.534,.131)),s.a)}),Sw=U(([s])=>{const e=s.mul(.9478672986).add(.0521327014).pow(2.4),t=s.mul(.0773993808),n=s.lessThanEqual(.04045);return it(e,t,n)}).setLayout({name:"sRGBToLinearSRGB",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),Tw=U(([s])=>{const e=s.pow(.41666).mul(1.055).sub(.055),t=s.mul(12.92),n=s.lessThanEqual(.0031308);return it(e,t,n)}).setLayout({name:"linearSRGBTosRGB",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),bw=U(([s,e])=>s.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),ww=U(([s,e])=>(s=s.mul(e),s.div(s.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),Aw=U(([s,e])=>{s=s.mul(e),s=s.sub(.004).max(0);const t=s.mul(s.mul(6.2).add(.5)),n=s.mul(s.mul(6.2).add(1.7)).add(.06);return t.div(n).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),wU=U(([s])=>{const e=s.mul(s.add(.0245786)).sub(90537e-9),t=s.mul(s.add(.432951).mul(.983729)).add(.238081);return e.div(t)}),Nw=U(([s,e])=>{const t=Tn(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),n=Tn(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return s=s.mul(e).div(.6),s=t.mul(s),s=wU(s),s=n.mul(s),s.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),AU=Tn(D(1.6605,-.1246,-.0182),D(-.5876,1.1329,-.1006),D(-.0728,-.0083,1.1187)),NU=Tn(D(.6274,.0691,.0164),D(.3293,.9195,.088),D(.0433,.0113,.8956)),EU=U(([s])=>{const e=D(s).toVar(),t=D(e.mul(e)).toVar(),n=D(t.mul(t)).toVar();return A(15.5).mul(n.mul(t)).sub(ot(40.14,n.mul(e))).add(ot(31.96,n).sub(ot(6.868,t.mul(e))).add(ot(.4298,t).add(ot(.1191,e).sub(.00232))))}),Ew=U(([s,e])=>{const t=D(s).toVar(),n=Tn(D(.856627153315983,.137318972929847,.11189821299995),D(.0951212405381588,.761241990602591,.0767994186031903),D(.0482516061458583,.101439036467562,.811302368396859)),i=Tn(D(1.1271005818144368,-.1413297634984383,-.14132976349843826),D(-.11060664309660323,1.157823702216272,-.11060664309660294),D(-.016493938717834573,-.016493938717834257,1.2519364065950405)),r=A(-12.47393),o=A(4.026069);return t.mulAssign(e),t.assign(NU.mul(t)),t.assign(n.mul(t)),t.assign(ft(t,1e-10)),t.assign(al(t)),t.assign(t.sub(r).div(o.sub(r))),t.assign(cn(t,0,1)),t.assign(EU(t)),t.assign(i.mul(t)),t.assign(Kn(ft(D(0),t),D(2.2))),t.assign(AU.mul(t)),t.assign(cn(t,0,1)),t}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),Cw=U(([s,e])=>{const t=A(.76),n=A(.15);s=s.mul(e);const i=Mn(s.r,Mn(s.g,s.b)),r=In(i.lessThan(.08),i.sub(ot(6.25,i.mul(i))),.04);s.subAssign(r);const o=ft(s.r,ft(s.g,s.b));Oe(o.lessThan(t),()=>s);const a=Ft(1,t),c=Ft(1,a.mul(a).div(o.add(a.sub(t))));s.mulAssign(c.div(o));const l=Ft(1,ns(1,n.mul(o.sub(c)).add(1)));return it(s,D(c),l)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class CU extends Ye{static get type(){return"ComputeBuiltinNode"}constructor(e,t){super(t),this._builtinName=e}getHash(e){return this.getBuiltinName(e)}getNodeType(){return this.nodeType}setBuiltinName(e){return this._builtinName=e,this}getBuiltinName(){return this._builtinName}hasBuiltin(e){e.hasBuiltin(this._builtinName)}generate(e,t){const n=this.getBuiltinName(e),i=this.getNodeType(e);return e.shaderStage==="compute"?e.format(n,i,t):(console.warn(`ComputeBuiltinNode: Compute built-in value ${n} can not be accessed in the ${e.shaderStage} stage`),e.generateConst(i))}serialize(e){super.serialize(e),e.global=this.global,e._builtinName=this._builtinName}deserialize(e){super.deserialize(e),this.global=e.global,this._builtinName=e._builtinName}}const kd=(s,e)=>H(new CU(s,e)),RU=kd("numWorkgroups","uvec3"),IU=kd("workgroupId","uvec3"),PU=kd("localId","uvec3"),LU=kd("subgroupSize","uint");class DU extends Ye{constructor(e){super(),this.scope=e}generate(e){const{scope:t}=this,{renderer:n}=e;n.backend.isWebGLBackend===!0?e.addFlowCode(` // ${t}Barrier
3874
- `):e.addLineFlowCode(`${t}Barrier()`,this)}}const o0=K(DU),UU=()=>o0("workgroup").append(),FU=()=>o0("storage").append(),OU=()=>o0("texture").append();class VU extends fr{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let n;const i=e.context.assign;if(n=super.generate(e),i!==!0){const r=this.getNodeType(e);n=e.format(n,r,t)}return n}}class BU extends Ye{constructor(e,t,n=0){super(t),this.bufferType=t,this.bufferCount=n,this.isWorkgroupInfoNode=!0,this.scope=e}label(e){return this.name=e,this}getHash(){return this.uuid}setScope(e){return this.scope=e,this}getInputType(){return`${this.scope}Array`}element(e){return H(new VU(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}const zU=(s,e)=>H(new BU("Workgroup",s,e));class wn extends pt{static get type(){return"AtomicFunctionNode"}constructor(e,t,n,i=null){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=n,this.storeNode=i}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const t=this.method,n=this.getNodeType(e),i=this.getInputType(e),r=this.pointerNode,o=this.valueNode,a=[];a.push(`&${r.build(e,i)}`),a.push(o.build(e,i));const c=`${e.getMethod(t,n)}( ${a.join(", ")} )`;if(this.storeNode!==null){const l=this.storeNode.build(e,i);e.addLineFlowCode(`${l} = ${c}`,this)}else e.addLineFlowCode(c,this)}}wn.ATOMIC_LOAD="atomicLoad";wn.ATOMIC_STORE="atomicStore";wn.ATOMIC_ADD="atomicAdd";wn.ATOMIC_SUB="atomicSub";wn.ATOMIC_MAX="atomicMax";wn.ATOMIC_MIN="atomicMin";wn.ATOMIC_AND="atomicAnd";wn.ATOMIC_OR="atomicOr";wn.ATOMIC_XOR="atomicXor";const kU=K(wn),Os=(s,e,t,n)=>{const i=kU(s,e,t,n);return i.append(),i},GU=(s,e,t=null)=>Os(wn.ATOMIC_STORE,s,e,t),HU=(s,e,t=null)=>Os(wn.ATOMIC_ADD,s,e,t),WU=(s,e,t=null)=>Os(wn.ATOMIC_SUB,s,e,t),XU=(s,e,t=null)=>Os(wn.ATOMIC_MAX,s,e,t),qU=(s,e,t=null)=>Os(wn.ATOMIC_MIN,s,e,t),$U=(s,e,t=null)=>Os(wn.ATOMIC_AND,s,e,t),YU=(s,e,t=null)=>Os(wn.ATOMIC_OR,s,e,t),ZU=(s,e,t=null)=>Os(wn.ATOMIC_XOR,s,e,t),JU=U(([s=rt()])=>{const e=s.mul(2),t=e.x.floor(),n=e.y.floor();return t.add(n).mod(2).sign()}),ac=U(([s,e,t])=>{const n=A(t).toVar(),i=A(e).toVar(),r=cr(s).toVar();return In(r,i,n)}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),bh=U(([s,e])=>{const t=cr(e).toVar(),n=A(s).toVar();return In(t,n.negate(),n)}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),rn=U(([s])=>{const e=A(s).toVar();return L(mr(e))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),Ht=U(([s,e])=>{const t=A(s).toVar();return e.assign(rn(t)),t.sub(A(e))}),KU=U(([s,e,t,n,i,r])=>{const o=A(r).toVar(),a=A(i).toVar(),c=A(n).toVar(),l=A(t).toVar(),u=A(e).toVar(),h=A(s).toVar(),d=A(Ft(1,a)).toVar();return Ft(1,o).mul(h.mul(d).add(u.mul(a))).add(o.mul(l.mul(d).add(c.mul(a))))}).setLayout({name:"mx_bilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"}]}),jU=U(([s,e,t,n,i,r])=>{const o=A(r).toVar(),a=A(i).toVar(),c=D(n).toVar(),l=D(t).toVar(),u=D(e).toVar(),h=D(s).toVar(),d=A(Ft(1,a)).toVar();return Ft(1,o).mul(h.mul(d).add(u.mul(a))).add(o.mul(l.mul(d).add(c.mul(a))))}).setLayout({name:"mx_bilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"}]}),Rw=On([KU,jU]),QU=U(([s,e,t,n,i,r,o,a,c,l,u])=>{const h=A(u).toVar(),d=A(l).toVar(),p=A(c).toVar(),f=A(a).toVar(),x=A(o).toVar(),m=A(r).toVar(),g=A(i).toVar(),y=A(n).toVar(),_=A(t).toVar(),v=A(e).toVar(),I=A(s).toVar(),T=A(Ft(1,p)).toVar(),w=A(Ft(1,d)).toVar();return A(Ft(1,h)).toVar().mul(w.mul(I.mul(T).add(v.mul(p))).add(d.mul(_.mul(T).add(y.mul(p))))).add(h.mul(w.mul(g.mul(T).add(m.mul(p))).add(d.mul(x.mul(T).add(f.mul(p))))))}).setLayout({name:"mx_trilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"v4",type:"float"},{name:"v5",type:"float"},{name:"v6",type:"float"},{name:"v7",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),eF=U(([s,e,t,n,i,r,o,a,c,l,u])=>{const h=A(u).toVar(),d=A(l).toVar(),p=A(c).toVar(),f=D(a).toVar(),x=D(o).toVar(),m=D(r).toVar(),g=D(i).toVar(),y=D(n).toVar(),_=D(t).toVar(),v=D(e).toVar(),I=D(s).toVar(),T=A(Ft(1,p)).toVar(),w=A(Ft(1,d)).toVar();return A(Ft(1,h)).toVar().mul(w.mul(I.mul(T).add(v.mul(p))).add(d.mul(_.mul(T).add(y.mul(p))))).add(h.mul(w.mul(g.mul(T).add(m.mul(p))).add(d.mul(x.mul(T).add(f.mul(p))))))}).setLayout({name:"mx_trilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"v4",type:"vec3"},{name:"v5",type:"vec3"},{name:"v6",type:"vec3"},{name:"v7",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),Iw=On([QU,eF]),tF=U(([s,e,t])=>{const n=A(t).toVar(),i=A(e).toVar(),r=ve(s).toVar(),o=ve(r.bitAnd(ve(7))).toVar(),a=A(ac(o.lessThan(ve(4)),i,n)).toVar(),c=A(ot(2,ac(o.lessThan(ve(4)),n,i))).toVar();return bh(a,cr(o.bitAnd(ve(1)))).add(bh(c,cr(o.bitAnd(ve(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),nF=U(([s,e,t,n])=>{const i=A(n).toVar(),r=A(t).toVar(),o=A(e).toVar(),a=ve(s).toVar(),c=ve(a.bitAnd(ve(15))).toVar(),l=A(ac(c.lessThan(ve(8)),o,r)).toVar(),u=A(ac(c.lessThan(ve(4)),r,ac(c.equal(ve(12)).or(c.equal(ve(14))),o,i))).toVar();return bh(l,cr(c.bitAnd(ve(1)))).add(bh(u,cr(c.bitAnd(ve(2)))))}).setLayout({name:"mx_gradient_float_1",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),yn=On([tF,nF]),iF=U(([s,e,t])=>{const n=A(t).toVar(),i=A(e).toVar(),r=wa(s).toVar();return D(yn(r.x,i,n),yn(r.y,i,n),yn(r.z,i,n))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),sF=U(([s,e,t,n])=>{const i=A(n).toVar(),r=A(t).toVar(),o=A(e).toVar(),a=wa(s).toVar();return D(yn(a.x,o,r,i),yn(a.y,o,r,i),yn(a.z,o,r,i))}).setLayout({name:"mx_gradient_vec3_1",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),Ri=On([iF,sF]),rF=U(([s])=>{const e=A(s).toVar();return ot(.6616,e)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),oF=U(([s])=>{const e=A(s).toVar();return ot(.982,e)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),aF=U(([s])=>{const e=D(s).toVar();return ot(.6616,e)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),Pw=On([rF,aF]),cF=U(([s])=>{const e=D(s).toVar();return ot(.982,e)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),Lw=On([oF,cF]),yi=U(([s,e])=>{const t=L(e).toVar(),n=ve(s).toVar();return n.shiftLeft(t).bitOr(n.shiftRight(L(32).sub(t)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),Dw=U(([s,e,t])=>{s.subAssign(t),s.bitXorAssign(yi(t,L(4))),t.addAssign(e),e.subAssign(s),e.bitXorAssign(yi(s,L(6))),s.addAssign(t),t.subAssign(e),t.bitXorAssign(yi(e,L(8))),e.addAssign(s),s.subAssign(t),s.bitXorAssign(yi(t,L(16))),t.addAssign(e),e.subAssign(s),e.bitXorAssign(yi(s,L(19))),s.addAssign(t),t.subAssign(e),t.bitXorAssign(yi(e,L(4))),e.addAssign(s)}),Sl=U(([s,e,t])=>{const n=ve(t).toVar(),i=ve(e).toVar(),r=ve(s).toVar();return n.bitXorAssign(i),n.subAssign(yi(i,L(14))),r.bitXorAssign(n),r.subAssign(yi(n,L(11))),i.bitXorAssign(r),i.subAssign(yi(r,L(25))),n.bitXorAssign(i),n.subAssign(yi(i,L(16))),r.bitXorAssign(n),r.subAssign(yi(n,L(4))),i.bitXorAssign(r),i.subAssign(yi(r,L(14))),n.bitXorAssign(i),n.subAssign(yi(i,L(24))),n}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),Wn=U(([s])=>{const e=ve(s).toVar();return A(e).div(A(ve(L(4294967295))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),ps=U(([s])=>{const e=A(s).toVar();return e.mul(e).mul(e).mul(e.mul(e.mul(6).sub(15)).add(10))}).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),lF=U(([s])=>{const e=L(s).toVar(),t=ve(ve(1)).toVar(),n=ve(ve(L(3735928559)).add(t.shiftLeft(ve(2))).add(ve(13))).toVar();return Sl(n.add(ve(e)),n,n)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),uF=U(([s,e])=>{const t=L(e).toVar(),n=L(s).toVar(),i=ve(ve(2)).toVar(),r=ve().toVar(),o=ve().toVar(),a=ve().toVar();return r.assign(o.assign(a.assign(ve(L(3735928559)).add(i.shiftLeft(ve(2))).add(ve(13))))),r.addAssign(ve(n)),o.addAssign(ve(t)),Sl(r,o,a)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),hF=U(([s,e,t])=>{const n=L(t).toVar(),i=L(e).toVar(),r=L(s).toVar(),o=ve(ve(3)).toVar(),a=ve().toVar(),c=ve().toVar(),l=ve().toVar();return a.assign(c.assign(l.assign(ve(L(3735928559)).add(o.shiftLeft(ve(2))).add(ve(13))))),a.addAssign(ve(r)),c.addAssign(ve(i)),l.addAssign(ve(n)),Sl(a,c,l)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),dF=U(([s,e,t,n])=>{const i=L(n).toVar(),r=L(t).toVar(),o=L(e).toVar(),a=L(s).toVar(),c=ve(ve(4)).toVar(),l=ve().toVar(),u=ve().toVar(),h=ve().toVar();return l.assign(u.assign(h.assign(ve(L(3735928559)).add(c.shiftLeft(ve(2))).add(ve(13))))),l.addAssign(ve(a)),u.addAssign(ve(o)),h.addAssign(ve(r)),Dw(l,u,h),l.addAssign(ve(i)),Sl(l,u,h)}).setLayout({name:"mx_hash_int_3",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"}]}),pF=U(([s,e,t,n,i])=>{const r=L(i).toVar(),o=L(n).toVar(),a=L(t).toVar(),c=L(e).toVar(),l=L(s).toVar(),u=ve(ve(5)).toVar(),h=ve().toVar(),d=ve().toVar(),p=ve().toVar();return h.assign(d.assign(p.assign(ve(L(3735928559)).add(u.shiftLeft(ve(2))).add(ve(13))))),h.addAssign(ve(l)),d.addAssign(ve(c)),p.addAssign(ve(a)),Dw(h,d,p),h.addAssign(ve(o)),d.addAssign(ve(r)),Sl(h,d,p)}).setLayout({name:"mx_hash_int_4",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"},{name:"yy",type:"int"}]}),Pt=On([lF,uF,hF,dF,pF]),fF=U(([s,e])=>{const t=L(e).toVar(),n=L(s).toVar(),i=ve(Pt(n,t)).toVar(),r=wa().toVar();return r.x.assign(i.bitAnd(L(255))),r.y.assign(i.shiftRight(L(8)).bitAnd(L(255))),r.z.assign(i.shiftRight(L(16)).bitAnd(L(255))),r}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),mF=U(([s,e,t])=>{const n=L(t).toVar(),i=L(e).toVar(),r=L(s).toVar(),o=ve(Pt(r,i,n)).toVar(),a=wa().toVar();return a.x.assign(o.bitAnd(L(255))),a.y.assign(o.shiftRight(L(8)).bitAnd(L(255))),a.z.assign(o.shiftRight(L(16)).bitAnd(L(255))),a}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),Ii=On([fF,mF]),gF=U(([s])=>{const e=z(s).toVar(),t=L().toVar(),n=L().toVar(),i=A(Ht(e.x,t)).toVar(),r=A(Ht(e.y,n)).toVar(),o=A(ps(i)).toVar(),a=A(ps(r)).toVar(),c=A(Rw(yn(Pt(t,n),i,r),yn(Pt(t.add(L(1)),n),i.sub(1),r),yn(Pt(t,n.add(L(1))),i,r.sub(1)),yn(Pt(t.add(L(1)),n.add(L(1))),i.sub(1),r.sub(1)),o,a)).toVar();return Pw(c)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),xF=U(([s])=>{const e=D(s).toVar(),t=L().toVar(),n=L().toVar(),i=L().toVar(),r=A(Ht(e.x,t)).toVar(),o=A(Ht(e.y,n)).toVar(),a=A(Ht(e.z,i)).toVar(),c=A(ps(r)).toVar(),l=A(ps(o)).toVar(),u=A(ps(a)).toVar(),h=A(Iw(yn(Pt(t,n,i),r,o,a),yn(Pt(t.add(L(1)),n,i),r.sub(1),o,a),yn(Pt(t,n.add(L(1)),i),r,o.sub(1),a),yn(Pt(t.add(L(1)),n.add(L(1)),i),r.sub(1),o.sub(1),a),yn(Pt(t,n,i.add(L(1))),r,o,a.sub(1)),yn(Pt(t.add(L(1)),n,i.add(L(1))),r.sub(1),o,a.sub(1)),yn(Pt(t,n.add(L(1)),i.add(L(1))),r,o.sub(1),a.sub(1)),yn(Pt(t.add(L(1)),n.add(L(1)),i.add(L(1))),r.sub(1),o.sub(1),a.sub(1)),c,l,u)).toVar();return Lw(h)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]}),a0=On([gF,xF]),_F=U(([s])=>{const e=z(s).toVar(),t=L().toVar(),n=L().toVar(),i=A(Ht(e.x,t)).toVar(),r=A(Ht(e.y,n)).toVar(),o=A(ps(i)).toVar(),a=A(ps(r)).toVar(),c=D(Rw(Ri(Ii(t,n),i,r),Ri(Ii(t.add(L(1)),n),i.sub(1),r),Ri(Ii(t,n.add(L(1))),i,r.sub(1)),Ri(Ii(t.add(L(1)),n.add(L(1))),i.sub(1),r.sub(1)),o,a)).toVar();return Pw(c)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),yF=U(([s])=>{const e=D(s).toVar(),t=L().toVar(),n=L().toVar(),i=L().toVar(),r=A(Ht(e.x,t)).toVar(),o=A(Ht(e.y,n)).toVar(),a=A(Ht(e.z,i)).toVar(),c=A(ps(r)).toVar(),l=A(ps(o)).toVar(),u=A(ps(a)).toVar(),h=D(Iw(Ri(Ii(t,n,i),r,o,a),Ri(Ii(t.add(L(1)),n,i),r.sub(1),o,a),Ri(Ii(t,n.add(L(1)),i),r,o.sub(1),a),Ri(Ii(t.add(L(1)),n.add(L(1)),i),r.sub(1),o.sub(1),a),Ri(Ii(t,n,i.add(L(1))),r,o,a.sub(1)),Ri(Ii(t.add(L(1)),n,i.add(L(1))),r.sub(1),o,a.sub(1)),Ri(Ii(t,n.add(L(1)),i.add(L(1))),r,o.sub(1),a.sub(1)),Ri(Ii(t.add(L(1)),n.add(L(1)),i.add(L(1))),r.sub(1),o.sub(1),a.sub(1)),c,l,u)).toVar();return Lw(h)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),c0=On([_F,yF]),vF=U(([s])=>{const e=A(s).toVar(),t=L(rn(e)).toVar();return Wn(Pt(t))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),MF=U(([s])=>{const e=z(s).toVar(),t=L(rn(e.x)).toVar(),n=L(rn(e.y)).toVar();return Wn(Pt(t,n))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),SF=U(([s])=>{const e=D(s).toVar(),t=L(rn(e.x)).toVar(),n=L(rn(e.y)).toVar(),i=L(rn(e.z)).toVar();return Wn(Pt(t,n,i))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),TF=U(([s])=>{const e=oe(s).toVar(),t=L(rn(e.x)).toVar(),n=L(rn(e.y)).toVar(),i=L(rn(e.z)).toVar(),r=L(rn(e.w)).toVar();return Wn(Pt(t,n,i,r))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]}),bF=On([vF,MF,SF,TF]),wF=U(([s])=>{const e=A(s).toVar(),t=L(rn(e)).toVar();return D(Wn(Pt(t,L(0))),Wn(Pt(t,L(1))),Wn(Pt(t,L(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),AF=U(([s])=>{const e=z(s).toVar(),t=L(rn(e.x)).toVar(),n=L(rn(e.y)).toVar();return D(Wn(Pt(t,n,L(0))),Wn(Pt(t,n,L(1))),Wn(Pt(t,n,L(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),NF=U(([s])=>{const e=D(s).toVar(),t=L(rn(e.x)).toVar(),n=L(rn(e.y)).toVar(),i=L(rn(e.z)).toVar();return D(Wn(Pt(t,n,i,L(0))),Wn(Pt(t,n,i,L(1))),Wn(Pt(t,n,i,L(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),EF=U(([s])=>{const e=oe(s).toVar(),t=L(rn(e.x)).toVar(),n=L(rn(e.y)).toVar(),i=L(rn(e.z)).toVar(),r=L(rn(e.w)).toVar();return D(Wn(Pt(t,n,i,r,L(0))),Wn(Pt(t,n,i,r,L(1))),Wn(Pt(t,n,i,r,L(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]}),Uw=On([wF,AF,NF,EF]),wh=U(([s,e,t,n])=>{const i=A(n).toVar(),r=A(t).toVar(),o=L(e).toVar(),a=D(s).toVar(),c=A(0).toVar(),l=A(1).toVar();return mt(o,()=>{c.addAssign(l.mul(a0(a))),l.mulAssign(i),a.mulAssign(r)}),c}).setLayout({name:"mx_fractal_noise_float",type:"float",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),Fw=U(([s,e,t,n])=>{const i=A(n).toVar(),r=A(t).toVar(),o=L(e).toVar(),a=D(s).toVar(),c=D(0).toVar(),l=A(1).toVar();return mt(o,()=>{c.addAssign(l.mul(c0(a))),l.mulAssign(i),a.mulAssign(r)}),c}).setLayout({name:"mx_fractal_noise_vec3",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),CF=U(([s,e,t,n])=>{const i=A(n).toVar(),r=A(t).toVar(),o=L(e).toVar(),a=D(s).toVar();return z(wh(a,o,r,i),wh(a.add(D(L(19),L(193),L(17))),o,r,i))}).setLayout({name:"mx_fractal_noise_vec2",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),RF=U(([s,e,t,n])=>{const i=A(n).toVar(),r=A(t).toVar(),o=L(e).toVar(),a=D(s).toVar(),c=D(Fw(a,o,r,i)).toVar(),l=A(wh(a.add(D(L(19),L(193),L(17))),o,r,i)).toVar();return oe(c,l)}).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),IF=U(([s,e,t,n,i,r,o])=>{const a=L(o).toVar(),c=A(r).toVar(),l=L(i).toVar(),u=L(n).toVar(),h=L(t).toVar(),d=L(e).toVar(),p=z(s).toVar(),f=D(Uw(z(d.add(u),h.add(l)))).toVar(),x=z(f.x,f.y).toVar();x.subAssign(.5),x.mulAssign(c),x.addAssign(.5);const m=z(z(A(d),A(h)).add(x)).toVar(),g=z(m.sub(p)).toVar();return Oe(a.equal(L(2)),()=>Dt(g.x).add(Dt(g.y))),Oe(a.equal(L(3)),()=>ft(Dt(g.x),Dt(g.y))),$t(g,g)}).setLayout({name:"mx_worley_distance_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),PF=U(([s,e,t,n,i,r,o,a,c])=>{const l=L(c).toVar(),u=A(a).toVar(),h=L(o).toVar(),d=L(r).toVar(),p=L(i).toVar(),f=L(n).toVar(),x=L(t).toVar(),m=L(e).toVar(),g=D(s).toVar(),y=D(Uw(D(m.add(p),x.add(d),f.add(h)))).toVar();y.subAssign(.5),y.mulAssign(u),y.addAssign(.5);const _=D(D(A(m),A(x),A(f)).add(y)).toVar(),v=D(_.sub(g)).toVar();return Oe(l.equal(L(2)),()=>Dt(v.x).add(Dt(v.y)).add(Dt(v.z))),Oe(l.equal(L(3)),()=>ft(ft(Dt(v.x),Dt(v.y)),Dt(v.z))),$t(v,v)}).setLayout({name:"mx_worley_distance_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"zoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Ea=On([IF,PF]),LF=U(([s,e,t])=>{const n=L(t).toVar(),i=A(e).toVar(),r=z(s).toVar(),o=L().toVar(),a=L().toVar(),c=z(Ht(r.x,o),Ht(r.y,a)).toVar(),l=A(1e6).toVar();return mt({start:-1,end:L(1),name:"x",condition:"<="},({x:u})=>{mt({start:-1,end:L(1),name:"y",condition:"<="},({y:h})=>{const d=A(Ea(c,u,h,o,a,i,n)).toVar();l.assign(Mn(l,d))})}),Oe(n.equal(L(0)),()=>{l.assign(os(l))}),l}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),DF=U(([s,e,t])=>{const n=L(t).toVar(),i=A(e).toVar(),r=z(s).toVar(),o=L().toVar(),a=L().toVar(),c=z(Ht(r.x,o),Ht(r.y,a)).toVar(),l=z(1e6,1e6).toVar();return mt({start:-1,end:L(1),name:"x",condition:"<="},({x:u})=>{mt({start:-1,end:L(1),name:"y",condition:"<="},({y:h})=>{const d=A(Ea(c,u,h,o,a,i,n)).toVar();Oe(d.lessThan(l.x),()=>{l.y.assign(l.x),l.x.assign(d)}).ElseIf(d.lessThan(l.y),()=>{l.y.assign(d)})})}),Oe(n.equal(L(0)),()=>{l.assign(os(l))}),l}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),UF=U(([s,e,t])=>{const n=L(t).toVar(),i=A(e).toVar(),r=z(s).toVar(),o=L().toVar(),a=L().toVar(),c=z(Ht(r.x,o),Ht(r.y,a)).toVar(),l=D(1e6,1e6,1e6).toVar();return mt({start:-1,end:L(1),name:"x",condition:"<="},({x:u})=>{mt({start:-1,end:L(1),name:"y",condition:"<="},({y:h})=>{const d=A(Ea(c,u,h,o,a,i,n)).toVar();Oe(d.lessThan(l.x),()=>{l.z.assign(l.y),l.y.assign(l.x),l.x.assign(d)}).ElseIf(d.lessThan(l.y),()=>{l.z.assign(l.y),l.y.assign(d)}).ElseIf(d.lessThan(l.z),()=>{l.z.assign(d)})})}),Oe(n.equal(L(0)),()=>{l.assign(os(l))}),l}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),FF=U(([s,e,t])=>{const n=L(t).toVar(),i=A(e).toVar(),r=D(s).toVar(),o=L().toVar(),a=L().toVar(),c=L().toVar(),l=D(Ht(r.x,o),Ht(r.y,a),Ht(r.z,c)).toVar(),u=A(1e6).toVar();return mt({start:-1,end:L(1),name:"x",condition:"<="},({x:h})=>{mt({start:-1,end:L(1),name:"y",condition:"<="},({y:d})=>{mt({start:-1,end:L(1),name:"z",condition:"<="},({z:p})=>{const f=A(Ea(l,h,d,p,o,a,c,i,n)).toVar();u.assign(Mn(u,f))})})}),Oe(n.equal(L(0)),()=>{u.assign(os(u))}),u}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),OF=On([LF,FF]),VF=U(([s,e,t])=>{const n=L(t).toVar(),i=A(e).toVar(),r=D(s).toVar(),o=L().toVar(),a=L().toVar(),c=L().toVar(),l=D(Ht(r.x,o),Ht(r.y,a),Ht(r.z,c)).toVar(),u=z(1e6,1e6).toVar();return mt({start:-1,end:L(1),name:"x",condition:"<="},({x:h})=>{mt({start:-1,end:L(1),name:"y",condition:"<="},({y:d})=>{mt({start:-1,end:L(1),name:"z",condition:"<="},({z:p})=>{const f=A(Ea(l,h,d,p,o,a,c,i,n)).toVar();Oe(f.lessThan(u.x),()=>{u.y.assign(u.x),u.x.assign(f)}).ElseIf(f.lessThan(u.y),()=>{u.y.assign(f)})})})}),Oe(n.equal(L(0)),()=>{u.assign(os(u))}),u}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),BF=On([DF,VF]),zF=U(([s,e,t])=>{const n=L(t).toVar(),i=A(e).toVar(),r=D(s).toVar(),o=L().toVar(),a=L().toVar(),c=L().toVar(),l=D(Ht(r.x,o),Ht(r.y,a),Ht(r.z,c)).toVar(),u=D(1e6,1e6,1e6).toVar();return mt({start:-1,end:L(1),name:"x",condition:"<="},({x:h})=>{mt({start:-1,end:L(1),name:"y",condition:"<="},({y:d})=>{mt({start:-1,end:L(1),name:"z",condition:"<="},({z:p})=>{const f=A(Ea(l,h,d,p,o,a,c,i,n)).toVar();Oe(f.lessThan(u.x),()=>{u.z.assign(u.y),u.y.assign(u.x),u.x.assign(f)}).ElseIf(f.lessThan(u.y),()=>{u.z.assign(u.y),u.y.assign(f)}).ElseIf(f.lessThan(u.z),()=>{u.z.assign(f)})})})}),Oe(n.equal(L(0)),()=>{u.assign(os(u))}),u}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),kF=On([UF,zF]),GF=U(([s])=>{const e=s.y,t=s.z,n=D().toVar();return Oe(e.lessThan(1e-4),()=>{n.assign(D(t,t,t))}).Else(()=>{let i=s.x;i=i.sub(mr(i)).mul(6).toVar();const r=L(mg(i)),o=i.sub(A(r)),a=t.mul(e.oneMinus()),c=t.mul(e.mul(o).oneMinus()),l=t.mul(e.mul(o.oneMinus()).oneMinus());Oe(r.equal(L(0)),()=>{n.assign(D(t,l,a))}).ElseIf(r.equal(L(1)),()=>{n.assign(D(c,t,a))}).ElseIf(r.equal(L(2)),()=>{n.assign(D(a,t,l))}).ElseIf(r.equal(L(3)),()=>{n.assign(D(a,c,t))}).ElseIf(r.equal(L(4)),()=>{n.assign(D(l,a,t))}).Else(()=>{n.assign(D(t,a,c))})}),n}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),HF=U(([s])=>{const e=D(s).toVar(),t=A(e.x).toVar(),n=A(e.y).toVar(),i=A(e.z).toVar(),r=A(Mn(t,Mn(n,i))).toVar(),o=A(ft(t,ft(n,i))).toVar(),a=A(o.sub(r)).toVar(),c=A().toVar(),l=A().toVar(),u=A().toVar();return u.assign(o),Oe(o.greaterThan(0),()=>{l.assign(a.div(o))}).Else(()=>{l.assign(0)}),Oe(l.lessThanEqual(0),()=>{c.assign(0)}).Else(()=>{Oe(t.greaterThanEqual(o),()=>{c.assign(n.sub(i).div(a))}).ElseIf(n.greaterThanEqual(o),()=>{c.assign(Wt(2,i.sub(t).div(a)))}).Else(()=>{c.assign(Wt(4,t.sub(n).div(a)))}),c.mulAssign(1/6),Oe(c.lessThan(0),()=>{c.addAssign(1)})}),D(c,l,u)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),WF=U(([s])=>{const e=D(s).toVar(),t=Qm(ug(e,D(.04045))).toVar(),n=D(e.div(12.92)).toVar(),i=D(Kn(ft(e.add(D(.055)),D(0)).div(1.055),D(2.4))).toVar();return it(n,i,t)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),Ow=(s,e)=>{s=A(s),e=A(e);const t=z(e.dFdx(),e.dFdy()).length().mul(.7071067811865476);return ti(s.sub(t),s.add(t),e)},Vw=(s,e,t,n)=>it(s,e,t[n].clamp()),XF=(s,e,t=rt())=>Vw(s,e,t,"x"),qF=(s,e,t=rt())=>Vw(s,e,t,"y"),Bw=(s,e,t,n,i)=>it(s,e,Ow(t,n[i])),$F=(s,e,t,n=rt())=>Bw(s,e,t,n,"x"),YF=(s,e,t,n=rt())=>Bw(s,e,t,n,"y"),ZF=(s=1,e=0,t=rt())=>t.mul(s).add(e),JF=(s,e=1)=>(s=A(s),s.abs().pow(e).mul(s.sign())),KF=(s,e=1,t=.5)=>A(s).sub(t).mul(e).add(t),jF=(s=rt(),e=1,t=0)=>a0(s.convert("vec2|vec3")).mul(e).add(t),QF=(s=rt(),e=1,t=0)=>c0(s.convert("vec2|vec3")).mul(e).add(t),eO=(s=rt(),e=1,t=0)=>(s=s.convert("vec2|vec3"),oe(c0(s),a0(s.add(z(19,73)))).mul(e).add(t)),tO=(s=rt(),e=1)=>OF(s.convert("vec2|vec3"),e,L(1)),nO=(s=rt(),e=1)=>BF(s.convert("vec2|vec3"),e,L(1)),iO=(s=rt(),e=1)=>kF(s.convert("vec2|vec3"),e,L(1)),sO=(s=rt())=>bF(s.convert("vec2|vec3")),rO=(s=rt(),e=3,t=2,n=.5,i=1)=>wh(s,L(e),t,n).mul(i),oO=(s=rt(),e=3,t=2,n=.5,i=1)=>CF(s,L(e),t,n).mul(i),aO=(s=rt(),e=3,t=2,n=.5,i=1)=>Fw(s,L(e),t,n).mul(i),cO=(s=rt(),e=3,t=2,n=.5,i=1)=>RF(s,L(e),t,n).mul(i),zw=U(([s,e])=>{const t=s.x,n=s.y,i=s.z;let r=e.element(0).mul(.886227);return r=r.add(e.element(1).mul(2*.511664).mul(n)),r=r.add(e.element(2).mul(2*.511664).mul(i)),r=r.add(e.element(3).mul(2*.511664).mul(t)),r=r.add(e.element(4).mul(2*.429043).mul(t).mul(n)),r=r.add(e.element(5).mul(2*.429043).mul(n).mul(i)),r=r.add(e.element(6).mul(i.mul(i).mul(.743125).sub(.247708))),r=r.add(e.element(7).mul(2*.429043).mul(t).mul(i)),r=r.add(e.element(8).mul(.429043).mul(ot(t,t).sub(ot(n,n)))),r});class kw extends _r{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=pe(0).setGroup(_t),this.decayExponentNode=pe(0).setGroup(_t)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setup(e){const{colorNode:t,cutoffDistanceNode:n,decayExponentNode:i,light:r}=this,o=e.context.lightingModel,a=zd(r).sub(Pn),c=a.normalize(),l=a.length(),u=n0({lightDistance:l,cutoffDistance:n,decayExponent:i}),h=t.mul(u),d=e.context.reflectedLight;o.direct({lightDirection:c,lightColor:h,reflectedLight:d},e.stack,e)}}class Gw extends _r{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setup(e){super.setup(e);const t=e.context.lightingModel,n=this.colorNode,i=r0(this.light),r=e.context.reflectedLight;t.direct({lightDirection:i,lightColor:n,reflectedLight:r},e.stack,e)}}const nf=new Fe,Nu=new Fe;let Ya=null;class Hw extends _r{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=pe(new E).setGroup(_t),this.halfWidth=pe(new E).setGroup(_t)}update(e){super.update(e);const{light:t}=this,n=e.camera.matrixWorldInverse;Nu.identity(),nf.copy(t.matrixWorld),nf.premultiply(n),Nu.extractRotation(nf),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(Nu),this.halfHeight.value.applyMatrix4(Nu)}setup(e){super.setup(e);let t,n;e.isAvailable("float32Filterable")?(t=xt(Ya.LTC_FLOAT_1),n=xt(Ya.LTC_FLOAT_2)):(t=xt(Ya.LTC_HALF_1),n=xt(Ya.LTC_HALF_2));const{colorNode:i,light:r}=this,o=e.context.lightingModel,a=zd(r),c=e.context.reflectedLight;o.directRectArea({lightColor:i,lightPosition:a,halfWidth:this.halfWidth,halfHeight:this.halfHeight,reflectedLight:c,ltc_1:t,ltc_2:n},e.stack,e)}static setLTC(e){Ya=e}}class l0 extends _r{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=pe(0).setGroup(_t),this.penumbraCosNode=pe(0).setGroup(_t),this.cutoffDistanceNode=pe(0).setGroup(_t),this.decayExponentNode=pe(0).setGroup(_t)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e){const{coneCosNode:t,penumbraCosNode:n}=this;return ti(t,n,e)}setup(e){super.setup(e);const t=e.context.lightingModel,{colorNode:n,cutoffDistanceNode:i,decayExponentNode:r,light:o}=this,a=zd(o).sub(Pn),c=a.normalize(),l=c.dot(r0(o)),u=this.getSpotAttenuation(l),h=a.length(),d=n0({lightDistance:h,cutoffDistance:i,decayExponent:r}),p=n.mul(u).mul(d),f=e.context.reflectedLight;t.direct({lightDirection:c,lightColor:p,reflectedLight:f},e.stack,e)}}class Ww extends l0{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e){const t=this.light.iesMap;let n=null;if(t&&t.isTexture===!0){const i=e.acos().mul(1/Math.PI);n=xt(t,z(i,0),0).r}else n=super.getSpotAttenuation(e);return n}}class Xw extends _r{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class qw extends _r{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=s0(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=pe(new _e).setGroup(_t)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:n,lightDirectionNode:i}=this,o=di.dot(i).mul(.5).add(.5),a=it(n,t,o);e.context.irradiance.addAssign(a)}}class $w extends _r{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let n=0;n<9;n++)t.push(new E);this.lightProbe=ds(t)}update(e){const{light:t}=this;super.update(e);for(let n=0;n<9;n++)this.lightProbe.array[n].copy(t.sh.coefficients[n]).multiplyScalar(t.intensity)}setup(e){const t=zw(Ed,this.lightProbe);e.context.irradiance.addAssign(t)}}class lO{parseFunction(){console.warn("Abstract function.")}}class Yw{constructor(e,t,n="",i=""){this.type=e,this.inputs=t,this.name=n,this.precision=i}getCode(){console.warn("Abstract function.")}}Yw.isNodeFunction=!0;const uO=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,hO=/[a-z_0-9]+/ig,k_="#pragma main",dO=s=>{s=s.trim();const e=s.indexOf(k_),t=e!==-1?s.slice(e+k_.length):s,n=t.match(uO);if(n!==null&&n.length===5){const i=n[4],r=[];let o=null;for(;(o=hO.exec(i))!==null;)r.push(o);const a=[];let c=0;for(;c<r.length;){const f=r[c][0]==="const";f===!0&&c++;let x=r[c][0];x==="in"||x==="out"||x==="inout"?c++:x="";const m=r[c++][0];let g=Number.parseInt(r[c][0]);Number.isNaN(g)===!1?c++:g=null;const y=r[c++][0];a.push(new Kg(m,y,g,x,f))}const l=t.substring(n[0].length),u=n[3]!==void 0?n[3]:"",h=n[2],d=n[1]!==void 0?n[1]:"",p=e!==-1?s.slice(0,e):"";return{type:h,inputs:a,name:u,precision:d,inputsCode:i,blockCode:l,headerCode:p}}else throw new Error("FunctionNode: Function is not a GLSL code.")};class pO extends Yw{constructor(e){const{type:t,inputs:n,name:i,precision:r,inputsCode:o,blockCode:a,headerCode:c}=dO(e);super(t,n,i,r),this.inputsCode=o,this.blockCode=a,this.headerCode=c}getCode(e=this.name){let t;const n=this.blockCode;if(n!==""){const{type:i,inputsCode:r,headerCode:o,precision:a}=this;let c=`${i} ${e} ( ${r.trim()} )`;a!==""&&(c=`${a} ${c}`),t=o+c+n}else t="";return t}}class Zw extends lO{parseFunction(e){return new pO(e)}}class fO{constructor(){this.lightNodes=new WeakMap,this.materialNodes=new Map,this.toneMappingNodes=new Map,this.colorSpaceNodes=new Map}fromMaterial(e){if(e.isNodeMaterial)return e;let t=null;const n=this.getMaterialNodeClass(e.type);if(n!==null){t=new n;for(const i in e)t[i]=e[i]}return t}addColorSpace(e,t){this.addType(e,t,this.colorSpaceNodes)}getColorSpaceFunction(e){return this.colorSpaceNodes.get(e)||null}addToneMapping(e,t){this.addType(e,t,this.toneMappingNodes)}getToneMappingFunction(e){return this.toneMappingNodes.get(e)||null}getMaterialNodeClass(e){return this.materialNodes.get(e)||null}addMaterial(e,t){this.addType(e,t.name,this.materialNodes)}getLightNodeClass(e){return this.lightNodes.get(e)||null}addLight(e,t){this.addClass(e,t,this.lightNodes)}addType(e,t,n){if(n.has(t)){console.warn(`Redefinition of node ${t}`);return}if(typeof e!="function")throw new Error(`Node class ${e.name} is not a class.`);if(typeof t=="function"||typeof t=="object")throw new Error(`Base class ${t} is not a class.`);n.set(t,e)}addClass(e,t,n){if(n.has(t)){console.warn(`Redefinition of node ${t.name}`);return}if(typeof e!="function")throw new Error(`Node class ${e.name} is not a class.`);if(typeof t!="function")throw new Error(`Base class ${t.name} is not a class.`);n.set(t,e)}}class mO extends il{constructor(e,t,n,i,r,o){super(e,t,n,i,r,o),this.iesMap=null}copy(e,t){return super.copy(e,t),this.iesMap=e.iesMap,this}}class Jw extends fO{constructor(){super(),this.addLight(kw,_d),this.addLight(Gw,yd),this.addLight(Hw,Im),this.addLight(l0,il),this.addLight(Xw,vd),this.addLight(qw,xd),this.addLight($w,Pm),this.addLight(Ww,mO),this.addToneMapping(bw,Ah),this.addToneMapping(ww,Nh),this.addToneMapping(Aw,Bf),this.addToneMapping(Nw,Eh),this.addToneMapping(Ew,Ch),this.addToneMapping(Cw,Rh),this.addColorSpace(Tw,xh(li,kn)),this.addColorSpace(Sw,xh(kn,li))}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Ks}}));if(typeof window<"u"){try{typeof document>"u"?require("url").pathToFileURL(__filename).href:mo&&mo.tagName.toUpperCase()==="SCRIPT"&&mo.src||new URL("three-B-jwTHao.umd.cjs",document.baseURI).href,window.__THREE__IMPORTS__||(window.__THREE__IMPORTS__=[]),window.__THREE__IMPORTS__.push({url:typeof document>"u"?require("url").pathToFileURL(__filename).href:mo&&mo.tagName.toUpperCase()==="SCRIPT"&&mo.src||new URL("three-B-jwTHao.umd.cjs",document.baseURI).href,revision:Ks})}catch{}window.__THREE__?(console.warn("WARNING: Multiple instances of Three.js being imported. Existing: "+window.__THREE__+", new: "+Ks),console.warn(window.__THREE__IMPORTS__)):window.__THREE__=Ks}const gO=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:Eh,AONode:OT,AddEquation:Zs,AddOperation:Vf,AdditiveAnimationBlendMode:Yf,AdditiveBlending:cc,AfterImageNode:qb,AgXToneMapping:Ch,AlphaFormat:Gf,AlwaysCompare:Dy,AlwaysDepth:uc,AlwaysStencilFunc:ih,AmbientLight:vd,AmbientLightNode:Xw,AnaglyphPassNode:uw,AnalyticLightNode:_r,AnamorphicNode:Yb,AnimationAction:Tv,AnimationClip:la,AnimationLoader:FI,AnimationMixer:bv,AnimationObjectGroup:tP,AnimationUtils:PI,ArcCurve:tv,ArrayCamera:rm,ArrayElementNode:fr,ArrowHelper:mP,AssignNode:oM,AttachedBindMode:af,AttributeNode:Ag,Audio:Fm,AudioAnalyser:XI,AudioContext:Md,AudioListener:vv,AudioLoader:yv,AxesHelper:Fv,BRDF_GGX:Af,BRDF_Lambert:to,BackSide:ln,BasicDepthPacking:Zf,BasicEnvironmentNode:Dd,BasicNodeLibrary:Jw,BasicShadowMap:nA,BatchNode:CT,BatchedMesh:hm,BloomNode:sw,Bone:Kh,BooleanKeyframeTrack:co,Box2:aP,Box3:Hn,Box3Helper:Uv,BoxGeometry:_s,BoxHelper:Dv,Break:Ld,BufferAttribute:At,BufferAttributeNode:fS,BufferGeometry:at,BufferGeometryLoader:gv,BufferNode:Rd,BumpMapNode:JS,BypassNode:yS,ByteType:zf,Cache:Rs,CacheNode:_S,Camera:Yc,CameraHelper:Lv,CanvasTexture:ev,CapsuleGeometry:Qh,CatmullRomCurve3:gm,CineonToneMapping:Bf,CircleGeometry:ed,ClampToEdgeWrapping:Si,Clock:Um,CodeNode:$g,Color:_e,ColorKeyframeTrack:md,ColorManagement:gt,ColorSpaceNode:hl,CompressedArrayTexture:jy,CompressedCubeTexture:Qy,CompressedTexture:Kc,CompressedTextureLoader:OI,ComputeNode:gS,ConeGeometry:td,ConstNode:Wi,ConstantAlphaFactor:oy,ConstantColorFactor:sy,ContextNode:vg,Continue:wL,Controls:Vv,ConvertNode:$m,CubeCamera:Xh,CubeReflectionMapping:wi,CubeRefractionMapping:Vi,CubeTexture:io,CubeTextureLoader:VI,CubeTextureNode:GS,CubeUVReflectionMapping:hr,CubicBezierCurve:xm,CubicBezierCurve3:nv,CubicInterpolant:uv,CullFaceBack:sf,CullFaceFront:X_,CullFaceFrontBack:tA,CullFaceNone:W_,Curve:Gi,CurvePath:sv,CustomBlending:Uf,CustomToneMapping:cy,CylinderGeometry:ao,Cylindrical:oP,DFGApprox:Hg,D_GGX:eb,Data3DTexture:Hh,DataArrayTexture:qc,DataTexture:Oi,DataTextureLoader:pv,DataUtils:By,DecrementStencilOp:_y,DecrementWrapStencilOp:vy,DefaultLoadingManager:Cm,DenoiseNode:nw,DepthFormat:Qs,DepthOfFieldNode:Jb,DepthStencilFormat:ar,DepthTexture:oo,DetachedBindMode:ly,DirectionalLight:yd,DirectionalLightHelper:Pv,DirectionalLightNode:Gw,Discard:bS,DiscreteInterpolant:hv,DisplayP3ColorSpace:kh,DodecahedronGeometry:nd,DotScreenNode:Kb,DoubleSide:Ji,DstAlphaFactor:Q_,DstColorFactor:ty,DynamicCopyUsage:fA,DynamicDrawUsage:kr,DynamicReadUsage:hA,EPSILON:AM,EdgesGeometry:Sm,EllipseCurve:jh,EnvironmentNode:hb,EqualCompare:Ry,EqualDepth:dc,EqualStencilFunc:by,EquirectUVNode:YT,EquirectangularReflectionMapping:ir,EquirectangularRefractionMapping:sr,Euler:ui,EventDispatcher:Ai,ExpressionNode:TS,ExtrudeGeometry:Qc,FXAANode:iw,F_Schlick:pa,FileLoader:ts,FilmNode:Qb,Float16BufferAttribute:zy,Float32BufferAttribute:Ve,FloatType:Gn,Fn:U,Fog:om,FogExp2:Zh,FogExp2Node:xw,FogNode:Bd,FogRangeNode:gw,FramebufferTexture:fm,FrontFacingNode:LS,FrontSide:fs,Frustum:ga,FunctionCallNode:cM,FunctionNode:Yg,FunctionOverloadingNode:Cb,GLBufferAttribute:rP,GLSL1:gA,GLSL3:sh,GLSLNodeParser:Zw,GTAONode:tw,GaussianBlurNode:Xb,GreaterCompare:Iy,GreaterDepth:fc,GreaterEqualCompare:Ly,GreaterEqualDepth:pc,GreaterEqualStencilFunc:Ey,GreaterStencilFunc:Ay,GridHelper:Iv,Group:Gr,HalfFloatType:Ln,HemisphereLight:xd,HemisphereLightHelper:dP,HemisphereLightNode:qw,IESSpotLightNode:Ww,INFINITY:zP,IcosahedronGeometry:sd,If:Oe,ImageBitmapLoader:_v,ImageLoader:Dc,ImageUtils:Oy,IncrementStencilOp:xy,IncrementWrapStencilOp:yy,IndexNode:zt,InstanceNode:NT,InstancedBufferAttribute:Us,InstancedBufferGeometry:Lm,InstancedInterleavedBuffer:Bm,InstancedMesh:um,InstancedPointsNodeMaterial:zL,Int16BufferAttribute:e1,Int32BufferAttribute:t1,Int8BufferAttribute:KA,IntType:ma,InterleavedBuffer:_a,InterleavedBufferAttribute:Ds,Interpolant:Sa,InterpolateDiscrete:ia,InterpolateLinear:bc,InterpolateSmooth:Eu,InvertStencilOp:My,IrradianceNode:zT,JoinNode:Gv,KeepStencilOp:$s,KeyframeTrack:Hi,LOD:cm,LatheGeometry:jc,Layers:$c,LessCompare:jf,LessDepth:hc,LessEqualCompare:Qf,LessEqualDepth:nr,LessEqualStencilFunc:wy,LessStencilFunc:Ty,Light:pr,LightProbe:Pm,LightProbeNode:$w,LightingContextNode:VT,LightingModel:Ml,LightingNode:ho,LightsNode:UT,Line:Fs,Line2NodeMaterial:qL,Line3:Cv,LineBasicMaterial:Fn,LineBasicNodeMaterial:GL,LineCurve:_m,LineCurve3:iv,LineDashedMaterial:fd,LineDashedNodeMaterial:WL,LineLoop:dm,LineSegments:rs,LinearDisplayP3ColorSpace:Xc,LinearFilter:Ut,LinearInterpolant:Em,LinearMipMapLinearFilter:uy,LinearMipMapNearestFilter:rA,LinearMipmapLinearFilter:Jn,LinearMipmapNearestFilter:js,LinearSRGBColorSpace:li,LinearToneMapping:Ah,LinearTransfer:Ac,Loader:Xn,LoaderUtils:lh,LoadingManager:gd,Loop:mt,LoopNode:PT,LoopOnce:qf,LoopPingPong:hy,LoopRepeat:$f,LuminanceAlphaFormat:Wf,LuminanceFormat:Hf,Lut3DNode:ew,MOUSE:G_,MRTNode:Eb,MatcapUVNode:fb,Material:mn,MaterialLoader:sl,MaterialNode:j,MaterialReferenceNode:HS,MathUtils:Gh,Matrix2:zm,Matrix3:Ke,Matrix4:Fe,MaxEquation:Ff,MaxMipLevelNode:ES,Mesh:kt,MeshBasicMaterial:ss,MeshBasicNodeMaterial:t2,MeshDepthMaterial:Yh,MeshDistanceMaterial:sm,MeshLambertMaterial:pd,MeshLambertNodeMaterial:o2,MeshMatcapMaterial:Am,MeshMatcapNodeMaterial:W2,MeshNormalMaterial:dd,MeshNormalNodeMaterial:ZL,MeshPhongMaterial:hd,MeshPhongNodeMaterial:c2,MeshPhysicalMaterial:ud,MeshPhysicalNodeMaterial:pb,MeshSSSNodeMaterial:V2,MeshStandardMaterial:nl,MeshStandardNodeMaterial:db,MeshToonMaterial:wm,MeshToonNodeMaterial:G2,MinEquation:Y_,MirroredRepeatWrapping:ea,MixOperation:Of,ModelNode:is,ModelViewProjectionNode:bT,MorphNode:LT,MultiplyBlending:of,MultiplyOperation:fa,NearestFilter:Qt,NearestMipMapLinearFilter:sA,NearestMipMapNearestFilter:iA,NearestMipmapLinearFilter:Cs,NearestMipmapNearestFilter:Ph,NeutralToneMapping:Rh,NeverCompare:Cy,NeverDepth:lc,NeverStencilFunc:Sy,NoBlending:Fi,NoColorSpace:Li,NoToneMapping:Ti,Node:Ye,NodeAttribute:If,NodeBuilder:Ab,NodeCache:Lu,NodeCode:Tb,NodeFrame:Nb,NodeFunctionInput:Kg,NodeLoader:yb,NodeMaterial:Tt,NodeMaterialLoader:vb,NodeMaterialObserver:Bv,NodeObjectLoader:e3,NodeShaderStage:mf,NodeType:yP,NodeUniform:Mb,NodeUpdateType:We,NodeUtils:_P,NodeVar:Xg,NodeVarying:Sb,NormalAnimationBlendMode:zh,NormalBlending:Ps,NormalMapNode:ZS,NotEqualCompare:Py,NotEqualDepth:mc,NotEqualStencilFunc:Ny,NumberKeyframeTrack:aa,Object3D:yt,Object3DNode:wt,ObjectLoader:xv,ObjectSpaceNormalMap:Kf,OctahedronGeometry:va,OneFactor:J_,OneMinusConstantAlphaFactor:ay,OneMinusConstantColorFactor:ry,OneMinusDstAlphaFactor:ey,OneMinusDstColorFactor:ny,OneMinusSrcAlphaFactor:Vu,OneMinusSrcColorFactor:j_,OrthographicCamera:ro,OscNode:pn,OutputStructNode:jg,P3Primaries:Ec,PCFShadowMap:Lf,PCFSoftShadowMap:Df,PI:eo,PI2:kP,PMREMGenerator:rh,PMREMNode:lb,ParallaxBarrierPassNode:hw,ParameterNode:qg,PassNode:bn,Path:Rc,PerspectiveCamera:hn,PhongLightingModel:kg,PhysicalLightingModel:Fd,PixelationPassNode:ow,Plane:cs,PlaneGeometry:so,PlaneHelper:fP,PointLight:_d,PointLightHelper:uP,PointLightNode:kw,PointUVNode:Vb,Points:pm,PointsMaterial:ya,PointsNodeMaterial:q2,PolarGridHelper:pP,PolyhedronGeometry:dr,PositionalAudio:Mv,PosterizeNode:Gb,PropertyBinding:St,PropertyMixer:Sv,PropertyNode:Nt,QuadraticBezierCurve:ym,QuadraticBezierCurve3:vm,Quaternion:Qn,QuaternionKeyframeTrack:Ta,QuaternionLinearInterpolant:dv,RED_GREEN_RGTC2_Format:th,RED_RGTC1_Format:Xf,REVISION:Ks,RGBADepthPacking:Jf,RGBAFormat:Rn,RGBAIntegerFormat:Bh,RGBA_ASTC_10x10_Format:Ju,RGBA_ASTC_10x5_Format:$u,RGBA_ASTC_10x6_Format:Yu,RGBA_ASTC_10x8_Format:Zu,RGBA_ASTC_12x10_Format:Ku,RGBA_ASTC_12x12_Format:ju,RGBA_ASTC_4x4_Format:Mc,RGBA_ASTC_5x4_Format:ku,RGBA_ASTC_5x5_Format:Gu,RGBA_ASTC_6x5_Format:Hu,RGBA_ASTC_6x6_Format:Sc,RGBA_ASTC_8x5_Format:Wu,RGBA_ASTC_8x6_Format:Xu,RGBA_ASTC_8x8_Format:qu,RGBA_BPTC_Format:Ko,RGBA_ETC2_EAC_Format:vc,RGBA_PVRTC_2BPPV1_Format:zu,RGBA_PVRTC_4BPPV1_Format:xc,RGBA_S3TC_DXT1_Format:Yo,RGBA_S3TC_DXT3_Format:Zo,RGBA_S3TC_DXT5_Format:Jo,RGBDepthPacking:aA,RGBFormat:Oh,RGBIntegerFormat:oA,RGBShiftNode:jb,RGB_BPTC_SIGNED_Format:Qu,RGB_BPTC_UNSIGNED_Format:Tc,RGB_ETC1_Format:_c,RGB_ETC2_Format:yc,RGB_PVRTC_2BPPV1_Format:Bu,RGB_PVRTC_4BPPV1_Format:gc,RGB_S3TC_DXT1_Format:$o,RGDepthPacking:cA,RGFormat:na,RGIntegerFormat:Vh,RTTNode:Ub,RangeNode:_w,RawShaderMaterial:bm,Ray:no,Raycaster:Nv,Rec709Primaries:Nc,RectAreaLight:Im,RectAreaLightNode:Hw,RedFormat:Hc,RedIntegerFormat:Wc,ReferenceNode:ml,ReflectorNode:Db,ReinhardToneMapping:Nh,RemapNode:wg,RenderOutputNode:wS,RenderTarget:fn,RendererReferenceNode:lS,RepeatWrapping:rr,ReplaceStencilOp:gy,Return:qP,ReverseSubtractEquation:$_,RingGeometry:el,RotateNode:gb,SIGNED_RED_GREEN_RGTC2_Format:nh,SIGNED_RED_RGTC1_Format:eh,SRGBColorSpace:kn,SRGBTransfer:Vt,SSAAPassNode:aw,Scene:Jh,SceneNode:Qi,Schlick_to_F0:nb,ScreenNode:sn,ScriptableNode:mw,ScriptableValueNode:pw,SetNode:Hv,ShaderChunk:lt,ShaderLib:Pi,ShaderMaterial:ki,ShaderNode:ec,ShadowMaterial:ld,ShadowNodeMaterial:K2,Shape:er,ShapeGeometry:rd,ShapePath:Ov,ShapeUtils:ji,ShortType:kf,Skeleton:Jc,SkeletonHelper:lP,SkinnedMesh:lm,SkinningNode:Fg,SobelOperatorNode:Zb,Source:Js,Sphere:Dn,SphereGeometry:Ma,Spherical:Ev,SphericalHarmonics3:mv,SplineCurve:Mm,SplitNode:uh,SpotLight:il,SpotLightHelper:cP,SpotLightNode:l0,Sprite:am,SpriteMaterial:Zc,SpriteNodeMaterial:Y2,SpriteSheetUVNode:Rb,SrcAlphaFactor:Ou,SrcAlphaSaturateFactor:iy,SrcColorFactor:K_,StackNode:wb,StaticCopyUsage:pA,StaticDrawUsage:sa,StaticReadUsage:uA,StereoCamera:Dm,StereoPassNode:cw,StorageArrayElementNode:Ib,StorageBufferNode:t0,StorageTextureNode:Bb,StreamCopyUsage:mA,StreamDrawUsage:lA,StreamReadUsage:dA,StringKeyframeTrack:lo,SubtractEquation:q_,SubtractiveBlending:rf,TBNViewMatrix:Xr,TOUCH:H_,TangentSpaceNormalMap:ms,TempNode:pt,TetrahedronGeometry:od,Texture:Xt,Texture3DNode:xb,TextureLoader:fv,TextureNode:gs,TextureSizeNode:NS,TextureUtils:OR,TimerNode:Sn,ToneMappingNode:hS,ToonOutlinePassNode:dw,TorusGeometry:tl,TorusKnotGeometry:ad,TransitionNode:rw,Triangle:Zn,TriangleFanDrawMode:fy,TriangleStripDrawMode:py,TrianglesDrawMode:dy,TriplanarTexturesNode:Pb,TubeGeometry:cd,UVMapping:Ih,Uint16BufferAttribute:Wh,Uint32BufferAttribute:tm,Uint8BufferAttribute:jA,Uint8ClampedBufferAttribute:QA,Uniform:wv,UniformArrayNode:Ig,UniformGroupNode:eg,UniformNode:uo,UniformsGroup:sP,UniformsLib:Se,UniformsUtils:nm,UnsignedByteType:es,UnsignedInt101111Type:Fh,UnsignedInt248Type:or,UnsignedInt5999Type:Uh,UnsignedIntType:Bi,UnsignedShort4444Type:Lh,UnsignedShort5551Type:Dh,UnsignedShortType:ta,UserDataNode:kb,VSMShadowMap:oi,V_GGX_SmithCorrelated:QT,VarNode:iS,VaryingNode:sS,Vector2:J,Vector3:E,Vector4:st,VectorKeyframeTrack:ca,VertexColorNode:Ob,VideoTexture:Ky,ViewportDepthNode:jn,ViewportDepthTextureNode:WT,ViewportSharedTextureNode:Hb,ViewportTextureNode:vl,VolumeNodeMaterial:Q2,WebGL3DRenderTarget:kA,WebGLArrayRenderTarget:zA,WebGLCoordinateSystem:Di,WebGLCubeRenderTarget:qh,WebGLMultipleRenderTargets:gP,WebGLRenderTarget:zi,WebGLRenderer:Yy,WebGLUtils:$y,WebGPUCoordinateSystem:jr,WireframeGeometry:Tm,WrapAroundEnding:wc,ZeroCurvatureEnding:Br,ZeroFactor:Z_,ZeroSlopeEnding:zr,ZeroStencilOp:my,abs:Dt,acesFilmicToneMapping:Nw,acos:gh,add:Wt,addMethodChaining:te,addNodeElement:$P,afterImage:lD,agxToneMapping:Ew,all:hg,alphaT:dh,anaglyphPass:XD,anamorphic:mD,and:mM,anisotropy:Ys,anisotropyB:Zr,anisotropyT:tc,any:NM,ao:wD,append:Yv,arrayBuffer:FP,asin:LM,assign:aM,atan:DM,atan2:HM,atomicAdd:HU,atomicAnd:$U,atomicFunc:Os,atomicMax:XU,atomicMin:qU,atomicOr:YU,atomicStore:GU,atomicSub:WU,atomicXor:ZU,attenuationColor:ag,attenuationDistance:og,attribute:vn,backgroundBlurriness:K3,backgroundIntensity:j3,batch:RT,billboarding:fU,bitAnd:yM,bitNot:vM,bitOr:MM,bitXor:SM,bitangentGeometry:pL,bitangentLocal:fL,bitangentView:XS,bitangentWorld:mL,bitcast:GP,bleach:TU,bloom:DD,blur:cb,bool:cr,buffer:fl,bufferAttribute:dl,bumpMap:KS,burn:_U,bvec2:Kv,bvec3:Qm,bvec4:tM,bypass:vS,cache:ic,call:lM,cameraFar:Bo,cameraLogDepth:RS,cameraNear:Vo,cameraNormalMatrix:KP,cameraPosition:Ng,cameraProjectionMatrix:ci,cameraProjectionMatrixInverse:ZP,cameraViewMatrix:pi,cameraWorldMatrix:JP,cbrt:JM,ceil:fg,checker:JU,cineonToneMapping:Aw,clamp:cn,clearcoat:hh,clearcoatRoughness:zc,code:Od,color:Zv,colorSpaceToWorking:bg,colorToDirection:$L,compute:xS,cond:tS,context:Mg,convert:iM,convertToTexture:ei,cos:Mi,createCanvasElement:Fy,cross:Qo,cubeTexture:Cd,dFdx:OM,dFdy:VM,dashSize:Jr,defaultBuildStages:gf,defaultShaderStages:qm,defined:Oc,degrees:RM,denoise:ED,densityFog:jD,depth:Bg,depthPass:aD,difference:qM,diffuseColor:Ct,directionToColor:$T,dispersion:cg,distance:XM,div:ns,dodge:yU,dof:xD,dot:$t,dotScreen:_D,drawIndex:AT,dynamicBufferAttribute:mS,element:nM,emissive:yf,equal:uM,equals:EM,equirectUV:zg,exp:dg,exp2:mh,expression:lr,faceDirection:pl,faceForward:jM,film:vD,float:A,floor:mr,fog:JD,fract:gr,frameGroup:VP,frameId:F3,frontFacing:DS,fwidth:kM,fxaa:CD,gain:cU,gapSize:Gc,gaussianBlur:cD,getColorSpaceMethod:xh,getConstNodeType:$v,getCurrentStack:jm,getDirection:ob,getDistanceAttenuation:n0,getGeometryRoughness:jT,getRoughness:Gg,getShIrradianceAt:zw,getTextureIndex:Qg,global:Fu,glsl:r3,glslFn:o3,grayscale:uD,greaterThan:ug,greaterThanEqual:fM,hash:aU,highPrecisionModelNormalViewMatrix:cL,highPrecisionModelViewMatrix:aL,hue:pD,instance:ET,instanceIndex:yl,instancedBufferAttribute:_h,instancedDynamicBufferAttribute:vf,int:L,inverseSqrt:IM,invocationLocalIndex:TL,invocationSubgroupIndex:SL,ior:nc,iridescence:wd,iridescenceIOR:ng,iridescenceThickness:ig,ivec2:ls,ivec3:jv,ivec4:Qv,js:i3,label:nS,length:Kr,lengthSq:xg,lessThan:dM,lessThanEqual:pM,lightPosition:s0,lightTargetDirection:r0,lightTargetPosition:yw,lightViewPosition:zd,lightingContext:BT,lights:FT,linearDepth:Sh,linearSRGBTosRGB:Tw,linearToneMapping:bw,localId:PU,log:pg,log2:al,loop:AL,luminance:En,lut3D:MD,mat2:ol,mat3:Tn,mat4:Yr,matcapUV:mb,materialAOMap:TT,materialAlphaTest:jS,materialAnisotropy:dT,materialAnisotropyVector:zo,materialAttenuationColor:vT,materialAttenuationDistance:yT,materialClearcoat:oT,materialClearcoatNormal:cT,materialClearcoatRoughness:aT,materialColor:ha,materialDispersion:ST,materialEmissive:eT,materialIOR:_T,materialIridescence:pT,materialIridescenceIOR:fT,materialIridescenceThickness:mT,materialLightMap:Ug,materialLineDashOffset:bf,materialLineDashSize:Lg,materialLineGapSize:Dg,materialLineScale:Mh,materialLineWidth:Pu,materialMetalness:sT,materialNormal:rT,materialOpacity:Pd,materialPointWidth:MT,materialReference:Ki,materialReflectivity:Iu,materialRefractionRatio:OS,materialRotation:lT,materialRoughness:iT,materialSheen:uT,materialSheenRoughness:hT,materialShininess:QS,materialSpecular:tT,materialSpecularColor:nT,materialSpecularIntensity:Tf,materialSpecularStrength:sc,materialThickness:xT,materialTransmission:gT,max:ft,maxMipLevel:CS,metalness:Bc,min:Mn,mix:it,mixElement:QM,mod:Ad,modInt:lg,modelDirection:iL,modelNormalMatrix:IS,modelPosition:sL,modelScale:rL,modelViewMatrix:xs,modelViewPosition:oL,modelViewProjection:wf,modelWorldMatrix:Ui,modelWorldMatrixInverse:PS,morphReference:DT,motionBlur:SU,mrt:Vd,mul:ot,mx_aastep:Ow,mx_cell_noise_float:sO,mx_contrast:KF,mx_fractal_noise_float:rO,mx_fractal_noise_vec2:oO,mx_fractal_noise_vec3:aO,mx_fractal_noise_vec4:cO,mx_hsvtorgb:GF,mx_noise_float:jF,mx_noise_vec3:QF,mx_noise_vec4:eO,mx_ramplr:XF,mx_ramptb:qF,mx_rgbtohsv:HF,mx_safepower:JF,mx_splitlr:$F,mx_splittb:YF,mx_srgb_texture_to_lin_rec709:WF,mx_transform_uv:ZF,mx_worley_noise_float:tO,mx_worley_noise_vec2:nO,mx_worley_noise_vec3:iO,negate:UM,neutralToneMapping:Cw,nodeArray:$r,nodeImmutable:fe,nodeObject:H,nodeObjects:rl,nodeProxy:K,normalFlat:US,normalGeometry:Nd,normalLocal:hi,normalMap:Sf,normalView:di,normalWorld:Ed,normalize:vi,not:xM,notEqual:hM,numWorkgroups:RU,objectDirection:jP,objectGroup:rM,objectPosition:eL,objectScale:tL,objectViewPosition:nL,objectWorldMatrix:QP,oneMinus:FM,or:gM,orthographicDepthToViewZ:UL,oscSawtooth:z3,oscSine:O3,oscSquare:V3,oscTriangle:B3,output:sg,outputStruct:P3,overlay:MU,overloadingFn:On,parabola:Pf,parallaxBarrierPass:qD,parallaxDirection:$S,parallaxUV:xL,parameter:n3,pass:oD,passTexture:Na,pcurve:lU,perspectiveDepthToViewZ:Vg,pixelationPass:VD,pmremTexture:ub,pointUV:J3,pointWidth:BP,positionGeometry:Nn,positionLocal:en,positionPrevious:yh,positionView:Pn,positionViewDirection:Bt,positionWorld:vh,positionWorldDirection:Eg,posterize:iD,pow:Kn,pow2:gg,pow3:$M,pow4:YM,property:ai,radians:CM,rand:yg,range:QD,rangeFog:KD,reciprocal:zM,reference:dn,referenceBuffer:Mf,reflect:WM,reflectVector:zS,reflectView:VS,reflector:X3,refract:_g,refractVector:kS,refractView:BS,reinhardToneMapping:ww,remainder:wM,remap:MS,remapClamp:SS,renderGroup:_t,renderOutput:AS,rendererReference:uS,rgbShift:yD,rotate:Wg,rotateUV:dU,roughness:hs,round:BM,rtt:Fb,sRGBToLinearSRGB:Sw,sampler:YP,saturate:KM,saturation:hD,screen:vU,screenCoordinate:Aa,screenSize:da,screenUV:xr,scriptable:ZD,scriptableValue:Uu,select:In,sepia:bU,setCurrentStack:Vc,shaderStages:xf,sharedUniformGroup:tg,sheen:Wr,sheenRoughness:bd,shiftLeft:TM,shiftRight:bM,shininess:ph,sign:cl,sin:Cn,sinc:uU,skinning:bL,skinningReference:IT,smoothstep:ti,smoothstepElement:eS,sobel:gD,specularColor:ri,specularF90:kc,spherizeUV:pU,split:OP,spritesheetUV:k3,sqrt:os,ssaaPass:kD,stack:Du,step:ll,stereoPass:HD,storage:Q3,storageBarrier:FU,storageObject:eD,storageTexture:zb,string:UP,sub:Ft,subgroupIndex:ML,subgroupSize:LU,tan:PM,tangentGeometry:Id,tangentLocal:gl,tangentView:xl,tangentWorld:WS,temp:Sg,texture:xt,texture3D:_b,textureBarrier:OU,textureBicubic:rb,textureCubeUV:ab,textureLoad:Ci,textureSize:tr,textureStore:tD,thickness:rg,threshold:$b,timerDelta:U3,timerGlobal:D3,timerLocal:e0,toOutputColorSpace:rS,toWorkingColorSpace:oS,toneMapping:dS,toneMappingExposure:pS,toonOutlinePass:$D,transformDirection:ZM,transformNormal:FS,transformNormalToView:Rg,transformedBentNormalView:YS,transformedBitangentView:qS,transformedBitangentWorld:gL,transformedClearcoatNormalView:Xo,transformedNormalView:Yt,transformedNormalWorld:Cg,transformedTangentView:Pg,transformedTangentWorld:dL,transition:UD,transmission:fh,transpose:GM,tri:us,tri3:vw,triNoise3D:hU,triplanarTexture:H3,triplanarTextures:Lb,trunc:mg,tslFn:DP,uint:ve,uniform:pe,uniformArray:ds,uniformGroup:sM,uniforms:uL,userData:nD,uv:rt,uvec2:Jv,uvec3:wa,uvec4:eM,varying:Un,varyingProperty:Zi,vec2:z,vec3:D,vec4:oe,vectorComponents:ba,velocity:xU,vertexColor:Z3,vertexIndex:wT,vibrance:dD,viewZToOrthographicDepth:rc,viewZToPerspectiveDepth:XT,viewport:Ls,viewportBottomLeft:LL,viewportCoordinate:GT,viewportDepthTexture:Og,viewportLinearDepth:FL,viewportMipTexture:HT,viewportResolution:IL,viewportSafeUV:mU,viewportSharedTexture:sD,viewportSize:kT,viewportTexture:DL,viewportTopLeft:PL,viewportUV:RL,wgsl:s3,wgslFn:a3,workgroupArray:zU,workgroupBarrier:UU,workgroupId:IU,workingToColorSpace:aS,xor:_M},Symbol.toStringTag,{value:"Module"}));exports.ACESFilmicToneMapping=Eh;exports.AdditiveBlending=cc;exports.AgXToneMapping=Ch;exports.AlwaysDepth=uc;exports.AlwaysStencilFunc=ih;exports.AmbientLight=vd;exports.AnimationClip=la;exports.AnimationMixer=bv;exports.ArrayCamera=rm;exports.Audio=Fm;exports.AudioContext=Md;exports.AudioListener=vv;exports.AudioLoader=yv;exports.AxesHelper=Fv;exports.BackSide=ln;exports.BasicDepthPacking=Zf;exports.BasicNodeLibrary=Jw;exports.BatchedMesh=hm;exports.Bone=Kh;exports.Box3=Hn;exports.Box3Helper=Uv;exports.BoxGeometry=_s;exports.BoxHelper=Dv;exports.BufferAttribute=At;exports.BufferGeometry=at;exports.Camera=Yc;exports.CameraHelper=Lv;exports.CanvasTexture=ev;exports.CatmullRomCurve3=gm;exports.ClampToEdgeWrapping=Si;exports.Clock=Um;exports.Color=_e;exports.ColorKeyframeTrack=md;exports.ColorManagement=gt;exports.CompressedArrayTexture=jy;exports.CompressedCubeTexture=Qy;exports.CompressedTexture=Kc;exports.Controls=Vv;exports.CubeCamera=Xh;exports.CubeTexture=io;exports.CubeUVReflectionMapping=hr;exports.Curve=Gi;exports.CustomBlending=Uf;exports.CylinderGeometry=ao;exports.Data3DTexture=Hh;exports.DataTexture=Oi;exports.DataTextureLoader=pv;exports.DataUtils=By;exports.DecrementStencilOp=_y;exports.DecrementWrapStencilOp=vy;exports.DefaultLoadingManager=Cm;exports.DepthFormat=Qs;exports.DepthStencilFormat=ar;exports.DepthTexture=oo;exports.DirectionalLight=yd;exports.DirectionalLightHelper=Pv;exports.DoubleSide=Ji;exports.DynamicDrawUsage=kr;exports.EdgesGeometry=Sm;exports.EqualDepth=dc;exports.EqualStencilFunc=by;exports.EquirectangularReflectionMapping=ir;exports.EquirectangularRefractionMapping=sr;exports.Euler=ui;exports.EventDispatcher=Ai;exports.ExtrudeGeometry=Qc;exports.FileLoader=ts;exports.Float32BufferAttribute=Ve;exports.FloatType=Gn;exports.Fog=om;exports.FrontSide=fs;exports.Frustum=ga;exports.GLSL3=sh;exports.GLSLNodeParser=Zw;exports.GreaterDepth=fc;exports.GreaterEqualDepth=pc;exports.GreaterEqualStencilFunc=Ey;exports.GreaterStencilFunc=Ay;exports.GridHelper=Iv;exports.Group=Gr;exports.HalfFloatType=Ln;exports.HemisphereLight=xd;exports.ImageBitmapLoader=_v;exports.IncrementStencilOp=xy;exports.IncrementWrapStencilOp=yy;exports.InstancedBufferAttribute=Us;exports.InstancedBufferGeometry=Lm;exports.InstancedInterleavedBuffer=Bm;exports.InstancedMesh=um;exports.InterleavedBuffer=_a;exports.InterleavedBufferAttribute=Ds;exports.Interpolant=Sa;exports.InterpolateDiscrete=ia;exports.InterpolateLinear=bc;exports.InvertStencilOp=My;exports.KeepStencilOp=$s;exports.KeyframeTrack=Hi;exports.LOD=cm;exports.Layers=$c;exports.LessDepth=hc;exports.LessEqualDepth=nr;exports.LessEqualStencilFunc=wy;exports.LessStencilFunc=Ty;exports.Line=Fs;exports.Line3=Cv;exports.LineBasicMaterial=Fn;exports.LineLoop=dm;exports.LineSegments=rs;exports.LinearFilter=Ut;exports.LinearMipmapLinearFilter=Jn;exports.LinearMipmapNearestFilter=js;exports.LinearSRGBColorSpace=li;exports.LinearToneMapping=Ah;exports.Loader=Xn;exports.LoaderUtils=lh;exports.LoadingManager=gd;exports.LoopOnce=qf;exports.LoopRepeat=$f;exports.MOUSE=G_;exports.Material=mn;exports.MathUtils=Gh;exports.Matrix3=Ke;exports.Matrix4=Fe;exports.MaxEquation=Ff;exports.Mesh=kt;exports.MeshBasicMaterial=ss;exports.MeshDepthMaterial=Yh;exports.MeshLambertMaterial=pd;exports.MeshNormalMaterial=dd;exports.MeshPhongMaterial=hd;exports.MeshPhysicalMaterial=ud;exports.MeshStandardMaterial=nl;exports.MirroredRepeatWrapping=ea;exports.NearestFilter=Qt;exports.NearestMipmapLinearFilter=Cs;exports.NearestMipmapNearestFilter=Ph;exports.NeutralToneMapping=Rh;exports.NeverDepth=lc;exports.NeverStencilFunc=Sy;exports.NoBlending=Fi;exports.NoColorSpace=Li;exports.NoToneMapping=Ti;exports.Node=Ye;exports.NodeBuilder=Ab;exports.NodeFrame=Nb;exports.NormalBlending=Ps;exports.NotEqualDepth=mc;exports.NotEqualStencilFunc=Ny;exports.NumberKeyframeTrack=aa;exports.Object3D=yt;exports.OctahedronGeometry=va;exports.OrthographicCamera=ro;exports.PCFSoftShadowMap$1=Df;exports.PMREMGenerator$1=rh;exports.PerspectiveCamera=hn;exports.Plane=cs;exports.PlaneGeometry=so;exports.PointLight=_d;exports.Points=pm;exports.PointsMaterial=ya;exports.PositionalAudio=Mv;exports.PropertyBinding=St;exports.Quaternion=Qn;exports.QuaternionKeyframeTrack=Ta;exports.REVISION=Ks;exports.RGBADepthPacking=Jf;exports.RGBAFormat=Rn;exports.RGBA_ASTC_4x4_Format=Mc;exports.RGBA_ASTC_6x6_Format=Sc;exports.RGBA_BPTC_Format=Ko;exports.RGBA_ETC2_EAC_Format=vc;exports.RGBA_PVRTC_4BPPV1_Format=xc;exports.RGBA_S3TC_DXT1_Format=Yo;exports.RGBA_S3TC_DXT3_Format=Zo;exports.RGBA_S3TC_DXT5_Format=Jo;exports.RGBFormat=Oh;exports.RGB_BPTC_UNSIGNED_Format=Tc;exports.RGB_ETC1_Format=_c;exports.RGB_ETC2_Format=yc;exports.RGB_PVRTC_4BPPV1_Format=gc;exports.RGB_S3TC_DXT1_Format=$o;exports.RGFormat=na;exports.RawShaderMaterial=bm;exports.Ray=no;exports.Raycaster=Nv;exports.RedFormat=Hc;exports.ReinhardToneMapping=Nh;exports.RepeatWrapping=rr;exports.ReplaceStencilOp=gy;exports.RingGeometry=el;exports.SRGBColorSpace=kn;exports.Scene=Jh;exports.ShaderChunk=lt;exports.ShaderLib=Pi;exports.ShaderMaterial=ki;exports.ShadowMaterial=ld;exports.Shape=er;exports.ShapePath=Ov;exports.ShapeUtils=ji;exports.Skeleton=Jc;exports.SkinnedMesh=lm;exports.Source=Js;exports.Sphere=Dn;exports.SphereGeometry=Ma;exports.Spherical=Ev;exports.SpotLight=il;exports.Sprite=am;exports.SpriteMaterial=Zc;exports.THREE=gO;exports.TOUCH=H_;exports.Texture=Xt;exports.TextureLoader=fv;exports.TorusGeometry=tl;exports.Triangle=Zn;exports.TriangleFanDrawMode=fy;exports.TriangleStripDrawMode=py;exports.TrianglesDrawMode=dy;exports.Uint16BufferAttribute=Wh;exports.Uniform$1=wv;exports.UniformsLib=Se;exports.UniformsUtils=nm;exports.UnsignedByteType=es;exports.UnsignedInt101111Type=Fh;exports.UnsignedInt248Type=or;exports.UnsignedInt5999Type=Uh;exports.UnsignedIntType=Bi;exports.Vector2=J;exports.Vector3=E;exports.Vector4=st;exports.VectorKeyframeTrack=ca;exports.VideoTexture=Ky;exports.WebGLCubeRenderTarget=qh;exports.WebGLRenderTarget=zi;exports.WebGLRenderer=Yy;exports.WireframeGeometry=Tm;exports.ZeroStencilOp=my;exports.defaultShaderStages=qm;exports.normalView=di;
3873
+ return { ...output, `+n+" };",o=i+this.codeNode.code+r;return this._method=new Function(...e,o),this._method}dispose(){this._method!==null&&(this._object&&typeof this._object.dispose=="function"&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(e){const t=[zv(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(const n in this.parameters)t.push(this.parameters[n].getCacheKey(e));return kv(t)}set needsUpdate(e){e===!0&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return this.codeNode===null?this:(this._needsOutputUpdate===!0&&(this._value=this.call("main"),this._needsOutputUpdate=!1),this._output.value=this._value,this)}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}}const ZD=K(mw);class Bd extends Ye{static get type(){return"FogNode"}constructor(e,t){super("float"),this.isFogNode=!0,this.colorNode=e,this.factorNode=t}getViewZNode(e){let t;const n=e.context.getViewZ;return n!==void 0&&(t=n(this)),(t||Pn.z).negate()}setup(){return this.factorNode}}const JD=K(Bd);class gw extends Bd{static get type(){return"FogRangeNode"}constructor(e,t,n){super(e),this.isFogRangeNode=!0,this.nearNode=t,this.farNode=n}setup(e){const t=this.getViewZNode(e);return ti(this.nearNode,this.farNode,t)}}const KD=K(gw);class xw extends Bd{static get type(){return"FogExp2Node"}constructor(e,t){super(e),this.isFogExp2Node=!0,this.densityNode=t}setup(e){const t=this.getViewZNode(e),n=this.densityNode;return n.mul(n,t,t).negate().exp().oneMinus()}}const jD=K(xw);let Dr=null,Ur=null;class _w extends Ye{static get type(){return"RangeNode"}constructor(e=A(),t=A()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=e.getTypeLength(Is(this.minNode.value)),n=e.getTypeLength(Is(this.maxNode.value));return t>n?t:n}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}setup(e){const t=e.object;let n=null;if(t.count>1){const i=this.minNode.value,r=this.maxNode.value,o=e.getTypeLength(Is(i)),a=e.getTypeLength(Is(r));Dr=Dr||new st,Ur=Ur||new st,Dr.setScalar(0),Ur.setScalar(0),o===1?Dr.setScalar(i):i.isColor?Dr.set(i.r,i.g,i.b):Dr.set(i.x,i.y,i.z||0,i.w||0),a===1?Ur.setScalar(r):r.isColor?Ur.set(r.r,r.g,r.b):Ur.set(r.x,r.y,r.z||0,r.w||0);const c=4,l=c*t.count,u=new Float32Array(l);for(let d=0;d<l;d++){const p=d%c,f=Dr.getComponent(p),x=Ur.getComponent(p);u[d]=Gh.lerp(f,x,Math.random())}const h=this.getNodeType(e);if(t.count<=4096)n=fl(u,"vec4",t.count).element(yl).convert(h);else{const d=new Us(u,4);e.geometry.setAttribute("__range"+this.id,d),n=_h(d).convert(h)}}else n=A(0);return n}}const QD=K(_w),eU=U(({depthTexture:s,shadowCoord:e})=>xt(s,e.xy).compare(e.z)),tU=U(({depthTexture:s,shadowCoord:e,shadow:t})=>{const n=(x,m)=>xt(s,x).compare(m),i=dn("mapSize","vec2",t).setGroup(_t),r=dn("radius","float",t).setGroup(_t),o=z(1).div(i),a=o.x.negate().mul(r),c=o.y.negate().mul(r),l=o.x.mul(r),u=o.y.mul(r),h=a.div(2),d=c.div(2),p=l.div(2),f=u.div(2);return Wt(n(e.xy.add(z(a,c)),e.z),n(e.xy.add(z(0,c)),e.z),n(e.xy.add(z(l,c)),e.z),n(e.xy.add(z(h,d)),e.z),n(e.xy.add(z(0,d)),e.z),n(e.xy.add(z(p,d)),e.z),n(e.xy.add(z(a,0)),e.z),n(e.xy.add(z(h,0)),e.z),n(e.xy,e.z),n(e.xy.add(z(p,0)),e.z),n(e.xy.add(z(l,0)),e.z),n(e.xy.add(z(h,f)),e.z),n(e.xy.add(z(0,f)),e.z),n(e.xy.add(z(p,f)),e.z),n(e.xy.add(z(a,u)),e.z),n(e.xy.add(z(0,u)),e.z),n(e.xy.add(z(l,u)),e.z)).mul(1/17)}),nU=U(({depthTexture:s,shadowCoord:e,shadow:t})=>{const n=(u,h)=>xt(s,u).compare(h),i=dn("mapSize","vec2",t).setGroup(_t),r=z(1).div(i),o=r.x,a=r.y,c=e.xy,l=xr(c.mul(i).add(.5));return c.subAssign(l.mul(r)),Wt(n(c,e.z),n(c.add(z(o,0)),e.z),n(c.add(z(0,a)),e.z),n(c.add(r),e.z),it(n(c.add(z(o.negate(),0)),e.z),n(c.add(z(o.mul(2),0)),e.z),l.x),it(n(c.add(z(o.negate(),a)),e.z),n(c.add(z(o.mul(2),a)),e.z),l.x),it(n(c.add(z(0,a.negate())),e.z),n(c.add(z(0,a.mul(2))),e.z),l.y),it(n(c.add(z(o,a.negate())),e.z),n(c.add(z(o,a.mul(2))),e.z),l.y),it(it(n(c.add(z(o.negate(),a.negate())),e.z),n(c.add(z(o.mul(2),a.negate())),e.z),l.x),it(n(c.add(z(o.negate(),a.mul(2))),e.z),n(c.add(z(o.mul(2),a.mul(2))),e.z),l.x),l.y)).mul(1/9)}),iU=U(({depthTexture:s,shadowCoord:e})=>{const t=A(1).toVar(),n=xt(s).uv(e.xy).rg,i=ll(e.z,n.x);return Oe(i.notEqual(A(1)),()=>{const r=e.z.sub(n.x),o=ft(0,n.y.mul(n.y));let a=o.div(o.add(r.mul(r)));a=cn(Ft(a,.3).div(.95-.3)),t.assign(cn(ft(i,a)))}),t}),sU=U(({samples:s,radius:e,size:t,shadowPass:n})=>{const i=A(0).toVar(),r=A(0).toVar(),o=s.lessThanEqual(A(1)).select(A(0),A(2).div(s.sub(1))),a=s.lessThanEqual(A(1)).select(A(0),A(-1));mt({start:L(0),end:L(s),type:"int",condition:"<"},({i:l})=>{const u=a.add(A(l).mul(o)),h=n.uv(Wt(Aa.xy,z(0,u).mul(e)).div(t)).x;i.addAssign(h),r.addAssign(h.mul(h))}),i.divAssign(s),r.divAssign(s);const c=os(r.sub(i.mul(i)));return z(i,c)}),rU=U(({samples:s,radius:e,size:t,shadowPass:n})=>{const i=A(0).toVar(),r=A(0).toVar(),o=s.lessThanEqual(A(1)).select(A(0),A(2).div(s.sub(1))),a=s.lessThanEqual(A(1)).select(A(0),A(-1));mt({start:L(0),end:L(s),type:"int",condition:"<"},({i:l})=>{const u=a.add(A(l).mul(o)),h=n.uv(Wt(Aa.xy,z(u,0).mul(e)).div(t));i.addAssign(h.x),r.addAssign(Wt(h.y.mul(h.y),h.x.mul(h.x)))}),i.divAssign(s),r.divAssign(s);const c=os(r.sub(i.mul(i)));return z(i,c)}),oU=[eU,tU,nU,iU];let Oo=null;const wu=new ys;class yr extends ho{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.updateType=We.FRAME,this.light=e,this.color=new _e,this.colorNode=pe(this.color).setGroup(_t),this.baseColorNode=null,this.shadowMap=null,this.shadowNode=null,this.shadowColorNode=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this.isAnalyticLightNode=!0}getCacheKey(){return km(super.getCacheKey(),this.light.id,this.light.castShadow?1:0)}getHash(){return this.light.uuid}setupShadow(e){const{object:t,renderer:n}=e;if(n.shadowMap.enabled===!1)return;let i=this.shadowColorNode;if(i===null){Oo===null&&(Oo=new Tt,Oo.fragmentNode=oe(0,0,0,1),Oo.isShadowNodeMaterial=!0,Oo.name="ShadowMaterial");const r=n.shadowMap.type,o=this.light.shadow,a=new ao;a.compareFunction=jf;const c=e.createRenderTarget(o.mapSize.width,o.mapSize.height);if(c.depthTexture=a,o.camera.updateProjectionMatrix(),r===oi){a.compareFunction=null,this.vsmShadowMapVertical=e.createRenderTarget(o.mapSize.width,o.mapSize.height,{format:na,type:Ln}),this.vsmShadowMapHorizontal=e.createRenderTarget(o.mapSize.width,o.mapSize.height,{format:na,type:Ln});const _=xt(a),v=xt(this.vsmShadowMapVertical.texture),I=dn("blurSamples","float",o).setGroup(_t),T=dn("radius","float",o).setGroup(_t),w=dn("mapSize","vec2",o).setGroup(_t);let C=this.vsmMaterialVertical||(this.vsmMaterialVertical=new Tt);C.fragmentNode=sU({samples:I,radius:T,size:w,shadowPass:_}).context(e.getSharedContext()),C.name="VSMVertical",C=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new Tt),C.fragmentNode=rU({samples:I,radius:T,size:w,shadowPass:v}).context(e.getSharedContext()),C.name="VSMHorizontal"}const l=dn("intensity","float",o).setGroup(_t),u=dn("bias","float",o).setGroup(_t),h=dn("normalBias","float",o).setGroup(_t),d=t.material.shadowPositionNode||vh;let p=pe(o.matrix).setGroup(_t).mul(d.add(Ed.mul(h)));p=p.xyz.div(p.w);let f=p.z.add(u);n.coordinateSystem===Qr&&(f=f.mul(2).sub(1)),p=D(p.x,p.y.oneMinus(),f);const x=p.x.greaterThanEqual(0).and(p.x.lessThanEqual(1)).and(p.y.greaterThanEqual(0)).and(p.y.lessThanEqual(1)).and(p.z.lessThanEqual(1)),m=o.filterNode||oU[n.shadowMap.type]||null;if(m===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const g=xt(c.texture,p),y=x.select(m({depthTexture:r===oi?this.vsmShadowMapHorizontal.texture:a,shadowCoord:p,shadow:o}),A(1));this.shadowMap=c,this.light.shadow.map=c,this.shadowNode=y,this.shadowColorNode=i=this.colorNode.mul(it(1,y.rgb.mix(g,1),l.mul(g.a))),this.baseColorNode=this.colorNode}this.colorNode=i,this.updateBeforeType=We.RENDER}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):this.shadowNode!==null&&this.disposeShadow()}updateShadow(e){const{shadowMap:t,light:n}=this,{renderer:i,scene:r,camera:o}=e,a=i.shadowMap.type,c=t.depthTexture.version;this._depthVersionCached=c;const l=r.overrideMaterial;r.overrideMaterial=Oo,t.setSize(n.shadow.mapSize.width,n.shadow.mapSize.height),n.shadow.updateMatrices(n),n.shadow.camera.layers.mask=o.layers.mask;const u=i.getRenderTarget(),h=i.getRenderObjectFunction();i.setRenderObjectFunction((d,...p)=>{(d.castShadow===!0||d.receiveShadow&&a===oi)&&i.renderObject(d,...p)}),i.setRenderTarget(t),i.render(r,n.shadow.camera),i.setRenderObjectFunction(h),n.isPointLight!==!0&&a===oi&&this.vsmPass(e,n),i.setRenderTarget(u),r.overrideMaterial=l}vsmPass(e,t){const{renderer:n}=e;this.vsmShadowMapVertical.setSize(t.shadow.mapSize.width,t.shadow.mapSize.height),this.vsmShadowMapHorizontal.setSize(t.shadow.mapSize.width,t.shadow.mapSize.height),n.setRenderTarget(this.vsmShadowMapVertical),wu.material=this.vsmMaterialVertical,wu.render(n),n.setRenderTarget(this.vsmShadowMapHorizontal),wu.material=this.vsmMaterialHorizontal,wu.render(n)}disposeShadow(){this.shadowMap.dispose(),this.shadowMap=null,this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null),this.shadowNode=null,this.shadowColorNode=null,this.baseColorNode=null,this.updateBeforeType=We.NONE}updateBefore(e){const t=this.light.shadow;(t.needsUpdate||t.autoUpdate)&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const n0=U(s=>{const{lightDistance:e,cutoffDistance:t,decayExponent:n}=s,i=e.pow(n).max(.01).reciprocal();return t.greaterThan(0).select(i.mul(e.div(t).pow4().oneMinus().clamp().pow2()),i)});let Au;function i0(s){Au=Au||new WeakMap;let e=Au.get(s);return e===void 0&&Au.set(s,e={}),e}function s0(s){const e=i0(s);return e.position||(e.position=pe(new E).setGroup(_t).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(s.matrixWorld)))}function yw(s){const e=i0(s);return e.targetPosition||(e.targetPosition=pe(new E).setGroup(_t).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(s.target.matrixWorld)))}function zd(s){const e=i0(s);return e.viewPosition||(e.viewPosition=pe(new E).setGroup(_t).onRenderUpdate(({camera:t},n)=>{n.value=n.value||new E,n.value.setFromMatrixPosition(s.matrixWorld),n.value.applyMatrix4(t.matrixWorldInverse)}))}const r0=s=>pi.transformDirection(s0(s).sub(yw(s))),aU=U(([s])=>{const e=s.toUint().mul(747796405).add(2891336453),t=e.shiftRight(e.shiftRight(28).add(4)).bitXor(e).mul(277803737);return t.shiftRight(22).bitXor(t).toFloat().mul(1/2**32)}),Pf=(s,e)=>Kn(ot(4,s.mul(Ft(1,s))),e),cU=(s,e)=>s.lessThan(.5)?Pf(s.mul(2),e).div(2):Ft(1,Pf(ot(Ft(1,s),2),e).div(2)),lU=(s,e,t)=>Kn(ns(Kn(s,e),Wt(Kn(s,e),Kn(Ft(1,s),t))),1/e),uU=(s,e)=>Cn(to.mul(e.mul(s).sub(1))).div(to.mul(e.mul(s).sub(1))),us=U(([s])=>s.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),vw=U(([s])=>D(us(s.z.add(us(s.y.mul(1)))),us(s.z.add(us(s.x.mul(1)))),us(s.y.add(us(s.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),hU=U(([s,e,t])=>{const n=D(s).toVar(),i=A(1.4).toVar(),r=A(0).toVar(),o=D(n).toVar();return mt({start:A(0),end:A(3),type:"float",condition:"<="},()=>{const a=D(vw(o.mul(2))).toVar();n.addAssign(a.add(t.mul(A(.1).mul(e)))),o.mulAssign(1.8),i.mulAssign(1.5),n.mulAssign(1.2);const c=A(us(n.z.add(us(n.x.add(us(n.y)))))).toVar();r.addAssign(c.div(i)),o.addAssign(.14)}),r}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"p",type:"vec3"},{name:"spd",type:"float"},{name:"time",type:"float"}]}),dU=U(([s,e,t=z(.5)])=>Wg(s.sub(t),e).add(t)),pU=U(([s,e,t=z(.5)])=>{const n=s.sub(t),i=n.dot(n),o=i.mul(i).mul(e);return s.add(n.mul(o))}),fU=U(({position:s=null,horizontal:e=!0,vertical:t=!1})=>{let n;s!==null?(n=Ui.toVar(),n[3][0]=s.x,n[3][1]=s.y,n[3][2]=s.z):n=Ui;const i=pi.mul(n);return Oc(e)&&(i[0][0]=Ui[0].length(),i[0][1]=0,i[0][2]=0),Oc(t)&&(i[1][0]=0,i[1][1]=Ui[1].length(),i[1][2]=0),i[2][0]=0,i[2][1]=0,i[2][2]=1,ci.mul(i).mul(en)}),mU=U(([s=null])=>{const e=Sh();return Sh(Og(s)).sub(e).lessThan(0).select(_r,s)}),B_=new WeakMap;class gU extends pt{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.updateType=We.OBJECT,this.updateAfterType=We.OBJECT,this.previousModelWorldMatrix=pe(new Fe),this.previousProjectionMatrix=pe(new Fe).setGroup(_t),this.previousCameraViewMatrix=pe(new Fe)}update({frameId:e,camera:t,object:n}){const i=z_(n);this.previousModelWorldMatrix.value.copy(i);const r=Mw(t);r.frameId!==e&&(r.frameId=e,r.previousProjectionMatrix===void 0?(r.previousProjectionMatrix=new Fe,r.previousCameraViewMatrix=new Fe,r.currentProjectionMatrix=new Fe,r.currentCameraViewMatrix=new Fe,r.previousProjectionMatrix.copy(t.projectionMatrix),r.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(r.previousProjectionMatrix.copy(r.currentProjectionMatrix),r.previousCameraViewMatrix.copy(r.currentCameraViewMatrix)),r.currentProjectionMatrix.copy(t.projectionMatrix),r.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(r.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(r.previousCameraViewMatrix))}updateAfter({object:e}){z_(e).copy(e.matrixWorld)}setup(){const e=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),t=ci.mul(xs).mul(en),n=this.previousProjectionMatrix.mul(e).mul(yh),i=t.xy.div(t.w),r=n.xy.div(n.w);return Ft(i,r)}}function Mw(s){let e=B_.get(s);return e===void 0&&(e={},B_.set(s,e)),e}function z_(s,e=0){const t=Mw(s);let n=t[e];return n===void 0&&(t[e]=n=new Fe),n}const xU=fe(gU),_U=U(([s,e])=>Mn(1,s.oneMinus().div(e)).oneMinus()).setLayout({name:"burnBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),yU=U(([s,e])=>Mn(s.div(e.oneMinus()),1)).setLayout({name:"dodgeBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),vU=U(([s,e])=>s.oneMinus().mul(e.oneMinus()).oneMinus()).setLayout({name:"screenBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),MU=U(([s,e])=>it(s.mul(2).mul(e),s.oneMinus().mul(2).mul(e.oneMinus()).oneMinus(),ll(.5,s))).setLayout({name:"overlayBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),SU=U(([s,e,t=L(16)])=>{const n=a=>s.uv(a),i=rt(),r=n(i).toVar(),o=A(t);return mt({start:L(1),end:t,type:"int",condition:"<="},({i:a})=>{const c=e.mul(A(a).div(o.sub(1)).sub(.5));r.addAssign(n(i.add(c)))}),r.divAssign(o),r}),TU=U(([s,e=1])=>{const t=s,n=En(t.rgb),i=D(n),r=Mn(1,ft(0,A(10).mul(n.sub(.45)))),o=i.mul(t.rgb).mul(2),a=A(2).mul(i.oneMinus()).mul(t.rgb.oneMinus()).oneMinus(),c=it(o,a,r),l=t.a.mul(e),u=l.mul(c.rgb);return u.addAssign(t.rgb.mul(l.oneMinus())),oe(u,t.a)}),bU=U(([s])=>{const e=D(s);return oe($t(e,D(.393,.769,.189)),$t(e,D(.349,.686,.168)),$t(e,D(.272,.534,.131)),s.a)}),Sw=U(([s])=>{const e=s.mul(.9478672986).add(.0521327014).pow(2.4),t=s.mul(.0773993808),n=s.lessThanEqual(.04045);return it(e,t,n)}).setLayout({name:"sRGBToLinearSRGB",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),Tw=U(([s])=>{const e=s.pow(.41666).mul(1.055).sub(.055),t=s.mul(12.92),n=s.lessThanEqual(.0031308);return it(e,t,n)}).setLayout({name:"linearSRGBTosRGB",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),bw=U(([s,e])=>s.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),ww=U(([s,e])=>(s=s.mul(e),s.div(s.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),Aw=U(([s,e])=>{s=s.mul(e),s=s.sub(.004).max(0);const t=s.mul(s.mul(6.2).add(.5)),n=s.mul(s.mul(6.2).add(1.7)).add(.06);return t.div(n).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),wU=U(([s])=>{const e=s.mul(s.add(.0245786)).sub(90537e-9),t=s.mul(s.add(.432951).mul(.983729)).add(.238081);return e.div(t)}),Nw=U(([s,e])=>{const t=Tn(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),n=Tn(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return s=s.mul(e).div(.6),s=t.mul(s),s=wU(s),s=n.mul(s),s.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),AU=Tn(D(1.6605,-.1246,-.0182),D(-.5876,1.1329,-.1006),D(-.0728,-.0083,1.1187)),NU=Tn(D(.6274,.0691,.0164),D(.3293,.9195,.088),D(.0433,.0113,.8956)),EU=U(([s])=>{const e=D(s).toVar(),t=D(e.mul(e)).toVar(),n=D(t.mul(t)).toVar();return A(15.5).mul(n.mul(t)).sub(ot(40.14,n.mul(e))).add(ot(31.96,n).sub(ot(6.868,t.mul(e))).add(ot(.4298,t).add(ot(.1191,e).sub(.00232))))}),Ew=U(([s,e])=>{const t=D(s).toVar(),n=Tn(D(.856627153315983,.137318972929847,.11189821299995),D(.0951212405381588,.761241990602591,.0767994186031903),D(.0482516061458583,.101439036467562,.811302368396859)),i=Tn(D(1.1271005818144368,-.1413297634984383,-.14132976349843826),D(-.11060664309660323,1.157823702216272,-.11060664309660294),D(-.016493938717834573,-.016493938717834257,1.2519364065950405)),r=A(-12.47393),o=A(4.026069);return t.mulAssign(e),t.assign(NU.mul(t)),t.assign(n.mul(t)),t.assign(ft(t,1e-10)),t.assign(al(t)),t.assign(t.sub(r).div(o.sub(r))),t.assign(cn(t,0,1)),t.assign(EU(t)),t.assign(i.mul(t)),t.assign(Kn(ft(D(0),t),D(2.2))),t.assign(AU.mul(t)),t.assign(cn(t,0,1)),t}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),Cw=U(([s,e])=>{const t=A(.76),n=A(.15);s=s.mul(e);const i=Mn(s.r,Mn(s.g,s.b)),r=In(i.lessThan(.08),i.sub(ot(6.25,i.mul(i))),.04);s.subAssign(r);const o=ft(s.r,ft(s.g,s.b));Oe(o.lessThan(t),()=>s);const a=Ft(1,t),c=Ft(1,a.mul(a).div(o.add(a.sub(t))));s.mulAssign(c.div(o));const l=Ft(1,ns(1,n.mul(o.sub(c)).add(1)));return it(s,D(c),l)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class CU extends Ye{static get type(){return"ComputeBuiltinNode"}constructor(e,t){super(t),this._builtinName=e}getHash(e){return this.getBuiltinName(e)}getNodeType(){return this.nodeType}setBuiltinName(e){return this._builtinName=e,this}getBuiltinName(){return this._builtinName}hasBuiltin(e){e.hasBuiltin(this._builtinName)}generate(e,t){const n=this.getBuiltinName(e),i=this.getNodeType(e);return e.shaderStage==="compute"?e.format(n,i,t):(console.warn(`ComputeBuiltinNode: Compute built-in value ${n} can not be accessed in the ${e.shaderStage} stage`),e.generateConst(i))}serialize(e){super.serialize(e),e.global=this.global,e._builtinName=this._builtinName}deserialize(e){super.deserialize(e),this.global=e.global,this._builtinName=e._builtinName}}const kd=(s,e)=>H(new CU(s,e)),RU=kd("numWorkgroups","uvec3"),IU=kd("workgroupId","uvec3"),PU=kd("localId","uvec3"),LU=kd("subgroupSize","uint");class DU extends Ye{constructor(e){super(),this.scope=e}generate(e){const{scope:t}=this,{renderer:n}=e;n.backend.isWebGLBackend===!0?e.addFlowCode(` // ${t}Barrier
3874
+ `):e.addLineFlowCode(`${t}Barrier()`,this)}}const o0=K(DU),UU=()=>o0("workgroup").append(),FU=()=>o0("storage").append(),OU=()=>o0("texture").append();class VU extends mr{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let n;const i=e.context.assign;if(n=super.generate(e),i!==!0){const r=this.getNodeType(e);n=e.format(n,r,t)}return n}}class BU extends Ye{constructor(e,t,n=0){super(t),this.bufferType=t,this.bufferCount=n,this.isWorkgroupInfoNode=!0,this.scope=e}label(e){return this.name=e,this}getHash(){return this.uuid}setScope(e){return this.scope=e,this}getInputType(){return`${this.scope}Array`}element(e){return H(new VU(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}const zU=(s,e)=>H(new BU("Workgroup",s,e));class wn extends pt{static get type(){return"AtomicFunctionNode"}constructor(e,t,n,i=null){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=n,this.storeNode=i}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const t=this.method,n=this.getNodeType(e),i=this.getInputType(e),r=this.pointerNode,o=this.valueNode,a=[];a.push(`&${r.build(e,i)}`),a.push(o.build(e,i));const c=`${e.getMethod(t,n)}( ${a.join(", ")} )`;if(this.storeNode!==null){const l=this.storeNode.build(e,i);e.addLineFlowCode(`${l} = ${c}`,this)}else e.addLineFlowCode(c,this)}}wn.ATOMIC_LOAD="atomicLoad";wn.ATOMIC_STORE="atomicStore";wn.ATOMIC_ADD="atomicAdd";wn.ATOMIC_SUB="atomicSub";wn.ATOMIC_MAX="atomicMax";wn.ATOMIC_MIN="atomicMin";wn.ATOMIC_AND="atomicAnd";wn.ATOMIC_OR="atomicOr";wn.ATOMIC_XOR="atomicXor";const kU=K(wn),Os=(s,e,t,n)=>{const i=kU(s,e,t,n);return i.append(),i},GU=(s,e,t=null)=>Os(wn.ATOMIC_STORE,s,e,t),HU=(s,e,t=null)=>Os(wn.ATOMIC_ADD,s,e,t),WU=(s,e,t=null)=>Os(wn.ATOMIC_SUB,s,e,t),XU=(s,e,t=null)=>Os(wn.ATOMIC_MAX,s,e,t),qU=(s,e,t=null)=>Os(wn.ATOMIC_MIN,s,e,t),$U=(s,e,t=null)=>Os(wn.ATOMIC_AND,s,e,t),YU=(s,e,t=null)=>Os(wn.ATOMIC_OR,s,e,t),ZU=(s,e,t=null)=>Os(wn.ATOMIC_XOR,s,e,t),JU=U(([s=rt()])=>{const e=s.mul(2),t=e.x.floor(),n=e.y.floor();return t.add(n).mod(2).sign()}),ac=U(([s,e,t])=>{const n=A(t).toVar(),i=A(e).toVar(),r=cr(s).toVar();return In(r,i,n)}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),bh=U(([s,e])=>{const t=cr(e).toVar(),n=A(s).toVar();return In(t,n.negate(),n)}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),rn=U(([s])=>{const e=A(s).toVar();return L(gr(e))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),Ht=U(([s,e])=>{const t=A(s).toVar();return e.assign(rn(t)),t.sub(A(e))}),KU=U(([s,e,t,n,i,r])=>{const o=A(r).toVar(),a=A(i).toVar(),c=A(n).toVar(),l=A(t).toVar(),u=A(e).toVar(),h=A(s).toVar(),d=A(Ft(1,a)).toVar();return Ft(1,o).mul(h.mul(d).add(u.mul(a))).add(o.mul(l.mul(d).add(c.mul(a))))}).setLayout({name:"mx_bilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"}]}),jU=U(([s,e,t,n,i,r])=>{const o=A(r).toVar(),a=A(i).toVar(),c=D(n).toVar(),l=D(t).toVar(),u=D(e).toVar(),h=D(s).toVar(),d=A(Ft(1,a)).toVar();return Ft(1,o).mul(h.mul(d).add(u.mul(a))).add(o.mul(l.mul(d).add(c.mul(a))))}).setLayout({name:"mx_bilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"}]}),Rw=On([KU,jU]),QU=U(([s,e,t,n,i,r,o,a,c,l,u])=>{const h=A(u).toVar(),d=A(l).toVar(),p=A(c).toVar(),f=A(a).toVar(),x=A(o).toVar(),m=A(r).toVar(),g=A(i).toVar(),y=A(n).toVar(),_=A(t).toVar(),v=A(e).toVar(),I=A(s).toVar(),T=A(Ft(1,p)).toVar(),w=A(Ft(1,d)).toVar();return A(Ft(1,h)).toVar().mul(w.mul(I.mul(T).add(v.mul(p))).add(d.mul(_.mul(T).add(y.mul(p))))).add(h.mul(w.mul(g.mul(T).add(m.mul(p))).add(d.mul(x.mul(T).add(f.mul(p))))))}).setLayout({name:"mx_trilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"v4",type:"float"},{name:"v5",type:"float"},{name:"v6",type:"float"},{name:"v7",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),eF=U(([s,e,t,n,i,r,o,a,c,l,u])=>{const h=A(u).toVar(),d=A(l).toVar(),p=A(c).toVar(),f=D(a).toVar(),x=D(o).toVar(),m=D(r).toVar(),g=D(i).toVar(),y=D(n).toVar(),_=D(t).toVar(),v=D(e).toVar(),I=D(s).toVar(),T=A(Ft(1,p)).toVar(),w=A(Ft(1,d)).toVar();return A(Ft(1,h)).toVar().mul(w.mul(I.mul(T).add(v.mul(p))).add(d.mul(_.mul(T).add(y.mul(p))))).add(h.mul(w.mul(g.mul(T).add(m.mul(p))).add(d.mul(x.mul(T).add(f.mul(p))))))}).setLayout({name:"mx_trilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"v4",type:"vec3"},{name:"v5",type:"vec3"},{name:"v6",type:"vec3"},{name:"v7",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),Iw=On([QU,eF]),tF=U(([s,e,t])=>{const n=A(t).toVar(),i=A(e).toVar(),r=ve(s).toVar(),o=ve(r.bitAnd(ve(7))).toVar(),a=A(ac(o.lessThan(ve(4)),i,n)).toVar(),c=A(ot(2,ac(o.lessThan(ve(4)),n,i))).toVar();return bh(a,cr(o.bitAnd(ve(1)))).add(bh(c,cr(o.bitAnd(ve(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),nF=U(([s,e,t,n])=>{const i=A(n).toVar(),r=A(t).toVar(),o=A(e).toVar(),a=ve(s).toVar(),c=ve(a.bitAnd(ve(15))).toVar(),l=A(ac(c.lessThan(ve(8)),o,r)).toVar(),u=A(ac(c.lessThan(ve(4)),r,ac(c.equal(ve(12)).or(c.equal(ve(14))),o,i))).toVar();return bh(l,cr(c.bitAnd(ve(1)))).add(bh(u,cr(c.bitAnd(ve(2)))))}).setLayout({name:"mx_gradient_float_1",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),yn=On([tF,nF]),iF=U(([s,e,t])=>{const n=A(t).toVar(),i=A(e).toVar(),r=wa(s).toVar();return D(yn(r.x,i,n),yn(r.y,i,n),yn(r.z,i,n))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),sF=U(([s,e,t,n])=>{const i=A(n).toVar(),r=A(t).toVar(),o=A(e).toVar(),a=wa(s).toVar();return D(yn(a.x,o,r,i),yn(a.y,o,r,i),yn(a.z,o,r,i))}).setLayout({name:"mx_gradient_vec3_1",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),Ri=On([iF,sF]),rF=U(([s])=>{const e=A(s).toVar();return ot(.6616,e)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),oF=U(([s])=>{const e=A(s).toVar();return ot(.982,e)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),aF=U(([s])=>{const e=D(s).toVar();return ot(.6616,e)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),Pw=On([rF,aF]),cF=U(([s])=>{const e=D(s).toVar();return ot(.982,e)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),Lw=On([oF,cF]),yi=U(([s,e])=>{const t=L(e).toVar(),n=ve(s).toVar();return n.shiftLeft(t).bitOr(n.shiftRight(L(32).sub(t)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),Dw=U(([s,e,t])=>{s.subAssign(t),s.bitXorAssign(yi(t,L(4))),t.addAssign(e),e.subAssign(s),e.bitXorAssign(yi(s,L(6))),s.addAssign(t),t.subAssign(e),t.bitXorAssign(yi(e,L(8))),e.addAssign(s),s.subAssign(t),s.bitXorAssign(yi(t,L(16))),t.addAssign(e),e.subAssign(s),e.bitXorAssign(yi(s,L(19))),s.addAssign(t),t.subAssign(e),t.bitXorAssign(yi(e,L(4))),e.addAssign(s)}),Sl=U(([s,e,t])=>{const n=ve(t).toVar(),i=ve(e).toVar(),r=ve(s).toVar();return n.bitXorAssign(i),n.subAssign(yi(i,L(14))),r.bitXorAssign(n),r.subAssign(yi(n,L(11))),i.bitXorAssign(r),i.subAssign(yi(r,L(25))),n.bitXorAssign(i),n.subAssign(yi(i,L(16))),r.bitXorAssign(n),r.subAssign(yi(n,L(4))),i.bitXorAssign(r),i.subAssign(yi(r,L(14))),n.bitXorAssign(i),n.subAssign(yi(i,L(24))),n}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),Wn=U(([s])=>{const e=ve(s).toVar();return A(e).div(A(ve(L(4294967295))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),ps=U(([s])=>{const e=A(s).toVar();return e.mul(e).mul(e).mul(e.mul(e.mul(6).sub(15)).add(10))}).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),lF=U(([s])=>{const e=L(s).toVar(),t=ve(ve(1)).toVar(),n=ve(ve(L(3735928559)).add(t.shiftLeft(ve(2))).add(ve(13))).toVar();return Sl(n.add(ve(e)),n,n)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),uF=U(([s,e])=>{const t=L(e).toVar(),n=L(s).toVar(),i=ve(ve(2)).toVar(),r=ve().toVar(),o=ve().toVar(),a=ve().toVar();return r.assign(o.assign(a.assign(ve(L(3735928559)).add(i.shiftLeft(ve(2))).add(ve(13))))),r.addAssign(ve(n)),o.addAssign(ve(t)),Sl(r,o,a)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),hF=U(([s,e,t])=>{const n=L(t).toVar(),i=L(e).toVar(),r=L(s).toVar(),o=ve(ve(3)).toVar(),a=ve().toVar(),c=ve().toVar(),l=ve().toVar();return a.assign(c.assign(l.assign(ve(L(3735928559)).add(o.shiftLeft(ve(2))).add(ve(13))))),a.addAssign(ve(r)),c.addAssign(ve(i)),l.addAssign(ve(n)),Sl(a,c,l)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),dF=U(([s,e,t,n])=>{const i=L(n).toVar(),r=L(t).toVar(),o=L(e).toVar(),a=L(s).toVar(),c=ve(ve(4)).toVar(),l=ve().toVar(),u=ve().toVar(),h=ve().toVar();return l.assign(u.assign(h.assign(ve(L(3735928559)).add(c.shiftLeft(ve(2))).add(ve(13))))),l.addAssign(ve(a)),u.addAssign(ve(o)),h.addAssign(ve(r)),Dw(l,u,h),l.addAssign(ve(i)),Sl(l,u,h)}).setLayout({name:"mx_hash_int_3",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"}]}),pF=U(([s,e,t,n,i])=>{const r=L(i).toVar(),o=L(n).toVar(),a=L(t).toVar(),c=L(e).toVar(),l=L(s).toVar(),u=ve(ve(5)).toVar(),h=ve().toVar(),d=ve().toVar(),p=ve().toVar();return h.assign(d.assign(p.assign(ve(L(3735928559)).add(u.shiftLeft(ve(2))).add(ve(13))))),h.addAssign(ve(l)),d.addAssign(ve(c)),p.addAssign(ve(a)),Dw(h,d,p),h.addAssign(ve(o)),d.addAssign(ve(r)),Sl(h,d,p)}).setLayout({name:"mx_hash_int_4",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"},{name:"yy",type:"int"}]}),Pt=On([lF,uF,hF,dF,pF]),fF=U(([s,e])=>{const t=L(e).toVar(),n=L(s).toVar(),i=ve(Pt(n,t)).toVar(),r=wa().toVar();return r.x.assign(i.bitAnd(L(255))),r.y.assign(i.shiftRight(L(8)).bitAnd(L(255))),r.z.assign(i.shiftRight(L(16)).bitAnd(L(255))),r}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),mF=U(([s,e,t])=>{const n=L(t).toVar(),i=L(e).toVar(),r=L(s).toVar(),o=ve(Pt(r,i,n)).toVar(),a=wa().toVar();return a.x.assign(o.bitAnd(L(255))),a.y.assign(o.shiftRight(L(8)).bitAnd(L(255))),a.z.assign(o.shiftRight(L(16)).bitAnd(L(255))),a}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),Ii=On([fF,mF]),gF=U(([s])=>{const e=z(s).toVar(),t=L().toVar(),n=L().toVar(),i=A(Ht(e.x,t)).toVar(),r=A(Ht(e.y,n)).toVar(),o=A(ps(i)).toVar(),a=A(ps(r)).toVar(),c=A(Rw(yn(Pt(t,n),i,r),yn(Pt(t.add(L(1)),n),i.sub(1),r),yn(Pt(t,n.add(L(1))),i,r.sub(1)),yn(Pt(t.add(L(1)),n.add(L(1))),i.sub(1),r.sub(1)),o,a)).toVar();return Pw(c)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),xF=U(([s])=>{const e=D(s).toVar(),t=L().toVar(),n=L().toVar(),i=L().toVar(),r=A(Ht(e.x,t)).toVar(),o=A(Ht(e.y,n)).toVar(),a=A(Ht(e.z,i)).toVar(),c=A(ps(r)).toVar(),l=A(ps(o)).toVar(),u=A(ps(a)).toVar(),h=A(Iw(yn(Pt(t,n,i),r,o,a),yn(Pt(t.add(L(1)),n,i),r.sub(1),o,a),yn(Pt(t,n.add(L(1)),i),r,o.sub(1),a),yn(Pt(t.add(L(1)),n.add(L(1)),i),r.sub(1),o.sub(1),a),yn(Pt(t,n,i.add(L(1))),r,o,a.sub(1)),yn(Pt(t.add(L(1)),n,i.add(L(1))),r.sub(1),o,a.sub(1)),yn(Pt(t,n.add(L(1)),i.add(L(1))),r,o.sub(1),a.sub(1)),yn(Pt(t.add(L(1)),n.add(L(1)),i.add(L(1))),r.sub(1),o.sub(1),a.sub(1)),c,l,u)).toVar();return Lw(h)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]}),a0=On([gF,xF]),_F=U(([s])=>{const e=z(s).toVar(),t=L().toVar(),n=L().toVar(),i=A(Ht(e.x,t)).toVar(),r=A(Ht(e.y,n)).toVar(),o=A(ps(i)).toVar(),a=A(ps(r)).toVar(),c=D(Rw(Ri(Ii(t,n),i,r),Ri(Ii(t.add(L(1)),n),i.sub(1),r),Ri(Ii(t,n.add(L(1))),i,r.sub(1)),Ri(Ii(t.add(L(1)),n.add(L(1))),i.sub(1),r.sub(1)),o,a)).toVar();return Pw(c)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),yF=U(([s])=>{const e=D(s).toVar(),t=L().toVar(),n=L().toVar(),i=L().toVar(),r=A(Ht(e.x,t)).toVar(),o=A(Ht(e.y,n)).toVar(),a=A(Ht(e.z,i)).toVar(),c=A(ps(r)).toVar(),l=A(ps(o)).toVar(),u=A(ps(a)).toVar(),h=D(Iw(Ri(Ii(t,n,i),r,o,a),Ri(Ii(t.add(L(1)),n,i),r.sub(1),o,a),Ri(Ii(t,n.add(L(1)),i),r,o.sub(1),a),Ri(Ii(t.add(L(1)),n.add(L(1)),i),r.sub(1),o.sub(1),a),Ri(Ii(t,n,i.add(L(1))),r,o,a.sub(1)),Ri(Ii(t.add(L(1)),n,i.add(L(1))),r.sub(1),o,a.sub(1)),Ri(Ii(t,n.add(L(1)),i.add(L(1))),r,o.sub(1),a.sub(1)),Ri(Ii(t.add(L(1)),n.add(L(1)),i.add(L(1))),r.sub(1),o.sub(1),a.sub(1)),c,l,u)).toVar();return Lw(h)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),c0=On([_F,yF]),vF=U(([s])=>{const e=A(s).toVar(),t=L(rn(e)).toVar();return Wn(Pt(t))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),MF=U(([s])=>{const e=z(s).toVar(),t=L(rn(e.x)).toVar(),n=L(rn(e.y)).toVar();return Wn(Pt(t,n))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),SF=U(([s])=>{const e=D(s).toVar(),t=L(rn(e.x)).toVar(),n=L(rn(e.y)).toVar(),i=L(rn(e.z)).toVar();return Wn(Pt(t,n,i))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),TF=U(([s])=>{const e=oe(s).toVar(),t=L(rn(e.x)).toVar(),n=L(rn(e.y)).toVar(),i=L(rn(e.z)).toVar(),r=L(rn(e.w)).toVar();return Wn(Pt(t,n,i,r))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]}),bF=On([vF,MF,SF,TF]),wF=U(([s])=>{const e=A(s).toVar(),t=L(rn(e)).toVar();return D(Wn(Pt(t,L(0))),Wn(Pt(t,L(1))),Wn(Pt(t,L(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),AF=U(([s])=>{const e=z(s).toVar(),t=L(rn(e.x)).toVar(),n=L(rn(e.y)).toVar();return D(Wn(Pt(t,n,L(0))),Wn(Pt(t,n,L(1))),Wn(Pt(t,n,L(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),NF=U(([s])=>{const e=D(s).toVar(),t=L(rn(e.x)).toVar(),n=L(rn(e.y)).toVar(),i=L(rn(e.z)).toVar();return D(Wn(Pt(t,n,i,L(0))),Wn(Pt(t,n,i,L(1))),Wn(Pt(t,n,i,L(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),EF=U(([s])=>{const e=oe(s).toVar(),t=L(rn(e.x)).toVar(),n=L(rn(e.y)).toVar(),i=L(rn(e.z)).toVar(),r=L(rn(e.w)).toVar();return D(Wn(Pt(t,n,i,r,L(0))),Wn(Pt(t,n,i,r,L(1))),Wn(Pt(t,n,i,r,L(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]}),Uw=On([wF,AF,NF,EF]),wh=U(([s,e,t,n])=>{const i=A(n).toVar(),r=A(t).toVar(),o=L(e).toVar(),a=D(s).toVar(),c=A(0).toVar(),l=A(1).toVar();return mt(o,()=>{c.addAssign(l.mul(a0(a))),l.mulAssign(i),a.mulAssign(r)}),c}).setLayout({name:"mx_fractal_noise_float",type:"float",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),Fw=U(([s,e,t,n])=>{const i=A(n).toVar(),r=A(t).toVar(),o=L(e).toVar(),a=D(s).toVar(),c=D(0).toVar(),l=A(1).toVar();return mt(o,()=>{c.addAssign(l.mul(c0(a))),l.mulAssign(i),a.mulAssign(r)}),c}).setLayout({name:"mx_fractal_noise_vec3",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),CF=U(([s,e,t,n])=>{const i=A(n).toVar(),r=A(t).toVar(),o=L(e).toVar(),a=D(s).toVar();return z(wh(a,o,r,i),wh(a.add(D(L(19),L(193),L(17))),o,r,i))}).setLayout({name:"mx_fractal_noise_vec2",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),RF=U(([s,e,t,n])=>{const i=A(n).toVar(),r=A(t).toVar(),o=L(e).toVar(),a=D(s).toVar(),c=D(Fw(a,o,r,i)).toVar(),l=A(wh(a.add(D(L(19),L(193),L(17))),o,r,i)).toVar();return oe(c,l)}).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),IF=U(([s,e,t,n,i,r,o])=>{const a=L(o).toVar(),c=A(r).toVar(),l=L(i).toVar(),u=L(n).toVar(),h=L(t).toVar(),d=L(e).toVar(),p=z(s).toVar(),f=D(Uw(z(d.add(u),h.add(l)))).toVar(),x=z(f.x,f.y).toVar();x.subAssign(.5),x.mulAssign(c),x.addAssign(.5);const m=z(z(A(d),A(h)).add(x)).toVar(),g=z(m.sub(p)).toVar();return Oe(a.equal(L(2)),()=>Dt(g.x).add(Dt(g.y))),Oe(a.equal(L(3)),()=>ft(Dt(g.x),Dt(g.y))),$t(g,g)}).setLayout({name:"mx_worley_distance_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),PF=U(([s,e,t,n,i,r,o,a,c])=>{const l=L(c).toVar(),u=A(a).toVar(),h=L(o).toVar(),d=L(r).toVar(),p=L(i).toVar(),f=L(n).toVar(),x=L(t).toVar(),m=L(e).toVar(),g=D(s).toVar(),y=D(Uw(D(m.add(p),x.add(d),f.add(h)))).toVar();y.subAssign(.5),y.mulAssign(u),y.addAssign(.5);const _=D(D(A(m),A(x),A(f)).add(y)).toVar(),v=D(_.sub(g)).toVar();return Oe(l.equal(L(2)),()=>Dt(v.x).add(Dt(v.y)).add(Dt(v.z))),Oe(l.equal(L(3)),()=>ft(ft(Dt(v.x),Dt(v.y)),Dt(v.z))),$t(v,v)}).setLayout({name:"mx_worley_distance_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"zoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Ea=On([IF,PF]),LF=U(([s,e,t])=>{const n=L(t).toVar(),i=A(e).toVar(),r=z(s).toVar(),o=L().toVar(),a=L().toVar(),c=z(Ht(r.x,o),Ht(r.y,a)).toVar(),l=A(1e6).toVar();return mt({start:-1,end:L(1),name:"x",condition:"<="},({x:u})=>{mt({start:-1,end:L(1),name:"y",condition:"<="},({y:h})=>{const d=A(Ea(c,u,h,o,a,i,n)).toVar();l.assign(Mn(l,d))})}),Oe(n.equal(L(0)),()=>{l.assign(os(l))}),l}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),DF=U(([s,e,t])=>{const n=L(t).toVar(),i=A(e).toVar(),r=z(s).toVar(),o=L().toVar(),a=L().toVar(),c=z(Ht(r.x,o),Ht(r.y,a)).toVar(),l=z(1e6,1e6).toVar();return mt({start:-1,end:L(1),name:"x",condition:"<="},({x:u})=>{mt({start:-1,end:L(1),name:"y",condition:"<="},({y:h})=>{const d=A(Ea(c,u,h,o,a,i,n)).toVar();Oe(d.lessThan(l.x),()=>{l.y.assign(l.x),l.x.assign(d)}).ElseIf(d.lessThan(l.y),()=>{l.y.assign(d)})})}),Oe(n.equal(L(0)),()=>{l.assign(os(l))}),l}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),UF=U(([s,e,t])=>{const n=L(t).toVar(),i=A(e).toVar(),r=z(s).toVar(),o=L().toVar(),a=L().toVar(),c=z(Ht(r.x,o),Ht(r.y,a)).toVar(),l=D(1e6,1e6,1e6).toVar();return mt({start:-1,end:L(1),name:"x",condition:"<="},({x:u})=>{mt({start:-1,end:L(1),name:"y",condition:"<="},({y:h})=>{const d=A(Ea(c,u,h,o,a,i,n)).toVar();Oe(d.lessThan(l.x),()=>{l.z.assign(l.y),l.y.assign(l.x),l.x.assign(d)}).ElseIf(d.lessThan(l.y),()=>{l.z.assign(l.y),l.y.assign(d)}).ElseIf(d.lessThan(l.z),()=>{l.z.assign(d)})})}),Oe(n.equal(L(0)),()=>{l.assign(os(l))}),l}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),FF=U(([s,e,t])=>{const n=L(t).toVar(),i=A(e).toVar(),r=D(s).toVar(),o=L().toVar(),a=L().toVar(),c=L().toVar(),l=D(Ht(r.x,o),Ht(r.y,a),Ht(r.z,c)).toVar(),u=A(1e6).toVar();return mt({start:-1,end:L(1),name:"x",condition:"<="},({x:h})=>{mt({start:-1,end:L(1),name:"y",condition:"<="},({y:d})=>{mt({start:-1,end:L(1),name:"z",condition:"<="},({z:p})=>{const f=A(Ea(l,h,d,p,o,a,c,i,n)).toVar();u.assign(Mn(u,f))})})}),Oe(n.equal(L(0)),()=>{u.assign(os(u))}),u}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),OF=On([LF,FF]),VF=U(([s,e,t])=>{const n=L(t).toVar(),i=A(e).toVar(),r=D(s).toVar(),o=L().toVar(),a=L().toVar(),c=L().toVar(),l=D(Ht(r.x,o),Ht(r.y,a),Ht(r.z,c)).toVar(),u=z(1e6,1e6).toVar();return mt({start:-1,end:L(1),name:"x",condition:"<="},({x:h})=>{mt({start:-1,end:L(1),name:"y",condition:"<="},({y:d})=>{mt({start:-1,end:L(1),name:"z",condition:"<="},({z:p})=>{const f=A(Ea(l,h,d,p,o,a,c,i,n)).toVar();Oe(f.lessThan(u.x),()=>{u.y.assign(u.x),u.x.assign(f)}).ElseIf(f.lessThan(u.y),()=>{u.y.assign(f)})})})}),Oe(n.equal(L(0)),()=>{u.assign(os(u))}),u}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),BF=On([DF,VF]),zF=U(([s,e,t])=>{const n=L(t).toVar(),i=A(e).toVar(),r=D(s).toVar(),o=L().toVar(),a=L().toVar(),c=L().toVar(),l=D(Ht(r.x,o),Ht(r.y,a),Ht(r.z,c)).toVar(),u=D(1e6,1e6,1e6).toVar();return mt({start:-1,end:L(1),name:"x",condition:"<="},({x:h})=>{mt({start:-1,end:L(1),name:"y",condition:"<="},({y:d})=>{mt({start:-1,end:L(1),name:"z",condition:"<="},({z:p})=>{const f=A(Ea(l,h,d,p,o,a,c,i,n)).toVar();Oe(f.lessThan(u.x),()=>{u.z.assign(u.y),u.y.assign(u.x),u.x.assign(f)}).ElseIf(f.lessThan(u.y),()=>{u.z.assign(u.y),u.y.assign(f)}).ElseIf(f.lessThan(u.z),()=>{u.z.assign(f)})})})}),Oe(n.equal(L(0)),()=>{u.assign(os(u))}),u}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),kF=On([UF,zF]),GF=U(([s])=>{const e=s.y,t=s.z,n=D().toVar();return Oe(e.lessThan(1e-4),()=>{n.assign(D(t,t,t))}).Else(()=>{let i=s.x;i=i.sub(gr(i)).mul(6).toVar();const r=L(mg(i)),o=i.sub(A(r)),a=t.mul(e.oneMinus()),c=t.mul(e.mul(o).oneMinus()),l=t.mul(e.mul(o.oneMinus()).oneMinus());Oe(r.equal(L(0)),()=>{n.assign(D(t,l,a))}).ElseIf(r.equal(L(1)),()=>{n.assign(D(c,t,a))}).ElseIf(r.equal(L(2)),()=>{n.assign(D(a,t,l))}).ElseIf(r.equal(L(3)),()=>{n.assign(D(a,c,t))}).ElseIf(r.equal(L(4)),()=>{n.assign(D(l,a,t))}).Else(()=>{n.assign(D(t,a,c))})}),n}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),HF=U(([s])=>{const e=D(s).toVar(),t=A(e.x).toVar(),n=A(e.y).toVar(),i=A(e.z).toVar(),r=A(Mn(t,Mn(n,i))).toVar(),o=A(ft(t,ft(n,i))).toVar(),a=A(o.sub(r)).toVar(),c=A().toVar(),l=A().toVar(),u=A().toVar();return u.assign(o),Oe(o.greaterThan(0),()=>{l.assign(a.div(o))}).Else(()=>{l.assign(0)}),Oe(l.lessThanEqual(0),()=>{c.assign(0)}).Else(()=>{Oe(t.greaterThanEqual(o),()=>{c.assign(n.sub(i).div(a))}).ElseIf(n.greaterThanEqual(o),()=>{c.assign(Wt(2,i.sub(t).div(a)))}).Else(()=>{c.assign(Wt(4,t.sub(n).div(a)))}),c.mulAssign(1/6),Oe(c.lessThan(0),()=>{c.addAssign(1)})}),D(c,l,u)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),WF=U(([s])=>{const e=D(s).toVar(),t=Qm(ug(e,D(.04045))).toVar(),n=D(e.div(12.92)).toVar(),i=D(Kn(ft(e.add(D(.055)),D(0)).div(1.055),D(2.4))).toVar();return it(n,i,t)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),Ow=(s,e)=>{s=A(s),e=A(e);const t=z(e.dFdx(),e.dFdy()).length().mul(.7071067811865476);return ti(s.sub(t),s.add(t),e)},Vw=(s,e,t,n)=>it(s,e,t[n].clamp()),XF=(s,e,t=rt())=>Vw(s,e,t,"x"),qF=(s,e,t=rt())=>Vw(s,e,t,"y"),Bw=(s,e,t,n,i)=>it(s,e,Ow(t,n[i])),$F=(s,e,t,n=rt())=>Bw(s,e,t,n,"x"),YF=(s,e,t,n=rt())=>Bw(s,e,t,n,"y"),ZF=(s=1,e=0,t=rt())=>t.mul(s).add(e),JF=(s,e=1)=>(s=A(s),s.abs().pow(e).mul(s.sign())),KF=(s,e=1,t=.5)=>A(s).sub(t).mul(e).add(t),jF=(s=rt(),e=1,t=0)=>a0(s.convert("vec2|vec3")).mul(e).add(t),QF=(s=rt(),e=1,t=0)=>c0(s.convert("vec2|vec3")).mul(e).add(t),eO=(s=rt(),e=1,t=0)=>(s=s.convert("vec2|vec3"),oe(c0(s),a0(s.add(z(19,73)))).mul(e).add(t)),tO=(s=rt(),e=1)=>OF(s.convert("vec2|vec3"),e,L(1)),nO=(s=rt(),e=1)=>BF(s.convert("vec2|vec3"),e,L(1)),iO=(s=rt(),e=1)=>kF(s.convert("vec2|vec3"),e,L(1)),sO=(s=rt())=>bF(s.convert("vec2|vec3")),rO=(s=rt(),e=3,t=2,n=.5,i=1)=>wh(s,L(e),t,n).mul(i),oO=(s=rt(),e=3,t=2,n=.5,i=1)=>CF(s,L(e),t,n).mul(i),aO=(s=rt(),e=3,t=2,n=.5,i=1)=>Fw(s,L(e),t,n).mul(i),cO=(s=rt(),e=3,t=2,n=.5,i=1)=>RF(s,L(e),t,n).mul(i),zw=U(([s,e])=>{const t=s.x,n=s.y,i=s.z;let r=e.element(0).mul(.886227);return r=r.add(e.element(1).mul(2*.511664).mul(n)),r=r.add(e.element(2).mul(2*.511664).mul(i)),r=r.add(e.element(3).mul(2*.511664).mul(t)),r=r.add(e.element(4).mul(2*.429043).mul(t).mul(n)),r=r.add(e.element(5).mul(2*.429043).mul(n).mul(i)),r=r.add(e.element(6).mul(i.mul(i).mul(.743125).sub(.247708))),r=r.add(e.element(7).mul(2*.429043).mul(t).mul(i)),r=r.add(e.element(8).mul(.429043).mul(ot(t,t).sub(ot(n,n)))),r});class kw extends yr{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=pe(0).setGroup(_t),this.decayExponentNode=pe(0).setGroup(_t)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setup(e){const{colorNode:t,cutoffDistanceNode:n,decayExponentNode:i,light:r}=this,o=e.context.lightingModel,a=zd(r).sub(Pn),c=a.normalize(),l=a.length(),u=n0({lightDistance:l,cutoffDistance:n,decayExponent:i}),h=t.mul(u),d=e.context.reflectedLight;o.direct({lightDirection:c,lightColor:h,reflectedLight:d},e.stack,e)}}class Gw extends yr{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setup(e){super.setup(e);const t=e.context.lightingModel,n=this.colorNode,i=r0(this.light),r=e.context.reflectedLight;t.direct({lightDirection:i,lightColor:n,reflectedLight:r},e.stack,e)}}const nf=new Fe,Nu=new Fe;let Ya=null;class Hw extends yr{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=pe(new E).setGroup(_t),this.halfWidth=pe(new E).setGroup(_t)}update(e){super.update(e);const{light:t}=this,n=e.camera.matrixWorldInverse;Nu.identity(),nf.copy(t.matrixWorld),nf.premultiply(n),Nu.extractRotation(nf),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(Nu),this.halfHeight.value.applyMatrix4(Nu)}setup(e){super.setup(e);let t,n;e.isAvailable("float32Filterable")?(t=xt(Ya.LTC_FLOAT_1),n=xt(Ya.LTC_FLOAT_2)):(t=xt(Ya.LTC_HALF_1),n=xt(Ya.LTC_HALF_2));const{colorNode:i,light:r}=this,o=e.context.lightingModel,a=zd(r),c=e.context.reflectedLight;o.directRectArea({lightColor:i,lightPosition:a,halfWidth:this.halfWidth,halfHeight:this.halfHeight,reflectedLight:c,ltc_1:t,ltc_2:n},e.stack,e)}static setLTC(e){Ya=e}}class l0 extends yr{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=pe(0).setGroup(_t),this.penumbraCosNode=pe(0).setGroup(_t),this.cutoffDistanceNode=pe(0).setGroup(_t),this.decayExponentNode=pe(0).setGroup(_t)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e){const{coneCosNode:t,penumbraCosNode:n}=this;return ti(t,n,e)}setup(e){super.setup(e);const t=e.context.lightingModel,{colorNode:n,cutoffDistanceNode:i,decayExponentNode:r,light:o}=this,a=zd(o).sub(Pn),c=a.normalize(),l=c.dot(r0(o)),u=this.getSpotAttenuation(l),h=a.length(),d=n0({lightDistance:h,cutoffDistance:i,decayExponent:r}),p=n.mul(u).mul(d),f=e.context.reflectedLight;t.direct({lightDirection:c,lightColor:p,reflectedLight:f},e.stack,e)}}class Ww extends l0{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e){const t=this.light.iesMap;let n=null;if(t&&t.isTexture===!0){const i=e.acos().mul(1/Math.PI);n=xt(t,z(i,0),0).r}else n=super.getSpotAttenuation(e);return n}}class Xw extends yr{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class qw extends yr{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=s0(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=pe(new _e).setGroup(_t)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:n,lightDirectionNode:i}=this,o=di.dot(i).mul(.5).add(.5),a=it(n,t,o);e.context.irradiance.addAssign(a)}}class $w extends yr{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let n=0;n<9;n++)t.push(new E);this.lightProbe=ds(t)}update(e){const{light:t}=this;super.update(e);for(let n=0;n<9;n++)this.lightProbe.array[n].copy(t.sh.coefficients[n]).multiplyScalar(t.intensity)}setup(e){const t=zw(Ed,this.lightProbe);e.context.irradiance.addAssign(t)}}class lO{parseFunction(){console.warn("Abstract function.")}}class Yw{constructor(e,t,n="",i=""){this.type=e,this.inputs=t,this.name=n,this.precision=i}getCode(){console.warn("Abstract function.")}}Yw.isNodeFunction=!0;const uO=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,hO=/[a-z_0-9]+/ig,k_="#pragma main",dO=s=>{s=s.trim();const e=s.indexOf(k_),t=e!==-1?s.slice(e+k_.length):s,n=t.match(uO);if(n!==null&&n.length===5){const i=n[4],r=[];let o=null;for(;(o=hO.exec(i))!==null;)r.push(o);const a=[];let c=0;for(;c<r.length;){const f=r[c][0]==="const";f===!0&&c++;let x=r[c][0];x==="in"||x==="out"||x==="inout"?c++:x="";const m=r[c++][0];let g=Number.parseInt(r[c][0]);Number.isNaN(g)===!1?c++:g=null;const y=r[c++][0];a.push(new Kg(m,y,g,x,f))}const l=t.substring(n[0].length),u=n[3]!==void 0?n[3]:"",h=n[2],d=n[1]!==void 0?n[1]:"",p=e!==-1?s.slice(0,e):"";return{type:h,inputs:a,name:u,precision:d,inputsCode:i,blockCode:l,headerCode:p}}else throw new Error("FunctionNode: Function is not a GLSL code.")};class pO extends Yw{constructor(e){const{type:t,inputs:n,name:i,precision:r,inputsCode:o,blockCode:a,headerCode:c}=dO(e);super(t,n,i,r),this.inputsCode=o,this.blockCode=a,this.headerCode=c}getCode(e=this.name){let t;const n=this.blockCode;if(n!==""){const{type:i,inputsCode:r,headerCode:o,precision:a}=this;let c=`${i} ${e} ( ${r.trim()} )`;a!==""&&(c=`${a} ${c}`),t=o+c+n}else t="";return t}}class Zw extends lO{parseFunction(e){return new pO(e)}}class fO{constructor(){this.lightNodes=new WeakMap,this.materialNodes=new Map,this.toneMappingNodes=new Map,this.colorSpaceNodes=new Map}fromMaterial(e){if(e.isNodeMaterial)return e;let t=null;const n=this.getMaterialNodeClass(e.type);if(n!==null){t=new n;for(const i in e)t[i]=e[i]}return t}addColorSpace(e,t){this.addType(e,t,this.colorSpaceNodes)}getColorSpaceFunction(e){return this.colorSpaceNodes.get(e)||null}addToneMapping(e,t){this.addType(e,t,this.toneMappingNodes)}getToneMappingFunction(e){return this.toneMappingNodes.get(e)||null}getMaterialNodeClass(e){return this.materialNodes.get(e)||null}addMaterial(e,t){this.addType(e,t.name,this.materialNodes)}getLightNodeClass(e){return this.lightNodes.get(e)||null}addLight(e,t){this.addClass(e,t,this.lightNodes)}addType(e,t,n){if(n.has(t)){console.warn(`Redefinition of node ${t}`);return}if(typeof e!="function")throw new Error(`Node class ${e.name} is not a class.`);if(typeof t=="function"||typeof t=="object")throw new Error(`Base class ${t} is not a class.`);n.set(t,e)}addClass(e,t,n){if(n.has(t)){console.warn(`Redefinition of node ${t.name}`);return}if(typeof e!="function")throw new Error(`Node class ${e.name} is not a class.`);if(typeof t!="function")throw new Error(`Base class ${t.name} is not a class.`);n.set(t,e)}}class mO extends il{constructor(e,t,n,i,r,o){super(e,t,n,i,r,o),this.iesMap=null}copy(e,t){return super.copy(e,t),this.iesMap=e.iesMap,this}}class Jw extends fO{constructor(){super(),this.addLight(kw,_d),this.addLight(Gw,yd),this.addLight(Hw,Im),this.addLight(l0,il),this.addLight(Xw,vd),this.addLight(qw,xd),this.addLight($w,Pm),this.addLight(Ww,mO),this.addToneMapping(bw,Ah),this.addToneMapping(ww,Nh),this.addToneMapping(Aw,Bf),this.addToneMapping(Nw,Eh),this.addToneMapping(Ew,Ch),this.addToneMapping(Cw,Rh),this.addColorSpace(Tw,xh(li,kn)),this.addColorSpace(Sw,xh(kn,li))}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Ks}}));if(typeof window<"u"){try{typeof document>"u"?require("url").pathToFileURL(__filename).href:mo&&mo.tagName.toUpperCase()==="SCRIPT"&&mo.src||new URL("three-iFaDq9U3.umd.cjs",document.baseURI).href,window.__THREE__IMPORTS__||(window.__THREE__IMPORTS__=[]),window.__THREE__IMPORTS__.push({url:typeof document>"u"?require("url").pathToFileURL(__filename).href:mo&&mo.tagName.toUpperCase()==="SCRIPT"&&mo.src||new URL("three-iFaDq9U3.umd.cjs",document.baseURI).href,revision:Ks})}catch{}window.__THREE__?(console.warn("WARNING: Multiple instances of Three.js being imported. Existing: "+window.__THREE__+", new: "+Ks),console.warn(window.__THREE__IMPORTS__)):window.__THREE__=Ks}const gO=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:Eh,AONode:OT,AddEquation:Zs,AddOperation:Vf,AdditiveAnimationBlendMode:Yf,AdditiveBlending:cc,AfterImageNode:qb,AgXToneMapping:Ch,AlphaFormat:Gf,AlwaysCompare:Dy,AlwaysDepth:uc,AlwaysStencilFunc:ih,AmbientLight:vd,AmbientLightNode:Xw,AnaglyphPassNode:uw,AnalyticLightNode:yr,AnamorphicNode:Yb,AnimationAction:Tv,AnimationClip:la,AnimationLoader:FI,AnimationMixer:bv,AnimationObjectGroup:tP,AnimationUtils:PI,ArcCurve:tv,ArrayCamera:rm,ArrayElementNode:mr,ArrowHelper:mP,AssignNode:oM,AttachedBindMode:af,AttributeNode:Ag,Audio:Fm,AudioAnalyser:XI,AudioContext:Md,AudioListener:vv,AudioLoader:yv,AxesHelper:Fv,BRDF_GGX:Af,BRDF_Lambert:no,BackSide:ln,BasicDepthPacking:Zf,BasicEnvironmentNode:Dd,BasicNodeLibrary:Jw,BasicShadowMap:nA,BatchNode:CT,BatchedMesh:hm,BloomNode:sw,Bone:Kh,BooleanKeyframeTrack:pr,Box2:aP,Box3:Hn,Box3Helper:Uv,BoxGeometry:_s,BoxHelper:Dv,Break:Ld,BufferAttribute:At,BufferAttributeNode:fS,BufferGeometry:at,BufferGeometryLoader:gv,BufferNode:Rd,BumpMapNode:JS,BypassNode:yS,ByteType:zf,Cache:Rs,CacheNode:_S,Camera:Yc,CameraHelper:Lv,CanvasTexture:ev,CapsuleGeometry:Qh,CatmullRomCurve3:gm,CineonToneMapping:Bf,CircleGeometry:ed,ClampToEdgeWrapping:Si,Clock:Um,CodeNode:$g,Color:_e,ColorKeyframeTrack:md,ColorManagement:gt,ColorSpaceNode:hl,CompressedArrayTexture:jy,CompressedCubeTexture:Qy,CompressedTexture:Kc,CompressedTextureLoader:OI,ComputeNode:gS,ConeGeometry:td,ConstNode:Wi,ConstantAlphaFactor:oy,ConstantColorFactor:sy,ContextNode:vg,Continue:wL,Controls:Vv,ConvertNode:$m,CubeCamera:Xh,CubeReflectionMapping:wi,CubeRefractionMapping:Vi,CubeTexture:so,CubeTextureLoader:VI,CubeTextureNode:GS,CubeUVReflectionMapping:hr,CubicBezierCurve:xm,CubicBezierCurve3:nv,CubicInterpolant:uv,CullFaceBack:sf,CullFaceFront:X_,CullFaceFrontBack:tA,CullFaceNone:W_,Curve:Gi,CurvePath:sv,CustomBlending:Uf,CustomToneMapping:cy,CylinderGeometry:co,Cylindrical:oP,DFGApprox:Hg,D_GGX:eb,Data3DTexture:Hh,DataArrayTexture:qc,DataTexture:Oi,DataTextureLoader:pv,DataUtils:By,DecrementStencilOp:_y,DecrementWrapStencilOp:vy,DefaultLoadingManager:Cm,DenoiseNode:nw,DepthFormat:Qs,DepthOfFieldNode:Jb,DepthStencilFormat:ar,DepthTexture:ao,DetachedBindMode:ly,DirectionalLight:yd,DirectionalLightHelper:Pv,DirectionalLightNode:Gw,Discard:bS,DiscreteInterpolant:hv,DisplayP3ColorSpace:kh,DodecahedronGeometry:nd,DotScreenNode:Kb,DoubleSide:Ji,DstAlphaFactor:Q_,DstColorFactor:ty,DynamicCopyUsage:fA,DynamicDrawUsage:Gr,DynamicReadUsage:hA,EPSILON:AM,EdgesGeometry:Sm,EllipseCurve:jh,EnvironmentNode:hb,EqualCompare:Ry,EqualDepth:dc,EqualStencilFunc:by,EquirectUVNode:YT,EquirectangularReflectionMapping:ir,EquirectangularRefractionMapping:sr,Euler:ui,EventDispatcher:Ai,ExpressionNode:TS,ExtrudeGeometry:Qc,FXAANode:iw,F_Schlick:pa,FileLoader:ts,FilmNode:Qb,Float16BufferAttribute:zy,Float32BufferAttribute:Ve,FloatType:Gn,Fn:U,Fog:om,FogExp2:Zh,FogExp2Node:xw,FogNode:Bd,FogRangeNode:gw,FramebufferTexture:fm,FrontFacingNode:LS,FrontSide:fs,Frustum:ga,FunctionCallNode:cM,FunctionNode:Yg,FunctionOverloadingNode:Cb,GLBufferAttribute:rP,GLSL1:gA,GLSL3:sh,GLSLNodeParser:Zw,GTAONode:tw,GaussianBlurNode:Xb,GreaterCompare:Iy,GreaterDepth:fc,GreaterEqualCompare:Ly,GreaterEqualDepth:pc,GreaterEqualStencilFunc:Ey,GreaterStencilFunc:Ay,GridHelper:Iv,Group:Hr,HalfFloatType:Ln,HemisphereLight:xd,HemisphereLightHelper:dP,HemisphereLightNode:qw,IESSpotLightNode:Ww,INFINITY:zP,IcosahedronGeometry:sd,If:Oe,ImageBitmapLoader:_v,ImageLoader:Dc,ImageUtils:Oy,IncrementStencilOp:xy,IncrementWrapStencilOp:yy,IndexNode:zt,InstanceNode:NT,InstancedBufferAttribute:Us,InstancedBufferGeometry:Lm,InstancedInterleavedBuffer:Bm,InstancedMesh:um,InstancedPointsNodeMaterial:zL,Int16BufferAttribute:e1,Int32BufferAttribute:t1,Int8BufferAttribute:KA,IntType:ma,InterleavedBuffer:_a,InterleavedBufferAttribute:Ds,Interpolant:Sa,InterpolateDiscrete:ia,InterpolateLinear:bc,InterpolateSmooth:Eu,InvertStencilOp:My,IrradianceNode:zT,JoinNode:Gv,KeepStencilOp:$s,KeyframeTrack:Hi,LOD:cm,LatheGeometry:jc,Layers:$c,LessCompare:jf,LessDepth:hc,LessEqualCompare:Qf,LessEqualDepth:nr,LessEqualStencilFunc:wy,LessStencilFunc:Ty,Light:fr,LightProbe:Pm,LightProbeNode:$w,LightingContextNode:VT,LightingModel:Ml,LightingNode:ho,LightsNode:UT,Line:Fs,Line2NodeMaterial:qL,Line3:Cv,LineBasicMaterial:Fn,LineBasicNodeMaterial:GL,LineCurve:_m,LineCurve3:iv,LineDashedMaterial:fd,LineDashedNodeMaterial:WL,LineLoop:dm,LineSegments:rs,LinearDisplayP3ColorSpace:Xc,LinearFilter:Ut,LinearInterpolant:Em,LinearMipMapLinearFilter:uy,LinearMipMapNearestFilter:rA,LinearMipmapLinearFilter:Jn,LinearMipmapNearestFilter:js,LinearSRGBColorSpace:li,LinearToneMapping:Ah,LinearTransfer:Ac,Loader:Xn,LoaderUtils:lh,LoadingManager:gd,Loop:mt,LoopNode:PT,LoopOnce:qf,LoopPingPong:hy,LoopRepeat:$f,LuminanceAlphaFormat:Wf,LuminanceFormat:Hf,Lut3DNode:ew,MOUSE:G_,MRTNode:Eb,MatcapUVNode:fb,Material:mn,MaterialLoader:sl,MaterialNode:j,MaterialReferenceNode:HS,MathUtils:Gh,Matrix2:zm,Matrix3:Ke,Matrix4:Fe,MaxEquation:Ff,MaxMipLevelNode:ES,Mesh:kt,MeshBasicMaterial:ss,MeshBasicNodeMaterial:t2,MeshDepthMaterial:Yh,MeshDistanceMaterial:sm,MeshLambertMaterial:pd,MeshLambertNodeMaterial:o2,MeshMatcapMaterial:Am,MeshMatcapNodeMaterial:W2,MeshNormalMaterial:dd,MeshNormalNodeMaterial:ZL,MeshPhongMaterial:hd,MeshPhongNodeMaterial:c2,MeshPhysicalMaterial:ud,MeshPhysicalNodeMaterial:pb,MeshSSSNodeMaterial:V2,MeshStandardMaterial:nl,MeshStandardNodeMaterial:db,MeshToonMaterial:wm,MeshToonNodeMaterial:G2,MinEquation:Y_,MirroredRepeatWrapping:ea,MixOperation:Of,ModelNode:is,ModelViewProjectionNode:bT,MorphNode:LT,MultiplyBlending:of,MultiplyOperation:fa,NearestFilter:Qt,NearestMipMapLinearFilter:sA,NearestMipMapNearestFilter:iA,NearestMipmapLinearFilter:Cs,NearestMipmapNearestFilter:Ph,NeutralToneMapping:Rh,NeverCompare:Cy,NeverDepth:lc,NeverStencilFunc:Sy,NoBlending:Fi,NoColorSpace:Li,NoToneMapping:Ti,Node:Ye,NodeAttribute:If,NodeBuilder:Ab,NodeCache:Lu,NodeCode:Tb,NodeFrame:Nb,NodeFunctionInput:Kg,NodeLoader:yb,NodeMaterial:Tt,NodeMaterialLoader:vb,NodeMaterialObserver:Bv,NodeObjectLoader:e3,NodeShaderStage:mf,NodeType:yP,NodeUniform:Mb,NodeUpdateType:We,NodeUtils:_P,NodeVar:Xg,NodeVarying:Sb,NormalAnimationBlendMode:zh,NormalBlending:Ps,NormalMapNode:ZS,NotEqualCompare:Py,NotEqualDepth:mc,NotEqualStencilFunc:Ny,NumberKeyframeTrack:aa,Object3D:yt,Object3DNode:wt,ObjectLoader:xv,ObjectSpaceNormalMap:Kf,OctahedronGeometry:va,OneFactor:J_,OneMinusConstantAlphaFactor:ay,OneMinusConstantColorFactor:ry,OneMinusDstAlphaFactor:ey,OneMinusDstColorFactor:ny,OneMinusSrcAlphaFactor:Vu,OneMinusSrcColorFactor:j_,OrthographicCamera:oo,OscNode:pn,OutputStructNode:jg,P3Primaries:Ec,PCFShadowMap:Lf,PCFSoftShadowMap:Df,PI:to,PI2:kP,PMREMGenerator:rh,PMREMNode:lb,ParallaxBarrierPassNode:hw,ParameterNode:qg,PassNode:bn,Path:Rc,PerspectiveCamera:hn,PhongLightingModel:kg,PhysicalLightingModel:Fd,PixelationPassNode:ow,Plane:cs,PlaneGeometry:ro,PlaneHelper:fP,PointLight:_d,PointLightHelper:uP,PointLightNode:kw,PointUVNode:Vb,Points:pm,PointsMaterial:ya,PointsNodeMaterial:q2,PolarGridHelper:pP,PolyhedronGeometry:dr,PositionalAudio:Mv,PosterizeNode:Gb,PropertyBinding:St,PropertyMixer:Sv,PropertyNode:Nt,QuadraticBezierCurve:ym,QuadraticBezierCurve3:vm,Quaternion:Qn,QuaternionKeyframeTrack:Ta,QuaternionLinearInterpolant:dv,RED_GREEN_RGTC2_Format:th,RED_RGTC1_Format:Xf,REVISION:Ks,RGBADepthPacking:Jf,RGBAFormat:Rn,RGBAIntegerFormat:Bh,RGBA_ASTC_10x10_Format:Ju,RGBA_ASTC_10x5_Format:$u,RGBA_ASTC_10x6_Format:Yu,RGBA_ASTC_10x8_Format:Zu,RGBA_ASTC_12x10_Format:Ku,RGBA_ASTC_12x12_Format:ju,RGBA_ASTC_4x4_Format:Mc,RGBA_ASTC_5x4_Format:ku,RGBA_ASTC_5x5_Format:Gu,RGBA_ASTC_6x5_Format:Hu,RGBA_ASTC_6x6_Format:Sc,RGBA_ASTC_8x5_Format:Wu,RGBA_ASTC_8x6_Format:Xu,RGBA_ASTC_8x8_Format:qu,RGBA_BPTC_Format:Ko,RGBA_ETC2_EAC_Format:vc,RGBA_PVRTC_2BPPV1_Format:zu,RGBA_PVRTC_4BPPV1_Format:xc,RGBA_S3TC_DXT1_Format:Yo,RGBA_S3TC_DXT3_Format:Zo,RGBA_S3TC_DXT5_Format:Jo,RGBDepthPacking:aA,RGBFormat:Oh,RGBIntegerFormat:oA,RGBShiftNode:jb,RGB_BPTC_SIGNED_Format:Qu,RGB_BPTC_UNSIGNED_Format:Tc,RGB_ETC1_Format:_c,RGB_ETC2_Format:yc,RGB_PVRTC_2BPPV1_Format:Bu,RGB_PVRTC_4BPPV1_Format:gc,RGB_S3TC_DXT1_Format:$o,RGDepthPacking:cA,RGFormat:na,RGIntegerFormat:Vh,RTTNode:Ub,RangeNode:_w,RawShaderMaterial:bm,Ray:io,Raycaster:Nv,Rec709Primaries:Nc,RectAreaLight:Im,RectAreaLightNode:Hw,RedFormat:Hc,RedIntegerFormat:Wc,ReferenceNode:ml,ReflectorNode:Db,ReinhardToneMapping:Nh,RemapNode:wg,RenderOutputNode:wS,RenderTarget:fn,RendererReferenceNode:lS,RepeatWrapping:rr,ReplaceStencilOp:gy,Return:qP,ReverseSubtractEquation:$_,RingGeometry:el,RotateNode:gb,SIGNED_RED_GREEN_RGTC2_Format:nh,SIGNED_RED_RGTC1_Format:eh,SRGBColorSpace:kn,SRGBTransfer:Vt,SSAAPassNode:aw,Scene:Jh,SceneNode:Qi,Schlick_to_F0:nb,ScreenNode:sn,ScriptableNode:mw,ScriptableValueNode:pw,SetNode:Hv,ShaderChunk:lt,ShaderLib:Pi,ShaderMaterial:ki,ShaderNode:ec,ShadowMaterial:ld,ShadowNodeMaterial:K2,Shape:er,ShapeGeometry:rd,ShapePath:Ov,ShapeUtils:ji,ShortType:kf,Skeleton:Jc,SkeletonHelper:lP,SkinnedMesh:lm,SkinningNode:Fg,SobelOperatorNode:Zb,Source:Js,Sphere:Dn,SphereGeometry:Ma,Spherical:Ev,SphericalHarmonics3:mv,SplineCurve:Mm,SplitNode:uh,SpotLight:il,SpotLightHelper:cP,SpotLightNode:l0,Sprite:am,SpriteMaterial:Zc,SpriteNodeMaterial:Y2,SpriteSheetUVNode:Rb,SrcAlphaFactor:Ou,SrcAlphaSaturateFactor:iy,SrcColorFactor:K_,StackNode:wb,StaticCopyUsage:pA,StaticDrawUsage:sa,StaticReadUsage:uA,StereoCamera:Dm,StereoPassNode:cw,StorageArrayElementNode:Ib,StorageBufferNode:t0,StorageTextureNode:Bb,StreamCopyUsage:mA,StreamDrawUsage:lA,StreamReadUsage:dA,StringKeyframeTrack:lo,SubtractEquation:q_,SubtractiveBlending:rf,TBNViewMatrix:qr,TOUCH:H_,TangentSpaceNormalMap:ms,TempNode:pt,TetrahedronGeometry:od,Texture:Xt,Texture3DNode:xb,TextureLoader:fv,TextureNode:gs,TextureSizeNode:NS,TextureUtils:OR,TimerNode:Sn,ToneMappingNode:hS,ToonOutlinePassNode:dw,TorusGeometry:tl,TorusKnotGeometry:ad,TransitionNode:rw,Triangle:Zn,TriangleFanDrawMode:fy,TriangleStripDrawMode:py,TrianglesDrawMode:dy,TriplanarTexturesNode:Pb,TubeGeometry:cd,UVMapping:Ih,Uint16BufferAttribute:Wh,Uint32BufferAttribute:tm,Uint8BufferAttribute:jA,Uint8ClampedBufferAttribute:QA,Uniform:wv,UniformArrayNode:Ig,UniformGroupNode:eg,UniformNode:uo,UniformsGroup:sP,UniformsLib:Se,UniformsUtils:nm,UnsignedByteType:es,UnsignedInt101111Type:Fh,UnsignedInt248Type:or,UnsignedInt5999Type:Uh,UnsignedIntType:Bi,UnsignedShort4444Type:Lh,UnsignedShort5551Type:Dh,UnsignedShortType:ta,UserDataNode:kb,VSMShadowMap:oi,V_GGX_SmithCorrelated:QT,VarNode:iS,VaryingNode:sS,Vector2:J,Vector3:E,Vector4:st,VectorKeyframeTrack:ca,VertexColorNode:Ob,VideoTexture:Ky,ViewportDepthNode:jn,ViewportDepthTextureNode:WT,ViewportSharedTextureNode:Hb,ViewportTextureNode:vl,VolumeNodeMaterial:Q2,WebGL3DRenderTarget:kA,WebGLArrayRenderTarget:zA,WebGLCoordinateSystem:Di,WebGLCubeRenderTarget:qh,WebGLMultipleRenderTargets:gP,WebGLRenderTarget:zi,WebGLRenderer:Yy,WebGLUtils:$y,WebGPUCoordinateSystem:Qr,WireframeGeometry:Tm,WrapAroundEnding:wc,ZeroCurvatureEnding:zr,ZeroFactor:Z_,ZeroSlopeEnding:kr,ZeroStencilOp:my,abs:Dt,acesFilmicToneMapping:Nw,acos:gh,add:Wt,addMethodChaining:te,addNodeElement:$P,afterImage:lD,agxToneMapping:Ew,all:hg,alphaT:dh,anaglyphPass:XD,anamorphic:mD,and:mM,anisotropy:Ys,anisotropyB:Jr,anisotropyT:tc,any:NM,ao:wD,append:Yv,arrayBuffer:FP,asin:LM,assign:aM,atan:DM,atan2:HM,atomicAdd:HU,atomicAnd:$U,atomicFunc:Os,atomicMax:XU,atomicMin:qU,atomicOr:YU,atomicStore:GU,atomicSub:WU,atomicXor:ZU,attenuationColor:ag,attenuationDistance:og,attribute:vn,backgroundBlurriness:K3,backgroundIntensity:j3,batch:RT,billboarding:fU,bitAnd:yM,bitNot:vM,bitOr:MM,bitXor:SM,bitangentGeometry:pL,bitangentLocal:fL,bitangentView:XS,bitangentWorld:mL,bitcast:GP,bleach:TU,bloom:DD,blur:cb,bool:cr,buffer:fl,bufferAttribute:dl,bumpMap:KS,burn:_U,bvec2:Kv,bvec3:Qm,bvec4:tM,bypass:vS,cache:ic,call:lM,cameraFar:Bo,cameraLogDepth:RS,cameraNear:Vo,cameraNormalMatrix:KP,cameraPosition:Ng,cameraProjectionMatrix:ci,cameraProjectionMatrixInverse:ZP,cameraViewMatrix:pi,cameraWorldMatrix:JP,cbrt:JM,ceil:fg,checker:JU,cineonToneMapping:Aw,clamp:cn,clearcoat:hh,clearcoatRoughness:zc,code:Od,color:Zv,colorSpaceToWorking:bg,colorToDirection:$L,compute:xS,cond:tS,context:Mg,convert:iM,convertToTexture:ei,cos:Mi,createCanvasElement:Fy,cross:Qo,cubeTexture:Cd,dFdx:OM,dFdy:VM,dashSize:Kr,defaultBuildStages:gf,defaultShaderStages:qm,defined:Oc,degrees:RM,denoise:ED,densityFog:jD,depth:Bg,depthPass:aD,difference:qM,diffuseColor:Ct,directionToColor:$T,dispersion:cg,distance:XM,div:ns,dodge:yU,dof:xD,dot:$t,dotScreen:_D,drawIndex:AT,dynamicBufferAttribute:mS,element:nM,emissive:yf,equal:uM,equals:EM,equirectUV:zg,exp:dg,exp2:mh,expression:lr,faceDirection:pl,faceForward:jM,film:vD,float:A,floor:gr,fog:JD,fract:xr,frameGroup:VP,frameId:F3,frontFacing:DS,fwidth:kM,fxaa:CD,gain:cU,gapSize:Gc,gaussianBlur:cD,getColorSpaceMethod:xh,getConstNodeType:$v,getCurrentStack:jm,getDirection:ob,getDistanceAttenuation:n0,getGeometryRoughness:jT,getRoughness:Gg,getShIrradianceAt:zw,getTextureIndex:Qg,global:Fu,glsl:r3,glslFn:o3,grayscale:uD,greaterThan:ug,greaterThanEqual:fM,hash:aU,highPrecisionModelNormalViewMatrix:cL,highPrecisionModelViewMatrix:aL,hue:pD,instance:ET,instanceIndex:yl,instancedBufferAttribute:_h,instancedDynamicBufferAttribute:vf,int:L,inverseSqrt:IM,invocationLocalIndex:TL,invocationSubgroupIndex:SL,ior:nc,iridescence:wd,iridescenceIOR:ng,iridescenceThickness:ig,ivec2:ls,ivec3:jv,ivec4:Qv,js:i3,label:nS,length:jr,lengthSq:xg,lessThan:dM,lessThanEqual:pM,lightPosition:s0,lightTargetDirection:r0,lightTargetPosition:yw,lightViewPosition:zd,lightingContext:BT,lights:FT,linearDepth:Sh,linearSRGBTosRGB:Tw,linearToneMapping:bw,localId:PU,log:pg,log2:al,loop:AL,luminance:En,lut3D:MD,mat2:ol,mat3:Tn,mat4:Zr,matcapUV:mb,materialAOMap:TT,materialAlphaTest:jS,materialAnisotropy:dT,materialAnisotropyVector:zo,materialAttenuationColor:vT,materialAttenuationDistance:yT,materialClearcoat:oT,materialClearcoatNormal:cT,materialClearcoatRoughness:aT,materialColor:ha,materialDispersion:ST,materialEmissive:eT,materialIOR:_T,materialIridescence:pT,materialIridescenceIOR:fT,materialIridescenceThickness:mT,materialLightMap:Ug,materialLineDashOffset:bf,materialLineDashSize:Lg,materialLineGapSize:Dg,materialLineScale:Mh,materialLineWidth:Pu,materialMetalness:sT,materialNormal:rT,materialOpacity:Pd,materialPointWidth:MT,materialReference:Ki,materialReflectivity:Iu,materialRefractionRatio:OS,materialRotation:lT,materialRoughness:iT,materialSheen:uT,materialSheenRoughness:hT,materialShininess:QS,materialSpecular:tT,materialSpecularColor:nT,materialSpecularIntensity:Tf,materialSpecularStrength:sc,materialThickness:xT,materialTransmission:gT,max:ft,maxMipLevel:CS,metalness:Bc,min:Mn,mix:it,mixElement:QM,mod:Ad,modInt:lg,modelDirection:iL,modelNormalMatrix:IS,modelPosition:sL,modelScale:rL,modelViewMatrix:xs,modelViewPosition:oL,modelViewProjection:wf,modelWorldMatrix:Ui,modelWorldMatrixInverse:PS,morphReference:DT,motionBlur:SU,mrt:Vd,mul:ot,mx_aastep:Ow,mx_cell_noise_float:sO,mx_contrast:KF,mx_fractal_noise_float:rO,mx_fractal_noise_vec2:oO,mx_fractal_noise_vec3:aO,mx_fractal_noise_vec4:cO,mx_hsvtorgb:GF,mx_noise_float:jF,mx_noise_vec3:QF,mx_noise_vec4:eO,mx_ramplr:XF,mx_ramptb:qF,mx_rgbtohsv:HF,mx_safepower:JF,mx_splitlr:$F,mx_splittb:YF,mx_srgb_texture_to_lin_rec709:WF,mx_transform_uv:ZF,mx_worley_noise_float:tO,mx_worley_noise_vec2:nO,mx_worley_noise_vec3:iO,negate:UM,neutralToneMapping:Cw,nodeArray:Yr,nodeImmutable:fe,nodeObject:H,nodeObjects:rl,nodeProxy:K,normalFlat:US,normalGeometry:Nd,normalLocal:hi,normalMap:Sf,normalView:di,normalWorld:Ed,normalize:vi,not:xM,notEqual:hM,numWorkgroups:RU,objectDirection:jP,objectGroup:rM,objectPosition:eL,objectScale:tL,objectViewPosition:nL,objectWorldMatrix:QP,oneMinus:FM,or:gM,orthographicDepthToViewZ:UL,oscSawtooth:z3,oscSine:O3,oscSquare:V3,oscTriangle:B3,output:sg,outputStruct:P3,overlay:MU,overloadingFn:On,parabola:Pf,parallaxBarrierPass:qD,parallaxDirection:$S,parallaxUV:xL,parameter:n3,pass:oD,passTexture:Na,pcurve:lU,perspectiveDepthToViewZ:Vg,pixelationPass:VD,pmremTexture:ub,pointUV:J3,pointWidth:BP,positionGeometry:Nn,positionLocal:en,positionPrevious:yh,positionView:Pn,positionViewDirection:Bt,positionWorld:vh,positionWorldDirection:Eg,posterize:iD,pow:Kn,pow2:gg,pow3:$M,pow4:YM,property:ai,radians:CM,rand:yg,range:QD,rangeFog:KD,reciprocal:zM,reference:dn,referenceBuffer:Mf,reflect:WM,reflectVector:zS,reflectView:VS,reflector:X3,refract:_g,refractVector:kS,refractView:BS,reinhardToneMapping:ww,remainder:wM,remap:MS,remapClamp:SS,renderGroup:_t,renderOutput:AS,rendererReference:uS,rgbShift:yD,rotate:Wg,rotateUV:dU,roughness:hs,round:BM,rtt:Fb,sRGBToLinearSRGB:Sw,sampler:YP,saturate:KM,saturation:hD,screen:vU,screenCoordinate:Aa,screenSize:da,screenUV:_r,scriptable:ZD,scriptableValue:Uu,select:In,sepia:bU,setCurrentStack:Vc,shaderStages:xf,sharedUniformGroup:tg,sheen:Xr,sheenRoughness:bd,shiftLeft:TM,shiftRight:bM,shininess:ph,sign:cl,sin:Cn,sinc:uU,skinning:bL,skinningReference:IT,smoothstep:ti,smoothstepElement:eS,sobel:gD,specularColor:ri,specularF90:kc,spherizeUV:pU,split:OP,spritesheetUV:k3,sqrt:os,ssaaPass:kD,stack:Du,step:ll,stereoPass:HD,storage:Q3,storageBarrier:FU,storageObject:eD,storageTexture:zb,string:UP,sub:Ft,subgroupIndex:ML,subgroupSize:LU,tan:PM,tangentGeometry:Id,tangentLocal:gl,tangentView:xl,tangentWorld:WS,temp:Sg,texture:xt,texture3D:_b,textureBarrier:OU,textureBicubic:rb,textureCubeUV:ab,textureLoad:Ci,textureSize:tr,textureStore:tD,thickness:rg,threshold:$b,timerDelta:U3,timerGlobal:D3,timerLocal:e0,toOutputColorSpace:rS,toWorkingColorSpace:oS,toneMapping:dS,toneMappingExposure:pS,toonOutlinePass:$D,transformDirection:ZM,transformNormal:FS,transformNormalToView:Rg,transformedBentNormalView:YS,transformedBitangentView:qS,transformedBitangentWorld:gL,transformedClearcoatNormalView:Xo,transformedNormalView:Yt,transformedNormalWorld:Cg,transformedTangentView:Pg,transformedTangentWorld:dL,transition:UD,transmission:fh,transpose:GM,tri:us,tri3:vw,triNoise3D:hU,triplanarTexture:H3,triplanarTextures:Lb,trunc:mg,tslFn:DP,uint:ve,uniform:pe,uniformArray:ds,uniformGroup:sM,uniforms:uL,userData:nD,uv:rt,uvec2:Jv,uvec3:wa,uvec4:eM,varying:Un,varyingProperty:Zi,vec2:z,vec3:D,vec4:oe,vectorComponents:ba,velocity:xU,vertexColor:Z3,vertexIndex:wT,vibrance:dD,viewZToOrthographicDepth:rc,viewZToPerspectiveDepth:XT,viewport:Ls,viewportBottomLeft:LL,viewportCoordinate:GT,viewportDepthTexture:Og,viewportLinearDepth:FL,viewportMipTexture:HT,viewportResolution:IL,viewportSafeUV:mU,viewportSharedTexture:sD,viewportSize:kT,viewportTexture:DL,viewportTopLeft:PL,viewportUV:RL,wgsl:s3,wgslFn:a3,workgroupArray:zU,workgroupBarrier:UU,workgroupId:IU,workingToColorSpace:aS,xor:_M},Symbol.toStringTag,{value:"Module"}));exports.ACESFilmicToneMapping=Eh;exports.AdditiveBlending=cc;exports.AgXToneMapping=Ch;exports.AlwaysDepth=uc;exports.AlwaysStencilFunc=ih;exports.AmbientLight=vd;exports.AnimationClip=la;exports.AnimationMixer=bv;exports.ArrayCamera=rm;exports.Audio=Fm;exports.AudioContext=Md;exports.AudioListener=vv;exports.AudioLoader=yv;exports.AxesHelper=Fv;exports.BackSide=ln;exports.BasicDepthPacking=Zf;exports.BasicNodeLibrary=Jw;exports.BatchedMesh=hm;exports.Bone=Kh;exports.BooleanKeyframeTrack=pr;exports.Box3=Hn;exports.Box3Helper=Uv;exports.BoxGeometry=_s;exports.BoxHelper=Dv;exports.BufferAttribute=At;exports.BufferGeometry=at;exports.Camera=Yc;exports.CameraHelper=Lv;exports.CanvasTexture=ev;exports.CatmullRomCurve3=gm;exports.ClampToEdgeWrapping=Si;exports.Clock=Um;exports.Color=_e;exports.ColorKeyframeTrack=md;exports.ColorManagement=gt;exports.CompressedArrayTexture=jy;exports.CompressedCubeTexture=Qy;exports.CompressedTexture=Kc;exports.Controls=Vv;exports.CubeCamera=Xh;exports.CubeTexture=so;exports.CubeUVReflectionMapping=hr;exports.Curve=Gi;exports.CustomBlending=Uf;exports.CylinderGeometry=co;exports.Data3DTexture=Hh;exports.DataTexture=Oi;exports.DataTextureLoader=pv;exports.DataUtils=By;exports.DecrementStencilOp=_y;exports.DecrementWrapStencilOp=vy;exports.DefaultLoadingManager=Cm;exports.DepthFormat=Qs;exports.DepthStencilFormat=ar;exports.DepthTexture=ao;exports.DirectionalLight=yd;exports.DirectionalLightHelper=Pv;exports.DoubleSide=Ji;exports.DynamicDrawUsage=Gr;exports.EdgesGeometry=Sm;exports.EqualDepth=dc;exports.EqualStencilFunc=by;exports.EquirectangularReflectionMapping=ir;exports.EquirectangularRefractionMapping=sr;exports.Euler=ui;exports.EventDispatcher=Ai;exports.ExtrudeGeometry=Qc;exports.FileLoader=ts;exports.Float32BufferAttribute=Ve;exports.FloatType=Gn;exports.Fog=om;exports.FrontSide=fs;exports.Frustum=ga;exports.GLSL3=sh;exports.GLSLNodeParser=Zw;exports.GreaterDepth=fc;exports.GreaterEqualDepth=pc;exports.GreaterEqualStencilFunc=Ey;exports.GreaterStencilFunc=Ay;exports.GridHelper=Iv;exports.Group=Hr;exports.HalfFloatType=Ln;exports.HemisphereLight=xd;exports.ImageBitmapLoader=_v;exports.IncrementStencilOp=xy;exports.IncrementWrapStencilOp=yy;exports.InstancedBufferAttribute=Us;exports.InstancedBufferGeometry=Lm;exports.InstancedInterleavedBuffer=Bm;exports.InstancedMesh=um;exports.InterleavedBuffer=_a;exports.InterleavedBufferAttribute=Ds;exports.Interpolant=Sa;exports.InterpolateDiscrete=ia;exports.InterpolateLinear=bc;exports.InvertStencilOp=My;exports.KeepStencilOp=$s;exports.KeyframeTrack=Hi;exports.LOD=cm;exports.Layers=$c;exports.LessDepth=hc;exports.LessEqualDepth=nr;exports.LessEqualStencilFunc=wy;exports.LessStencilFunc=Ty;exports.Line=Fs;exports.Line3=Cv;exports.LineBasicMaterial=Fn;exports.LineLoop=dm;exports.LineSegments=rs;exports.LinearFilter=Ut;exports.LinearMipmapLinearFilter=Jn;exports.LinearMipmapNearestFilter=js;exports.LinearSRGBColorSpace=li;exports.LinearToneMapping=Ah;exports.Loader=Xn;exports.LoaderUtils=lh;exports.LoadingManager=gd;exports.LoopOnce=qf;exports.LoopRepeat=$f;exports.MOUSE=G_;exports.Material=mn;exports.MathUtils=Gh;exports.Matrix3=Ke;exports.Matrix4=Fe;exports.MaxEquation=Ff;exports.Mesh=kt;exports.MeshBasicMaterial=ss;exports.MeshDepthMaterial=Yh;exports.MeshLambertMaterial=pd;exports.MeshNormalMaterial=dd;exports.MeshPhongMaterial=hd;exports.MeshPhysicalMaterial=ud;exports.MeshStandardMaterial=nl;exports.MirroredRepeatWrapping=ea;exports.NearestFilter=Qt;exports.NearestMipmapLinearFilter=Cs;exports.NearestMipmapNearestFilter=Ph;exports.NeutralToneMapping=Rh;exports.NeverDepth=lc;exports.NeverStencilFunc=Sy;exports.NoBlending=Fi;exports.NoColorSpace=Li;exports.NoToneMapping=Ti;exports.Node=Ye;exports.NodeBuilder=Ab;exports.NodeFrame=Nb;exports.NormalBlending=Ps;exports.NotEqualDepth=mc;exports.NotEqualStencilFunc=Ny;exports.NumberKeyframeTrack=aa;exports.Object3D=yt;exports.OctahedronGeometry=va;exports.OrthographicCamera=oo;exports.PCFSoftShadowMap$1=Df;exports.PMREMGenerator$1=rh;exports.PerspectiveCamera=hn;exports.Plane=cs;exports.PlaneGeometry=ro;exports.PointLight=_d;exports.Points=pm;exports.PointsMaterial=ya;exports.PositionalAudio=Mv;exports.PropertyBinding=St;exports.Quaternion=Qn;exports.QuaternionKeyframeTrack=Ta;exports.REVISION=Ks;exports.RGBADepthPacking=Jf;exports.RGBAFormat=Rn;exports.RGBA_ASTC_4x4_Format=Mc;exports.RGBA_ASTC_6x6_Format=Sc;exports.RGBA_BPTC_Format=Ko;exports.RGBA_ETC2_EAC_Format=vc;exports.RGBA_PVRTC_4BPPV1_Format=xc;exports.RGBA_S3TC_DXT1_Format=Yo;exports.RGBA_S3TC_DXT3_Format=Zo;exports.RGBA_S3TC_DXT5_Format=Jo;exports.RGBFormat=Oh;exports.RGB_BPTC_UNSIGNED_Format=Tc;exports.RGB_ETC1_Format=_c;exports.RGB_ETC2_Format=yc;exports.RGB_PVRTC_4BPPV1_Format=gc;exports.RGB_S3TC_DXT1_Format=$o;exports.RGFormat=na;exports.RawShaderMaterial=bm;exports.Ray=io;exports.Raycaster=Nv;exports.RedFormat=Hc;exports.ReinhardToneMapping=Nh;exports.RepeatWrapping=rr;exports.ReplaceStencilOp=gy;exports.RingGeometry=el;exports.SRGBColorSpace=kn;exports.Scene=Jh;exports.ShaderChunk=lt;exports.ShaderLib=Pi;exports.ShaderMaterial=ki;exports.ShadowMaterial=ld;exports.Shape=er;exports.ShapePath=Ov;exports.ShapeUtils=ji;exports.Skeleton=Jc;exports.SkinnedMesh=lm;exports.Source=Js;exports.Sphere=Dn;exports.SphereGeometry=Ma;exports.Spherical=Ev;exports.SpotLight=il;exports.Sprite=am;exports.SpriteMaterial=Zc;exports.THREE=gO;exports.TOUCH=H_;exports.Texture=Xt;exports.TextureLoader=fv;exports.TorusGeometry=tl;exports.Triangle=Zn;exports.TriangleFanDrawMode=fy;exports.TriangleStripDrawMode=py;exports.TrianglesDrawMode=dy;exports.Uint16BufferAttribute=Wh;exports.Uniform$1=wv;exports.UniformsLib=Se;exports.UniformsUtils=nm;exports.UnsignedByteType=es;exports.UnsignedInt101111Type=Fh;exports.UnsignedInt248Type=or;exports.UnsignedInt5999Type=Uh;exports.UnsignedIntType=Bi;exports.Vector2=J;exports.Vector3=E;exports.Vector4=st;exports.VectorKeyframeTrack=ca;exports.VideoTexture=Ky;exports.WebGLCubeRenderTarget=qh;exports.WebGLRenderTarget=zi;exports.WebGLRenderer=Yy;exports.WireframeGeometry=Tm;exports.ZeroStencilOp=my;exports.defaultShaderStages=qm;exports.normalView=di;