chatlab-cli 0.32.0 → 0.34.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 (158) hide show
  1. package/README.md +2 -1
  2. package/dist/{chat-command-3KUWKS53.mjs → chat-command-XPY3WURC.mjs} +9 -9
  3. package/dist/{chunk-LNU4RW5G.mjs → chunk-AQPDZAWB.mjs} +1604 -1327
  4. package/dist/chunk-AQPDZAWB.mjs.map +1 -0
  5. package/dist/{chunk-UVCH2ICD.mjs → chunk-BQ3QN4QT.mjs} +3 -3
  6. package/dist/{chunk-DV4U34MR.mjs → chunk-DGF3S3TZ.mjs} +2 -2
  7. package/dist/{chunk-3J7WTUEE.mjs → chunk-IGEHMLHM.mjs} +2 -2
  8. package/dist/{chunk-CANPJOIE.mjs → chunk-IGK6UMN2.mjs} +112 -16
  9. package/dist/chunk-IGK6UMN2.mjs.map +1 -0
  10. package/dist/{chunk-BLOBEOCG.mjs → chunk-ISRLGLUL.mjs} +2 -2
  11. package/dist/{chunk-27DWKA3L.mjs → chunk-JCSPDTZL.mjs} +15 -62
  12. package/dist/chunk-JCSPDTZL.mjs.map +1 -0
  13. package/dist/{chunk-23AIEWCD.mjs → chunk-JTOHAMIW.mjs} +2 -2
  14. package/dist/{chunk-YVNZ73O5.mjs → chunk-OLE2USEN.mjs} +4492 -4038
  15. package/dist/chunk-OLE2USEN.mjs.map +1 -0
  16. package/dist/{chunk-YAQLYL52.mjs → chunk-QZCNVAH6.mjs} +2 -2
  17. package/dist/{chunk-YAQLYL52.mjs.map → chunk-QZCNVAH6.mjs.map} +1 -1
  18. package/dist/{chunk-3IGBPOJM.mjs → chunk-S5NCEESV.mjs} +5 -4
  19. package/dist/chunk-S5NCEESV.mjs.map +1 -0
  20. package/dist/{chunk-PZM3FHVZ.mjs → chunk-UO2XVFY6.mjs} +37 -26
  21. package/dist/chunk-UO2XVFY6.mjs.map +1 -0
  22. package/dist/cli.mjs +9 -9
  23. package/dist/contacts-worker.mjs +2 -2
  24. package/dist/global-insight-worker.mjs +2 -2
  25. package/dist/{http-YR26GF7X.mjs → http-HV6XWU6X.mjs} +12 -12
  26. package/dist/{import-Q3DUACU4.mjs → import-DP2XLZ2H.mjs} +8 -8
  27. package/dist/index.mjs +12 -12
  28. package/dist/{mcp-HTVZSGTI.mjs → mcp-QDPFBPGW.mjs} +9 -9
  29. package/dist/people-relationships-worker.mjs +2 -2
  30. package/dist/semantic-index-worker.mjs +1 -1
  31. package/dist/{src-HJL7YZZJ.mjs → src-B3A2QHP5.mjs} +12 -10
  32. package/dist/{stream-import-MXETSEPW.mjs → stream-import-KEGNP3QK.mjs} +8 -8
  33. package/dist/{worker-runtime-DZQDL2E2.mjs → worker-runtime-MDYKX3BW.mjs} +6 -6
  34. package/dist-cli-web/assets/ActionToolsPanel.vue_vue_type_script_setup_true_lang-JxPR2O6b.js +110 -0
  35. package/{dist-web/assets/BufferResource-BXfwfGam.js → dist-cli-web/assets/BufferResource--dSbJb0k.js} +1 -1
  36. package/dist-cli-web/assets/CanvasRenderer-Cm_dmJXZ.js +1 -0
  37. package/dist-cli-web/assets/DataDirCleanupNotice-B0s5txX3.js +1 -0
  38. package/dist-cli-web/assets/EChartWordcloud-CwMVJLBO.js +1 -0
  39. package/{dist-web/assets/Filter-Irxx0f6j.js → dist-cli-web/assets/Filter-BjYScRpK.js} +1 -1
  40. package/dist-cli-web/assets/LoadingState.vue_vue_type_script_setup_true_lang-BshQybD_.js +1 -0
  41. package/dist-cli-web/assets/MessageExportModal-DAJW2mFj.js +1 -0
  42. package/dist-cli-web/assets/PageHeader-BKAjCuqs.js +1 -0
  43. package/{dist-web/assets/RelationshipGalaxyCanvas-ByDU6ZS_.js → dist-cli-web/assets/RelationshipGalaxyCanvas-mlZs7k4L.js} +14 -14
  44. package/{dist-web/assets/RelationshipGalaxyThreeCanvas-BluPHjCR.css → dist-cli-web/assets/RelationshipGalaxyThreeCanvas-CeYJABxI.css} +1 -1
  45. package/{dist-web/assets/RelationshipGalaxyThreeCanvas-DgAlyKjc.js → dist-cli-web/assets/RelationshipGalaxyThreeCanvas-DgMG3jdU.js} +14 -14
  46. package/{dist-web/assets/RenderTargetSystem-Cx5U5HAM.js → dist-cli-web/assets/RenderTargetSystem-D00Ex44y.js} +1 -1
  47. package/dist-cli-web/assets/ThemeCard.vue_vue_type_script_setup_true_lang-Dsb6lzs-.js +1 -0
  48. package/dist-cli-web/assets/TimeSelect.vue_vue_type_script_setup_true_lang-BfR3tlkz.js +1 -0
  49. package/{dist-web/assets/WebGLRenderer-B3Fnp1WX.js → dist-cli-web/assets/WebGLRenderer-CTTusm2n.js} +2 -2
  50. package/{dist-web/assets/WebGPURenderer-DZ0X9N86.js → dist-cli-web/assets/WebGPURenderer-pyv3EXor.js} +2 -2
  51. package/dist-cli-web/assets/annual-summary-time-range-C_d1oZrj.js +1 -0
  52. package/dist-cli-web/assets/base-D91aVUwM.js +1 -0
  53. package/{dist-web/assets/browserAll-BqC9ELNO.js → dist-cli-web/assets/browserAll-C9fW936Y.js} +1 -1
  54. package/dist-cli-web/assets/cli-web-C7uGKz_E.js +1 -0
  55. package/{dist-web/assets/dateFormat-CX9atL2g.js → dist-cli-web/assets/dateFormat-rY43adcv.js} +1 -1
  56. package/{dist-web/assets/fetch-CUT9JdXT.js → dist-cli-web/assets/fetch-C6po4XYB.js} +3 -3
  57. package/dist-cli-web/assets/fetch-CNy9OQ2g.js +1 -0
  58. package/dist-cli-web/assets/fetch-CS3T-v-1.js +1 -0
  59. package/{dist-web/assets/fetch-C3KuMfIU.js → dist-cli-web/assets/fetch-CbnX5VoM.js} +3 -3
  60. package/dist-cli-web/assets/fetch-CrSz5KJy.js +1 -0
  61. package/dist-cli-web/assets/fetch-DG3AeEjW.js +1 -0
  62. package/dist-cli-web/assets/fetch-DYNgtIcU.js +1 -0
  63. package/{dist-web/assets/fetch-th_egarZ.js → dist-cli-web/assets/fetch-DZPC3D8R.js} +2 -2
  64. package/dist-cli-web/assets/fetch-Kk2knkEo.js +1 -0
  65. package/dist-cli-web/assets/fetch-PLrI3V67.js +1 -0
  66. package/dist-cli-web/assets/index-2-OaYdzt.js +1 -0
  67. package/dist-cli-web/assets/index-2S80bo1s.js +2 -0
  68. package/dist-cli-web/assets/index-3YO6RI5e.js +2 -0
  69. package/dist-cli-web/assets/index-BKo68Iu5.js +1 -0
  70. package/{dist-web/assets/index-Bm_U0hSr.js → dist-cli-web/assets/index-BrkDgcJ6.js} +4 -4
  71. package/dist-cli-web/assets/index-CGI3Y8pq.js +1 -0
  72. package/dist-cli-web/assets/index-CW9H_fBd.js +53 -0
  73. package/dist-cli-web/assets/index-DA3Q0TGT.js +1 -0
  74. package/dist-cli-web/assets/index-DFHYr_-u.js +1 -0
  75. package/dist-cli-web/assets/index-DmrrdYXH.css +1 -0
  76. package/dist-cli-web/assets/index-DmwA85vG.js +173 -0
  77. package/dist-cli-web/assets/index-DrjoMv9s.css +1 -0
  78. package/dist-cli-web/assets/index-DsdMsKYT.js +1 -0
  79. package/dist-cli-web/assets/index-JYfjMRb-.js +1 -0
  80. package/dist-cli-web/assets/index-Jhwca9kg.css +1 -0
  81. package/dist-cli-web/assets/index-ZTgfCZvY.js +64 -0
  82. package/dist-cli-web/assets/index-vtF05fh7.css +1 -0
  83. package/dist-cli-web/assets/people-page-header-D-LWaEqn.js +1 -0
  84. package/{dist-web/assets/webworkerAll-a_fveCLR.js → dist-cli-web/assets/webworkerAll-CPOVECup.js} +1 -1
  85. package/{dist-web → dist-cli-web}/index.html +2 -4
  86. package/package.json +4 -4
  87. package/dist/chunk-27DWKA3L.mjs.map +0 -1
  88. package/dist/chunk-3IGBPOJM.mjs.map +0 -1
  89. package/dist/chunk-CANPJOIE.mjs.map +0 -1
  90. package/dist/chunk-LNU4RW5G.mjs.map +0 -1
  91. package/dist/chunk-PZM3FHVZ.mjs.map +0 -1
  92. package/dist/chunk-YVNZ73O5.mjs.map +0 -1
  93. package/dist-web/assets/ActionToolsPanel.vue_vue_type_script_setup_true_lang-DfQa9E2W.js +0 -110
  94. package/dist-web/assets/CanvasRenderer-Bvpsbxds.js +0 -1
  95. package/dist-web/assets/DataDirCleanupNotice-C0sCmNL2.js +0 -1
  96. package/dist-web/assets/EChartWordcloud-C5hLT1vS.js +0 -1
  97. package/dist-web/assets/LoadingState.vue_vue_type_script_setup_true_lang-8s6XRB3S.js +0 -1
  98. package/dist-web/assets/MessageExportModal-tTI358HU.js +0 -1
  99. package/dist-web/assets/PageHeader-D5QQI9io.js +0 -1
  100. package/dist-web/assets/ThemeCard.vue_vue_type_script_setup_true_lang-CpNjFhpm.js +0 -1
  101. package/dist-web/assets/TimeSelect.vue_vue_type_script_setup_true_lang-DtCKfbaz.js +0 -1
  102. package/dist-web/assets/annual-summary-time-range-CvG74N2l.js +0 -1
  103. package/dist-web/assets/base-DdQRTliS.js +0 -1
  104. package/dist-web/assets/electron-ChQkD5ht.js +0 -1
  105. package/dist-web/assets/electron-DGxVMsvC.js +0 -1
  106. package/dist-web/assets/electron-hcWiB7Gg.js +0 -1
  107. package/dist-web/assets/fetch-3Ifr5YJN.js +0 -1
  108. package/dist-web/assets/fetch-74o_kRZf.js +0 -1
  109. package/dist-web/assets/fetch-BKFznq4l.js +0 -1
  110. package/dist-web/assets/fetch-BPj6IlT-.js +0 -1
  111. package/dist-web/assets/fetch-CoYaXr5K.js +0 -1
  112. package/dist-web/assets/fetch-Dcg6Q6Ei.js +0 -1
  113. package/dist-web/assets/fetch-DxWfYzkB.js +0 -1
  114. package/dist-web/assets/index-B3riRaJA.js +0 -1
  115. package/dist-web/assets/index-BKFGuwJu.css +0 -1
  116. package/dist-web/assets/index-BRDdozcm.js +0 -173
  117. package/dist-web/assets/index-Bg-OiHMa.js +0 -1
  118. package/dist-web/assets/index-BhewGKey.js +0 -2
  119. package/dist-web/assets/index-BpeJ40uK.js +0 -1
  120. package/dist-web/assets/index-C6bwt1H4.js +0 -1
  121. package/dist-web/assets/index-CEJqRkis.js +0 -2
  122. package/dist-web/assets/index-CKLCaqdT.js +0 -1
  123. package/dist-web/assets/index-D8Uq3_Dc.css +0 -1
  124. package/dist-web/assets/index-DBb03wVF.css +0 -1
  125. package/dist-web/assets/index-Ds5PiVyB.js +0 -64
  126. package/dist-web/assets/index-GXMxhYc9.js +0 -1
  127. package/dist-web/assets/index-JyB6Cr8r.js +0 -25
  128. package/dist-web/assets/index-UJl03IYE.css +0 -1
  129. package/dist-web/assets/index-tx-Oal36.js +0 -1
  130. package/dist-web/assets/people-page-header-DGkK0AMO.js +0 -1
  131. package/dist-web/assets/types-CZnACqaB.js +0 -1
  132. package/dist-web/assets/vendor-nuxt-ui-DMdbdSFy.js +0 -15
  133. package/dist-web/assets/vendor-reka-ui-8_x7iKfi.js +0 -15
  134. package/dist-web/assets/web-aZcioccr.js +0 -1
  135. /package/dist/{chat-command-3KUWKS53.mjs.map → chat-command-XPY3WURC.mjs.map} +0 -0
  136. /package/dist/{chunk-UVCH2ICD.mjs.map → chunk-BQ3QN4QT.mjs.map} +0 -0
  137. /package/dist/{chunk-DV4U34MR.mjs.map → chunk-DGF3S3TZ.mjs.map} +0 -0
  138. /package/dist/{chunk-3J7WTUEE.mjs.map → chunk-IGEHMLHM.mjs.map} +0 -0
  139. /package/dist/{chunk-BLOBEOCG.mjs.map → chunk-ISRLGLUL.mjs.map} +0 -0
  140. /package/dist/{chunk-23AIEWCD.mjs.map → chunk-JTOHAMIW.mjs.map} +0 -0
  141. /package/dist/{http-YR26GF7X.mjs.map → http-HV6XWU6X.mjs.map} +0 -0
  142. /package/dist/{import-Q3DUACU4.mjs.map → import-DP2XLZ2H.mjs.map} +0 -0
  143. /package/dist/{mcp-HTVZSGTI.mjs.map → mcp-QDPFBPGW.mjs.map} +0 -0
  144. /package/dist/{src-HJL7YZZJ.mjs.map → src-B3A2QHP5.mjs.map} +0 -0
  145. /package/dist/{stream-import-MXETSEPW.mjs.map → stream-import-KEGNP3QK.mjs.map} +0 -0
  146. /package/dist/{worker-runtime-DZQDL2E2.mjs.map → worker-runtime-MDYKX3BW.mjs.map} +0 -0
  147. /package/{dist-web → dist-cli-web}/assets/ActionToolsPanel-Dp-ojXjO.css +0 -0
  148. /package/{dist-web → dist-cli-web}/assets/PageHeader-XIXMTomn.css +0 -0
  149. /package/{dist-web → dist-cli-web}/assets/index-BfO_LpDv.css +0 -0
  150. /package/{dist-web → dist-cli-web}/assets/index-ByUaiVQK.css +0 -0
  151. /package/{dist-web → dist-cli-web}/assets/index-ZsZwPLWy.css +0 -0
  152. /package/{dist-web → dist-cli-web}/assets/logo-DXIuG_WE.svg +0 -0
  153. /package/{dist-web → dist-cli-web}/assets/relationship-galaxy-viewport-Cwfa51ER.js +0 -0
  154. /package/{dist-web → dist-cli-web}/assets/vendor-echarts-B-i_56Av.js +0 -0
  155. /package/{dist-web → dist-cli-web}/assets/vendor-echarts-wordcloud-Ca8n6qS6.js +0 -0
  156. /package/{dist-web → dist-cli-web}/assets/vendor-snapdom--nZvo8Sg.js +0 -0
  157. /package/{dist-web → dist-cli-web}/assets/vendor-zrender-5DcYjSZk.js +0 -0
  158. /package/{dist-web → dist-cli-web}/favicon.ico +0 -0
@@ -1,8 +1,8 @@
1
- import{d as lc,s as jr,x as cc,n as hc,w as es,F as uc,P as ts,Z as ns,ag as fc,ad as dc,ae as pc,ak as mc,aa as _c,_ as gc,a0 as xc,r as io}from"./vendor-reka-ui-8_x7iKfi.js";import{b as vc,a as ml,m as Mc}from"./index-BhewGKey.js";import{n as _l}from"./relationship-galaxy-viewport-Cwfa51ER.js";import{o as Sc}from"./index-JyB6Cr8r.js";import"./vendor-nuxt-ui-DMdbdSFy.js";import"./LoadingState.vue_vue_type_script_setup_true_lang-8s6XRB3S.js";import"./people-page-header-DGkK0AMO.js";import"./vendor-snapdom--nZvo8Sg.js";const Ia="185",Ti={ROTATE:0,DOLLY:1,PAN:2},bi={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Ec=0,ro=1,yc=2,Rr=1,bc=2,Xi=3,zn=0,Nt=1,pn=2,_n=0,On=1,so=2,ao=3,oo=4,Tc=5,Kn=100,Ac=101,Rc=102,wc=103,Cc=104,Pc=200,Dc=201,Lc=202,Ic=203,Gs=204,Vs=205,Uc=206,Nc=207,Fc=208,Oc=209,Bc=210,zc=211,Gc=212,Vc=213,Hc=214,Hs=0,ks=1,Ws=2,Ci=3,Xs=4,Ys=5,qs=6,Ks=7,gl=0,kc=1,Wc=2,sn=0,xl=1,vl=2,Ml=3,Sl=4,El=5,yl=6,bl=7,Tl=300,Qn=301,Pi=302,is=303,rs=304,Xr=306,Zs=1e3,mn=1001,$s=1002,bt=1003,Xc=1004,ji=1005,wt=1006,ss=1007,$n=1008,kt=1009,Al=1010,Rl=1011,qi=1012,Ua=1013,on=1014,nn=1015,xn=1016,Na=1017,Fa=1018,Ki=1020,wl=35902,Cl=35899,Pl=1021,Dl=1022,Zt=1023,vn=1026,Jn=1027,Ll=1028,Oa=1029,jn=1030,Ba=1031,za=1033,wr=33776,Cr=33777,Pr=33778,Dr=33779,Js=35840,Qs=35841,js=35842,ea=35843,ta=36196,na=37492,ia=37496,ra=37488,sa=37489,Ur=37490,aa=37491,oa=37808,la=37809,ca=37810,ha=37811,ua=37812,fa=37813,da=37814,pa=37815,ma=37816,_a=37817,ga=37818,xa=37819,va=37820,Ma=37821,Sa=36492,Ea=36494,ya=36495,ba=36283,Ta=36284,Nr=36285,Aa=36286,Yc=3200,lo=0,qc=1,In="",Ut="srgb",Fr="srgb-linear",Or="linear",$e="srgb",ai=7680,co=519,Kc=512,Zc=513,$c=514,Ga=515,Jc=516,Qc=517,Va=518,jc=519,Ra=35044,ho="300 es",rn=2e3,Br=2001;function eh(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function zr(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function th(){const i=zr("canvas");return i.style.display="block",i}const uo={};function Gr(...i){const e="THREE."+i.shift();console.log(e,...i)}function Il(i){const e=i[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=i[1];t&&t.isStackTrace?i[0]+=" "+t.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function we(...i){i=Il(i);const e="THREE."+i.shift();{const t=i[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...i)}}function He(...i){i=Il(i);const e="THREE."+i.shift();{const t=i[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...i)}}function Ai(...i){const e=i.join(" ");e in uo||(uo[e]=!0,we(...i))}function nh(i,e,t){return new Promise(function(n,r){function s(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:n()}}setTimeout(s,t)})}const ih={[Hs]:ks,[Ws]:qs,[Xs]:Ks,[Ci]:Ys,[ks]:Hs,[qs]:Ws,[Ks]:Xs,[Ys]:Ci};class Vn{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){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const r=n[e];if(r!==void 0){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const r=n.slice(0);for(let s=0,a=r.length;s<a;s++)r[s].call(this,e);e.target=null}}}const At=["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"],Lr=Math.PI/180,wa=180/Math.PI;function Bn(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(At[i&255]+At[i>>8&255]+At[i>>16&255]+At[i>>24&255]+"-"+At[e&255]+At[e>>8&255]+"-"+At[e>>16&15|64]+At[e>>24&255]+"-"+At[t&63|128]+At[t>>8&255]+"-"+At[t>>16&255]+At[t>>24&255]+At[n&255]+At[n>>8&255]+At[n>>16&255]+At[n>>24&255]).toLowerCase()}function Be(i,e,t){return Math.max(e,Math.min(t,i))}function rh(i,e){return(i%e+e)%e}function as(i,e,t){return(1-t)*i+t*e}function tn(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function Qe(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const sh={DEG2RAD:Lr},Ya=class Ya{constructor(e=0,t=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("THREE.Vector2: 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("THREE.Vector2: 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,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Be(this.x,e.x,t.x),this.y=Be(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Be(this.x,e,t),this.y=Be(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Be(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Be(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),r=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*n-a*r+e.x,this.y=s*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};Ya.prototype.isVector2=!0;let Ce=Ya;class Gn{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,s,a,o){let c=n[r+0],l=n[r+1],u=n[r+2],m=n[r+3],h=s[a+0],d=s[a+1],x=s[a+2],y=s[a+3];if(m!==y||c!==h||l!==d||u!==x){let _=c*h+l*d+u*x+m*y;_<0&&(h=-h,d=-d,x=-x,y=-y,_=-_);let f=1-o;if(_<.9995){const w=Math.acos(_),C=Math.sin(w);f=Math.sin(f*w)/C,o=Math.sin(o*w)/C,c=c*f+h*o,l=l*f+d*o,u=u*f+x*o,m=m*f+y*o}else{c=c*f+h*o,l=l*f+d*o,u=u*f+x*o,m=m*f+y*o;const w=1/Math.sqrt(c*c+l*l+u*u+m*m);c*=w,l*=w,u*=w,m*=w}}e[t]=c,e[t+1]=l,e[t+2]=u,e[t+3]=m}static multiplyQuaternionsFlat(e,t,n,r,s,a){const o=n[r],c=n[r+1],l=n[r+2],u=n[r+3],m=s[a],h=s[a+1],d=s[a+2],x=s[a+3];return e[t]=o*x+u*m+c*d-l*h,e[t+1]=c*x+u*h+l*m-o*d,e[t+2]=l*x+u*d+o*h-c*m,e[t+3]=u*x-o*m-c*h-l*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,r=e._y,s=e._z,a=e._order,o=Math.cos,c=Math.sin,l=o(n/2),u=o(r/2),m=o(s/2),h=c(n/2),d=c(r/2),x=c(s/2);switch(a){case"XYZ":this._x=h*u*m+l*d*x,this._y=l*d*m-h*u*x,this._z=l*u*x+h*d*m,this._w=l*u*m-h*d*x;break;case"YXZ":this._x=h*u*m+l*d*x,this._y=l*d*m-h*u*x,this._z=l*u*x-h*d*m,this._w=l*u*m+h*d*x;break;case"ZXY":this._x=h*u*m-l*d*x,this._y=l*d*m+h*u*x,this._z=l*u*x+h*d*m,this._w=l*u*m-h*d*x;break;case"ZYX":this._x=h*u*m-l*d*x,this._y=l*d*m+h*u*x,this._z=l*u*x-h*d*m,this._w=l*u*m+h*d*x;break;case"YZX":this._x=h*u*m+l*d*x,this._y=l*d*m+h*u*x,this._z=l*u*x-h*d*m,this._w=l*u*m-h*d*x;break;case"XZY":this._x=h*u*m-l*d*x,this._y=l*d*m-h*u*x,this._z=l*u*x+h*d*m,this._w=l*u*m+h*d*x;break;default:we("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],s=t[8],a=t[1],o=t[5],c=t[9],l=t[2],u=t[6],m=t[10],h=n+o+m;if(h>0){const d=.5/Math.sqrt(h+1);this._w=.25/d,this._x=(u-c)*d,this._y=(s-l)*d,this._z=(a-r)*d}else if(n>o&&n>m){const d=2*Math.sqrt(1+n-o-m);this._w=(u-c)/d,this._x=.25*d,this._y=(r+a)/d,this._z=(s+l)/d}else if(o>m){const d=2*Math.sqrt(1+o-n-m);this._w=(s-l)/d,this._x=(r+a)/d,this._y=.25*d,this._z=(c+u)/d}else{const d=2*Math.sqrt(1+m-n-o);this._w=(a-r)/d,this._x=(s+l)/d,this._y=(c+u)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(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(Be(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,r=e._y,s=e._z,a=e._w,o=t._x,c=t._y,l=t._z,u=t._w;return this._x=n*u+a*o+r*l-s*c,this._y=r*u+a*c+s*o-n*l,this._z=s*u+a*l+n*c-r*o,this._w=a*u-n*o-r*c-s*l,this._onChangeCallback(),this}slerp(e,t){let n=e._x,r=e._y,s=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,r=-r,s=-s,a=-a,o=-o);let c=1-t;if(o<.9995){const l=Math.acos(o),u=Math.sin(l);c=Math.sin(c*l)/u,t=Math.sin(t*l)/u,this._x=this._x*c+n*t,this._y=this._y*c+r*t,this._z=this._z*c+s*t,this._w=this._w*c+a*t,this._onChangeCallback()}else this._x=this._x*c+n*t,this._y=this._y*c+r*t,this._z=this._z*c+s*t,this._w=this._w*c+a*t,this.normalize();return 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(),r=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const qa=class qa{constructor(e=0,t=0,n=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("THREE.Vector3: 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("THREE.Vector3: 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(fo.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(fo.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*r,this.y=s[1]*t+s[4]*n+s[7]*r,this.z=s[2]*t+s[5]*n+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=e.elements,a=1/(s[3]*t+s[7]*n+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*r+s[12])*a,this.y=(s[1]*t+s[5]*n+s[9]*r+s[13])*a,this.z=(s[2]*t+s[6]*n+s[10]*r+s[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,s=e.x,a=e.y,o=e.z,c=e.w,l=2*(a*r-o*n),u=2*(o*t-s*r),m=2*(s*n-a*t);return this.x=t+c*l+a*m-o*u,this.y=n+c*u+o*l-s*m,this.z=r+c*m+s*u-a*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,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*r,this.y=s[1]*t+s[5]*n+s[9]*r,this.z=s[2]*t+s[6]*n+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Be(this.x,e.x,t.x),this.y=Be(this.y,e.y,t.y),this.z=Be(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Be(this.x,e,t),this.y=Be(this.y,e,t),this.z=Be(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Be(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,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,r=e.y,s=e.z,a=t.x,o=t.y,c=t.z;return this.x=r*c-s*o,this.y=s*a-n*c,this.z=n*o-r*a,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 os.copy(this).projectOnVector(e),this.sub(os)}reflect(e){return this.sub(os.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(Be(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*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(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,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}};qa.prototype.isVector3=!0;let D=qa;const os=new D,fo=new Gn,Ka=class Ka{constructor(e,t,n,r,s,a,o,c,l){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,o,c,l)}set(e,t,n,r,s,a,o,c,l){const u=this.elements;return u[0]=e,u[1]=r,u[2]=o,u[3]=t,u[4]=s,u[5]=c,u[6]=n,u[7]=a,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,r=t.elements,s=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],u=n[4],m=n[7],h=n[2],d=n[5],x=n[8],y=r[0],_=r[3],f=r[6],w=r[1],C=r[4],S=r[7],R=r[2],b=r[5],P=r[8];return s[0]=a*y+o*w+c*R,s[3]=a*_+o*C+c*b,s[6]=a*f+o*S+c*P,s[1]=l*y+u*w+m*R,s[4]=l*_+u*C+m*b,s[7]=l*f+u*S+m*P,s[2]=h*y+d*w+x*R,s[5]=h*_+d*C+x*b,s[8]=h*f+d*S+x*P,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],r=e[2],s=e[3],a=e[4],o=e[5],c=e[6],l=e[7],u=e[8];return t*a*u-t*o*l-n*s*u+n*o*c+r*s*l-r*a*c}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],c=e[6],l=e[7],u=e[8],m=u*a-o*l,h=o*c-u*s,d=l*s-a*c,x=t*m+n*h+r*d;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/x;return e[0]=m*y,e[1]=(r*l-u*n)*y,e[2]=(o*n-r*a)*y,e[3]=h*y,e[4]=(u*t-r*c)*y,e[5]=(r*s-o*t)*y,e[6]=d*y,e[7]=(n*c-l*t)*y,e[8]=(a*t-n*s)*y,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,r,s,a,o){const c=Math.cos(s),l=Math.sin(s);return this.set(n*c,n*l,-n*(c*a+l*o)+a+e,-r*l,r*c,-r*(-l*a+c*o)+o+t,0,0,1),this}scale(e,t){return Ai("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(ls.makeScale(e,t)),this}rotate(e){return Ai("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(ls.makeRotation(-e)),this}translate(e,t){return Ai("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(ls.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 r=0;r<9;r++)if(t[r]!==n[r])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)}};Ka.prototype.isMatrix3=!0;let Le=Ka;const ls=new Le,po=new Le().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),mo=new Le().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function ah(){const i={enabled:!0,workingColorSpace:Fr,spaces:{},convert:function(r,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===$e&&(r.r=gn(r.r),r.g=gn(r.g),r.b=gn(r.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===$e&&(r.r=Ri(r.r),r.g=Ri(r.g),r.b=Ri(r.b))),r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===In?Or:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,a){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return Ai("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return Ai("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(r,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Fr]:{primaries:e,whitePoint:n,transfer:Or,toXYZ:po,fromXYZ:mo,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Ut},outputColorSpaceConfig:{drawingBufferColorSpace:Ut}},[Ut]:{primaries:e,whitePoint:n,transfer:$e,toXYZ:po,fromXYZ:mo,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Ut}}}),i}const ke=ah();function gn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function Ri(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let oi;class oh{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{oi===void 0&&(oi=zr("canvas")),oi.width=e.width,oi.height=e.height;const r=oi.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=oi}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=zr("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),s=r.data;for(let a=0;a<s.length;a++)s[a]=gn(s[a]/255)*255;return n.putImageData(r,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(gn(t[n]/255)*255):t[n]=gn(t[n]);return{data:t,width:e.width,height:e.height}}else return we("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let lh=0;class Ha{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:lh++}),this.uuid=Bn(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let a=0,o=r.length;a<o;a++)r[a].isDataTexture?s.push(cs(r[a].image)):s.push(cs(r[a]))}else s=cs(r);n.url=s}return t||(e.images[this.uuid]=n),n}}function cs(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?oh.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(we("Texture: Unable to serialize Texture."),{})}let ch=0;const hs=new D;class Ct extends Vn{constructor(e=Ct.DEFAULT_IMAGE,t=Ct.DEFAULT_MAPPING,n=mn,r=mn,s=wt,a=$n,o=Zt,c=kt,l=Ct.DEFAULT_ANISOTROPY,u=In){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:ch++}),this.uuid=Bn(),this.name="",this.source=new Ha(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=s,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=c,this.offset=new Ce(0,0),this.repeat=new Ce(1,1),this.center=new Ce(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Le,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(hs).x}get height(){return this.source.getSize(hs).y}get depth(){return this.source.getSize(hs).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const n=e[t];if(n===void 0){we(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){we(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}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.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,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!==Tl)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Zs:e.x=e.x-Math.floor(e.x);break;case mn:e.x=e.x<0?0:1;break;case $s:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Zs:e.y=e.y-Math.floor(e.y);break;case mn:e.y=e.y<0?0:1;break;case $s:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Ct.DEFAULT_IMAGE=null;Ct.DEFAULT_MAPPING=Tl;Ct.DEFAULT_ANISOTROPY=1;const Za=class Za{constructor(e=0,t=0,n=0,r=1){this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: 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("THREE.Vector4: 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,r=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*s,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*s,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*s,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,s;const c=e.elements,l=c[0],u=c[4],m=c[8],h=c[1],d=c[5],x=c[9],y=c[2],_=c[6],f=c[10];if(Math.abs(u-h)<.01&&Math.abs(m-y)<.01&&Math.abs(x-_)<.01){if(Math.abs(u+h)<.1&&Math.abs(m+y)<.1&&Math.abs(x+_)<.1&&Math.abs(l+d+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const C=(l+1)/2,S=(d+1)/2,R=(f+1)/2,b=(u+h)/4,P=(m+y)/4,g=(x+_)/4;return C>S&&C>R?C<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(C),r=b/n,s=P/n):S>R?S<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(S),n=b/r,s=g/r):R<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(R),n=P/s,r=g/s),this.set(n,r,s,t),this}let w=Math.sqrt((_-x)*(_-x)+(m-y)*(m-y)+(h-u)*(h-u));return Math.abs(w)<.001&&(w=1),this.x=(_-x)/w,this.y=(m-y)/w,this.z=(h-u)/w,this.w=Math.acos((l+d+f-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Be(this.x,e.x,t.x),this.y=Be(this.y,e.y,t.y),this.z=Be(this.z,e.z,t.z),this.w=Be(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Be(this.x,e,t),this.y=Be(this.y,e,t),this.z=Be(this.z,e,t),this.w=Be(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Be(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,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}};Za.prototype.isVector4=!0;let dt=Za;class hh extends Vn{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:wt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new dt(0,0,e,t),this.scissorTest=!1,this.viewport=new dt(0,0,e,t),this.textures=[];const r={width:e,height:t,depth:n.depth},s=new Ct(r),a=n.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){const t={minFilter:wt,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const r=Object.assign({},e.textures[t].image);this.textures[t].source=new Ha(r)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class an extends hh{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class Ul extends Ct{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=bt,this.minFilter=bt,this.wrapR=mn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class uh extends Ct{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=bt,this.minFilter=bt,this.wrapR=mn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Wr=class Wr{constructor(e,t,n,r,s,a,o,c,l,u,m,h,d,x,y,_){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,r,s,a,o,c,l,u,m,h,d,x,y,_)}set(e,t,n,r,s,a,o,c,l,u,m,h,d,x,y,_){const f=this.elements;return f[0]=e,f[4]=t,f[8]=n,f[12]=r,f[1]=s,f[5]=a,f[9]=o,f[13]=c,f[2]=l,f[6]=u,f[10]=m,f[14]=h,f[3]=d,f[7]=x,f[11]=y,f[15]=_,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 Wr().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 this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(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){if(e.determinantAffine()===0)return this.identity();const t=this.elements,n=e.elements,r=1/li.setFromMatrixColumn(e,0).length(),s=1/li.setFromMatrixColumn(e,1).length(),a=1/li.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,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,r=e.y,s=e.z,a=Math.cos(n),o=Math.sin(n),c=Math.cos(r),l=Math.sin(r),u=Math.cos(s),m=Math.sin(s);if(e.order==="XYZ"){const h=a*u,d=a*m,x=o*u,y=o*m;t[0]=c*u,t[4]=-c*m,t[8]=l,t[1]=d+x*l,t[5]=h-y*l,t[9]=-o*c,t[2]=y-h*l,t[6]=x+d*l,t[10]=a*c}else if(e.order==="YXZ"){const h=c*u,d=c*m,x=l*u,y=l*m;t[0]=h+y*o,t[4]=x*o-d,t[8]=a*l,t[1]=a*m,t[5]=a*u,t[9]=-o,t[2]=d*o-x,t[6]=y+h*o,t[10]=a*c}else if(e.order==="ZXY"){const h=c*u,d=c*m,x=l*u,y=l*m;t[0]=h-y*o,t[4]=-a*m,t[8]=x+d*o,t[1]=d+x*o,t[5]=a*u,t[9]=y-h*o,t[2]=-a*l,t[6]=o,t[10]=a*c}else if(e.order==="ZYX"){const h=a*u,d=a*m,x=o*u,y=o*m;t[0]=c*u,t[4]=x*l-d,t[8]=h*l+y,t[1]=c*m,t[5]=y*l+h,t[9]=d*l-x,t[2]=-l,t[6]=o*c,t[10]=a*c}else if(e.order==="YZX"){const h=a*c,d=a*l,x=o*c,y=o*l;t[0]=c*u,t[4]=y-h*m,t[8]=x*m+d,t[1]=m,t[5]=a*u,t[9]=-o*u,t[2]=-l*u,t[6]=d*m+x,t[10]=h-y*m}else if(e.order==="XZY"){const h=a*c,d=a*l,x=o*c,y=o*l;t[0]=c*u,t[4]=-m,t[8]=l*u,t[1]=h*m+y,t[5]=a*u,t[9]=d*m-x,t[2]=x*m-d,t[6]=o*u,t[10]=y*m+h}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(fh,e,dh)}lookAt(e,t,n){const r=this.elements;return Ot.subVectors(e,t),Ot.lengthSq()===0&&(Ot.z=1),Ot.normalize(),An.crossVectors(n,Ot),An.lengthSq()===0&&(Math.abs(n.z)===1?Ot.x+=1e-4:Ot.z+=1e-4,Ot.normalize(),An.crossVectors(n,Ot)),An.normalize(),er.crossVectors(Ot,An),r[0]=An.x,r[4]=er.x,r[8]=Ot.x,r[1]=An.y,r[5]=er.y,r[9]=Ot.y,r[2]=An.z,r[6]=er.z,r[10]=Ot.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,a=n[0],o=n[4],c=n[8],l=n[12],u=n[1],m=n[5],h=n[9],d=n[13],x=n[2],y=n[6],_=n[10],f=n[14],w=n[3],C=n[7],S=n[11],R=n[15],b=r[0],P=r[4],g=r[8],T=r[12],U=r[1],L=r[5],z=r[9],$=r[13],j=r[2],H=r[6],Z=r[10],X=r[14],te=r[3],ie=r[7],fe=r[11],me=r[15];return s[0]=a*b+o*U+c*j+l*te,s[4]=a*P+o*L+c*H+l*ie,s[8]=a*g+o*z+c*Z+l*fe,s[12]=a*T+o*$+c*X+l*me,s[1]=u*b+m*U+h*j+d*te,s[5]=u*P+m*L+h*H+d*ie,s[9]=u*g+m*z+h*Z+d*fe,s[13]=u*T+m*$+h*X+d*me,s[2]=x*b+y*U+_*j+f*te,s[6]=x*P+y*L+_*H+f*ie,s[10]=x*g+y*z+_*Z+f*fe,s[14]=x*T+y*$+_*X+f*me,s[3]=w*b+C*U+S*j+R*te,s[7]=w*P+C*L+S*H+R*ie,s[11]=w*g+C*z+S*Z+R*fe,s[15]=w*T+C*$+S*X+R*me,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],r=e[8],s=e[12],a=e[1],o=e[5],c=e[9],l=e[13],u=e[2],m=e[6],h=e[10],d=e[14],x=e[3],y=e[7],_=e[11],f=e[15],w=c*d-l*h,C=o*d-l*m,S=o*h-c*m,R=a*d-l*u,b=a*h-c*u,P=a*m-o*u;return t*(y*w-_*C+f*S)-n*(x*w-_*R+f*b)+r*(x*C-y*R+f*P)-s*(x*S-y*b+_*P)}determinantAffine(){const e=this.elements,t=e[0],n=e[4],r=e[8],s=e[1],a=e[5],o=e[9],c=e[2],l=e[6],u=e[10];return t*(a*u-o*l)-n*(s*u-o*c)+r*(s*l-a*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],c=e[6],l=e[7],u=e[8],m=e[9],h=e[10],d=e[11],x=e[12],y=e[13],_=e[14],f=e[15],w=t*o-n*a,C=t*c-r*a,S=t*l-s*a,R=n*c-r*o,b=n*l-s*o,P=r*l-s*c,g=u*y-m*x,T=u*_-h*x,U=u*f-d*x,L=m*_-h*y,z=m*f-d*y,$=h*f-d*_,j=w*$-C*z+S*L+R*U-b*T+P*g;if(j===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const H=1/j;return e[0]=(o*$-c*z+l*L)*H,e[1]=(r*z-n*$-s*L)*H,e[2]=(y*P-_*b+f*R)*H,e[3]=(h*b-m*P-d*R)*H,e[4]=(c*U-a*$-l*T)*H,e[5]=(t*$-r*U+s*T)*H,e[6]=(_*S-x*P-f*C)*H,e[7]=(u*P-h*S+d*C)*H,e[8]=(a*z-o*U+l*g)*H,e[9]=(n*U-t*z-s*g)*H,e[10]=(x*b-y*S+f*w)*H,e[11]=(m*S-u*b-d*w)*H,e[12]=(o*T-a*L-c*g)*H,e[13]=(t*L-n*T+r*g)*H,e[14]=(y*C-x*R-_*w)*H,e[15]=(u*R-m*C+h*w)*H,this}scale(e){const t=this.elements,n=e.x,r=e.y,s=e.z;return t[0]*=n,t[4]*=r,t[8]*=s,t[1]*=n,t[5]*=r,t[9]*=s,t[2]*=n,t[6]*=r,t[10]*=s,t[3]*=n,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}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),r=Math.sin(t),s=1-n,a=e.x,o=e.y,c=e.z,l=s*a,u=s*o;return this.set(l*a+n,l*o-r*c,l*c+r*o,0,l*o+r*c,u*o+n,u*c-r*a,0,l*c-r*o,u*c+r*a,s*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,r,s,a){return this.set(1,n,s,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,s=t._x,a=t._y,o=t._z,c=t._w,l=s+s,u=a+a,m=o+o,h=s*l,d=s*u,x=s*m,y=a*u,_=a*m,f=o*m,w=c*l,C=c*u,S=c*m,R=n.x,b=n.y,P=n.z;return r[0]=(1-(y+f))*R,r[1]=(d+S)*R,r[2]=(x-C)*R,r[3]=0,r[4]=(d-S)*b,r[5]=(1-(h+f))*b,r[6]=(_+w)*b,r[7]=0,r[8]=(x+C)*P,r[9]=(_-w)*P,r[10]=(1-(h+y))*P,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];const s=this.determinantAffine();if(s===0)return n.set(1,1,1),t.identity(),this;let a=li.set(r[0],r[1],r[2]).length();const o=li.set(r[4],r[5],r[6]).length(),c=li.set(r[8],r[9],r[10]).length();s<0&&(a=-a),Yt.copy(this);const l=1/a,u=1/o,m=1/c;return Yt.elements[0]*=l,Yt.elements[1]*=l,Yt.elements[2]*=l,Yt.elements[4]*=u,Yt.elements[5]*=u,Yt.elements[6]*=u,Yt.elements[8]*=m,Yt.elements[9]*=m,Yt.elements[10]*=m,t.setFromRotationMatrix(Yt),n.x=a,n.y=o,n.z=c,this}makePerspective(e,t,n,r,s,a,o=rn,c=!1){const l=this.elements,u=2*s/(t-e),m=2*s/(n-r),h=(t+e)/(t-e),d=(n+r)/(n-r);let x,y;if(c)x=s/(a-s),y=a*s/(a-s);else if(o===rn)x=-(a+s)/(a-s),y=-2*a*s/(a-s);else if(o===Br)x=-a/(a-s),y=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=u,l[4]=0,l[8]=h,l[12]=0,l[1]=0,l[5]=m,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=x,l[14]=y,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,r,s,a,o=rn,c=!1){const l=this.elements,u=2/(t-e),m=2/(n-r),h=-(t+e)/(t-e),d=-(n+r)/(n-r);let x,y;if(c)x=1/(a-s),y=a/(a-s);else if(o===rn)x=-2/(a-s),y=-(a+s)/(a-s);else if(o===Br)x=-1/(a-s),y=-s/(a-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=u,l[4]=0,l[8]=0,l[12]=h,l[1]=0,l[5]=m,l[9]=0,l[13]=d,l[2]=0,l[6]=0,l[10]=x,l[14]=y,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<16;r++)if(t[r]!==n[r])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}};Wr.prototype.isMatrix4=!0;let at=Wr;const li=new D,Yt=new at,fh=new D(0,0,0),dh=new D(1,1,1),An=new D,er=new D,Ot=new D,_o=new at,go=new Gn;class ei{constructor(e=0,t=0,n=0,r=ei.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const r=e.elements,s=r[0],a=r[4],o=r[8],c=r[1],l=r[5],u=r[9],m=r[2],h=r[6],d=r[10];switch(t){case"XYZ":this._y=Math.asin(Be(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,d),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Be(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,d),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-m,s),this._z=0);break;case"ZXY":this._x=Math.asin(Be(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-m,d),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Be(m,-1,1)),Math.abs(m)<.9999999?(this._x=Math.atan2(h,d),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(Be(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-m,s)):(this._x=0,this._y=Math.atan2(o,d));break;case"XZY":this._z=Math.asin(-Be(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(h,l),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-u,d),this._y=0);break;default:we("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return _o.makeRotationFromQuaternion(e),this.setFromRotationMatrix(_o,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return go.setFromEuler(this),this.setFromQuaternion(go,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}}ei.DEFAULT_ORDER="XYZ";class ka{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 ph=0;const xo=new D,ci=new Gn,cn=new at,tr=new D,Ni=new D,mh=new D,_h=new Gn,vo=new D(1,0,0),Mo=new D(0,1,0),So=new D(0,0,1),Eo={type:"added"},gh={type:"removed"},hi={type:"childadded",child:null},us={type:"childremoved",child:null};class Lt extends Vn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:ph++}),this.uuid=Bn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Lt.DEFAULT_UP.clone();const e=new D,t=new ei,n=new Gn,r=new D(1,1,1);function s(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new at},normalMatrix:{value:new Le}}),this.matrix=new at,this.matrixWorld=new at,this.matrixAutoUpdate=Lt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Lt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new ka,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return ci.setFromAxisAngle(e,t),this.quaternion.multiply(ci),this}rotateOnWorldAxis(e,t){return ci.setFromAxisAngle(e,t),this.quaternion.premultiply(ci),this}rotateX(e){return this.rotateOnAxis(vo,e)}rotateY(e){return this.rotateOnAxis(Mo,e)}rotateZ(e){return this.rotateOnAxis(So,e)}translateOnAxis(e,t){return xo.copy(e).applyQuaternion(this.quaternion),this.position.add(xo.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(vo,e)}translateY(e){return this.translateOnAxis(Mo,e)}translateZ(e){return this.translateOnAxis(So,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(cn.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?tr.copy(e):tr.set(e,t,n);const r=this.parent;this.updateWorldMatrix(!0,!1),Ni.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?cn.lookAt(Ni,tr,this.up):cn.lookAt(tr,Ni,this.up),this.quaternion.setFromRotationMatrix(cn),r&&(cn.extractRotation(r.matrixWorld),ci.setFromRotationMatrix(cn),this.quaternion.premultiply(ci.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(He("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(Eo),hi.child=e,this.dispatchEvent(hi),hi.child=null):He("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(gh),us.child=e,this.dispatchEvent(us),us.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),cn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),cn.multiply(e.parent.matrixWorld)),e.applyMatrix4(cn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Eo),hi.child=e,this.dispatchEvent(hi),hi.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,r=this.children.length;n<r;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].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(Ni,e,mh),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ni,_h,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,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,r=t.length;n<r;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);const e=this.pivot;if(e!==null){const t=e.x,n=e.y,r=e.z,s=this.matrix.elements;s[12]+=t-s[0]*t-s[4]*n-s[8]*r,s[13]+=n-s[1]*t-s[5]*n-s[9]*r,s[14]+=r-s[2]*t-s[6]*n-s[10]*r}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){const r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),t===!0){const s=this.children;for(let a=0,o=s.length;a<o;a++)s[a].updateWorldMatrix(!1,!0,n)}}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.7,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),this.static!==!1&&(r.static=this.static),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(o=>({...o})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function s(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let l=0,u=c.length;l<u;l++){const m=c[l];s(e.shapes,m)}else s(e.shapes,c)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let c=0,l=this.material.length;c<l;c++)o.push(s(e.materials,this.material[c]));r.material=o}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let o=0;o<this.children.length;o++)r.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];r.animations.push(s(e.animations,c))}}if(t){const o=a(e.geometries),c=a(e.materials),l=a(e.textures),u=a(e.images),m=a(e.shapes),h=a(e.skeletons),d=a(e.animations),x=a(e.nodes);o.length>0&&(n.geometries=o),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),u.length>0&&(n.images=u),m.length>0&&(n.shapes=m),h.length>0&&(n.skeletons=h),d.length>0&&(n.animations=d),x.length>0&&(n.nodes=x)}return n.object=r,n;function a(o){const c=[];for(const l in o){const u=o[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.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const r=e.children[n];this.add(r.clone())}return this}}Lt.DEFAULT_UP=new D(0,1,0);Lt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Lt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Nn extends Lt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const xh={type:"move"};class fs{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Nn,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 Nn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new D,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new D),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Nn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new D,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new D,this._grip.eventsEnabled=!1),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 r=null,s=null,a=null;const o=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){a=!0;for(const y of e.hand.values()){const _=t.getJointPose(y,n),f=this._getHandJoint(l,y);_!==null&&(f.matrix.fromArray(_.transform.matrix),f.matrix.decompose(f.position,f.rotation,f.scale),f.matrixWorldNeedsUpdate=!0,f.jointRadius=_.radius),f.visible=_!==null}const u=l.joints["index-finger-tip"],m=l.joints["thumb-tip"],h=u.position.distanceTo(m.position),d=.02,x=.005;l.inputState.pinching&&h>d+x?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&h<=d-x&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1,c.eventsEnabled&&c.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(xh)))}return o!==null&&(o.visible=r!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Nn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const Nl={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},Rn={h:0,s:0,l:0},nr={h:0,s:0,l:0};function ds(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}class ze{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 r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ut){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,ke.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=ke.workingColorSpace){return this.r=e,this.g=t,this.b=n,ke.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=ke.workingColorSpace){if(e=rh(e,1),t=Be(t,0,1),n=Be(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,a=2*n-s;this.r=ds(a,s,e+1/3),this.g=ds(a,s,e),this.b=ds(a,s,e-1/3)}return ke.colorSpaceToWorking(this,r),this}setStyle(e,t=Ut){function n(s){s!==void 0&&parseFloat(s)<1&&we("Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=r[1],o=r[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:we("Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);we("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Ut){const n=Nl[e.toLowerCase()];return n!==void 0?this.setHex(n,t):we("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=gn(e.r),this.g=gn(e.g),this.b=gn(e.b),this}copyLinearToSRGB(e){return this.r=Ri(e.r),this.g=Ri(e.g),this.b=Ri(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ut){return ke.workingToColorSpace(Rt.copy(this),e),Math.round(Be(Rt.r*255,0,255))*65536+Math.round(Be(Rt.g*255,0,255))*256+Math.round(Be(Rt.b*255,0,255))}getHexString(e=Ut){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=ke.workingColorSpace){ke.workingToColorSpace(Rt.copy(this),t);const n=Rt.r,r=Rt.g,s=Rt.b,a=Math.max(n,r,s),o=Math.min(n,r,s);let c,l;const u=(o+a)/2;if(o===a)c=0,l=0;else{const m=a-o;switch(l=u<=.5?m/(a+o):m/(2-a-o),a){case n:c=(r-s)/m+(r<s?6:0);break;case r:c=(s-n)/m+2;break;case s:c=(n-r)/m+4;break}c/=6}return e.h=c,e.s=l,e.l=u,e}getRGB(e,t=ke.workingColorSpace){return ke.workingToColorSpace(Rt.copy(this),t),e.r=Rt.r,e.g=Rt.g,e.b=Rt.b,e}getStyle(e=Ut){ke.workingToColorSpace(Rt.copy(this),e);const t=Rt.r,n=Rt.g,r=Rt.b;return e!==Ut?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`}offsetHSL(e,t,n){return this.getHSL(Rn),this.setHSL(Rn.h+e,Rn.s+t,Rn.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(Rn),e.getHSL(nr);const n=as(Rn.h,nr.h,t),r=as(Rn.s,nr.s,t),s=as(Rn.l,nr.l,t);return this.setHSL(n,r,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*n+s[6]*r,this.g=s[1]*t+s[4]*n+s[7]*r,this.b=s[2]*t+s[5]*n+s[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Rt=new ze;ze.NAMES=Nl;class Wa{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new ze(e),this.density=t}clone(){return new Wa(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class vh extends Lt{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 ei,this.environmentIntensity=1,this.environmentRotation=new ei,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const qt=new D,hn=new D,ps=new D,un=new D,ui=new D,fi=new D,yo=new D,ms=new D,_s=new D,gs=new D,xs=new dt,vs=new dt,Ms=new dt;class Wt{constructor(e=new D,t=new D,n=new D){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),qt.subVectors(e,t),r.cross(qt);const s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,n,r,s){qt.subVectors(r,t),hn.subVectors(n,t),ps.subVectors(e,t);const a=qt.dot(qt),o=qt.dot(hn),c=qt.dot(ps),l=hn.dot(hn),u=hn.dot(ps),m=a*l-o*o;if(m===0)return s.set(0,0,0),null;const h=1/m,d=(l*c-o*u)*h,x=(a*u-o*c)*h;return s.set(1-d-x,x,d)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,un)===null?!1:un.x>=0&&un.y>=0&&un.x+un.y<=1}static getInterpolation(e,t,n,r,s,a,o,c){return this.getBarycoord(e,t,n,r,un)===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(s,un.x),c.addScaledVector(a,un.y),c.addScaledVector(o,un.z),c)}static getInterpolatedAttribute(e,t,n,r,s,a){return xs.setScalar(0),vs.setScalar(0),Ms.setScalar(0),xs.fromBufferAttribute(e,t),vs.fromBufferAttribute(e,n),Ms.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(xs,s.x),a.addScaledVector(vs,s.y),a.addScaledVector(Ms,s.z),a}static isFrontFacing(e,t,n,r){return qt.subVectors(n,t),hn.subVectors(e,t),qt.cross(hn).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return qt.subVectors(this.c,this.b),hn.subVectors(this.a,this.b),qt.cross(hn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Wt.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Wt.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,s){return Wt.getInterpolation(e,this.a,this.b,this.c,t,n,r,s)}containsPoint(e){return Wt.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Wt.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,r=this.b,s=this.c;let a,o;ui.subVectors(r,n),fi.subVectors(s,n),ms.subVectors(e,n);const c=ui.dot(ms),l=fi.dot(ms);if(c<=0&&l<=0)return t.copy(n);_s.subVectors(e,r);const u=ui.dot(_s),m=fi.dot(_s);if(u>=0&&m<=u)return t.copy(r);const h=c*m-u*l;if(h<=0&&c>=0&&u<=0)return a=c/(c-u),t.copy(n).addScaledVector(ui,a);gs.subVectors(e,s);const d=ui.dot(gs),x=fi.dot(gs);if(x>=0&&d<=x)return t.copy(s);const y=d*l-c*x;if(y<=0&&l>=0&&x<=0)return o=l/(l-x),t.copy(n).addScaledVector(fi,o);const _=u*x-d*m;if(_<=0&&m-u>=0&&d-x>=0)return yo.subVectors(s,r),o=(m-u)/(m-u+(d-x)),t.copy(r).addScaledVector(yo,o);const f=1/(_+y+h);return a=y*f,o=h*f,t.copy(n).addScaledVector(ui,a).addScaledVector(fi,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Zi{constructor(e=new D(1/0,1/0,1/0),t=new D(-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(Kt.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Kt.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=Kt.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 s=n.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,Kt):Kt.fromBufferAttribute(s,a),Kt.applyMatrix4(e.matrixWorld),this.expandByPoint(Kt);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),ir.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),ir.copy(n.boundingBox)),ir.applyMatrix4(e.matrixWorld),this.union(ir)}const r=e.children;for(let s=0,a=r.length;s<a;s++)this.expandByObject(r[s],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Kt),Kt.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(Fi),rr.subVectors(this.max,Fi),di.subVectors(e.a,Fi),pi.subVectors(e.b,Fi),mi.subVectors(e.c,Fi),wn.subVectors(pi,di),Cn.subVectors(mi,pi),Wn.subVectors(di,mi);let t=[0,-wn.z,wn.y,0,-Cn.z,Cn.y,0,-Wn.z,Wn.y,wn.z,0,-wn.x,Cn.z,0,-Cn.x,Wn.z,0,-Wn.x,-wn.y,wn.x,0,-Cn.y,Cn.x,0,-Wn.y,Wn.x,0];return!Ss(t,di,pi,mi,rr)||(t=[1,0,0,0,1,0,0,0,1],!Ss(t,di,pi,mi,rr))?!1:(sr.crossVectors(wn,Cn),t=[sr.x,sr.y,sr.z],Ss(t,di,pi,mi,rr))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Kt).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Kt).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:(fn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),fn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),fn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),fn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),fn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),fn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),fn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),fn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(fn),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const fn=[new D,new D,new D,new D,new D,new D,new D,new D],Kt=new D,ir=new Zi,di=new D,pi=new D,mi=new D,wn=new D,Cn=new D,Wn=new D,Fi=new D,rr=new D,sr=new D,Xn=new D;function Ss(i,e,t,n,r){for(let s=0,a=i.length-3;s<=a;s+=3){Xn.fromArray(i,s);const o=r.x*Math.abs(Xn.x)+r.y*Math.abs(Xn.y)+r.z*Math.abs(Xn.z),c=e.dot(Xn),l=t.dot(Xn),u=n.dot(Xn);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>o)return!1}return!0}const gt=new D,ar=new Ce;let Mh=0;class $t extends Vn{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Mh++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Ra,this.updateRanges=[],this.gpuType=nn,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 r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[n+r];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++)ar.fromBufferAttribute(this,t),ar.applyMatrix3(e),this.setXY(t,ar.x,ar.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)gt.fromBufferAttribute(this,t),gt.applyMatrix3(e),this.setXYZ(t,gt.x,gt.y,gt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)gt.fromBufferAttribute(this,t),gt.applyMatrix4(e),this.setXYZ(t,gt.x,gt.y,gt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)gt.fromBufferAttribute(this,t),gt.applyNormalMatrix(e),this.setXYZ(t,gt.x,gt.y,gt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)gt.fromBufferAttribute(this,t),gt.transformDirection(e),this.setXYZ(t,gt.x,gt.y,gt.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=tn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Qe(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=tn(t,this.array)),t}setX(e,t){return this.normalized&&(t=Qe(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=tn(t,this.array)),t}setY(e,t){return this.normalized&&(t=Qe(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=tn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Qe(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=tn(t,this.array)),t}setW(e,t){return this.normalized&&(t=Qe(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Qe(t,this.array),n=Qe(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=Qe(t,this.array),n=Qe(n,this.array),r=Qe(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,s){return e*=this.itemSize,this.normalized&&(t=Qe(t,this.array),n=Qe(n,this.array),r=Qe(r,this.array),s=Qe(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Ra&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class Fl extends $t{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Ol extends $t{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class zt extends $t{constructor(e,t,n){super(new Float32Array(e),t,n)}}const Sh=new Zi,Oi=new D,Es=new D;class Yr{constructor(e=new D,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):Sh.setFromPoints(e).getCenter(n);let r=0;for(let s=0,a=e.length;s<a;s++)r=Math.max(r,n.distanceToSquared(e[s]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const 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;Oi.subVectors(e,this.center);const t=Oi.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),r=(n-this.radius)*.5;this.center.addScaledVector(Oi,r/n),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Es.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Oi.copy(e.center).add(Es)),this.expandByPoint(Oi.copy(e.center).sub(Es))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let Eh=0;const Vt=new at,ys=new Lt,_i=new D,Bt=new Zi,Bi=new Zi,Et=new D;class Xt extends Vn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Eh++}),this.uuid=Bn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(eh(e)?Ol:Fl)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,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 s=new Le().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return Vt.makeRotationFromQuaternion(e),this.applyMatrix4(Vt),this}rotateX(e){return Vt.makeRotationX(e),this.applyMatrix4(Vt),this}rotateY(e){return Vt.makeRotationY(e),this.applyMatrix4(Vt),this}rotateZ(e){return Vt.makeRotationZ(e),this.applyMatrix4(Vt),this}translate(e,t,n){return Vt.makeTranslation(e,t,n),this.applyMatrix4(Vt),this}scale(e,t,n){return Vt.makeScale(e,t,n),this.applyMatrix4(Vt),this}lookAt(e){return ys.lookAt(e),ys.updateMatrix(),this.applyMatrix4(ys.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(_i).negate(),this.translate(_i.x,_i.y,_i.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let r=0,s=e.length;r<s;r++){const a=e[r];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new zt(n,3))}else{const n=Math.min(e.length,t.count);for(let r=0;r<n;r++){const s=e[r];t.setXYZ(r,s.x,s.y,s.z||0)}e.length>t.count&&we("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Zi);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){He("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new D(-1/0,-1/0,-1/0),new D(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,r=t.length;n<r;n++){const s=t[n];Bt.setFromBufferAttribute(s),this.morphTargetsRelative?(Et.addVectors(this.boundingBox.min,Bt.min),this.boundingBox.expandByPoint(Et),Et.addVectors(this.boundingBox.max,Bt.max),this.boundingBox.expandByPoint(Et)):(this.boundingBox.expandByPoint(Bt.min),this.boundingBox.expandByPoint(Bt.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&He('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 Yr);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){He("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new D,1/0);return}if(e){const n=this.boundingSphere.center;if(Bt.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];Bi.setFromBufferAttribute(o),this.morphTargetsRelative?(Et.addVectors(Bt.min,Bi.min),Bt.expandByPoint(Et),Et.addVectors(Bt.max,Bi.max),Bt.expandByPoint(Et)):(Bt.expandByPoint(Bi.min),Bt.expandByPoint(Bi.max))}Bt.getCenter(n);let r=0;for(let s=0,a=e.count;s<a;s++)Et.fromBufferAttribute(e,s),r=Math.max(r,n.distanceToSquared(Et));if(t)for(let s=0,a=t.length;s<a;s++){const o=t[s],c=this.morphTargetsRelative;for(let l=0,u=o.count;l<u;l++)Et.fromBufferAttribute(o,l),c&&(_i.fromBufferAttribute(e,l),Et.add(_i)),r=Math.max(r,n.distanceToSquared(Et))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&He('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){He("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,r=t.normal,s=t.uv;let a=this.getAttribute("tangent");(a===void 0||a.count!==n.count)&&(a=new $t(new Float32Array(4*n.count),4),this.setAttribute("tangent",a));const o=[],c=[];for(let g=0;g<n.count;g++)o[g]=new D,c[g]=new D;const l=new D,u=new D,m=new D,h=new Ce,d=new Ce,x=new Ce,y=new D,_=new D;function f(g,T,U){l.fromBufferAttribute(n,g),u.fromBufferAttribute(n,T),m.fromBufferAttribute(n,U),h.fromBufferAttribute(s,g),d.fromBufferAttribute(s,T),x.fromBufferAttribute(s,U),u.sub(l),m.sub(l),d.sub(h),x.sub(h);const L=1/(d.x*x.y-x.x*d.y);isFinite(L)&&(y.copy(u).multiplyScalar(x.y).addScaledVector(m,-d.y).multiplyScalar(L),_.copy(m).multiplyScalar(d.x).addScaledVector(u,-x.x).multiplyScalar(L),o[g].add(y),o[T].add(y),o[U].add(y),c[g].add(_),c[T].add(_),c[U].add(_))}let w=this.groups;w.length===0&&(w=[{start:0,count:e.count}]);for(let g=0,T=w.length;g<T;++g){const U=w[g],L=U.start,z=U.count;for(let $=L,j=L+z;$<j;$+=3)f(e.getX($+0),e.getX($+1),e.getX($+2))}const C=new D,S=new D,R=new D,b=new D;function P(g){R.fromBufferAttribute(r,g),b.copy(R);const T=o[g];C.copy(T),C.sub(R.multiplyScalar(R.dot(T))).normalize(),S.crossVectors(b,T);const L=S.dot(c[g])<0?-1:1;a.setXYZW(g,C.x,C.y,C.z,L)}for(let g=0,T=w.length;g<T;++g){const U=w[g],L=U.start,z=U.count;for(let $=L,j=L+z;$<j;$+=3)P(e.getX($+0)),P(e.getX($+1)),P(e.getX($+2))}this._transformed=!0}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new $t(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let h=0,d=n.count;h<d;h++)n.setXYZ(h,0,0,0);const r=new D,s=new D,a=new D,o=new D,c=new D,l=new D,u=new D,m=new D;if(e)for(let h=0,d=e.count;h<d;h+=3){const x=e.getX(h+0),y=e.getX(h+1),_=e.getX(h+2);r.fromBufferAttribute(t,x),s.fromBufferAttribute(t,y),a.fromBufferAttribute(t,_),u.subVectors(a,s),m.subVectors(r,s),u.cross(m),o.fromBufferAttribute(n,x),c.fromBufferAttribute(n,y),l.fromBufferAttribute(n,_),o.add(u),c.add(u),l.add(u),n.setXYZ(x,o.x,o.y,o.z),n.setXYZ(y,c.x,c.y,c.z),n.setXYZ(_,l.x,l.y,l.z)}else for(let h=0,d=t.count;h<d;h+=3)r.fromBufferAttribute(t,h+0),s.fromBufferAttribute(t,h+1),a.fromBufferAttribute(t,h+2),u.subVectors(a,s),m.subVectors(r,s),u.cross(m),n.setXYZ(h+0,u.x,u.y,u.z),n.setXYZ(h+1,u.x,u.y,u.z),n.setXYZ(h+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++)Et.fromBufferAttribute(e,t),Et.normalize(),e.setXYZ(t,Et.x,Et.y,Et.z)}toNonIndexed(){function e(o,c){const l=o.array,u=o.itemSize,m=o.normalized,h=new l.constructor(c.length*u);let d=0,x=0;for(let y=0,_=c.length;y<_;y++){o.isInterleavedBufferAttribute?d=c[y]*o.data.stride+o.offset:d=c[y]*u;for(let f=0;f<u;f++)h[x++]=l[d++]}return new $t(h,u,m)}if(this.index===null)return we("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Xt,n=this.index.array,r=this.attributes;for(const o in r){const c=r[o],l=e(c,n);t.setAttribute(o,l)}const s=this.morphAttributes;for(const o in s){const c=[],l=s[o];for(let u=0,m=l.length;u<m;u++){const h=l[u],d=e(h,n);c.push(d)}t.morphAttributes[o]=c}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,c=a.length;o<c;o++){const l=a[o];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!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 r={};let s=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],u=[];for(let m=0,h=l.length;m<h;m++){const d=l[m];u.push(d.toJSON(e.data))}u.length>0&&(r[c]=u,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const r=e.attributes;for(const l in r){const u=r[l];this.setAttribute(l,u.clone(t))}const s=e.morphAttributes;for(const l in s){const u=[],m=s[l];for(let h=0,d=m.length;h<d;h++)u.push(m[h].clone(t));this.morphAttributes[l]=u}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let l=0,u=a.length;l<u;l++){const m=a[l];this.addGroup(m.start,m.count,m.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.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._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class yh{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Ra,this.updateRanges=[],this.version=0,this.uuid=Bn()}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 r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[n+r];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=Bn()),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=Bn()),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 Pt=new D;class Vr{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}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++)Pt.fromBufferAttribute(this,t),Pt.applyMatrix4(e),this.setXYZ(t,Pt.x,Pt.y,Pt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Pt.fromBufferAttribute(this,t),Pt.applyNormalMatrix(e),this.setXYZ(t,Pt.x,Pt.y,Pt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Pt.fromBufferAttribute(this,t),Pt.transformDirection(e),this.setXYZ(t,Pt.x,Pt.y,Pt.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=tn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Qe(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=Qe(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Qe(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Qe(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Qe(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=tn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=tn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=tn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=tn(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=Qe(t,this.array),n=Qe(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Qe(t,this.array),n=Qe(n,this.array),r=Qe(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=Qe(t,this.array),n=Qe(n,this.array),r=Qe(r,this.array),s=Qe(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){Gr("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new $t(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 Vr(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){Gr("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}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}}}let bh=0;class Ii extends Vn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:bh++}),this.uuid=Bn(),this.name="",this.type="Material",this.blending=On,this.side=zn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Gs,this.blendDst=Vs,this.blendEquation=Kn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ze(0,0,0),this.blendAlpha=0,this.depthFunc=Ci,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=co,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ai,this.stencilZFail=ai,this.stencilZPass=ai,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){we(`Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){we(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector2&&n&&n.isVector2||r&&r.isEuler&&n&&n.isEuler||r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(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.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),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!==On&&(n.blending=this.blending),this.side!==zn&&(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!==Gs&&(n.blendSrc=this.blendSrc),this.blendDst!==Vs&&(n.blendDst=this.blendDst),this.blendEquation!==Kn&&(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!==Ci&&(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!==co&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ai&&(n.stencilFail=this.stencilFail),this.stencilZFail!==ai&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==ai&&(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.allowOverride===!1&&(n.allowOverride=!1),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 r(s){const a=[];for(const o in s){const c=s[o];delete c.metadata,a.push(c)}return a}if(t){const s=r(e.textures),a=r(e.images);s.length>0&&(n.textures=s),a.length>0&&(n.images=a)}return n}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new ze().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let n=e.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new Ce().fromArray(n)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Ce().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}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 r=t.length;n=new Array(r);for(let s=0;s!==r;++s)n[s]=t[s].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.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class Bl extends Ii{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new ze(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 gi;const zi=new D,xi=new D,vi=new D,Mi=new Ce,Gi=new Ce,zl=new at,or=new D,Vi=new D,lr=new D,bo=new Ce,bs=new Ce,To=new Ce;class Th extends Lt{constructor(e=new Bl){if(super(),this.isSprite=!0,this.type="Sprite",gi===void 0){gi=new Xt;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 yh(t,5);gi.setIndex([0,1,2,0,2,3]),gi.setAttribute("position",new Vr(n,3,0,!1)),gi.setAttribute("uv",new Vr(n,2,3,!1))}this.geometry=gi,this.material=e,this.center=new Ce(.5,.5),this.count=1}raycast(e,t){e.camera===null&&He('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),xi.setFromMatrixScale(this.matrixWorld),zl.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),vi.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&xi.multiplyScalar(-vi.z);const n=this.material.rotation;let r,s;n!==0&&(s=Math.cos(n),r=Math.sin(n));const a=this.center;cr(or.set(-.5,-.5,0),vi,a,xi,r,s),cr(Vi.set(.5,-.5,0),vi,a,xi,r,s),cr(lr.set(.5,.5,0),vi,a,xi,r,s),bo.set(0,0),bs.set(1,0),To.set(1,1);let o=e.ray.intersectTriangle(or,Vi,lr,!1,zi);if(o===null&&(cr(Vi.set(-.5,.5,0),vi,a,xi,r,s),bs.set(0,1),o=e.ray.intersectTriangle(or,lr,Vi,!1,zi),o===null))return;const c=e.ray.origin.distanceTo(zi);c<e.near||c>e.far||t.push({distance:c,point:zi.clone(),uv:Wt.getInterpolation(zi,or,Vi,lr,bo,bs,To,new Ce),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 cr(i,e,t,n,r,s){Mi.subVectors(i,t).addScalar(.5).multiply(n),r!==void 0?(Gi.x=s*Mi.x-r*Mi.y,Gi.y=r*Mi.x+s*Mi.y):Gi.copy(Mi),i.copy(e),i.x+=Gi.x,i.y+=Gi.y,i.applyMatrix4(zl)}const dn=new D,Ts=new D,hr=new D,Pn=new D,As=new D,ur=new D,Rs=new D;class qr{constructor(e=new D,t=new D(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,dn)),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=dn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(dn.copy(this.origin).addScaledVector(this.direction,t),dn.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){Ts.copy(e).add(t).multiplyScalar(.5),hr.copy(t).sub(e).normalize(),Pn.copy(this.origin).sub(Ts);const s=e.distanceTo(t)*.5,a=-this.direction.dot(hr),o=Pn.dot(this.direction),c=-Pn.dot(hr),l=Pn.lengthSq(),u=Math.abs(1-a*a);let m,h,d,x;if(u>0)if(m=a*c-o,h=a*o-c,x=s*u,m>=0)if(h>=-x)if(h<=x){const y=1/u;m*=y,h*=y,d=m*(m+a*h+2*o)+h*(a*m+h+2*c)+l}else h=s,m=Math.max(0,-(a*h+o)),d=-m*m+h*(h+2*c)+l;else h=-s,m=Math.max(0,-(a*h+o)),d=-m*m+h*(h+2*c)+l;else h<=-x?(m=Math.max(0,-(-a*s+o)),h=m>0?-s:Math.min(Math.max(-s,-c),s),d=-m*m+h*(h+2*c)+l):h<=x?(m=0,h=Math.min(Math.max(-s,-c),s),d=h*(h+2*c)+l):(m=Math.max(0,-(a*s+o)),h=m>0?s:Math.min(Math.max(-s,-c),s),d=-m*m+h*(h+2*c)+l);else h=a>0?-s:s,m=Math.max(0,-(a*h+o)),d=-m*m+h*(h+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,m),r&&r.copy(Ts).addScaledVector(hr,h),d}intersectSphere(e,t){dn.subVectors(e.center,this.origin);const n=dn.dot(this.direction),r=dn.dot(dn)-n*n,s=e.radius*e.radius;if(r>s)return null;const a=Math.sqrt(s-r),o=n-a,c=n+a;return c<0?null:o<0?this.at(c,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const 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,r,s,a,o,c;const l=1/this.direction.x,u=1/this.direction.y,m=1/this.direction.z,h=this.origin;return l>=0?(n=(e.min.x-h.x)*l,r=(e.max.x-h.x)*l):(n=(e.max.x-h.x)*l,r=(e.min.x-h.x)*l),u>=0?(s=(e.min.y-h.y)*u,a=(e.max.y-h.y)*u):(s=(e.max.y-h.y)*u,a=(e.min.y-h.y)*u),n>a||s>r||((s>n||isNaN(n))&&(n=s),(a<r||isNaN(r))&&(r=a),m>=0?(o=(e.min.z-h.z)*m,c=(e.max.z-h.z)*m):(o=(e.max.z-h.z)*m,c=(e.min.z-h.z)*m),n>c||o>r)||((o>n||n!==n)&&(n=o),(c<r||r!==r)&&(r=c),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,dn)!==null}intersectTriangle(e,t,n,r,s){As.subVectors(t,e),ur.subVectors(n,e),Rs.crossVectors(As,ur);let a=this.direction.dot(Rs),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Pn.subVectors(this.origin,e);const c=o*this.direction.dot(ur.crossVectors(Pn,ur));if(c<0)return null;const l=o*this.direction.dot(As.cross(Pn));if(l<0||c+l>a)return null;const u=-o*Pn.dot(Rs);return u<0?null:this.at(u/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Gl extends Ii{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ze(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 ei,this.combine=gl,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 Ao=new at,Yn=new qr,fr=new Yr,Ro=new D,dr=new D,pr=new D,mr=new D,ws=new D,_r=new D,wo=new D,gr=new D;class Mn extends Lt{constructor(e=new Xt,t=new Gl){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,t){const n=this.geometry,r=n.attributes.position,s=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);const o=this.morphTargetInfluences;if(s&&o){_r.set(0,0,0);for(let c=0,l=s.length;c<l;c++){const u=o[c],m=s[c];u!==0&&(ws.fromBufferAttribute(m,e),a?_r.addScaledVector(ws,u):_r.addScaledVector(ws.sub(t),u))}t.add(_r)}return t}raycast(e,t){const n=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),fr.copy(n.boundingSphere),fr.applyMatrix4(s),Yn.copy(e.ray).recast(e.near),!(fr.containsPoint(Yn.origin)===!1&&(Yn.intersectSphere(fr,Ro)===null||Yn.origin.distanceToSquared(Ro)>(e.far-e.near)**2))&&(Ao.copy(s).invert(),Yn.copy(e.ray).applyMatrix4(Ao),!(n.boundingBox!==null&&Yn.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Yn)))}_computeIntersections(e,t,n){let r;const s=this.geometry,a=this.material,o=s.index,c=s.attributes.position,l=s.attributes.uv,u=s.attributes.uv1,m=s.attributes.normal,h=s.groups,d=s.drawRange;if(o!==null)if(Array.isArray(a))for(let x=0,y=h.length;x<y;x++){const _=h[x],f=a[_.materialIndex],w=Math.max(_.start,d.start),C=Math.min(o.count,Math.min(_.start+_.count,d.start+d.count));for(let S=w,R=C;S<R;S+=3){const b=o.getX(S),P=o.getX(S+1),g=o.getX(S+2);r=xr(this,f,e,n,l,u,m,b,P,g),r&&(r.faceIndex=Math.floor(S/3),r.face.materialIndex=_.materialIndex,t.push(r))}}else{const x=Math.max(0,d.start),y=Math.min(o.count,d.start+d.count);for(let _=x,f=y;_<f;_+=3){const w=o.getX(_),C=o.getX(_+1),S=o.getX(_+2);r=xr(this,a,e,n,l,u,m,w,C,S),r&&(r.faceIndex=Math.floor(_/3),t.push(r))}}else if(c!==void 0)if(Array.isArray(a))for(let x=0,y=h.length;x<y;x++){const _=h[x],f=a[_.materialIndex],w=Math.max(_.start,d.start),C=Math.min(c.count,Math.min(_.start+_.count,d.start+d.count));for(let S=w,R=C;S<R;S+=3){const b=S,P=S+1,g=S+2;r=xr(this,f,e,n,l,u,m,b,P,g),r&&(r.faceIndex=Math.floor(S/3),r.face.materialIndex=_.materialIndex,t.push(r))}}else{const x=Math.max(0,d.start),y=Math.min(c.count,d.start+d.count);for(let _=x,f=y;_<f;_+=3){const w=_,C=_+1,S=_+2;r=xr(this,a,e,n,l,u,m,w,C,S),r&&(r.faceIndex=Math.floor(_/3),t.push(r))}}}}function Ah(i,e,t,n,r,s,a,o){let c;if(e.side===Nt?c=n.intersectTriangle(a,s,r,!0,o):c=n.intersectTriangle(r,s,a,e.side===zn,o),c===null)return null;gr.copy(o),gr.applyMatrix4(i.matrixWorld);const l=t.ray.origin.distanceTo(gr);return l<t.near||l>t.far?null:{distance:l,point:gr.clone(),object:i}}function xr(i,e,t,n,r,s,a,o,c,l){i.getVertexPosition(o,dr),i.getVertexPosition(c,pr),i.getVertexPosition(l,mr);const u=Ah(i,e,t,n,dr,pr,mr,wo);if(u){const m=new D;Wt.getBarycoord(wo,dr,pr,mr,m),r&&(u.uv=Wt.getInterpolatedAttribute(r,o,c,l,m,new Ce)),s&&(u.uv1=Wt.getInterpolatedAttribute(s,o,c,l,m,new Ce)),a&&(u.normal=Wt.getInterpolatedAttribute(a,o,c,l,m,new D),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));const h={a:o,b:c,c:l,normal:new D,materialIndex:0};Wt.getNormal(dr,pr,mr,h.normal),u.face=h,u.barycoord=m}return u}class Rh extends Ct{constructor(e=null,t=1,n=1,r,s,a,o,c,l=bt,u=bt,m,h){super(null,a,o,c,l,u,r,s,m,h),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Cs=new D,wh=new D,Ch=new Le;class Ln{constructor(e=new D(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,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const r=Cs.subVectors(n,t).cross(wh.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){const r=e.delta(Cs),s=this.normal.dot(r);if(s===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/s;return n===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(r,a)}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||Ch.getNormalMatrix(e),r=this.coplanarPoint(Cs).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const qn=new Yr,Ph=new Ce(.5,.5),vr=new D;class Vl{constructor(e=new Ln,t=new Ln,n=new Ln,r=new Ln,s=new Ln,a=new Ln){this.planes=[e,t,n,r,s,a]}set(e,t,n,r,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(s),o[5].copy(a),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=rn,n=!1){const r=this.planes,s=e.elements,a=s[0],o=s[1],c=s[2],l=s[3],u=s[4],m=s[5],h=s[6],d=s[7],x=s[8],y=s[9],_=s[10],f=s[11],w=s[12],C=s[13],S=s[14],R=s[15];if(r[0].setComponents(l-a,d-u,f-x,R-w).normalize(),r[1].setComponents(l+a,d+u,f+x,R+w).normalize(),r[2].setComponents(l+o,d+m,f+y,R+C).normalize(),r[3].setComponents(l-o,d-m,f-y,R-C).normalize(),n)r[4].setComponents(c,h,_,S).normalize(),r[5].setComponents(l-c,d-h,f-_,R-S).normalize();else if(r[4].setComponents(l-c,d-h,f-_,R-S).normalize(),t===rn)r[5].setComponents(l+c,d+h,f+_,R+S).normalize();else if(t===Br)r[5].setComponents(c,h,_,S).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(),qn.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),qn.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(qn)}intersectsSprite(e){qn.center.set(0,0,0);const t=Ph.distanceTo(e.center);return qn.radius=.7071067811865476+t,qn.applyMatrix4(e.matrixWorld),this.intersectsSphere(qn)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const r=t[n];if(vr.x=r.normal.x>0?e.max.x:e.min.x,vr.y=r.normal.y>0?e.max.y:e.min.y,vr.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(vr)<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)}}class Hl extends Ii{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new ze(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 Hr=new D,kr=new D,Co=new at,Hi=new qr,Mr=new Yr,Ps=new D,Po=new D;class Dh extends Lt{constructor(e=new Xt,t=new Hl){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,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 r=1,s=t.count;r<s;r++)Hr.fromBufferAttribute(t,r-1),kr.fromBufferAttribute(t,r),n[r]=n[r-1],n[r]+=Hr.distanceTo(kr);e.setAttribute("lineDistance",new zt(n,1))}else we("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Mr.copy(n.boundingSphere),Mr.applyMatrix4(r),Mr.radius+=s,e.ray.intersectsSphere(Mr)===!1)return;Co.copy(r).invert(),Hi.copy(e.ray).applyMatrix4(Co);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=this.isLineSegments?2:1,u=n.index,h=n.attributes.position;if(u!==null){const d=Math.max(0,a.start),x=Math.min(u.count,a.start+a.count);for(let y=d,_=x-1;y<_;y+=l){const f=u.getX(y),w=u.getX(y+1),C=Sr(this,e,Hi,c,f,w,y);C&&t.push(C)}if(this.isLineLoop){const y=u.getX(x-1),_=u.getX(d),f=Sr(this,e,Hi,c,y,_,x-1);f&&t.push(f)}}else{const d=Math.max(0,a.start),x=Math.min(h.count,a.start+a.count);for(let y=d,_=x-1;y<_;y+=l){const f=Sr(this,e,Hi,c,y,y+1,y);f&&t.push(f)}if(this.isLineLoop){const y=Sr(this,e,Hi,c,x-1,d,x-1);y&&t.push(y)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function Sr(i,e,t,n,r,s,a){const o=i.geometry.attributes.position;if(Hr.fromBufferAttribute(o,r),kr.fromBufferAttribute(o,s),t.distanceSqToSegment(Hr,kr,Ps,Po)>n)return;Ps.applyMatrix4(i.matrixWorld);const l=e.ray.origin.distanceTo(Ps);if(!(l<e.near||l>e.far))return{distance:l,point:Po.clone().applyMatrix4(i.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:i}}const Do=new D,Lo=new D;class Lh extends Dh{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 r=0,s=t.count;r<s;r+=2)Do.fromBufferAttribute(t,r),Lo.fromBufferAttribute(t,r+1),n[r]=r===0?0:n[r-1],n[r+1]=n[r]+Do.distanceTo(Lo);e.setAttribute("lineDistance",new zt(n,1))}else we("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class kl extends Ct{constructor(e=[],t=Qn,n,r,s,a,o,c,l,u){super(e,t,n,r,s,a,o,c,l,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Ih extends Ct{constructor(e,t,n,r,s,a,o,c,l){super(e,t,n,r,s,a,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Di extends Ct{constructor(e,t,n=on,r,s,a,o=bt,c=bt,l,u=vn,m=1){if(u!==vn&&u!==Jn)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const h={width:e,height:t,depth:m};super(h,r,s,a,o,c,u,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Ha(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class Uh extends Di{constructor(e,t=on,n=Qn,r,s,a=bt,o=bt,c,l=vn){const u={width:e,height:e,depth:1},m=[u,u,u,u,u,u];super(e,e,t,n,r,s,a,o,c,l),this.image=m,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class Wl extends Ct{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class $i extends Xt{constructor(e=1,t=1,n=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:s,depthSegments:a};const o=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a);const c=[],l=[],u=[],m=[];let h=0,d=0;x("z","y","x",-1,-1,n,t,e,a,s,0),x("z","y","x",1,-1,n,t,-e,a,s,1),x("x","z","y",1,1,e,n,t,r,a,2),x("x","z","y",1,-1,e,n,-t,r,a,3),x("x","y","z",1,-1,e,t,n,r,s,4),x("x","y","z",-1,-1,e,t,-n,r,s,5),this.setIndex(c),this.setAttribute("position",new zt(l,3)),this.setAttribute("normal",new zt(u,3)),this.setAttribute("uv",new zt(m,2));function x(y,_,f,w,C,S,R,b,P,g,T){const U=S/P,L=R/g,z=S/2,$=R/2,j=b/2,H=P+1,Z=g+1;let X=0,te=0;const ie=new D;for(let fe=0;fe<Z;fe++){const me=fe*L-$;for(let Me=0;Me<H;Me++){const Xe=Me*U-z;ie[y]=Xe*w,ie[_]=me*C,ie[f]=j,l.push(ie.x,ie.y,ie.z),ie[y]=0,ie[_]=0,ie[f]=b>0?1:-1,u.push(ie.x,ie.y,ie.z),m.push(Me/P),m.push(1-fe/g),X+=1}}for(let fe=0;fe<g;fe++)for(let me=0;me<P;me++){const Me=h+me+H*fe,Xe=h+me+H*(fe+1),rt=h+(me+1)+H*(fe+1),Ye=h+(me+1)+H*fe;c.push(Me,Xe,Ye),c.push(Xe,rt,Ye),te+=6}o.addGroup(d,te,T),d+=te,h+=X}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new $i(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class Nh{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){we("Curve: .getPoint() not implemented.")}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,r=this.getPoint(0),s=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),s+=n.distanceTo(r),t.push(s),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){const n=this.getLengths();let r=0;const s=n.length;let a;t?a=t:a=e*n[s-1];let o=0,c=s-1,l;for(;o<=c;)if(r=Math.floor(o+(c-o)/2),l=n[r]-a,l<0)o=r+1;else if(l>0)c=r-1;else{c=r;break}if(r=c,n[r]===a)return r/(s-1);const u=n[r],h=n[r+1]-u,d=(a-u)/h;return(r+d)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);const a=this.getPoint(r),o=this.getPoint(s),c=t||(a.isVector2?new Ce:new D);return c.copy(o).sub(a).normalize(),c}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){const n=new D,r=[],s=[],a=[],o=new D,c=new at;for(let d=0;d<=e;d++){const x=d/e;r[d]=this.getTangentAt(x,new D)}s[0]=new D,a[0]=new D;let l=Number.MAX_VALUE;const u=Math.abs(r[0].x),m=Math.abs(r[0].y),h=Math.abs(r[0].z);u<=l&&(l=u,n.set(1,0,0)),m<=l&&(l=m,n.set(0,1,0)),h<=l&&n.set(0,0,1),o.crossVectors(r[0],n).normalize(),s[0].crossVectors(r[0],o),a[0].crossVectors(r[0],s[0]);for(let d=1;d<=e;d++){if(s[d]=s[d-1].clone(),a[d]=a[d-1].clone(),o.crossVectors(r[d-1],r[d]),o.length()>Number.EPSILON){o.normalize();const x=Math.acos(Be(r[d-1].dot(r[d]),-1,1));s[d].applyMatrix4(c.makeRotationAxis(o,x))}a[d].crossVectors(r[d],s[d])}if(t===!0){let d=Math.acos(Be(s[0].dot(s[e]),-1,1));d/=e,r[0].dot(o.crossVectors(s[0],s[e]))>0&&(d=-d);for(let x=1;x<=e;x++)s[x].applyMatrix4(c.makeRotationAxis(r[x],d*x)),a[x].crossVectors(r[x],s[x])}return{tangents:r,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}function Fh(i,e){const t=1-i;return t*t*e}function Oh(i,e){return 2*(1-i)*i*e}function Bh(i,e){return i*i*e}function Ds(i,e,t,n){return Fh(i,e)+Oh(i,t)+Bh(i,n)}class zh extends Nh{constructor(e=new D,t=new D,n=new D){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new D){const n=t,r=this.v0,s=this.v1,a=this.v2;return n.set(Ds(e,r.x,s.x,a.x),Ds(e,r.y,s.y,a.y),Ds(e,r.z,s.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}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 Kr extends Xt{constructor(e=1,t=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};const s=e/2,a=t/2,o=Math.floor(n),c=Math.floor(r),l=o+1,u=c+1,m=e/o,h=t/c,d=[],x=[],y=[],_=[];for(let f=0;f<u;f++){const w=f*h-a;for(let C=0;C<l;C++){const S=C*m-s;x.push(S,-w,0),y.push(0,0,1),_.push(C/o),_.push(1-f/c)}}for(let f=0;f<c;f++)for(let w=0;w<o;w++){const C=w+l*f,S=w+l*(f+1),R=w+1+l*(f+1),b=w+1+l*f;d.push(C,S,b),d.push(S,R,b)}this.setIndex(d),this.setAttribute("position",new zt(x,3)),this.setAttribute("normal",new zt(y,3)),this.setAttribute("uv",new zt(_,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Kr(e.width,e.height,e.widthSegments,e.heightSegments)}}function Li(i){const e={};for(const t in i){e[t]={};for(const n in i[t]){const r=i[t][n];if(Io(r))r.isRenderTargetTexture?(we("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=r.clone();else if(Array.isArray(r))if(Io(r[0])){const s=[];for(let a=0,o=r.length;a<o;a++)s[a]=r[a].clone();e[t][n]=s}else e[t][n]=r.slice();else e[t][n]=r}}return e}function Dt(i){const e={};for(let t=0;t<i.length;t++){const n=Li(i[t]);for(const r in n)e[r]=n[r]}return e}function Io(i){return i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)}function Gh(i){const e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function Xl(i){const e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:ke.workingColorSpace}const Vh={clone:Li,merge:Dt};var Hh=`void main() {
1
+ import{d as lc,s as es,C as cc,an as hc,w as ji,aq as uc,o as ts,c as ns,f as fc,Z as dc,$ as pc,al as mc,P as _c,n as gc,t as xc,b as io,Y as vc}from"./index-CW9H_fBd.js";import{b as Mc,a as ml,m as Sc}from"./index-2S80bo1s.js";import{n as _l}from"./relationship-galaxy-viewport-Cwfa51ER.js";import"./vendor-snapdom--nZvo8Sg.js";import"./LoadingState.vue_vue_type_script_setup_true_lang-BshQybD_.js";import"./people-page-header-D-LWaEqn.js";const Ia="185",Ti={ROTATE:0,DOLLY:1,PAN:2},bi={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Ec=0,ro=1,yc=2,wr=1,bc=2,Xi=3,zn=0,Nt=1,pn=2,_n=0,On=1,so=2,ao=3,oo=4,Tc=5,Kn=100,Ac=101,Rc=102,wc=103,Cc=104,Pc=200,Dc=201,Lc=202,Ic=203,Gs=204,Vs=205,Uc=206,Nc=207,Fc=208,Oc=209,Bc=210,zc=211,Gc=212,Vc=213,Hc=214,Hs=0,ks=1,Ws=2,Ci=3,Xs=4,Ys=5,qs=6,Ks=7,gl=0,kc=1,Wc=2,sn=0,xl=1,vl=2,Ml=3,Sl=4,El=5,yl=6,bl=7,Tl=300,Qn=301,Pi=302,is=303,rs=304,Yr=306,Zs=1e3,mn=1001,$s=1002,bt=1003,Xc=1004,er=1005,wt=1006,ss=1007,$n=1008,kt=1009,Al=1010,Rl=1011,qi=1012,Ua=1013,on=1014,nn=1015,xn=1016,Na=1017,Fa=1018,Ki=1020,wl=35902,Cl=35899,Pl=1021,Dl=1022,Zt=1023,vn=1026,Jn=1027,Ll=1028,Oa=1029,jn=1030,Ba=1031,za=1033,Cr=33776,Pr=33777,Dr=33778,Lr=33779,Js=35840,Qs=35841,js=35842,ea=35843,ta=36196,na=37492,ia=37496,ra=37488,sa=37489,Nr=37490,aa=37491,oa=37808,la=37809,ca=37810,ha=37811,ua=37812,fa=37813,da=37814,pa=37815,ma=37816,_a=37817,ga=37818,xa=37819,va=37820,Ma=37821,Sa=36492,Ea=36494,ya=36495,ba=36283,Ta=36284,Fr=36285,Aa=36286,Yc=3200,lo=0,qc=1,In="",Ut="srgb",Or="srgb-linear",Br="linear",$e="srgb",ai=7680,co=519,Kc=512,Zc=513,$c=514,Ga=515,Jc=516,Qc=517,Va=518,jc=519,Ra=35044,ho="300 es",rn=2e3,zr=2001;function eh(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function Gr(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function th(){const i=Gr("canvas");return i.style.display="block",i}const uo={};function Vr(...i){const e="THREE."+i.shift();console.log(e,...i)}function Il(i){const e=i[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=i[1];t&&t.isStackTrace?i[0]+=" "+t.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function we(...i){i=Il(i);const e="THREE."+i.shift();{const t=i[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...i)}}function He(...i){i=Il(i);const e="THREE."+i.shift();{const t=i[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...i)}}function Ai(...i){const e=i.join(" ");e in uo||(uo[e]=!0,we(...i))}function nh(i,e,t){return new Promise(function(n,r){function s(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:n()}}setTimeout(s,t)})}const ih={[Hs]:ks,[Ws]:qs,[Xs]:Ks,[Ci]:Ys,[ks]:Hs,[qs]:Ws,[Ks]:Xs,[Ys]:Ci};class Vn{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){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const r=n[e];if(r!==void 0){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const r=n.slice(0);for(let s=0,a=r.length;s<a;s++)r[s].call(this,e);e.target=null}}}const At=["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"],Ir=Math.PI/180,wa=180/Math.PI;function Bn(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(At[i&255]+At[i>>8&255]+At[i>>16&255]+At[i>>24&255]+"-"+At[e&255]+At[e>>8&255]+"-"+At[e>>16&15|64]+At[e>>24&255]+"-"+At[t&63|128]+At[t>>8&255]+"-"+At[t>>16&255]+At[t>>24&255]+At[n&255]+At[n>>8&255]+At[n>>16&255]+At[n>>24&255]).toLowerCase()}function Be(i,e,t){return Math.max(e,Math.min(t,i))}function rh(i,e){return(i%e+e)%e}function as(i,e,t){return(1-t)*i+t*e}function tn(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function Qe(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const sh={DEG2RAD:Ir},Ya=class Ya{constructor(e=0,t=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("THREE.Vector2: 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("THREE.Vector2: 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,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Be(this.x,e.x,t.x),this.y=Be(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Be(this.x,e,t),this.y=Be(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Be(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Be(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),r=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*n-a*r+e.x,this.y=s*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};Ya.prototype.isVector2=!0;let Ce=Ya;class Gn{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,s,a,o){let c=n[r+0],l=n[r+1],u=n[r+2],m=n[r+3],h=s[a+0],d=s[a+1],x=s[a+2],y=s[a+3];if(m!==y||c!==h||l!==d||u!==x){let _=c*h+l*d+u*x+m*y;_<0&&(h=-h,d=-d,x=-x,y=-y,_=-_);let f=1-o;if(_<.9995){const w=Math.acos(_),C=Math.sin(w);f=Math.sin(f*w)/C,o=Math.sin(o*w)/C,c=c*f+h*o,l=l*f+d*o,u=u*f+x*o,m=m*f+y*o}else{c=c*f+h*o,l=l*f+d*o,u=u*f+x*o,m=m*f+y*o;const w=1/Math.sqrt(c*c+l*l+u*u+m*m);c*=w,l*=w,u*=w,m*=w}}e[t]=c,e[t+1]=l,e[t+2]=u,e[t+3]=m}static multiplyQuaternionsFlat(e,t,n,r,s,a){const o=n[r],c=n[r+1],l=n[r+2],u=n[r+3],m=s[a],h=s[a+1],d=s[a+2],x=s[a+3];return e[t]=o*x+u*m+c*d-l*h,e[t+1]=c*x+u*h+l*m-o*d,e[t+2]=l*x+u*d+o*h-c*m,e[t+3]=u*x-o*m-c*h-l*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,r=e._y,s=e._z,a=e._order,o=Math.cos,c=Math.sin,l=o(n/2),u=o(r/2),m=o(s/2),h=c(n/2),d=c(r/2),x=c(s/2);switch(a){case"XYZ":this._x=h*u*m+l*d*x,this._y=l*d*m-h*u*x,this._z=l*u*x+h*d*m,this._w=l*u*m-h*d*x;break;case"YXZ":this._x=h*u*m+l*d*x,this._y=l*d*m-h*u*x,this._z=l*u*x-h*d*m,this._w=l*u*m+h*d*x;break;case"ZXY":this._x=h*u*m-l*d*x,this._y=l*d*m+h*u*x,this._z=l*u*x+h*d*m,this._w=l*u*m-h*d*x;break;case"ZYX":this._x=h*u*m-l*d*x,this._y=l*d*m+h*u*x,this._z=l*u*x-h*d*m,this._w=l*u*m+h*d*x;break;case"YZX":this._x=h*u*m+l*d*x,this._y=l*d*m+h*u*x,this._z=l*u*x-h*d*m,this._w=l*u*m-h*d*x;break;case"XZY":this._x=h*u*m-l*d*x,this._y=l*d*m-h*u*x,this._z=l*u*x+h*d*m,this._w=l*u*m+h*d*x;break;default:we("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],s=t[8],a=t[1],o=t[5],c=t[9],l=t[2],u=t[6],m=t[10],h=n+o+m;if(h>0){const d=.5/Math.sqrt(h+1);this._w=.25/d,this._x=(u-c)*d,this._y=(s-l)*d,this._z=(a-r)*d}else if(n>o&&n>m){const d=2*Math.sqrt(1+n-o-m);this._w=(u-c)/d,this._x=.25*d,this._y=(r+a)/d,this._z=(s+l)/d}else if(o>m){const d=2*Math.sqrt(1+o-n-m);this._w=(s-l)/d,this._x=(r+a)/d,this._y=.25*d,this._z=(c+u)/d}else{const d=2*Math.sqrt(1+m-n-o);this._w=(a-r)/d,this._x=(s+l)/d,this._y=(c+u)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(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(Be(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,r=e._y,s=e._z,a=e._w,o=t._x,c=t._y,l=t._z,u=t._w;return this._x=n*u+a*o+r*l-s*c,this._y=r*u+a*c+s*o-n*l,this._z=s*u+a*l+n*c-r*o,this._w=a*u-n*o-r*c-s*l,this._onChangeCallback(),this}slerp(e,t){let n=e._x,r=e._y,s=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,r=-r,s=-s,a=-a,o=-o);let c=1-t;if(o<.9995){const l=Math.acos(o),u=Math.sin(l);c=Math.sin(c*l)/u,t=Math.sin(t*l)/u,this._x=this._x*c+n*t,this._y=this._y*c+r*t,this._z=this._z*c+s*t,this._w=this._w*c+a*t,this._onChangeCallback()}else this._x=this._x*c+n*t,this._y=this._y*c+r*t,this._z=this._z*c+s*t,this._w=this._w*c+a*t,this.normalize();return 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(),r=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const qa=class qa{constructor(e=0,t=0,n=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("THREE.Vector3: 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("THREE.Vector3: 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(fo.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(fo.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*r,this.y=s[1]*t+s[4]*n+s[7]*r,this.z=s[2]*t+s[5]*n+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=e.elements,a=1/(s[3]*t+s[7]*n+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*r+s[12])*a,this.y=(s[1]*t+s[5]*n+s[9]*r+s[13])*a,this.z=(s[2]*t+s[6]*n+s[10]*r+s[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,s=e.x,a=e.y,o=e.z,c=e.w,l=2*(a*r-o*n),u=2*(o*t-s*r),m=2*(s*n-a*t);return this.x=t+c*l+a*m-o*u,this.y=n+c*u+o*l-s*m,this.z=r+c*m+s*u-a*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,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*r,this.y=s[1]*t+s[5]*n+s[9]*r,this.z=s[2]*t+s[6]*n+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Be(this.x,e.x,t.x),this.y=Be(this.y,e.y,t.y),this.z=Be(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Be(this.x,e,t),this.y=Be(this.y,e,t),this.z=Be(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Be(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,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,r=e.y,s=e.z,a=t.x,o=t.y,c=t.z;return this.x=r*c-s*o,this.y=s*a-n*c,this.z=n*o-r*a,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 os.copy(this).projectOnVector(e),this.sub(os)}reflect(e){return this.sub(os.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(Be(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*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(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,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}};qa.prototype.isVector3=!0;let D=qa;const os=new D,fo=new Gn,Ka=class Ka{constructor(e,t,n,r,s,a,o,c,l){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,o,c,l)}set(e,t,n,r,s,a,o,c,l){const u=this.elements;return u[0]=e,u[1]=r,u[2]=o,u[3]=t,u[4]=s,u[5]=c,u[6]=n,u[7]=a,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,r=t.elements,s=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],u=n[4],m=n[7],h=n[2],d=n[5],x=n[8],y=r[0],_=r[3],f=r[6],w=r[1],C=r[4],S=r[7],R=r[2],b=r[5],P=r[8];return s[0]=a*y+o*w+c*R,s[3]=a*_+o*C+c*b,s[6]=a*f+o*S+c*P,s[1]=l*y+u*w+m*R,s[4]=l*_+u*C+m*b,s[7]=l*f+u*S+m*P,s[2]=h*y+d*w+x*R,s[5]=h*_+d*C+x*b,s[8]=h*f+d*S+x*P,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],r=e[2],s=e[3],a=e[4],o=e[5],c=e[6],l=e[7],u=e[8];return t*a*u-t*o*l-n*s*u+n*o*c+r*s*l-r*a*c}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],c=e[6],l=e[7],u=e[8],m=u*a-o*l,h=o*c-u*s,d=l*s-a*c,x=t*m+n*h+r*d;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/x;return e[0]=m*y,e[1]=(r*l-u*n)*y,e[2]=(o*n-r*a)*y,e[3]=h*y,e[4]=(u*t-r*c)*y,e[5]=(r*s-o*t)*y,e[6]=d*y,e[7]=(n*c-l*t)*y,e[8]=(a*t-n*s)*y,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,r,s,a,o){const c=Math.cos(s),l=Math.sin(s);return this.set(n*c,n*l,-n*(c*a+l*o)+a+e,-r*l,r*c,-r*(-l*a+c*o)+o+t,0,0,1),this}scale(e,t){return Ai("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(ls.makeScale(e,t)),this}rotate(e){return Ai("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(ls.makeRotation(-e)),this}translate(e,t){return Ai("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(ls.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 r=0;r<9;r++)if(t[r]!==n[r])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)}};Ka.prototype.isMatrix3=!0;let Le=Ka;const ls=new Le,po=new Le().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),mo=new Le().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function ah(){const i={enabled:!0,workingColorSpace:Or,spaces:{},convert:function(r,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===$e&&(r.r=gn(r.r),r.g=gn(r.g),r.b=gn(r.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===$e&&(r.r=Ri(r.r),r.g=Ri(r.g),r.b=Ri(r.b))),r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===In?Br:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,a){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return Ai("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return Ai("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(r,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Or]:{primaries:e,whitePoint:n,transfer:Br,toXYZ:po,fromXYZ:mo,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Ut},outputColorSpaceConfig:{drawingBufferColorSpace:Ut}},[Ut]:{primaries:e,whitePoint:n,transfer:$e,toXYZ:po,fromXYZ:mo,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Ut}}}),i}const ke=ah();function gn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function Ri(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let oi;class oh{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{oi===void 0&&(oi=Gr("canvas")),oi.width=e.width,oi.height=e.height;const r=oi.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=oi}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Gr("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),s=r.data;for(let a=0;a<s.length;a++)s[a]=gn(s[a]/255)*255;return n.putImageData(r,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(gn(t[n]/255)*255):t[n]=gn(t[n]);return{data:t,width:e.width,height:e.height}}else return we("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let lh=0;class Ha{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:lh++}),this.uuid=Bn(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let a=0,o=r.length;a<o;a++)r[a].isDataTexture?s.push(cs(r[a].image)):s.push(cs(r[a]))}else s=cs(r);n.url=s}return t||(e.images[this.uuid]=n),n}}function cs(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?oh.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(we("Texture: Unable to serialize Texture."),{})}let ch=0;const hs=new D;class Ct extends Vn{constructor(e=Ct.DEFAULT_IMAGE,t=Ct.DEFAULT_MAPPING,n=mn,r=mn,s=wt,a=$n,o=Zt,c=kt,l=Ct.DEFAULT_ANISOTROPY,u=In){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:ch++}),this.uuid=Bn(),this.name="",this.source=new Ha(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=s,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=c,this.offset=new Ce(0,0),this.repeat=new Ce(1,1),this.center=new Ce(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Le,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(hs).x}get height(){return this.source.getSize(hs).y}get depth(){return this.source.getSize(hs).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const n=e[t];if(n===void 0){we(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){we(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}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.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,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!==Tl)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Zs:e.x=e.x-Math.floor(e.x);break;case mn:e.x=e.x<0?0:1;break;case $s:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Zs:e.y=e.y-Math.floor(e.y);break;case mn:e.y=e.y<0?0:1;break;case $s:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Ct.DEFAULT_IMAGE=null;Ct.DEFAULT_MAPPING=Tl;Ct.DEFAULT_ANISOTROPY=1;const Za=class Za{constructor(e=0,t=0,n=0,r=1){this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: 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("THREE.Vector4: 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,r=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*s,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*s,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*s,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,s;const c=e.elements,l=c[0],u=c[4],m=c[8],h=c[1],d=c[5],x=c[9],y=c[2],_=c[6],f=c[10];if(Math.abs(u-h)<.01&&Math.abs(m-y)<.01&&Math.abs(x-_)<.01){if(Math.abs(u+h)<.1&&Math.abs(m+y)<.1&&Math.abs(x+_)<.1&&Math.abs(l+d+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const C=(l+1)/2,S=(d+1)/2,R=(f+1)/2,b=(u+h)/4,P=(m+y)/4,g=(x+_)/4;return C>S&&C>R?C<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(C),r=b/n,s=P/n):S>R?S<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(S),n=b/r,s=g/r):R<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(R),n=P/s,r=g/s),this.set(n,r,s,t),this}let w=Math.sqrt((_-x)*(_-x)+(m-y)*(m-y)+(h-u)*(h-u));return Math.abs(w)<.001&&(w=1),this.x=(_-x)/w,this.y=(m-y)/w,this.z=(h-u)/w,this.w=Math.acos((l+d+f-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Be(this.x,e.x,t.x),this.y=Be(this.y,e.y,t.y),this.z=Be(this.z,e.z,t.z),this.w=Be(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Be(this.x,e,t),this.y=Be(this.y,e,t),this.z=Be(this.z,e,t),this.w=Be(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Be(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,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}};Za.prototype.isVector4=!0;let dt=Za;class hh extends Vn{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:wt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new dt(0,0,e,t),this.scissorTest=!1,this.viewport=new dt(0,0,e,t),this.textures=[];const r={width:e,height:t,depth:n.depth},s=new Ct(r),a=n.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){const t={minFilter:wt,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const r=Object.assign({},e.textures[t].image);this.textures[t].source=new Ha(r)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class an extends hh{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class Ul extends Ct{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=bt,this.minFilter=bt,this.wrapR=mn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class uh extends Ct{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=bt,this.minFilter=bt,this.wrapR=mn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Xr=class Xr{constructor(e,t,n,r,s,a,o,c,l,u,m,h,d,x,y,_){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,r,s,a,o,c,l,u,m,h,d,x,y,_)}set(e,t,n,r,s,a,o,c,l,u,m,h,d,x,y,_){const f=this.elements;return f[0]=e,f[4]=t,f[8]=n,f[12]=r,f[1]=s,f[5]=a,f[9]=o,f[13]=c,f[2]=l,f[6]=u,f[10]=m,f[14]=h,f[3]=d,f[7]=x,f[11]=y,f[15]=_,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 Xr().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 this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(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){if(e.determinantAffine()===0)return this.identity();const t=this.elements,n=e.elements,r=1/li.setFromMatrixColumn(e,0).length(),s=1/li.setFromMatrixColumn(e,1).length(),a=1/li.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,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,r=e.y,s=e.z,a=Math.cos(n),o=Math.sin(n),c=Math.cos(r),l=Math.sin(r),u=Math.cos(s),m=Math.sin(s);if(e.order==="XYZ"){const h=a*u,d=a*m,x=o*u,y=o*m;t[0]=c*u,t[4]=-c*m,t[8]=l,t[1]=d+x*l,t[5]=h-y*l,t[9]=-o*c,t[2]=y-h*l,t[6]=x+d*l,t[10]=a*c}else if(e.order==="YXZ"){const h=c*u,d=c*m,x=l*u,y=l*m;t[0]=h+y*o,t[4]=x*o-d,t[8]=a*l,t[1]=a*m,t[5]=a*u,t[9]=-o,t[2]=d*o-x,t[6]=y+h*o,t[10]=a*c}else if(e.order==="ZXY"){const h=c*u,d=c*m,x=l*u,y=l*m;t[0]=h-y*o,t[4]=-a*m,t[8]=x+d*o,t[1]=d+x*o,t[5]=a*u,t[9]=y-h*o,t[2]=-a*l,t[6]=o,t[10]=a*c}else if(e.order==="ZYX"){const h=a*u,d=a*m,x=o*u,y=o*m;t[0]=c*u,t[4]=x*l-d,t[8]=h*l+y,t[1]=c*m,t[5]=y*l+h,t[9]=d*l-x,t[2]=-l,t[6]=o*c,t[10]=a*c}else if(e.order==="YZX"){const h=a*c,d=a*l,x=o*c,y=o*l;t[0]=c*u,t[4]=y-h*m,t[8]=x*m+d,t[1]=m,t[5]=a*u,t[9]=-o*u,t[2]=-l*u,t[6]=d*m+x,t[10]=h-y*m}else if(e.order==="XZY"){const h=a*c,d=a*l,x=o*c,y=o*l;t[0]=c*u,t[4]=-m,t[8]=l*u,t[1]=h*m+y,t[5]=a*u,t[9]=d*m-x,t[2]=x*m-d,t[6]=o*u,t[10]=y*m+h}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(fh,e,dh)}lookAt(e,t,n){const r=this.elements;return Ot.subVectors(e,t),Ot.lengthSq()===0&&(Ot.z=1),Ot.normalize(),An.crossVectors(n,Ot),An.lengthSq()===0&&(Math.abs(n.z)===1?Ot.x+=1e-4:Ot.z+=1e-4,Ot.normalize(),An.crossVectors(n,Ot)),An.normalize(),tr.crossVectors(Ot,An),r[0]=An.x,r[4]=tr.x,r[8]=Ot.x,r[1]=An.y,r[5]=tr.y,r[9]=Ot.y,r[2]=An.z,r[6]=tr.z,r[10]=Ot.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,a=n[0],o=n[4],c=n[8],l=n[12],u=n[1],m=n[5],h=n[9],d=n[13],x=n[2],y=n[6],_=n[10],f=n[14],w=n[3],C=n[7],S=n[11],R=n[15],b=r[0],P=r[4],g=r[8],T=r[12],U=r[1],L=r[5],z=r[9],$=r[13],j=r[2],H=r[6],Z=r[10],X=r[14],te=r[3],ie=r[7],fe=r[11],me=r[15];return s[0]=a*b+o*U+c*j+l*te,s[4]=a*P+o*L+c*H+l*ie,s[8]=a*g+o*z+c*Z+l*fe,s[12]=a*T+o*$+c*X+l*me,s[1]=u*b+m*U+h*j+d*te,s[5]=u*P+m*L+h*H+d*ie,s[9]=u*g+m*z+h*Z+d*fe,s[13]=u*T+m*$+h*X+d*me,s[2]=x*b+y*U+_*j+f*te,s[6]=x*P+y*L+_*H+f*ie,s[10]=x*g+y*z+_*Z+f*fe,s[14]=x*T+y*$+_*X+f*me,s[3]=w*b+C*U+S*j+R*te,s[7]=w*P+C*L+S*H+R*ie,s[11]=w*g+C*z+S*Z+R*fe,s[15]=w*T+C*$+S*X+R*me,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],r=e[8],s=e[12],a=e[1],o=e[5],c=e[9],l=e[13],u=e[2],m=e[6],h=e[10],d=e[14],x=e[3],y=e[7],_=e[11],f=e[15],w=c*d-l*h,C=o*d-l*m,S=o*h-c*m,R=a*d-l*u,b=a*h-c*u,P=a*m-o*u;return t*(y*w-_*C+f*S)-n*(x*w-_*R+f*b)+r*(x*C-y*R+f*P)-s*(x*S-y*b+_*P)}determinantAffine(){const e=this.elements,t=e[0],n=e[4],r=e[8],s=e[1],a=e[5],o=e[9],c=e[2],l=e[6],u=e[10];return t*(a*u-o*l)-n*(s*u-o*c)+r*(s*l-a*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],c=e[6],l=e[7],u=e[8],m=e[9],h=e[10],d=e[11],x=e[12],y=e[13],_=e[14],f=e[15],w=t*o-n*a,C=t*c-r*a,S=t*l-s*a,R=n*c-r*o,b=n*l-s*o,P=r*l-s*c,g=u*y-m*x,T=u*_-h*x,U=u*f-d*x,L=m*_-h*y,z=m*f-d*y,$=h*f-d*_,j=w*$-C*z+S*L+R*U-b*T+P*g;if(j===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const H=1/j;return e[0]=(o*$-c*z+l*L)*H,e[1]=(r*z-n*$-s*L)*H,e[2]=(y*P-_*b+f*R)*H,e[3]=(h*b-m*P-d*R)*H,e[4]=(c*U-a*$-l*T)*H,e[5]=(t*$-r*U+s*T)*H,e[6]=(_*S-x*P-f*C)*H,e[7]=(u*P-h*S+d*C)*H,e[8]=(a*z-o*U+l*g)*H,e[9]=(n*U-t*z-s*g)*H,e[10]=(x*b-y*S+f*w)*H,e[11]=(m*S-u*b-d*w)*H,e[12]=(o*T-a*L-c*g)*H,e[13]=(t*L-n*T+r*g)*H,e[14]=(y*C-x*R-_*w)*H,e[15]=(u*R-m*C+h*w)*H,this}scale(e){const t=this.elements,n=e.x,r=e.y,s=e.z;return t[0]*=n,t[4]*=r,t[8]*=s,t[1]*=n,t[5]*=r,t[9]*=s,t[2]*=n,t[6]*=r,t[10]*=s,t[3]*=n,t[7]*=r,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}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),r=Math.sin(t),s=1-n,a=e.x,o=e.y,c=e.z,l=s*a,u=s*o;return this.set(l*a+n,l*o-r*c,l*c+r*o,0,l*o+r*c,u*o+n,u*c-r*a,0,l*c-r*o,u*c+r*a,s*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,r,s,a){return this.set(1,n,s,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,s=t._x,a=t._y,o=t._z,c=t._w,l=s+s,u=a+a,m=o+o,h=s*l,d=s*u,x=s*m,y=a*u,_=a*m,f=o*m,w=c*l,C=c*u,S=c*m,R=n.x,b=n.y,P=n.z;return r[0]=(1-(y+f))*R,r[1]=(d+S)*R,r[2]=(x-C)*R,r[3]=0,r[4]=(d-S)*b,r[5]=(1-(h+f))*b,r[6]=(_+w)*b,r[7]=0,r[8]=(x+C)*P,r[9]=(_-w)*P,r[10]=(1-(h+y))*P,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];const s=this.determinantAffine();if(s===0)return n.set(1,1,1),t.identity(),this;let a=li.set(r[0],r[1],r[2]).length();const o=li.set(r[4],r[5],r[6]).length(),c=li.set(r[8],r[9],r[10]).length();s<0&&(a=-a),Yt.copy(this);const l=1/a,u=1/o,m=1/c;return Yt.elements[0]*=l,Yt.elements[1]*=l,Yt.elements[2]*=l,Yt.elements[4]*=u,Yt.elements[5]*=u,Yt.elements[6]*=u,Yt.elements[8]*=m,Yt.elements[9]*=m,Yt.elements[10]*=m,t.setFromRotationMatrix(Yt),n.x=a,n.y=o,n.z=c,this}makePerspective(e,t,n,r,s,a,o=rn,c=!1){const l=this.elements,u=2*s/(t-e),m=2*s/(n-r),h=(t+e)/(t-e),d=(n+r)/(n-r);let x,y;if(c)x=s/(a-s),y=a*s/(a-s);else if(o===rn)x=-(a+s)/(a-s),y=-2*a*s/(a-s);else if(o===zr)x=-a/(a-s),y=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=u,l[4]=0,l[8]=h,l[12]=0,l[1]=0,l[5]=m,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=x,l[14]=y,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,r,s,a,o=rn,c=!1){const l=this.elements,u=2/(t-e),m=2/(n-r),h=-(t+e)/(t-e),d=-(n+r)/(n-r);let x,y;if(c)x=1/(a-s),y=a/(a-s);else if(o===rn)x=-2/(a-s),y=-(a+s)/(a-s);else if(o===zr)x=-1/(a-s),y=-s/(a-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=u,l[4]=0,l[8]=0,l[12]=h,l[1]=0,l[5]=m,l[9]=0,l[13]=d,l[2]=0,l[6]=0,l[10]=x,l[14]=y,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<16;r++)if(t[r]!==n[r])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}};Xr.prototype.isMatrix4=!0;let at=Xr;const li=new D,Yt=new at,fh=new D(0,0,0),dh=new D(1,1,1),An=new D,tr=new D,Ot=new D,_o=new at,go=new Gn;class ei{constructor(e=0,t=0,n=0,r=ei.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const r=e.elements,s=r[0],a=r[4],o=r[8],c=r[1],l=r[5],u=r[9],m=r[2],h=r[6],d=r[10];switch(t){case"XYZ":this._y=Math.asin(Be(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,d),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Be(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,d),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-m,s),this._z=0);break;case"ZXY":this._x=Math.asin(Be(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-m,d),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Be(m,-1,1)),Math.abs(m)<.9999999?(this._x=Math.atan2(h,d),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(Be(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-m,s)):(this._x=0,this._y=Math.atan2(o,d));break;case"XZY":this._z=Math.asin(-Be(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(h,l),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-u,d),this._y=0);break;default:we("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return _o.makeRotationFromQuaternion(e),this.setFromRotationMatrix(_o,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return go.setFromEuler(this),this.setFromQuaternion(go,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}}ei.DEFAULT_ORDER="XYZ";class ka{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 ph=0;const xo=new D,ci=new Gn,cn=new at,nr=new D,Ni=new D,mh=new D,_h=new Gn,vo=new D(1,0,0),Mo=new D(0,1,0),So=new D(0,0,1),Eo={type:"added"},gh={type:"removed"},hi={type:"childadded",child:null},us={type:"childremoved",child:null};class Lt extends Vn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:ph++}),this.uuid=Bn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Lt.DEFAULT_UP.clone();const e=new D,t=new ei,n=new Gn,r=new D(1,1,1);function s(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new at},normalMatrix:{value:new Le}}),this.matrix=new at,this.matrixWorld=new at,this.matrixAutoUpdate=Lt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Lt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new ka,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return ci.setFromAxisAngle(e,t),this.quaternion.multiply(ci),this}rotateOnWorldAxis(e,t){return ci.setFromAxisAngle(e,t),this.quaternion.premultiply(ci),this}rotateX(e){return this.rotateOnAxis(vo,e)}rotateY(e){return this.rotateOnAxis(Mo,e)}rotateZ(e){return this.rotateOnAxis(So,e)}translateOnAxis(e,t){return xo.copy(e).applyQuaternion(this.quaternion),this.position.add(xo.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(vo,e)}translateY(e){return this.translateOnAxis(Mo,e)}translateZ(e){return this.translateOnAxis(So,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(cn.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?nr.copy(e):nr.set(e,t,n);const r=this.parent;this.updateWorldMatrix(!0,!1),Ni.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?cn.lookAt(Ni,nr,this.up):cn.lookAt(nr,Ni,this.up),this.quaternion.setFromRotationMatrix(cn),r&&(cn.extractRotation(r.matrixWorld),ci.setFromRotationMatrix(cn),this.quaternion.premultiply(ci.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(He("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(Eo),hi.child=e,this.dispatchEvent(hi),hi.child=null):He("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(gh),us.child=e,this.dispatchEvent(us),us.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),cn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),cn.multiply(e.parent.matrixWorld)),e.applyMatrix4(cn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Eo),hi.child=e,this.dispatchEvent(hi),hi.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,r=this.children.length;n<r;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].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(Ni,e,mh),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ni,_h,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,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,r=t.length;n<r;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);const e=this.pivot;if(e!==null){const t=e.x,n=e.y,r=e.z,s=this.matrix.elements;s[12]+=t-s[0]*t-s[4]*n-s[8]*r,s[13]+=n-s[1]*t-s[5]*n-s[9]*r,s[14]+=r-s[2]*t-s[6]*n-s[10]*r}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){const r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),t===!0){const s=this.children;for(let a=0,o=s.length;a<o;a++)s[a].updateWorldMatrix(!1,!0,n)}}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.7,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),this.static!==!1&&(r.static=this.static),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(o=>({...o})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function s(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let l=0,u=c.length;l<u;l++){const m=c[l];s(e.shapes,m)}else s(e.shapes,c)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let c=0,l=this.material.length;c<l;c++)o.push(s(e.materials,this.material[c]));r.material=o}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let o=0;o<this.children.length;o++)r.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];r.animations.push(s(e.animations,c))}}if(t){const o=a(e.geometries),c=a(e.materials),l=a(e.textures),u=a(e.images),m=a(e.shapes),h=a(e.skeletons),d=a(e.animations),x=a(e.nodes);o.length>0&&(n.geometries=o),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),u.length>0&&(n.images=u),m.length>0&&(n.shapes=m),h.length>0&&(n.skeletons=h),d.length>0&&(n.animations=d),x.length>0&&(n.nodes=x)}return n.object=r,n;function a(o){const c=[];for(const l in o){const u=o[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.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const r=e.children[n];this.add(r.clone())}return this}}Lt.DEFAULT_UP=new D(0,1,0);Lt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Lt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Nn extends Lt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const xh={type:"move"};class fs{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Nn,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 Nn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new D,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new D),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Nn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new D,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new D,this._grip.eventsEnabled=!1),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 r=null,s=null,a=null;const o=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){a=!0;for(const y of e.hand.values()){const _=t.getJointPose(y,n),f=this._getHandJoint(l,y);_!==null&&(f.matrix.fromArray(_.transform.matrix),f.matrix.decompose(f.position,f.rotation,f.scale),f.matrixWorldNeedsUpdate=!0,f.jointRadius=_.radius),f.visible=_!==null}const u=l.joints["index-finger-tip"],m=l.joints["thumb-tip"],h=u.position.distanceTo(m.position),d=.02,x=.005;l.inputState.pinching&&h>d+x?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&h<=d-x&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1,c.eventsEnabled&&c.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(xh)))}return o!==null&&(o.visible=r!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Nn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const Nl={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},Rn={h:0,s:0,l:0},ir={h:0,s:0,l:0};function ds(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}class ze{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 r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ut){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,ke.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=ke.workingColorSpace){return this.r=e,this.g=t,this.b=n,ke.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=ke.workingColorSpace){if(e=rh(e,1),t=Be(t,0,1),n=Be(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,a=2*n-s;this.r=ds(a,s,e+1/3),this.g=ds(a,s,e),this.b=ds(a,s,e-1/3)}return ke.colorSpaceToWorking(this,r),this}setStyle(e,t=Ut){function n(s){s!==void 0&&parseFloat(s)<1&&we("Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=r[1],o=r[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:we("Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);we("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Ut){const n=Nl[e.toLowerCase()];return n!==void 0?this.setHex(n,t):we("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=gn(e.r),this.g=gn(e.g),this.b=gn(e.b),this}copyLinearToSRGB(e){return this.r=Ri(e.r),this.g=Ri(e.g),this.b=Ri(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ut){return ke.workingToColorSpace(Rt.copy(this),e),Math.round(Be(Rt.r*255,0,255))*65536+Math.round(Be(Rt.g*255,0,255))*256+Math.round(Be(Rt.b*255,0,255))}getHexString(e=Ut){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=ke.workingColorSpace){ke.workingToColorSpace(Rt.copy(this),t);const n=Rt.r,r=Rt.g,s=Rt.b,a=Math.max(n,r,s),o=Math.min(n,r,s);let c,l;const u=(o+a)/2;if(o===a)c=0,l=0;else{const m=a-o;switch(l=u<=.5?m/(a+o):m/(2-a-o),a){case n:c=(r-s)/m+(r<s?6:0);break;case r:c=(s-n)/m+2;break;case s:c=(n-r)/m+4;break}c/=6}return e.h=c,e.s=l,e.l=u,e}getRGB(e,t=ke.workingColorSpace){return ke.workingToColorSpace(Rt.copy(this),t),e.r=Rt.r,e.g=Rt.g,e.b=Rt.b,e}getStyle(e=Ut){ke.workingToColorSpace(Rt.copy(this),e);const t=Rt.r,n=Rt.g,r=Rt.b;return e!==Ut?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`}offsetHSL(e,t,n){return this.getHSL(Rn),this.setHSL(Rn.h+e,Rn.s+t,Rn.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(Rn),e.getHSL(ir);const n=as(Rn.h,ir.h,t),r=as(Rn.s,ir.s,t),s=as(Rn.l,ir.l,t);return this.setHSL(n,r,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*n+s[6]*r,this.g=s[1]*t+s[4]*n+s[7]*r,this.b=s[2]*t+s[5]*n+s[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Rt=new ze;ze.NAMES=Nl;class Wa{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new ze(e),this.density=t}clone(){return new Wa(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class vh extends Lt{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 ei,this.environmentIntensity=1,this.environmentRotation=new ei,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const qt=new D,hn=new D,ps=new D,un=new D,ui=new D,fi=new D,yo=new D,ms=new D,_s=new D,gs=new D,xs=new dt,vs=new dt,Ms=new dt;class Wt{constructor(e=new D,t=new D,n=new D){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),qt.subVectors(e,t),r.cross(qt);const s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,n,r,s){qt.subVectors(r,t),hn.subVectors(n,t),ps.subVectors(e,t);const a=qt.dot(qt),o=qt.dot(hn),c=qt.dot(ps),l=hn.dot(hn),u=hn.dot(ps),m=a*l-o*o;if(m===0)return s.set(0,0,0),null;const h=1/m,d=(l*c-o*u)*h,x=(a*u-o*c)*h;return s.set(1-d-x,x,d)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,un)===null?!1:un.x>=0&&un.y>=0&&un.x+un.y<=1}static getInterpolation(e,t,n,r,s,a,o,c){return this.getBarycoord(e,t,n,r,un)===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(s,un.x),c.addScaledVector(a,un.y),c.addScaledVector(o,un.z),c)}static getInterpolatedAttribute(e,t,n,r,s,a){return xs.setScalar(0),vs.setScalar(0),Ms.setScalar(0),xs.fromBufferAttribute(e,t),vs.fromBufferAttribute(e,n),Ms.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(xs,s.x),a.addScaledVector(vs,s.y),a.addScaledVector(Ms,s.z),a}static isFrontFacing(e,t,n,r){return qt.subVectors(n,t),hn.subVectors(e,t),qt.cross(hn).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return qt.subVectors(this.c,this.b),hn.subVectors(this.a,this.b),qt.cross(hn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Wt.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Wt.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,s){return Wt.getInterpolation(e,this.a,this.b,this.c,t,n,r,s)}containsPoint(e){return Wt.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Wt.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,r=this.b,s=this.c;let a,o;ui.subVectors(r,n),fi.subVectors(s,n),ms.subVectors(e,n);const c=ui.dot(ms),l=fi.dot(ms);if(c<=0&&l<=0)return t.copy(n);_s.subVectors(e,r);const u=ui.dot(_s),m=fi.dot(_s);if(u>=0&&m<=u)return t.copy(r);const h=c*m-u*l;if(h<=0&&c>=0&&u<=0)return a=c/(c-u),t.copy(n).addScaledVector(ui,a);gs.subVectors(e,s);const d=ui.dot(gs),x=fi.dot(gs);if(x>=0&&d<=x)return t.copy(s);const y=d*l-c*x;if(y<=0&&l>=0&&x<=0)return o=l/(l-x),t.copy(n).addScaledVector(fi,o);const _=u*x-d*m;if(_<=0&&m-u>=0&&d-x>=0)return yo.subVectors(s,r),o=(m-u)/(m-u+(d-x)),t.copy(r).addScaledVector(yo,o);const f=1/(_+y+h);return a=y*f,o=h*f,t.copy(n).addScaledVector(ui,a).addScaledVector(fi,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Zi{constructor(e=new D(1/0,1/0,1/0),t=new D(-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(Kt.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Kt.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=Kt.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 s=n.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,Kt):Kt.fromBufferAttribute(s,a),Kt.applyMatrix4(e.matrixWorld),this.expandByPoint(Kt);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),rr.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),rr.copy(n.boundingBox)),rr.applyMatrix4(e.matrixWorld),this.union(rr)}const r=e.children;for(let s=0,a=r.length;s<a;s++)this.expandByObject(r[s],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Kt),Kt.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(Fi),sr.subVectors(this.max,Fi),di.subVectors(e.a,Fi),pi.subVectors(e.b,Fi),mi.subVectors(e.c,Fi),wn.subVectors(pi,di),Cn.subVectors(mi,pi),Wn.subVectors(di,mi);let t=[0,-wn.z,wn.y,0,-Cn.z,Cn.y,0,-Wn.z,Wn.y,wn.z,0,-wn.x,Cn.z,0,-Cn.x,Wn.z,0,-Wn.x,-wn.y,wn.x,0,-Cn.y,Cn.x,0,-Wn.y,Wn.x,0];return!Ss(t,di,pi,mi,sr)||(t=[1,0,0,0,1,0,0,0,1],!Ss(t,di,pi,mi,sr))?!1:(ar.crossVectors(wn,Cn),t=[ar.x,ar.y,ar.z],Ss(t,di,pi,mi,sr))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Kt).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Kt).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:(fn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),fn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),fn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),fn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),fn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),fn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),fn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),fn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(fn),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const fn=[new D,new D,new D,new D,new D,new D,new D,new D],Kt=new D,rr=new Zi,di=new D,pi=new D,mi=new D,wn=new D,Cn=new D,Wn=new D,Fi=new D,sr=new D,ar=new D,Xn=new D;function Ss(i,e,t,n,r){for(let s=0,a=i.length-3;s<=a;s+=3){Xn.fromArray(i,s);const o=r.x*Math.abs(Xn.x)+r.y*Math.abs(Xn.y)+r.z*Math.abs(Xn.z),c=e.dot(Xn),l=t.dot(Xn),u=n.dot(Xn);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>o)return!1}return!0}const gt=new D,or=new Ce;let Mh=0;class $t extends Vn{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Mh++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Ra,this.updateRanges=[],this.gpuType=nn,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 r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[n+r];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++)or.fromBufferAttribute(this,t),or.applyMatrix3(e),this.setXY(t,or.x,or.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)gt.fromBufferAttribute(this,t),gt.applyMatrix3(e),this.setXYZ(t,gt.x,gt.y,gt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)gt.fromBufferAttribute(this,t),gt.applyMatrix4(e),this.setXYZ(t,gt.x,gt.y,gt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)gt.fromBufferAttribute(this,t),gt.applyNormalMatrix(e),this.setXYZ(t,gt.x,gt.y,gt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)gt.fromBufferAttribute(this,t),gt.transformDirection(e),this.setXYZ(t,gt.x,gt.y,gt.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=tn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Qe(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=tn(t,this.array)),t}setX(e,t){return this.normalized&&(t=Qe(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=tn(t,this.array)),t}setY(e,t){return this.normalized&&(t=Qe(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=tn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Qe(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=tn(t,this.array)),t}setW(e,t){return this.normalized&&(t=Qe(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Qe(t,this.array),n=Qe(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=Qe(t,this.array),n=Qe(n,this.array),r=Qe(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,s){return e*=this.itemSize,this.normalized&&(t=Qe(t,this.array),n=Qe(n,this.array),r=Qe(r,this.array),s=Qe(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=s,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Ra&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class Fl extends $t{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Ol extends $t{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class zt extends $t{constructor(e,t,n){super(new Float32Array(e),t,n)}}const Sh=new Zi,Oi=new D,Es=new D;class qr{constructor(e=new D,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):Sh.setFromPoints(e).getCenter(n);let r=0;for(let s=0,a=e.length;s<a;s++)r=Math.max(r,n.distanceToSquared(e[s]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const 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;Oi.subVectors(e,this.center);const t=Oi.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),r=(n-this.radius)*.5;this.center.addScaledVector(Oi,r/n),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Es.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Oi.copy(e.center).add(Es)),this.expandByPoint(Oi.copy(e.center).sub(Es))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let Eh=0;const Vt=new at,ys=new Lt,_i=new D,Bt=new Zi,Bi=new Zi,Et=new D;class Xt extends Vn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Eh++}),this.uuid=Bn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(eh(e)?Ol:Fl)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,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 s=new Le().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return Vt.makeRotationFromQuaternion(e),this.applyMatrix4(Vt),this}rotateX(e){return Vt.makeRotationX(e),this.applyMatrix4(Vt),this}rotateY(e){return Vt.makeRotationY(e),this.applyMatrix4(Vt),this}rotateZ(e){return Vt.makeRotationZ(e),this.applyMatrix4(Vt),this}translate(e,t,n){return Vt.makeTranslation(e,t,n),this.applyMatrix4(Vt),this}scale(e,t,n){return Vt.makeScale(e,t,n),this.applyMatrix4(Vt),this}lookAt(e){return ys.lookAt(e),ys.updateMatrix(),this.applyMatrix4(ys.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(_i).negate(),this.translate(_i.x,_i.y,_i.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let r=0,s=e.length;r<s;r++){const a=e[r];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new zt(n,3))}else{const n=Math.min(e.length,t.count);for(let r=0;r<n;r++){const s=e[r];t.setXYZ(r,s.x,s.y,s.z||0)}e.length>t.count&&we("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Zi);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){He("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new D(-1/0,-1/0,-1/0),new D(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,r=t.length;n<r;n++){const s=t[n];Bt.setFromBufferAttribute(s),this.morphTargetsRelative?(Et.addVectors(this.boundingBox.min,Bt.min),this.boundingBox.expandByPoint(Et),Et.addVectors(this.boundingBox.max,Bt.max),this.boundingBox.expandByPoint(Et)):(this.boundingBox.expandByPoint(Bt.min),this.boundingBox.expandByPoint(Bt.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&He('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 qr);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){He("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new D,1/0);return}if(e){const n=this.boundingSphere.center;if(Bt.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];Bi.setFromBufferAttribute(o),this.morphTargetsRelative?(Et.addVectors(Bt.min,Bi.min),Bt.expandByPoint(Et),Et.addVectors(Bt.max,Bi.max),Bt.expandByPoint(Et)):(Bt.expandByPoint(Bi.min),Bt.expandByPoint(Bi.max))}Bt.getCenter(n);let r=0;for(let s=0,a=e.count;s<a;s++)Et.fromBufferAttribute(e,s),r=Math.max(r,n.distanceToSquared(Et));if(t)for(let s=0,a=t.length;s<a;s++){const o=t[s],c=this.morphTargetsRelative;for(let l=0,u=o.count;l<u;l++)Et.fromBufferAttribute(o,l),c&&(_i.fromBufferAttribute(e,l),Et.add(_i)),r=Math.max(r,n.distanceToSquared(Et))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&He('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){He("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,r=t.normal,s=t.uv;let a=this.getAttribute("tangent");(a===void 0||a.count!==n.count)&&(a=new $t(new Float32Array(4*n.count),4),this.setAttribute("tangent",a));const o=[],c=[];for(let g=0;g<n.count;g++)o[g]=new D,c[g]=new D;const l=new D,u=new D,m=new D,h=new Ce,d=new Ce,x=new Ce,y=new D,_=new D;function f(g,T,U){l.fromBufferAttribute(n,g),u.fromBufferAttribute(n,T),m.fromBufferAttribute(n,U),h.fromBufferAttribute(s,g),d.fromBufferAttribute(s,T),x.fromBufferAttribute(s,U),u.sub(l),m.sub(l),d.sub(h),x.sub(h);const L=1/(d.x*x.y-x.x*d.y);isFinite(L)&&(y.copy(u).multiplyScalar(x.y).addScaledVector(m,-d.y).multiplyScalar(L),_.copy(m).multiplyScalar(d.x).addScaledVector(u,-x.x).multiplyScalar(L),o[g].add(y),o[T].add(y),o[U].add(y),c[g].add(_),c[T].add(_),c[U].add(_))}let w=this.groups;w.length===0&&(w=[{start:0,count:e.count}]);for(let g=0,T=w.length;g<T;++g){const U=w[g],L=U.start,z=U.count;for(let $=L,j=L+z;$<j;$+=3)f(e.getX($+0),e.getX($+1),e.getX($+2))}const C=new D,S=new D,R=new D,b=new D;function P(g){R.fromBufferAttribute(r,g),b.copy(R);const T=o[g];C.copy(T),C.sub(R.multiplyScalar(R.dot(T))).normalize(),S.crossVectors(b,T);const L=S.dot(c[g])<0?-1:1;a.setXYZW(g,C.x,C.y,C.z,L)}for(let g=0,T=w.length;g<T;++g){const U=w[g],L=U.start,z=U.count;for(let $=L,j=L+z;$<j;$+=3)P(e.getX($+0)),P(e.getX($+1)),P(e.getX($+2))}this._transformed=!0}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new $t(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let h=0,d=n.count;h<d;h++)n.setXYZ(h,0,0,0);const r=new D,s=new D,a=new D,o=new D,c=new D,l=new D,u=new D,m=new D;if(e)for(let h=0,d=e.count;h<d;h+=3){const x=e.getX(h+0),y=e.getX(h+1),_=e.getX(h+2);r.fromBufferAttribute(t,x),s.fromBufferAttribute(t,y),a.fromBufferAttribute(t,_),u.subVectors(a,s),m.subVectors(r,s),u.cross(m),o.fromBufferAttribute(n,x),c.fromBufferAttribute(n,y),l.fromBufferAttribute(n,_),o.add(u),c.add(u),l.add(u),n.setXYZ(x,o.x,o.y,o.z),n.setXYZ(y,c.x,c.y,c.z),n.setXYZ(_,l.x,l.y,l.z)}else for(let h=0,d=t.count;h<d;h+=3)r.fromBufferAttribute(t,h+0),s.fromBufferAttribute(t,h+1),a.fromBufferAttribute(t,h+2),u.subVectors(a,s),m.subVectors(r,s),u.cross(m),n.setXYZ(h+0,u.x,u.y,u.z),n.setXYZ(h+1,u.x,u.y,u.z),n.setXYZ(h+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++)Et.fromBufferAttribute(e,t),Et.normalize(),e.setXYZ(t,Et.x,Et.y,Et.z)}toNonIndexed(){function e(o,c){const l=o.array,u=o.itemSize,m=o.normalized,h=new l.constructor(c.length*u);let d=0,x=0;for(let y=0,_=c.length;y<_;y++){o.isInterleavedBufferAttribute?d=c[y]*o.data.stride+o.offset:d=c[y]*u;for(let f=0;f<u;f++)h[x++]=l[d++]}return new $t(h,u,m)}if(this.index===null)return we("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Xt,n=this.index.array,r=this.attributes;for(const o in r){const c=r[o],l=e(c,n);t.setAttribute(o,l)}const s=this.morphAttributes;for(const o in s){const c=[],l=s[o];for(let u=0,m=l.length;u<m;u++){const h=l[u],d=e(h,n);c.push(d)}t.morphAttributes[o]=c}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,c=a.length;o<c;o++){const l=a[o];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!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 r={};let s=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],u=[];for(let m=0,h=l.length;m<h;m++){const d=l[m];u.push(d.toJSON(e.data))}u.length>0&&(r[c]=u,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const r=e.attributes;for(const l in r){const u=r[l];this.setAttribute(l,u.clone(t))}const s=e.morphAttributes;for(const l in s){const u=[],m=s[l];for(let h=0,d=m.length;h<d;h++)u.push(m[h].clone(t));this.morphAttributes[l]=u}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let l=0,u=a.length;l<u;l++){const m=a[l];this.addGroup(m.start,m.count,m.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.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._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class yh{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Ra,this.updateRanges=[],this.version=0,this.uuid=Bn()}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 r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[n+r];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=Bn()),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=Bn()),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 Pt=new D;class Hr{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}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++)Pt.fromBufferAttribute(this,t),Pt.applyMatrix4(e),this.setXYZ(t,Pt.x,Pt.y,Pt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Pt.fromBufferAttribute(this,t),Pt.applyNormalMatrix(e),this.setXYZ(t,Pt.x,Pt.y,Pt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Pt.fromBufferAttribute(this,t),Pt.transformDirection(e),this.setXYZ(t,Pt.x,Pt.y,Pt.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=tn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Qe(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=Qe(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Qe(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Qe(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Qe(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=tn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=tn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=tn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=tn(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=Qe(t,this.array),n=Qe(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Qe(t,this.array),n=Qe(n,this.array),r=Qe(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=Qe(t,this.array),n=Qe(n,this.array),r=Qe(r,this.array),s=Qe(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){Vr("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new $t(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 Hr(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){Vr("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}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}}}let bh=0;class Ii extends Vn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:bh++}),this.uuid=Bn(),this.name="",this.type="Material",this.blending=On,this.side=zn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Gs,this.blendDst=Vs,this.blendEquation=Kn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ze(0,0,0),this.blendAlpha=0,this.depthFunc=Ci,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=co,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ai,this.stencilZFail=ai,this.stencilZPass=ai,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){we(`Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){we(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector2&&n&&n.isVector2||r&&r.isEuler&&n&&n.isEuler||r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(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.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),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!==On&&(n.blending=this.blending),this.side!==zn&&(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!==Gs&&(n.blendSrc=this.blendSrc),this.blendDst!==Vs&&(n.blendDst=this.blendDst),this.blendEquation!==Kn&&(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!==Ci&&(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!==co&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ai&&(n.stencilFail=this.stencilFail),this.stencilZFail!==ai&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==ai&&(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.allowOverride===!1&&(n.allowOverride=!1),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 r(s){const a=[];for(const o in s){const c=s[o];delete c.metadata,a.push(c)}return a}if(t){const s=r(e.textures),a=r(e.images);s.length>0&&(n.textures=s),a.length>0&&(n.images=a)}return n}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new ze().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let n=e.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new Ce().fromArray(n)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Ce().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}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 r=t.length;n=new Array(r);for(let s=0;s!==r;++s)n[s]=t[s].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.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class Bl extends Ii{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new ze(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 gi;const zi=new D,xi=new D,vi=new D,Mi=new Ce,Gi=new Ce,zl=new at,lr=new D,Vi=new D,cr=new D,bo=new Ce,bs=new Ce,To=new Ce;class Th extends Lt{constructor(e=new Bl){if(super(),this.isSprite=!0,this.type="Sprite",gi===void 0){gi=new Xt;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 yh(t,5);gi.setIndex([0,1,2,0,2,3]),gi.setAttribute("position",new Hr(n,3,0,!1)),gi.setAttribute("uv",new Hr(n,2,3,!1))}this.geometry=gi,this.material=e,this.center=new Ce(.5,.5),this.count=1}raycast(e,t){e.camera===null&&He('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),xi.setFromMatrixScale(this.matrixWorld),zl.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),vi.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&xi.multiplyScalar(-vi.z);const n=this.material.rotation;let r,s;n!==0&&(s=Math.cos(n),r=Math.sin(n));const a=this.center;hr(lr.set(-.5,-.5,0),vi,a,xi,r,s),hr(Vi.set(.5,-.5,0),vi,a,xi,r,s),hr(cr.set(.5,.5,0),vi,a,xi,r,s),bo.set(0,0),bs.set(1,0),To.set(1,1);let o=e.ray.intersectTriangle(lr,Vi,cr,!1,zi);if(o===null&&(hr(Vi.set(-.5,.5,0),vi,a,xi,r,s),bs.set(0,1),o=e.ray.intersectTriangle(lr,cr,Vi,!1,zi),o===null))return;const c=e.ray.origin.distanceTo(zi);c<e.near||c>e.far||t.push({distance:c,point:zi.clone(),uv:Wt.getInterpolation(zi,lr,Vi,cr,bo,bs,To,new Ce),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 hr(i,e,t,n,r,s){Mi.subVectors(i,t).addScalar(.5).multiply(n),r!==void 0?(Gi.x=s*Mi.x-r*Mi.y,Gi.y=r*Mi.x+s*Mi.y):Gi.copy(Mi),i.copy(e),i.x+=Gi.x,i.y+=Gi.y,i.applyMatrix4(zl)}const dn=new D,Ts=new D,ur=new D,Pn=new D,As=new D,fr=new D,Rs=new D;class Kr{constructor(e=new D,t=new D(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,dn)),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=dn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(dn.copy(this.origin).addScaledVector(this.direction,t),dn.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){Ts.copy(e).add(t).multiplyScalar(.5),ur.copy(t).sub(e).normalize(),Pn.copy(this.origin).sub(Ts);const s=e.distanceTo(t)*.5,a=-this.direction.dot(ur),o=Pn.dot(this.direction),c=-Pn.dot(ur),l=Pn.lengthSq(),u=Math.abs(1-a*a);let m,h,d,x;if(u>0)if(m=a*c-o,h=a*o-c,x=s*u,m>=0)if(h>=-x)if(h<=x){const y=1/u;m*=y,h*=y,d=m*(m+a*h+2*o)+h*(a*m+h+2*c)+l}else h=s,m=Math.max(0,-(a*h+o)),d=-m*m+h*(h+2*c)+l;else h=-s,m=Math.max(0,-(a*h+o)),d=-m*m+h*(h+2*c)+l;else h<=-x?(m=Math.max(0,-(-a*s+o)),h=m>0?-s:Math.min(Math.max(-s,-c),s),d=-m*m+h*(h+2*c)+l):h<=x?(m=0,h=Math.min(Math.max(-s,-c),s),d=h*(h+2*c)+l):(m=Math.max(0,-(a*s+o)),h=m>0?s:Math.min(Math.max(-s,-c),s),d=-m*m+h*(h+2*c)+l);else h=a>0?-s:s,m=Math.max(0,-(a*h+o)),d=-m*m+h*(h+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,m),r&&r.copy(Ts).addScaledVector(ur,h),d}intersectSphere(e,t){dn.subVectors(e.center,this.origin);const n=dn.dot(this.direction),r=dn.dot(dn)-n*n,s=e.radius*e.radius;if(r>s)return null;const a=Math.sqrt(s-r),o=n-a,c=n+a;return c<0?null:o<0?this.at(c,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const 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,r,s,a,o,c;const l=1/this.direction.x,u=1/this.direction.y,m=1/this.direction.z,h=this.origin;return l>=0?(n=(e.min.x-h.x)*l,r=(e.max.x-h.x)*l):(n=(e.max.x-h.x)*l,r=(e.min.x-h.x)*l),u>=0?(s=(e.min.y-h.y)*u,a=(e.max.y-h.y)*u):(s=(e.max.y-h.y)*u,a=(e.min.y-h.y)*u),n>a||s>r||((s>n||isNaN(n))&&(n=s),(a<r||isNaN(r))&&(r=a),m>=0?(o=(e.min.z-h.z)*m,c=(e.max.z-h.z)*m):(o=(e.max.z-h.z)*m,c=(e.min.z-h.z)*m),n>c||o>r)||((o>n||n!==n)&&(n=o),(c<r||r!==r)&&(r=c),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,dn)!==null}intersectTriangle(e,t,n,r,s){As.subVectors(t,e),fr.subVectors(n,e),Rs.crossVectors(As,fr);let a=this.direction.dot(Rs),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Pn.subVectors(this.origin,e);const c=o*this.direction.dot(fr.crossVectors(Pn,fr));if(c<0)return null;const l=o*this.direction.dot(As.cross(Pn));if(l<0||c+l>a)return null;const u=-o*Pn.dot(Rs);return u<0?null:this.at(u/a,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Gl extends Ii{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ze(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 ei,this.combine=gl,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 Ao=new at,Yn=new Kr,dr=new qr,Ro=new D,pr=new D,mr=new D,_r=new D,ws=new D,gr=new D,wo=new D,xr=new D;class Mn extends Lt{constructor(e=new Xt,t=new Gl){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,t){const n=this.geometry,r=n.attributes.position,s=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);const o=this.morphTargetInfluences;if(s&&o){gr.set(0,0,0);for(let c=0,l=s.length;c<l;c++){const u=o[c],m=s[c];u!==0&&(ws.fromBufferAttribute(m,e),a?gr.addScaledVector(ws,u):gr.addScaledVector(ws.sub(t),u))}t.add(gr)}return t}raycast(e,t){const n=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),dr.copy(n.boundingSphere),dr.applyMatrix4(s),Yn.copy(e.ray).recast(e.near),!(dr.containsPoint(Yn.origin)===!1&&(Yn.intersectSphere(dr,Ro)===null||Yn.origin.distanceToSquared(Ro)>(e.far-e.near)**2))&&(Ao.copy(s).invert(),Yn.copy(e.ray).applyMatrix4(Ao),!(n.boundingBox!==null&&Yn.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Yn)))}_computeIntersections(e,t,n){let r;const s=this.geometry,a=this.material,o=s.index,c=s.attributes.position,l=s.attributes.uv,u=s.attributes.uv1,m=s.attributes.normal,h=s.groups,d=s.drawRange;if(o!==null)if(Array.isArray(a))for(let x=0,y=h.length;x<y;x++){const _=h[x],f=a[_.materialIndex],w=Math.max(_.start,d.start),C=Math.min(o.count,Math.min(_.start+_.count,d.start+d.count));for(let S=w,R=C;S<R;S+=3){const b=o.getX(S),P=o.getX(S+1),g=o.getX(S+2);r=vr(this,f,e,n,l,u,m,b,P,g),r&&(r.faceIndex=Math.floor(S/3),r.face.materialIndex=_.materialIndex,t.push(r))}}else{const x=Math.max(0,d.start),y=Math.min(o.count,d.start+d.count);for(let _=x,f=y;_<f;_+=3){const w=o.getX(_),C=o.getX(_+1),S=o.getX(_+2);r=vr(this,a,e,n,l,u,m,w,C,S),r&&(r.faceIndex=Math.floor(_/3),t.push(r))}}else if(c!==void 0)if(Array.isArray(a))for(let x=0,y=h.length;x<y;x++){const _=h[x],f=a[_.materialIndex],w=Math.max(_.start,d.start),C=Math.min(c.count,Math.min(_.start+_.count,d.start+d.count));for(let S=w,R=C;S<R;S+=3){const b=S,P=S+1,g=S+2;r=vr(this,f,e,n,l,u,m,b,P,g),r&&(r.faceIndex=Math.floor(S/3),r.face.materialIndex=_.materialIndex,t.push(r))}}else{const x=Math.max(0,d.start),y=Math.min(c.count,d.start+d.count);for(let _=x,f=y;_<f;_+=3){const w=_,C=_+1,S=_+2;r=vr(this,a,e,n,l,u,m,w,C,S),r&&(r.faceIndex=Math.floor(_/3),t.push(r))}}}}function Ah(i,e,t,n,r,s,a,o){let c;if(e.side===Nt?c=n.intersectTriangle(a,s,r,!0,o):c=n.intersectTriangle(r,s,a,e.side===zn,o),c===null)return null;xr.copy(o),xr.applyMatrix4(i.matrixWorld);const l=t.ray.origin.distanceTo(xr);return l<t.near||l>t.far?null:{distance:l,point:xr.clone(),object:i}}function vr(i,e,t,n,r,s,a,o,c,l){i.getVertexPosition(o,pr),i.getVertexPosition(c,mr),i.getVertexPosition(l,_r);const u=Ah(i,e,t,n,pr,mr,_r,wo);if(u){const m=new D;Wt.getBarycoord(wo,pr,mr,_r,m),r&&(u.uv=Wt.getInterpolatedAttribute(r,o,c,l,m,new Ce)),s&&(u.uv1=Wt.getInterpolatedAttribute(s,o,c,l,m,new Ce)),a&&(u.normal=Wt.getInterpolatedAttribute(a,o,c,l,m,new D),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));const h={a:o,b:c,c:l,normal:new D,materialIndex:0};Wt.getNormal(pr,mr,_r,h.normal),u.face=h,u.barycoord=m}return u}class Rh extends Ct{constructor(e=null,t=1,n=1,r,s,a,o,c,l=bt,u=bt,m,h){super(null,a,o,c,l,u,r,s,m,h),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Cs=new D,wh=new D,Ch=new Le;class Ln{constructor(e=new D(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,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const r=Cs.subVectors(n,t).cross(wh.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){const r=e.delta(Cs),s=this.normal.dot(r);if(s===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/s;return n===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(r,a)}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||Ch.getNormalMatrix(e),r=this.coplanarPoint(Cs).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const qn=new qr,Ph=new Ce(.5,.5),Mr=new D;class Vl{constructor(e=new Ln,t=new Ln,n=new Ln,r=new Ln,s=new Ln,a=new Ln){this.planes=[e,t,n,r,s,a]}set(e,t,n,r,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(s),o[5].copy(a),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=rn,n=!1){const r=this.planes,s=e.elements,a=s[0],o=s[1],c=s[2],l=s[3],u=s[4],m=s[5],h=s[6],d=s[7],x=s[8],y=s[9],_=s[10],f=s[11],w=s[12],C=s[13],S=s[14],R=s[15];if(r[0].setComponents(l-a,d-u,f-x,R-w).normalize(),r[1].setComponents(l+a,d+u,f+x,R+w).normalize(),r[2].setComponents(l+o,d+m,f+y,R+C).normalize(),r[3].setComponents(l-o,d-m,f-y,R-C).normalize(),n)r[4].setComponents(c,h,_,S).normalize(),r[5].setComponents(l-c,d-h,f-_,R-S).normalize();else if(r[4].setComponents(l-c,d-h,f-_,R-S).normalize(),t===rn)r[5].setComponents(l+c,d+h,f+_,R+S).normalize();else if(t===zr)r[5].setComponents(c,h,_,S).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(),qn.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),qn.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(qn)}intersectsSprite(e){qn.center.set(0,0,0);const t=Ph.distanceTo(e.center);return qn.radius=.7071067811865476+t,qn.applyMatrix4(e.matrixWorld),this.intersectsSphere(qn)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const r=t[n];if(Mr.x=r.normal.x>0?e.max.x:e.min.x,Mr.y=r.normal.y>0?e.max.y:e.min.y,Mr.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Mr)<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)}}class Hl extends Ii{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new ze(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 kr=new D,Wr=new D,Co=new at,Hi=new Kr,Sr=new qr,Ps=new D,Po=new D;class Dh extends Lt{constructor(e=new Xt,t=new Hl){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,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 r=1,s=t.count;r<s;r++)kr.fromBufferAttribute(t,r-1),Wr.fromBufferAttribute(t,r),n[r]=n[r-1],n[r]+=kr.distanceTo(Wr);e.setAttribute("lineDistance",new zt(n,1))}else we("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Sr.copy(n.boundingSphere),Sr.applyMatrix4(r),Sr.radius+=s,e.ray.intersectsSphere(Sr)===!1)return;Co.copy(r).invert(),Hi.copy(e.ray).applyMatrix4(Co);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=this.isLineSegments?2:1,u=n.index,h=n.attributes.position;if(u!==null){const d=Math.max(0,a.start),x=Math.min(u.count,a.start+a.count);for(let y=d,_=x-1;y<_;y+=l){const f=u.getX(y),w=u.getX(y+1),C=Er(this,e,Hi,c,f,w,y);C&&t.push(C)}if(this.isLineLoop){const y=u.getX(x-1),_=u.getX(d),f=Er(this,e,Hi,c,y,_,x-1);f&&t.push(f)}}else{const d=Math.max(0,a.start),x=Math.min(h.count,a.start+a.count);for(let y=d,_=x-1;y<_;y+=l){const f=Er(this,e,Hi,c,y,y+1,y);f&&t.push(f)}if(this.isLineLoop){const y=Er(this,e,Hi,c,x-1,d,x-1);y&&t.push(y)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function Er(i,e,t,n,r,s,a){const o=i.geometry.attributes.position;if(kr.fromBufferAttribute(o,r),Wr.fromBufferAttribute(o,s),t.distanceSqToSegment(kr,Wr,Ps,Po)>n)return;Ps.applyMatrix4(i.matrixWorld);const l=e.ray.origin.distanceTo(Ps);if(!(l<e.near||l>e.far))return{distance:l,point:Po.clone().applyMatrix4(i.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:i}}const Do=new D,Lo=new D;class Lh extends Dh{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 r=0,s=t.count;r<s;r+=2)Do.fromBufferAttribute(t,r),Lo.fromBufferAttribute(t,r+1),n[r]=r===0?0:n[r-1],n[r+1]=n[r]+Do.distanceTo(Lo);e.setAttribute("lineDistance",new zt(n,1))}else we("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class kl extends Ct{constructor(e=[],t=Qn,n,r,s,a,o,c,l,u){super(e,t,n,r,s,a,o,c,l,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Ih extends Ct{constructor(e,t,n,r,s,a,o,c,l){super(e,t,n,r,s,a,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Di extends Ct{constructor(e,t,n=on,r,s,a,o=bt,c=bt,l,u=vn,m=1){if(u!==vn&&u!==Jn)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const h={width:e,height:t,depth:m};super(h,r,s,a,o,c,u,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Ha(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class Uh extends Di{constructor(e,t=on,n=Qn,r,s,a=bt,o=bt,c,l=vn){const u={width:e,height:e,depth:1},m=[u,u,u,u,u,u];super(e,e,t,n,r,s,a,o,c,l),this.image=m,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class Wl extends Ct{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class $i extends Xt{constructor(e=1,t=1,n=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:s,depthSegments:a};const o=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a);const c=[],l=[],u=[],m=[];let h=0,d=0;x("z","y","x",-1,-1,n,t,e,a,s,0),x("z","y","x",1,-1,n,t,-e,a,s,1),x("x","z","y",1,1,e,n,t,r,a,2),x("x","z","y",1,-1,e,n,-t,r,a,3),x("x","y","z",1,-1,e,t,n,r,s,4),x("x","y","z",-1,-1,e,t,-n,r,s,5),this.setIndex(c),this.setAttribute("position",new zt(l,3)),this.setAttribute("normal",new zt(u,3)),this.setAttribute("uv",new zt(m,2));function x(y,_,f,w,C,S,R,b,P,g,T){const U=S/P,L=R/g,z=S/2,$=R/2,j=b/2,H=P+1,Z=g+1;let X=0,te=0;const ie=new D;for(let fe=0;fe<Z;fe++){const me=fe*L-$;for(let Me=0;Me<H;Me++){const Xe=Me*U-z;ie[y]=Xe*w,ie[_]=me*C,ie[f]=j,l.push(ie.x,ie.y,ie.z),ie[y]=0,ie[_]=0,ie[f]=b>0?1:-1,u.push(ie.x,ie.y,ie.z),m.push(Me/P),m.push(1-fe/g),X+=1}}for(let fe=0;fe<g;fe++)for(let me=0;me<P;me++){const Me=h+me+H*fe,Xe=h+me+H*(fe+1),rt=h+(me+1)+H*(fe+1),Ye=h+(me+1)+H*fe;c.push(Me,Xe,Ye),c.push(Xe,rt,Ye),te+=6}o.addGroup(d,te,T),d+=te,h+=X}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new $i(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class Nh{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){we("Curve: .getPoint() not implemented.")}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,r=this.getPoint(0),s=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),s+=n.distanceTo(r),t.push(s),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){const n=this.getLengths();let r=0;const s=n.length;let a;t?a=t:a=e*n[s-1];let o=0,c=s-1,l;for(;o<=c;)if(r=Math.floor(o+(c-o)/2),l=n[r]-a,l<0)o=r+1;else if(l>0)c=r-1;else{c=r;break}if(r=c,n[r]===a)return r/(s-1);const u=n[r],h=n[r+1]-u,d=(a-u)/h;return(r+d)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);const a=this.getPoint(r),o=this.getPoint(s),c=t||(a.isVector2?new Ce:new D);return c.copy(o).sub(a).normalize(),c}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){const n=new D,r=[],s=[],a=[],o=new D,c=new at;for(let d=0;d<=e;d++){const x=d/e;r[d]=this.getTangentAt(x,new D)}s[0]=new D,a[0]=new D;let l=Number.MAX_VALUE;const u=Math.abs(r[0].x),m=Math.abs(r[0].y),h=Math.abs(r[0].z);u<=l&&(l=u,n.set(1,0,0)),m<=l&&(l=m,n.set(0,1,0)),h<=l&&n.set(0,0,1),o.crossVectors(r[0],n).normalize(),s[0].crossVectors(r[0],o),a[0].crossVectors(r[0],s[0]);for(let d=1;d<=e;d++){if(s[d]=s[d-1].clone(),a[d]=a[d-1].clone(),o.crossVectors(r[d-1],r[d]),o.length()>Number.EPSILON){o.normalize();const x=Math.acos(Be(r[d-1].dot(r[d]),-1,1));s[d].applyMatrix4(c.makeRotationAxis(o,x))}a[d].crossVectors(r[d],s[d])}if(t===!0){let d=Math.acos(Be(s[0].dot(s[e]),-1,1));d/=e,r[0].dot(o.crossVectors(s[0],s[e]))>0&&(d=-d);for(let x=1;x<=e;x++)s[x].applyMatrix4(c.makeRotationAxis(r[x],d*x)),a[x].crossVectors(r[x],s[x])}return{tangents:r,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}function Fh(i,e){const t=1-i;return t*t*e}function Oh(i,e){return 2*(1-i)*i*e}function Bh(i,e){return i*i*e}function Ds(i,e,t,n){return Fh(i,e)+Oh(i,t)+Bh(i,n)}class zh extends Nh{constructor(e=new D,t=new D,n=new D){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new D){const n=t,r=this.v0,s=this.v1,a=this.v2;return n.set(Ds(e,r.x,s.x,a.x),Ds(e,r.y,s.y,a.y),Ds(e,r.z,s.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}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 Zr extends Xt{constructor(e=1,t=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};const s=e/2,a=t/2,o=Math.floor(n),c=Math.floor(r),l=o+1,u=c+1,m=e/o,h=t/c,d=[],x=[],y=[],_=[];for(let f=0;f<u;f++){const w=f*h-a;for(let C=0;C<l;C++){const S=C*m-s;x.push(S,-w,0),y.push(0,0,1),_.push(C/o),_.push(1-f/c)}}for(let f=0;f<c;f++)for(let w=0;w<o;w++){const C=w+l*f,S=w+l*(f+1),R=w+1+l*(f+1),b=w+1+l*f;d.push(C,S,b),d.push(S,R,b)}this.setIndex(d),this.setAttribute("position",new zt(x,3)),this.setAttribute("normal",new zt(y,3)),this.setAttribute("uv",new zt(_,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Zr(e.width,e.height,e.widthSegments,e.heightSegments)}}function Li(i){const e={};for(const t in i){e[t]={};for(const n in i[t]){const r=i[t][n];if(Io(r))r.isRenderTargetTexture?(we("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=r.clone();else if(Array.isArray(r))if(Io(r[0])){const s=[];for(let a=0,o=r.length;a<o;a++)s[a]=r[a].clone();e[t][n]=s}else e[t][n]=r.slice();else e[t][n]=r}}return e}function Dt(i){const e={};for(let t=0;t<i.length;t++){const n=Li(i[t]);for(const r in n)e[r]=n[r]}return e}function Io(i){return i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)}function Gh(i){const e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function Xl(i){const e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:ke.workingColorSpace}const Vh={clone:Li,merge:Dt};var Hh=`void main() {
2
2
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
3
3
  }`,kh=`void main() {
4
4
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
5
- }`;class ln extends Ii{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Hh,this.fragmentShader=kh,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=Li(e.uniforms),this.uniformsGroups=Gh(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const r in this.uniforms){const a=this.uniforms[r].value;a&&a.isTexture?t.uniforms[r]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[r]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[r]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[r]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[r]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[r]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[r]={type:"m4",value:a.toArray()}:t.uniforms[r]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const r in this.extensions)this.extensions[r]===!0&&(n[r]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const n in e.uniforms){const r=e.uniforms[n];switch(this.uniforms[n]={},r.type){case"t":this.uniforms[n].value=t[r.value]||null;break;case"c":this.uniforms[n].value=new ze().setHex(r.value);break;case"v2":this.uniforms[n].value=new Ce().fromArray(r.value);break;case"v3":this.uniforms[n].value=new D().fromArray(r.value);break;case"v4":this.uniforms[n].value=new dt().fromArray(r.value);break;case"m3":this.uniforms[n].value=new Le().fromArray(r.value);break;case"m4":this.uniforms[n].value=new at().fromArray(r.value);break;default:this.uniforms[n].value=r.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(const n in e.extensions)this.extensions[n]=e.extensions[n];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class Wh extends ln{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Xh extends Ii{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Yc,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Yh extends Ii{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const Er=new D,yr=new Gn,Qt=new D;class Yl extends Lt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new at,this.projectionMatrix=new at,this.projectionMatrixInverse=new at,this.coordinateSystem=rn,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(Er,yr,Qt),Qt.x===1&&Qt.y===1&&Qt.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Er,yr,Qt.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(Er,yr,Qt),Qt.x===1&&Qt.y===1&&Qt.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Er,yr,Qt.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const Dn=new D,Uo=new Ce,No=new Ce;class Ht extends Yl{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=wa*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Lr*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return wa*2*Math.atan(Math.tan(Lr*.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){Dn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Dn.x,Dn.y).multiplyScalar(-e/Dn.z),Dn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Dn.x,Dn.y).multiplyScalar(-e/Dn.z)}getViewSize(e,t){return this.getViewBounds(e,Uo,No),t.subVectors(No,Uo)}setViewOffset(e,t,n,r,s,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Lr*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,s=-.5*r;const a=this.view;if(this.view!==null&&this.view.enabled){const c=a.fullWidth,l=a.fullHeight;s+=a.offsetX*r/c,t-=a.offsetY*n/l,r*=a.width/c,n*=a.height/l}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class ql extends Yl{constructor(e=-1,t=1,n=1,r=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,s,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let s=n-e,a=n+e,o=r+t,c=r-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;s+=l*this.view.offsetX,a=s+l*this.view.width,o-=u*this.view.offsetY,c=o-u*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const Si=-90,Ei=1;class qh extends Lt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new Ht(Si,Ei,e,t);r.layers=this.layers,this.add(r);const s=new Ht(Si,Ei,e,t);s.layers=this.layers,this.add(s);const a=new Ht(Si,Ei,e,t);a.layers=this.layers,this.add(a);const o=new Ht(Si,Ei,e,t);o.layers=this.layers,this.add(o);const c=new Ht(Si,Ei,e,t);c.layers=this.layers,this.add(c);const l=new Ht(Si,Ei,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,r,s,a,o,c]=t;for(const l of t)this.remove(l);if(e===rn)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Br)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),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:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,c,l,u]=this.children,m=e.getRenderTarget(),h=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;const y=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let _=!1;e.isWebGLRenderer===!0?_=e.state.buffers.depth.getReversed():_=e.reversedDepthBuffer,e.setRenderTarget(n,0,r),_&&e.autoClear===!1&&e.clearDepth(),e.render(t,s),e.setRenderTarget(n,1,r),_&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,2,r),_&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,3,r),_&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),e.setRenderTarget(n,4,r),_&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),n.texture.generateMipmaps=y,e.setRenderTarget(n,5,r),_&&e.autoClear===!1&&e.clearDepth(),e.render(t,u),e.setRenderTarget(m,h,d),e.xr.enabled=x,n.texture.needsPMREMUpdate=!0}}class Kh extends Ht{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const Fo=new at;class Zh{constructor(e,t,n=0,r=1/0){this.ray=new qr(e,t),this.near=n,this.far=r,this.camera=null,this.layers=new ka,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.projectionMatrix.elements[14]).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):He("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Fo.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Fo),this}intersectObject(e,t=!0,n=[]){return Ca(e,this,n,t),n.sort(Oo),n}intersectObjects(e,t=!0,n=[]){for(let r=0,s=e.length;r<s;r++)Ca(e[r],this,n,t);return n.sort(Oo),n}}function Oo(i,e){return i.distance-e.distance}function Ca(i,e,t,n){let r=!0;if(i.layers.test(e.layers)&&i.raycast(e,t)===!1&&(r=!1),r===!0&&n===!0){const s=i.children;for(let a=0,o=s.length;a<o;a++)Ca(s[a],e,t,!0)}}class Bo{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}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=Be(this.phi,1e-6,Math.PI-1e-6),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(Be(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const $a=class $a{constructor(e,t,n,r){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,r)}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,r){const s=this.elements;return s[0]=e,s[2]=t,s[1]=n,s[3]=r,this}};$a.prototype.isMatrix2=!0;let zo=$a;class $h extends Vn{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(e){if(e===void 0){we("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function Go(i,e,t,n){const r=Jh(n);switch(t){case Pl:return i*e;case Ll:return i*e/r.components*r.byteLength;case Oa:return i*e/r.components*r.byteLength;case jn:return i*e*2/r.components*r.byteLength;case Ba:return i*e*2/r.components*r.byteLength;case Dl:return i*e*3/r.components*r.byteLength;case Zt:return i*e*4/r.components*r.byteLength;case za:return i*e*4/r.components*r.byteLength;case wr:case Cr:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Pr:case Dr:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Qs:case ea:return Math.max(i,16)*Math.max(e,8)/4;case Js:case js:return Math.max(i,8)*Math.max(e,8)/2;case ta:case na:case ra:case sa:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case ia:case Ur:case aa:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case oa:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case la:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case ca:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case ha:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case ua:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case fa:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case da:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case pa:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case ma:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case _a:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case ga:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case xa:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case va:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case Ma:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case Sa:case Ea:case ya:return Math.ceil(i/4)*Math.ceil(e/4)*16;case ba:case Ta:return Math.ceil(i/4)*Math.ceil(e/4)*8;case Nr:case Aa:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Jh(i){switch(i){case kt:case Al:return{byteLength:1,components:1};case qi:case Rl:case xn:return{byteLength:2,components:1};case Na:case Fa:return{byteLength:2,components:4};case on:case Ua:case nn:return{byteLength:4,components:1};case wl:case Cl:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Ia}}));typeof window<"u"&&(window.__THREE__?we("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Ia);function Kl(){let i=null,e=!1,t=null,n=null;function r(s,a){t(s,a),n=i.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&i!==null&&(n=i.requestAnimationFrame(r),e=!0)},stop:function(){i!==null&&i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){i=s}}}function Qh(i){const e=new WeakMap;function t(o,c){const l=o.array,u=o.usage,m=l.byteLength,h=i.createBuffer();i.bindBuffer(c,h),i.bufferData(c,l,u),o.onUploadCallback();let d;if(l instanceof Float32Array)d=i.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)d=i.HALF_FLOAT;else if(l instanceof Uint16Array)o.isFloat16BufferAttribute?d=i.HALF_FLOAT:d=i.UNSIGNED_SHORT;else if(l instanceof Int16Array)d=i.SHORT;else if(l instanceof Uint32Array)d=i.UNSIGNED_INT;else if(l instanceof Int32Array)d=i.INT;else if(l instanceof Int8Array)d=i.BYTE;else if(l instanceof Uint8Array)d=i.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)d=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:h,type:d,bytesPerElement:l.BYTES_PER_ELEMENT,version:o.version,size:m}}function n(o,c,l){const u=c.array,m=c.updateRanges;if(i.bindBuffer(l,o),m.length===0)i.bufferSubData(l,0,u);else{m.sort((d,x)=>d.start-x.start);let h=0;for(let d=1;d<m.length;d++){const x=m[h],y=m[d];y.start<=x.start+x.count+1?x.count=Math.max(x.count,y.start+y.count-x.start):(++h,m[h]=y)}m.length=h+1;for(let d=0,x=m.length;d<x;d++){const y=m[d];i.bufferSubData(l,y.start*u.BYTES_PER_ELEMENT,u,y.start,y.count)}c.clearUpdateRanges()}c.onUploadCallback()}function r(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function s(o){o.isInterleavedBufferAttribute&&(o=o.data);const c=e.get(o);c&&(i.deleteBuffer(c.buffer),e.delete(o))}function a(o,c){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const u=e.get(o);(!u||u.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const l=e.get(o);if(l===void 0)e.set(o,t(o,c));else if(l.version<o.version){if(l.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(l.buffer,o,c),l.version=o.version}}return{get:r,remove:s,update:a}}var jh=`#ifdef USE_ALPHAHASH
5
+ }`;class ln extends Ii{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Hh,this.fragmentShader=kh,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=Li(e.uniforms),this.uniformsGroups=Gh(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const r in this.uniforms){const a=this.uniforms[r].value;a&&a.isTexture?t.uniforms[r]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[r]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[r]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[r]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[r]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[r]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[r]={type:"m4",value:a.toArray()}:t.uniforms[r]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const r in this.extensions)this.extensions[r]===!0&&(n[r]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const n in e.uniforms){const r=e.uniforms[n];switch(this.uniforms[n]={},r.type){case"t":this.uniforms[n].value=t[r.value]||null;break;case"c":this.uniforms[n].value=new ze().setHex(r.value);break;case"v2":this.uniforms[n].value=new Ce().fromArray(r.value);break;case"v3":this.uniforms[n].value=new D().fromArray(r.value);break;case"v4":this.uniforms[n].value=new dt().fromArray(r.value);break;case"m3":this.uniforms[n].value=new Le().fromArray(r.value);break;case"m4":this.uniforms[n].value=new at().fromArray(r.value);break;default:this.uniforms[n].value=r.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(const n in e.extensions)this.extensions[n]=e.extensions[n];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class Wh extends ln{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Xh extends Ii{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Yc,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Yh extends Ii{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const yr=new D,br=new Gn,Qt=new D;class Yl extends Lt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new at,this.projectionMatrix=new at,this.projectionMatrixInverse=new at,this.coordinateSystem=rn,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(yr,br,Qt),Qt.x===1&&Qt.y===1&&Qt.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(yr,br,Qt.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(yr,br,Qt),Qt.x===1&&Qt.y===1&&Qt.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(yr,br,Qt.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const Dn=new D,Uo=new Ce,No=new Ce;class Ht extends Yl{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=wa*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Ir*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return wa*2*Math.atan(Math.tan(Ir*.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){Dn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Dn.x,Dn.y).multiplyScalar(-e/Dn.z),Dn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Dn.x,Dn.y).multiplyScalar(-e/Dn.z)}getViewSize(e,t){return this.getViewBounds(e,Uo,No),t.subVectors(No,Uo)}setViewOffset(e,t,n,r,s,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Ir*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,s=-.5*r;const a=this.view;if(this.view!==null&&this.view.enabled){const c=a.fullWidth,l=a.fullHeight;s+=a.offsetX*r/c,t-=a.offsetY*n/l,r*=a.width/c,n*=a.height/l}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class ql extends Yl{constructor(e=-1,t=1,n=1,r=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,s,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let s=n-e,a=n+e,o=r+t,c=r-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;s+=l*this.view.offsetX,a=s+l*this.view.width,o-=u*this.view.offsetY,c=o-u*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const Si=-90,Ei=1;class qh extends Lt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new Ht(Si,Ei,e,t);r.layers=this.layers,this.add(r);const s=new Ht(Si,Ei,e,t);s.layers=this.layers,this.add(s);const a=new Ht(Si,Ei,e,t);a.layers=this.layers,this.add(a);const o=new Ht(Si,Ei,e,t);o.layers=this.layers,this.add(o);const c=new Ht(Si,Ei,e,t);c.layers=this.layers,this.add(c);const l=new Ht(Si,Ei,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,r,s,a,o,c]=t;for(const l of t)this.remove(l);if(e===rn)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===zr)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),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:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,c,l,u]=this.children,m=e.getRenderTarget(),h=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;const y=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let _=!1;e.isWebGLRenderer===!0?_=e.state.buffers.depth.getReversed():_=e.reversedDepthBuffer,e.setRenderTarget(n,0,r),_&&e.autoClear===!1&&e.clearDepth(),e.render(t,s),e.setRenderTarget(n,1,r),_&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,2,r),_&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,3,r),_&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),e.setRenderTarget(n,4,r),_&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),n.texture.generateMipmaps=y,e.setRenderTarget(n,5,r),_&&e.autoClear===!1&&e.clearDepth(),e.render(t,u),e.setRenderTarget(m,h,d),e.xr.enabled=x,n.texture.needsPMREMUpdate=!0}}class Kh extends Ht{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const Fo=new at;class Zh{constructor(e,t,n=0,r=1/0){this.ray=new Kr(e,t),this.near=n,this.far=r,this.camera=null,this.layers=new ka,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.projectionMatrix.elements[14]).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):He("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Fo.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Fo),this}intersectObject(e,t=!0,n=[]){return Ca(e,this,n,t),n.sort(Oo),n}intersectObjects(e,t=!0,n=[]){for(let r=0,s=e.length;r<s;r++)Ca(e[r],this,n,t);return n.sort(Oo),n}}function Oo(i,e){return i.distance-e.distance}function Ca(i,e,t,n){let r=!0;if(i.layers.test(e.layers)&&i.raycast(e,t)===!1&&(r=!1),r===!0&&n===!0){const s=i.children;for(let a=0,o=s.length;a<o;a++)Ca(s[a],e,t,!0)}}class Bo{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}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=Be(this.phi,1e-6,Math.PI-1e-6),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(Be(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const $a=class $a{constructor(e,t,n,r){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,r)}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,r){const s=this.elements;return s[0]=e,s[2]=t,s[1]=n,s[3]=r,this}};$a.prototype.isMatrix2=!0;let zo=$a;class $h extends Vn{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(e){if(e===void 0){we("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function Go(i,e,t,n){const r=Jh(n);switch(t){case Pl:return i*e;case Ll:return i*e/r.components*r.byteLength;case Oa:return i*e/r.components*r.byteLength;case jn:return i*e*2/r.components*r.byteLength;case Ba:return i*e*2/r.components*r.byteLength;case Dl:return i*e*3/r.components*r.byteLength;case Zt:return i*e*4/r.components*r.byteLength;case za:return i*e*4/r.components*r.byteLength;case Cr:case Pr:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Dr:case Lr:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Qs:case ea:return Math.max(i,16)*Math.max(e,8)/4;case Js:case js:return Math.max(i,8)*Math.max(e,8)/2;case ta:case na:case ra:case sa:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case ia:case Nr:case aa:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case oa:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case la:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case ca:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case ha:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case ua:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case fa:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case da:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case pa:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case ma:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case _a:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case ga:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case xa:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case va:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case Ma:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case Sa:case Ea:case ya:return Math.ceil(i/4)*Math.ceil(e/4)*16;case ba:case Ta:return Math.ceil(i/4)*Math.ceil(e/4)*8;case Fr:case Aa:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Jh(i){switch(i){case kt:case Al:return{byteLength:1,components:1};case qi:case Rl:case xn:return{byteLength:2,components:1};case Na:case Fa:return{byteLength:2,components:4};case on:case Ua:case nn:return{byteLength:4,components:1};case wl:case Cl:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Ia}}));typeof window<"u"&&(window.__THREE__?we("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Ia);function Kl(){let i=null,e=!1,t=null,n=null;function r(s,a){t(s,a),n=i.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&i!==null&&(n=i.requestAnimationFrame(r),e=!0)},stop:function(){i!==null&&i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){i=s}}}function Qh(i){const e=new WeakMap;function t(o,c){const l=o.array,u=o.usage,m=l.byteLength,h=i.createBuffer();i.bindBuffer(c,h),i.bufferData(c,l,u),o.onUploadCallback();let d;if(l instanceof Float32Array)d=i.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)d=i.HALF_FLOAT;else if(l instanceof Uint16Array)o.isFloat16BufferAttribute?d=i.HALF_FLOAT:d=i.UNSIGNED_SHORT;else if(l instanceof Int16Array)d=i.SHORT;else if(l instanceof Uint32Array)d=i.UNSIGNED_INT;else if(l instanceof Int32Array)d=i.INT;else if(l instanceof Int8Array)d=i.BYTE;else if(l instanceof Uint8Array)d=i.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)d=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:h,type:d,bytesPerElement:l.BYTES_PER_ELEMENT,version:o.version,size:m}}function n(o,c,l){const u=c.array,m=c.updateRanges;if(i.bindBuffer(l,o),m.length===0)i.bufferSubData(l,0,u);else{m.sort((d,x)=>d.start-x.start);let h=0;for(let d=1;d<m.length;d++){const x=m[h],y=m[d];y.start<=x.start+x.count+1?x.count=Math.max(x.count,y.start+y.count-x.start):(++h,m[h]=y)}m.length=h+1;for(let d=0,x=m.length;d<x;d++){const y=m[d];i.bufferSubData(l,y.start*u.BYTES_PER_ELEMENT,u,y.start,y.count)}c.clearUpdateRanges()}c.onUploadCallback()}function r(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function s(o){o.isInterleavedBufferAttribute&&(o=o.data);const c=e.get(o);c&&(i.deleteBuffer(c.buffer),e.delete(o))}function a(o,c){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const u=e.get(o);(!u||u.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const l=e.get(o);if(l===void 0)e.set(o,t(o,c));else if(l.version<o.version){if(l.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(l.buffer,o,c),l.version=o.version}}return{get:r,remove:s,update:a}}var jh=`#ifdef USE_ALPHAHASH
6
6
  if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
7
7
  #endif`,eu=`#ifdef USE_ALPHAHASH
8
8
  const float ALPHA_HASH_SCALE = 0.05;
@@ -3668,7 +3668,7 @@ void main() {
3668
3668
  #include <tonemapping_fragment>
3669
3669
  #include <colorspace_fragment>
3670
3670
  #include <fog_fragment>
3671
- }`,Ne={alphahash_fragment:jh,alphahash_pars_fragment:eu,alphamap_fragment:tu,alphamap_pars_fragment:nu,alphatest_fragment:iu,alphatest_pars_fragment:ru,aomap_fragment:su,aomap_pars_fragment:au,batching_pars_vertex:ou,batching_vertex:lu,begin_vertex:cu,beginnormal_vertex:hu,bsdfs:uu,iridescence_fragment:fu,bumpmap_pars_fragment:du,clipping_planes_fragment:pu,clipping_planes_pars_fragment:mu,clipping_planes_pars_vertex:_u,clipping_planes_vertex:gu,color_fragment:xu,color_pars_fragment:vu,color_pars_vertex:Mu,color_vertex:Su,common:Eu,cube_uv_reflection_fragment:yu,defaultnormal_vertex:bu,displacementmap_pars_vertex:Tu,displacementmap_vertex:Au,emissivemap_fragment:Ru,emissivemap_pars_fragment:wu,colorspace_fragment:Cu,colorspace_pars_fragment:Pu,envmap_fragment:Du,envmap_common_pars_fragment:Lu,envmap_pars_fragment:Iu,envmap_pars_vertex:Uu,envmap_physical_pars_fragment:Xu,envmap_vertex:Nu,fog_vertex:Fu,fog_pars_vertex:Ou,fog_fragment:Bu,fog_pars_fragment:zu,gradientmap_pars_fragment:Gu,lightmap_pars_fragment:Vu,lights_lambert_fragment:Hu,lights_lambert_pars_fragment:ku,lights_pars_begin:Wu,lights_toon_fragment:Yu,lights_toon_pars_fragment:qu,lights_phong_fragment:Ku,lights_phong_pars_fragment:Zu,lights_physical_fragment:$u,lights_physical_pars_fragment:Ju,lights_fragment_begin:Qu,lights_fragment_maps:ju,lights_fragment_end:ef,lightprobes_pars_fragment:tf,logdepthbuf_fragment:nf,logdepthbuf_pars_fragment:rf,logdepthbuf_pars_vertex:sf,logdepthbuf_vertex:af,map_fragment:of,map_pars_fragment:lf,map_particle_fragment:cf,map_particle_pars_fragment:hf,metalnessmap_fragment:uf,metalnessmap_pars_fragment:ff,morphinstance_vertex:df,morphcolor_vertex:pf,morphnormal_vertex:mf,morphtarget_pars_vertex:_f,morphtarget_vertex:gf,normal_fragment_begin:xf,normal_fragment_maps:vf,normal_pars_fragment:Mf,normal_pars_vertex:Sf,normal_vertex:Ef,normalmap_pars_fragment:yf,clearcoat_normal_fragment_begin:bf,clearcoat_normal_fragment_maps:Tf,clearcoat_pars_fragment:Af,iridescence_pars_fragment:Rf,opaque_fragment:wf,packing:Cf,premultiplied_alpha_fragment:Pf,project_vertex:Df,dithering_fragment:Lf,dithering_pars_fragment:If,roughnessmap_fragment:Uf,roughnessmap_pars_fragment:Nf,shadowmap_pars_fragment:Ff,shadowmap_pars_vertex:Of,shadowmap_vertex:Bf,shadowmask_pars_fragment:zf,skinbase_vertex:Gf,skinning_pars_vertex:Vf,skinning_vertex:Hf,skinnormal_vertex:kf,specularmap_fragment:Wf,specularmap_pars_fragment:Xf,tonemapping_fragment:Yf,tonemapping_pars_fragment:qf,transmission_fragment:Kf,transmission_pars_fragment:Zf,uv_pars_fragment:$f,uv_pars_vertex:Jf,uv_vertex:Qf,worldpos_vertex:jf,background_vert:ed,background_frag:td,backgroundCube_vert:nd,backgroundCube_frag:id,cube_vert:rd,cube_frag:sd,depth_vert:ad,depth_frag:od,distance_vert:ld,distance_frag:cd,equirect_vert:hd,equirect_frag:ud,linedashed_vert:fd,linedashed_frag:dd,meshbasic_vert:pd,meshbasic_frag:md,meshlambert_vert:_d,meshlambert_frag:gd,meshmatcap_vert:xd,meshmatcap_frag:vd,meshnormal_vert:Md,meshnormal_frag:Sd,meshphong_vert:Ed,meshphong_frag:yd,meshphysical_vert:bd,meshphysical_frag:Td,meshtoon_vert:Ad,meshtoon_frag:Rd,points_vert:wd,points_frag:Cd,shadow_vert:Pd,shadow_frag:Dd,sprite_vert:Ld,sprite_frag:Id},pe={common:{diffuse:{value:new ze(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Le},alphaMap:{value:null},alphaMapTransform:{value:new Le},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Le}},envmap:{envMap:{value:null},envMapRotation:{value:new Le},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Le}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Le}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Le},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Le},normalScale:{value:new Ce(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Le},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Le}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Le}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Le}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ze(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new D},probesMax:{value:new D},probesResolution:{value:new D}},points:{diffuse:{value:new ze(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Le},alphaTest:{value:0},uvTransform:{value:new Le}},sprite:{diffuse:{value:new ze(16777215)},opacity:{value:1},center:{value:new Ce(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Le},alphaMap:{value:null},alphaMapTransform:{value:new Le},alphaTest:{value:0}}},en={basic:{uniforms:Dt([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.fog]),vertexShader:Ne.meshbasic_vert,fragmentShader:Ne.meshbasic_frag},lambert:{uniforms:Dt([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,pe.lights,{emissive:{value:new ze(0)},envMapIntensity:{value:1}}]),vertexShader:Ne.meshlambert_vert,fragmentShader:Ne.meshlambert_frag},phong:{uniforms:Dt([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,pe.lights,{emissive:{value:new ze(0)},specular:{value:new ze(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ne.meshphong_vert,fragmentShader:Ne.meshphong_frag},standard:{uniforms:Dt([pe.common,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.roughnessmap,pe.metalnessmap,pe.fog,pe.lights,{emissive:{value:new ze(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ne.meshphysical_vert,fragmentShader:Ne.meshphysical_frag},toon:{uniforms:Dt([pe.common,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.gradientmap,pe.fog,pe.lights,{emissive:{value:new ze(0)}}]),vertexShader:Ne.meshtoon_vert,fragmentShader:Ne.meshtoon_frag},matcap:{uniforms:Dt([pe.common,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,{matcap:{value:null}}]),vertexShader:Ne.meshmatcap_vert,fragmentShader:Ne.meshmatcap_frag},points:{uniforms:Dt([pe.points,pe.fog]),vertexShader:Ne.points_vert,fragmentShader:Ne.points_frag},dashed:{uniforms:Dt([pe.common,pe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ne.linedashed_vert,fragmentShader:Ne.linedashed_frag},depth:{uniforms:Dt([pe.common,pe.displacementmap]),vertexShader:Ne.depth_vert,fragmentShader:Ne.depth_frag},normal:{uniforms:Dt([pe.common,pe.bumpmap,pe.normalmap,pe.displacementmap,{opacity:{value:1}}]),vertexShader:Ne.meshnormal_vert,fragmentShader:Ne.meshnormal_frag},sprite:{uniforms:Dt([pe.sprite,pe.fog]),vertexShader:Ne.sprite_vert,fragmentShader:Ne.sprite_frag},background:{uniforms:{uvTransform:{value:new Le},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ne.background_vert,fragmentShader:Ne.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Le}},vertexShader:Ne.backgroundCube_vert,fragmentShader:Ne.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ne.cube_vert,fragmentShader:Ne.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ne.equirect_vert,fragmentShader:Ne.equirect_frag},distance:{uniforms:Dt([pe.common,pe.displacementmap,{referencePosition:{value:new D},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ne.distance_vert,fragmentShader:Ne.distance_frag},shadow:{uniforms:Dt([pe.lights,pe.fog,{color:{value:new ze(0)},opacity:{value:1}}]),vertexShader:Ne.shadow_vert,fragmentShader:Ne.shadow_frag}};en.physical={uniforms:Dt([en.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Le},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Le},clearcoatNormalScale:{value:new Ce(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Le},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Le},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Le},sheen:{value:0},sheenColor:{value:new ze(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Le},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Le},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Le},transmissionSamplerSize:{value:new Ce},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Le},attenuationDistance:{value:0},attenuationColor:{value:new ze(0)},specularColor:{value:new ze(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Le},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Le},anisotropyVector:{value:new Ce},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Le}}]),vertexShader:Ne.meshphysical_vert,fragmentShader:Ne.meshphysical_frag};const br={r:0,b:0,g:0},Ud=new at,Zl=new Le;Zl.set(-1,0,0,0,1,0,0,0,1);function Nd(i,e,t,n,r,s){const a=new ze(0);let o=r===!0?0:1,c,l,u=null,m=0,h=null;function d(w){let C=w.isScene===!0?w.background:null;if(C&&C.isTexture){const S=w.backgroundBlurriness>0;C=e.get(C,S)}return C}function x(w){let C=!1;const S=d(w);S===null?_(a,o):S&&S.isColor&&(_(S,1),C=!0);const R=i.xr.getEnvironmentBlendMode();R==="additive"?t.buffers.color.setClear(0,0,0,1,s):R==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,s),(i.autoClear||C)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function y(w,C){const S=d(C);S&&(S.isCubeTexture||S.mapping===Xr)?(l===void 0&&(l=new Mn(new $i(1,1,1),new ln({name:"BackgroundCubeMaterial",uniforms:Li(en.backgroundCube.uniforms),vertexShader:en.backgroundCube.vertexShader,fragmentShader:en.backgroundCube.fragmentShader,side:Nt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(R,b,P){this.matrixWorld.copyPosition(P.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),l.material.uniforms.envMap.value=S,l.material.uniforms.backgroundBlurriness.value=C.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=C.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(Ud.makeRotationFromEuler(C.backgroundRotation)).transpose(),S.isCubeTexture&&S.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(Zl),l.material.toneMapped=ke.getTransfer(S.colorSpace)!==$e,(u!==S||m!==S.version||h!==i.toneMapping)&&(l.material.needsUpdate=!0,u=S,m=S.version,h=i.toneMapping),l.layers.enableAll(),w.unshift(l,l.geometry,l.material,0,0,null)):S&&S.isTexture&&(c===void 0&&(c=new Mn(new Kr(2,2),new ln({name:"BackgroundMaterial",uniforms:Li(en.background.uniforms),vertexShader:en.background.vertexShader,fragmentShader:en.background.fragmentShader,side:zn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(c)),c.material.uniforms.t2D.value=S,c.material.uniforms.backgroundIntensity.value=C.backgroundIntensity,c.material.toneMapped=ke.getTransfer(S.colorSpace)!==$e,S.matrixAutoUpdate===!0&&S.updateMatrix(),c.material.uniforms.uvTransform.value.copy(S.matrix),(u!==S||m!==S.version||h!==i.toneMapping)&&(c.material.needsUpdate=!0,u=S,m=S.version,h=i.toneMapping),c.layers.enableAll(),w.unshift(c,c.geometry,c.material,0,0,null))}function _(w,C){w.getRGB(br,Xl(i)),t.buffers.color.setClear(br.r,br.g,br.b,C,s)}function f(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return a},setClearColor:function(w,C=1){a.set(w),o=C,_(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(w){o=w,_(a,o)},render:x,addToRenderList:y,dispose:f}}function Fd(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=h(null);let s=r,a=!1;function o(L,z,$,j,H){let Z=!1;const X=m(L,j,$,z);s!==X&&(s=X,l(s.object)),Z=d(L,j,$,H),Z&&x(L,j,$,H),H!==null&&e.update(H,i.ELEMENT_ARRAY_BUFFER),(Z||a)&&(a=!1,S(L,z,$,j),H!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(H).buffer))}function c(){return i.createVertexArray()}function l(L){return i.bindVertexArray(L)}function u(L){return i.deleteVertexArray(L)}function m(L,z,$,j){const H=j.wireframe===!0;let Z=n[z.id];Z===void 0&&(Z={},n[z.id]=Z);const X=L.isInstancedMesh===!0?L.id:0;let te=Z[X];te===void 0&&(te={},Z[X]=te);let ie=te[$.id];ie===void 0&&(ie={},te[$.id]=ie);let fe=ie[H];return fe===void 0&&(fe=h(c()),ie[H]=fe),fe}function h(L){const z=[],$=[],j=[];for(let H=0;H<t;H++)z[H]=0,$[H]=0,j[H]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:z,enabledAttributes:$,attributeDivisors:j,object:L,attributes:{},index:null}}function d(L,z,$,j){const H=s.attributes,Z=z.attributes;let X=0;const te=$.getAttributes();for(const ie in te)if(te[ie].location>=0){const me=H[ie];let Me=Z[ie];if(Me===void 0&&(ie==="instanceMatrix"&&L.instanceMatrix&&(Me=L.instanceMatrix),ie==="instanceColor"&&L.instanceColor&&(Me=L.instanceColor)),me===void 0||me.attribute!==Me||Me&&me.data!==Me.data)return!0;X++}return s.attributesNum!==X||s.index!==j}function x(L,z,$,j){const H={},Z=z.attributes;let X=0;const te=$.getAttributes();for(const ie in te)if(te[ie].location>=0){let me=Z[ie];me===void 0&&(ie==="instanceMatrix"&&L.instanceMatrix&&(me=L.instanceMatrix),ie==="instanceColor"&&L.instanceColor&&(me=L.instanceColor));const Me={};Me.attribute=me,me&&me.data&&(Me.data=me.data),H[ie]=Me,X++}s.attributes=H,s.attributesNum=X,s.index=j}function y(){const L=s.newAttributes;for(let z=0,$=L.length;z<$;z++)L[z]=0}function _(L){f(L,0)}function f(L,z){const $=s.newAttributes,j=s.enabledAttributes,H=s.attributeDivisors;$[L]=1,j[L]===0&&(i.enableVertexAttribArray(L),j[L]=1),H[L]!==z&&(i.vertexAttribDivisor(L,z),H[L]=z)}function w(){const L=s.newAttributes,z=s.enabledAttributes;for(let $=0,j=z.length;$<j;$++)z[$]!==L[$]&&(i.disableVertexAttribArray($),z[$]=0)}function C(L,z,$,j,H,Z,X){X===!0?i.vertexAttribIPointer(L,z,$,H,Z):i.vertexAttribPointer(L,z,$,j,H,Z)}function S(L,z,$,j){y();const H=j.attributes,Z=$.getAttributes(),X=z.defaultAttributeValues;for(const te in Z){const ie=Z[te];if(ie.location>=0){let fe=H[te];if(fe===void 0&&(te==="instanceMatrix"&&L.instanceMatrix&&(fe=L.instanceMatrix),te==="instanceColor"&&L.instanceColor&&(fe=L.instanceColor)),fe!==void 0){const me=fe.normalized,Me=fe.itemSize,Xe=e.get(fe);if(Xe===void 0)continue;const rt=Xe.buffer,Ye=Xe.type,Q=Xe.bytesPerElement,le=Ye===i.INT||Ye===i.UNSIGNED_INT||fe.gpuType===Ua;if(fe.isInterleavedBufferAttribute){const re=fe.data,Pe=re.stride,De=fe.offset;if(re.isInstancedInterleavedBuffer){for(let Re=0;Re<ie.locationSize;Re++)f(ie.location+Re,re.meshPerAttribute);L.isInstancedMesh!==!0&&j._maxInstanceCount===void 0&&(j._maxInstanceCount=re.meshPerAttribute*re.count)}else for(let Re=0;Re<ie.locationSize;Re++)_(ie.location+Re);i.bindBuffer(i.ARRAY_BUFFER,rt);for(let Re=0;Re<ie.locationSize;Re++)C(ie.location+Re,Me/ie.locationSize,Ye,me,Pe*Q,(De+Me/ie.locationSize*Re)*Q,le)}else{if(fe.isInstancedBufferAttribute){for(let re=0;re<ie.locationSize;re++)f(ie.location+re,fe.meshPerAttribute);L.isInstancedMesh!==!0&&j._maxInstanceCount===void 0&&(j._maxInstanceCount=fe.meshPerAttribute*fe.count)}else for(let re=0;re<ie.locationSize;re++)_(ie.location+re);i.bindBuffer(i.ARRAY_BUFFER,rt);for(let re=0;re<ie.locationSize;re++)C(ie.location+re,Me/ie.locationSize,Ye,me,Me*Q,Me/ie.locationSize*re*Q,le)}}else if(X!==void 0){const me=X[te];if(me!==void 0)switch(me.length){case 2:i.vertexAttrib2fv(ie.location,me);break;case 3:i.vertexAttrib3fv(ie.location,me);break;case 4:i.vertexAttrib4fv(ie.location,me);break;default:i.vertexAttrib1fv(ie.location,me)}}}}w()}function R(){T();for(const L in n){const z=n[L];for(const $ in z){const j=z[$];for(const H in j){const Z=j[H];for(const X in Z)u(Z[X].object),delete Z[X];delete j[H]}}delete n[L]}}function b(L){if(n[L.id]===void 0)return;const z=n[L.id];for(const $ in z){const j=z[$];for(const H in j){const Z=j[H];for(const X in Z)u(Z[X].object),delete Z[X];delete j[H]}}delete n[L.id]}function P(L){for(const z in n){const $=n[z];for(const j in $){const H=$[j];if(H[L.id]===void 0)continue;const Z=H[L.id];for(const X in Z)u(Z[X].object),delete Z[X];delete H[L.id]}}}function g(L){for(const z in n){const $=n[z],j=L.isInstancedMesh===!0?L.id:0,H=$[j];if(H!==void 0){for(const Z in H){const X=H[Z];for(const te in X)u(X[te].object),delete X[te];delete H[Z]}delete $[j],Object.keys($).length===0&&delete n[z]}}}function T(){U(),a=!0,s!==r&&(s=r,l(s.object))}function U(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:T,resetDefaultState:U,dispose:R,releaseStatesOfGeometry:b,releaseStatesOfObject:g,releaseStatesOfProgram:P,initAttributes:y,enableAttribute:_,disableUnusedAttributes:w}}function Od(i,e,t){let n;function r(c){n=c}function s(c,l){i.drawArrays(n,c,l),t.update(l,n,1)}function a(c,l,u){u!==0&&(i.drawArraysInstanced(n,c,l,u),t.update(l,n,u))}function o(c,l,u){if(u===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,l,0,u);let h=0;for(let d=0;d<u;d++)h+=l[d];t.update(h,n,1)}this.setMode=r,this.render=s,this.renderInstances=a,this.renderMultiDraw=o}function Bd(i,e,t,n){let r;function s(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const P=e.get("EXT_texture_filter_anisotropic");r=i.getParameter(P.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(P){return!(P!==Zt&&n.convert(P)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(P){const g=P===xn&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(P!==kt&&n.convert(P)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&P!==nn&&!g)}function c(P){if(P==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";P="mediump"}return P==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp";const u=c(l);u!==l&&(we("WebGLRenderer:",l,"not supported, using",u,"instead."),l=u);const m=t.logarithmicDepthBuffer===!0,h=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&h===!1&&we("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const d=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),x=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),y=i.getParameter(i.MAX_TEXTURE_SIZE),_=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),f=i.getParameter(i.MAX_VERTEX_ATTRIBS),w=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),C=i.getParameter(i.MAX_VARYING_VECTORS),S=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),R=i.getParameter(i.MAX_SAMPLES),b=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:m,reversedDepthBuffer:h,maxTextures:d,maxVertexTextures:x,maxTextureSize:y,maxCubemapSize:_,maxAttributes:f,maxVertexUniforms:w,maxVaryings:C,maxFragmentUniforms:S,maxSamples:R,samples:b}}function zd(i){const e=this;let t=null,n=0,r=!1,s=!1;const a=new Ln,o=new Le,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(m,h){const d=m.length!==0||h||n!==0||r;return r=h,n=m.length,d},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(m,h){t=u(m,h,0)},this.setState=function(m,h,d){const x=m.clippingPlanes,y=m.clipIntersection,_=m.clipShadows,f=i.get(m);if(!r||x===null||x.length===0||s&&!_)s?u(null):l();else{const w=s?0:n,C=w*4;let S=f.clippingState||null;c.value=S,S=u(x,h,C,d);for(let R=0;R!==C;++R)S[R]=t[R];f.clippingState=S,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=w}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(m,h,d,x){const y=m!==null?m.length:0;let _=null;if(y!==0){if(_=c.value,x!==!0||_===null){const f=d+y*4,w=h.matrixWorldInverse;o.getNormalMatrix(w),(_===null||_.length<f)&&(_=new Float32Array(f));for(let C=0,S=d;C!==y;++C,S+=4)a.copy(m[C]).applyMatrix4(w,o),a.normal.toArray(_,S),_[S+3]=a.constant}c.value=_,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,_}}const Fn=4,Vo=[.125,.215,.35,.446,.526,.582],Zn=20,Gd=256,ki=new ql,Ho=new ze;let Ls=null,Is=0,Us=0,Ns=!1;const Vd=new D;class ko{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=.1,r=100,s={}){const{size:a=256,position:o=Vd}=s;Ls=this._renderer.getRenderTarget(),Is=this._renderer.getActiveCubeFace(),Us=this._renderer.getActiveMipmapLevel(),Ns=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,n,r,c,o),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Yo(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Xo(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Ls,Is,Us),this._renderer.xr.enabled=Ns,e.scissorTest=!1,yi(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Qn||e.mapping===Pi?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Ls=this._renderer.getRenderTarget(),Is=this._renderer.getActiveCubeFace(),Us=this._renderer.getActiveMipmapLevel(),Ns=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:wt,minFilter:wt,generateMipmaps:!1,type:xn,format:Zt,colorSpace:Fr,depthBuffer:!1},r=Wo(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Wo(e,t,n);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=Hd(s)),this._blurMaterial=Wd(s,e,t),this._ggxMaterial=kd(s,e,t)}return r}_compileMaterial(e){const t=new Mn(new Xt,e);this._renderer.compile(t,ki)}_sceneToCubeUV(e,t,n,r,s){const c=new Ht(90,1,t,n),l=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],m=this._renderer,h=m.autoClear,d=m.toneMapping;m.getClearColor(Ho),m.toneMapping=sn,m.autoClear=!1,m.state.buffers.depth.getReversed()&&(m.setRenderTarget(r),m.clearDepth(),m.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Mn(new $i,new Gl({name:"PMREM.Background",side:Nt,depthWrite:!1,depthTest:!1})));const y=this._backgroundBox,_=y.material;let f=!1;const w=e.background;w?w.isColor&&(_.color.copy(w),e.background=null,f=!0):(_.color.copy(Ho),f=!0);for(let C=0;C<6;C++){const S=C%3;S===0?(c.up.set(0,l[C],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x+u[C],s.y,s.z)):S===1?(c.up.set(0,0,l[C]),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y+u[C],s.z)):(c.up.set(0,l[C],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y,s.z+u[C]));const R=this._cubeSize;yi(r,S*R,C>2?R:0,R,R),m.setRenderTarget(r),f&&m.render(y,c),m.render(e,c)}m.toneMapping=d,m.autoClear=h,e.background=w}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===Qn||e.mapping===Pi;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=Yo()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Xo());const s=r?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=s;const o=s.uniforms;o.envMap.value=e;const c=this._cubeSize;yi(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(a,ki)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodMeshes.length;for(let s=1;s<r;s++)this._applyGGXFilter(e,s-1,s);t.autoClear=n}_applyGGXFilter(e,t,n){const r=this._renderer,s=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[n];o.material=a;const c=a.uniforms,l=n/(this._lodMeshes.length-1),u=t/(this._lodMeshes.length-1),m=Math.sqrt(l*l-u*u),h=0+l*1.25,d=m*h,{_lodMax:x}=this,y=this._sizeLods[n],_=3*y*(n>x-Fn?n-x+Fn:0),f=4*(this._cubeSize-y);c.envMap.value=e.texture,c.roughness.value=d,c.mipInt.value=x-t,yi(s,_,f,3*y,2*y),r.setRenderTarget(s),r.render(o,ki),c.envMap.value=s.texture,c.roughness.value=0,c.mipInt.value=x-n,yi(e,_,f,3*y,2*y),r.setRenderTarget(e),r.render(o,ki)}_blur(e,t,n,r,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,"latitudinal",s),this._halfBlur(a,e,n,n,r,"longitudinal",s)}_halfBlur(e,t,n,r,s,a,o){const c=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&He("blur direction must be either latitudinal or longitudinal!");const u=3,m=this._lodMeshes[r];m.material=l;const h=l.uniforms,d=this._sizeLods[n]-1,x=isFinite(s)?Math.PI/(2*d):2*Math.PI/(2*Zn-1),y=s/x,_=isFinite(s)?1+Math.floor(u*y):Zn;_>Zn&&we(`sigmaRadians, ${s}, is too large and will clip, as it requested ${_} samples when the maximum is set to ${Zn}`);const f=[];let w=0;for(let P=0;P<Zn;++P){const g=P/y,T=Math.exp(-g*g/2);f.push(T),P===0?w+=T:P<_&&(w+=2*T)}for(let P=0;P<f.length;P++)f[P]=f[P]/w;h.envMap.value=e.texture,h.samples.value=_,h.weights.value=f,h.latitudinal.value=a==="latitudinal",o&&(h.poleAxis.value=o);const{_lodMax:C}=this;h.dTheta.value=x,h.mipInt.value=C-n;const S=this._sizeLods[r],R=3*S*(r>C-Fn?r-C+Fn:0),b=4*(this._cubeSize-S);yi(t,R,b,3*S,2*S),c.setRenderTarget(t),c.render(m,ki)}}function Hd(i){const e=[],t=[],n=[];let r=i;const s=i-Fn+1+Vo.length;for(let a=0;a<s;a++){const o=Math.pow(2,r);e.push(o);let c=1/o;a>i-Fn?c=Vo[a-i+Fn-1]:a===0&&(c=0),t.push(c);const l=1/(o-2),u=-l,m=1+l,h=[u,u,m,u,m,m,u,u,m,m,u,m],d=6,x=6,y=3,_=2,f=1,w=new Float32Array(y*x*d),C=new Float32Array(_*x*d),S=new Float32Array(f*x*d);for(let b=0;b<d;b++){const P=b%3*2/3-1,g=b>2?0:-1,T=[P,g,0,P+2/3,g,0,P+2/3,g+1,0,P,g,0,P+2/3,g+1,0,P,g+1,0];w.set(T,y*x*b),C.set(h,_*x*b);const U=[b,b,b,b,b,b];S.set(U,f*x*b)}const R=new Xt;R.setAttribute("position",new $t(w,y)),R.setAttribute("uv",new $t(C,_)),R.setAttribute("faceIndex",new $t(S,f)),n.push(new Mn(R,null)),r>Fn&&r--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function Wo(i,e,t){const n=new an(i,e,t);return n.texture.mapping=Xr,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function yi(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function kd(i,e,t){return new ln({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Gd,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Zr(),fragmentShader:`
3671
+ }`,Ne={alphahash_fragment:jh,alphahash_pars_fragment:eu,alphamap_fragment:tu,alphamap_pars_fragment:nu,alphatest_fragment:iu,alphatest_pars_fragment:ru,aomap_fragment:su,aomap_pars_fragment:au,batching_pars_vertex:ou,batching_vertex:lu,begin_vertex:cu,beginnormal_vertex:hu,bsdfs:uu,iridescence_fragment:fu,bumpmap_pars_fragment:du,clipping_planes_fragment:pu,clipping_planes_pars_fragment:mu,clipping_planes_pars_vertex:_u,clipping_planes_vertex:gu,color_fragment:xu,color_pars_fragment:vu,color_pars_vertex:Mu,color_vertex:Su,common:Eu,cube_uv_reflection_fragment:yu,defaultnormal_vertex:bu,displacementmap_pars_vertex:Tu,displacementmap_vertex:Au,emissivemap_fragment:Ru,emissivemap_pars_fragment:wu,colorspace_fragment:Cu,colorspace_pars_fragment:Pu,envmap_fragment:Du,envmap_common_pars_fragment:Lu,envmap_pars_fragment:Iu,envmap_pars_vertex:Uu,envmap_physical_pars_fragment:Xu,envmap_vertex:Nu,fog_vertex:Fu,fog_pars_vertex:Ou,fog_fragment:Bu,fog_pars_fragment:zu,gradientmap_pars_fragment:Gu,lightmap_pars_fragment:Vu,lights_lambert_fragment:Hu,lights_lambert_pars_fragment:ku,lights_pars_begin:Wu,lights_toon_fragment:Yu,lights_toon_pars_fragment:qu,lights_phong_fragment:Ku,lights_phong_pars_fragment:Zu,lights_physical_fragment:$u,lights_physical_pars_fragment:Ju,lights_fragment_begin:Qu,lights_fragment_maps:ju,lights_fragment_end:ef,lightprobes_pars_fragment:tf,logdepthbuf_fragment:nf,logdepthbuf_pars_fragment:rf,logdepthbuf_pars_vertex:sf,logdepthbuf_vertex:af,map_fragment:of,map_pars_fragment:lf,map_particle_fragment:cf,map_particle_pars_fragment:hf,metalnessmap_fragment:uf,metalnessmap_pars_fragment:ff,morphinstance_vertex:df,morphcolor_vertex:pf,morphnormal_vertex:mf,morphtarget_pars_vertex:_f,morphtarget_vertex:gf,normal_fragment_begin:xf,normal_fragment_maps:vf,normal_pars_fragment:Mf,normal_pars_vertex:Sf,normal_vertex:Ef,normalmap_pars_fragment:yf,clearcoat_normal_fragment_begin:bf,clearcoat_normal_fragment_maps:Tf,clearcoat_pars_fragment:Af,iridescence_pars_fragment:Rf,opaque_fragment:wf,packing:Cf,premultiplied_alpha_fragment:Pf,project_vertex:Df,dithering_fragment:Lf,dithering_pars_fragment:If,roughnessmap_fragment:Uf,roughnessmap_pars_fragment:Nf,shadowmap_pars_fragment:Ff,shadowmap_pars_vertex:Of,shadowmap_vertex:Bf,shadowmask_pars_fragment:zf,skinbase_vertex:Gf,skinning_pars_vertex:Vf,skinning_vertex:Hf,skinnormal_vertex:kf,specularmap_fragment:Wf,specularmap_pars_fragment:Xf,tonemapping_fragment:Yf,tonemapping_pars_fragment:qf,transmission_fragment:Kf,transmission_pars_fragment:Zf,uv_pars_fragment:$f,uv_pars_vertex:Jf,uv_vertex:Qf,worldpos_vertex:jf,background_vert:ed,background_frag:td,backgroundCube_vert:nd,backgroundCube_frag:id,cube_vert:rd,cube_frag:sd,depth_vert:ad,depth_frag:od,distance_vert:ld,distance_frag:cd,equirect_vert:hd,equirect_frag:ud,linedashed_vert:fd,linedashed_frag:dd,meshbasic_vert:pd,meshbasic_frag:md,meshlambert_vert:_d,meshlambert_frag:gd,meshmatcap_vert:xd,meshmatcap_frag:vd,meshnormal_vert:Md,meshnormal_frag:Sd,meshphong_vert:Ed,meshphong_frag:yd,meshphysical_vert:bd,meshphysical_frag:Td,meshtoon_vert:Ad,meshtoon_frag:Rd,points_vert:wd,points_frag:Cd,shadow_vert:Pd,shadow_frag:Dd,sprite_vert:Ld,sprite_frag:Id},pe={common:{diffuse:{value:new ze(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Le},alphaMap:{value:null},alphaMapTransform:{value:new Le},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Le}},envmap:{envMap:{value:null},envMapRotation:{value:new Le},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Le}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Le}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Le},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Le},normalScale:{value:new Ce(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Le},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Le}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Le}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Le}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ze(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new D},probesMax:{value:new D},probesResolution:{value:new D}},points:{diffuse:{value:new ze(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Le},alphaTest:{value:0},uvTransform:{value:new Le}},sprite:{diffuse:{value:new ze(16777215)},opacity:{value:1},center:{value:new Ce(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Le},alphaMap:{value:null},alphaMapTransform:{value:new Le},alphaTest:{value:0}}},en={basic:{uniforms:Dt([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.fog]),vertexShader:Ne.meshbasic_vert,fragmentShader:Ne.meshbasic_frag},lambert:{uniforms:Dt([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,pe.lights,{emissive:{value:new ze(0)},envMapIntensity:{value:1}}]),vertexShader:Ne.meshlambert_vert,fragmentShader:Ne.meshlambert_frag},phong:{uniforms:Dt([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,pe.lights,{emissive:{value:new ze(0)},specular:{value:new ze(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ne.meshphong_vert,fragmentShader:Ne.meshphong_frag},standard:{uniforms:Dt([pe.common,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.roughnessmap,pe.metalnessmap,pe.fog,pe.lights,{emissive:{value:new ze(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ne.meshphysical_vert,fragmentShader:Ne.meshphysical_frag},toon:{uniforms:Dt([pe.common,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.gradientmap,pe.fog,pe.lights,{emissive:{value:new ze(0)}}]),vertexShader:Ne.meshtoon_vert,fragmentShader:Ne.meshtoon_frag},matcap:{uniforms:Dt([pe.common,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,{matcap:{value:null}}]),vertexShader:Ne.meshmatcap_vert,fragmentShader:Ne.meshmatcap_frag},points:{uniforms:Dt([pe.points,pe.fog]),vertexShader:Ne.points_vert,fragmentShader:Ne.points_frag},dashed:{uniforms:Dt([pe.common,pe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ne.linedashed_vert,fragmentShader:Ne.linedashed_frag},depth:{uniforms:Dt([pe.common,pe.displacementmap]),vertexShader:Ne.depth_vert,fragmentShader:Ne.depth_frag},normal:{uniforms:Dt([pe.common,pe.bumpmap,pe.normalmap,pe.displacementmap,{opacity:{value:1}}]),vertexShader:Ne.meshnormal_vert,fragmentShader:Ne.meshnormal_frag},sprite:{uniforms:Dt([pe.sprite,pe.fog]),vertexShader:Ne.sprite_vert,fragmentShader:Ne.sprite_frag},background:{uniforms:{uvTransform:{value:new Le},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ne.background_vert,fragmentShader:Ne.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Le}},vertexShader:Ne.backgroundCube_vert,fragmentShader:Ne.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ne.cube_vert,fragmentShader:Ne.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ne.equirect_vert,fragmentShader:Ne.equirect_frag},distance:{uniforms:Dt([pe.common,pe.displacementmap,{referencePosition:{value:new D},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ne.distance_vert,fragmentShader:Ne.distance_frag},shadow:{uniforms:Dt([pe.lights,pe.fog,{color:{value:new ze(0)},opacity:{value:1}}]),vertexShader:Ne.shadow_vert,fragmentShader:Ne.shadow_frag}};en.physical={uniforms:Dt([en.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Le},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Le},clearcoatNormalScale:{value:new Ce(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Le},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Le},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Le},sheen:{value:0},sheenColor:{value:new ze(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Le},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Le},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Le},transmissionSamplerSize:{value:new Ce},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Le},attenuationDistance:{value:0},attenuationColor:{value:new ze(0)},specularColor:{value:new ze(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Le},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Le},anisotropyVector:{value:new Ce},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Le}}]),vertexShader:Ne.meshphysical_vert,fragmentShader:Ne.meshphysical_frag};const Tr={r:0,b:0,g:0},Ud=new at,Zl=new Le;Zl.set(-1,0,0,0,1,0,0,0,1);function Nd(i,e,t,n,r,s){const a=new ze(0);let o=r===!0?0:1,c,l,u=null,m=0,h=null;function d(w){let C=w.isScene===!0?w.background:null;if(C&&C.isTexture){const S=w.backgroundBlurriness>0;C=e.get(C,S)}return C}function x(w){let C=!1;const S=d(w);S===null?_(a,o):S&&S.isColor&&(_(S,1),C=!0);const R=i.xr.getEnvironmentBlendMode();R==="additive"?t.buffers.color.setClear(0,0,0,1,s):R==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,s),(i.autoClear||C)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function y(w,C){const S=d(C);S&&(S.isCubeTexture||S.mapping===Yr)?(l===void 0&&(l=new Mn(new $i(1,1,1),new ln({name:"BackgroundCubeMaterial",uniforms:Li(en.backgroundCube.uniforms),vertexShader:en.backgroundCube.vertexShader,fragmentShader:en.backgroundCube.fragmentShader,side:Nt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(R,b,P){this.matrixWorld.copyPosition(P.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),l.material.uniforms.envMap.value=S,l.material.uniforms.backgroundBlurriness.value=C.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=C.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(Ud.makeRotationFromEuler(C.backgroundRotation)).transpose(),S.isCubeTexture&&S.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(Zl),l.material.toneMapped=ke.getTransfer(S.colorSpace)!==$e,(u!==S||m!==S.version||h!==i.toneMapping)&&(l.material.needsUpdate=!0,u=S,m=S.version,h=i.toneMapping),l.layers.enableAll(),w.unshift(l,l.geometry,l.material,0,0,null)):S&&S.isTexture&&(c===void 0&&(c=new Mn(new Zr(2,2),new ln({name:"BackgroundMaterial",uniforms:Li(en.background.uniforms),vertexShader:en.background.vertexShader,fragmentShader:en.background.fragmentShader,side:zn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(c)),c.material.uniforms.t2D.value=S,c.material.uniforms.backgroundIntensity.value=C.backgroundIntensity,c.material.toneMapped=ke.getTransfer(S.colorSpace)!==$e,S.matrixAutoUpdate===!0&&S.updateMatrix(),c.material.uniforms.uvTransform.value.copy(S.matrix),(u!==S||m!==S.version||h!==i.toneMapping)&&(c.material.needsUpdate=!0,u=S,m=S.version,h=i.toneMapping),c.layers.enableAll(),w.unshift(c,c.geometry,c.material,0,0,null))}function _(w,C){w.getRGB(Tr,Xl(i)),t.buffers.color.setClear(Tr.r,Tr.g,Tr.b,C,s)}function f(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return a},setClearColor:function(w,C=1){a.set(w),o=C,_(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(w){o=w,_(a,o)},render:x,addToRenderList:y,dispose:f}}function Fd(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=h(null);let s=r,a=!1;function o(L,z,$,j,H){let Z=!1;const X=m(L,j,$,z);s!==X&&(s=X,l(s.object)),Z=d(L,j,$,H),Z&&x(L,j,$,H),H!==null&&e.update(H,i.ELEMENT_ARRAY_BUFFER),(Z||a)&&(a=!1,S(L,z,$,j),H!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(H).buffer))}function c(){return i.createVertexArray()}function l(L){return i.bindVertexArray(L)}function u(L){return i.deleteVertexArray(L)}function m(L,z,$,j){const H=j.wireframe===!0;let Z=n[z.id];Z===void 0&&(Z={},n[z.id]=Z);const X=L.isInstancedMesh===!0?L.id:0;let te=Z[X];te===void 0&&(te={},Z[X]=te);let ie=te[$.id];ie===void 0&&(ie={},te[$.id]=ie);let fe=ie[H];return fe===void 0&&(fe=h(c()),ie[H]=fe),fe}function h(L){const z=[],$=[],j=[];for(let H=0;H<t;H++)z[H]=0,$[H]=0,j[H]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:z,enabledAttributes:$,attributeDivisors:j,object:L,attributes:{},index:null}}function d(L,z,$,j){const H=s.attributes,Z=z.attributes;let X=0;const te=$.getAttributes();for(const ie in te)if(te[ie].location>=0){const me=H[ie];let Me=Z[ie];if(Me===void 0&&(ie==="instanceMatrix"&&L.instanceMatrix&&(Me=L.instanceMatrix),ie==="instanceColor"&&L.instanceColor&&(Me=L.instanceColor)),me===void 0||me.attribute!==Me||Me&&me.data!==Me.data)return!0;X++}return s.attributesNum!==X||s.index!==j}function x(L,z,$,j){const H={},Z=z.attributes;let X=0;const te=$.getAttributes();for(const ie in te)if(te[ie].location>=0){let me=Z[ie];me===void 0&&(ie==="instanceMatrix"&&L.instanceMatrix&&(me=L.instanceMatrix),ie==="instanceColor"&&L.instanceColor&&(me=L.instanceColor));const Me={};Me.attribute=me,me&&me.data&&(Me.data=me.data),H[ie]=Me,X++}s.attributes=H,s.attributesNum=X,s.index=j}function y(){const L=s.newAttributes;for(let z=0,$=L.length;z<$;z++)L[z]=0}function _(L){f(L,0)}function f(L,z){const $=s.newAttributes,j=s.enabledAttributes,H=s.attributeDivisors;$[L]=1,j[L]===0&&(i.enableVertexAttribArray(L),j[L]=1),H[L]!==z&&(i.vertexAttribDivisor(L,z),H[L]=z)}function w(){const L=s.newAttributes,z=s.enabledAttributes;for(let $=0,j=z.length;$<j;$++)z[$]!==L[$]&&(i.disableVertexAttribArray($),z[$]=0)}function C(L,z,$,j,H,Z,X){X===!0?i.vertexAttribIPointer(L,z,$,H,Z):i.vertexAttribPointer(L,z,$,j,H,Z)}function S(L,z,$,j){y();const H=j.attributes,Z=$.getAttributes(),X=z.defaultAttributeValues;for(const te in Z){const ie=Z[te];if(ie.location>=0){let fe=H[te];if(fe===void 0&&(te==="instanceMatrix"&&L.instanceMatrix&&(fe=L.instanceMatrix),te==="instanceColor"&&L.instanceColor&&(fe=L.instanceColor)),fe!==void 0){const me=fe.normalized,Me=fe.itemSize,Xe=e.get(fe);if(Xe===void 0)continue;const rt=Xe.buffer,Ye=Xe.type,Q=Xe.bytesPerElement,le=Ye===i.INT||Ye===i.UNSIGNED_INT||fe.gpuType===Ua;if(fe.isInterleavedBufferAttribute){const re=fe.data,Pe=re.stride,De=fe.offset;if(re.isInstancedInterleavedBuffer){for(let Re=0;Re<ie.locationSize;Re++)f(ie.location+Re,re.meshPerAttribute);L.isInstancedMesh!==!0&&j._maxInstanceCount===void 0&&(j._maxInstanceCount=re.meshPerAttribute*re.count)}else for(let Re=0;Re<ie.locationSize;Re++)_(ie.location+Re);i.bindBuffer(i.ARRAY_BUFFER,rt);for(let Re=0;Re<ie.locationSize;Re++)C(ie.location+Re,Me/ie.locationSize,Ye,me,Pe*Q,(De+Me/ie.locationSize*Re)*Q,le)}else{if(fe.isInstancedBufferAttribute){for(let re=0;re<ie.locationSize;re++)f(ie.location+re,fe.meshPerAttribute);L.isInstancedMesh!==!0&&j._maxInstanceCount===void 0&&(j._maxInstanceCount=fe.meshPerAttribute*fe.count)}else for(let re=0;re<ie.locationSize;re++)_(ie.location+re);i.bindBuffer(i.ARRAY_BUFFER,rt);for(let re=0;re<ie.locationSize;re++)C(ie.location+re,Me/ie.locationSize,Ye,me,Me*Q,Me/ie.locationSize*re*Q,le)}}else if(X!==void 0){const me=X[te];if(me!==void 0)switch(me.length){case 2:i.vertexAttrib2fv(ie.location,me);break;case 3:i.vertexAttrib3fv(ie.location,me);break;case 4:i.vertexAttrib4fv(ie.location,me);break;default:i.vertexAttrib1fv(ie.location,me)}}}}w()}function R(){T();for(const L in n){const z=n[L];for(const $ in z){const j=z[$];for(const H in j){const Z=j[H];for(const X in Z)u(Z[X].object),delete Z[X];delete j[H]}}delete n[L]}}function b(L){if(n[L.id]===void 0)return;const z=n[L.id];for(const $ in z){const j=z[$];for(const H in j){const Z=j[H];for(const X in Z)u(Z[X].object),delete Z[X];delete j[H]}}delete n[L.id]}function P(L){for(const z in n){const $=n[z];for(const j in $){const H=$[j];if(H[L.id]===void 0)continue;const Z=H[L.id];for(const X in Z)u(Z[X].object),delete Z[X];delete H[L.id]}}}function g(L){for(const z in n){const $=n[z],j=L.isInstancedMesh===!0?L.id:0,H=$[j];if(H!==void 0){for(const Z in H){const X=H[Z];for(const te in X)u(X[te].object),delete X[te];delete H[Z]}delete $[j],Object.keys($).length===0&&delete n[z]}}}function T(){U(),a=!0,s!==r&&(s=r,l(s.object))}function U(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:T,resetDefaultState:U,dispose:R,releaseStatesOfGeometry:b,releaseStatesOfObject:g,releaseStatesOfProgram:P,initAttributes:y,enableAttribute:_,disableUnusedAttributes:w}}function Od(i,e,t){let n;function r(c){n=c}function s(c,l){i.drawArrays(n,c,l),t.update(l,n,1)}function a(c,l,u){u!==0&&(i.drawArraysInstanced(n,c,l,u),t.update(l,n,u))}function o(c,l,u){if(u===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,l,0,u);let h=0;for(let d=0;d<u;d++)h+=l[d];t.update(h,n,1)}this.setMode=r,this.render=s,this.renderInstances=a,this.renderMultiDraw=o}function Bd(i,e,t,n){let r;function s(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const P=e.get("EXT_texture_filter_anisotropic");r=i.getParameter(P.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(P){return!(P!==Zt&&n.convert(P)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(P){const g=P===xn&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(P!==kt&&n.convert(P)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&P!==nn&&!g)}function c(P){if(P==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";P="mediump"}return P==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp";const u=c(l);u!==l&&(we("WebGLRenderer:",l,"not supported, using",u,"instead."),l=u);const m=t.logarithmicDepthBuffer===!0,h=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&h===!1&&we("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const d=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),x=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),y=i.getParameter(i.MAX_TEXTURE_SIZE),_=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),f=i.getParameter(i.MAX_VERTEX_ATTRIBS),w=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),C=i.getParameter(i.MAX_VARYING_VECTORS),S=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),R=i.getParameter(i.MAX_SAMPLES),b=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:m,reversedDepthBuffer:h,maxTextures:d,maxVertexTextures:x,maxTextureSize:y,maxCubemapSize:_,maxAttributes:f,maxVertexUniforms:w,maxVaryings:C,maxFragmentUniforms:S,maxSamples:R,samples:b}}function zd(i){const e=this;let t=null,n=0,r=!1,s=!1;const a=new Ln,o=new Le,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(m,h){const d=m.length!==0||h||n!==0||r;return r=h,n=m.length,d},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(m,h){t=u(m,h,0)},this.setState=function(m,h,d){const x=m.clippingPlanes,y=m.clipIntersection,_=m.clipShadows,f=i.get(m);if(!r||x===null||x.length===0||s&&!_)s?u(null):l();else{const w=s?0:n,C=w*4;let S=f.clippingState||null;c.value=S,S=u(x,h,C,d);for(let R=0;R!==C;++R)S[R]=t[R];f.clippingState=S,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=w}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(m,h,d,x){const y=m!==null?m.length:0;let _=null;if(y!==0){if(_=c.value,x!==!0||_===null){const f=d+y*4,w=h.matrixWorldInverse;o.getNormalMatrix(w),(_===null||_.length<f)&&(_=new Float32Array(f));for(let C=0,S=d;C!==y;++C,S+=4)a.copy(m[C]).applyMatrix4(w,o),a.normal.toArray(_,S),_[S+3]=a.constant}c.value=_,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,_}}const Fn=4,Vo=[.125,.215,.35,.446,.526,.582],Zn=20,Gd=256,ki=new ql,Ho=new ze;let Ls=null,Is=0,Us=0,Ns=!1;const Vd=new D;class ko{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=.1,r=100,s={}){const{size:a=256,position:o=Vd}=s;Ls=this._renderer.getRenderTarget(),Is=this._renderer.getActiveCubeFace(),Us=this._renderer.getActiveMipmapLevel(),Ns=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,n,r,c,o),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Yo(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Xo(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Ls,Is,Us),this._renderer.xr.enabled=Ns,e.scissorTest=!1,yi(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Qn||e.mapping===Pi?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Ls=this._renderer.getRenderTarget(),Is=this._renderer.getActiveCubeFace(),Us=this._renderer.getActiveMipmapLevel(),Ns=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:wt,minFilter:wt,generateMipmaps:!1,type:xn,format:Zt,colorSpace:Or,depthBuffer:!1},r=Wo(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Wo(e,t,n);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=Hd(s)),this._blurMaterial=Wd(s,e,t),this._ggxMaterial=kd(s,e,t)}return r}_compileMaterial(e){const t=new Mn(new Xt,e);this._renderer.compile(t,ki)}_sceneToCubeUV(e,t,n,r,s){const c=new Ht(90,1,t,n),l=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],m=this._renderer,h=m.autoClear,d=m.toneMapping;m.getClearColor(Ho),m.toneMapping=sn,m.autoClear=!1,m.state.buffers.depth.getReversed()&&(m.setRenderTarget(r),m.clearDepth(),m.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Mn(new $i,new Gl({name:"PMREM.Background",side:Nt,depthWrite:!1,depthTest:!1})));const y=this._backgroundBox,_=y.material;let f=!1;const w=e.background;w?w.isColor&&(_.color.copy(w),e.background=null,f=!0):(_.color.copy(Ho),f=!0);for(let C=0;C<6;C++){const S=C%3;S===0?(c.up.set(0,l[C],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x+u[C],s.y,s.z)):S===1?(c.up.set(0,0,l[C]),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y+u[C],s.z)):(c.up.set(0,l[C],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y,s.z+u[C]));const R=this._cubeSize;yi(r,S*R,C>2?R:0,R,R),m.setRenderTarget(r),f&&m.render(y,c),m.render(e,c)}m.toneMapping=d,m.autoClear=h,e.background=w}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===Qn||e.mapping===Pi;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=Yo()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Xo());const s=r?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=s;const o=s.uniforms;o.envMap.value=e;const c=this._cubeSize;yi(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(a,ki)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodMeshes.length;for(let s=1;s<r;s++)this._applyGGXFilter(e,s-1,s);t.autoClear=n}_applyGGXFilter(e,t,n){const r=this._renderer,s=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[n];o.material=a;const c=a.uniforms,l=n/(this._lodMeshes.length-1),u=t/(this._lodMeshes.length-1),m=Math.sqrt(l*l-u*u),h=0+l*1.25,d=m*h,{_lodMax:x}=this,y=this._sizeLods[n],_=3*y*(n>x-Fn?n-x+Fn:0),f=4*(this._cubeSize-y);c.envMap.value=e.texture,c.roughness.value=d,c.mipInt.value=x-t,yi(s,_,f,3*y,2*y),r.setRenderTarget(s),r.render(o,ki),c.envMap.value=s.texture,c.roughness.value=0,c.mipInt.value=x-n,yi(e,_,f,3*y,2*y),r.setRenderTarget(e),r.render(o,ki)}_blur(e,t,n,r,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,"latitudinal",s),this._halfBlur(a,e,n,n,r,"longitudinal",s)}_halfBlur(e,t,n,r,s,a,o){const c=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&He("blur direction must be either latitudinal or longitudinal!");const u=3,m=this._lodMeshes[r];m.material=l;const h=l.uniforms,d=this._sizeLods[n]-1,x=isFinite(s)?Math.PI/(2*d):2*Math.PI/(2*Zn-1),y=s/x,_=isFinite(s)?1+Math.floor(u*y):Zn;_>Zn&&we(`sigmaRadians, ${s}, is too large and will clip, as it requested ${_} samples when the maximum is set to ${Zn}`);const f=[];let w=0;for(let P=0;P<Zn;++P){const g=P/y,T=Math.exp(-g*g/2);f.push(T),P===0?w+=T:P<_&&(w+=2*T)}for(let P=0;P<f.length;P++)f[P]=f[P]/w;h.envMap.value=e.texture,h.samples.value=_,h.weights.value=f,h.latitudinal.value=a==="latitudinal",o&&(h.poleAxis.value=o);const{_lodMax:C}=this;h.dTheta.value=x,h.mipInt.value=C-n;const S=this._sizeLods[r],R=3*S*(r>C-Fn?r-C+Fn:0),b=4*(this._cubeSize-S);yi(t,R,b,3*S,2*S),c.setRenderTarget(t),c.render(m,ki)}}function Hd(i){const e=[],t=[],n=[];let r=i;const s=i-Fn+1+Vo.length;for(let a=0;a<s;a++){const o=Math.pow(2,r);e.push(o);let c=1/o;a>i-Fn?c=Vo[a-i+Fn-1]:a===0&&(c=0),t.push(c);const l=1/(o-2),u=-l,m=1+l,h=[u,u,m,u,m,m,u,u,m,m,u,m],d=6,x=6,y=3,_=2,f=1,w=new Float32Array(y*x*d),C=new Float32Array(_*x*d),S=new Float32Array(f*x*d);for(let b=0;b<d;b++){const P=b%3*2/3-1,g=b>2?0:-1,T=[P,g,0,P+2/3,g,0,P+2/3,g+1,0,P,g,0,P+2/3,g+1,0,P,g+1,0];w.set(T,y*x*b),C.set(h,_*x*b);const U=[b,b,b,b,b,b];S.set(U,f*x*b)}const R=new Xt;R.setAttribute("position",new $t(w,y)),R.setAttribute("uv",new $t(C,_)),R.setAttribute("faceIndex",new $t(S,f)),n.push(new Mn(R,null)),r>Fn&&r--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function Wo(i,e,t){const n=new an(i,e,t);return n.texture.mapping=Yr,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function yi(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function kd(i,e,t){return new ln({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Gd,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:$r(),fragmentShader:`
3672
3672
 
3673
3673
  precision highp float;
3674
3674
  precision highp int;
@@ -3772,7 +3772,7 @@ void main() {
3772
3772
 
3773
3773
  gl_FragColor = vec4(prefilteredColor, 1.0);
3774
3774
  }
3775
- `,blending:_n,depthTest:!1,depthWrite:!1})}function Wd(i,e,t){const n=new Float32Array(Zn),r=new D(0,1,0);return new ln({name:"SphericalGaussianBlur",defines:{n:Zn,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Zr(),fragmentShader:`
3775
+ `,blending:_n,depthTest:!1,depthWrite:!1})}function Wd(i,e,t){const n=new Float32Array(Zn),r=new D(0,1,0);return new ln({name:"SphericalGaussianBlur",defines:{n:Zn,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:$r(),fragmentShader:`
3776
3776
 
3777
3777
  precision mediump float;
3778
3778
  precision mediump int;
@@ -3832,7 +3832,7 @@ void main() {
3832
3832
  }
3833
3833
 
3834
3834
  }
3835
- `,blending:_n,depthTest:!1,depthWrite:!1})}function Xo(){return new ln({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Zr(),fragmentShader:`
3835
+ `,blending:_n,depthTest:!1,depthWrite:!1})}function Xo(){return new ln({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:$r(),fragmentShader:`
3836
3836
 
3837
3837
  precision mediump float;
3838
3838
  precision mediump int;
@@ -3851,7 +3851,7 @@ void main() {
3851
3851
  gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
3852
3852
 
3853
3853
  }
3854
- `,blending:_n,depthTest:!1,depthWrite:!1})}function Yo(){return new ln({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Zr(),fragmentShader:`
3854
+ `,blending:_n,depthTest:!1,depthWrite:!1})}function Yo(){return new ln({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:$r(),fragmentShader:`
3855
3855
 
3856
3856
  precision mediump float;
3857
3857
  precision mediump int;
@@ -3867,7 +3867,7 @@ void main() {
3867
3867
  gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
3868
3868
 
3869
3869
  }
3870
- `,blending:_n,depthTest:!1,depthWrite:!1})}function Zr(){return`
3870
+ `,blending:_n,depthTest:!1,depthWrite:!1})}function $r(){return`
3871
3871
 
3872
3872
  precision mediump float;
3873
3873
  precision mediump int;
@@ -4003,14 +4003,14 @@ void main() {
4003
4003
  #ifdef SRGB_TRANSFER
4004
4004
  gl_FragColor = sRGBTransferOETF( gl_FragColor );
4005
4005
  #endif
4006
- }`,depthTest:!1,depthWrite:!1}),u=new Mn(c,l),m=new ql(-1,1,1,-1,0,1);let h=null,d=null,x=!1,y,_=null,f=[],w=!1;this.setSize=function(C,S){a.setSize(C,S),o.setSize(C,S);for(let R=0;R<f.length;R++){const b=f[R];b.setSize&&b.setSize(C,S)}},this.setEffects=function(C){f=C,w=f.length>0&&f[0].isRenderPass===!0;const S=a.width,R=a.height;for(let b=0;b<f.length;b++){const P=f[b];P.setSize&&P.setSize(S,R)}},this.begin=function(C,S){if(x||C.toneMapping===sn&&f.length===0)return!1;if(_=S,S!==null){const R=S.width,b=S.height;(a.width!==R||a.height!==b)&&this.setSize(R,b)}return w===!1&&C.setRenderTarget(a),y=C.toneMapping,C.toneMapping=sn,!0},this.hasRenderPass=function(){return w},this.end=function(C,S){C.toneMapping=y,x=!0;let R=a,b=o;for(let P=0;P<f.length;P++){const g=f[P];if(g.enabled!==!1&&(g.render(C,b,R,S),g.needsSwap!==!1)){const T=R;R=b,b=T}}if(h!==C.outputColorSpace||d!==C.toneMapping){h=C.outputColorSpace,d=C.toneMapping,l.defines={},ke.getTransfer(h)===$e&&(l.defines.SRGB_TRANSFER="");const P=Qd[d];P&&(l.defines[P]=""),l.needsUpdate=!0}l.uniforms.tDiffuse.value=R.texture,C.setRenderTarget(_),C.render(u,m),_=null,x=!1},this.isCompositing=function(){return x},this.dispose=function(){a.depthTexture&&a.depthTexture.dispose(),a.dispose(),o.dispose(),c.dispose(),l.dispose()}}const Jl=new Ct,Pa=new Di(1,1),Ql=new Ul,jl=new uh,ec=new kl,qo=[],Ko=[],Zo=new Float32Array(16),$o=new Float32Array(9),Jo=new Float32Array(4);function Ui(i,e,t){const n=i[0];if(n<=0||n>0)return i;const r=e*t;let s=qo[r];if(s===void 0&&(s=new Float32Array(r),qo[r]=s),e!==0){n.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=t,i[a].toArray(s,o)}return s}function Mt(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t<n;t++)if(i[t]!==e[t])return!1;return!0}function St(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function $r(i,e){let t=Ko[e];t===void 0&&(t=new Int32Array(e),Ko[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function ep(i,e){const t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function tp(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Mt(t,e))return;i.uniform2fv(this.addr,e),St(t,e)}}function np(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.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)&&(i.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Mt(t,e))return;i.uniform3fv(this.addr,e),St(t,e)}}function ip(i,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)&&(i.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(Mt(t,e))return;i.uniform4fv(this.addr,e),St(t,e)}}function rp(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(Mt(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),St(t,e)}else{if(Mt(t,n))return;Jo.set(n),i.uniformMatrix2fv(this.addr,!1,Jo),St(t,n)}}function sp(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(Mt(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),St(t,e)}else{if(Mt(t,n))return;$o.set(n),i.uniformMatrix3fv(this.addr,!1,$o),St(t,n)}}function ap(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(Mt(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),St(t,e)}else{if(Mt(t,n))return;Zo.set(n),i.uniformMatrix4fv(this.addr,!1,Zo),St(t,n)}}function op(i,e){const t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function lp(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Mt(t,e))return;i.uniform2iv(this.addr,e),St(t,e)}}function cp(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Mt(t,e))return;i.uniform3iv(this.addr,e),St(t,e)}}function hp(i,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)&&(i.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(Mt(t,e))return;i.uniform4iv(this.addr,e),St(t,e)}}function up(i,e){const t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function fp(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Mt(t,e))return;i.uniform2uiv(this.addr,e),St(t,e)}}function dp(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Mt(t,e))return;i.uniform3uiv(this.addr,e),St(t,e)}}function pp(i,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)&&(i.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(Mt(t,e))return;i.uniform4uiv(this.addr,e),St(t,e)}}function mp(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r);let s;this.type===i.SAMPLER_2D_SHADOW?(Pa.compareFunction=t.isReversedDepthBuffer()?Va:Ga,s=Pa):s=Jl,t.setTexture2D(e||s,r)}function _p(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture3D(e||jl,r)}function gp(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTextureCube(e||ec,r)}function xp(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture2DArray(e||Ql,r)}function vp(i){switch(i){case 5126:return ep;case 35664:return tp;case 35665:return np;case 35666:return ip;case 35674:return rp;case 35675:return sp;case 35676:return ap;case 5124:case 35670:return op;case 35667:case 35671:return lp;case 35668:case 35672:return cp;case 35669:case 35673:return hp;case 5125:return up;case 36294:return fp;case 36295:return dp;case 36296:return pp;case 35678:case 36198:case 36298:case 36306:case 35682:return mp;case 35679:case 36299:case 36307:return _p;case 35680:case 36300:case 36308:case 36293:return gp;case 36289:case 36303:case 36311:case 36292:return xp}}function Mp(i,e){i.uniform1fv(this.addr,e)}function Sp(i,e){const t=Ui(e,this.size,2);i.uniform2fv(this.addr,t)}function Ep(i,e){const t=Ui(e,this.size,3);i.uniform3fv(this.addr,t)}function yp(i,e){const t=Ui(e,this.size,4);i.uniform4fv(this.addr,t)}function bp(i,e){const t=Ui(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function Tp(i,e){const t=Ui(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function Ap(i,e){const t=Ui(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function Rp(i,e){i.uniform1iv(this.addr,e)}function wp(i,e){i.uniform2iv(this.addr,e)}function Cp(i,e){i.uniform3iv(this.addr,e)}function Pp(i,e){i.uniform4iv(this.addr,e)}function Dp(i,e){i.uniform1uiv(this.addr,e)}function Lp(i,e){i.uniform2uiv(this.addr,e)}function Ip(i,e){i.uniform3uiv(this.addr,e)}function Up(i,e){i.uniform4uiv(this.addr,e)}function Np(i,e,t){const n=this.cache,r=e.length,s=$r(t,r);Mt(n,s)||(i.uniform1iv(this.addr,s),St(n,s));let a;this.type===i.SAMPLER_2D_SHADOW?a=Pa:a=Jl;for(let o=0;o!==r;++o)t.setTexture2D(e[o]||a,s[o])}function Fp(i,e,t){const n=this.cache,r=e.length,s=$r(t,r);Mt(n,s)||(i.uniform1iv(this.addr,s),St(n,s));for(let a=0;a!==r;++a)t.setTexture3D(e[a]||jl,s[a])}function Op(i,e,t){const n=this.cache,r=e.length,s=$r(t,r);Mt(n,s)||(i.uniform1iv(this.addr,s),St(n,s));for(let a=0;a!==r;++a)t.setTextureCube(e[a]||ec,s[a])}function Bp(i,e,t){const n=this.cache,r=e.length,s=$r(t,r);Mt(n,s)||(i.uniform1iv(this.addr,s),St(n,s));for(let a=0;a!==r;++a)t.setTexture2DArray(e[a]||Ql,s[a])}function zp(i){switch(i){case 5126:return Mp;case 35664:return Sp;case 35665:return Ep;case 35666:return yp;case 35674:return bp;case 35675:return Tp;case 35676:return Ap;case 5124:case 35670:return Rp;case 35667:case 35671:return wp;case 35668:case 35672:return Cp;case 35669:case 35673:return Pp;case 5125:return Dp;case 36294:return Lp;case 36295:return Ip;case 36296:return Up;case 35678:case 36198:case 36298:case 36306:case 35682:return Np;case 35679:case 36299:case 36307:return Fp;case 35680:case 36300:case 36308:case 36293:return Op;case 36289:case 36303:case 36311:case 36292:return Bp}}class Gp{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=vp(t.type)}}class Vp{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=zp(t.type)}}class Hp{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const r=this.seq;for(let s=0,a=r.length;s!==a;++s){const o=r[s];o.setValue(e,t[o.id],n)}}}const Fs=/(\w+)(\])?(\[|\.)?/g;function Qo(i,e){i.seq.push(e),i.map[e.id]=e}function kp(i,e,t){const n=i.name,r=n.length;for(Fs.lastIndex=0;;){const s=Fs.exec(n),a=Fs.lastIndex;let o=s[1];const c=s[2]==="]",l=s[3];if(c&&(o=o|0),l===void 0||l==="["&&a+2===r){Qo(t,l===void 0?new Gp(o,i,e):new Vp(o,i,e));break}else{let m=t.map[o];m===void 0&&(m=new Hp(o),Qo(t,m)),t=m}}}class Ir{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let a=0;a<n;++a){const o=e.getActiveUniform(t,a),c=e.getUniformLocation(t,o.name);kp(o,c,this)}const r=[],s=[];for(const a of this.seq)a.type===e.SAMPLER_2D_SHADOW||a.type===e.SAMPLER_CUBE_SHADOW||a.type===e.SAMPLER_2D_ARRAY_SHADOW?r.push(a):s.push(a);r.length>0&&(this.seq=r.concat(s))}setValue(e,t,n,r){const s=this.map[t];s!==void 0&&s.setValue(e,n,r)}setOptional(e,t,n){const r=t[n];r!==void 0&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let s=0,a=t.length;s!==a;++s){const o=t[s],c=n[o.id];c.needsUpdate!==!1&&o.setValue(e,c.value,r)}}static seqWithValue(e,t){const n=[];for(let r=0,s=e.length;r!==s;++r){const a=e[r];a.id in t&&n.push(a)}return n}}function jo(i,e,t){const n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}const Wp=37297;let Xp=0;function Yp(i,e){const t=i.split(`
4006
+ }`,depthTest:!1,depthWrite:!1}),u=new Mn(c,l),m=new ql(-1,1,1,-1,0,1);let h=null,d=null,x=!1,y,_=null,f=[],w=!1;this.setSize=function(C,S){a.setSize(C,S),o.setSize(C,S);for(let R=0;R<f.length;R++){const b=f[R];b.setSize&&b.setSize(C,S)}},this.setEffects=function(C){f=C,w=f.length>0&&f[0].isRenderPass===!0;const S=a.width,R=a.height;for(let b=0;b<f.length;b++){const P=f[b];P.setSize&&P.setSize(S,R)}},this.begin=function(C,S){if(x||C.toneMapping===sn&&f.length===0)return!1;if(_=S,S!==null){const R=S.width,b=S.height;(a.width!==R||a.height!==b)&&this.setSize(R,b)}return w===!1&&C.setRenderTarget(a),y=C.toneMapping,C.toneMapping=sn,!0},this.hasRenderPass=function(){return w},this.end=function(C,S){C.toneMapping=y,x=!0;let R=a,b=o;for(let P=0;P<f.length;P++){const g=f[P];if(g.enabled!==!1&&(g.render(C,b,R,S),g.needsSwap!==!1)){const T=R;R=b,b=T}}if(h!==C.outputColorSpace||d!==C.toneMapping){h=C.outputColorSpace,d=C.toneMapping,l.defines={},ke.getTransfer(h)===$e&&(l.defines.SRGB_TRANSFER="");const P=Qd[d];P&&(l.defines[P]=""),l.needsUpdate=!0}l.uniforms.tDiffuse.value=R.texture,C.setRenderTarget(_),C.render(u,m),_=null,x=!1},this.isCompositing=function(){return x},this.dispose=function(){a.depthTexture&&a.depthTexture.dispose(),a.dispose(),o.dispose(),c.dispose(),l.dispose()}}const Jl=new Ct,Pa=new Di(1,1),Ql=new Ul,jl=new uh,ec=new kl,qo=[],Ko=[],Zo=new Float32Array(16),$o=new Float32Array(9),Jo=new Float32Array(4);function Ui(i,e,t){const n=i[0];if(n<=0||n>0)return i;const r=e*t;let s=qo[r];if(s===void 0&&(s=new Float32Array(r),qo[r]=s),e!==0){n.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=t,i[a].toArray(s,o)}return s}function Mt(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t<n;t++)if(i[t]!==e[t])return!1;return!0}function St(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function Jr(i,e){let t=Ko[e];t===void 0&&(t=new Int32Array(e),Ko[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function ep(i,e){const t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function tp(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Mt(t,e))return;i.uniform2fv(this.addr,e),St(t,e)}}function np(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.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)&&(i.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Mt(t,e))return;i.uniform3fv(this.addr,e),St(t,e)}}function ip(i,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)&&(i.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(Mt(t,e))return;i.uniform4fv(this.addr,e),St(t,e)}}function rp(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(Mt(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),St(t,e)}else{if(Mt(t,n))return;Jo.set(n),i.uniformMatrix2fv(this.addr,!1,Jo),St(t,n)}}function sp(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(Mt(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),St(t,e)}else{if(Mt(t,n))return;$o.set(n),i.uniformMatrix3fv(this.addr,!1,$o),St(t,n)}}function ap(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(Mt(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),St(t,e)}else{if(Mt(t,n))return;Zo.set(n),i.uniformMatrix4fv(this.addr,!1,Zo),St(t,n)}}function op(i,e){const t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function lp(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Mt(t,e))return;i.uniform2iv(this.addr,e),St(t,e)}}function cp(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Mt(t,e))return;i.uniform3iv(this.addr,e),St(t,e)}}function hp(i,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)&&(i.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(Mt(t,e))return;i.uniform4iv(this.addr,e),St(t,e)}}function up(i,e){const t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function fp(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Mt(t,e))return;i.uniform2uiv(this.addr,e),St(t,e)}}function dp(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Mt(t,e))return;i.uniform3uiv(this.addr,e),St(t,e)}}function pp(i,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)&&(i.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(Mt(t,e))return;i.uniform4uiv(this.addr,e),St(t,e)}}function mp(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r);let s;this.type===i.SAMPLER_2D_SHADOW?(Pa.compareFunction=t.isReversedDepthBuffer()?Va:Ga,s=Pa):s=Jl,t.setTexture2D(e||s,r)}function _p(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture3D(e||jl,r)}function gp(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTextureCube(e||ec,r)}function xp(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture2DArray(e||Ql,r)}function vp(i){switch(i){case 5126:return ep;case 35664:return tp;case 35665:return np;case 35666:return ip;case 35674:return rp;case 35675:return sp;case 35676:return ap;case 5124:case 35670:return op;case 35667:case 35671:return lp;case 35668:case 35672:return cp;case 35669:case 35673:return hp;case 5125:return up;case 36294:return fp;case 36295:return dp;case 36296:return pp;case 35678:case 36198:case 36298:case 36306:case 35682:return mp;case 35679:case 36299:case 36307:return _p;case 35680:case 36300:case 36308:case 36293:return gp;case 36289:case 36303:case 36311:case 36292:return xp}}function Mp(i,e){i.uniform1fv(this.addr,e)}function Sp(i,e){const t=Ui(e,this.size,2);i.uniform2fv(this.addr,t)}function Ep(i,e){const t=Ui(e,this.size,3);i.uniform3fv(this.addr,t)}function yp(i,e){const t=Ui(e,this.size,4);i.uniform4fv(this.addr,t)}function bp(i,e){const t=Ui(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function Tp(i,e){const t=Ui(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function Ap(i,e){const t=Ui(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function Rp(i,e){i.uniform1iv(this.addr,e)}function wp(i,e){i.uniform2iv(this.addr,e)}function Cp(i,e){i.uniform3iv(this.addr,e)}function Pp(i,e){i.uniform4iv(this.addr,e)}function Dp(i,e){i.uniform1uiv(this.addr,e)}function Lp(i,e){i.uniform2uiv(this.addr,e)}function Ip(i,e){i.uniform3uiv(this.addr,e)}function Up(i,e){i.uniform4uiv(this.addr,e)}function Np(i,e,t){const n=this.cache,r=e.length,s=Jr(t,r);Mt(n,s)||(i.uniform1iv(this.addr,s),St(n,s));let a;this.type===i.SAMPLER_2D_SHADOW?a=Pa:a=Jl;for(let o=0;o!==r;++o)t.setTexture2D(e[o]||a,s[o])}function Fp(i,e,t){const n=this.cache,r=e.length,s=Jr(t,r);Mt(n,s)||(i.uniform1iv(this.addr,s),St(n,s));for(let a=0;a!==r;++a)t.setTexture3D(e[a]||jl,s[a])}function Op(i,e,t){const n=this.cache,r=e.length,s=Jr(t,r);Mt(n,s)||(i.uniform1iv(this.addr,s),St(n,s));for(let a=0;a!==r;++a)t.setTextureCube(e[a]||ec,s[a])}function Bp(i,e,t){const n=this.cache,r=e.length,s=Jr(t,r);Mt(n,s)||(i.uniform1iv(this.addr,s),St(n,s));for(let a=0;a!==r;++a)t.setTexture2DArray(e[a]||Ql,s[a])}function zp(i){switch(i){case 5126:return Mp;case 35664:return Sp;case 35665:return Ep;case 35666:return yp;case 35674:return bp;case 35675:return Tp;case 35676:return Ap;case 5124:case 35670:return Rp;case 35667:case 35671:return wp;case 35668:case 35672:return Cp;case 35669:case 35673:return Pp;case 5125:return Dp;case 36294:return Lp;case 36295:return Ip;case 36296:return Up;case 35678:case 36198:case 36298:case 36306:case 35682:return Np;case 35679:case 36299:case 36307:return Fp;case 35680:case 36300:case 36308:case 36293:return Op;case 36289:case 36303:case 36311:case 36292:return Bp}}class Gp{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=vp(t.type)}}class Vp{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=zp(t.type)}}class Hp{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const r=this.seq;for(let s=0,a=r.length;s!==a;++s){const o=r[s];o.setValue(e,t[o.id],n)}}}const Fs=/(\w+)(\])?(\[|\.)?/g;function Qo(i,e){i.seq.push(e),i.map[e.id]=e}function kp(i,e,t){const n=i.name,r=n.length;for(Fs.lastIndex=0;;){const s=Fs.exec(n),a=Fs.lastIndex;let o=s[1];const c=s[2]==="]",l=s[3];if(c&&(o=o|0),l===void 0||l==="["&&a+2===r){Qo(t,l===void 0?new Gp(o,i,e):new Vp(o,i,e));break}else{let m=t.map[o];m===void 0&&(m=new Hp(o),Qo(t,m)),t=m}}}class Ur{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let a=0;a<n;++a){const o=e.getActiveUniform(t,a),c=e.getUniformLocation(t,o.name);kp(o,c,this)}const r=[],s=[];for(const a of this.seq)a.type===e.SAMPLER_2D_SHADOW||a.type===e.SAMPLER_CUBE_SHADOW||a.type===e.SAMPLER_2D_ARRAY_SHADOW?r.push(a):s.push(a);r.length>0&&(this.seq=r.concat(s))}setValue(e,t,n,r){const s=this.map[t];s!==void 0&&s.setValue(e,n,r)}setOptional(e,t,n){const r=t[n];r!==void 0&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let s=0,a=t.length;s!==a;++s){const o=t[s],c=n[o.id];c.needsUpdate!==!1&&o.setValue(e,c.value,r)}}static seqWithValue(e,t){const n=[];for(let r=0,s=e.length;r!==s;++r){const a=e[r];a.id in t&&n.push(a)}return n}}function jo(i,e,t){const n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}const Wp=37297;let Xp=0;function Yp(i,e){const t=i.split(`
4007
4007
  `),n=[],r=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let a=r;a<s;a++){const o=a+1;n.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return n.join(`
4008
- `)}const el=new Le;function qp(i){ke._getMatrix(el,ke.workingColorSpace,i);const e=`mat3( ${el.elements.map(t=>t.toFixed(4))} )`;switch(ke.getTransfer(i)){case Or:return[e,"LinearTransferOETF"];case $e:return[e,"sRGBTransferOETF"];default:return we("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function tl(i,e,t){const n=i.getShaderParameter(e,i.COMPILE_STATUS),s=(i.getShaderInfoLog(e)||"").trim();if(n&&s==="")return"";const a=/ERROR: 0:(\d+)/.exec(s);if(a){const o=parseInt(a[1]);return t.toUpperCase()+`
4008
+ `)}const el=new Le;function qp(i){ke._getMatrix(el,ke.workingColorSpace,i);const e=`mat3( ${el.elements.map(t=>t.toFixed(4))} )`;switch(ke.getTransfer(i)){case Br:return[e,"LinearTransferOETF"];case $e:return[e,"sRGBTransferOETF"];default:return we("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function tl(i,e,t){const n=i.getShaderParameter(e,i.COMPILE_STATUS),s=(i.getShaderInfoLog(e)||"").trim();if(n&&s==="")return"";const a=/ERROR: 0:(\d+)/.exec(s);if(a){const o=parseInt(a[1]);return t.toUpperCase()+`
4009
4009
 
4010
4010
  `+s+`
4011
4011
 
4012
4012
  `+Yp(i.getShaderSource(e),o)}else return s}function Kp(i,e){const t=qp(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
4013
- `)}const Zp={[xl]:"Linear",[vl]:"Reinhard",[Ml]:"Cineon",[Sl]:"ACESFilmic",[yl]:"AgX",[bl]:"Neutral",[El]:"Custom"};function $p(i,e){const t=Zp[e];return t===void 0?(we("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Tr=new D;function Jp(){ke.getLuminanceCoefficients(Tr);const i=Tr.x.toFixed(4),e=Tr.y.toFixed(4),t=Tr.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
4013
+ `)}const Zp={[xl]:"Linear",[vl]:"Reinhard",[Ml]:"Cineon",[Sl]:"ACESFilmic",[yl]:"AgX",[bl]:"Neutral",[El]:"Custom"};function $p(i,e){const t=Zp[e];return t===void 0?(we("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Ar=new D;function Jp(){ke.getLuminanceCoefficients(Ar);const i=Ar.x.toFixed(4),e=Ar.y.toFixed(4),t=Ar.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
4014
4014
  `)}function Qp(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Yi).join(`
4015
4015
  `)}function jp(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
4016
4016
  `)}function em(i,e){const t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let r=0;r<n;r++){const s=i.getActiveAttrib(e,r),a=s.name;let o=1;s.type===i.FLOAT_MAT2&&(o=2),s.type===i.FLOAT_MAT3&&(o=3),s.type===i.FLOAT_MAT4&&(o=4),t[a]={type:s.type,location:i.getAttribLocation(e,a),locationSize:o}}return t}function Yi(i){return i!==""}function nl(i,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function il(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const tm=/^[ \t]*#include +<([\w\d./]+)>/gm;function Da(i){return i.replace(tm,im)}const nm=new Map;function im(i,e){let t=Ne[e];if(t===void 0){const n=nm.get(e);if(n!==void 0)t=Ne[n],we('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return Da(t)}const rm=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function rl(i){return i.replace(rm,sm)}function sm(i,e,t,n){let r="";for(let s=parseInt(e);s<parseInt(t);s++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function sl(i){let e=`precision ${i.precision} float;
@@ -4033,7 +4033,7 @@ void main() {
4033
4033
  `;return i.precision==="highp"?e+=`
4034
4034
  #define HIGH_PRECISION`:i.precision==="mediump"?e+=`
4035
4035
  #define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=`
4036
- #define LOW_PRECISION`),e}const am={[Rr]:"SHADOWMAP_TYPE_PCF",[Xi]:"SHADOWMAP_TYPE_VSM"};function om(i){return am[i.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const lm={[Qn]:"ENVMAP_TYPE_CUBE",[Pi]:"ENVMAP_TYPE_CUBE",[Xr]:"ENVMAP_TYPE_CUBE_UV"};function cm(i){return i.envMap===!1?"ENVMAP_TYPE_CUBE":lm[i.envMapMode]||"ENVMAP_TYPE_CUBE"}const hm={[Pi]:"ENVMAP_MODE_REFRACTION"};function um(i){return i.envMap===!1?"ENVMAP_MODE_REFLECTION":hm[i.envMapMode]||"ENVMAP_MODE_REFLECTION"}const fm={[gl]:"ENVMAP_BLENDING_MULTIPLY",[kc]:"ENVMAP_BLENDING_MIX",[Wc]:"ENVMAP_BLENDING_ADD"};function dm(i){return i.envMap===!1?"ENVMAP_BLENDING_NONE":fm[i.combine]||"ENVMAP_BLENDING_NONE"}function pm(i){const e=i.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:n,maxMip:t}}function mm(i,e,t,n){const r=i.getContext(),s=t.defines;let a=t.vertexShader,o=t.fragmentShader;const c=om(t),l=cm(t),u=um(t),m=dm(t),h=pm(t),d=Qp(t),x=jp(s),y=r.createProgram();let _,f,w=t.glslVersion?"#version "+t.glslVersion+`
4036
+ #define LOW_PRECISION`),e}const am={[wr]:"SHADOWMAP_TYPE_PCF",[Xi]:"SHADOWMAP_TYPE_VSM"};function om(i){return am[i.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const lm={[Qn]:"ENVMAP_TYPE_CUBE",[Pi]:"ENVMAP_TYPE_CUBE",[Yr]:"ENVMAP_TYPE_CUBE_UV"};function cm(i){return i.envMap===!1?"ENVMAP_TYPE_CUBE":lm[i.envMapMode]||"ENVMAP_TYPE_CUBE"}const hm={[Pi]:"ENVMAP_MODE_REFRACTION"};function um(i){return i.envMap===!1?"ENVMAP_MODE_REFLECTION":hm[i.envMapMode]||"ENVMAP_MODE_REFLECTION"}const fm={[gl]:"ENVMAP_BLENDING_MULTIPLY",[kc]:"ENVMAP_BLENDING_MIX",[Wc]:"ENVMAP_BLENDING_ADD"};function dm(i){return i.envMap===!1?"ENVMAP_BLENDING_NONE":fm[i.combine]||"ENVMAP_BLENDING_NONE"}function pm(i){const e=i.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:n,maxMip:t}}function mm(i,e,t,n){const r=i.getContext(),s=t.defines;let a=t.vertexShader,o=t.fragmentShader;const c=om(t),l=cm(t),u=um(t),m=dm(t),h=pm(t),d=Qp(t),x=jp(s),y=r.createProgram();let _,f,w=t.glslVersion?"#version "+t.glslVersion+`
4037
4037
  `:"";t.isRawShaderMaterial?(_=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,x].filter(Yi).join(`
4038
4038
  `),_.length>0&&(_+=`
4039
4039
  `),f=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,x].filter(Yi).join(`
@@ -4054,7 +4054,7 @@ Material Type: `+L.type+`
4054
4054
 
4055
4055
  Program Info Log: `+H+`
4056
4056
  `+fe+`
4057
- `+me)}else H!==""?we("WebGLProgram: Program Info Log:",H):(Z===""||X==="")&&(ie=!1);ie&&(L.diagnostics={runnable:te,programLog:H,vertexShader:{log:Z,prefix:_},fragmentShader:{log:X,prefix:f}})}r.deleteShader(R),r.deleteShader(b),g=new Ir(r,y),T=em(r,y)}let g;this.getUniforms=function(){return g===void 0&&P(this),g};let T;this.getAttributes=function(){return T===void 0&&P(this),T};let U=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return U===!1&&(U=r.getProgramParameter(y,Wp)),U},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(y),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Xp++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=R,this.fragmentShader=b,this}let _m=0;class gm{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){const r=this._getShaderCacheForMaterial(e);return r.has(t)===!1&&(r.add(t),t.usedTimes++),r.has(n)===!1&&(r.add(n),n.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new xm(e),t.set(e,n)),n}}class xm{constructor(e){this.id=_m++,this.code=e,this.usedTimes=0}}function vm(i){return i===jn||i===Ur||i===Nr}function Mm(i,e,t,n,r,s){const a=new ka,o=new gm,c=new Set,l=[],u=new Map,m=n.logarithmicDepthBuffer;let h=n.precision;const d={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function x(g){return c.add(g),g===0?"uv":`uv${g}`}function y(g,T,U,L,z,$){const j=L.fog,H=z.geometry,Z=g.isMeshStandardMaterial||g.isMeshLambertMaterial||g.isMeshPhongMaterial?L.environment:null,X=g.isMeshStandardMaterial||g.isMeshLambertMaterial&&!g.envMap||g.isMeshPhongMaterial&&!g.envMap,te=e.get(g.envMap||Z,X),ie=te&&te.mapping===Xr?te.image.height:null,fe=d[g.type];g.precision!==null&&(h=n.getMaxPrecision(g.precision),h!==g.precision&&we("WebGLProgram.getParameters:",g.precision,"not supported, using",h,"instead."));const me=H.morphAttributes.position||H.morphAttributes.normal||H.morphAttributes.color,Me=me!==void 0?me.length:0;let Xe=0;H.morphAttributes.position!==void 0&&(Xe=1),H.morphAttributes.normal!==void 0&&(Xe=2),H.morphAttributes.color!==void 0&&(Xe=3);let rt,Ye,Q,le;if(fe){const ue=en[fe];rt=ue.vertexShader,Ye=ue.fragmentShader}else{rt=g.vertexShader,Ye=g.fragmentShader;const ue=o.getVertexShaderStage(g),Ge=o.getFragmentShaderStage(g);o.update(g,ue,Ge),Q=ue.id,le=Ge.id}const re=i.getRenderTarget(),Pe=i.state.buffers.depth.getReversed(),De=z.isInstancedMesh===!0,Re=z.isBatchedMesh===!0,ot=!!g.map,Fe=!!g.matcap,Ze=!!te,We=!!g.aoMap,Ve=!!g.lightMap,lt=!!g.bumpMap&&g.wireframe===!1,ht=!!g.normalMap,_t=!!g.displacementMap,xt=!!g.emissiveMap,it=!!g.metalnessMap,ut=!!g.roughnessMap,I=g.anisotropy>0,yt=g.clearcoat>0,Ke=g.dispersion>0,E=g.iridescence>0,p=g.sheen>0,O=g.transmission>0,k=I&&!!g.anisotropyMap,Y=yt&&!!g.clearcoatMap,se=yt&&!!g.clearcoatNormalMap,ae=yt&&!!g.clearcoatRoughnessMap,K=E&&!!g.iridescenceMap,J=E&&!!g.iridescenceThicknessMap,oe=p&&!!g.sheenColorMap,Se=p&&!!g.sheenRoughnessMap,he=!!g.specularMap,ce=!!g.specularColorMap,ye=!!g.specularIntensityMap,be=O&&!!g.transmissionMap,A=O&&!!g.thicknessMap,M=!!g.gradientMap,B=!!g.alphaMap,N=g.alphaTest>0,ee=!!g.alphaHash,ne=!!g.extensions;let q=sn;g.toneMapped&&(re===null||re.isXRRenderTarget===!0)&&(q=i.toneMapping);const de={shaderID:fe,shaderType:g.type,shaderName:g.name,vertexShader:rt,fragmentShader:Ye,defines:g.defines,customVertexShaderID:Q,customFragmentShaderID:le,isRawShaderMaterial:g.isRawShaderMaterial===!0,glslVersion:g.glslVersion,precision:h,batching:Re,batchingColor:Re&&z._colorsTexture!==null,instancing:De,instancingColor:De&&z.instanceColor!==null,instancingMorph:De&&z.morphTexture!==null,outputColorSpace:re===null?i.outputColorSpace:re.isXRRenderTarget===!0?re.texture.colorSpace:ke.workingColorSpace,alphaToCoverage:!!g.alphaToCoverage,map:ot,matcap:Fe,envMap:Ze,envMapMode:Ze&&te.mapping,envMapCubeUVHeight:ie,aoMap:We,lightMap:Ve,bumpMap:lt,normalMap:ht,displacementMap:_t,emissiveMap:xt,normalMapObjectSpace:ht&&g.normalMapType===qc,normalMapTangentSpace:ht&&g.normalMapType===lo,packedNormalMap:ht&&g.normalMapType===lo&&vm(g.normalMap.format),metalnessMap:it,roughnessMap:ut,anisotropy:I,anisotropyMap:k,clearcoat:yt,clearcoatMap:Y,clearcoatNormalMap:se,clearcoatRoughnessMap:ae,dispersion:Ke,iridescence:E,iridescenceMap:K,iridescenceThicknessMap:J,sheen:p,sheenColorMap:oe,sheenRoughnessMap:Se,specularMap:he,specularColorMap:ce,specularIntensityMap:ye,transmission:O,transmissionMap:be,thicknessMap:A,gradientMap:M,opaque:g.transparent===!1&&g.blending===On&&g.alphaToCoverage===!1,alphaMap:B,alphaTest:N,alphaHash:ee,combine:g.combine,mapUv:ot&&x(g.map.channel),aoMapUv:We&&x(g.aoMap.channel),lightMapUv:Ve&&x(g.lightMap.channel),bumpMapUv:lt&&x(g.bumpMap.channel),normalMapUv:ht&&x(g.normalMap.channel),displacementMapUv:_t&&x(g.displacementMap.channel),emissiveMapUv:xt&&x(g.emissiveMap.channel),metalnessMapUv:it&&x(g.metalnessMap.channel),roughnessMapUv:ut&&x(g.roughnessMap.channel),anisotropyMapUv:k&&x(g.anisotropyMap.channel),clearcoatMapUv:Y&&x(g.clearcoatMap.channel),clearcoatNormalMapUv:se&&x(g.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ae&&x(g.clearcoatRoughnessMap.channel),iridescenceMapUv:K&&x(g.iridescenceMap.channel),iridescenceThicknessMapUv:J&&x(g.iridescenceThicknessMap.channel),sheenColorMapUv:oe&&x(g.sheenColorMap.channel),sheenRoughnessMapUv:Se&&x(g.sheenRoughnessMap.channel),specularMapUv:he&&x(g.specularMap.channel),specularColorMapUv:ce&&x(g.specularColorMap.channel),specularIntensityMapUv:ye&&x(g.specularIntensityMap.channel),transmissionMapUv:be&&x(g.transmissionMap.channel),thicknessMapUv:A&&x(g.thicknessMap.channel),alphaMapUv:B&&x(g.alphaMap.channel),vertexTangents:!!H.attributes.tangent&&(ht||I),vertexNormals:!!H.attributes.normal,vertexColors:g.vertexColors,vertexAlphas:g.vertexColors===!0&&!!H.attributes.color&&H.attributes.color.itemSize===4,pointsUvs:z.isPoints===!0&&!!H.attributes.uv&&(ot||B),fog:!!j,useFog:g.fog===!0,fogExp2:!!j&&j.isFogExp2,flatShading:g.wireframe===!1&&(g.flatShading===!0||H.attributes.normal===void 0&&ht===!1&&(g.isMeshLambertMaterial||g.isMeshPhongMaterial||g.isMeshStandardMaterial||g.isMeshPhysicalMaterial)),sizeAttenuation:g.sizeAttenuation===!0,logarithmicDepthBuffer:m,reversedDepthBuffer:Pe,skinning:z.isSkinnedMesh===!0,hasPositionAttribute:H.attributes.position!==void 0,morphTargets:H.morphAttributes.position!==void 0,morphNormals:H.morphAttributes.normal!==void 0,morphColors:H.morphAttributes.color!==void 0,morphTargetsCount:Me,morphTextureStride:Xe,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.length,numDirLightShadows:T.directionalShadowMap.length,numPointLightShadows:T.pointShadowMap.length,numSpotLightShadows:T.spotShadowMap.length,numSpotLightShadowsWithMaps:T.numSpotLightShadowsWithMaps,numLightProbes:T.numLightProbes,numLightProbeGrids:$.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:g.dithering,shadowMapEnabled:i.shadowMap.enabled&&U.length>0,shadowMapType:i.shadowMap.type,toneMapping:q,decodeVideoTexture:ot&&g.map.isVideoTexture===!0&&ke.getTransfer(g.map.colorSpace)===$e,decodeVideoTextureEmissive:xt&&g.emissiveMap.isVideoTexture===!0&&ke.getTransfer(g.emissiveMap.colorSpace)===$e,premultipliedAlpha:g.premultipliedAlpha,doubleSided:g.side===pn,flipSided:g.side===Nt,useDepthPacking:g.depthPacking>=0,depthPacking:g.depthPacking||0,index0AttributeName:g.index0AttributeName,extensionClipCullDistance:ne&&g.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ne&&g.extensions.multiDraw===!0||Re)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:g.customProgramCacheKey()};return de.vertexUv1s=c.has(1),de.vertexUv2s=c.has(2),de.vertexUv3s=c.has(3),c.clear(),de}function _(g){const T=[];if(g.shaderID?T.push(g.shaderID):(T.push(g.customVertexShaderID),T.push(g.customFragmentShaderID)),g.defines!==void 0)for(const U in g.defines)T.push(U),T.push(g.defines[U]);return g.isRawShaderMaterial===!1&&(f(T,g),w(T,g),T.push(i.outputColorSpace)),T.push(g.customProgramCacheKey),T.join()}function f(g,T){g.push(T.precision),g.push(T.outputColorSpace),g.push(T.envMapMode),g.push(T.envMapCubeUVHeight),g.push(T.mapUv),g.push(T.alphaMapUv),g.push(T.lightMapUv),g.push(T.aoMapUv),g.push(T.bumpMapUv),g.push(T.normalMapUv),g.push(T.displacementMapUv),g.push(T.emissiveMapUv),g.push(T.metalnessMapUv),g.push(T.roughnessMapUv),g.push(T.anisotropyMapUv),g.push(T.clearcoatMapUv),g.push(T.clearcoatNormalMapUv),g.push(T.clearcoatRoughnessMapUv),g.push(T.iridescenceMapUv),g.push(T.iridescenceThicknessMapUv),g.push(T.sheenColorMapUv),g.push(T.sheenRoughnessMapUv),g.push(T.specularMapUv),g.push(T.specularColorMapUv),g.push(T.specularIntensityMapUv),g.push(T.transmissionMapUv),g.push(T.thicknessMapUv),g.push(T.combine),g.push(T.fogExp2),g.push(T.sizeAttenuation),g.push(T.morphTargetsCount),g.push(T.morphAttributeCount),g.push(T.numDirLights),g.push(T.numPointLights),g.push(T.numSpotLights),g.push(T.numSpotLightMaps),g.push(T.numHemiLights),g.push(T.numRectAreaLights),g.push(T.numDirLightShadows),g.push(T.numPointLightShadows),g.push(T.numSpotLightShadows),g.push(T.numSpotLightShadowsWithMaps),g.push(T.numLightProbes),g.push(T.shadowMapType),g.push(T.toneMapping),g.push(T.numClippingPlanes),g.push(T.numClipIntersection),g.push(T.depthPacking)}function w(g,T){a.disableAll(),T.instancing&&a.enable(0),T.instancingColor&&a.enable(1),T.instancingMorph&&a.enable(2),T.matcap&&a.enable(3),T.envMap&&a.enable(4),T.normalMapObjectSpace&&a.enable(5),T.normalMapTangentSpace&&a.enable(6),T.clearcoat&&a.enable(7),T.iridescence&&a.enable(8),T.alphaTest&&a.enable(9),T.vertexColors&&a.enable(10),T.vertexAlphas&&a.enable(11),T.vertexUv1s&&a.enable(12),T.vertexUv2s&&a.enable(13),T.vertexUv3s&&a.enable(14),T.vertexTangents&&a.enable(15),T.anisotropy&&a.enable(16),T.alphaHash&&a.enable(17),T.batching&&a.enable(18),T.dispersion&&a.enable(19),T.batchingColor&&a.enable(20),T.gradientMap&&a.enable(21),T.packedNormalMap&&a.enable(22),T.vertexNormals&&a.enable(23),g.push(a.mask),a.disableAll(),T.fog&&a.enable(0),T.useFog&&a.enable(1),T.flatShading&&a.enable(2),T.logarithmicDepthBuffer&&a.enable(3),T.reversedDepthBuffer&&a.enable(4),T.skinning&&a.enable(5),T.morphTargets&&a.enable(6),T.morphNormals&&a.enable(7),T.morphColors&&a.enable(8),T.premultipliedAlpha&&a.enable(9),T.shadowMapEnabled&&a.enable(10),T.doubleSided&&a.enable(11),T.flipSided&&a.enable(12),T.useDepthPacking&&a.enable(13),T.dithering&&a.enable(14),T.transmission&&a.enable(15),T.sheen&&a.enable(16),T.opaque&&a.enable(17),T.pointsUvs&&a.enable(18),T.decodeVideoTexture&&a.enable(19),T.decodeVideoTextureEmissive&&a.enable(20),T.alphaToCoverage&&a.enable(21),T.numLightProbeGrids>0&&a.enable(22),T.hasPositionAttribute&&a.enable(23),g.push(a.mask)}function C(g){const T=d[g.type];let U;if(T){const L=en[T];U=Vh.clone(L.uniforms)}else U=g.uniforms;return U}function S(g,T){let U=u.get(T);return U!==void 0?++U.usedTimes:(U=new mm(i,T,g,r),l.push(U),u.set(T,U)),U}function R(g){if(--g.usedTimes===0){const T=l.indexOf(g);l[T]=l[l.length-1],l.pop(),u.delete(g.cacheKey),g.destroy()}}function b(g){o.remove(g)}function P(){o.dispose()}return{getParameters:y,getProgramCacheKey:_,getUniforms:C,acquireProgram:S,releaseProgram:R,releaseShaderCache:b,programs:l,dispose:P}}function Sm(){let i=new WeakMap;function e(a){return i.has(a)}function t(a){let o=i.get(a);return o===void 0&&(o={},i.set(a,o)),o}function n(a){i.delete(a)}function r(a,o,c){i.get(a)[o]=c}function s(){i=new WeakMap}return{has:e,get:t,remove:n,update:r,dispose:s}}function Em(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.materialVariant!==e.materialVariant?i.materialVariant-e.materialVariant:i.z!==e.z?i.z-e.z:i.id-e.id}function al(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function ol(){const i=[];let e=0;const t=[],n=[],r=[];function s(){e=0,t.length=0,n.length=0,r.length=0}function a(h){let d=0;return h.isInstancedMesh&&(d+=2),h.isSkinnedMesh&&(d+=1),d}function o(h,d,x,y,_,f){let w=i[e];return w===void 0?(w={id:h.id,object:h,geometry:d,material:x,materialVariant:a(h),groupOrder:y,renderOrder:h.renderOrder,z:_,group:f},i[e]=w):(w.id=h.id,w.object=h,w.geometry=d,w.material=x,w.materialVariant=a(h),w.groupOrder=y,w.renderOrder=h.renderOrder,w.z=_,w.group=f),e++,w}function c(h,d,x,y,_,f){const w=o(h,d,x,y,_,f);x.transmission>0?n.push(w):x.transparent===!0?r.push(w):t.push(w)}function l(h,d,x,y,_,f){const w=o(h,d,x,y,_,f);x.transmission>0?n.unshift(w):x.transparent===!0?r.unshift(w):t.unshift(w)}function u(h,d,x){t.length>1&&t.sort(h||Em),n.length>1&&n.sort(d||al),r.length>1&&r.sort(d||al),x&&(t.reverse(),n.reverse(),r.reverse())}function m(){for(let h=e,d=i.length;h<d;h++){const x=i[h];if(x.id===null)break;x.id=null,x.object=null,x.geometry=null,x.material=null,x.group=null}}return{opaque:t,transmissive:n,transparent:r,init:s,push:c,unshift:l,finish:m,sort:u}}function ym(){let i=new WeakMap;function e(n,r){const s=i.get(n);let a;return s===void 0?(a=new ol,i.set(n,[a])):r>=s.length?(a=new ol,s.push(a)):a=s[r],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function bm(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new D,color:new ze};break;case"SpotLight":t={position:new D,direction:new D,color:new ze,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new D,color:new ze,distance:0,decay:0};break;case"HemisphereLight":t={direction:new D,skyColor:new ze,groundColor:new ze};break;case"RectAreaLight":t={color:new ze,position:new D,halfWidth:new D,halfHeight:new D};break}return i[e.id]=t,t}}}function Tm(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ce};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ce};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ce,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let Am=0;function Rm(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function wm(i){const e=new bm,t=Tm(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)n.probe.push(new D);const r=new D,s=new at,a=new at;function o(l){let u=0,m=0,h=0;for(let T=0;T<9;T++)n.probe[T].set(0,0,0);let d=0,x=0,y=0,_=0,f=0,w=0,C=0,S=0,R=0,b=0,P=0;l.sort(Rm);for(let T=0,U=l.length;T<U;T++){const L=l[T],z=L.color,$=L.intensity,j=L.distance;let H=null;if(L.shadow&&L.shadow.map&&(L.shadow.map.texture.format===jn?H=L.shadow.map.texture:H=L.shadow.map.depthTexture||L.shadow.map.texture),L.isAmbientLight)u+=z.r*$,m+=z.g*$,h+=z.b*$;else if(L.isLightProbe){for(let Z=0;Z<9;Z++)n.probe[Z].addScaledVector(L.sh.coefficients[Z],$);P++}else if(L.isDirectionalLight){const Z=e.get(L);if(Z.color.copy(L.color).multiplyScalar(L.intensity),L.castShadow){const X=L.shadow,te=t.get(L);te.shadowIntensity=X.intensity,te.shadowBias=X.bias,te.shadowNormalBias=X.normalBias,te.shadowRadius=X.radius,te.shadowMapSize=X.mapSize,n.directionalShadow[d]=te,n.directionalShadowMap[d]=H,n.directionalShadowMatrix[d]=L.shadow.matrix,w++}n.directional[d]=Z,d++}else if(L.isSpotLight){const Z=e.get(L);Z.position.setFromMatrixPosition(L.matrixWorld),Z.color.copy(z).multiplyScalar($),Z.distance=j,Z.coneCos=Math.cos(L.angle),Z.penumbraCos=Math.cos(L.angle*(1-L.penumbra)),Z.decay=L.decay,n.spot[y]=Z;const X=L.shadow;if(L.map&&(n.spotLightMap[R]=L.map,R++,X.updateMatrices(L),L.castShadow&&b++),n.spotLightMatrix[y]=X.matrix,L.castShadow){const te=t.get(L);te.shadowIntensity=X.intensity,te.shadowBias=X.bias,te.shadowNormalBias=X.normalBias,te.shadowRadius=X.radius,te.shadowMapSize=X.mapSize,n.spotShadow[y]=te,n.spotShadowMap[y]=H,S++}y++}else if(L.isRectAreaLight){const Z=e.get(L);Z.color.copy(z).multiplyScalar($),Z.halfWidth.set(L.width*.5,0,0),Z.halfHeight.set(0,L.height*.5,0),n.rectArea[_]=Z,_++}else if(L.isPointLight){const Z=e.get(L);if(Z.color.copy(L.color).multiplyScalar(L.intensity),Z.distance=L.distance,Z.decay=L.decay,L.castShadow){const X=L.shadow,te=t.get(L);te.shadowIntensity=X.intensity,te.shadowBias=X.bias,te.shadowNormalBias=X.normalBias,te.shadowRadius=X.radius,te.shadowMapSize=X.mapSize,te.shadowCameraNear=X.camera.near,te.shadowCameraFar=X.camera.far,n.pointShadow[x]=te,n.pointShadowMap[x]=H,n.pointShadowMatrix[x]=L.shadow.matrix,C++}n.point[x]=Z,x++}else if(L.isHemisphereLight){const Z=e.get(L);Z.skyColor.copy(L.color).multiplyScalar($),Z.groundColor.copy(L.groundColor).multiplyScalar($),n.hemi[f]=Z,f++}}_>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=pe.LTC_FLOAT_1,n.rectAreaLTC2=pe.LTC_FLOAT_2):(n.rectAreaLTC1=pe.LTC_HALF_1,n.rectAreaLTC2=pe.LTC_HALF_2)),n.ambient[0]=u,n.ambient[1]=m,n.ambient[2]=h;const g=n.hash;(g.directionalLength!==d||g.pointLength!==x||g.spotLength!==y||g.rectAreaLength!==_||g.hemiLength!==f||g.numDirectionalShadows!==w||g.numPointShadows!==C||g.numSpotShadows!==S||g.numSpotMaps!==R||g.numLightProbes!==P)&&(n.directional.length=d,n.spot.length=y,n.rectArea.length=_,n.point.length=x,n.hemi.length=f,n.directionalShadow.length=w,n.directionalShadowMap.length=w,n.pointShadow.length=C,n.pointShadowMap.length=C,n.spotShadow.length=S,n.spotShadowMap.length=S,n.directionalShadowMatrix.length=w,n.pointShadowMatrix.length=C,n.spotLightMatrix.length=S+R-b,n.spotLightMap.length=R,n.numSpotLightShadowsWithMaps=b,n.numLightProbes=P,g.directionalLength=d,g.pointLength=x,g.spotLength=y,g.rectAreaLength=_,g.hemiLength=f,g.numDirectionalShadows=w,g.numPointShadows=C,g.numSpotShadows=S,g.numSpotMaps=R,g.numLightProbes=P,n.version=Am++)}function c(l,u){let m=0,h=0,d=0,x=0,y=0;const _=u.matrixWorldInverse;for(let f=0,w=l.length;f<w;f++){const C=l[f];if(C.isDirectionalLight){const S=n.directional[m];S.direction.setFromMatrixPosition(C.matrixWorld),r.setFromMatrixPosition(C.target.matrixWorld),S.direction.sub(r),S.direction.transformDirection(_),m++}else if(C.isSpotLight){const S=n.spot[d];S.position.setFromMatrixPosition(C.matrixWorld),S.position.applyMatrix4(_),S.direction.setFromMatrixPosition(C.matrixWorld),r.setFromMatrixPosition(C.target.matrixWorld),S.direction.sub(r),S.direction.transformDirection(_),d++}else if(C.isRectAreaLight){const S=n.rectArea[x];S.position.setFromMatrixPosition(C.matrixWorld),S.position.applyMatrix4(_),a.identity(),s.copy(C.matrixWorld),s.premultiply(_),a.extractRotation(s),S.halfWidth.set(C.width*.5,0,0),S.halfHeight.set(0,C.height*.5,0),S.halfWidth.applyMatrix4(a),S.halfHeight.applyMatrix4(a),x++}else if(C.isPointLight){const S=n.point[h];S.position.setFromMatrixPosition(C.matrixWorld),S.position.applyMatrix4(_),h++}else if(C.isHemisphereLight){const S=n.hemi[y];S.direction.setFromMatrixPosition(C.matrixWorld),S.direction.transformDirection(_),y++}}}return{setup:o,setupView:c,state:n}}function ll(i){const e=new wm(i),t=[],n=[],r=[];function s(h){m.camera=h,t.length=0,n.length=0,r.length=0}function a(h){t.push(h)}function o(h){n.push(h)}function c(h){r.push(h)}function l(){e.setup(t)}function u(h){e.setupView(t,h)}const m={lightsArray:t,shadowsArray:n,lightProbeGridArray:r,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:m,setupLights:l,setupLightsView:u,pushLight:a,pushShadow:o,pushLightProbeGrid:c}}function Cm(i){let e=new WeakMap;function t(r,s=0){const a=e.get(r);let o;return a===void 0?(o=new ll(i),e.set(r,[o])):s>=a.length?(o=new ll(i),a.push(o)):o=a[s],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const Pm=`void main() {
4057
+ `+me)}else H!==""?we("WebGLProgram: Program Info Log:",H):(Z===""||X==="")&&(ie=!1);ie&&(L.diagnostics={runnable:te,programLog:H,vertexShader:{log:Z,prefix:_},fragmentShader:{log:X,prefix:f}})}r.deleteShader(R),r.deleteShader(b),g=new Ur(r,y),T=em(r,y)}let g;this.getUniforms=function(){return g===void 0&&P(this),g};let T;this.getAttributes=function(){return T===void 0&&P(this),T};let U=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return U===!1&&(U=r.getProgramParameter(y,Wp)),U},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(y),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Xp++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=R,this.fragmentShader=b,this}let _m=0;class gm{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){const r=this._getShaderCacheForMaterial(e);return r.has(t)===!1&&(r.add(t),t.usedTimes++),r.has(n)===!1&&(r.add(n),n.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new xm(e),t.set(e,n)),n}}class xm{constructor(e){this.id=_m++,this.code=e,this.usedTimes=0}}function vm(i){return i===jn||i===Nr||i===Fr}function Mm(i,e,t,n,r,s){const a=new ka,o=new gm,c=new Set,l=[],u=new Map,m=n.logarithmicDepthBuffer;let h=n.precision;const d={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function x(g){return c.add(g),g===0?"uv":`uv${g}`}function y(g,T,U,L,z,$){const j=L.fog,H=z.geometry,Z=g.isMeshStandardMaterial||g.isMeshLambertMaterial||g.isMeshPhongMaterial?L.environment:null,X=g.isMeshStandardMaterial||g.isMeshLambertMaterial&&!g.envMap||g.isMeshPhongMaterial&&!g.envMap,te=e.get(g.envMap||Z,X),ie=te&&te.mapping===Yr?te.image.height:null,fe=d[g.type];g.precision!==null&&(h=n.getMaxPrecision(g.precision),h!==g.precision&&we("WebGLProgram.getParameters:",g.precision,"not supported, using",h,"instead."));const me=H.morphAttributes.position||H.morphAttributes.normal||H.morphAttributes.color,Me=me!==void 0?me.length:0;let Xe=0;H.morphAttributes.position!==void 0&&(Xe=1),H.morphAttributes.normal!==void 0&&(Xe=2),H.morphAttributes.color!==void 0&&(Xe=3);let rt,Ye,Q,le;if(fe){const ue=en[fe];rt=ue.vertexShader,Ye=ue.fragmentShader}else{rt=g.vertexShader,Ye=g.fragmentShader;const ue=o.getVertexShaderStage(g),Ge=o.getFragmentShaderStage(g);o.update(g,ue,Ge),Q=ue.id,le=Ge.id}const re=i.getRenderTarget(),Pe=i.state.buffers.depth.getReversed(),De=z.isInstancedMesh===!0,Re=z.isBatchedMesh===!0,ot=!!g.map,Fe=!!g.matcap,Ze=!!te,We=!!g.aoMap,Ve=!!g.lightMap,lt=!!g.bumpMap&&g.wireframe===!1,ht=!!g.normalMap,_t=!!g.displacementMap,xt=!!g.emissiveMap,it=!!g.metalnessMap,ut=!!g.roughnessMap,I=g.anisotropy>0,yt=g.clearcoat>0,Ke=g.dispersion>0,E=g.iridescence>0,p=g.sheen>0,O=g.transmission>0,k=I&&!!g.anisotropyMap,Y=yt&&!!g.clearcoatMap,se=yt&&!!g.clearcoatNormalMap,ae=yt&&!!g.clearcoatRoughnessMap,K=E&&!!g.iridescenceMap,J=E&&!!g.iridescenceThicknessMap,oe=p&&!!g.sheenColorMap,Se=p&&!!g.sheenRoughnessMap,he=!!g.specularMap,ce=!!g.specularColorMap,ye=!!g.specularIntensityMap,be=O&&!!g.transmissionMap,A=O&&!!g.thicknessMap,M=!!g.gradientMap,B=!!g.alphaMap,N=g.alphaTest>0,ee=!!g.alphaHash,ne=!!g.extensions;let q=sn;g.toneMapped&&(re===null||re.isXRRenderTarget===!0)&&(q=i.toneMapping);const de={shaderID:fe,shaderType:g.type,shaderName:g.name,vertexShader:rt,fragmentShader:Ye,defines:g.defines,customVertexShaderID:Q,customFragmentShaderID:le,isRawShaderMaterial:g.isRawShaderMaterial===!0,glslVersion:g.glslVersion,precision:h,batching:Re,batchingColor:Re&&z._colorsTexture!==null,instancing:De,instancingColor:De&&z.instanceColor!==null,instancingMorph:De&&z.morphTexture!==null,outputColorSpace:re===null?i.outputColorSpace:re.isXRRenderTarget===!0?re.texture.colorSpace:ke.workingColorSpace,alphaToCoverage:!!g.alphaToCoverage,map:ot,matcap:Fe,envMap:Ze,envMapMode:Ze&&te.mapping,envMapCubeUVHeight:ie,aoMap:We,lightMap:Ve,bumpMap:lt,normalMap:ht,displacementMap:_t,emissiveMap:xt,normalMapObjectSpace:ht&&g.normalMapType===qc,normalMapTangentSpace:ht&&g.normalMapType===lo,packedNormalMap:ht&&g.normalMapType===lo&&vm(g.normalMap.format),metalnessMap:it,roughnessMap:ut,anisotropy:I,anisotropyMap:k,clearcoat:yt,clearcoatMap:Y,clearcoatNormalMap:se,clearcoatRoughnessMap:ae,dispersion:Ke,iridescence:E,iridescenceMap:K,iridescenceThicknessMap:J,sheen:p,sheenColorMap:oe,sheenRoughnessMap:Se,specularMap:he,specularColorMap:ce,specularIntensityMap:ye,transmission:O,transmissionMap:be,thicknessMap:A,gradientMap:M,opaque:g.transparent===!1&&g.blending===On&&g.alphaToCoverage===!1,alphaMap:B,alphaTest:N,alphaHash:ee,combine:g.combine,mapUv:ot&&x(g.map.channel),aoMapUv:We&&x(g.aoMap.channel),lightMapUv:Ve&&x(g.lightMap.channel),bumpMapUv:lt&&x(g.bumpMap.channel),normalMapUv:ht&&x(g.normalMap.channel),displacementMapUv:_t&&x(g.displacementMap.channel),emissiveMapUv:xt&&x(g.emissiveMap.channel),metalnessMapUv:it&&x(g.metalnessMap.channel),roughnessMapUv:ut&&x(g.roughnessMap.channel),anisotropyMapUv:k&&x(g.anisotropyMap.channel),clearcoatMapUv:Y&&x(g.clearcoatMap.channel),clearcoatNormalMapUv:se&&x(g.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ae&&x(g.clearcoatRoughnessMap.channel),iridescenceMapUv:K&&x(g.iridescenceMap.channel),iridescenceThicknessMapUv:J&&x(g.iridescenceThicknessMap.channel),sheenColorMapUv:oe&&x(g.sheenColorMap.channel),sheenRoughnessMapUv:Se&&x(g.sheenRoughnessMap.channel),specularMapUv:he&&x(g.specularMap.channel),specularColorMapUv:ce&&x(g.specularColorMap.channel),specularIntensityMapUv:ye&&x(g.specularIntensityMap.channel),transmissionMapUv:be&&x(g.transmissionMap.channel),thicknessMapUv:A&&x(g.thicknessMap.channel),alphaMapUv:B&&x(g.alphaMap.channel),vertexTangents:!!H.attributes.tangent&&(ht||I),vertexNormals:!!H.attributes.normal,vertexColors:g.vertexColors,vertexAlphas:g.vertexColors===!0&&!!H.attributes.color&&H.attributes.color.itemSize===4,pointsUvs:z.isPoints===!0&&!!H.attributes.uv&&(ot||B),fog:!!j,useFog:g.fog===!0,fogExp2:!!j&&j.isFogExp2,flatShading:g.wireframe===!1&&(g.flatShading===!0||H.attributes.normal===void 0&&ht===!1&&(g.isMeshLambertMaterial||g.isMeshPhongMaterial||g.isMeshStandardMaterial||g.isMeshPhysicalMaterial)),sizeAttenuation:g.sizeAttenuation===!0,logarithmicDepthBuffer:m,reversedDepthBuffer:Pe,skinning:z.isSkinnedMesh===!0,hasPositionAttribute:H.attributes.position!==void 0,morphTargets:H.morphAttributes.position!==void 0,morphNormals:H.morphAttributes.normal!==void 0,morphColors:H.morphAttributes.color!==void 0,morphTargetsCount:Me,morphTextureStride:Xe,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.length,numDirLightShadows:T.directionalShadowMap.length,numPointLightShadows:T.pointShadowMap.length,numSpotLightShadows:T.spotShadowMap.length,numSpotLightShadowsWithMaps:T.numSpotLightShadowsWithMaps,numLightProbes:T.numLightProbes,numLightProbeGrids:$.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:g.dithering,shadowMapEnabled:i.shadowMap.enabled&&U.length>0,shadowMapType:i.shadowMap.type,toneMapping:q,decodeVideoTexture:ot&&g.map.isVideoTexture===!0&&ke.getTransfer(g.map.colorSpace)===$e,decodeVideoTextureEmissive:xt&&g.emissiveMap.isVideoTexture===!0&&ke.getTransfer(g.emissiveMap.colorSpace)===$e,premultipliedAlpha:g.premultipliedAlpha,doubleSided:g.side===pn,flipSided:g.side===Nt,useDepthPacking:g.depthPacking>=0,depthPacking:g.depthPacking||0,index0AttributeName:g.index0AttributeName,extensionClipCullDistance:ne&&g.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ne&&g.extensions.multiDraw===!0||Re)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:g.customProgramCacheKey()};return de.vertexUv1s=c.has(1),de.vertexUv2s=c.has(2),de.vertexUv3s=c.has(3),c.clear(),de}function _(g){const T=[];if(g.shaderID?T.push(g.shaderID):(T.push(g.customVertexShaderID),T.push(g.customFragmentShaderID)),g.defines!==void 0)for(const U in g.defines)T.push(U),T.push(g.defines[U]);return g.isRawShaderMaterial===!1&&(f(T,g),w(T,g),T.push(i.outputColorSpace)),T.push(g.customProgramCacheKey),T.join()}function f(g,T){g.push(T.precision),g.push(T.outputColorSpace),g.push(T.envMapMode),g.push(T.envMapCubeUVHeight),g.push(T.mapUv),g.push(T.alphaMapUv),g.push(T.lightMapUv),g.push(T.aoMapUv),g.push(T.bumpMapUv),g.push(T.normalMapUv),g.push(T.displacementMapUv),g.push(T.emissiveMapUv),g.push(T.metalnessMapUv),g.push(T.roughnessMapUv),g.push(T.anisotropyMapUv),g.push(T.clearcoatMapUv),g.push(T.clearcoatNormalMapUv),g.push(T.clearcoatRoughnessMapUv),g.push(T.iridescenceMapUv),g.push(T.iridescenceThicknessMapUv),g.push(T.sheenColorMapUv),g.push(T.sheenRoughnessMapUv),g.push(T.specularMapUv),g.push(T.specularColorMapUv),g.push(T.specularIntensityMapUv),g.push(T.transmissionMapUv),g.push(T.thicknessMapUv),g.push(T.combine),g.push(T.fogExp2),g.push(T.sizeAttenuation),g.push(T.morphTargetsCount),g.push(T.morphAttributeCount),g.push(T.numDirLights),g.push(T.numPointLights),g.push(T.numSpotLights),g.push(T.numSpotLightMaps),g.push(T.numHemiLights),g.push(T.numRectAreaLights),g.push(T.numDirLightShadows),g.push(T.numPointLightShadows),g.push(T.numSpotLightShadows),g.push(T.numSpotLightShadowsWithMaps),g.push(T.numLightProbes),g.push(T.shadowMapType),g.push(T.toneMapping),g.push(T.numClippingPlanes),g.push(T.numClipIntersection),g.push(T.depthPacking)}function w(g,T){a.disableAll(),T.instancing&&a.enable(0),T.instancingColor&&a.enable(1),T.instancingMorph&&a.enable(2),T.matcap&&a.enable(3),T.envMap&&a.enable(4),T.normalMapObjectSpace&&a.enable(5),T.normalMapTangentSpace&&a.enable(6),T.clearcoat&&a.enable(7),T.iridescence&&a.enable(8),T.alphaTest&&a.enable(9),T.vertexColors&&a.enable(10),T.vertexAlphas&&a.enable(11),T.vertexUv1s&&a.enable(12),T.vertexUv2s&&a.enable(13),T.vertexUv3s&&a.enable(14),T.vertexTangents&&a.enable(15),T.anisotropy&&a.enable(16),T.alphaHash&&a.enable(17),T.batching&&a.enable(18),T.dispersion&&a.enable(19),T.batchingColor&&a.enable(20),T.gradientMap&&a.enable(21),T.packedNormalMap&&a.enable(22),T.vertexNormals&&a.enable(23),g.push(a.mask),a.disableAll(),T.fog&&a.enable(0),T.useFog&&a.enable(1),T.flatShading&&a.enable(2),T.logarithmicDepthBuffer&&a.enable(3),T.reversedDepthBuffer&&a.enable(4),T.skinning&&a.enable(5),T.morphTargets&&a.enable(6),T.morphNormals&&a.enable(7),T.morphColors&&a.enable(8),T.premultipliedAlpha&&a.enable(9),T.shadowMapEnabled&&a.enable(10),T.doubleSided&&a.enable(11),T.flipSided&&a.enable(12),T.useDepthPacking&&a.enable(13),T.dithering&&a.enable(14),T.transmission&&a.enable(15),T.sheen&&a.enable(16),T.opaque&&a.enable(17),T.pointsUvs&&a.enable(18),T.decodeVideoTexture&&a.enable(19),T.decodeVideoTextureEmissive&&a.enable(20),T.alphaToCoverage&&a.enable(21),T.numLightProbeGrids>0&&a.enable(22),T.hasPositionAttribute&&a.enable(23),g.push(a.mask)}function C(g){const T=d[g.type];let U;if(T){const L=en[T];U=Vh.clone(L.uniforms)}else U=g.uniforms;return U}function S(g,T){let U=u.get(T);return U!==void 0?++U.usedTimes:(U=new mm(i,T,g,r),l.push(U),u.set(T,U)),U}function R(g){if(--g.usedTimes===0){const T=l.indexOf(g);l[T]=l[l.length-1],l.pop(),u.delete(g.cacheKey),g.destroy()}}function b(g){o.remove(g)}function P(){o.dispose()}return{getParameters:y,getProgramCacheKey:_,getUniforms:C,acquireProgram:S,releaseProgram:R,releaseShaderCache:b,programs:l,dispose:P}}function Sm(){let i=new WeakMap;function e(a){return i.has(a)}function t(a){let o=i.get(a);return o===void 0&&(o={},i.set(a,o)),o}function n(a){i.delete(a)}function r(a,o,c){i.get(a)[o]=c}function s(){i=new WeakMap}return{has:e,get:t,remove:n,update:r,dispose:s}}function Em(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.materialVariant!==e.materialVariant?i.materialVariant-e.materialVariant:i.z!==e.z?i.z-e.z:i.id-e.id}function al(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function ol(){const i=[];let e=0;const t=[],n=[],r=[];function s(){e=0,t.length=0,n.length=0,r.length=0}function a(h){let d=0;return h.isInstancedMesh&&(d+=2),h.isSkinnedMesh&&(d+=1),d}function o(h,d,x,y,_,f){let w=i[e];return w===void 0?(w={id:h.id,object:h,geometry:d,material:x,materialVariant:a(h),groupOrder:y,renderOrder:h.renderOrder,z:_,group:f},i[e]=w):(w.id=h.id,w.object=h,w.geometry=d,w.material=x,w.materialVariant=a(h),w.groupOrder=y,w.renderOrder=h.renderOrder,w.z=_,w.group=f),e++,w}function c(h,d,x,y,_,f){const w=o(h,d,x,y,_,f);x.transmission>0?n.push(w):x.transparent===!0?r.push(w):t.push(w)}function l(h,d,x,y,_,f){const w=o(h,d,x,y,_,f);x.transmission>0?n.unshift(w):x.transparent===!0?r.unshift(w):t.unshift(w)}function u(h,d,x){t.length>1&&t.sort(h||Em),n.length>1&&n.sort(d||al),r.length>1&&r.sort(d||al),x&&(t.reverse(),n.reverse(),r.reverse())}function m(){for(let h=e,d=i.length;h<d;h++){const x=i[h];if(x.id===null)break;x.id=null,x.object=null,x.geometry=null,x.material=null,x.group=null}}return{opaque:t,transmissive:n,transparent:r,init:s,push:c,unshift:l,finish:m,sort:u}}function ym(){let i=new WeakMap;function e(n,r){const s=i.get(n);let a;return s===void 0?(a=new ol,i.set(n,[a])):r>=s.length?(a=new ol,s.push(a)):a=s[r],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function bm(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new D,color:new ze};break;case"SpotLight":t={position:new D,direction:new D,color:new ze,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new D,color:new ze,distance:0,decay:0};break;case"HemisphereLight":t={direction:new D,skyColor:new ze,groundColor:new ze};break;case"RectAreaLight":t={color:new ze,position:new D,halfWidth:new D,halfHeight:new D};break}return i[e.id]=t,t}}}function Tm(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ce};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ce};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ce,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let Am=0;function Rm(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function wm(i){const e=new bm,t=Tm(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)n.probe.push(new D);const r=new D,s=new at,a=new at;function o(l){let u=0,m=0,h=0;for(let T=0;T<9;T++)n.probe[T].set(0,0,0);let d=0,x=0,y=0,_=0,f=0,w=0,C=0,S=0,R=0,b=0,P=0;l.sort(Rm);for(let T=0,U=l.length;T<U;T++){const L=l[T],z=L.color,$=L.intensity,j=L.distance;let H=null;if(L.shadow&&L.shadow.map&&(L.shadow.map.texture.format===jn?H=L.shadow.map.texture:H=L.shadow.map.depthTexture||L.shadow.map.texture),L.isAmbientLight)u+=z.r*$,m+=z.g*$,h+=z.b*$;else if(L.isLightProbe){for(let Z=0;Z<9;Z++)n.probe[Z].addScaledVector(L.sh.coefficients[Z],$);P++}else if(L.isDirectionalLight){const Z=e.get(L);if(Z.color.copy(L.color).multiplyScalar(L.intensity),L.castShadow){const X=L.shadow,te=t.get(L);te.shadowIntensity=X.intensity,te.shadowBias=X.bias,te.shadowNormalBias=X.normalBias,te.shadowRadius=X.radius,te.shadowMapSize=X.mapSize,n.directionalShadow[d]=te,n.directionalShadowMap[d]=H,n.directionalShadowMatrix[d]=L.shadow.matrix,w++}n.directional[d]=Z,d++}else if(L.isSpotLight){const Z=e.get(L);Z.position.setFromMatrixPosition(L.matrixWorld),Z.color.copy(z).multiplyScalar($),Z.distance=j,Z.coneCos=Math.cos(L.angle),Z.penumbraCos=Math.cos(L.angle*(1-L.penumbra)),Z.decay=L.decay,n.spot[y]=Z;const X=L.shadow;if(L.map&&(n.spotLightMap[R]=L.map,R++,X.updateMatrices(L),L.castShadow&&b++),n.spotLightMatrix[y]=X.matrix,L.castShadow){const te=t.get(L);te.shadowIntensity=X.intensity,te.shadowBias=X.bias,te.shadowNormalBias=X.normalBias,te.shadowRadius=X.radius,te.shadowMapSize=X.mapSize,n.spotShadow[y]=te,n.spotShadowMap[y]=H,S++}y++}else if(L.isRectAreaLight){const Z=e.get(L);Z.color.copy(z).multiplyScalar($),Z.halfWidth.set(L.width*.5,0,0),Z.halfHeight.set(0,L.height*.5,0),n.rectArea[_]=Z,_++}else if(L.isPointLight){const Z=e.get(L);if(Z.color.copy(L.color).multiplyScalar(L.intensity),Z.distance=L.distance,Z.decay=L.decay,L.castShadow){const X=L.shadow,te=t.get(L);te.shadowIntensity=X.intensity,te.shadowBias=X.bias,te.shadowNormalBias=X.normalBias,te.shadowRadius=X.radius,te.shadowMapSize=X.mapSize,te.shadowCameraNear=X.camera.near,te.shadowCameraFar=X.camera.far,n.pointShadow[x]=te,n.pointShadowMap[x]=H,n.pointShadowMatrix[x]=L.shadow.matrix,C++}n.point[x]=Z,x++}else if(L.isHemisphereLight){const Z=e.get(L);Z.skyColor.copy(L.color).multiplyScalar($),Z.groundColor.copy(L.groundColor).multiplyScalar($),n.hemi[f]=Z,f++}}_>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=pe.LTC_FLOAT_1,n.rectAreaLTC2=pe.LTC_FLOAT_2):(n.rectAreaLTC1=pe.LTC_HALF_1,n.rectAreaLTC2=pe.LTC_HALF_2)),n.ambient[0]=u,n.ambient[1]=m,n.ambient[2]=h;const g=n.hash;(g.directionalLength!==d||g.pointLength!==x||g.spotLength!==y||g.rectAreaLength!==_||g.hemiLength!==f||g.numDirectionalShadows!==w||g.numPointShadows!==C||g.numSpotShadows!==S||g.numSpotMaps!==R||g.numLightProbes!==P)&&(n.directional.length=d,n.spot.length=y,n.rectArea.length=_,n.point.length=x,n.hemi.length=f,n.directionalShadow.length=w,n.directionalShadowMap.length=w,n.pointShadow.length=C,n.pointShadowMap.length=C,n.spotShadow.length=S,n.spotShadowMap.length=S,n.directionalShadowMatrix.length=w,n.pointShadowMatrix.length=C,n.spotLightMatrix.length=S+R-b,n.spotLightMap.length=R,n.numSpotLightShadowsWithMaps=b,n.numLightProbes=P,g.directionalLength=d,g.pointLength=x,g.spotLength=y,g.rectAreaLength=_,g.hemiLength=f,g.numDirectionalShadows=w,g.numPointShadows=C,g.numSpotShadows=S,g.numSpotMaps=R,g.numLightProbes=P,n.version=Am++)}function c(l,u){let m=0,h=0,d=0,x=0,y=0;const _=u.matrixWorldInverse;for(let f=0,w=l.length;f<w;f++){const C=l[f];if(C.isDirectionalLight){const S=n.directional[m];S.direction.setFromMatrixPosition(C.matrixWorld),r.setFromMatrixPosition(C.target.matrixWorld),S.direction.sub(r),S.direction.transformDirection(_),m++}else if(C.isSpotLight){const S=n.spot[d];S.position.setFromMatrixPosition(C.matrixWorld),S.position.applyMatrix4(_),S.direction.setFromMatrixPosition(C.matrixWorld),r.setFromMatrixPosition(C.target.matrixWorld),S.direction.sub(r),S.direction.transformDirection(_),d++}else if(C.isRectAreaLight){const S=n.rectArea[x];S.position.setFromMatrixPosition(C.matrixWorld),S.position.applyMatrix4(_),a.identity(),s.copy(C.matrixWorld),s.premultiply(_),a.extractRotation(s),S.halfWidth.set(C.width*.5,0,0),S.halfHeight.set(0,C.height*.5,0),S.halfWidth.applyMatrix4(a),S.halfHeight.applyMatrix4(a),x++}else if(C.isPointLight){const S=n.point[h];S.position.setFromMatrixPosition(C.matrixWorld),S.position.applyMatrix4(_),h++}else if(C.isHemisphereLight){const S=n.hemi[y];S.direction.setFromMatrixPosition(C.matrixWorld),S.direction.transformDirection(_),y++}}}return{setup:o,setupView:c,state:n}}function ll(i){const e=new wm(i),t=[],n=[],r=[];function s(h){m.camera=h,t.length=0,n.length=0,r.length=0}function a(h){t.push(h)}function o(h){n.push(h)}function c(h){r.push(h)}function l(){e.setup(t)}function u(h){e.setupView(t,h)}const m={lightsArray:t,shadowsArray:n,lightProbeGridArray:r,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:m,setupLights:l,setupLightsView:u,pushLight:a,pushShadow:o,pushLightProbeGrid:c}}function Cm(i){let e=new WeakMap;function t(r,s=0){const a=e.get(r);let o;return a===void 0?(o=new ll(i),e.set(r,[o])):s>=a.length?(o=new ll(i),a.push(o)):o=a[s],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const Pm=`void main() {
4058
4058
  gl_Position = vec4( position, 1.0 );
4059
4059
  }`,Dm=`uniform sampler2D shadow_pass;
4060
4060
  uniform vec2 resolution;
@@ -4081,7 +4081,7 @@ void main() {
4081
4081
  squared_mean = squared_mean / samples;
4082
4082
  float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
4083
4083
  gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
4084
- }`,Lm=[new D(1,0,0),new D(-1,0,0),new D(0,1,0),new D(0,-1,0),new D(0,0,1),new D(0,0,-1)],Im=[new D(0,-1,0),new D(0,-1,0),new D(0,0,1),new D(0,0,-1),new D(0,-1,0),new D(0,-1,0)],cl=new at,Wi=new D,Os=new D;function Um(i,e,t){let n=new Vl;const r=new Ce,s=new Ce,a=new dt,o=new Xh,c=new Yh,l={},u=t.maxTextureSize,m={[zn]:Nt,[Nt]:zn,[pn]:pn},h=new ln({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ce},radius:{value:4}},vertexShader:Pm,fragmentShader:Dm}),d=h.clone();d.defines.HORIZONTAL_PASS=1;const x=new Xt;x.setAttribute("position",new $t(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new Mn(x,h),_=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Rr;let f=this.type;this.render=function(b,P,g){if(_.enabled===!1||_.autoUpdate===!1&&_.needsUpdate===!1||b.length===0)return;this.type===bc&&(we("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=Rr);const T=i.getRenderTarget(),U=i.getActiveCubeFace(),L=i.getActiveMipmapLevel(),z=i.state;z.setBlending(_n),z.buffers.depth.getReversed()===!0?z.buffers.color.setClear(0,0,0,0):z.buffers.color.setClear(1,1,1,1),z.buffers.depth.setTest(!0),z.setScissorTest(!1);const $=f!==this.type;$&&P.traverse(function(j){j.material&&(Array.isArray(j.material)?j.material.forEach(H=>H.needsUpdate=!0):j.material.needsUpdate=!0)});for(let j=0,H=b.length;j<H;j++){const Z=b[j],X=Z.shadow;if(X===void 0){we("WebGLShadowMap:",Z,"has no shadow.");continue}if(X.autoUpdate===!1&&X.needsUpdate===!1)continue;r.copy(X.mapSize);const te=X.getFrameExtents();r.multiply(te),s.copy(X.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(s.x=Math.floor(u/te.x),r.x=s.x*te.x,X.mapSize.x=s.x),r.y>u&&(s.y=Math.floor(u/te.y),r.y=s.y*te.y,X.mapSize.y=s.y));const ie=i.state.buffers.depth.getReversed();if(X.camera._reversedDepth=ie,X.map===null||$===!0){if(X.map!==null&&(X.map.depthTexture!==null&&(X.map.depthTexture.dispose(),X.map.depthTexture=null),X.map.dispose()),this.type===Xi){if(Z.isPointLight){we("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}X.map=new an(r.x,r.y,{format:jn,type:xn,minFilter:wt,magFilter:wt,generateMipmaps:!1}),X.map.texture.name=Z.name+".shadowMap",X.map.depthTexture=new Di(r.x,r.y,nn),X.map.depthTexture.name=Z.name+".shadowMapDepth",X.map.depthTexture.format=vn,X.map.depthTexture.compareFunction=null,X.map.depthTexture.minFilter=bt,X.map.depthTexture.magFilter=bt}else Z.isPointLight?(X.map=new $l(r.x),X.map.depthTexture=new Uh(r.x,on)):(X.map=new an(r.x,r.y),X.map.depthTexture=new Di(r.x,r.y,on)),X.map.depthTexture.name=Z.name+".shadowMap",X.map.depthTexture.format=vn,this.type===Rr?(X.map.depthTexture.compareFunction=ie?Va:Ga,X.map.depthTexture.minFilter=wt,X.map.depthTexture.magFilter=wt):(X.map.depthTexture.compareFunction=null,X.map.depthTexture.minFilter=bt,X.map.depthTexture.magFilter=bt);X.camera.updateProjectionMatrix()}const fe=X.map.isWebGLCubeRenderTarget?6:1;for(let me=0;me<fe;me++){if(X.map.isWebGLCubeRenderTarget)i.setRenderTarget(X.map,me),i.clear();else{me===0&&(i.setRenderTarget(X.map),i.clear());const Me=X.getViewport(me);a.set(s.x*Me.x,s.y*Me.y,s.x*Me.z,s.y*Me.w),z.viewport(a)}if(Z.isPointLight){const Me=X.camera,Xe=X.matrix,rt=Z.distance||Me.far;rt!==Me.far&&(Me.far=rt,Me.updateProjectionMatrix()),Wi.setFromMatrixPosition(Z.matrixWorld),Me.position.copy(Wi),Os.copy(Me.position),Os.add(Lm[me]),Me.up.copy(Im[me]),Me.lookAt(Os),Me.updateMatrixWorld(),Xe.makeTranslation(-Wi.x,-Wi.y,-Wi.z),cl.multiplyMatrices(Me.projectionMatrix,Me.matrixWorldInverse),X._frustum.setFromProjectionMatrix(cl,Me.coordinateSystem,Me.reversedDepth)}else X.updateMatrices(Z);n=X.getFrustum(),S(P,g,X.camera,Z,this.type)}X.isPointLightShadow!==!0&&this.type===Xi&&w(X,g),X.needsUpdate=!1}f=this.type,_.needsUpdate=!1,i.setRenderTarget(T,U,L)};function w(b,P){const g=e.update(y);h.defines.VSM_SAMPLES!==b.blurSamples&&(h.defines.VSM_SAMPLES=b.blurSamples,d.defines.VSM_SAMPLES=b.blurSamples,h.needsUpdate=!0,d.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new an(r.x,r.y,{format:jn,type:xn})),h.uniforms.shadow_pass.value=b.map.depthTexture,h.uniforms.resolution.value=b.mapSize,h.uniforms.radius.value=b.radius,i.setRenderTarget(b.mapPass),i.clear(),i.renderBufferDirect(P,null,g,h,y,null),d.uniforms.shadow_pass.value=b.mapPass.texture,d.uniforms.resolution.value=b.mapSize,d.uniforms.radius.value=b.radius,i.setRenderTarget(b.map),i.clear(),i.renderBufferDirect(P,null,g,d,y,null)}function C(b,P,g,T){let U=null;const L=g.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(L!==void 0)U=L;else if(U=g.isPointLight===!0?c:o,i.localClippingEnabled&&P.clipShadows===!0&&Array.isArray(P.clippingPlanes)&&P.clippingPlanes.length!==0||P.displacementMap&&P.displacementScale!==0||P.alphaMap&&P.alphaTest>0||P.map&&P.alphaTest>0||P.alphaToCoverage===!0){const z=U.uuid,$=P.uuid;let j=l[z];j===void 0&&(j={},l[z]=j);let H=j[$];H===void 0&&(H=U.clone(),j[$]=H,P.addEventListener("dispose",R)),U=H}if(U.visible=P.visible,U.wireframe=P.wireframe,T===Xi?U.side=P.shadowSide!==null?P.shadowSide:P.side:U.side=P.shadowSide!==null?P.shadowSide:m[P.side],U.alphaMap=P.alphaMap,U.alphaTest=P.alphaToCoverage===!0?.5:P.alphaTest,U.map=P.map,U.clipShadows=P.clipShadows,U.clippingPlanes=P.clippingPlanes,U.clipIntersection=P.clipIntersection,U.displacementMap=P.displacementMap,U.displacementScale=P.displacementScale,U.displacementBias=P.displacementBias,U.wireframeLinewidth=P.wireframeLinewidth,U.linewidth=P.linewidth,g.isPointLight===!0&&U.isMeshDistanceMaterial===!0){const z=i.properties.get(U);z.light=g}return U}function S(b,P,g,T,U){if(b.visible===!1)return;if(b.layers.test(P.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&U===Xi)&&(!b.frustumCulled||n.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(g.matrixWorldInverse,b.matrixWorld);const $=e.update(b),j=b.material;if(Array.isArray(j)){const H=$.groups;for(let Z=0,X=H.length;Z<X;Z++){const te=H[Z],ie=j[te.materialIndex];if(ie&&ie.visible){const fe=C(b,ie,T,U);b.onBeforeShadow(i,b,P,g,$,fe,te),i.renderBufferDirect(g,null,$,fe,b,te),b.onAfterShadow(i,b,P,g,$,fe,te)}}}else if(j.visible){const H=C(b,j,T,U);b.onBeforeShadow(i,b,P,g,$,H,null),i.renderBufferDirect(g,null,$,H,b,null),b.onAfterShadow(i,b,P,g,$,H,null)}}const z=b.children;for(let $=0,j=z.length;$<j;$++)S(z[$],P,g,T,U)}function R(b){b.target.removeEventListener("dispose",R);for(const g in l){const T=l[g],U=b.target.uuid;U in T&&(T[U].dispose(),delete T[U])}}}function Nm(i,e){function t(){let M=!1;const B=new dt;let N=null;const ee=new dt(0,0,0,0);return{setMask:function(ne){N!==ne&&!M&&(i.colorMask(ne,ne,ne,ne),N=ne)},setLocked:function(ne){M=ne},setClear:function(ne,q,de,ue,Ge){Ge===!0&&(ne*=ue,q*=ue,de*=ue),B.set(ne,q,de,ue),ee.equals(B)===!1&&(i.clearColor(ne,q,de,ue),ee.copy(B))},reset:function(){M=!1,N=null,ee.set(-1,0,0,0)}}}function n(){let M=!1,B=!1,N=null,ee=null,ne=null;return{setReversed:function(q){if(B!==q){const de=e.get("EXT_clip_control");q?de.clipControlEXT(de.LOWER_LEFT_EXT,de.ZERO_TO_ONE_EXT):de.clipControlEXT(de.LOWER_LEFT_EXT,de.NEGATIVE_ONE_TO_ONE_EXT),B=q;const ue=ne;ne=null,this.setClear(ue)}},getReversed:function(){return B},setTest:function(q){q?re(i.DEPTH_TEST):Pe(i.DEPTH_TEST)},setMask:function(q){N!==q&&!M&&(i.depthMask(q),N=q)},setFunc:function(q){if(B&&(q=ih[q]),ee!==q){switch(q){case Hs:i.depthFunc(i.NEVER);break;case ks:i.depthFunc(i.ALWAYS);break;case Ws:i.depthFunc(i.LESS);break;case Ci:i.depthFunc(i.LEQUAL);break;case Xs:i.depthFunc(i.EQUAL);break;case Ys:i.depthFunc(i.GEQUAL);break;case qs:i.depthFunc(i.GREATER);break;case Ks:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}ee=q}},setLocked:function(q){M=q},setClear:function(q){ne!==q&&(ne=q,B&&(q=1-q),i.clearDepth(q))},reset:function(){M=!1,N=null,ee=null,ne=null,B=!1}}}function r(){let M=!1,B=null,N=null,ee=null,ne=null,q=null,de=null,ue=null,Ge=null;return{setTest:function(Ie){M||(Ie?re(i.STENCIL_TEST):Pe(i.STENCIL_TEST))},setMask:function(Ie){B!==Ie&&!M&&(i.stencilMask(Ie),B=Ie)},setFunc:function(Ie,ct,st){(N!==Ie||ee!==ct||ne!==st)&&(i.stencilFunc(Ie,ct,st),N=Ie,ee=ct,ne=st)},setOp:function(Ie,ct,st){(q!==Ie||de!==ct||ue!==st)&&(i.stencilOp(Ie,ct,st),q=Ie,de=ct,ue=st)},setLocked:function(Ie){M=Ie},setClear:function(Ie){Ge!==Ie&&(i.clearStencil(Ie),Ge=Ie)},reset:function(){M=!1,B=null,N=null,ee=null,ne=null,q=null,de=null,ue=null,Ge=null}}}const s=new t,a=new n,o=new r,c=new WeakMap,l=new WeakMap;let u={},m={},h={},d=new WeakMap,x=[],y=null,_=!1,f=null,w=null,C=null,S=null,R=null,b=null,P=null,g=new ze(0,0,0),T=0,U=!1,L=null,z=null,$=null,j=null,H=null;const Z=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let X=!1,te=0;const ie=i.getParameter(i.VERSION);ie.indexOf("WebGL")!==-1?(te=parseFloat(/^WebGL (\d)/.exec(ie)[1]),X=te>=1):ie.indexOf("OpenGL ES")!==-1&&(te=parseFloat(/^OpenGL ES (\d)/.exec(ie)[1]),X=te>=2);let fe=null,me={};const Me=i.getParameter(i.SCISSOR_BOX),Xe=i.getParameter(i.VIEWPORT),rt=new dt().fromArray(Me),Ye=new dt().fromArray(Xe);function Q(M,B,N,ee){const ne=new Uint8Array(4),q=i.createTexture();i.bindTexture(M,q),i.texParameteri(M,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(M,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let de=0;de<N;de++)M===i.TEXTURE_3D||M===i.TEXTURE_2D_ARRAY?i.texImage3D(B,0,i.RGBA,1,1,ee,0,i.RGBA,i.UNSIGNED_BYTE,ne):i.texImage2D(B+de,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,ne);return q}const le={};le[i.TEXTURE_2D]=Q(i.TEXTURE_2D,i.TEXTURE_2D,1),le[i.TEXTURE_CUBE_MAP]=Q(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),le[i.TEXTURE_2D_ARRAY]=Q(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),le[i.TEXTURE_3D]=Q(i.TEXTURE_3D,i.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),re(i.DEPTH_TEST),a.setFunc(Ci),lt(!1),ht(ro),re(i.CULL_FACE),We(_n);function re(M){u[M]!==!0&&(i.enable(M),u[M]=!0)}function Pe(M){u[M]!==!1&&(i.disable(M),u[M]=!1)}function De(M,B){return h[M]!==B?(i.bindFramebuffer(M,B),h[M]=B,M===i.DRAW_FRAMEBUFFER&&(h[i.FRAMEBUFFER]=B),M===i.FRAMEBUFFER&&(h[i.DRAW_FRAMEBUFFER]=B),!0):!1}function Re(M,B){let N=x,ee=!1;if(M){N=d.get(B),N===void 0&&(N=[],d.set(B,N));const ne=M.textures;if(N.length!==ne.length||N[0]!==i.COLOR_ATTACHMENT0){for(let q=0,de=ne.length;q<de;q++)N[q]=i.COLOR_ATTACHMENT0+q;N.length=ne.length,ee=!0}}else N[0]!==i.BACK&&(N[0]=i.BACK,ee=!0);ee&&i.drawBuffers(N)}function ot(M){return y!==M?(i.useProgram(M),y=M,!0):!1}const Fe={[Kn]:i.FUNC_ADD,[Ac]:i.FUNC_SUBTRACT,[Rc]:i.FUNC_REVERSE_SUBTRACT};Fe[wc]=i.MIN,Fe[Cc]=i.MAX;const Ze={[Pc]:i.ZERO,[Dc]:i.ONE,[Lc]:i.SRC_COLOR,[Gs]:i.SRC_ALPHA,[Bc]:i.SRC_ALPHA_SATURATE,[Fc]:i.DST_COLOR,[Uc]:i.DST_ALPHA,[Ic]:i.ONE_MINUS_SRC_COLOR,[Vs]:i.ONE_MINUS_SRC_ALPHA,[Oc]:i.ONE_MINUS_DST_COLOR,[Nc]:i.ONE_MINUS_DST_ALPHA,[zc]:i.CONSTANT_COLOR,[Gc]:i.ONE_MINUS_CONSTANT_COLOR,[Vc]:i.CONSTANT_ALPHA,[Hc]:i.ONE_MINUS_CONSTANT_ALPHA};function We(M,B,N,ee,ne,q,de,ue,Ge,Ie){if(M===_n){_===!0&&(Pe(i.BLEND),_=!1);return}if(_===!1&&(re(i.BLEND),_=!0),M!==Tc){if(M!==f||Ie!==U){if((w!==Kn||R!==Kn)&&(i.blendEquation(i.FUNC_ADD),w=Kn,R=Kn),Ie)switch(M){case On:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case so:i.blendFunc(i.ONE,i.ONE);break;case ao:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case oo:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:He("WebGLState: Invalid blending: ",M);break}else switch(M){case On:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case so:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case ao:He("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case oo:He("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:He("WebGLState: Invalid blending: ",M);break}C=null,S=null,b=null,P=null,g.set(0,0,0),T=0,f=M,U=Ie}return}ne=ne||B,q=q||N,de=de||ee,(B!==w||ne!==R)&&(i.blendEquationSeparate(Fe[B],Fe[ne]),w=B,R=ne),(N!==C||ee!==S||q!==b||de!==P)&&(i.blendFuncSeparate(Ze[N],Ze[ee],Ze[q],Ze[de]),C=N,S=ee,b=q,P=de),(ue.equals(g)===!1||Ge!==T)&&(i.blendColor(ue.r,ue.g,ue.b,Ge),g.copy(ue),T=Ge),f=M,U=!1}function Ve(M,B){M.side===pn?Pe(i.CULL_FACE):re(i.CULL_FACE);let N=M.side===Nt;B&&(N=!N),lt(N),M.blending===On&&M.transparent===!1?We(_n):We(M.blending,M.blendEquation,M.blendSrc,M.blendDst,M.blendEquationAlpha,M.blendSrcAlpha,M.blendDstAlpha,M.blendColor,M.blendAlpha,M.premultipliedAlpha),a.setFunc(M.depthFunc),a.setTest(M.depthTest),a.setMask(M.depthWrite),s.setMask(M.colorWrite);const ee=M.stencilWrite;o.setTest(ee),ee&&(o.setMask(M.stencilWriteMask),o.setFunc(M.stencilFunc,M.stencilRef,M.stencilFuncMask),o.setOp(M.stencilFail,M.stencilZFail,M.stencilZPass)),xt(M.polygonOffset,M.polygonOffsetFactor,M.polygonOffsetUnits),M.alphaToCoverage===!0?re(i.SAMPLE_ALPHA_TO_COVERAGE):Pe(i.SAMPLE_ALPHA_TO_COVERAGE)}function lt(M){L!==M&&(M?i.frontFace(i.CW):i.frontFace(i.CCW),L=M)}function ht(M){M!==Ec?(re(i.CULL_FACE),M!==z&&(M===ro?i.cullFace(i.BACK):M===yc?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):Pe(i.CULL_FACE),z=M}function _t(M){M!==$&&(X&&i.lineWidth(M),$=M)}function xt(M,B,N){M?(re(i.POLYGON_OFFSET_FILL),(j!==B||H!==N)&&(j=B,H=N,a.getReversed()&&(B=-B),i.polygonOffset(B,N))):Pe(i.POLYGON_OFFSET_FILL)}function it(M){M?re(i.SCISSOR_TEST):Pe(i.SCISSOR_TEST)}function ut(M){M===void 0&&(M=i.TEXTURE0+Z-1),fe!==M&&(i.activeTexture(M),fe=M)}function I(M,B,N){N===void 0&&(fe===null?N=i.TEXTURE0+Z-1:N=fe);let ee=me[N];ee===void 0&&(ee={type:void 0,texture:void 0},me[N]=ee),(ee.type!==M||ee.texture!==B)&&(fe!==N&&(i.activeTexture(N),fe=N),i.bindTexture(M,B||le[M]),ee.type=M,ee.texture=B)}function yt(){const M=me[fe];M!==void 0&&M.type!==void 0&&(i.bindTexture(M.type,null),M.type=void 0,M.texture=void 0)}function Ke(){try{i.compressedTexImage2D(...arguments)}catch(M){He("WebGLState:",M)}}function E(){try{i.compressedTexImage3D(...arguments)}catch(M){He("WebGLState:",M)}}function p(){try{i.texSubImage2D(...arguments)}catch(M){He("WebGLState:",M)}}function O(){try{i.texSubImage3D(...arguments)}catch(M){He("WebGLState:",M)}}function k(){try{i.compressedTexSubImage2D(...arguments)}catch(M){He("WebGLState:",M)}}function Y(){try{i.compressedTexSubImage3D(...arguments)}catch(M){He("WebGLState:",M)}}function se(){try{i.texStorage2D(...arguments)}catch(M){He("WebGLState:",M)}}function ae(){try{i.texStorage3D(...arguments)}catch(M){He("WebGLState:",M)}}function K(){try{i.texImage2D(...arguments)}catch(M){He("WebGLState:",M)}}function J(){try{i.texImage3D(...arguments)}catch(M){He("WebGLState:",M)}}function oe(M){return m[M]!==void 0?m[M]:i.getParameter(M)}function Se(M,B){m[M]!==B&&(i.pixelStorei(M,B),m[M]=B)}function he(M){rt.equals(M)===!1&&(i.scissor(M.x,M.y,M.z,M.w),rt.copy(M))}function ce(M){Ye.equals(M)===!1&&(i.viewport(M.x,M.y,M.z,M.w),Ye.copy(M))}function ye(M,B){let N=l.get(B);N===void 0&&(N=new WeakMap,l.set(B,N));let ee=N.get(M);ee===void 0&&(ee=i.getUniformBlockIndex(B,M.name),N.set(M,ee))}function be(M,B){const ee=l.get(B).get(M);c.get(B)!==ee&&(i.uniformBlockBinding(B,ee,M.__bindingPointIndex),c.set(B,ee))}function A(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),a.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),i.pixelStorei(i.PACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.BROWSER_DEFAULT_WEBGL),i.pixelStorei(i.PACK_ROW_LENGTH,0),i.pixelStorei(i.PACK_SKIP_PIXELS,0),i.pixelStorei(i.PACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_ROW_LENGTH,0),i.pixelStorei(i.UNPACK_IMAGE_HEIGHT,0),i.pixelStorei(i.UNPACK_SKIP_PIXELS,0),i.pixelStorei(i.UNPACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_SKIP_IMAGES,0),u={},m={},fe=null,me={},h={},d=new WeakMap,x=[],y=null,_=!1,f=null,w=null,C=null,S=null,R=null,b=null,P=null,g=new ze(0,0,0),T=0,U=!1,L=null,z=null,$=null,j=null,H=null,rt.set(0,0,i.canvas.width,i.canvas.height),Ye.set(0,0,i.canvas.width,i.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:re,disable:Pe,bindFramebuffer:De,drawBuffers:Re,useProgram:ot,setBlending:We,setMaterial:Ve,setFlipSided:lt,setCullFace:ht,setLineWidth:_t,setPolygonOffset:xt,setScissorTest:it,activeTexture:ut,bindTexture:I,unbindTexture:yt,compressedTexImage2D:Ke,compressedTexImage3D:E,texImage2D:K,texImage3D:J,pixelStorei:Se,getParameter:oe,updateUBOMapping:ye,uniformBlockBinding:be,texStorage2D:se,texStorage3D:ae,texSubImage2D:p,texSubImage3D:O,compressedTexSubImage2D:k,compressedTexSubImage3D:Y,scissor:he,viewport:ce,reset:A}}function Fm(i,e,t,n,r,s,a){const o=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 Ce,u=new WeakMap,m=new Set;let h;const d=new WeakMap;let x=!1;try{x=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function y(E,p){return x?new OffscreenCanvas(E,p):zr("canvas")}function _(E,p,O){let k=1;const Y=Ke(E);if((Y.width>O||Y.height>O)&&(k=O/Math.max(Y.width,Y.height)),k<1)if(typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&E instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&E instanceof ImageBitmap||typeof VideoFrame<"u"&&E instanceof VideoFrame){const se=Math.floor(k*Y.width),ae=Math.floor(k*Y.height);h===void 0&&(h=y(se,ae));const K=p?y(se,ae):h;return K.width=se,K.height=ae,K.getContext("2d").drawImage(E,0,0,se,ae),we("WebGLRenderer: Texture has been resized from ("+Y.width+"x"+Y.height+") to ("+se+"x"+ae+")."),K}else return"data"in E&&we("WebGLRenderer: Image in DataTexture is too big ("+Y.width+"x"+Y.height+")."),E;return E}function f(E){return E.generateMipmaps}function w(E){i.generateMipmap(E)}function C(E){return E.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:E.isWebGL3DRenderTarget?i.TEXTURE_3D:E.isWebGLArrayRenderTarget||E.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function S(E,p,O,k,Y,se=!1){if(E!==null){if(i[E]!==void 0)return i[E];we("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+E+"'")}let ae;k&&(ae=e.get("EXT_texture_norm16"),ae||we("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let K=p;if(p===i.RED&&(O===i.FLOAT&&(K=i.R32F),O===i.HALF_FLOAT&&(K=i.R16F),O===i.UNSIGNED_BYTE&&(K=i.R8),O===i.UNSIGNED_SHORT&&ae&&(K=ae.R16_EXT),O===i.SHORT&&ae&&(K=ae.R16_SNORM_EXT)),p===i.RED_INTEGER&&(O===i.UNSIGNED_BYTE&&(K=i.R8UI),O===i.UNSIGNED_SHORT&&(K=i.R16UI),O===i.UNSIGNED_INT&&(K=i.R32UI),O===i.BYTE&&(K=i.R8I),O===i.SHORT&&(K=i.R16I),O===i.INT&&(K=i.R32I)),p===i.RG&&(O===i.FLOAT&&(K=i.RG32F),O===i.HALF_FLOAT&&(K=i.RG16F),O===i.UNSIGNED_BYTE&&(K=i.RG8),O===i.UNSIGNED_SHORT&&ae&&(K=ae.RG16_EXT),O===i.SHORT&&ae&&(K=ae.RG16_SNORM_EXT)),p===i.RG_INTEGER&&(O===i.UNSIGNED_BYTE&&(K=i.RG8UI),O===i.UNSIGNED_SHORT&&(K=i.RG16UI),O===i.UNSIGNED_INT&&(K=i.RG32UI),O===i.BYTE&&(K=i.RG8I),O===i.SHORT&&(K=i.RG16I),O===i.INT&&(K=i.RG32I)),p===i.RGB_INTEGER&&(O===i.UNSIGNED_BYTE&&(K=i.RGB8UI),O===i.UNSIGNED_SHORT&&(K=i.RGB16UI),O===i.UNSIGNED_INT&&(K=i.RGB32UI),O===i.BYTE&&(K=i.RGB8I),O===i.SHORT&&(K=i.RGB16I),O===i.INT&&(K=i.RGB32I)),p===i.RGBA_INTEGER&&(O===i.UNSIGNED_BYTE&&(K=i.RGBA8UI),O===i.UNSIGNED_SHORT&&(K=i.RGBA16UI),O===i.UNSIGNED_INT&&(K=i.RGBA32UI),O===i.BYTE&&(K=i.RGBA8I),O===i.SHORT&&(K=i.RGBA16I),O===i.INT&&(K=i.RGBA32I)),p===i.RGB&&(O===i.UNSIGNED_SHORT&&ae&&(K=ae.RGB16_EXT),O===i.SHORT&&ae&&(K=ae.RGB16_SNORM_EXT),O===i.UNSIGNED_INT_5_9_9_9_REV&&(K=i.RGB9_E5),O===i.UNSIGNED_INT_10F_11F_11F_REV&&(K=i.R11F_G11F_B10F)),p===i.RGBA){const J=se?Or:ke.getTransfer(Y);O===i.FLOAT&&(K=i.RGBA32F),O===i.HALF_FLOAT&&(K=i.RGBA16F),O===i.UNSIGNED_BYTE&&(K=J===$e?i.SRGB8_ALPHA8:i.RGBA8),O===i.UNSIGNED_SHORT&&ae&&(K=ae.RGBA16_EXT),O===i.SHORT&&ae&&(K=ae.RGBA16_SNORM_EXT),O===i.UNSIGNED_SHORT_4_4_4_4&&(K=i.RGBA4),O===i.UNSIGNED_SHORT_5_5_5_1&&(K=i.RGB5_A1)}return(K===i.R16F||K===i.R32F||K===i.RG16F||K===i.RG32F||K===i.RGBA16F||K===i.RGBA32F)&&e.get("EXT_color_buffer_float"),K}function R(E,p){let O;return E?p===null||p===on||p===Ki?O=i.DEPTH24_STENCIL8:p===nn?O=i.DEPTH32F_STENCIL8:p===qi&&(O=i.DEPTH24_STENCIL8,we("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):p===null||p===on||p===Ki?O=i.DEPTH_COMPONENT24:p===nn?O=i.DEPTH_COMPONENT32F:p===qi&&(O=i.DEPTH_COMPONENT16),O}function b(E,p){return f(E)===!0||E.isFramebufferTexture&&E.minFilter!==bt&&E.minFilter!==wt?Math.log2(Math.max(p.width,p.height))+1:E.mipmaps!==void 0&&E.mipmaps.length>0?E.mipmaps.length:E.isCompressedTexture&&Array.isArray(E.image)?p.mipmaps.length:1}function P(E){const p=E.target;p.removeEventListener("dispose",P),T(p),p.isVideoTexture&&u.delete(p),p.isHTMLTexture&&m.delete(p)}function g(E){const p=E.target;p.removeEventListener("dispose",g),L(p)}function T(E){const p=n.get(E);if(p.__webglInit===void 0)return;const O=E.source,k=d.get(O);if(k){const Y=k[p.__cacheKey];Y.usedTimes--,Y.usedTimes===0&&U(E),Object.keys(k).length===0&&d.delete(O)}n.remove(E)}function U(E){const p=n.get(E);i.deleteTexture(p.__webglTexture);const O=E.source,k=d.get(O);delete k[p.__cacheKey],a.memory.textures--}function L(E){const p=n.get(E);if(E.depthTexture&&(E.depthTexture.dispose(),n.remove(E.depthTexture)),E.isWebGLCubeRenderTarget)for(let k=0;k<6;k++){if(Array.isArray(p.__webglFramebuffer[k]))for(let Y=0;Y<p.__webglFramebuffer[k].length;Y++)i.deleteFramebuffer(p.__webglFramebuffer[k][Y]);else i.deleteFramebuffer(p.__webglFramebuffer[k]);p.__webglDepthbuffer&&i.deleteRenderbuffer(p.__webglDepthbuffer[k])}else{if(Array.isArray(p.__webglFramebuffer))for(let k=0;k<p.__webglFramebuffer.length;k++)i.deleteFramebuffer(p.__webglFramebuffer[k]);else i.deleteFramebuffer(p.__webglFramebuffer);if(p.__webglDepthbuffer&&i.deleteRenderbuffer(p.__webglDepthbuffer),p.__webglMultisampledFramebuffer&&i.deleteFramebuffer(p.__webglMultisampledFramebuffer),p.__webglColorRenderbuffer)for(let k=0;k<p.__webglColorRenderbuffer.length;k++)p.__webglColorRenderbuffer[k]&&i.deleteRenderbuffer(p.__webglColorRenderbuffer[k]);p.__webglDepthRenderbuffer&&i.deleteRenderbuffer(p.__webglDepthRenderbuffer)}const O=E.textures;for(let k=0,Y=O.length;k<Y;k++){const se=n.get(O[k]);se.__webglTexture&&(i.deleteTexture(se.__webglTexture),a.memory.textures--),n.remove(O[k])}n.remove(E)}let z=0;function $(){z=0}function j(){return z}function H(E){z=E}function Z(){const E=z;return E>=r.maxTextures&&we("WebGLTextures: Trying to use "+E+" texture units while this GPU supports only "+r.maxTextures),z+=1,E}function X(E){const p=[];return p.push(E.wrapS),p.push(E.wrapT),p.push(E.wrapR||0),p.push(E.magFilter),p.push(E.minFilter),p.push(E.anisotropy),p.push(E.internalFormat),p.push(E.format),p.push(E.type),p.push(E.generateMipmaps),p.push(E.premultiplyAlpha),p.push(E.flipY),p.push(E.unpackAlignment),p.push(E.colorSpace),p.join()}function te(E,p){const O=n.get(E);if(E.isVideoTexture&&I(E),E.isRenderTargetTexture===!1&&E.isExternalTexture!==!0&&E.version>0&&O.__version!==E.version){const k=E.image;if(k===null)we("WebGLRenderer: Texture marked for update but no image data found.");else if(k.complete===!1)we("WebGLRenderer: Texture marked for update but image is incomplete");else{Pe(O,E,p);return}}else E.isExternalTexture&&(O.__webglTexture=E.sourceTexture?E.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,O.__webglTexture,i.TEXTURE0+p)}function ie(E,p){const O=n.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&O.__version!==E.version){Pe(O,E,p);return}else E.isExternalTexture&&(O.__webglTexture=E.sourceTexture?E.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,O.__webglTexture,i.TEXTURE0+p)}function fe(E,p){const O=n.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&O.__version!==E.version){Pe(O,E,p);return}t.bindTexture(i.TEXTURE_3D,O.__webglTexture,i.TEXTURE0+p)}function me(E,p){const O=n.get(E);if(E.isCubeDepthTexture!==!0&&E.version>0&&O.__version!==E.version){De(O,E,p);return}t.bindTexture(i.TEXTURE_CUBE_MAP,O.__webglTexture,i.TEXTURE0+p)}const Me={[Zs]:i.REPEAT,[mn]:i.CLAMP_TO_EDGE,[$s]:i.MIRRORED_REPEAT},Xe={[bt]:i.NEAREST,[Xc]:i.NEAREST_MIPMAP_NEAREST,[ji]:i.NEAREST_MIPMAP_LINEAR,[wt]:i.LINEAR,[ss]:i.LINEAR_MIPMAP_NEAREST,[$n]:i.LINEAR_MIPMAP_LINEAR},rt={[Kc]:i.NEVER,[jc]:i.ALWAYS,[Zc]:i.LESS,[Ga]:i.LEQUAL,[$c]:i.EQUAL,[Va]:i.GEQUAL,[Jc]:i.GREATER,[Qc]:i.NOTEQUAL};function Ye(E,p){if(p.type===nn&&e.has("OES_texture_float_linear")===!1&&(p.magFilter===wt||p.magFilter===ss||p.magFilter===ji||p.magFilter===$n||p.minFilter===wt||p.minFilter===ss||p.minFilter===ji||p.minFilter===$n)&&we("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(E,i.TEXTURE_WRAP_S,Me[p.wrapS]),i.texParameteri(E,i.TEXTURE_WRAP_T,Me[p.wrapT]),(E===i.TEXTURE_3D||E===i.TEXTURE_2D_ARRAY)&&i.texParameteri(E,i.TEXTURE_WRAP_R,Me[p.wrapR]),i.texParameteri(E,i.TEXTURE_MAG_FILTER,Xe[p.magFilter]),i.texParameteri(E,i.TEXTURE_MIN_FILTER,Xe[p.minFilter]),p.compareFunction&&(i.texParameteri(E,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(E,i.TEXTURE_COMPARE_FUNC,rt[p.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(p.magFilter===bt||p.minFilter!==ji&&p.minFilter!==$n||p.type===nn&&e.has("OES_texture_float_linear")===!1)return;if(p.anisotropy>1||n.get(p).__currentAnisotropy){const O=e.get("EXT_texture_filter_anisotropic");i.texParameterf(E,O.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(p.anisotropy,r.getMaxAnisotropy())),n.get(p).__currentAnisotropy=p.anisotropy}}}function Q(E,p){let O=!1;E.__webglInit===void 0&&(E.__webglInit=!0,p.addEventListener("dispose",P));const k=p.source;let Y=d.get(k);Y===void 0&&(Y={},d.set(k,Y));const se=X(p);if(se!==E.__cacheKey){Y[se]===void 0&&(Y[se]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,O=!0),Y[se].usedTimes++;const ae=Y[E.__cacheKey];ae!==void 0&&(Y[E.__cacheKey].usedTimes--,ae.usedTimes===0&&U(p)),E.__cacheKey=se,E.__webglTexture=Y[se].texture}return O}function le(E,p,O){return Math.floor(Math.floor(E/O)/p)}function re(E,p,O,k){const se=E.updateRanges;if(se.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,p.width,p.height,O,k,p.data);else{se.sort((Se,he)=>Se.start-he.start);let ae=0;for(let Se=1;Se<se.length;Se++){const he=se[ae],ce=se[Se],ye=he.start+he.count,be=le(ce.start,p.width,4),A=le(he.start,p.width,4);ce.start<=ye+1&&be===A&&le(ce.start+ce.count-1,p.width,4)===be?he.count=Math.max(he.count,ce.start+ce.count-he.start):(++ae,se[ae]=ce)}se.length=ae+1;const K=t.getParameter(i.UNPACK_ROW_LENGTH),J=t.getParameter(i.UNPACK_SKIP_PIXELS),oe=t.getParameter(i.UNPACK_SKIP_ROWS);t.pixelStorei(i.UNPACK_ROW_LENGTH,p.width);for(let Se=0,he=se.length;Se<he;Se++){const ce=se[Se],ye=Math.floor(ce.start/4),be=Math.ceil(ce.count/4),A=ye%p.width,M=Math.floor(ye/p.width),B=be,N=1;t.pixelStorei(i.UNPACK_SKIP_PIXELS,A),t.pixelStorei(i.UNPACK_SKIP_ROWS,M),t.texSubImage2D(i.TEXTURE_2D,0,A,M,B,N,O,k,p.data)}E.clearUpdateRanges(),t.pixelStorei(i.UNPACK_ROW_LENGTH,K),t.pixelStorei(i.UNPACK_SKIP_PIXELS,J),t.pixelStorei(i.UNPACK_SKIP_ROWS,oe)}}function Pe(E,p,O){let k=i.TEXTURE_2D;(p.isDataArrayTexture||p.isCompressedArrayTexture)&&(k=i.TEXTURE_2D_ARRAY),p.isData3DTexture&&(k=i.TEXTURE_3D);const Y=Q(E,p),se=p.source;t.bindTexture(k,E.__webglTexture,i.TEXTURE0+O);const ae=n.get(se);if(se.version!==ae.__version||Y===!0){if(t.activeTexture(i.TEXTURE0+O),(typeof ImageBitmap<"u"&&p.image instanceof ImageBitmap)===!1){const N=ke.getPrimaries(ke.workingColorSpace),ee=p.colorSpace===In?null:ke.getPrimaries(p.colorSpace),ne=p.colorSpace===In||N===ee?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,p.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,p.premultiplyAlpha),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,ne)}t.pixelStorei(i.UNPACK_ALIGNMENT,p.unpackAlignment);let J=_(p.image,!1,r.maxTextureSize);J=yt(p,J);const oe=s.convert(p.format,p.colorSpace),Se=s.convert(p.type);let he=S(p.internalFormat,oe,Se,p.normalized,p.colorSpace,p.isVideoTexture);Ye(k,p);let ce;const ye=p.mipmaps,be=p.isVideoTexture!==!0,A=ae.__version===void 0||Y===!0,M=se.dataReady,B=b(p,J);if(p.isDepthTexture)he=R(p.format===Jn,p.type),A&&(be?t.texStorage2D(i.TEXTURE_2D,1,he,J.width,J.height):t.texImage2D(i.TEXTURE_2D,0,he,J.width,J.height,0,oe,Se,null));else if(p.isDataTexture)if(ye.length>0){be&&A&&t.texStorage2D(i.TEXTURE_2D,B,he,ye[0].width,ye[0].height);for(let N=0,ee=ye.length;N<ee;N++)ce=ye[N],be?M&&t.texSubImage2D(i.TEXTURE_2D,N,0,0,ce.width,ce.height,oe,Se,ce.data):t.texImage2D(i.TEXTURE_2D,N,he,ce.width,ce.height,0,oe,Se,ce.data);p.generateMipmaps=!1}else be?(A&&t.texStorage2D(i.TEXTURE_2D,B,he,J.width,J.height),M&&re(p,J,oe,Se)):t.texImage2D(i.TEXTURE_2D,0,he,J.width,J.height,0,oe,Se,J.data);else if(p.isCompressedTexture)if(p.isCompressedArrayTexture){be&&A&&t.texStorage3D(i.TEXTURE_2D_ARRAY,B,he,ye[0].width,ye[0].height,J.depth);for(let N=0,ee=ye.length;N<ee;N++)if(ce=ye[N],p.format!==Zt)if(oe!==null)if(be){if(M)if(p.layerUpdates.size>0){const ne=Go(ce.width,ce.height,p.format,p.type);for(const q of p.layerUpdates){const de=ce.data.subarray(q*ne/ce.data.BYTES_PER_ELEMENT,(q+1)*ne/ce.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,N,0,0,q,ce.width,ce.height,1,oe,de)}p.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,N,0,0,0,ce.width,ce.height,J.depth,oe,ce.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,N,he,ce.width,ce.height,J.depth,0,ce.data,0,0);else we("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else be?M&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,N,0,0,0,ce.width,ce.height,J.depth,oe,Se,ce.data):t.texImage3D(i.TEXTURE_2D_ARRAY,N,he,ce.width,ce.height,J.depth,0,oe,Se,ce.data)}else{be&&A&&t.texStorage2D(i.TEXTURE_2D,B,he,ye[0].width,ye[0].height);for(let N=0,ee=ye.length;N<ee;N++)ce=ye[N],p.format!==Zt?oe!==null?be?M&&t.compressedTexSubImage2D(i.TEXTURE_2D,N,0,0,ce.width,ce.height,oe,ce.data):t.compressedTexImage2D(i.TEXTURE_2D,N,he,ce.width,ce.height,0,ce.data):we("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):be?M&&t.texSubImage2D(i.TEXTURE_2D,N,0,0,ce.width,ce.height,oe,Se,ce.data):t.texImage2D(i.TEXTURE_2D,N,he,ce.width,ce.height,0,oe,Se,ce.data)}else if(p.isDataArrayTexture)if(be){if(A&&t.texStorage3D(i.TEXTURE_2D_ARRAY,B,he,J.width,J.height,J.depth),M)if(p.layerUpdates.size>0){const N=Go(J.width,J.height,p.format,p.type);for(const ee of p.layerUpdates){const ne=J.data.subarray(ee*N/J.data.BYTES_PER_ELEMENT,(ee+1)*N/J.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,ee,J.width,J.height,1,oe,Se,ne)}p.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,J.width,J.height,J.depth,oe,Se,J.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,he,J.width,J.height,J.depth,0,oe,Se,J.data);else if(p.isData3DTexture)be?(A&&t.texStorage3D(i.TEXTURE_3D,B,he,J.width,J.height,J.depth),M&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,J.width,J.height,J.depth,oe,Se,J.data)):t.texImage3D(i.TEXTURE_3D,0,he,J.width,J.height,J.depth,0,oe,Se,J.data);else if(p.isFramebufferTexture){if(A)if(be)t.texStorage2D(i.TEXTURE_2D,B,he,J.width,J.height);else{let N=J.width,ee=J.height;for(let ne=0;ne<B;ne++)t.texImage2D(i.TEXTURE_2D,ne,he,N,ee,0,oe,Se,null),N>>=1,ee>>=1}}else if(p.isHTMLTexture){if("texElementImage2D"in i){const N=i.canvas;if(N.hasAttribute("layoutsubtree")||N.setAttribute("layoutsubtree","true"),J.parentNode!==N){N.appendChild(J),m.add(p),N.onpaint=ee=>{const ne=ee.changedElements;for(const q of m)ne.includes(q.image)&&(q.needsUpdate=!0)},N.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,J);else{const ne=i.RGBA,q=i.RGBA,de=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,ne,q,de,J)}i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE)}}else if(ye.length>0){if(be&&A){const N=Ke(ye[0]);t.texStorage2D(i.TEXTURE_2D,B,he,N.width,N.height)}for(let N=0,ee=ye.length;N<ee;N++)ce=ye[N],be?M&&t.texSubImage2D(i.TEXTURE_2D,N,0,0,oe,Se,ce):t.texImage2D(i.TEXTURE_2D,N,he,oe,Se,ce);p.generateMipmaps=!1}else if(be){if(A){const N=Ke(J);t.texStorage2D(i.TEXTURE_2D,B,he,N.width,N.height)}M&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,oe,Se,J)}else t.texImage2D(i.TEXTURE_2D,0,he,oe,Se,J);f(p)&&w(k),ae.__version=se.version,p.onUpdate&&p.onUpdate(p)}E.__version=p.version}function De(E,p,O){if(p.image.length!==6)return;const k=Q(E,p),Y=p.source;t.bindTexture(i.TEXTURE_CUBE_MAP,E.__webglTexture,i.TEXTURE0+O);const se=n.get(Y);if(Y.version!==se.__version||k===!0){t.activeTexture(i.TEXTURE0+O);const ae=ke.getPrimaries(ke.workingColorSpace),K=p.colorSpace===In?null:ke.getPrimaries(p.colorSpace),J=p.colorSpace===In||ae===K?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,p.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,p.premultiplyAlpha),t.pixelStorei(i.UNPACK_ALIGNMENT,p.unpackAlignment),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,J);const oe=p.isCompressedTexture||p.image[0].isCompressedTexture,Se=p.image[0]&&p.image[0].isDataTexture,he=[];for(let q=0;q<6;q++)!oe&&!Se?he[q]=_(p.image[q],!0,r.maxCubemapSize):he[q]=Se?p.image[q].image:p.image[q],he[q]=yt(p,he[q]);const ce=he[0],ye=s.convert(p.format,p.colorSpace),be=s.convert(p.type),A=S(p.internalFormat,ye,be,p.normalized,p.colorSpace),M=p.isVideoTexture!==!0,B=se.__version===void 0||k===!0,N=Y.dataReady;let ee=b(p,ce);Ye(i.TEXTURE_CUBE_MAP,p);let ne;if(oe){M&&B&&t.texStorage2D(i.TEXTURE_CUBE_MAP,ee,A,ce.width,ce.height);for(let q=0;q<6;q++){ne=he[q].mipmaps;for(let de=0;de<ne.length;de++){const ue=ne[de];p.format!==Zt?ye!==null?M?N&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,de,0,0,ue.width,ue.height,ye,ue.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,de,A,ue.width,ue.height,0,ue.data):we("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):M?N&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,de,0,0,ue.width,ue.height,ye,be,ue.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,de,A,ue.width,ue.height,0,ye,be,ue.data)}}}else{if(ne=p.mipmaps,M&&B){ne.length>0&&ee++;const q=Ke(he[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,ee,A,q.width,q.height)}for(let q=0;q<6;q++)if(Se){M?N&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,0,0,0,he[q].width,he[q].height,ye,be,he[q].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,0,A,he[q].width,he[q].height,0,ye,be,he[q].data);for(let de=0;de<ne.length;de++){const Ge=ne[de].image[q].image;M?N&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,de+1,0,0,Ge.width,Ge.height,ye,be,Ge.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,de+1,A,Ge.width,Ge.height,0,ye,be,Ge.data)}}else{M?N&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,0,0,0,ye,be,he[q]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,0,A,ye,be,he[q]);for(let de=0;de<ne.length;de++){const ue=ne[de];M?N&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,de+1,0,0,ye,be,ue.image[q]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,de+1,A,ye,be,ue.image[q])}}}f(p)&&w(i.TEXTURE_CUBE_MAP),se.__version=Y.version,p.onUpdate&&p.onUpdate(p)}E.__version=p.version}function Re(E,p,O,k,Y,se){const ae=s.convert(O.format,O.colorSpace),K=s.convert(O.type),J=S(O.internalFormat,ae,K,O.normalized,O.colorSpace),oe=n.get(p),Se=n.get(O);if(Se.__renderTarget=p,!oe.__hasExternalTextures){const he=Math.max(1,p.width>>se),ce=Math.max(1,p.height>>se);Y===i.TEXTURE_3D||Y===i.TEXTURE_2D_ARRAY?t.texImage3D(Y,se,J,he,ce,p.depth,0,ae,K,null):t.texImage2D(Y,se,J,he,ce,0,ae,K,null)}t.bindFramebuffer(i.FRAMEBUFFER,E),ut(p)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,k,Y,Se.__webglTexture,0,it(p)):(Y===i.TEXTURE_2D||Y>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&Y<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,k,Y,Se.__webglTexture,se),t.bindFramebuffer(i.FRAMEBUFFER,null)}function ot(E,p,O){if(i.bindRenderbuffer(i.RENDERBUFFER,E),p.depthBuffer){const k=p.depthTexture,Y=k&&k.isDepthTexture?k.type:null,se=R(p.stencilBuffer,Y),ae=p.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;ut(p)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,it(p),se,p.width,p.height):O?i.renderbufferStorageMultisample(i.RENDERBUFFER,it(p),se,p.width,p.height):i.renderbufferStorage(i.RENDERBUFFER,se,p.width,p.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,ae,i.RENDERBUFFER,E)}else{const k=p.textures;for(let Y=0;Y<k.length;Y++){const se=k[Y],ae=s.convert(se.format,se.colorSpace),K=s.convert(se.type),J=S(se.internalFormat,ae,K,se.normalized,se.colorSpace);ut(p)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,it(p),J,p.width,p.height):O?i.renderbufferStorageMultisample(i.RENDERBUFFER,it(p),J,p.width,p.height):i.renderbufferStorage(i.RENDERBUFFER,J,p.width,p.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function Fe(E,p,O){const k=p.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(i.FRAMEBUFFER,E),!(p.depthTexture&&p.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const Y=n.get(p.depthTexture);if(Y.__renderTarget=p,(!Y.__webglTexture||p.depthTexture.image.width!==p.width||p.depthTexture.image.height!==p.height)&&(p.depthTexture.image.width=p.width,p.depthTexture.image.height=p.height,p.depthTexture.needsUpdate=!0),k){if(Y.__webglInit===void 0&&(Y.__webglInit=!0,p.depthTexture.addEventListener("dispose",P)),Y.__webglTexture===void 0){Y.__webglTexture=i.createTexture(),t.bindTexture(i.TEXTURE_CUBE_MAP,Y.__webglTexture),Ye(i.TEXTURE_CUBE_MAP,p.depthTexture);const oe=s.convert(p.depthTexture.format),Se=s.convert(p.depthTexture.type);let he;p.depthTexture.format===vn?he=i.DEPTH_COMPONENT24:p.depthTexture.format===Jn&&(he=i.DEPTH24_STENCIL8);for(let ce=0;ce<6;ce++)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,he,p.width,p.height,0,oe,Se,null)}}else te(p.depthTexture,0);const se=Y.__webglTexture,ae=it(p),K=k?i.TEXTURE_CUBE_MAP_POSITIVE_X+O:i.TEXTURE_2D,J=p.depthTexture.format===Jn?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;if(p.depthTexture.format===vn)ut(p)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,J,K,se,0,ae):i.framebufferTexture2D(i.FRAMEBUFFER,J,K,se,0);else if(p.depthTexture.format===Jn)ut(p)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,J,K,se,0,ae):i.framebufferTexture2D(i.FRAMEBUFFER,J,K,se,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ze(E){const p=n.get(E),O=E.isWebGLCubeRenderTarget===!0;if(p.__boundDepthTexture!==E.depthTexture){const k=E.depthTexture;if(p.__depthDisposeCallback&&p.__depthDisposeCallback(),k){const Y=()=>{delete p.__boundDepthTexture,delete p.__depthDisposeCallback,k.removeEventListener("dispose",Y)};k.addEventListener("dispose",Y),p.__depthDisposeCallback=Y}p.__boundDepthTexture=k}if(E.depthTexture&&!p.__autoAllocateDepthBuffer)if(O)for(let k=0;k<6;k++)Fe(p.__webglFramebuffer[k],E,k);else{const k=E.texture.mipmaps;k&&k.length>0?Fe(p.__webglFramebuffer[0],E,0):Fe(p.__webglFramebuffer,E,0)}else if(O){p.__webglDepthbuffer=[];for(let k=0;k<6;k++)if(t.bindFramebuffer(i.FRAMEBUFFER,p.__webglFramebuffer[k]),p.__webglDepthbuffer[k]===void 0)p.__webglDepthbuffer[k]=i.createRenderbuffer(),ot(p.__webglDepthbuffer[k],E,!1);else{const Y=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,se=p.__webglDepthbuffer[k];i.bindRenderbuffer(i.RENDERBUFFER,se),i.framebufferRenderbuffer(i.FRAMEBUFFER,Y,i.RENDERBUFFER,se)}}else{const k=E.texture.mipmaps;if(k&&k.length>0?t.bindFramebuffer(i.FRAMEBUFFER,p.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,p.__webglFramebuffer),p.__webglDepthbuffer===void 0)p.__webglDepthbuffer=i.createRenderbuffer(),ot(p.__webglDepthbuffer,E,!1);else{const Y=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,se=p.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,se),i.framebufferRenderbuffer(i.FRAMEBUFFER,Y,i.RENDERBUFFER,se)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function We(E,p,O){const k=n.get(E);p!==void 0&&Re(k.__webglFramebuffer,E,E.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),O!==void 0&&Ze(E)}function Ve(E){const p=E.texture,O=n.get(E),k=n.get(p);E.addEventListener("dispose",g);const Y=E.textures,se=E.isWebGLCubeRenderTarget===!0,ae=Y.length>1;if(ae||(k.__webglTexture===void 0&&(k.__webglTexture=i.createTexture()),k.__version=p.version,a.memory.textures++),se){O.__webglFramebuffer=[];for(let K=0;K<6;K++)if(p.mipmaps&&p.mipmaps.length>0){O.__webglFramebuffer[K]=[];for(let J=0;J<p.mipmaps.length;J++)O.__webglFramebuffer[K][J]=i.createFramebuffer()}else O.__webglFramebuffer[K]=i.createFramebuffer()}else{if(p.mipmaps&&p.mipmaps.length>0){O.__webglFramebuffer=[];for(let K=0;K<p.mipmaps.length;K++)O.__webglFramebuffer[K]=i.createFramebuffer()}else O.__webglFramebuffer=i.createFramebuffer();if(ae)for(let K=0,J=Y.length;K<J;K++){const oe=n.get(Y[K]);oe.__webglTexture===void 0&&(oe.__webglTexture=i.createTexture(),a.memory.textures++)}if(E.samples>0&&ut(E)===!1){O.__webglMultisampledFramebuffer=i.createFramebuffer(),O.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,O.__webglMultisampledFramebuffer);for(let K=0;K<Y.length;K++){const J=Y[K];O.__webglColorRenderbuffer[K]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,O.__webglColorRenderbuffer[K]);const oe=s.convert(J.format,J.colorSpace),Se=s.convert(J.type),he=S(J.internalFormat,oe,Se,J.normalized,J.colorSpace,E.isXRRenderTarget===!0),ce=it(E);i.renderbufferStorageMultisample(i.RENDERBUFFER,ce,he,E.width,E.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+K,i.RENDERBUFFER,O.__webglColorRenderbuffer[K])}i.bindRenderbuffer(i.RENDERBUFFER,null),E.depthBuffer&&(O.__webglDepthRenderbuffer=i.createRenderbuffer(),ot(O.__webglDepthRenderbuffer,E,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(se){t.bindTexture(i.TEXTURE_CUBE_MAP,k.__webglTexture),Ye(i.TEXTURE_CUBE_MAP,p);for(let K=0;K<6;K++)if(p.mipmaps&&p.mipmaps.length>0)for(let J=0;J<p.mipmaps.length;J++)Re(O.__webglFramebuffer[K][J],E,p,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+K,J);else Re(O.__webglFramebuffer[K],E,p,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+K,0);f(p)&&w(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(ae){for(let K=0,J=Y.length;K<J;K++){const oe=Y[K],Se=n.get(oe);let he=i.TEXTURE_2D;(E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)&&(he=E.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(he,Se.__webglTexture),Ye(he,oe),Re(O.__webglFramebuffer,E,oe,i.COLOR_ATTACHMENT0+K,he,0),f(oe)&&w(he)}t.unbindTexture()}else{let K=i.TEXTURE_2D;if((E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)&&(K=E.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(K,k.__webglTexture),Ye(K,p),p.mipmaps&&p.mipmaps.length>0)for(let J=0;J<p.mipmaps.length;J++)Re(O.__webglFramebuffer[J],E,p,i.COLOR_ATTACHMENT0,K,J);else Re(O.__webglFramebuffer,E,p,i.COLOR_ATTACHMENT0,K,0);f(p)&&w(K),t.unbindTexture()}E.depthBuffer&&Ze(E)}function lt(E){const p=E.textures;for(let O=0,k=p.length;O<k;O++){const Y=p[O];if(f(Y)){const se=C(E),ae=n.get(Y).__webglTexture;t.bindTexture(se,ae),w(se),t.unbindTexture()}}}const ht=[],_t=[];function xt(E){if(E.samples>0){if(ut(E)===!1){const p=E.textures,O=E.width,k=E.height;let Y=i.COLOR_BUFFER_BIT;const se=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ae=n.get(E),K=p.length>1;if(K)for(let oe=0;oe<p.length;oe++)t.bindFramebuffer(i.FRAMEBUFFER,ae.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+oe,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,ae.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+oe,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,ae.__webglMultisampledFramebuffer);const J=E.texture.mipmaps;J&&J.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ae.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ae.__webglFramebuffer);for(let oe=0;oe<p.length;oe++){if(E.resolveDepthBuffer&&(E.depthBuffer&&(Y|=i.DEPTH_BUFFER_BIT),E.stencilBuffer&&E.resolveStencilBuffer&&(Y|=i.STENCIL_BUFFER_BIT)),K){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,ae.__webglColorRenderbuffer[oe]);const Se=n.get(p[oe]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,Se,0)}i.blitFramebuffer(0,0,O,k,0,0,O,k,Y,i.NEAREST),c===!0&&(ht.length=0,_t.length=0,ht.push(i.COLOR_ATTACHMENT0+oe),E.depthBuffer&&E.resolveDepthBuffer===!1&&(ht.push(se),_t.push(se),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,_t)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,ht))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),K)for(let oe=0;oe<p.length;oe++){t.bindFramebuffer(i.FRAMEBUFFER,ae.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+oe,i.RENDERBUFFER,ae.__webglColorRenderbuffer[oe]);const Se=n.get(p[oe]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,ae.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+oe,i.TEXTURE_2D,Se,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ae.__webglMultisampledFramebuffer)}else if(E.depthBuffer&&E.resolveDepthBuffer===!1&&c){const p=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[p])}}}function it(E){return Math.min(r.maxSamples,E.samples)}function ut(E){const p=n.get(E);return E.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&p.__useRenderToTexture!==!1}function I(E){const p=a.render.frame;u.get(E)!==p&&(u.set(E,p),E.update())}function yt(E,p){const O=E.colorSpace,k=E.format,Y=E.type;return E.isCompressedTexture===!0||E.isVideoTexture===!0||O!==Fr&&O!==In&&(ke.getTransfer(O)===$e?(k!==Zt||Y!==kt)&&we("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):He("WebGLTextures: Unsupported texture color space:",O)),p}function Ke(E){return typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement?(l.width=E.naturalWidth||E.width,l.height=E.naturalHeight||E.height):typeof VideoFrame<"u"&&E instanceof VideoFrame?(l.width=E.displayWidth,l.height=E.displayHeight):(l.width=E.width,l.height=E.height),l}this.allocateTextureUnit=Z,this.resetTextureUnits=$,this.getTextureUnits=j,this.setTextureUnits=H,this.setTexture2D=te,this.setTexture2DArray=ie,this.setTexture3D=fe,this.setTextureCube=me,this.rebindTextures=We,this.setupRenderTarget=Ve,this.updateRenderTargetMipmap=lt,this.updateMultisampleRenderTarget=xt,this.setupDepthRenderbuffer=Ze,this.setupFrameBufferTexture=Re,this.useMultisampledRTT=ut,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Om(i,e){function t(n,r=In){let s;const a=ke.getTransfer(r);if(n===kt)return i.UNSIGNED_BYTE;if(n===Na)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Fa)return i.UNSIGNED_SHORT_5_5_5_1;if(n===wl)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Cl)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===Al)return i.BYTE;if(n===Rl)return i.SHORT;if(n===qi)return i.UNSIGNED_SHORT;if(n===Ua)return i.INT;if(n===on)return i.UNSIGNED_INT;if(n===nn)return i.FLOAT;if(n===xn)return i.HALF_FLOAT;if(n===Pl)return i.ALPHA;if(n===Dl)return i.RGB;if(n===Zt)return i.RGBA;if(n===vn)return i.DEPTH_COMPONENT;if(n===Jn)return i.DEPTH_STENCIL;if(n===Ll)return i.RED;if(n===Oa)return i.RED_INTEGER;if(n===jn)return i.RG;if(n===Ba)return i.RG_INTEGER;if(n===za)return i.RGBA_INTEGER;if(n===wr||n===Cr||n===Pr||n===Dr)if(a===$e)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===wr)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Cr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Pr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Dr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===wr)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Cr)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Pr)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Dr)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Js||n===Qs||n===js||n===ea)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===Js)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Qs)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===js)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===ea)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===ta||n===na||n===ia||n===ra||n===sa||n===Ur||n===aa)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(n===ta||n===na)return a===$e?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===ia)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(n===ra)return s.COMPRESSED_R11_EAC;if(n===sa)return s.COMPRESSED_SIGNED_R11_EAC;if(n===Ur)return s.COMPRESSED_RG11_EAC;if(n===aa)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===oa||n===la||n===ca||n===ha||n===ua||n===fa||n===da||n===pa||n===ma||n===_a||n===ga||n===xa||n===va||n===Ma)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(n===oa)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===la)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===ca)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===ha)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===ua)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===fa)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===da)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===pa)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===ma)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===_a)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===ga)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===xa)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===va)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Ma)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Sa||n===Ea||n===ya)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(n===Sa)return a===$e?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Ea)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===ya)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===ba||n===Ta||n===Nr||n===Aa)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(n===ba)return s.COMPRESSED_RED_RGTC1_EXT;if(n===Ta)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Nr)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Aa)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Ki?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const Bm=`
4084
+ }`,Lm=[new D(1,0,0),new D(-1,0,0),new D(0,1,0),new D(0,-1,0),new D(0,0,1),new D(0,0,-1)],Im=[new D(0,-1,0),new D(0,-1,0),new D(0,0,1),new D(0,0,-1),new D(0,-1,0),new D(0,-1,0)],cl=new at,Wi=new D,Os=new D;function Um(i,e,t){let n=new Vl;const r=new Ce,s=new Ce,a=new dt,o=new Xh,c=new Yh,l={},u=t.maxTextureSize,m={[zn]:Nt,[Nt]:zn,[pn]:pn},h=new ln({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ce},radius:{value:4}},vertexShader:Pm,fragmentShader:Dm}),d=h.clone();d.defines.HORIZONTAL_PASS=1;const x=new Xt;x.setAttribute("position",new $t(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new Mn(x,h),_=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=wr;let f=this.type;this.render=function(b,P,g){if(_.enabled===!1||_.autoUpdate===!1&&_.needsUpdate===!1||b.length===0)return;this.type===bc&&(we("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=wr);const T=i.getRenderTarget(),U=i.getActiveCubeFace(),L=i.getActiveMipmapLevel(),z=i.state;z.setBlending(_n),z.buffers.depth.getReversed()===!0?z.buffers.color.setClear(0,0,0,0):z.buffers.color.setClear(1,1,1,1),z.buffers.depth.setTest(!0),z.setScissorTest(!1);const $=f!==this.type;$&&P.traverse(function(j){j.material&&(Array.isArray(j.material)?j.material.forEach(H=>H.needsUpdate=!0):j.material.needsUpdate=!0)});for(let j=0,H=b.length;j<H;j++){const Z=b[j],X=Z.shadow;if(X===void 0){we("WebGLShadowMap:",Z,"has no shadow.");continue}if(X.autoUpdate===!1&&X.needsUpdate===!1)continue;r.copy(X.mapSize);const te=X.getFrameExtents();r.multiply(te),s.copy(X.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(s.x=Math.floor(u/te.x),r.x=s.x*te.x,X.mapSize.x=s.x),r.y>u&&(s.y=Math.floor(u/te.y),r.y=s.y*te.y,X.mapSize.y=s.y));const ie=i.state.buffers.depth.getReversed();if(X.camera._reversedDepth=ie,X.map===null||$===!0){if(X.map!==null&&(X.map.depthTexture!==null&&(X.map.depthTexture.dispose(),X.map.depthTexture=null),X.map.dispose()),this.type===Xi){if(Z.isPointLight){we("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}X.map=new an(r.x,r.y,{format:jn,type:xn,minFilter:wt,magFilter:wt,generateMipmaps:!1}),X.map.texture.name=Z.name+".shadowMap",X.map.depthTexture=new Di(r.x,r.y,nn),X.map.depthTexture.name=Z.name+".shadowMapDepth",X.map.depthTexture.format=vn,X.map.depthTexture.compareFunction=null,X.map.depthTexture.minFilter=bt,X.map.depthTexture.magFilter=bt}else Z.isPointLight?(X.map=new $l(r.x),X.map.depthTexture=new Uh(r.x,on)):(X.map=new an(r.x,r.y),X.map.depthTexture=new Di(r.x,r.y,on)),X.map.depthTexture.name=Z.name+".shadowMap",X.map.depthTexture.format=vn,this.type===wr?(X.map.depthTexture.compareFunction=ie?Va:Ga,X.map.depthTexture.minFilter=wt,X.map.depthTexture.magFilter=wt):(X.map.depthTexture.compareFunction=null,X.map.depthTexture.minFilter=bt,X.map.depthTexture.magFilter=bt);X.camera.updateProjectionMatrix()}const fe=X.map.isWebGLCubeRenderTarget?6:1;for(let me=0;me<fe;me++){if(X.map.isWebGLCubeRenderTarget)i.setRenderTarget(X.map,me),i.clear();else{me===0&&(i.setRenderTarget(X.map),i.clear());const Me=X.getViewport(me);a.set(s.x*Me.x,s.y*Me.y,s.x*Me.z,s.y*Me.w),z.viewport(a)}if(Z.isPointLight){const Me=X.camera,Xe=X.matrix,rt=Z.distance||Me.far;rt!==Me.far&&(Me.far=rt,Me.updateProjectionMatrix()),Wi.setFromMatrixPosition(Z.matrixWorld),Me.position.copy(Wi),Os.copy(Me.position),Os.add(Lm[me]),Me.up.copy(Im[me]),Me.lookAt(Os),Me.updateMatrixWorld(),Xe.makeTranslation(-Wi.x,-Wi.y,-Wi.z),cl.multiplyMatrices(Me.projectionMatrix,Me.matrixWorldInverse),X._frustum.setFromProjectionMatrix(cl,Me.coordinateSystem,Me.reversedDepth)}else X.updateMatrices(Z);n=X.getFrustum(),S(P,g,X.camera,Z,this.type)}X.isPointLightShadow!==!0&&this.type===Xi&&w(X,g),X.needsUpdate=!1}f=this.type,_.needsUpdate=!1,i.setRenderTarget(T,U,L)};function w(b,P){const g=e.update(y);h.defines.VSM_SAMPLES!==b.blurSamples&&(h.defines.VSM_SAMPLES=b.blurSamples,d.defines.VSM_SAMPLES=b.blurSamples,h.needsUpdate=!0,d.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new an(r.x,r.y,{format:jn,type:xn})),h.uniforms.shadow_pass.value=b.map.depthTexture,h.uniforms.resolution.value=b.mapSize,h.uniforms.radius.value=b.radius,i.setRenderTarget(b.mapPass),i.clear(),i.renderBufferDirect(P,null,g,h,y,null),d.uniforms.shadow_pass.value=b.mapPass.texture,d.uniforms.resolution.value=b.mapSize,d.uniforms.radius.value=b.radius,i.setRenderTarget(b.map),i.clear(),i.renderBufferDirect(P,null,g,d,y,null)}function C(b,P,g,T){let U=null;const L=g.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(L!==void 0)U=L;else if(U=g.isPointLight===!0?c:o,i.localClippingEnabled&&P.clipShadows===!0&&Array.isArray(P.clippingPlanes)&&P.clippingPlanes.length!==0||P.displacementMap&&P.displacementScale!==0||P.alphaMap&&P.alphaTest>0||P.map&&P.alphaTest>0||P.alphaToCoverage===!0){const z=U.uuid,$=P.uuid;let j=l[z];j===void 0&&(j={},l[z]=j);let H=j[$];H===void 0&&(H=U.clone(),j[$]=H,P.addEventListener("dispose",R)),U=H}if(U.visible=P.visible,U.wireframe=P.wireframe,T===Xi?U.side=P.shadowSide!==null?P.shadowSide:P.side:U.side=P.shadowSide!==null?P.shadowSide:m[P.side],U.alphaMap=P.alphaMap,U.alphaTest=P.alphaToCoverage===!0?.5:P.alphaTest,U.map=P.map,U.clipShadows=P.clipShadows,U.clippingPlanes=P.clippingPlanes,U.clipIntersection=P.clipIntersection,U.displacementMap=P.displacementMap,U.displacementScale=P.displacementScale,U.displacementBias=P.displacementBias,U.wireframeLinewidth=P.wireframeLinewidth,U.linewidth=P.linewidth,g.isPointLight===!0&&U.isMeshDistanceMaterial===!0){const z=i.properties.get(U);z.light=g}return U}function S(b,P,g,T,U){if(b.visible===!1)return;if(b.layers.test(P.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&U===Xi)&&(!b.frustumCulled||n.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(g.matrixWorldInverse,b.matrixWorld);const $=e.update(b),j=b.material;if(Array.isArray(j)){const H=$.groups;for(let Z=0,X=H.length;Z<X;Z++){const te=H[Z],ie=j[te.materialIndex];if(ie&&ie.visible){const fe=C(b,ie,T,U);b.onBeforeShadow(i,b,P,g,$,fe,te),i.renderBufferDirect(g,null,$,fe,b,te),b.onAfterShadow(i,b,P,g,$,fe,te)}}}else if(j.visible){const H=C(b,j,T,U);b.onBeforeShadow(i,b,P,g,$,H,null),i.renderBufferDirect(g,null,$,H,b,null),b.onAfterShadow(i,b,P,g,$,H,null)}}const z=b.children;for(let $=0,j=z.length;$<j;$++)S(z[$],P,g,T,U)}function R(b){b.target.removeEventListener("dispose",R);for(const g in l){const T=l[g],U=b.target.uuid;U in T&&(T[U].dispose(),delete T[U])}}}function Nm(i,e){function t(){let M=!1;const B=new dt;let N=null;const ee=new dt(0,0,0,0);return{setMask:function(ne){N!==ne&&!M&&(i.colorMask(ne,ne,ne,ne),N=ne)},setLocked:function(ne){M=ne},setClear:function(ne,q,de,ue,Ge){Ge===!0&&(ne*=ue,q*=ue,de*=ue),B.set(ne,q,de,ue),ee.equals(B)===!1&&(i.clearColor(ne,q,de,ue),ee.copy(B))},reset:function(){M=!1,N=null,ee.set(-1,0,0,0)}}}function n(){let M=!1,B=!1,N=null,ee=null,ne=null;return{setReversed:function(q){if(B!==q){const de=e.get("EXT_clip_control");q?de.clipControlEXT(de.LOWER_LEFT_EXT,de.ZERO_TO_ONE_EXT):de.clipControlEXT(de.LOWER_LEFT_EXT,de.NEGATIVE_ONE_TO_ONE_EXT),B=q;const ue=ne;ne=null,this.setClear(ue)}},getReversed:function(){return B},setTest:function(q){q?re(i.DEPTH_TEST):Pe(i.DEPTH_TEST)},setMask:function(q){N!==q&&!M&&(i.depthMask(q),N=q)},setFunc:function(q){if(B&&(q=ih[q]),ee!==q){switch(q){case Hs:i.depthFunc(i.NEVER);break;case ks:i.depthFunc(i.ALWAYS);break;case Ws:i.depthFunc(i.LESS);break;case Ci:i.depthFunc(i.LEQUAL);break;case Xs:i.depthFunc(i.EQUAL);break;case Ys:i.depthFunc(i.GEQUAL);break;case qs:i.depthFunc(i.GREATER);break;case Ks:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}ee=q}},setLocked:function(q){M=q},setClear:function(q){ne!==q&&(ne=q,B&&(q=1-q),i.clearDepth(q))},reset:function(){M=!1,N=null,ee=null,ne=null,B=!1}}}function r(){let M=!1,B=null,N=null,ee=null,ne=null,q=null,de=null,ue=null,Ge=null;return{setTest:function(Ie){M||(Ie?re(i.STENCIL_TEST):Pe(i.STENCIL_TEST))},setMask:function(Ie){B!==Ie&&!M&&(i.stencilMask(Ie),B=Ie)},setFunc:function(Ie,ct,st){(N!==Ie||ee!==ct||ne!==st)&&(i.stencilFunc(Ie,ct,st),N=Ie,ee=ct,ne=st)},setOp:function(Ie,ct,st){(q!==Ie||de!==ct||ue!==st)&&(i.stencilOp(Ie,ct,st),q=Ie,de=ct,ue=st)},setLocked:function(Ie){M=Ie},setClear:function(Ie){Ge!==Ie&&(i.clearStencil(Ie),Ge=Ie)},reset:function(){M=!1,B=null,N=null,ee=null,ne=null,q=null,de=null,ue=null,Ge=null}}}const s=new t,a=new n,o=new r,c=new WeakMap,l=new WeakMap;let u={},m={},h={},d=new WeakMap,x=[],y=null,_=!1,f=null,w=null,C=null,S=null,R=null,b=null,P=null,g=new ze(0,0,0),T=0,U=!1,L=null,z=null,$=null,j=null,H=null;const Z=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let X=!1,te=0;const ie=i.getParameter(i.VERSION);ie.indexOf("WebGL")!==-1?(te=parseFloat(/^WebGL (\d)/.exec(ie)[1]),X=te>=1):ie.indexOf("OpenGL ES")!==-1&&(te=parseFloat(/^OpenGL ES (\d)/.exec(ie)[1]),X=te>=2);let fe=null,me={};const Me=i.getParameter(i.SCISSOR_BOX),Xe=i.getParameter(i.VIEWPORT),rt=new dt().fromArray(Me),Ye=new dt().fromArray(Xe);function Q(M,B,N,ee){const ne=new Uint8Array(4),q=i.createTexture();i.bindTexture(M,q),i.texParameteri(M,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(M,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let de=0;de<N;de++)M===i.TEXTURE_3D||M===i.TEXTURE_2D_ARRAY?i.texImage3D(B,0,i.RGBA,1,1,ee,0,i.RGBA,i.UNSIGNED_BYTE,ne):i.texImage2D(B+de,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,ne);return q}const le={};le[i.TEXTURE_2D]=Q(i.TEXTURE_2D,i.TEXTURE_2D,1),le[i.TEXTURE_CUBE_MAP]=Q(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),le[i.TEXTURE_2D_ARRAY]=Q(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),le[i.TEXTURE_3D]=Q(i.TEXTURE_3D,i.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),re(i.DEPTH_TEST),a.setFunc(Ci),lt(!1),ht(ro),re(i.CULL_FACE),We(_n);function re(M){u[M]!==!0&&(i.enable(M),u[M]=!0)}function Pe(M){u[M]!==!1&&(i.disable(M),u[M]=!1)}function De(M,B){return h[M]!==B?(i.bindFramebuffer(M,B),h[M]=B,M===i.DRAW_FRAMEBUFFER&&(h[i.FRAMEBUFFER]=B),M===i.FRAMEBUFFER&&(h[i.DRAW_FRAMEBUFFER]=B),!0):!1}function Re(M,B){let N=x,ee=!1;if(M){N=d.get(B),N===void 0&&(N=[],d.set(B,N));const ne=M.textures;if(N.length!==ne.length||N[0]!==i.COLOR_ATTACHMENT0){for(let q=0,de=ne.length;q<de;q++)N[q]=i.COLOR_ATTACHMENT0+q;N.length=ne.length,ee=!0}}else N[0]!==i.BACK&&(N[0]=i.BACK,ee=!0);ee&&i.drawBuffers(N)}function ot(M){return y!==M?(i.useProgram(M),y=M,!0):!1}const Fe={[Kn]:i.FUNC_ADD,[Ac]:i.FUNC_SUBTRACT,[Rc]:i.FUNC_REVERSE_SUBTRACT};Fe[wc]=i.MIN,Fe[Cc]=i.MAX;const Ze={[Pc]:i.ZERO,[Dc]:i.ONE,[Lc]:i.SRC_COLOR,[Gs]:i.SRC_ALPHA,[Bc]:i.SRC_ALPHA_SATURATE,[Fc]:i.DST_COLOR,[Uc]:i.DST_ALPHA,[Ic]:i.ONE_MINUS_SRC_COLOR,[Vs]:i.ONE_MINUS_SRC_ALPHA,[Oc]:i.ONE_MINUS_DST_COLOR,[Nc]:i.ONE_MINUS_DST_ALPHA,[zc]:i.CONSTANT_COLOR,[Gc]:i.ONE_MINUS_CONSTANT_COLOR,[Vc]:i.CONSTANT_ALPHA,[Hc]:i.ONE_MINUS_CONSTANT_ALPHA};function We(M,B,N,ee,ne,q,de,ue,Ge,Ie){if(M===_n){_===!0&&(Pe(i.BLEND),_=!1);return}if(_===!1&&(re(i.BLEND),_=!0),M!==Tc){if(M!==f||Ie!==U){if((w!==Kn||R!==Kn)&&(i.blendEquation(i.FUNC_ADD),w=Kn,R=Kn),Ie)switch(M){case On:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case so:i.blendFunc(i.ONE,i.ONE);break;case ao:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case oo:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:He("WebGLState: Invalid blending: ",M);break}else switch(M){case On:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case so:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case ao:He("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case oo:He("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:He("WebGLState: Invalid blending: ",M);break}C=null,S=null,b=null,P=null,g.set(0,0,0),T=0,f=M,U=Ie}return}ne=ne||B,q=q||N,de=de||ee,(B!==w||ne!==R)&&(i.blendEquationSeparate(Fe[B],Fe[ne]),w=B,R=ne),(N!==C||ee!==S||q!==b||de!==P)&&(i.blendFuncSeparate(Ze[N],Ze[ee],Ze[q],Ze[de]),C=N,S=ee,b=q,P=de),(ue.equals(g)===!1||Ge!==T)&&(i.blendColor(ue.r,ue.g,ue.b,Ge),g.copy(ue),T=Ge),f=M,U=!1}function Ve(M,B){M.side===pn?Pe(i.CULL_FACE):re(i.CULL_FACE);let N=M.side===Nt;B&&(N=!N),lt(N),M.blending===On&&M.transparent===!1?We(_n):We(M.blending,M.blendEquation,M.blendSrc,M.blendDst,M.blendEquationAlpha,M.blendSrcAlpha,M.blendDstAlpha,M.blendColor,M.blendAlpha,M.premultipliedAlpha),a.setFunc(M.depthFunc),a.setTest(M.depthTest),a.setMask(M.depthWrite),s.setMask(M.colorWrite);const ee=M.stencilWrite;o.setTest(ee),ee&&(o.setMask(M.stencilWriteMask),o.setFunc(M.stencilFunc,M.stencilRef,M.stencilFuncMask),o.setOp(M.stencilFail,M.stencilZFail,M.stencilZPass)),xt(M.polygonOffset,M.polygonOffsetFactor,M.polygonOffsetUnits),M.alphaToCoverage===!0?re(i.SAMPLE_ALPHA_TO_COVERAGE):Pe(i.SAMPLE_ALPHA_TO_COVERAGE)}function lt(M){L!==M&&(M?i.frontFace(i.CW):i.frontFace(i.CCW),L=M)}function ht(M){M!==Ec?(re(i.CULL_FACE),M!==z&&(M===ro?i.cullFace(i.BACK):M===yc?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):Pe(i.CULL_FACE),z=M}function _t(M){M!==$&&(X&&i.lineWidth(M),$=M)}function xt(M,B,N){M?(re(i.POLYGON_OFFSET_FILL),(j!==B||H!==N)&&(j=B,H=N,a.getReversed()&&(B=-B),i.polygonOffset(B,N))):Pe(i.POLYGON_OFFSET_FILL)}function it(M){M?re(i.SCISSOR_TEST):Pe(i.SCISSOR_TEST)}function ut(M){M===void 0&&(M=i.TEXTURE0+Z-1),fe!==M&&(i.activeTexture(M),fe=M)}function I(M,B,N){N===void 0&&(fe===null?N=i.TEXTURE0+Z-1:N=fe);let ee=me[N];ee===void 0&&(ee={type:void 0,texture:void 0},me[N]=ee),(ee.type!==M||ee.texture!==B)&&(fe!==N&&(i.activeTexture(N),fe=N),i.bindTexture(M,B||le[M]),ee.type=M,ee.texture=B)}function yt(){const M=me[fe];M!==void 0&&M.type!==void 0&&(i.bindTexture(M.type,null),M.type=void 0,M.texture=void 0)}function Ke(){try{i.compressedTexImage2D(...arguments)}catch(M){He("WebGLState:",M)}}function E(){try{i.compressedTexImage3D(...arguments)}catch(M){He("WebGLState:",M)}}function p(){try{i.texSubImage2D(...arguments)}catch(M){He("WebGLState:",M)}}function O(){try{i.texSubImage3D(...arguments)}catch(M){He("WebGLState:",M)}}function k(){try{i.compressedTexSubImage2D(...arguments)}catch(M){He("WebGLState:",M)}}function Y(){try{i.compressedTexSubImage3D(...arguments)}catch(M){He("WebGLState:",M)}}function se(){try{i.texStorage2D(...arguments)}catch(M){He("WebGLState:",M)}}function ae(){try{i.texStorage3D(...arguments)}catch(M){He("WebGLState:",M)}}function K(){try{i.texImage2D(...arguments)}catch(M){He("WebGLState:",M)}}function J(){try{i.texImage3D(...arguments)}catch(M){He("WebGLState:",M)}}function oe(M){return m[M]!==void 0?m[M]:i.getParameter(M)}function Se(M,B){m[M]!==B&&(i.pixelStorei(M,B),m[M]=B)}function he(M){rt.equals(M)===!1&&(i.scissor(M.x,M.y,M.z,M.w),rt.copy(M))}function ce(M){Ye.equals(M)===!1&&(i.viewport(M.x,M.y,M.z,M.w),Ye.copy(M))}function ye(M,B){let N=l.get(B);N===void 0&&(N=new WeakMap,l.set(B,N));let ee=N.get(M);ee===void 0&&(ee=i.getUniformBlockIndex(B,M.name),N.set(M,ee))}function be(M,B){const ee=l.get(B).get(M);c.get(B)!==ee&&(i.uniformBlockBinding(B,ee,M.__bindingPointIndex),c.set(B,ee))}function A(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),a.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),i.pixelStorei(i.PACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.BROWSER_DEFAULT_WEBGL),i.pixelStorei(i.PACK_ROW_LENGTH,0),i.pixelStorei(i.PACK_SKIP_PIXELS,0),i.pixelStorei(i.PACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_ROW_LENGTH,0),i.pixelStorei(i.UNPACK_IMAGE_HEIGHT,0),i.pixelStorei(i.UNPACK_SKIP_PIXELS,0),i.pixelStorei(i.UNPACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_SKIP_IMAGES,0),u={},m={},fe=null,me={},h={},d=new WeakMap,x=[],y=null,_=!1,f=null,w=null,C=null,S=null,R=null,b=null,P=null,g=new ze(0,0,0),T=0,U=!1,L=null,z=null,$=null,j=null,H=null,rt.set(0,0,i.canvas.width,i.canvas.height),Ye.set(0,0,i.canvas.width,i.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:re,disable:Pe,bindFramebuffer:De,drawBuffers:Re,useProgram:ot,setBlending:We,setMaterial:Ve,setFlipSided:lt,setCullFace:ht,setLineWidth:_t,setPolygonOffset:xt,setScissorTest:it,activeTexture:ut,bindTexture:I,unbindTexture:yt,compressedTexImage2D:Ke,compressedTexImage3D:E,texImage2D:K,texImage3D:J,pixelStorei:Se,getParameter:oe,updateUBOMapping:ye,uniformBlockBinding:be,texStorage2D:se,texStorage3D:ae,texSubImage2D:p,texSubImage3D:O,compressedTexSubImage2D:k,compressedTexSubImage3D:Y,scissor:he,viewport:ce,reset:A}}function Fm(i,e,t,n,r,s,a){const o=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 Ce,u=new WeakMap,m=new Set;let h;const d=new WeakMap;let x=!1;try{x=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function y(E,p){return x?new OffscreenCanvas(E,p):Gr("canvas")}function _(E,p,O){let k=1;const Y=Ke(E);if((Y.width>O||Y.height>O)&&(k=O/Math.max(Y.width,Y.height)),k<1)if(typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&E instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&E instanceof ImageBitmap||typeof VideoFrame<"u"&&E instanceof VideoFrame){const se=Math.floor(k*Y.width),ae=Math.floor(k*Y.height);h===void 0&&(h=y(se,ae));const K=p?y(se,ae):h;return K.width=se,K.height=ae,K.getContext("2d").drawImage(E,0,0,se,ae),we("WebGLRenderer: Texture has been resized from ("+Y.width+"x"+Y.height+") to ("+se+"x"+ae+")."),K}else return"data"in E&&we("WebGLRenderer: Image in DataTexture is too big ("+Y.width+"x"+Y.height+")."),E;return E}function f(E){return E.generateMipmaps}function w(E){i.generateMipmap(E)}function C(E){return E.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:E.isWebGL3DRenderTarget?i.TEXTURE_3D:E.isWebGLArrayRenderTarget||E.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function S(E,p,O,k,Y,se=!1){if(E!==null){if(i[E]!==void 0)return i[E];we("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+E+"'")}let ae;k&&(ae=e.get("EXT_texture_norm16"),ae||we("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let K=p;if(p===i.RED&&(O===i.FLOAT&&(K=i.R32F),O===i.HALF_FLOAT&&(K=i.R16F),O===i.UNSIGNED_BYTE&&(K=i.R8),O===i.UNSIGNED_SHORT&&ae&&(K=ae.R16_EXT),O===i.SHORT&&ae&&(K=ae.R16_SNORM_EXT)),p===i.RED_INTEGER&&(O===i.UNSIGNED_BYTE&&(K=i.R8UI),O===i.UNSIGNED_SHORT&&(K=i.R16UI),O===i.UNSIGNED_INT&&(K=i.R32UI),O===i.BYTE&&(K=i.R8I),O===i.SHORT&&(K=i.R16I),O===i.INT&&(K=i.R32I)),p===i.RG&&(O===i.FLOAT&&(K=i.RG32F),O===i.HALF_FLOAT&&(K=i.RG16F),O===i.UNSIGNED_BYTE&&(K=i.RG8),O===i.UNSIGNED_SHORT&&ae&&(K=ae.RG16_EXT),O===i.SHORT&&ae&&(K=ae.RG16_SNORM_EXT)),p===i.RG_INTEGER&&(O===i.UNSIGNED_BYTE&&(K=i.RG8UI),O===i.UNSIGNED_SHORT&&(K=i.RG16UI),O===i.UNSIGNED_INT&&(K=i.RG32UI),O===i.BYTE&&(K=i.RG8I),O===i.SHORT&&(K=i.RG16I),O===i.INT&&(K=i.RG32I)),p===i.RGB_INTEGER&&(O===i.UNSIGNED_BYTE&&(K=i.RGB8UI),O===i.UNSIGNED_SHORT&&(K=i.RGB16UI),O===i.UNSIGNED_INT&&(K=i.RGB32UI),O===i.BYTE&&(K=i.RGB8I),O===i.SHORT&&(K=i.RGB16I),O===i.INT&&(K=i.RGB32I)),p===i.RGBA_INTEGER&&(O===i.UNSIGNED_BYTE&&(K=i.RGBA8UI),O===i.UNSIGNED_SHORT&&(K=i.RGBA16UI),O===i.UNSIGNED_INT&&(K=i.RGBA32UI),O===i.BYTE&&(K=i.RGBA8I),O===i.SHORT&&(K=i.RGBA16I),O===i.INT&&(K=i.RGBA32I)),p===i.RGB&&(O===i.UNSIGNED_SHORT&&ae&&(K=ae.RGB16_EXT),O===i.SHORT&&ae&&(K=ae.RGB16_SNORM_EXT),O===i.UNSIGNED_INT_5_9_9_9_REV&&(K=i.RGB9_E5),O===i.UNSIGNED_INT_10F_11F_11F_REV&&(K=i.R11F_G11F_B10F)),p===i.RGBA){const J=se?Br:ke.getTransfer(Y);O===i.FLOAT&&(K=i.RGBA32F),O===i.HALF_FLOAT&&(K=i.RGBA16F),O===i.UNSIGNED_BYTE&&(K=J===$e?i.SRGB8_ALPHA8:i.RGBA8),O===i.UNSIGNED_SHORT&&ae&&(K=ae.RGBA16_EXT),O===i.SHORT&&ae&&(K=ae.RGBA16_SNORM_EXT),O===i.UNSIGNED_SHORT_4_4_4_4&&(K=i.RGBA4),O===i.UNSIGNED_SHORT_5_5_5_1&&(K=i.RGB5_A1)}return(K===i.R16F||K===i.R32F||K===i.RG16F||K===i.RG32F||K===i.RGBA16F||K===i.RGBA32F)&&e.get("EXT_color_buffer_float"),K}function R(E,p){let O;return E?p===null||p===on||p===Ki?O=i.DEPTH24_STENCIL8:p===nn?O=i.DEPTH32F_STENCIL8:p===qi&&(O=i.DEPTH24_STENCIL8,we("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):p===null||p===on||p===Ki?O=i.DEPTH_COMPONENT24:p===nn?O=i.DEPTH_COMPONENT32F:p===qi&&(O=i.DEPTH_COMPONENT16),O}function b(E,p){return f(E)===!0||E.isFramebufferTexture&&E.minFilter!==bt&&E.minFilter!==wt?Math.log2(Math.max(p.width,p.height))+1:E.mipmaps!==void 0&&E.mipmaps.length>0?E.mipmaps.length:E.isCompressedTexture&&Array.isArray(E.image)?p.mipmaps.length:1}function P(E){const p=E.target;p.removeEventListener("dispose",P),T(p),p.isVideoTexture&&u.delete(p),p.isHTMLTexture&&m.delete(p)}function g(E){const p=E.target;p.removeEventListener("dispose",g),L(p)}function T(E){const p=n.get(E);if(p.__webglInit===void 0)return;const O=E.source,k=d.get(O);if(k){const Y=k[p.__cacheKey];Y.usedTimes--,Y.usedTimes===0&&U(E),Object.keys(k).length===0&&d.delete(O)}n.remove(E)}function U(E){const p=n.get(E);i.deleteTexture(p.__webglTexture);const O=E.source,k=d.get(O);delete k[p.__cacheKey],a.memory.textures--}function L(E){const p=n.get(E);if(E.depthTexture&&(E.depthTexture.dispose(),n.remove(E.depthTexture)),E.isWebGLCubeRenderTarget)for(let k=0;k<6;k++){if(Array.isArray(p.__webglFramebuffer[k]))for(let Y=0;Y<p.__webglFramebuffer[k].length;Y++)i.deleteFramebuffer(p.__webglFramebuffer[k][Y]);else i.deleteFramebuffer(p.__webglFramebuffer[k]);p.__webglDepthbuffer&&i.deleteRenderbuffer(p.__webglDepthbuffer[k])}else{if(Array.isArray(p.__webglFramebuffer))for(let k=0;k<p.__webglFramebuffer.length;k++)i.deleteFramebuffer(p.__webglFramebuffer[k]);else i.deleteFramebuffer(p.__webglFramebuffer);if(p.__webglDepthbuffer&&i.deleteRenderbuffer(p.__webglDepthbuffer),p.__webglMultisampledFramebuffer&&i.deleteFramebuffer(p.__webglMultisampledFramebuffer),p.__webglColorRenderbuffer)for(let k=0;k<p.__webglColorRenderbuffer.length;k++)p.__webglColorRenderbuffer[k]&&i.deleteRenderbuffer(p.__webglColorRenderbuffer[k]);p.__webglDepthRenderbuffer&&i.deleteRenderbuffer(p.__webglDepthRenderbuffer)}const O=E.textures;for(let k=0,Y=O.length;k<Y;k++){const se=n.get(O[k]);se.__webglTexture&&(i.deleteTexture(se.__webglTexture),a.memory.textures--),n.remove(O[k])}n.remove(E)}let z=0;function $(){z=0}function j(){return z}function H(E){z=E}function Z(){const E=z;return E>=r.maxTextures&&we("WebGLTextures: Trying to use "+E+" texture units while this GPU supports only "+r.maxTextures),z+=1,E}function X(E){const p=[];return p.push(E.wrapS),p.push(E.wrapT),p.push(E.wrapR||0),p.push(E.magFilter),p.push(E.minFilter),p.push(E.anisotropy),p.push(E.internalFormat),p.push(E.format),p.push(E.type),p.push(E.generateMipmaps),p.push(E.premultiplyAlpha),p.push(E.flipY),p.push(E.unpackAlignment),p.push(E.colorSpace),p.join()}function te(E,p){const O=n.get(E);if(E.isVideoTexture&&I(E),E.isRenderTargetTexture===!1&&E.isExternalTexture!==!0&&E.version>0&&O.__version!==E.version){const k=E.image;if(k===null)we("WebGLRenderer: Texture marked for update but no image data found.");else if(k.complete===!1)we("WebGLRenderer: Texture marked for update but image is incomplete");else{Pe(O,E,p);return}}else E.isExternalTexture&&(O.__webglTexture=E.sourceTexture?E.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,O.__webglTexture,i.TEXTURE0+p)}function ie(E,p){const O=n.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&O.__version!==E.version){Pe(O,E,p);return}else E.isExternalTexture&&(O.__webglTexture=E.sourceTexture?E.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,O.__webglTexture,i.TEXTURE0+p)}function fe(E,p){const O=n.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&O.__version!==E.version){Pe(O,E,p);return}t.bindTexture(i.TEXTURE_3D,O.__webglTexture,i.TEXTURE0+p)}function me(E,p){const O=n.get(E);if(E.isCubeDepthTexture!==!0&&E.version>0&&O.__version!==E.version){De(O,E,p);return}t.bindTexture(i.TEXTURE_CUBE_MAP,O.__webglTexture,i.TEXTURE0+p)}const Me={[Zs]:i.REPEAT,[mn]:i.CLAMP_TO_EDGE,[$s]:i.MIRRORED_REPEAT},Xe={[bt]:i.NEAREST,[Xc]:i.NEAREST_MIPMAP_NEAREST,[er]:i.NEAREST_MIPMAP_LINEAR,[wt]:i.LINEAR,[ss]:i.LINEAR_MIPMAP_NEAREST,[$n]:i.LINEAR_MIPMAP_LINEAR},rt={[Kc]:i.NEVER,[jc]:i.ALWAYS,[Zc]:i.LESS,[Ga]:i.LEQUAL,[$c]:i.EQUAL,[Va]:i.GEQUAL,[Jc]:i.GREATER,[Qc]:i.NOTEQUAL};function Ye(E,p){if(p.type===nn&&e.has("OES_texture_float_linear")===!1&&(p.magFilter===wt||p.magFilter===ss||p.magFilter===er||p.magFilter===$n||p.minFilter===wt||p.minFilter===ss||p.minFilter===er||p.minFilter===$n)&&we("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(E,i.TEXTURE_WRAP_S,Me[p.wrapS]),i.texParameteri(E,i.TEXTURE_WRAP_T,Me[p.wrapT]),(E===i.TEXTURE_3D||E===i.TEXTURE_2D_ARRAY)&&i.texParameteri(E,i.TEXTURE_WRAP_R,Me[p.wrapR]),i.texParameteri(E,i.TEXTURE_MAG_FILTER,Xe[p.magFilter]),i.texParameteri(E,i.TEXTURE_MIN_FILTER,Xe[p.minFilter]),p.compareFunction&&(i.texParameteri(E,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(E,i.TEXTURE_COMPARE_FUNC,rt[p.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(p.magFilter===bt||p.minFilter!==er&&p.minFilter!==$n||p.type===nn&&e.has("OES_texture_float_linear")===!1)return;if(p.anisotropy>1||n.get(p).__currentAnisotropy){const O=e.get("EXT_texture_filter_anisotropic");i.texParameterf(E,O.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(p.anisotropy,r.getMaxAnisotropy())),n.get(p).__currentAnisotropy=p.anisotropy}}}function Q(E,p){let O=!1;E.__webglInit===void 0&&(E.__webglInit=!0,p.addEventListener("dispose",P));const k=p.source;let Y=d.get(k);Y===void 0&&(Y={},d.set(k,Y));const se=X(p);if(se!==E.__cacheKey){Y[se]===void 0&&(Y[se]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,O=!0),Y[se].usedTimes++;const ae=Y[E.__cacheKey];ae!==void 0&&(Y[E.__cacheKey].usedTimes--,ae.usedTimes===0&&U(p)),E.__cacheKey=se,E.__webglTexture=Y[se].texture}return O}function le(E,p,O){return Math.floor(Math.floor(E/O)/p)}function re(E,p,O,k){const se=E.updateRanges;if(se.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,p.width,p.height,O,k,p.data);else{se.sort((Se,he)=>Se.start-he.start);let ae=0;for(let Se=1;Se<se.length;Se++){const he=se[ae],ce=se[Se],ye=he.start+he.count,be=le(ce.start,p.width,4),A=le(he.start,p.width,4);ce.start<=ye+1&&be===A&&le(ce.start+ce.count-1,p.width,4)===be?he.count=Math.max(he.count,ce.start+ce.count-he.start):(++ae,se[ae]=ce)}se.length=ae+1;const K=t.getParameter(i.UNPACK_ROW_LENGTH),J=t.getParameter(i.UNPACK_SKIP_PIXELS),oe=t.getParameter(i.UNPACK_SKIP_ROWS);t.pixelStorei(i.UNPACK_ROW_LENGTH,p.width);for(let Se=0,he=se.length;Se<he;Se++){const ce=se[Se],ye=Math.floor(ce.start/4),be=Math.ceil(ce.count/4),A=ye%p.width,M=Math.floor(ye/p.width),B=be,N=1;t.pixelStorei(i.UNPACK_SKIP_PIXELS,A),t.pixelStorei(i.UNPACK_SKIP_ROWS,M),t.texSubImage2D(i.TEXTURE_2D,0,A,M,B,N,O,k,p.data)}E.clearUpdateRanges(),t.pixelStorei(i.UNPACK_ROW_LENGTH,K),t.pixelStorei(i.UNPACK_SKIP_PIXELS,J),t.pixelStorei(i.UNPACK_SKIP_ROWS,oe)}}function Pe(E,p,O){let k=i.TEXTURE_2D;(p.isDataArrayTexture||p.isCompressedArrayTexture)&&(k=i.TEXTURE_2D_ARRAY),p.isData3DTexture&&(k=i.TEXTURE_3D);const Y=Q(E,p),se=p.source;t.bindTexture(k,E.__webglTexture,i.TEXTURE0+O);const ae=n.get(se);if(se.version!==ae.__version||Y===!0){if(t.activeTexture(i.TEXTURE0+O),(typeof ImageBitmap<"u"&&p.image instanceof ImageBitmap)===!1){const N=ke.getPrimaries(ke.workingColorSpace),ee=p.colorSpace===In?null:ke.getPrimaries(p.colorSpace),ne=p.colorSpace===In||N===ee?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,p.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,p.premultiplyAlpha),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,ne)}t.pixelStorei(i.UNPACK_ALIGNMENT,p.unpackAlignment);let J=_(p.image,!1,r.maxTextureSize);J=yt(p,J);const oe=s.convert(p.format,p.colorSpace),Se=s.convert(p.type);let he=S(p.internalFormat,oe,Se,p.normalized,p.colorSpace,p.isVideoTexture);Ye(k,p);let ce;const ye=p.mipmaps,be=p.isVideoTexture!==!0,A=ae.__version===void 0||Y===!0,M=se.dataReady,B=b(p,J);if(p.isDepthTexture)he=R(p.format===Jn,p.type),A&&(be?t.texStorage2D(i.TEXTURE_2D,1,he,J.width,J.height):t.texImage2D(i.TEXTURE_2D,0,he,J.width,J.height,0,oe,Se,null));else if(p.isDataTexture)if(ye.length>0){be&&A&&t.texStorage2D(i.TEXTURE_2D,B,he,ye[0].width,ye[0].height);for(let N=0,ee=ye.length;N<ee;N++)ce=ye[N],be?M&&t.texSubImage2D(i.TEXTURE_2D,N,0,0,ce.width,ce.height,oe,Se,ce.data):t.texImage2D(i.TEXTURE_2D,N,he,ce.width,ce.height,0,oe,Se,ce.data);p.generateMipmaps=!1}else be?(A&&t.texStorage2D(i.TEXTURE_2D,B,he,J.width,J.height),M&&re(p,J,oe,Se)):t.texImage2D(i.TEXTURE_2D,0,he,J.width,J.height,0,oe,Se,J.data);else if(p.isCompressedTexture)if(p.isCompressedArrayTexture){be&&A&&t.texStorage3D(i.TEXTURE_2D_ARRAY,B,he,ye[0].width,ye[0].height,J.depth);for(let N=0,ee=ye.length;N<ee;N++)if(ce=ye[N],p.format!==Zt)if(oe!==null)if(be){if(M)if(p.layerUpdates.size>0){const ne=Go(ce.width,ce.height,p.format,p.type);for(const q of p.layerUpdates){const de=ce.data.subarray(q*ne/ce.data.BYTES_PER_ELEMENT,(q+1)*ne/ce.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,N,0,0,q,ce.width,ce.height,1,oe,de)}p.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,N,0,0,0,ce.width,ce.height,J.depth,oe,ce.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,N,he,ce.width,ce.height,J.depth,0,ce.data,0,0);else we("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else be?M&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,N,0,0,0,ce.width,ce.height,J.depth,oe,Se,ce.data):t.texImage3D(i.TEXTURE_2D_ARRAY,N,he,ce.width,ce.height,J.depth,0,oe,Se,ce.data)}else{be&&A&&t.texStorage2D(i.TEXTURE_2D,B,he,ye[0].width,ye[0].height);for(let N=0,ee=ye.length;N<ee;N++)ce=ye[N],p.format!==Zt?oe!==null?be?M&&t.compressedTexSubImage2D(i.TEXTURE_2D,N,0,0,ce.width,ce.height,oe,ce.data):t.compressedTexImage2D(i.TEXTURE_2D,N,he,ce.width,ce.height,0,ce.data):we("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):be?M&&t.texSubImage2D(i.TEXTURE_2D,N,0,0,ce.width,ce.height,oe,Se,ce.data):t.texImage2D(i.TEXTURE_2D,N,he,ce.width,ce.height,0,oe,Se,ce.data)}else if(p.isDataArrayTexture)if(be){if(A&&t.texStorage3D(i.TEXTURE_2D_ARRAY,B,he,J.width,J.height,J.depth),M)if(p.layerUpdates.size>0){const N=Go(J.width,J.height,p.format,p.type);for(const ee of p.layerUpdates){const ne=J.data.subarray(ee*N/J.data.BYTES_PER_ELEMENT,(ee+1)*N/J.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,ee,J.width,J.height,1,oe,Se,ne)}p.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,J.width,J.height,J.depth,oe,Se,J.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,he,J.width,J.height,J.depth,0,oe,Se,J.data);else if(p.isData3DTexture)be?(A&&t.texStorage3D(i.TEXTURE_3D,B,he,J.width,J.height,J.depth),M&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,J.width,J.height,J.depth,oe,Se,J.data)):t.texImage3D(i.TEXTURE_3D,0,he,J.width,J.height,J.depth,0,oe,Se,J.data);else if(p.isFramebufferTexture){if(A)if(be)t.texStorage2D(i.TEXTURE_2D,B,he,J.width,J.height);else{let N=J.width,ee=J.height;for(let ne=0;ne<B;ne++)t.texImage2D(i.TEXTURE_2D,ne,he,N,ee,0,oe,Se,null),N>>=1,ee>>=1}}else if(p.isHTMLTexture){if("texElementImage2D"in i){const N=i.canvas;if(N.hasAttribute("layoutsubtree")||N.setAttribute("layoutsubtree","true"),J.parentNode!==N){N.appendChild(J),m.add(p),N.onpaint=ee=>{const ne=ee.changedElements;for(const q of m)ne.includes(q.image)&&(q.needsUpdate=!0)},N.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,J);else{const ne=i.RGBA,q=i.RGBA,de=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,ne,q,de,J)}i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE)}}else if(ye.length>0){if(be&&A){const N=Ke(ye[0]);t.texStorage2D(i.TEXTURE_2D,B,he,N.width,N.height)}for(let N=0,ee=ye.length;N<ee;N++)ce=ye[N],be?M&&t.texSubImage2D(i.TEXTURE_2D,N,0,0,oe,Se,ce):t.texImage2D(i.TEXTURE_2D,N,he,oe,Se,ce);p.generateMipmaps=!1}else if(be){if(A){const N=Ke(J);t.texStorage2D(i.TEXTURE_2D,B,he,N.width,N.height)}M&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,oe,Se,J)}else t.texImage2D(i.TEXTURE_2D,0,he,oe,Se,J);f(p)&&w(k),ae.__version=se.version,p.onUpdate&&p.onUpdate(p)}E.__version=p.version}function De(E,p,O){if(p.image.length!==6)return;const k=Q(E,p),Y=p.source;t.bindTexture(i.TEXTURE_CUBE_MAP,E.__webglTexture,i.TEXTURE0+O);const se=n.get(Y);if(Y.version!==se.__version||k===!0){t.activeTexture(i.TEXTURE0+O);const ae=ke.getPrimaries(ke.workingColorSpace),K=p.colorSpace===In?null:ke.getPrimaries(p.colorSpace),J=p.colorSpace===In||ae===K?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,p.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,p.premultiplyAlpha),t.pixelStorei(i.UNPACK_ALIGNMENT,p.unpackAlignment),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,J);const oe=p.isCompressedTexture||p.image[0].isCompressedTexture,Se=p.image[0]&&p.image[0].isDataTexture,he=[];for(let q=0;q<6;q++)!oe&&!Se?he[q]=_(p.image[q],!0,r.maxCubemapSize):he[q]=Se?p.image[q].image:p.image[q],he[q]=yt(p,he[q]);const ce=he[0],ye=s.convert(p.format,p.colorSpace),be=s.convert(p.type),A=S(p.internalFormat,ye,be,p.normalized,p.colorSpace),M=p.isVideoTexture!==!0,B=se.__version===void 0||k===!0,N=Y.dataReady;let ee=b(p,ce);Ye(i.TEXTURE_CUBE_MAP,p);let ne;if(oe){M&&B&&t.texStorage2D(i.TEXTURE_CUBE_MAP,ee,A,ce.width,ce.height);for(let q=0;q<6;q++){ne=he[q].mipmaps;for(let de=0;de<ne.length;de++){const ue=ne[de];p.format!==Zt?ye!==null?M?N&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,de,0,0,ue.width,ue.height,ye,ue.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,de,A,ue.width,ue.height,0,ue.data):we("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):M?N&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,de,0,0,ue.width,ue.height,ye,be,ue.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,de,A,ue.width,ue.height,0,ye,be,ue.data)}}}else{if(ne=p.mipmaps,M&&B){ne.length>0&&ee++;const q=Ke(he[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,ee,A,q.width,q.height)}for(let q=0;q<6;q++)if(Se){M?N&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,0,0,0,he[q].width,he[q].height,ye,be,he[q].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,0,A,he[q].width,he[q].height,0,ye,be,he[q].data);for(let de=0;de<ne.length;de++){const Ge=ne[de].image[q].image;M?N&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,de+1,0,0,Ge.width,Ge.height,ye,be,Ge.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,de+1,A,Ge.width,Ge.height,0,ye,be,Ge.data)}}else{M?N&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,0,0,0,ye,be,he[q]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,0,A,ye,be,he[q]);for(let de=0;de<ne.length;de++){const ue=ne[de];M?N&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,de+1,0,0,ye,be,ue.image[q]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,de+1,A,ye,be,ue.image[q])}}}f(p)&&w(i.TEXTURE_CUBE_MAP),se.__version=Y.version,p.onUpdate&&p.onUpdate(p)}E.__version=p.version}function Re(E,p,O,k,Y,se){const ae=s.convert(O.format,O.colorSpace),K=s.convert(O.type),J=S(O.internalFormat,ae,K,O.normalized,O.colorSpace),oe=n.get(p),Se=n.get(O);if(Se.__renderTarget=p,!oe.__hasExternalTextures){const he=Math.max(1,p.width>>se),ce=Math.max(1,p.height>>se);Y===i.TEXTURE_3D||Y===i.TEXTURE_2D_ARRAY?t.texImage3D(Y,se,J,he,ce,p.depth,0,ae,K,null):t.texImage2D(Y,se,J,he,ce,0,ae,K,null)}t.bindFramebuffer(i.FRAMEBUFFER,E),ut(p)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,k,Y,Se.__webglTexture,0,it(p)):(Y===i.TEXTURE_2D||Y>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&Y<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,k,Y,Se.__webglTexture,se),t.bindFramebuffer(i.FRAMEBUFFER,null)}function ot(E,p,O){if(i.bindRenderbuffer(i.RENDERBUFFER,E),p.depthBuffer){const k=p.depthTexture,Y=k&&k.isDepthTexture?k.type:null,se=R(p.stencilBuffer,Y),ae=p.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;ut(p)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,it(p),se,p.width,p.height):O?i.renderbufferStorageMultisample(i.RENDERBUFFER,it(p),se,p.width,p.height):i.renderbufferStorage(i.RENDERBUFFER,se,p.width,p.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,ae,i.RENDERBUFFER,E)}else{const k=p.textures;for(let Y=0;Y<k.length;Y++){const se=k[Y],ae=s.convert(se.format,se.colorSpace),K=s.convert(se.type),J=S(se.internalFormat,ae,K,se.normalized,se.colorSpace);ut(p)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,it(p),J,p.width,p.height):O?i.renderbufferStorageMultisample(i.RENDERBUFFER,it(p),J,p.width,p.height):i.renderbufferStorage(i.RENDERBUFFER,J,p.width,p.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function Fe(E,p,O){const k=p.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(i.FRAMEBUFFER,E),!(p.depthTexture&&p.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const Y=n.get(p.depthTexture);if(Y.__renderTarget=p,(!Y.__webglTexture||p.depthTexture.image.width!==p.width||p.depthTexture.image.height!==p.height)&&(p.depthTexture.image.width=p.width,p.depthTexture.image.height=p.height,p.depthTexture.needsUpdate=!0),k){if(Y.__webglInit===void 0&&(Y.__webglInit=!0,p.depthTexture.addEventListener("dispose",P)),Y.__webglTexture===void 0){Y.__webglTexture=i.createTexture(),t.bindTexture(i.TEXTURE_CUBE_MAP,Y.__webglTexture),Ye(i.TEXTURE_CUBE_MAP,p.depthTexture);const oe=s.convert(p.depthTexture.format),Se=s.convert(p.depthTexture.type);let he;p.depthTexture.format===vn?he=i.DEPTH_COMPONENT24:p.depthTexture.format===Jn&&(he=i.DEPTH24_STENCIL8);for(let ce=0;ce<6;ce++)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,he,p.width,p.height,0,oe,Se,null)}}else te(p.depthTexture,0);const se=Y.__webglTexture,ae=it(p),K=k?i.TEXTURE_CUBE_MAP_POSITIVE_X+O:i.TEXTURE_2D,J=p.depthTexture.format===Jn?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;if(p.depthTexture.format===vn)ut(p)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,J,K,se,0,ae):i.framebufferTexture2D(i.FRAMEBUFFER,J,K,se,0);else if(p.depthTexture.format===Jn)ut(p)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,J,K,se,0,ae):i.framebufferTexture2D(i.FRAMEBUFFER,J,K,se,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ze(E){const p=n.get(E),O=E.isWebGLCubeRenderTarget===!0;if(p.__boundDepthTexture!==E.depthTexture){const k=E.depthTexture;if(p.__depthDisposeCallback&&p.__depthDisposeCallback(),k){const Y=()=>{delete p.__boundDepthTexture,delete p.__depthDisposeCallback,k.removeEventListener("dispose",Y)};k.addEventListener("dispose",Y),p.__depthDisposeCallback=Y}p.__boundDepthTexture=k}if(E.depthTexture&&!p.__autoAllocateDepthBuffer)if(O)for(let k=0;k<6;k++)Fe(p.__webglFramebuffer[k],E,k);else{const k=E.texture.mipmaps;k&&k.length>0?Fe(p.__webglFramebuffer[0],E,0):Fe(p.__webglFramebuffer,E,0)}else if(O){p.__webglDepthbuffer=[];for(let k=0;k<6;k++)if(t.bindFramebuffer(i.FRAMEBUFFER,p.__webglFramebuffer[k]),p.__webglDepthbuffer[k]===void 0)p.__webglDepthbuffer[k]=i.createRenderbuffer(),ot(p.__webglDepthbuffer[k],E,!1);else{const Y=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,se=p.__webglDepthbuffer[k];i.bindRenderbuffer(i.RENDERBUFFER,se),i.framebufferRenderbuffer(i.FRAMEBUFFER,Y,i.RENDERBUFFER,se)}}else{const k=E.texture.mipmaps;if(k&&k.length>0?t.bindFramebuffer(i.FRAMEBUFFER,p.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,p.__webglFramebuffer),p.__webglDepthbuffer===void 0)p.__webglDepthbuffer=i.createRenderbuffer(),ot(p.__webglDepthbuffer,E,!1);else{const Y=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,se=p.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,se),i.framebufferRenderbuffer(i.FRAMEBUFFER,Y,i.RENDERBUFFER,se)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function We(E,p,O){const k=n.get(E);p!==void 0&&Re(k.__webglFramebuffer,E,E.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),O!==void 0&&Ze(E)}function Ve(E){const p=E.texture,O=n.get(E),k=n.get(p);E.addEventListener("dispose",g);const Y=E.textures,se=E.isWebGLCubeRenderTarget===!0,ae=Y.length>1;if(ae||(k.__webglTexture===void 0&&(k.__webglTexture=i.createTexture()),k.__version=p.version,a.memory.textures++),se){O.__webglFramebuffer=[];for(let K=0;K<6;K++)if(p.mipmaps&&p.mipmaps.length>0){O.__webglFramebuffer[K]=[];for(let J=0;J<p.mipmaps.length;J++)O.__webglFramebuffer[K][J]=i.createFramebuffer()}else O.__webglFramebuffer[K]=i.createFramebuffer()}else{if(p.mipmaps&&p.mipmaps.length>0){O.__webglFramebuffer=[];for(let K=0;K<p.mipmaps.length;K++)O.__webglFramebuffer[K]=i.createFramebuffer()}else O.__webglFramebuffer=i.createFramebuffer();if(ae)for(let K=0,J=Y.length;K<J;K++){const oe=n.get(Y[K]);oe.__webglTexture===void 0&&(oe.__webglTexture=i.createTexture(),a.memory.textures++)}if(E.samples>0&&ut(E)===!1){O.__webglMultisampledFramebuffer=i.createFramebuffer(),O.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,O.__webglMultisampledFramebuffer);for(let K=0;K<Y.length;K++){const J=Y[K];O.__webglColorRenderbuffer[K]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,O.__webglColorRenderbuffer[K]);const oe=s.convert(J.format,J.colorSpace),Se=s.convert(J.type),he=S(J.internalFormat,oe,Se,J.normalized,J.colorSpace,E.isXRRenderTarget===!0),ce=it(E);i.renderbufferStorageMultisample(i.RENDERBUFFER,ce,he,E.width,E.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+K,i.RENDERBUFFER,O.__webglColorRenderbuffer[K])}i.bindRenderbuffer(i.RENDERBUFFER,null),E.depthBuffer&&(O.__webglDepthRenderbuffer=i.createRenderbuffer(),ot(O.__webglDepthRenderbuffer,E,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(se){t.bindTexture(i.TEXTURE_CUBE_MAP,k.__webglTexture),Ye(i.TEXTURE_CUBE_MAP,p);for(let K=0;K<6;K++)if(p.mipmaps&&p.mipmaps.length>0)for(let J=0;J<p.mipmaps.length;J++)Re(O.__webglFramebuffer[K][J],E,p,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+K,J);else Re(O.__webglFramebuffer[K],E,p,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+K,0);f(p)&&w(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(ae){for(let K=0,J=Y.length;K<J;K++){const oe=Y[K],Se=n.get(oe);let he=i.TEXTURE_2D;(E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)&&(he=E.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(he,Se.__webglTexture),Ye(he,oe),Re(O.__webglFramebuffer,E,oe,i.COLOR_ATTACHMENT0+K,he,0),f(oe)&&w(he)}t.unbindTexture()}else{let K=i.TEXTURE_2D;if((E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)&&(K=E.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(K,k.__webglTexture),Ye(K,p),p.mipmaps&&p.mipmaps.length>0)for(let J=0;J<p.mipmaps.length;J++)Re(O.__webglFramebuffer[J],E,p,i.COLOR_ATTACHMENT0,K,J);else Re(O.__webglFramebuffer,E,p,i.COLOR_ATTACHMENT0,K,0);f(p)&&w(K),t.unbindTexture()}E.depthBuffer&&Ze(E)}function lt(E){const p=E.textures;for(let O=0,k=p.length;O<k;O++){const Y=p[O];if(f(Y)){const se=C(E),ae=n.get(Y).__webglTexture;t.bindTexture(se,ae),w(se),t.unbindTexture()}}}const ht=[],_t=[];function xt(E){if(E.samples>0){if(ut(E)===!1){const p=E.textures,O=E.width,k=E.height;let Y=i.COLOR_BUFFER_BIT;const se=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ae=n.get(E),K=p.length>1;if(K)for(let oe=0;oe<p.length;oe++)t.bindFramebuffer(i.FRAMEBUFFER,ae.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+oe,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,ae.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+oe,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,ae.__webglMultisampledFramebuffer);const J=E.texture.mipmaps;J&&J.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ae.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ae.__webglFramebuffer);for(let oe=0;oe<p.length;oe++){if(E.resolveDepthBuffer&&(E.depthBuffer&&(Y|=i.DEPTH_BUFFER_BIT),E.stencilBuffer&&E.resolveStencilBuffer&&(Y|=i.STENCIL_BUFFER_BIT)),K){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,ae.__webglColorRenderbuffer[oe]);const Se=n.get(p[oe]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,Se,0)}i.blitFramebuffer(0,0,O,k,0,0,O,k,Y,i.NEAREST),c===!0&&(ht.length=0,_t.length=0,ht.push(i.COLOR_ATTACHMENT0+oe),E.depthBuffer&&E.resolveDepthBuffer===!1&&(ht.push(se),_t.push(se),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,_t)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,ht))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),K)for(let oe=0;oe<p.length;oe++){t.bindFramebuffer(i.FRAMEBUFFER,ae.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+oe,i.RENDERBUFFER,ae.__webglColorRenderbuffer[oe]);const Se=n.get(p[oe]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,ae.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+oe,i.TEXTURE_2D,Se,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ae.__webglMultisampledFramebuffer)}else if(E.depthBuffer&&E.resolveDepthBuffer===!1&&c){const p=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[p])}}}function it(E){return Math.min(r.maxSamples,E.samples)}function ut(E){const p=n.get(E);return E.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&p.__useRenderToTexture!==!1}function I(E){const p=a.render.frame;u.get(E)!==p&&(u.set(E,p),E.update())}function yt(E,p){const O=E.colorSpace,k=E.format,Y=E.type;return E.isCompressedTexture===!0||E.isVideoTexture===!0||O!==Or&&O!==In&&(ke.getTransfer(O)===$e?(k!==Zt||Y!==kt)&&we("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):He("WebGLTextures: Unsupported texture color space:",O)),p}function Ke(E){return typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement?(l.width=E.naturalWidth||E.width,l.height=E.naturalHeight||E.height):typeof VideoFrame<"u"&&E instanceof VideoFrame?(l.width=E.displayWidth,l.height=E.displayHeight):(l.width=E.width,l.height=E.height),l}this.allocateTextureUnit=Z,this.resetTextureUnits=$,this.getTextureUnits=j,this.setTextureUnits=H,this.setTexture2D=te,this.setTexture2DArray=ie,this.setTexture3D=fe,this.setTextureCube=me,this.rebindTextures=We,this.setupRenderTarget=Ve,this.updateRenderTargetMipmap=lt,this.updateMultisampleRenderTarget=xt,this.setupDepthRenderbuffer=Ze,this.setupFrameBufferTexture=Re,this.useMultisampledRTT=ut,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Om(i,e){function t(n,r=In){let s;const a=ke.getTransfer(r);if(n===kt)return i.UNSIGNED_BYTE;if(n===Na)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Fa)return i.UNSIGNED_SHORT_5_5_5_1;if(n===wl)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Cl)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===Al)return i.BYTE;if(n===Rl)return i.SHORT;if(n===qi)return i.UNSIGNED_SHORT;if(n===Ua)return i.INT;if(n===on)return i.UNSIGNED_INT;if(n===nn)return i.FLOAT;if(n===xn)return i.HALF_FLOAT;if(n===Pl)return i.ALPHA;if(n===Dl)return i.RGB;if(n===Zt)return i.RGBA;if(n===vn)return i.DEPTH_COMPONENT;if(n===Jn)return i.DEPTH_STENCIL;if(n===Ll)return i.RED;if(n===Oa)return i.RED_INTEGER;if(n===jn)return i.RG;if(n===Ba)return i.RG_INTEGER;if(n===za)return i.RGBA_INTEGER;if(n===Cr||n===Pr||n===Dr||n===Lr)if(a===$e)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===Cr)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Pr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Dr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Lr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===Cr)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Pr)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Dr)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Lr)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Js||n===Qs||n===js||n===ea)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===Js)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Qs)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===js)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===ea)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===ta||n===na||n===ia||n===ra||n===sa||n===Nr||n===aa)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(n===ta||n===na)return a===$e?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===ia)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(n===ra)return s.COMPRESSED_R11_EAC;if(n===sa)return s.COMPRESSED_SIGNED_R11_EAC;if(n===Nr)return s.COMPRESSED_RG11_EAC;if(n===aa)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===oa||n===la||n===ca||n===ha||n===ua||n===fa||n===da||n===pa||n===ma||n===_a||n===ga||n===xa||n===va||n===Ma)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(n===oa)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===la)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===ca)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===ha)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===ua)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===fa)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===da)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===pa)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===ma)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===_a)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===ga)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===xa)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===va)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Ma)return a===$e?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Sa||n===Ea||n===ya)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(n===Sa)return a===$e?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Ea)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===ya)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===ba||n===Ta||n===Fr||n===Aa)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(n===ba)return s.COMPRESSED_RED_RGTC1_EXT;if(n===Ta)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Fr)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Aa)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Ki?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const Bm=`
4085
4085
  void main() {
4086
4086
 
4087
4087
  gl_Position = vec4( position, 1.0 );
@@ -4105,4 +4105,4 @@ void main() {
4105
4105
 
4106
4106
  }
4107
4107
 
4108
- }`;class Gm{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new Wl(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new ln({vertexShader:Bm,fragmentShader:zm,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Mn(new Kr(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Vm extends Vn{constructor(e,t){super();const n=this;let r=null,s=1,a=null,o="local-floor",c=1,l=null,u=null,m=null,h=null,d=null,x=null;const y=typeof XRWebGLBinding<"u",_=new Gm,f={},w=t.getContextAttributes();let C=null,S=null;const R=[],b=[],P=new Ce;let g=null;const T=new Ht;T.viewport=new dt;const U=new Ht;U.viewport=new dt;const L=[T,U],z=new Kh;let $=null,j=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Q){let le=R[Q];return le===void 0&&(le=new fs,R[Q]=le),le.getTargetRaySpace()},this.getControllerGrip=function(Q){let le=R[Q];return le===void 0&&(le=new fs,R[Q]=le),le.getGripSpace()},this.getHand=function(Q){let le=R[Q];return le===void 0&&(le=new fs,R[Q]=le),le.getHandSpace()};function H(Q){const le=b.indexOf(Q.inputSource);if(le===-1)return;const re=R[le];re!==void 0&&(re.update(Q.inputSource,Q.frame,l||a),re.dispatchEvent({type:Q.type,data:Q.inputSource}))}function Z(){r.removeEventListener("select",H),r.removeEventListener("selectstart",H),r.removeEventListener("selectend",H),r.removeEventListener("squeeze",H),r.removeEventListener("squeezestart",H),r.removeEventListener("squeezeend",H),r.removeEventListener("end",Z),r.removeEventListener("inputsourceschange",X);for(let Q=0;Q<R.length;Q++){const le=b[Q];le!==null&&(b[Q]=null,R[Q].disconnect(le))}$=null,j=null,_.reset();for(const Q in f)delete f[Q];e.setRenderTarget(C),d=null,h=null,m=null,r=null,S=null,Ye.stop(),n.isPresenting=!1,e.setPixelRatio(g),e.setSize(P.width,P.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Q){s=Q,n.isPresenting===!0&&we("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Q){o=Q,n.isPresenting===!0&&we("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(Q){l=Q},this.getBaseLayer=function(){return h!==null?h:d},this.getBinding=function(){return m===null&&y&&(m=new XRWebGLBinding(r,t)),m},this.getFrame=function(){return x},this.getSession=function(){return r},this.setSession=async function(Q){if(r=Q,r!==null){if(C=e.getRenderTarget(),r.addEventListener("select",H),r.addEventListener("selectstart",H),r.addEventListener("selectend",H),r.addEventListener("squeeze",H),r.addEventListener("squeezestart",H),r.addEventListener("squeezeend",H),r.addEventListener("end",Z),r.addEventListener("inputsourceschange",X),w.xrCompatible!==!0&&await t.makeXRCompatible(),g=e.getPixelRatio(),e.getSize(P),y&&"createProjectionLayer"in XRWebGLBinding.prototype){let re=null,Pe=null,De=null;w.depth&&(De=w.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,re=w.stencil?Jn:vn,Pe=w.stencil?Ki:on);const Re={colorFormat:t.RGBA8,depthFormat:De,scaleFactor:s};m=this.getBinding(),h=m.createProjectionLayer(Re),r.updateRenderState({layers:[h]}),e.setPixelRatio(1),e.setSize(h.textureWidth,h.textureHeight,!1),S=new an(h.textureWidth,h.textureHeight,{format:Zt,type:kt,depthTexture:new Di(h.textureWidth,h.textureHeight,Pe,void 0,void 0,void 0,void 0,void 0,void 0,re),stencilBuffer:w.stencil,colorSpace:e.outputColorSpace,samples:w.antialias?4:0,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1})}else{const re={antialias:w.antialias,alpha:!0,depth:w.depth,stencil:w.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(r,t,re),r.updateRenderState({baseLayer:d}),e.setPixelRatio(1),e.setSize(d.framebufferWidth,d.framebufferHeight,!1),S=new an(d.framebufferWidth,d.framebufferHeight,{format:Zt,type:kt,colorSpace:e.outputColorSpace,stencilBuffer:w.stencil,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}S.isXRRenderTarget=!0,this.setFoveation(c),l=null,a=await r.requestReferenceSpace(o),Ye.setContext(r),Ye.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return _.getDepthTexture()};function X(Q){for(let le=0;le<Q.removed.length;le++){const re=Q.removed[le],Pe=b.indexOf(re);Pe>=0&&(b[Pe]=null,R[Pe].disconnect(re))}for(let le=0;le<Q.added.length;le++){const re=Q.added[le];let Pe=b.indexOf(re);if(Pe===-1){for(let Re=0;Re<R.length;Re++)if(Re>=b.length){b.push(re),Pe=Re;break}else if(b[Re]===null){b[Re]=re,Pe=Re;break}if(Pe===-1)break}const De=R[Pe];De&&De.connect(re)}}const te=new D,ie=new D;function fe(Q,le,re){te.setFromMatrixPosition(le.matrixWorld),ie.setFromMatrixPosition(re.matrixWorld);const Pe=te.distanceTo(ie),De=le.projectionMatrix.elements,Re=re.projectionMatrix.elements,ot=De[14]/(De[10]-1),Fe=De[14]/(De[10]+1),Ze=(De[9]+1)/De[5],We=(De[9]-1)/De[5],Ve=(De[8]-1)/De[0],lt=(Re[8]+1)/Re[0],ht=ot*Ve,_t=ot*lt,xt=Pe/(-Ve+lt),it=xt*-Ve;if(le.matrixWorld.decompose(Q.position,Q.quaternion,Q.scale),Q.translateX(it),Q.translateZ(xt),Q.matrixWorld.compose(Q.position,Q.quaternion,Q.scale),Q.matrixWorldInverse.copy(Q.matrixWorld).invert(),De[10]===-1)Q.projectionMatrix.copy(le.projectionMatrix),Q.projectionMatrixInverse.copy(le.projectionMatrixInverse);else{const ut=ot+xt,I=Fe+xt,yt=ht-it,Ke=_t+(Pe-it),E=Ze*Fe/I*ut,p=We*Fe/I*ut;Q.projectionMatrix.makePerspective(yt,Ke,E,p,ut,I),Q.projectionMatrixInverse.copy(Q.projectionMatrix).invert()}}function me(Q,le){le===null?Q.matrixWorld.copy(Q.matrix):Q.matrixWorld.multiplyMatrices(le.matrixWorld,Q.matrix),Q.matrixWorldInverse.copy(Q.matrixWorld).invert()}this.updateCamera=function(Q){if(r===null)return;let le=Q.near,re=Q.far;_.texture!==null&&(_.depthNear>0&&(le=_.depthNear),_.depthFar>0&&(re=_.depthFar)),z.near=U.near=T.near=le,z.far=U.far=T.far=re,($!==z.near||j!==z.far)&&(r.updateRenderState({depthNear:z.near,depthFar:z.far}),$=z.near,j=z.far),z.layers.mask=Q.layers.mask|6,T.layers.mask=z.layers.mask&-5,U.layers.mask=z.layers.mask&-3;const Pe=Q.parent,De=z.cameras;me(z,Pe);for(let Re=0;Re<De.length;Re++)me(De[Re],Pe);De.length===2?fe(z,T,U):z.projectionMatrix.copy(T.projectionMatrix),Me(Q,z,Pe)};function Me(Q,le,re){re===null?Q.matrix.copy(le.matrixWorld):(Q.matrix.copy(re.matrixWorld),Q.matrix.invert(),Q.matrix.multiply(le.matrixWorld)),Q.matrix.decompose(Q.position,Q.quaternion,Q.scale),Q.updateMatrixWorld(!0),Q.projectionMatrix.copy(le.projectionMatrix),Q.projectionMatrixInverse.copy(le.projectionMatrixInverse),Q.isPerspectiveCamera&&(Q.fov=wa*2*Math.atan(1/Q.projectionMatrix.elements[5]),Q.zoom=1)}this.getCamera=function(){return z},this.getFoveation=function(){if(!(h===null&&d===null))return c},this.setFoveation=function(Q){c=Q,h!==null&&(h.fixedFoveation=Q),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=Q)},this.hasDepthSensing=function(){return _.texture!==null},this.getDepthSensingMesh=function(){return _.getMesh(z)},this.getCameraTexture=function(Q){return f[Q]};let Xe=null;function rt(Q,le){if(u=le.getViewerPose(l||a),x=le,u!==null){const re=u.views;d!==null&&(e.setRenderTargetFramebuffer(S,d.framebuffer),e.setRenderTarget(S));let Pe=!1;re.length!==z.cameras.length&&(z.cameras.length=0,Pe=!0);for(let Fe=0;Fe<re.length;Fe++){const Ze=re[Fe];let We=null;if(d!==null)We=d.getViewport(Ze);else{const lt=m.getViewSubImage(h,Ze);We=lt.viewport,Fe===0&&(e.setRenderTargetTextures(S,lt.colorTexture,lt.depthStencilTexture),e.setRenderTarget(S))}let Ve=L[Fe];Ve===void 0&&(Ve=new Ht,Ve.layers.enable(Fe),Ve.viewport=new dt,L[Fe]=Ve),Ve.matrix.fromArray(Ze.transform.matrix),Ve.matrix.decompose(Ve.position,Ve.quaternion,Ve.scale),Ve.projectionMatrix.fromArray(Ze.projectionMatrix),Ve.projectionMatrixInverse.copy(Ve.projectionMatrix).invert(),Ve.viewport.set(We.x,We.y,We.width,We.height),Fe===0&&(z.matrix.copy(Ve.matrix),z.matrix.decompose(z.position,z.quaternion,z.scale)),Pe===!0&&z.cameras.push(Ve)}const De=r.enabledFeatures;if(De&&De.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&y){m=n.getBinding();const Fe=m.getDepthInformation(re[0]);Fe&&Fe.isValid&&Fe.texture&&_.init(Fe,r.renderState)}if(De&&De.includes("camera-access")&&y){e.state.unbindTexture(),m=n.getBinding();for(let Fe=0;Fe<re.length;Fe++){const Ze=re[Fe].camera;if(Ze){let We=f[Ze];We||(We=new Wl,f[Ze]=We);const Ve=m.getCameraImage(Ze);We.sourceTexture=Ve}}}}for(let re=0;re<R.length;re++){const Pe=b[re],De=R[re];Pe!==null&&De!==void 0&&De.update(Pe,le,l||a)}Xe&&Xe(Q,le),le.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:le}),x=null}const Ye=new Kl;Ye.setAnimationLoop(rt),this.setAnimationLoop=function(Q){Xe=Q},this.dispose=function(){}}}const Hm=new at,tc=new Le;tc.set(-1,0,0,0,1,0,0,0,1);function km(i,e){function t(_,f){_.matrixAutoUpdate===!0&&_.updateMatrix(),f.value.copy(_.matrix)}function n(_,f){f.color.getRGB(_.fogColor.value,Xl(i)),f.isFog?(_.fogNear.value=f.near,_.fogFar.value=f.far):f.isFogExp2&&(_.fogDensity.value=f.density)}function r(_,f,w,C,S){f.isNodeMaterial?f.uniformsNeedUpdate=!1:f.isMeshBasicMaterial?s(_,f):f.isMeshLambertMaterial?(s(_,f),f.envMap&&(_.envMapIntensity.value=f.envMapIntensity)):f.isMeshToonMaterial?(s(_,f),m(_,f)):f.isMeshPhongMaterial?(s(_,f),u(_,f),f.envMap&&(_.envMapIntensity.value=f.envMapIntensity)):f.isMeshStandardMaterial?(s(_,f),h(_,f),f.isMeshPhysicalMaterial&&d(_,f,S)):f.isMeshMatcapMaterial?(s(_,f),x(_,f)):f.isMeshDepthMaterial?s(_,f):f.isMeshDistanceMaterial?(s(_,f),y(_,f)):f.isMeshNormalMaterial?s(_,f):f.isLineBasicMaterial?(a(_,f),f.isLineDashedMaterial&&o(_,f)):f.isPointsMaterial?c(_,f,w,C):f.isSpriteMaterial?l(_,f):f.isShadowMaterial?(_.color.value.copy(f.color),_.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function s(_,f){_.opacity.value=f.opacity,f.color&&_.diffuse.value.copy(f.color),f.emissive&&_.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity),f.map&&(_.map.value=f.map,t(f.map,_.mapTransform)),f.alphaMap&&(_.alphaMap.value=f.alphaMap,t(f.alphaMap,_.alphaMapTransform)),f.bumpMap&&(_.bumpMap.value=f.bumpMap,t(f.bumpMap,_.bumpMapTransform),_.bumpScale.value=f.bumpScale,f.side===Nt&&(_.bumpScale.value*=-1)),f.normalMap&&(_.normalMap.value=f.normalMap,t(f.normalMap,_.normalMapTransform),_.normalScale.value.copy(f.normalScale),f.side===Nt&&_.normalScale.value.negate()),f.displacementMap&&(_.displacementMap.value=f.displacementMap,t(f.displacementMap,_.displacementMapTransform),_.displacementScale.value=f.displacementScale,_.displacementBias.value=f.displacementBias),f.emissiveMap&&(_.emissiveMap.value=f.emissiveMap,t(f.emissiveMap,_.emissiveMapTransform)),f.specularMap&&(_.specularMap.value=f.specularMap,t(f.specularMap,_.specularMapTransform)),f.alphaTest>0&&(_.alphaTest.value=f.alphaTest);const w=e.get(f),C=w.envMap,S=w.envMapRotation;C&&(_.envMap.value=C,_.envMapRotation.value.setFromMatrix4(Hm.makeRotationFromEuler(S)).transpose(),C.isCubeTexture&&C.isRenderTargetTexture===!1&&_.envMapRotation.value.premultiply(tc),_.reflectivity.value=f.reflectivity,_.ior.value=f.ior,_.refractionRatio.value=f.refractionRatio),f.lightMap&&(_.lightMap.value=f.lightMap,_.lightMapIntensity.value=f.lightMapIntensity,t(f.lightMap,_.lightMapTransform)),f.aoMap&&(_.aoMap.value=f.aoMap,_.aoMapIntensity.value=f.aoMapIntensity,t(f.aoMap,_.aoMapTransform))}function a(_,f){_.diffuse.value.copy(f.color),_.opacity.value=f.opacity,f.map&&(_.map.value=f.map,t(f.map,_.mapTransform))}function o(_,f){_.dashSize.value=f.dashSize,_.totalSize.value=f.dashSize+f.gapSize,_.scale.value=f.scale}function c(_,f,w,C){_.diffuse.value.copy(f.color),_.opacity.value=f.opacity,_.size.value=f.size*w,_.scale.value=C*.5,f.map&&(_.map.value=f.map,t(f.map,_.uvTransform)),f.alphaMap&&(_.alphaMap.value=f.alphaMap,t(f.alphaMap,_.alphaMapTransform)),f.alphaTest>0&&(_.alphaTest.value=f.alphaTest)}function l(_,f){_.diffuse.value.copy(f.color),_.opacity.value=f.opacity,_.rotation.value=f.rotation,f.map&&(_.map.value=f.map,t(f.map,_.mapTransform)),f.alphaMap&&(_.alphaMap.value=f.alphaMap,t(f.alphaMap,_.alphaMapTransform)),f.alphaTest>0&&(_.alphaTest.value=f.alphaTest)}function u(_,f){_.specular.value.copy(f.specular),_.shininess.value=Math.max(f.shininess,1e-4)}function m(_,f){f.gradientMap&&(_.gradientMap.value=f.gradientMap)}function h(_,f){_.metalness.value=f.metalness,f.metalnessMap&&(_.metalnessMap.value=f.metalnessMap,t(f.metalnessMap,_.metalnessMapTransform)),_.roughness.value=f.roughness,f.roughnessMap&&(_.roughnessMap.value=f.roughnessMap,t(f.roughnessMap,_.roughnessMapTransform)),f.envMap&&(_.envMapIntensity.value=f.envMapIntensity)}function d(_,f,w){_.ior.value=f.ior,f.sheen>0&&(_.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),_.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(_.sheenColorMap.value=f.sheenColorMap,t(f.sheenColorMap,_.sheenColorMapTransform)),f.sheenRoughnessMap&&(_.sheenRoughnessMap.value=f.sheenRoughnessMap,t(f.sheenRoughnessMap,_.sheenRoughnessMapTransform))),f.clearcoat>0&&(_.clearcoat.value=f.clearcoat,_.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(_.clearcoatMap.value=f.clearcoatMap,t(f.clearcoatMap,_.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(_.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,t(f.clearcoatRoughnessMap,_.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(_.clearcoatNormalMap.value=f.clearcoatNormalMap,t(f.clearcoatNormalMap,_.clearcoatNormalMapTransform),_.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===Nt&&_.clearcoatNormalScale.value.negate())),f.dispersion>0&&(_.dispersion.value=f.dispersion),f.iridescence>0&&(_.iridescence.value=f.iridescence,_.iridescenceIOR.value=f.iridescenceIOR,_.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],_.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap&&(_.iridescenceMap.value=f.iridescenceMap,t(f.iridescenceMap,_.iridescenceMapTransform)),f.iridescenceThicknessMap&&(_.iridescenceThicknessMap.value=f.iridescenceThicknessMap,t(f.iridescenceThicknessMap,_.iridescenceThicknessMapTransform))),f.transmission>0&&(_.transmission.value=f.transmission,_.transmissionSamplerMap.value=w.texture,_.transmissionSamplerSize.value.set(w.width,w.height),f.transmissionMap&&(_.transmissionMap.value=f.transmissionMap,t(f.transmissionMap,_.transmissionMapTransform)),_.thickness.value=f.thickness,f.thicknessMap&&(_.thicknessMap.value=f.thicknessMap,t(f.thicknessMap,_.thicknessMapTransform)),_.attenuationDistance.value=f.attenuationDistance,_.attenuationColor.value.copy(f.attenuationColor)),f.anisotropy>0&&(_.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap&&(_.anisotropyMap.value=f.anisotropyMap,t(f.anisotropyMap,_.anisotropyMapTransform))),_.specularIntensity.value=f.specularIntensity,_.specularColor.value.copy(f.specularColor),f.specularColorMap&&(_.specularColorMap.value=f.specularColorMap,t(f.specularColorMap,_.specularColorMapTransform)),f.specularIntensityMap&&(_.specularIntensityMap.value=f.specularIntensityMap,t(f.specularIntensityMap,_.specularIntensityMapTransform))}function x(_,f){f.matcap&&(_.matcap.value=f.matcap)}function y(_,f){const w=e.get(f).light;_.referencePosition.value.setFromMatrixPosition(w.matrixWorld),_.nearDistance.value=w.shadow.camera.near,_.farDistance.value=w.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function Wm(i,e,t,n){let r={},s={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function c(S,R){const b=R.program;n.uniformBlockBinding(S,b)}function l(S,R){let b=r[S.id];b===void 0&&(_(S),b=u(S),r[S.id]=b,S.addEventListener("dispose",w));const P=R.program;n.updateUBOMapping(S,P);const g=e.render.frame;s[S.id]!==g&&(h(S),s[S.id]=g)}function u(S){const R=m();S.__bindingPointIndex=R;const b=i.createBuffer(),P=S.__size,g=S.usage;return i.bindBuffer(i.UNIFORM_BUFFER,b),i.bufferData(i.UNIFORM_BUFFER,P,g),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,R,b),b}function m(){for(let S=0;S<o;S++)if(a.indexOf(S)===-1)return a.push(S),S;return He("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(S){const R=r[S.id],b=S.uniforms,P=S.__cache;i.bindBuffer(i.UNIFORM_BUFFER,R);for(let g=0,T=b.length;g<T;g++){const U=b[g];if(Array.isArray(U))for(let L=0,z=U.length;L<z;L++)d(U[L],g,L,P);else d(U,g,0,P)}i.bindBuffer(i.UNIFORM_BUFFER,null)}function d(S,R,b,P){if(y(S,R,b,P)===!0){const g=S.__offset,T=S.value;if(Array.isArray(T)){let U=0;for(let L=0;L<T.length;L++){const z=T[L],$=f(z);x(z,S.__data,U),typeof z!="number"&&typeof z!="boolean"&&!z.isMatrix3&&!ArrayBuffer.isView(z)&&(U+=$.storage/Float32Array.BYTES_PER_ELEMENT)}}else x(T,S.__data,0);i.bufferSubData(i.UNIFORM_BUFFER,g,S.__data)}}function x(S,R,b){typeof S=="number"||typeof S=="boolean"?R[0]=S:S.isMatrix3?(R[0]=S.elements[0],R[1]=S.elements[1],R[2]=S.elements[2],R[3]=0,R[4]=S.elements[3],R[5]=S.elements[4],R[6]=S.elements[5],R[7]=0,R[8]=S.elements[6],R[9]=S.elements[7],R[10]=S.elements[8],R[11]=0):ArrayBuffer.isView(S)?R.set(new S.constructor(S.buffer,S.byteOffset,R.length)):S.toArray(R,b)}function y(S,R,b,P){const g=S.value,T=R+"_"+b;if(P[T]===void 0)return typeof g=="number"||typeof g=="boolean"?P[T]=g:ArrayBuffer.isView(g)?P[T]=g.slice():P[T]=g.clone(),!0;{const U=P[T];if(typeof g=="number"||typeof g=="boolean"){if(U!==g)return P[T]=g,!0}else{if(ArrayBuffer.isView(g))return!0;if(U.equals(g)===!1)return U.copy(g),!0}}return!1}function _(S){const R=S.uniforms;let b=0;const P=16;for(let T=0,U=R.length;T<U;T++){const L=Array.isArray(R[T])?R[T]:[R[T]];for(let z=0,$=L.length;z<$;z++){const j=L[z],H=Array.isArray(j.value)?j.value:[j.value];for(let Z=0,X=H.length;Z<X;Z++){const te=H[Z],ie=f(te),fe=b%P,me=fe%ie.boundary,Me=fe+me;b+=me,Me!==0&&P-Me<ie.storage&&(b+=P-Me),j.__data=new Float32Array(ie.storage/Float32Array.BYTES_PER_ELEMENT),j.__offset=b,b+=ie.storage}}}const g=b%P;return g>0&&(b+=P-g),S.__size=b,S.__cache={},this}function f(S){const R={boundary:0,storage:0};return typeof S=="number"||typeof S=="boolean"?(R.boundary=4,R.storage=4):S.isVector2?(R.boundary=8,R.storage=8):S.isVector3||S.isColor?(R.boundary=16,R.storage=12):S.isVector4?(R.boundary=16,R.storage=16):S.isMatrix3?(R.boundary=48,R.storage=48):S.isMatrix4?(R.boundary=64,R.storage=64):S.isTexture?we("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(S)?(R.boundary=16,R.storage=S.byteLength):we("WebGLRenderer: Unsupported uniform value type.",S),R}function w(S){const R=S.target;R.removeEventListener("dispose",w);const b=a.indexOf(R.__bindingPointIndex);a.splice(b,1),i.deleteBuffer(r[R.id]),delete r[R.id],delete s[R.id]}function C(){for(const S in r)i.deleteBuffer(r[S]);a=[],r={},s={}}return{bind:c,update:l,dispose:C}}const Xm=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let jt=null;function Ym(){return jt===null&&(jt=new Rh(Xm,16,16,jn,xn),jt.name="DFG_LUT",jt.minFilter=wt,jt.magFilter=wt,jt.wrapS=mn,jt.wrapT=mn,jt.generateMipmaps=!1,jt.needsUpdate=!0),jt}class qm{constructor(e={}){const{canvas:t=th(),context:n=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:m=!1,reversedDepthBuffer:h=!1,outputBufferType:d=kt}=e;this.isWebGLRenderer=!0;let x;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");x=n.getContextAttributes().alpha}else x=a;const y=d,_=new Set([za,Ba,Oa]),f=new Set([kt,on,qi,Ki,Na,Fa]),w=new Uint32Array(4),C=new Int32Array(4),S=new D;let R=null,b=null;const P=[],g=[];let T=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=sn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const U=this;let L=!1,z=null,$=null,j=null,H=null;this._outputColorSpace=Ut;let Z=0,X=0,te=null,ie=-1,fe=null;const me=new dt,Me=new dt;let Xe=null;const rt=new ze(0);let Ye=0,Q=t.width,le=t.height,re=1,Pe=null,De=null;const Re=new dt(0,0,Q,le),ot=new dt(0,0,Q,le);let Fe=!1;const Ze=new Vl;let We=!1,Ve=!1;const lt=new at,ht=new D,_t=new dt,xt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let it=!1;function ut(){return te===null?re:1}let I=n;function yt(v,F){return t.getContext(v,F)}try{const v={alpha:!0,depth:r,stencil:s,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:u,failIfMajorPerformanceCaveat:m};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Ia}`),t.addEventListener("webglcontextlost",Ge,!1),t.addEventListener("webglcontextrestored",Ie,!1),t.addEventListener("webglcontextcreationerror",ct,!1),I===null){const F="webgl2";if(I=yt(F,v),I===null)throw yt(F)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(v){throw He("WebGLRenderer: "+v.message),v}let Ke,E,p,O,k,Y,se,ae,K,J,oe,Se,he,ce,ye,be,A,M,B,N,ee,ne,q;function de(){Ke=new Yd(I),Ke.init(),ee=new Om(I,Ke),E=new Bd(I,Ke,e,ee),p=new Nm(I,Ke),E.reversedDepthBuffer&&h&&p.buffers.depth.setReversed(!0),$=I.createFramebuffer(),j=I.createFramebuffer(),H=I.createFramebuffer(),O=new Zd(I),k=new Sm,Y=new Fm(I,Ke,p,k,E,ee,O),se=new Xd(U),ae=new Qh(I),ne=new Fd(I,ae),K=new qd(I,ae,O,ne),J=new Jd(I,K,ae,ne,O),M=new $d(I,E,Y),ye=new zd(k),oe=new Mm(U,se,Ke,E,ne,ye),Se=new km(U,k),he=new ym,ce=new Cm(Ke),A=new Nd(U,se,p,J,x,c),be=new Um(U,J,E),q=new Wm(I,O,E,p),B=new Od(I,Ke,O),N=new Kd(I,Ke,O),O.programs=oe.programs,U.capabilities=E,U.extensions=Ke,U.properties=k,U.renderLists=he,U.shadowMap=be,U.state=p,U.info=O}de(),y!==kt&&(T=new jd(y,t.width,t.height,o,r,s));const ue=new Vm(U,I);this.xr=ue,this.getContext=function(){return I},this.getContextAttributes=function(){return I.getContextAttributes()},this.forceContextLoss=function(){const v=Ke.get("WEBGL_lose_context");v&&v.loseContext()},this.forceContextRestore=function(){const v=Ke.get("WEBGL_lose_context");v&&v.restoreContext()},this.getPixelRatio=function(){return re},this.setPixelRatio=function(v){v!==void 0&&(re=v,this.setSize(Q,le,!1))},this.getSize=function(v){return v.set(Q,le)},this.setSize=function(v,F,W=!0){if(ue.isPresenting){we("WebGLRenderer: Can't change size while VR device is presenting.");return}Q=v,le=F,t.width=Math.floor(v*re),t.height=Math.floor(F*re),W===!0&&(t.style.width=v+"px",t.style.height=F+"px"),T!==null&&T.setSize(t.width,t.height),this.setViewport(0,0,v,F)},this.getDrawingBufferSize=function(v){return v.set(Q*re,le*re).floor()},this.setDrawingBufferSize=function(v,F,W){Q=v,le=F,re=W,t.width=Math.floor(v*W),t.height=Math.floor(F*W),this.setViewport(0,0,v,F)},this.setEffects=function(v){if(y===kt){He("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(v){for(let F=0;F<v.length;F++)if(v[F].isOutputPass===!0){we("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}T.setEffects(v||[])},this.getCurrentViewport=function(v){return v.copy(me)},this.getViewport=function(v){return v.copy(Re)},this.setViewport=function(v,F,W,G){v.isVector4?Re.set(v.x,v.y,v.z,v.w):Re.set(v,F,W,G),p.viewport(me.copy(Re).multiplyScalar(re).round())},this.getScissor=function(v){return v.copy(ot)},this.setScissor=function(v,F,W,G){v.isVector4?ot.set(v.x,v.y,v.z,v.w):ot.set(v,F,W,G),p.scissor(Me.copy(ot).multiplyScalar(re).round())},this.getScissorTest=function(){return Fe},this.setScissorTest=function(v){p.setScissorTest(Fe=v)},this.setOpaqueSort=function(v){Pe=v},this.setTransparentSort=function(v){De=v},this.getClearColor=function(v){return v.copy(A.getClearColor())},this.setClearColor=function(){A.setClearColor(...arguments)},this.getClearAlpha=function(){return A.getClearAlpha()},this.setClearAlpha=function(){A.setClearAlpha(...arguments)},this.clear=function(v=!0,F=!0,W=!0){let G=0;if(v){let V=!1;if(te!==null){const ge=te.texture.format;V=_.has(ge)}if(V){const ge=te.texture.type,ve=f.has(ge),_e=A.getClearColor(),Ee=A.getClearAlpha(),Te=_e.r,Ue=_e.g,Oe=_e.b;ve?(w[0]=Te,w[1]=Ue,w[2]=Oe,w[3]=Ee,I.clearBufferuiv(I.COLOR,0,w)):(C[0]=Te,C[1]=Ue,C[2]=Oe,C[3]=Ee,I.clearBufferiv(I.COLOR,0,C))}else G|=I.COLOR_BUFFER_BIT}F&&(G|=I.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),W&&(G|=I.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),G!==0&&I.clear(G)},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.setNodesHandler=function(v){v.setRenderer(this),z=v},this.dispose=function(){t.removeEventListener("webglcontextlost",Ge,!1),t.removeEventListener("webglcontextrestored",Ie,!1),t.removeEventListener("webglcontextcreationerror",ct,!1),A.dispose(),he.dispose(),ce.dispose(),k.dispose(),se.dispose(),J.dispose(),ne.dispose(),q.dispose(),oe.dispose(),ue.dispose(),ue.removeEventListener("sessionstart",ni),ue.removeEventListener("sessionend",ii),kn.stop()};function Ge(v){v.preventDefault(),Gr("WebGLRenderer: Context Lost."),L=!0}function Ie(){Gr("WebGLRenderer: Context Restored."),L=!1;const v=O.autoReset,F=be.enabled,W=be.autoUpdate,G=be.needsUpdate,V=be.type;de(),O.autoReset=v,be.enabled=F,be.autoUpdate=W,be.needsUpdate=G,be.type=V}function ct(v){He("WebGLRenderer: A WebGL context could not be created. Reason: ",v.statusMessage)}function st(v){const F=v.target;F.removeEventListener("dispose",st),Sn(F)}function Sn(v){Jr(v),k.remove(v)}function Jr(v){const F=k.get(v).programs;F!==void 0&&(F.forEach(function(W){oe.releaseProgram(W)}),v.isShaderMaterial&&oe.releaseShaderCache(v))}this.renderBufferDirect=function(v,F,W,G,V,ge){F===null&&(F=xt);const ve=V.isMesh&&V.matrixWorld.determinantAffine()<0,_e=sc(v,F,W,G,V);p.setMaterial(G,ve);let Ee=W.index,Te=1;if(G.wireframe===!0){if(Ee=K.getWireframeAttribute(W),Ee===void 0)return;Te=2}const Ue=W.drawRange,Oe=W.attributes.position;let Ae=Ue.start*Te,Je=(Ue.start+Ue.count)*Te;ge!==null&&(Ae=Math.max(Ae,ge.start*Te),Je=Math.min(Je,(ge.start+ge.count)*Te)),Ee!==null?(Ae=Math.max(Ae,0),Je=Math.min(Je,Ee.count)):Oe!=null&&(Ae=Math.max(Ae,0),Je=Math.min(Je,Oe.count));const pt=Je-Ae;if(pt<0||pt===1/0)return;ne.setup(V,G,_e,W,Ee);let ft,et=B;if(Ee!==null&&(ft=ae.get(Ee),et=N,et.setIndex(ft)),V.isMesh)G.wireframe===!0?(p.setLineWidth(G.wireframeLinewidth*ut()),et.setMode(I.LINES)):et.setMode(I.TRIANGLES);else if(V.isLine){let Tt=G.linewidth;Tt===void 0&&(Tt=1),p.setLineWidth(Tt*ut()),V.isLineSegments?et.setMode(I.LINES):V.isLineLoop?et.setMode(I.LINE_LOOP):et.setMode(I.LINE_STRIP)}else V.isPoints?et.setMode(I.POINTS):V.isSprite&&et.setMode(I.TRIANGLES);if(V.isBatchedMesh)if(Ke.get("WEBGL_multi_draw"))et.renderMultiDraw(V._multiDrawStarts,V._multiDrawCounts,V._multiDrawCount);else{const Tt=V._multiDrawStarts,xe=V._multiDrawCounts,Ft=V._multiDrawCount,qe=Ee?ae.get(Ee).bytesPerElement:1,Gt=k.get(G).currentProgram.getUniforms();for(let Jt=0;Jt<Ft;Jt++)Gt.setValue(I,"_gl_DrawID",Jt),et.render(Tt[Jt]/qe,xe[Jt])}else if(V.isInstancedMesh)et.renderInstances(Ae,pt,V.count);else if(W.isInstancedBufferGeometry){const Tt=W._maxInstanceCount!==void 0?W._maxInstanceCount:1/0,xe=Math.min(W.instanceCount,Tt);et.renderInstances(Ae,pt,xe)}else et.render(Ae,pt)};function Hn(v,F,W){v.transparent===!0&&v.side===pn&&v.forceSinglePass===!1?(v.side=Nt,v.needsUpdate=!0,Qi(v,F,W),v.side=zn,v.needsUpdate=!0,Qi(v,F,W),v.side=pn):Qi(v,F,W)}this.compile=function(v,F,W=null){W===null&&(W=v),b=ce.get(W),b.init(F),g.push(b),W.traverseVisible(function(V){V.isLight&&V.layers.test(F.layers)&&(b.pushLight(V),V.castShadow&&b.pushShadow(V))}),v!==W&&v.traverseVisible(function(V){V.isLight&&V.layers.test(F.layers)&&(b.pushLight(V),V.castShadow&&b.pushShadow(V))}),b.setupLights();const G=new Set;return v.traverse(function(V){if(!(V.isMesh||V.isPoints||V.isLine||V.isSprite))return;const ge=V.material;if(ge)if(Array.isArray(ge))for(let ve=0;ve<ge.length;ve++){const _e=ge[ve];Hn(_e,W,V),G.add(_e)}else Hn(ge,W,V),G.add(ge)}),b=g.pop(),G},this.compileAsync=function(v,F,W=null){const G=this.compile(v,F,W);return new Promise(V=>{function ge(){if(G.forEach(function(ve){k.get(ve).currentProgram.isReady()&&G.delete(ve)}),G.size===0){V(v);return}setTimeout(ge,10)}Ke.get("KHR_parallel_shader_compile")!==null?ge():setTimeout(ge,10)})};let ti=null;function En(v){ti&&ti(v)}function ni(){kn.stop()}function ii(){kn.start()}const kn=new Kl;kn.setAnimationLoop(En),typeof self<"u"&&kn.setContext(self),this.setAnimationLoop=function(v){ti=v,ue.setAnimationLoop(v),v===null?kn.stop():kn.start()},ue.addEventListener("sessionstart",ni),ue.addEventListener("sessionend",ii),this.render=function(v,F){if(F!==void 0&&F.isCamera!==!0){He("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(L===!0)return;z!==null&&z.renderStart(v,F);const W=ue.enabled===!0&&ue.isPresenting===!0,G=T!==null&&(te===null||W)&&T.begin(U,te);if(v.matrixWorldAutoUpdate===!0&&v.updateMatrixWorld(),F.parent===null&&F.matrixWorldAutoUpdate===!0&&F.updateMatrixWorld(),ue.enabled===!0&&ue.isPresenting===!0&&(T===null||T.isCompositing()===!1)&&(ue.cameraAutoUpdate===!0&&ue.updateCamera(F),F=ue.getCamera()),v.isScene===!0&&v.onBeforeRender(U,v,F,te),b=ce.get(v,g.length),b.init(F),b.state.textureUnits=Y.getTextureUnits(),g.push(b),lt.multiplyMatrices(F.projectionMatrix,F.matrixWorldInverse),Ze.setFromProjectionMatrix(lt,rn,F.reversedDepth),Ve=this.localClippingEnabled,We=ye.init(this.clippingPlanes,Ve),R=he.get(v,P.length),R.init(),P.push(R),ue.enabled===!0&&ue.isPresenting===!0){const ve=U.xr.getDepthSensingMesh();ve!==null&&Qr(ve,F,-1/0,U.sortObjects)}Qr(v,F,0,U.sortObjects),R.finish(),U.sortObjects===!0&&R.sort(Pe,De,F.reversedDepth),it=ue.enabled===!1||ue.isPresenting===!1||ue.hasDepthSensing()===!1,it&&A.addToRenderList(R,v),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),We===!0&&ye.beginShadows();const V=b.state.shadowsArray;if(be.render(V,v,F),We===!0&&ye.endShadows(),(G&&T.hasRenderPass())===!1){const ve=R.opaque,_e=R.transmissive;if(b.setupLights(),F.isArrayCamera){const Ee=F.cameras;if(_e.length>0)for(let Te=0,Ue=Ee.length;Te<Ue;Te++){const Oe=Ee[Te];Qa(ve,_e,v,Oe)}it&&A.render(v);for(let Te=0,Ue=Ee.length;Te<Ue;Te++){const Oe=Ee[Te];Ja(R,v,Oe,Oe.viewport)}}else _e.length>0&&Qa(ve,_e,v,F),it&&A.render(v),Ja(R,v,F)}te!==null&&X===0&&(Y.updateMultisampleRenderTarget(te),Y.updateRenderTargetMipmap(te)),G&&T.end(U),v.isScene===!0&&v.onAfterRender(U,v,F),ne.resetDefaultState(),ie=-1,fe=null,g.pop(),g.length>0?(b=g[g.length-1],Y.setTextureUnits(b.state.textureUnits),We===!0&&ye.setGlobalState(U.clippingPlanes,b.state.camera)):b=null,P.pop(),P.length>0?R=P[P.length-1]:R=null,z!==null&&z.renderEnd()};function Qr(v,F,W,G){if(v.visible===!1)return;if(v.layers.test(F.layers)){if(v.isGroup)W=v.renderOrder;else if(v.isLOD)v.autoUpdate===!0&&v.update(F);else if(v.isLightProbeGrid)b.pushLightProbeGrid(v);else if(v.isLight)b.pushLight(v),v.castShadow&&b.pushShadow(v);else if(v.isSprite){if(!v.frustumCulled||Ze.intersectsSprite(v)){G&&_t.setFromMatrixPosition(v.matrixWorld).applyMatrix4(lt);const ve=J.update(v),_e=v.material;_e.visible&&R.push(v,ve,_e,W,_t.z,null)}}else if((v.isMesh||v.isLine||v.isPoints)&&(!v.frustumCulled||Ze.intersectsObject(v))){const ve=J.update(v),_e=v.material;if(G&&(v.boundingSphere!==void 0?(v.boundingSphere===null&&v.computeBoundingSphere(),_t.copy(v.boundingSphere.center)):(ve.boundingSphere===null&&ve.computeBoundingSphere(),_t.copy(ve.boundingSphere.center)),_t.applyMatrix4(v.matrixWorld).applyMatrix4(lt)),Array.isArray(_e)){const Ee=ve.groups;for(let Te=0,Ue=Ee.length;Te<Ue;Te++){const Oe=Ee[Te],Ae=_e[Oe.materialIndex];Ae&&Ae.visible&&R.push(v,ve,Ae,W,_t.z,Oe)}}else _e.visible&&R.push(v,ve,_e,W,_t.z,null)}}const ge=v.children;for(let ve=0,_e=ge.length;ve<_e;ve++)Qr(ge[ve],F,W,G)}function Ja(v,F,W,G){const{opaque:V,transmissive:ge,transparent:ve}=v;b.setupLightsView(W),We===!0&&ye.setGlobalState(U.clippingPlanes,W),G&&p.viewport(me.copy(G)),V.length>0&&Ji(V,F,W),ge.length>0&&Ji(ge,F,W),ve.length>0&&Ji(ve,F,W),p.buffers.depth.setTest(!0),p.buffers.depth.setMask(!0),p.buffers.color.setMask(!0),p.setPolygonOffset(!1)}function Qa(v,F,W,G){if((W.isScene===!0?W.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[G.id]===void 0){const Ae=Ke.has("EXT_color_buffer_half_float")||Ke.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[G.id]=new an(1,1,{generateMipmaps:!0,type:Ae?xn:kt,minFilter:$n,samples:Math.max(4,E.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:ke.workingColorSpace})}const ge=b.state.transmissionRenderTarget[G.id],ve=G.viewport||me;ge.setSize(ve.z*U.transmissionResolutionScale,ve.w*U.transmissionResolutionScale);const _e=U.getRenderTarget(),Ee=U.getActiveCubeFace(),Te=U.getActiveMipmapLevel();U.setRenderTarget(ge),U.getClearColor(rt),Ye=U.getClearAlpha(),Ye<1&&U.setClearColor(16777215,.5),U.clear(),it&&A.render(W);const Ue=U.toneMapping;U.toneMapping=sn;const Oe=G.viewport;if(G.viewport!==void 0&&(G.viewport=void 0),b.setupLightsView(G),We===!0&&ye.setGlobalState(U.clippingPlanes,G),Ji(v,W,G),Y.updateMultisampleRenderTarget(ge),Y.updateRenderTargetMipmap(ge),Ke.has("WEBGL_multisampled_render_to_texture")===!1){let Ae=!1;for(let Je=0,pt=F.length;Je<pt;Je++){const ft=F[Je],{object:et,geometry:Tt,material:xe,group:Ft}=ft;if(xe.side===pn&&et.layers.test(G.layers)){const qe=xe.side;xe.side=Nt,xe.needsUpdate=!0,ja(et,W,G,Tt,xe,Ft),xe.side=qe,xe.needsUpdate=!0,Ae=!0}}Ae===!0&&(Y.updateMultisampleRenderTarget(ge),Y.updateRenderTargetMipmap(ge))}U.setRenderTarget(_e,Ee,Te),U.setClearColor(rt,Ye),Oe!==void 0&&(G.viewport=Oe),U.toneMapping=Ue}function Ji(v,F,W){const G=F.isScene===!0?F.overrideMaterial:null;for(let V=0,ge=v.length;V<ge;V++){const ve=v[V],{object:_e,geometry:Ee,group:Te}=ve;let Ue=ve.material;Ue.allowOverride===!0&&G!==null&&(Ue=G),_e.layers.test(W.layers)&&ja(_e,F,W,Ee,Ue,Te)}}function ja(v,F,W,G,V,ge){v.onBeforeRender(U,F,W,G,V,ge),v.modelViewMatrix.multiplyMatrices(W.matrixWorldInverse,v.matrixWorld),v.normalMatrix.getNormalMatrix(v.modelViewMatrix),V.onBeforeRender(U,F,W,G,v,ge),V.transparent===!0&&V.side===pn&&V.forceSinglePass===!1?(V.side=Nt,V.needsUpdate=!0,U.renderBufferDirect(W,F,G,V,v,ge),V.side=zn,V.needsUpdate=!0,U.renderBufferDirect(W,F,G,V,v,ge),V.side=pn):U.renderBufferDirect(W,F,G,V,v,ge),v.onAfterRender(U,F,W,G,V,ge)}function Qi(v,F,W){F.isScene!==!0&&(F=xt);const G=k.get(v),V=b.state.lights,ge=b.state.shadowsArray,ve=V.state.version,_e=oe.getParameters(v,V.state,ge,F,W,b.state.lightProbeGridArray),Ee=oe.getProgramCacheKey(_e);let Te=G.programs;G.environment=v.isMeshStandardMaterial||v.isMeshLambertMaterial||v.isMeshPhongMaterial?F.environment:null,G.fog=F.fog;const Ue=v.isMeshStandardMaterial||v.isMeshLambertMaterial&&!v.envMap||v.isMeshPhongMaterial&&!v.envMap;G.envMap=se.get(v.envMap||G.environment,Ue),G.envMapRotation=G.environment!==null&&v.envMap===null?F.environmentRotation:v.envMapRotation,Te===void 0&&(v.addEventListener("dispose",st),Te=new Map,G.programs=Te);let Oe=Te.get(Ee);if(Oe!==void 0){if(G.currentProgram===Oe&&G.lightsStateVersion===ve)return to(v,_e),Oe}else _e.uniforms=oe.getUniforms(v),z!==null&&v.isNodeMaterial&&z.build(v,W,_e),v.onBeforeCompile(_e,U),Oe=oe.acquireProgram(_e,Ee),Te.set(Ee,Oe),G.uniforms=_e.uniforms;const Ae=G.uniforms;return(!v.isShaderMaterial&&!v.isRawShaderMaterial||v.clipping===!0)&&(Ae.clippingPlanes=ye.uniform),to(v,_e),G.needsLights=oc(v),G.lightsStateVersion=ve,G.needsLights&&(Ae.ambientLightColor.value=V.state.ambient,Ae.lightProbe.value=V.state.probe,Ae.directionalLights.value=V.state.directional,Ae.directionalLightShadows.value=V.state.directionalShadow,Ae.spotLights.value=V.state.spot,Ae.spotLightShadows.value=V.state.spotShadow,Ae.rectAreaLights.value=V.state.rectArea,Ae.ltc_1.value=V.state.rectAreaLTC1,Ae.ltc_2.value=V.state.rectAreaLTC2,Ae.pointLights.value=V.state.point,Ae.pointLightShadows.value=V.state.pointShadow,Ae.hemisphereLights.value=V.state.hemi,Ae.directionalShadowMatrix.value=V.state.directionalShadowMatrix,Ae.spotLightMatrix.value=V.state.spotLightMatrix,Ae.spotLightMap.value=V.state.spotLightMap,Ae.pointShadowMatrix.value=V.state.pointShadowMatrix),G.lightProbeGrid=b.state.lightProbeGridArray.length>0,G.currentProgram=Oe,G.uniformsList=null,Oe}function eo(v){if(v.uniformsList===null){const F=v.currentProgram.getUniforms();v.uniformsList=Ir.seqWithValue(F.seq,v.uniforms)}return v.uniformsList}function to(v,F){const W=k.get(v);W.outputColorSpace=F.outputColorSpace,W.batching=F.batching,W.batchingColor=F.batchingColor,W.instancing=F.instancing,W.instancingColor=F.instancingColor,W.instancingMorph=F.instancingMorph,W.skinning=F.skinning,W.morphTargets=F.morphTargets,W.morphNormals=F.morphNormals,W.morphColors=F.morphColors,W.morphTargetsCount=F.morphTargetsCount,W.numClippingPlanes=F.numClippingPlanes,W.numIntersection=F.numClipIntersection,W.vertexAlphas=F.vertexAlphas,W.vertexTangents=F.vertexTangents,W.toneMapping=F.toneMapping}function rc(v,F){if(v.length===0)return null;if(v.length===1)return v[0].texture!==null?v[0]:null;S.setFromMatrixPosition(F.matrixWorld);for(let W=0,G=v.length;W<G;W++){const V=v[W];if(V.texture!==null&&V.boundingBox.containsPoint(S))return V}return null}function sc(v,F,W,G,V){F.isScene!==!0&&(F=xt),Y.resetTextureUnits();const ge=F.fog,ve=G.isMeshStandardMaterial||G.isMeshLambertMaterial||G.isMeshPhongMaterial?F.environment:null,_e=te===null?U.outputColorSpace:te.isXRRenderTarget===!0?te.texture.colorSpace:ke.workingColorSpace,Ee=G.isMeshStandardMaterial||G.isMeshLambertMaterial&&!G.envMap||G.isMeshPhongMaterial&&!G.envMap,Te=se.get(G.envMap||ve,Ee),Ue=G.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,Oe=!!W.attributes.tangent&&(!!G.normalMap||G.anisotropy>0),Ae=!!W.morphAttributes.position,Je=!!W.morphAttributes.normal,pt=!!W.morphAttributes.color;let ft=sn;G.toneMapped&&(te===null||te.isXRRenderTarget===!0)&&(ft=U.toneMapping);const et=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,Tt=et!==void 0?et.length:0,xe=k.get(G),Ft=b.state.lights;if(We===!0&&(Ve===!0||v!==fe)){const nt=v===fe&&G.id===ie;ye.setState(G,v,nt)}let qe=!1;G.version===xe.__version?(xe.needsLights&&xe.lightsStateVersion!==Ft.state.version||xe.outputColorSpace!==_e||V.isBatchedMesh&&xe.batching===!1||!V.isBatchedMesh&&xe.batching===!0||V.isBatchedMesh&&xe.batchingColor===!0&&V.colorTexture===null||V.isBatchedMesh&&xe.batchingColor===!1&&V.colorTexture!==null||V.isInstancedMesh&&xe.instancing===!1||!V.isInstancedMesh&&xe.instancing===!0||V.isSkinnedMesh&&xe.skinning===!1||!V.isSkinnedMesh&&xe.skinning===!0||V.isInstancedMesh&&xe.instancingColor===!0&&V.instanceColor===null||V.isInstancedMesh&&xe.instancingColor===!1&&V.instanceColor!==null||V.isInstancedMesh&&xe.instancingMorph===!0&&V.morphTexture===null||V.isInstancedMesh&&xe.instancingMorph===!1&&V.morphTexture!==null||xe.envMap!==Te||G.fog===!0&&xe.fog!==ge||xe.numClippingPlanes!==void 0&&(xe.numClippingPlanes!==ye.numPlanes||xe.numIntersection!==ye.numIntersection)||xe.vertexAlphas!==Ue||xe.vertexTangents!==Oe||xe.morphTargets!==Ae||xe.morphNormals!==Je||xe.morphColors!==pt||xe.toneMapping!==ft||xe.morphTargetsCount!==Tt||!!xe.lightProbeGrid!=b.state.lightProbeGridArray.length>0)&&(qe=!0):(qe=!0,xe.__version=G.version);let Gt=xe.currentProgram;qe===!0&&(Gt=Qi(G,F,V),z&&G.isNodeMaterial&&z.onUpdateProgram(G,Gt,xe));let Jt=!1,yn=!1,ri=!1;const tt=Gt.getUniforms(),mt=xe.uniforms;if(p.useProgram(Gt.program)&&(Jt=!0,yn=!0,ri=!0),G.id!==ie&&(ie=G.id,yn=!0),xe.needsLights){const nt=rc(b.state.lightProbeGridArray,V);xe.lightProbeGrid!==nt&&(xe.lightProbeGrid=nt,yn=!0)}if(Jt||fe!==v){p.buffers.depth.getReversed()&&v.reversedDepth!==!0&&(v._reversedDepth=!0,v.updateProjectionMatrix()),tt.setValue(I,"projectionMatrix",v.projectionMatrix),tt.setValue(I,"viewMatrix",v.matrixWorldInverse);const Tn=tt.map.cameraPosition;Tn!==void 0&&Tn.setValue(I,ht.setFromMatrixPosition(v.matrixWorld)),E.logarithmicDepthBuffer&&tt.setValue(I,"logDepthBufFC",2/(Math.log(v.far+1)/Math.LN2)),(G.isMeshPhongMaterial||G.isMeshToonMaterial||G.isMeshLambertMaterial||G.isMeshBasicMaterial||G.isMeshStandardMaterial||G.isShaderMaterial)&&tt.setValue(I,"isOrthographic",v.isOrthographicCamera===!0),fe!==v&&(fe=v,yn=!0,ri=!0)}if(xe.needsLights&&(Ft.state.directionalShadowMap.length>0&&tt.setValue(I,"directionalShadowMap",Ft.state.directionalShadowMap,Y),Ft.state.spotShadowMap.length>0&&tt.setValue(I,"spotShadowMap",Ft.state.spotShadowMap,Y),Ft.state.pointShadowMap.length>0&&tt.setValue(I,"pointShadowMap",Ft.state.pointShadowMap,Y)),V.isSkinnedMesh){tt.setOptional(I,V,"bindMatrix"),tt.setOptional(I,V,"bindMatrixInverse");const nt=V.skeleton;nt&&(nt.boneTexture===null&&nt.computeBoneTexture(),tt.setValue(I,"boneTexture",nt.boneTexture,Y))}V.isBatchedMesh&&(tt.setOptional(I,V,"batchingTexture"),tt.setValue(I,"batchingTexture",V._matricesTexture,Y),tt.setOptional(I,V,"batchingIdTexture"),tt.setValue(I,"batchingIdTexture",V._indirectTexture,Y),tt.setOptional(I,V,"batchingColorTexture"),V._colorsTexture!==null&&tt.setValue(I,"batchingColorTexture",V._colorsTexture,Y));const bn=W.morphAttributes;if((bn.position!==void 0||bn.normal!==void 0||bn.color!==void 0)&&M.update(V,W,Gt),(yn||xe.receiveShadow!==V.receiveShadow)&&(xe.receiveShadow=V.receiveShadow,tt.setValue(I,"receiveShadow",V.receiveShadow)),(G.isMeshStandardMaterial||G.isMeshLambertMaterial||G.isMeshPhongMaterial)&&G.envMap===null&&F.environment!==null&&(mt.envMapIntensity.value=F.environmentIntensity),mt.dfgLUT!==void 0&&(mt.dfgLUT.value=Ym()),yn){if(tt.setValue(I,"toneMappingExposure",U.toneMappingExposure),xe.needsLights&&ac(mt,ri),ge&&G.fog===!0&&Se.refreshFogUniforms(mt,ge),Se.refreshMaterialUniforms(mt,G,re,le,b.state.transmissionRenderTarget[v.id]),xe.needsLights&&xe.lightProbeGrid){const nt=xe.lightProbeGrid;mt.probesSH.value=nt.texture,mt.probesMin.value.copy(nt.boundingBox.min),mt.probesMax.value.copy(nt.boundingBox.max),mt.probesResolution.value.copy(nt.resolution)}Ir.upload(I,eo(xe),mt,Y)}if(G.isShaderMaterial&&G.uniformsNeedUpdate===!0&&(Ir.upload(I,eo(xe),mt,Y),G.uniformsNeedUpdate=!1),G.isSpriteMaterial&&tt.setValue(I,"center",V.center),tt.setValue(I,"modelViewMatrix",V.modelViewMatrix),tt.setValue(I,"normalMatrix",V.normalMatrix),tt.setValue(I,"modelMatrix",V.matrixWorld),G.uniformsGroups!==void 0){const nt=G.uniformsGroups;for(let Tn=0,si=nt.length;Tn<si;Tn++){const no=nt[Tn];q.update(no,Gt),q.bind(no,Gt)}}return Gt}function ac(v,F){v.ambientLightColor.needsUpdate=F,v.lightProbe.needsUpdate=F,v.directionalLights.needsUpdate=F,v.directionalLightShadows.needsUpdate=F,v.pointLights.needsUpdate=F,v.pointLightShadows.needsUpdate=F,v.spotLights.needsUpdate=F,v.spotLightShadows.needsUpdate=F,v.rectAreaLights.needsUpdate=F,v.hemisphereLights.needsUpdate=F}function oc(v){return v.isMeshLambertMaterial||v.isMeshToonMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isShadowMaterial||v.isShaderMaterial&&v.lights===!0}this.getActiveCubeFace=function(){return Z},this.getActiveMipmapLevel=function(){return X},this.getRenderTarget=function(){return te},this.setRenderTargetTextures=function(v,F,W){const G=k.get(v);G.__autoAllocateDepthBuffer=v.resolveDepthBuffer===!1,G.__autoAllocateDepthBuffer===!1&&(G.__useRenderToTexture=!1),k.get(v.texture).__webglTexture=F,k.get(v.depthTexture).__webglTexture=G.__autoAllocateDepthBuffer?void 0:W,G.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(v,F){const W=k.get(v);W.__webglFramebuffer=F,W.__useDefaultFramebuffer=F===void 0},this.setRenderTarget=function(v,F=0,W=0){te=v,Z=F,X=W;let G=null,V=!1,ge=!1;if(v){const _e=k.get(v);if(_e.__useDefaultFramebuffer!==void 0){p.bindFramebuffer(I.FRAMEBUFFER,_e.__webglFramebuffer),me.copy(v.viewport),Me.copy(v.scissor),Xe=v.scissorTest,p.viewport(me),p.scissor(Me),p.setScissorTest(Xe),ie=-1;return}else if(_e.__webglFramebuffer===void 0)Y.setupRenderTarget(v);else if(_e.__hasExternalTextures)Y.rebindTextures(v,k.get(v.texture).__webglTexture,k.get(v.depthTexture).__webglTexture);else if(v.depthBuffer){const Ue=v.depthTexture;if(_e.__boundDepthTexture!==Ue){if(Ue!==null&&k.has(Ue)&&(v.width!==Ue.image.width||v.height!==Ue.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");Y.setupDepthRenderbuffer(v)}}const Ee=v.texture;(Ee.isData3DTexture||Ee.isDataArrayTexture||Ee.isCompressedArrayTexture)&&(ge=!0);const Te=k.get(v).__webglFramebuffer;v.isWebGLCubeRenderTarget?(Array.isArray(Te[F])?G=Te[F][W]:G=Te[F],V=!0):v.samples>0&&Y.useMultisampledRTT(v)===!1?G=k.get(v).__webglMultisampledFramebuffer:Array.isArray(Te)?G=Te[W]:G=Te,me.copy(v.viewport),Me.copy(v.scissor),Xe=v.scissorTest}else me.copy(Re).multiplyScalar(re).floor(),Me.copy(ot).multiplyScalar(re).floor(),Xe=Fe;if(W!==0&&(G=$),p.bindFramebuffer(I.FRAMEBUFFER,G)&&p.drawBuffers(v,G),p.viewport(me),p.scissor(Me),p.setScissorTest(Xe),V){const _e=k.get(v.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_CUBE_MAP_POSITIVE_X+F,_e.__webglTexture,W)}else if(ge){const _e=F;for(let Ee=0;Ee<v.textures.length;Ee++){const Te=k.get(v.textures[Ee]);I.framebufferTextureLayer(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0+Ee,Te.__webglTexture,W,_e)}}else if(v!==null&&W!==0){const _e=k.get(v.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,_e.__webglTexture,W)}ie=-1},this.readRenderTargetPixels=function(v,F,W,G,V,ge,ve,_e=0){if(!(v&&v.isWebGLRenderTarget)){He("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ee=k.get(v).__webglFramebuffer;if(v.isWebGLCubeRenderTarget&&ve!==void 0&&(Ee=Ee[ve]),Ee){p.bindFramebuffer(I.FRAMEBUFFER,Ee);try{const Te=v.textures[_e],Ue=Te.format,Oe=Te.type;if(v.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+_e),!E.textureFormatReadable(Ue)){He("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!E.textureTypeReadable(Oe)){He("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}F>=0&&F<=v.width-G&&W>=0&&W<=v.height-V&&I.readPixels(F,W,G,V,ee.convert(Ue),ee.convert(Oe),ge)}finally{const Te=te!==null?k.get(te).__webglFramebuffer:null;p.bindFramebuffer(I.FRAMEBUFFER,Te)}}},this.readRenderTargetPixelsAsync=async function(v,F,W,G,V,ge,ve,_e=0){if(!(v&&v.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Ee=k.get(v).__webglFramebuffer;if(v.isWebGLCubeRenderTarget&&ve!==void 0&&(Ee=Ee[ve]),Ee)if(F>=0&&F<=v.width-G&&W>=0&&W<=v.height-V){p.bindFramebuffer(I.FRAMEBUFFER,Ee);const Te=v.textures[_e],Ue=Te.format,Oe=Te.type;if(v.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+_e),!E.textureFormatReadable(Ue))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!E.textureTypeReadable(Oe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ae=I.createBuffer();I.bindBuffer(I.PIXEL_PACK_BUFFER,Ae),I.bufferData(I.PIXEL_PACK_BUFFER,ge.byteLength,I.STREAM_READ),I.readPixels(F,W,G,V,ee.convert(Ue),ee.convert(Oe),0);const Je=te!==null?k.get(te).__webglFramebuffer:null;p.bindFramebuffer(I.FRAMEBUFFER,Je);const pt=I.fenceSync(I.SYNC_GPU_COMMANDS_COMPLETE,0);return I.flush(),await nh(I,pt,4),I.bindBuffer(I.PIXEL_PACK_BUFFER,Ae),I.getBufferSubData(I.PIXEL_PACK_BUFFER,0,ge),I.deleteBuffer(Ae),I.deleteSync(pt),ge}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(v,F=null,W=0){const G=Math.pow(2,-W),V=Math.floor(v.image.width*G),ge=Math.floor(v.image.height*G),ve=F!==null?F.x:0,_e=F!==null?F.y:0;Y.setTexture2D(v,0),I.copyTexSubImage2D(I.TEXTURE_2D,W,0,0,ve,_e,V,ge),p.unbindTexture()},this.copyTextureToTexture=function(v,F,W=null,G=null,V=0,ge=0){let ve,_e,Ee,Te,Ue,Oe,Ae,Je,pt;const ft=v.isCompressedTexture?v.mipmaps[ge]:v.image;if(W!==null)ve=W.max.x-W.min.x,_e=W.max.y-W.min.y,Ee=W.isBox3?W.max.z-W.min.z:1,Te=W.min.x,Ue=W.min.y,Oe=W.isBox3?W.min.z:0;else{const mt=Math.pow(2,-V);ve=Math.floor(ft.width*mt),_e=Math.floor(ft.height*mt),v.isDataArrayTexture?Ee=ft.depth:v.isData3DTexture?Ee=Math.floor(ft.depth*mt):Ee=1,Te=0,Ue=0,Oe=0}G!==null?(Ae=G.x,Je=G.y,pt=G.z):(Ae=0,Je=0,pt=0);const et=ee.convert(F.format),Tt=ee.convert(F.type);let xe;F.isData3DTexture?(Y.setTexture3D(F,0),xe=I.TEXTURE_3D):F.isDataArrayTexture||F.isCompressedArrayTexture?(Y.setTexture2DArray(F,0),xe=I.TEXTURE_2D_ARRAY):(Y.setTexture2D(F,0),xe=I.TEXTURE_2D),p.activeTexture(I.TEXTURE0),p.pixelStorei(I.UNPACK_FLIP_Y_WEBGL,F.flipY),p.pixelStorei(I.UNPACK_PREMULTIPLY_ALPHA_WEBGL,F.premultiplyAlpha),p.pixelStorei(I.UNPACK_ALIGNMENT,F.unpackAlignment);const Ft=p.getParameter(I.UNPACK_ROW_LENGTH),qe=p.getParameter(I.UNPACK_IMAGE_HEIGHT),Gt=p.getParameter(I.UNPACK_SKIP_PIXELS),Jt=p.getParameter(I.UNPACK_SKIP_ROWS),yn=p.getParameter(I.UNPACK_SKIP_IMAGES);p.pixelStorei(I.UNPACK_ROW_LENGTH,ft.width),p.pixelStorei(I.UNPACK_IMAGE_HEIGHT,ft.height),p.pixelStorei(I.UNPACK_SKIP_PIXELS,Te),p.pixelStorei(I.UNPACK_SKIP_ROWS,Ue),p.pixelStorei(I.UNPACK_SKIP_IMAGES,Oe);const ri=v.isDataArrayTexture||v.isData3DTexture,tt=F.isDataArrayTexture||F.isData3DTexture;if(v.isDepthTexture){const mt=k.get(v),bn=k.get(F),nt=k.get(mt.__renderTarget),Tn=k.get(bn.__renderTarget);p.bindFramebuffer(I.READ_FRAMEBUFFER,nt.__webglFramebuffer),p.bindFramebuffer(I.DRAW_FRAMEBUFFER,Tn.__webglFramebuffer);for(let si=0;si<Ee;si++)ri&&(I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,k.get(v).__webglTexture,V,Oe+si),I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,k.get(F).__webglTexture,ge,pt+si)),I.blitFramebuffer(Te,Ue,ve,_e,Ae,Je,ve,_e,I.DEPTH_BUFFER_BIT,I.NEAREST);p.bindFramebuffer(I.READ_FRAMEBUFFER,null),p.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else if(V!==0||v.isRenderTargetTexture||k.has(v)){const mt=k.get(v),bn=k.get(F);p.bindFramebuffer(I.READ_FRAMEBUFFER,j),p.bindFramebuffer(I.DRAW_FRAMEBUFFER,H);for(let nt=0;nt<Ee;nt++)ri?I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,mt.__webglTexture,V,Oe+nt):I.framebufferTexture2D(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,mt.__webglTexture,V),tt?I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,bn.__webglTexture,ge,pt+nt):I.framebufferTexture2D(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,bn.__webglTexture,ge),V!==0?I.blitFramebuffer(Te,Ue,ve,_e,Ae,Je,ve,_e,I.COLOR_BUFFER_BIT,I.NEAREST):tt?I.copyTexSubImage3D(xe,ge,Ae,Je,pt+nt,Te,Ue,ve,_e):I.copyTexSubImage2D(xe,ge,Ae,Je,Te,Ue,ve,_e);p.bindFramebuffer(I.READ_FRAMEBUFFER,null),p.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else tt?v.isDataTexture||v.isData3DTexture?I.texSubImage3D(xe,ge,Ae,Je,pt,ve,_e,Ee,et,Tt,ft.data):F.isCompressedArrayTexture?I.compressedTexSubImage3D(xe,ge,Ae,Je,pt,ve,_e,Ee,et,ft.data):I.texSubImage3D(xe,ge,Ae,Je,pt,ve,_e,Ee,et,Tt,ft):v.isDataTexture?I.texSubImage2D(I.TEXTURE_2D,ge,Ae,Je,ve,_e,et,Tt,ft.data):v.isCompressedTexture?I.compressedTexSubImage2D(I.TEXTURE_2D,ge,Ae,Je,ft.width,ft.height,et,ft.data):I.texSubImage2D(I.TEXTURE_2D,ge,Ae,Je,ve,_e,et,Tt,ft);p.pixelStorei(I.UNPACK_ROW_LENGTH,Ft),p.pixelStorei(I.UNPACK_IMAGE_HEIGHT,qe),p.pixelStorei(I.UNPACK_SKIP_PIXELS,Gt),p.pixelStorei(I.UNPACK_SKIP_ROWS,Jt),p.pixelStorei(I.UNPACK_SKIP_IMAGES,yn),ge===0&&F.generateMipmaps&&I.generateMipmap(xe),p.unbindTexture()},this.initRenderTarget=function(v){k.get(v).__webglFramebuffer===void 0&&Y.setupRenderTarget(v)},this.initTexture=function(v){v.isCubeTexture?Y.setTextureCube(v,0):v.isData3DTexture?Y.setTexture3D(v,0):v.isDataArrayTexture||v.isCompressedArrayTexture?Y.setTexture2DArray(v,0):Y.setTexture2D(v,0),p.unbindTexture()},this.resetState=function(){Z=0,X=0,te=null,p.reset(),ne.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return rn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=ke._getDrawingBufferColorSpace(e),t.unpackColorSpace=ke._getUnpackColorSpace()}}const hl={type:"change"},Xa={type:"start"},nc={type:"end"},Ar=new qr,ul=new Ln,Km=Math.cos(70*sh.DEG2RAD),vt=new D,It=2*Math.PI,je={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Bs=1e-6;class Zm extends $h{constructor(e,t=null){super(e,t),this.state=je.NONE,this.target=new D,this.cursor=new D,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Ti.ROTATE,MIDDLE:Ti.DOLLY,RIGHT:Ti.PAN},this.touches={ONE:bi.ROTATE,TWO:bi.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new D,this._lastQuaternion=new Gn,this._lastTargetPosition=new D,this._quat=new Gn().setFromUnitVectors(e.up,new D(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Bo,this._sphericalDelta=new Bo,this._scale=1,this._panOffset=new D,this._rotateStart=new Ce,this._rotateEnd=new Ce,this._rotateDelta=new Ce,this._panStart=new Ce,this._panEnd=new Ce,this._panDelta=new Ce,this._dollyStart=new Ce,this._dollyEnd=new Ce,this._dollyDelta=new Ce,this._dollyDirection=new D,this._mouse=new Ce,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Jm.bind(this),this._onPointerDown=$m.bind(this),this._onPointerUp=Qm.bind(this),this._onContextMenu=s_.bind(this),this._onMouseWheel=t_.bind(this),this._onKeyDown=n_.bind(this),this._onTouchStart=i_.bind(this),this._onTouchMove=r_.bind(this),this._onMouseDown=jm.bind(this),this._onMouseMove=e_.bind(this),this._interceptControlDown=a_.bind(this),this._interceptControlUp=o_.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(e){this._cursorStyle=e,e==="grab"?this.domElement.style.cursor="grab":this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction=""}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(hl),this.update(),this.state=je.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){const t=this.object.position;vt.copy(t).sub(this.target),vt.applyQuaternion(this._quat),this._spherical.setFromVector3(vt),this.autoRotate&&this.state===je.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,r=this.maxAzimuthAngle;isFinite(n)&&isFinite(r)&&(n<-Math.PI?n+=It:n>Math.PI&&(n-=It),r<-Math.PI?r+=It:r>Math.PI&&(r-=It),n<=r?this._spherical.theta=Math.max(n,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+r)/2?Math.max(n,this._spherical.theta):Math.min(r,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=a!=this._spherical.radius}if(vt.setFromSpherical(this._spherical),vt.applyQuaternion(this._quatInverse),t.copy(this.target).add(vt),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=vt.length();a=this._clampDistance(o*this._scale);const c=o-a;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),s=!!c}else if(this.object.isOrthographicCamera){const o=new D(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=c!==this.object.zoom;const l=new D(this._mouse.x,this._mouse.y,0);l.unproject(this.object),this.object.position.sub(l).add(o),this.object.updateMatrixWorld(),a=vt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(Ar.origin.copy(this.object.position),Ar.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Ar.direction))<Km?this.object.lookAt(this.target):(ul.setFromNormalAndCoplanarPoint(this.object.up,this.target),Ar.intersectPlane(ul,this.target))))}else if(this.object.isOrthographicCamera){const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),s=!0)}return this._scale=1,this._performCursorZoom=!1,s||this._lastPosition.distanceToSquared(this.object.position)>Bs||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Bs||this._lastTargetPosition.distanceToSquared(this.target)>Bs?(this.dispatchEvent(hl),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?It/60*this.autoRotateSpeed*e:It/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){vt.setFromMatrixColumn(t,0),vt.multiplyScalar(-e),this._panOffset.add(vt)}_panUp(e,t){this.screenSpacePanning===!0?vt.setFromMatrixColumn(t,1):(vt.setFromMatrixColumn(t,0),vt.crossVectors(this.object.up,vt)),vt.multiplyScalar(e),this._panOffset.add(vt)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const r=this.object.position;vt.copy(r).sub(this.target);let s=vt.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/n.clientHeight,this.object.matrix),this._panUp(2*t*s/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),r=e-n.left,s=t-n.top,a=n.width,o=n.height;this._mouse.x=r/a*2-1,this._mouse.y=-(s/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(It*this._rotateDelta.x/t.clientHeight),this._rotateUp(It*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(It*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-It*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(It*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-It*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(n,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(n,r)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(n*n+r*r);this._dollyStart.set(0,s)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),s=.5*(e.pageY+n.y);this._rotateEnd.set(r,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(It*this._rotateDelta.x/t.clientHeight),this._rotateUp(It*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(n,r)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(n*n+r*r);this._dollyEnd.set(0,s),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new Ce,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function $m(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function Jm(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function Qm(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(nc),this.state=je.NONE,this._cursorStyle==="grab"&&(this.domElement.style.cursor="grab");break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function jm(i){let e;switch(i.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case Ti.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=je.DOLLY;break;case Ti.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=je.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=je.ROTATE}break;case Ti.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=je.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=je.PAN}break;default:this.state=je.NONE}this.state!==je.NONE&&this.dispatchEvent(Xa)}function e_(i){switch(this.state){case je.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case je.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case je.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function t_(i){this.enabled===!1||this.enableZoom===!1||this.state!==je.NONE||(i.preventDefault(),this.dispatchEvent(Xa),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(nc))}function n_(i){this.enabled!==!1&&this._handleKeyDown(i)}function i_(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case bi.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=je.TOUCH_ROTATE;break;case bi.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=je.TOUCH_PAN;break;default:this.state=je.NONE}break;case 2:switch(this.touches.TWO){case bi.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=je.TOUCH_DOLLY_PAN;break;case bi.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=je.TOUCH_DOLLY_ROTATE;break;default:this.state=je.NONE}break;default:this.state=je.NONE}this.state!==je.NONE&&this.dispatchEvent(Xa)}function r_(i){switch(this._trackPointer(i),this.state){case je.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case je.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case je.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case je.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=je.NONE}}function s_(i){this.enabled!==!1&&i.preventDefault()}function a_(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function o_(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const l_=16317439,c_=[16748467,16762967,8246268,10980346,8843180,16478597,3718648,15772668,16639626,6220500],h_=[16758891,6333946,3462041,15235577,16436245,6220500,12616956,16020150,10741301,9684477],wi=1700,u_={x:1.42,y:.84,z:1},f_={x:1,y:1,z:1};function fl(i,e={}){const t=e.selectedKey??null,n=vc(i,t),r=d_(n.edges,t),s=t?ml(n,t):null,a=n.nodes.map(l=>{const u=m_(l.key,t,r),m=La(l.key),h=__(l,u,t,m),d=M_(l,u),x=S_(l,u,n.nodes.length,s);return{key:l.key,node:l,x:h.x,y:h.y,z:h.z,radius:d,color:b_(l),state:u,labelTier:x,opacity:E_(u),seed:m}}),o=new Map(a.map(l=>[l.key,l])),c=n.edges.flatMap(l=>{const u=o.get(l.sourceKey),m=o.get(l.targetKey);if(!u||!m)return[];const h=!!(t&&(l.sourceKey===t||l.targetKey===t)),d=!!(t&&!h),x=d?.018:h?.32+Math.min(.2,l.weight*.2):l.visibility===2?.09:.06;return[{edge:l,source:u,target:m,color:u.color,alpha:x,width:p_(l,h,d),highlighted:h}]});return{nodes:a,edges:c,selectedNeighborKeys:r,bounds:y_(a,!!t)}}function d_(i,e){const t=new Set;if(!e)return t;for(const n of i)n.sourceKey===e&&t.add(n.targetKey),n.targetKey===e&&t.add(n.sourceKey);return t}function p_(i,e,t){const n=.75+Math.log10(i.weight+1)*.7+(i.visibility===2?.18:0);return e?Math.min(2.2,Math.max(1.65,n+.65)):t?Math.min(.8,Math.max(.55,n*.58)):Math.min(1.35,Math.max(.85,n))}function m_(i,e,t){return e?i===e?"selected":t.has(i)?"neighbor":"dimmed":"normal"}function __(i,e,t,n){if(e==="selected")return{x:0,y:0,z:0};if(!t&&i.kind==="owner")return{x:0,y:0,z:0};const r=g_(i,t),s=x_(i,e,!!t,n),a=t?f_:u_;return{x:zs(r.x*s*a.x,2),y:zs(r.y*s*a.y,2),z:zs(r.z*s*a.z,2)}}function g_(i,e){const t=e??"panorama",n=dl(`community:${t}:${i.communityId||"default"}`),r=dl(`node:${t}:${i.key}`),s=e?.7:1.15,a=e?1.15:.95;return A_({x:n.x*s+r.x*a,y:n.y*s+r.y*a,z:n.z*s+r.z*a})}function x_(i,e,t,n){const r=v_(i),s=(n-.5)*120;if(t&&e==="neighbor")return Un(980-r*650+s,220,1050);if(t&&e==="dimmed")return Un(1670-r*260+s,1280,wi);const a=i.pool==="friend"?280:620,o=i.pool==="friend"?1180:wi,c=i.pool==="non_friend"?Math.max(0,(i.rank-80)/220)*160:0;return Un(o-r*(o-a)+c+s,180,wi)}function v_(i){if(i.kind==="owner")return 1;const e=Un(i.score,0,1),t=Un(1-(i.rank-1)/120,0,1),n=Un(Math.log10(i.privateMessageCount+1)/4,0,1),r=Un(Math.log10(i.groupMessageCount+1)/4.5,0,1),s=i.pool==="friend"?.12:0;return Un(e*.36+t*.36+n*.18+r*.08+s,0,1)}function M_(i,e){let t=Math.max(i.size*.5,i.kind==="owner"?14:1.6);const n=Math.max(0,1-(i.rank-1)/50);return t+=Math.pow(n,1.35)*6,i.rank<=3?t+=2.5:i.rank<=10&&(t+=1.2),e==="selected"?t+5.5:e==="neighbor"?t+1.5:t}function S_(i,e,t,n){return n?n.has(i.key)?e==="selected"||i.kind==="owner"?2:1:0:e==="selected"||i.labelVisibility===2||i.kind==="owner"?2:e==="neighbor"&&i.rank<=30||i.labelVisibility===1&&t<=300||i.rank<=6?1:0}function E_(i){return i==="selected"?1:i==="neighbor"?.95:i==="dimmed"?.1:.82}function y_(i,e){if(i.length===0)return{minX:-500,maxX:500,minY:-500,maxY:500,minZ:-wi,maxZ:wi,width:1e3,height:1e3,depth:wi*2};let t=0,n=0,r=0;for(const l of i)t=Math.max(t,Math.abs(l.x)),n=Math.max(n,Math.abs(l.y)),r=Math.max(r,Math.abs(l.z));const s=Math.max(400,t,n,r);if(e)return{minX:-s,maxX:s,minY:-s,maxY:s,minZ:-s,maxZ:s,width:s*2,height:s*2,depth:s*2};const a=Math.max(400,t),o=Math.max(400,n),c=Math.max(400,r);return{minX:-a,maxX:a,minY:-o,maxY:o,minZ:-c,maxZ:c,width:a*2,height:o*2,depth:c*2}}function b_(i){return i.kind==="owner"?l_:T_(i)}function T_(i){const e=i.pool==="friend"?c_:h_,t=ic(`${i.communityId}:${i.key}:${i.rank}:${i.pool}`)%e.length;return e[t]??e[0]}function dl(i){const e=La(`${i}:azimuth`)*Math.PI*2,t=La(`${i}:z`)*2-1,n=Math.sqrt(Math.max(0,1-t*t));return{x:Math.cos(e)*n,y:Math.sin(e)*n,z:t}}function A_(i){const e=Math.hypot(i.x,i.y,i.z);return e<=1e-4?{x:1,y:0,z:0}:{x:i.x/e,y:i.y/e,z:i.z/e}}function La(i){return ic(i)/4294967295}function ic(i){let e=2166136261;for(let t=0;t<i.length;t++)e^=i.charCodeAt(t),e=Math.imul(e,16777619);return e>>>0}function zs(i,e=2){const t=10**e;return Math.round(i*t)/t}function Un(i,e,t){return Math.min(t,Math.max(e,i))}const R_=6;function w_(i,e,t){const n=i.distanceTo(e);if(n<=.001)return[i.clone(),e.clone()];const r=e.clone().sub(i).normalize(),s=new D(0,1,0);Math.abs(r.y)>.9&&s.set(1,0,0);const a=new D().crossVectors(r,s).normalize(),o=new D().crossVectors(r,a).normalize(),c=C_(a,o,t).multiplyScalar(Math.max(5,n*.08)),l=i.clone().lerp(e,.5).add(c);return new zh(i,l,e).getPoints(R_)}function C_(i,e,t){const n=t*7.1%1-.5,r=t*13.3%1-.5,s=i.clone().multiplyScalar(n).add(e.clone().multiplyScalar(r));return s.lengthSq()<=1e-4?i.clone():s.normalize()}const P_=new ze(16777215);function D_(i,e,t,n,r){return i.copy(e).lerp(t,L_(r)),i.lerp(P_,I_(n)),i.multiplyScalar(U_(n)),i}function L_(i){return i<=0?0:i>=1?1:i}function I_(i){return i==="highlight"?.06:i==="normal"?.16:.26}function U_(i){return i==="highlight"?1:i==="normal"?.56:.38}const pl=.9;function N_(i){const e=Math.max(i.width,i.height,i.depth,900);return{position:{x:0,y:-e*.5*pl,z:e*.5*pl},target:{x:0,y:0,z:0}}}function F_(i,e){const t=_l(e),n=Math.max(1,e.viewportWidth);if(t<=0)return i;const r=V_({x:i.target.x-i.position.x,y:i.target.y-i.position.y,z:i.target.z-i.position.z}),s=Math.max(1,G_(i.position,i.target)),a=Math.max(.001,(n-t)/n),o=s/a;return{position:B_(i.target,z_(r,-o)),target:i.target}}function O_(i){const e=Math.max(1,Math.floor(i.viewportWidth)),t=Math.max(1,Math.floor(i.viewportHeight)),n=Math.floor(_l(i));return n<=0?null:{fullWidth:e+n,fullHeight:t,offsetX:n,offsetY:0,width:e,height:t}}function B_(i,e){return{x:i.x+e.x,y:i.y+e.y,z:i.z+e.z}}function z_(i,e){return{x:i.x*e,y:i.y*e,z:i.z*e}}function G_(i,e){return Math.hypot(i.x-e.x,i.y-e.y,i.z-e.z)}function V_(i){const e=Math.hypot(i.x,i.y,i.z);return e<=0?{x:1,y:0,z:0}:{x:i.x/e,y:i.y/e,z:i.z/e}}const H_=["aria-label"],k_={class:"pointer-events-none absolute inset-0 z-10 overflow-hidden"},W_=["onBlur","onClick","onFocus","onMouseenter","onMouseleave"],X_=lc({__name:"RelationshipGalaxyThreeCanvas",props:{graph:{},selectedKey:{default:null},privacyMode:{type:Boolean,default:!1},safeInsetRight:{default:0},label:{},ownerLabel:{}},emits:["select-node","fallback"],setup(i,{expose:e,emit:t}){const n=i,r=t,s=io(null),a=jr([]),o=io(null),c=jr(fl(n.graph,{selectedKey:n.selectedKey})),l=jr(null);let u=null,m=null,h=null,d=null,x=null,y=0,_=0,f=0,w=!1,C=null,S=null;const R=new Nn,b=new Nn,P=new Nn,g=new Map,T=[],U=new Map,L=new Zh,z=new Ce,$=new D;function j(A){if(A.kind==="owner")return n.ownerLabel;const M=A.displayName||A.platformId||A.key;return n.privacyMode?Mc(M):M}function H(){const A=s.value?.getBoundingClientRect();return{width:Math.max(1,Math.floor(A?.width??1)),height:Math.max(1,Math.floor(A?.height??1))}}function Z(A,M){const B=(M.bounds.minX+M.bounds.maxX)/2,N=(M.bounds.minY+M.bounds.maxY)/2;return new D(A.x-B,-(A.y-N),A.z)}function X(A=!1){if(!m||!h||!u)return;const M=fl(n.graph,{selectedKey:n.selectedKey});c.value=M,te(),ae(b),ae(P),g.clear(),T.length=0,U.clear(),o.value=null,f=0,a.value=[];for(const B of M.edges)U.has(B.edge.sourceKey)||U.set(B.edge.sourceKey,new Set),U.has(B.edge.targetKey)||U.set(B.edge.targetKey,new Set),U.get(B.edge.sourceKey).add(B.edge.targetKey),U.get(B.edge.targetKey).add(B.edge.sourceKey);ie(M,"dim"),ie(M,"normal"),ie(M,"highlight");for(const B of M.nodes){const N=Z(B,M),ee=Ye(B,N);g.set(B.key,ee),T.push(ee.core),P.add(ee.group)}(A||!w)&&yt(),xt()}function te(){l.value=n.selectedKey?ml(n.graph,n.selectedKey):null}function ie(A,M){const B=A.edges.filter(N=>M==="highlight"?N.highlighted:M==="dim"?N.alpha<=.05:!N.highlighted&&N.alpha>.05);if(B.length!==0)for(const N of Me(B,M))fe(A,N.edges,M,N.linewidth)}function fe(A,M,B,N){const ee=new Hl({vertexColors:!0,transparent:!0,opacity:B==="highlight"?.62:B==="normal"?.21:.05,linewidth:N,blending:On,depthTest:!0,depthWrite:!1}),ne=new ze,q=new ze,de=new ze,ue=[],Ge=[];for(const st of M){const Sn=Z(st.source,A),Jr=Z(st.target,A),Hn=w_(Sn,Jr,st.source.seed+st.target.seed),ti=Math.max(1,Hn.length-1);ne.setHex(st.source.color),q.setHex(st.target.color);for(let En=0;En<Hn.length-1;En+=1){const ni=Hn[En],ii=Hn[En+1];ue.push(ni.x,ni.y,ni.z,ii.x,ii.y,ii.z),me(Ge,de,ne,q,B,En/ti),me(Ge,de,ne,q,B,(En+1)/ti)}}if(ue.length===0){ee.dispose();return}const Ie=new Xt;Ie.setAttribute("position",new zt(ue,3)),Ie.setAttribute("color",new zt(Ge,3));const ct=new Lh(Ie,ee);ct.frustumCulled=!1,b.add(ct)}function me(A,M,B,N,ee,ne){D_(M,B,N,ee,ne),A.push(M.r,M.g,M.b)}function Me(A,M){const B=new Map;for(const N of A){const ee=Xe(N,M),ne=B.get(ee)??[];ne.push(N),B.set(ee,ne)}return[...B.entries()].map(([N,ee])=>({linewidth:N,edges:ee}))}function Xe(A,M){return M==="highlight"?A.width>=2?2:1.65:M==="dim"?.55:A.width>=1.2?1.12:A.width>=.95?.96:.82}function rt(A){return A.state==="selected"?2.18:A.node.kind==="owner"?2.04:A.node.rank<=10?1.76:1.52}function Ye(A,M){const B=new Nn;B.position.copy(M);const N=new Th(new Bl({map:he(A.color,Math.floor(A.seed*8)),color:16777215,transparent:!0,opacity:A.opacity,blending:On,depthWrite:!1,alphaTest:.02}));return N.scale.setScalar(A.radius*rt(A)),N.userData.key=A.key,B.add(N),{group:B,core:N,sceneNode:A,basePosition:M,phase:A.seed*Math.PI*2}}function Q(){if(!u||!m||!h||!d)return;const A=performance.now()-_;le();const M=w?.003:.008;R.rotation.y=Math.sin(A/25e3)*M,R.rotation.x=Math.cos(A/3e4)*M*.4;const B=o.value||n.selectedKey;for(const N of g.values()){const ee=A/1e3+N.phase,ne=N.sceneNode.key===n.selectedKey,q=N.sceneNode.key===B,de=!!(B&&U.get(B)?.has(N.sceneNode.key)),ue=ne?.3:.8,Ge=o.value===N.sceneNode.key?1.28:1,Ie=ne?1.22:1,ct=de?1.08:1;N.group.position.set(N.basePosition.x+Math.sin(ee*.3)*2*ue,N.basePosition.y+Math.cos(ee*.25)*1.5*ue,N.basePosition.z+Math.sin(ee*.2)*4*ue),N.group.scale.setScalar((1+Math.sin(ee*.8)*.006)*Ge*Ie*ct);const st=N.core.material;let Sn=N.sceneNode.opacity;B&&(q?Sn=1:de?Sn=.85:Sn=.1),st.opacity+=(Sn-st.opacity)*.16}d.update(),re(),u.render(m,h),y=requestAnimationFrame(Q)}function le(){if(!d||!h||!S)return;const A=Math.min(1,(performance.now()-S.startedAt)/S.duration),M=J(A);h.position.lerpVectors(S.fromPosition,S.toPosition,M),d.target.lerpVectors(S.fromTarget,S.toTarget,M),A>=1&&(S=null)}function re(){if(!u||!h||(f+=1,f%2!==0))return;const{width:A,height:M}=H(),B=[],N=n.selectedKey,ee=N?U.get(N):null;for(const ne of g.values()){const q=ne.sceneNode.key===N,de=!!(N&&ee?.has(ne.sceneNode.key)),ue=Pe(ne.sceneNode,N??null,o.value);if(ue===0)continue;ne.group.getWorldPosition($);const Ge=$.clone().project(h);if(Ge.z<-1||Ge.z>1)continue;const Ie=(Ge.x*.5+.5)*A,ct=(-Ge.y*.5+.5)*M;Ie<-80||Ie>A+80||ct<-40||ct>M+40||B.push({key:ne.sceneNode.key,text:j(ne.sceneNode.node),x:Ie,y:ct+ne.sceneNode.radius+8,opacity:q?1:Math.max(.42,ne.core.material.opacity),selected:q,emphasis:De(ne.sceneNode,de,ue)})}a.value=B}function Pe(A,M,B){return A.key===B?A.labelTier===2?2:1:M?l.value?.has(A.key)?A.key===M||A.node.kind==="owner"?2:1:0:A.labelTier}function De(A,M=!1,B=A.labelTier){return B===2||A.node.kind==="owner"||A.node.rank<=5?"major":M||A.node.rank<=30?"medium":"minor"}async function Re(){const A=s.value;if(!A||u)return;const M=H();m=new vh,m.fog=new Wa(656643,32e-5),h=new Ht(45,M.width/M.height,1,3e4),h.position.set(0,-150,900);try{u=new qm({antialias:!0,alpha:!0,powerPreference:"high-performance"})}catch(B){console.warn("relationship galaxy 3d renderer unavailable",B),r("fallback");return}u.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),u.setSize(M.width,M.height),u.outputColorSpace=Ut,u.domElement.className="h-full w-full",A.appendChild(u.domElement),d=new Zm(h,u.domElement),d.enableDamping=!0,d.dampingFactor=.055,d.rotateSpeed=.34,d.zoomSpeed=.72,d.panSpeed=.58,d.minDistance=160,d.maxDistance=9e3,d.addEventListener("start",()=>{w=!0,S=null}),R.add(b),R.add(P),m.add(R),u.domElement.addEventListener("pointermove",Fe),u.domElement.addEventListener("pointerleave",Ze),u.domElement.addEventListener("click",We),x=new ResizeObserver(ot),x.observe(A),X(!0),_=performance.now(),y=requestAnimationFrame(Q)}function ot(){if(!u||!h)return;const A=H();h.aspect=A.width/A.height,u.setSize(A.width,A.height),E(A)}function Fe(A){if(!u||!h)return;const M=u.domElement.getBoundingClientRect();z.x=(A.clientX-M.left)/M.width*2-1,z.y=-((A.clientY-M.top)/M.height)*2+1,L.setFromCamera(z,h);const[B]=L.intersectObjects(T,!1);o.value=typeof B?.object.userData.key=="string"?B.object.userData.key:null}function Ze(){o.value=null}function We(){const A=o.value;if(!A)return;const M=g.get(A);M&&r("select-node",M.sceneNode.node)}function Ve(A){const M=g.get(A);M&&r("select-node",M.sceneNode.node)}function lt(A){o.value=A}function ht(A){o.value===A&&(o.value=null)}function _t(A){A.preventDefault(),A.stopPropagation();const M=u?.domElement;M&&M.dispatchEvent(new WheelEvent("wheel",{bubbles:!0,cancelable:!0,clientX:A.clientX,clientY:A.clientY,ctrlKey:A.ctrlKey,deltaMode:A.deltaMode,deltaX:A.deltaX,deltaY:A.deltaY,deltaZ:A.deltaZ,metaKey:A.metaKey,screenX:A.screenX,screenY:A.screenY,shiftKey:A.shiftKey}))}function xt(){if(!C)return;const A=C;if(!g.has(A)){C=null;return}it(A)}function it(A){if(!h||!d)return C=A,!1;const M=g.get(A);if(!M)return C=A,!1;C=null,w=!0;const B=M.basePosition.clone(),N=Math.max(180,Math.min(600,c.value.bounds.width*.18)),ee=Ke({position:p(B.clone().add(new D(0,-N*.25,N))),target:p(B)});return se(new D(ee.position.x,ee.position.y,ee.position.z),new D(ee.target.x,ee.target.y,ee.target.z),540),!0}function ut(){return!h||!d?null:{kind:"3d",position:p(h.position),target:p(d.target),hasUserMovedCamera:w}}function I(A){return!O(A)||!h||!d?!1:(C=null,w=A.hasUserMovedCamera,E(),se(new D(A.position.x,A.position.y,A.position.z),new D(A.target.x,A.target.y,A.target.z),620),!0)}function yt(){if(!h||!d)return;w=!1;const A=Ke(N_(c.value.bounds));se(new D(A.position.x,A.position.y,A.position.z),new D(A.target.x,A.target.y,A.target.z),620)}function Ke(A){const M=H();return E(M),F_(A,{viewportWidth:M.width,viewportHeight:M.height,safeInsetRight:n.safeInsetRight,fovDegrees:h?.fov??45})}function E(A=H()){if(!h)return;const M=O_({viewportWidth:A.width,viewportHeight:A.height,safeInsetRight:n.safeInsetRight});if(!M){h.clearViewOffset();return}h.setViewOffset(M.fullWidth,M.fullHeight,M.offsetX,M.offsetY,M.width,M.height)}function p(A){return{x:A.x,y:A.y,z:A.z}}function O(A){return Y(A)?A.kind==="3d"&&k(A.position)&&k(A.target)&&typeof A.hasUserMovedCamera=="boolean":!1}function k(A){return Y(A)?typeof A.x=="number"&&Number.isFinite(A.x)&&typeof A.y=="number"&&Number.isFinite(A.y)&&typeof A.z=="number"&&Number.isFinite(A.z):!1}function Y(A){return typeof A=="object"&&A!==null}function se(A,M,B){!h||!d||(S={startedAt:performance.now(),duration:B,fromPosition:h.position.clone(),toPosition:A,fromTarget:d.target.clone(),toTarget:M})}function ae(A){for(;A.children.length>0;){const M=A.children.pop();M&&K(M)}}function K(A){A.traverse(M=>{const B=M;if(B.geometry?.dispose(),Array.isArray(B.material))for(const N of B.material)N.dispose();else B.material?.dispose()})}function J(A){return A<.5?4*A*A*A:1-Math.pow(-2*A+2,3)/2}function oe(A){const M=Math.sin(A*12.9898)*43758.5453;return M-Math.floor(M)}const Se=new Map;function he(A,M){const N=`star:${A.toString(16).padStart(6,"0")}:${M}`,ee=Se.get(N);if(ee)return ee;const ne=document.createElement("canvas");ne.width=128,ne.height=128;const q=ne.getContext("2d");if(!q)throw new Error("failed to create galaxy texture context");const de=new ze(A),ue=1.04+oe(M+4.2)*.06,Ge=.94+oe(M+9.8)*.05,Ie=(oe(M+17.4)-.5)*.32,ct=.18+oe(M+21.7)*.12;ce(q,ue,Ge,Ie,38,[[0,"rgba(255,255,255,0.1)"],[.26,be(de,.16)],[.58,be(de,.04)],[1,"rgba(255,255,255,0)"]]),ye(q,Ie,48,2.2,ct,de),ye(q,Ie+Math.PI/2,32,1.35,ct*.62,de),M%3===0&&ye(q,Ie+Math.PI/4,22,.9,ct*.34,de),ce(q,ue,Ge,Ie,18,[[0,"rgba(255,255,255,1)"],[.28,"rgba(255,255,255,0.94)"],[.54,be(de,.95)],[.78,be(de,.38)],[1,"rgba(255,255,255,0)"]]);const st=new Ih(ne);return st.colorSpace=Ut,Se.set(N,st),st}function ce(A,M,B,N,ee,ne){A.save(),A.translate(64,64),A.rotate(N),A.scale(M,B);const q=A.createRadialGradient(0,0,0,0,0,ee);for(const[de,ue]of ne)q.addColorStop(de,ue);A.fillStyle=q,A.beginPath(),A.arc(0,0,ee,0,Math.PI*2),A.fill(),A.restore()}function ye(A,M,B,N,ee,ne){A.save(),A.translate(64,64),A.rotate(M);const q=A.createLinearGradient(-B,0,B,0);q.addColorStop(0,"rgba(255,255,255,0)"),q.addColorStop(.43,be(ne,ee*.32)),q.addColorStop(.5,`rgba(255,255,255,${ee})`),q.addColorStop(.57,be(ne,ee*.32)),q.addColorStop(1,"rgba(255,255,255,0)"),A.fillStyle=q,A.fillRect(-B,-N/2,B*2,N),A.restore()}function be(A,M){return`rgba(${Math.round(A.r*255)},${Math.round(A.g*255)},${Math.round(A.b*255)},${M})`}return cc(async()=>{await hc(),await Re()}),es(()=>n.graph,()=>{X(!1)},{flush:"post"}),es(()=>n.selectedKey,()=>{X(!1)},{flush:"post"}),es(()=>n.privacyMode,()=>{f=1,re()},{flush:"post"}),uc(()=>{y&&cancelAnimationFrame(y),x?.disconnect(),x=null,u&&(u.domElement.removeEventListener("pointermove",Fe),u.domElement.removeEventListener("pointerleave",Ze),u.domElement.removeEventListener("click",We)),ae(b),ae(P);for(const A of Se.values())A.dispose();Se.clear(),R.clear(),m?.clear(),d?.dispose(),u?.dispose(),u?.domElement.remove(),u=null,m=null,h=null,d=null,a.value=[]}),e({focusNode:it,fitView:yt,captureView:ut,restoreView:I}),(A,M)=>(ts(),ns("div",{ref_key:"canvasRoot",ref:s,class:"relationship-galaxy-3d relative h-full w-full overflow-hidden",role:"img","aria-label":i.label},[fc("div",k_,[(ts(!0),ns(dc,null,pc(a.value,B=>(ts(),ns("button",{key:B.key,type:"button",class:gc(["relationship-galaxy-3d__label",[`relationship-galaxy-3d__label--${B.emphasis}`,{"relationship-galaxy-3d__label--selected":B.selected}]]),style:_c({left:`${B.x}px`,top:`${B.y}px`,opacity:B.opacity}),onBlur:N=>ht(B.key),onClick:mc(N=>Ve(B.key),["stop"]),onFocus:N=>lt(B.key),onMouseenter:N=>lt(B.key),onMouseleave:N=>ht(B.key),onWheel:_t},xc(B.text),47,W_))),128))])],8,H_))}}),eg=Sc(X_,[["__scopeId","data-v-9c0ee911"]]);export{eg as default};
4108
+ }`;class Gm{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new Wl(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new ln({vertexShader:Bm,fragmentShader:zm,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Mn(new Zr(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Vm extends Vn{constructor(e,t){super();const n=this;let r=null,s=1,a=null,o="local-floor",c=1,l=null,u=null,m=null,h=null,d=null,x=null;const y=typeof XRWebGLBinding<"u",_=new Gm,f={},w=t.getContextAttributes();let C=null,S=null;const R=[],b=[],P=new Ce;let g=null;const T=new Ht;T.viewport=new dt;const U=new Ht;U.viewport=new dt;const L=[T,U],z=new Kh;let $=null,j=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Q){let le=R[Q];return le===void 0&&(le=new fs,R[Q]=le),le.getTargetRaySpace()},this.getControllerGrip=function(Q){let le=R[Q];return le===void 0&&(le=new fs,R[Q]=le),le.getGripSpace()},this.getHand=function(Q){let le=R[Q];return le===void 0&&(le=new fs,R[Q]=le),le.getHandSpace()};function H(Q){const le=b.indexOf(Q.inputSource);if(le===-1)return;const re=R[le];re!==void 0&&(re.update(Q.inputSource,Q.frame,l||a),re.dispatchEvent({type:Q.type,data:Q.inputSource}))}function Z(){r.removeEventListener("select",H),r.removeEventListener("selectstart",H),r.removeEventListener("selectend",H),r.removeEventListener("squeeze",H),r.removeEventListener("squeezestart",H),r.removeEventListener("squeezeend",H),r.removeEventListener("end",Z),r.removeEventListener("inputsourceschange",X);for(let Q=0;Q<R.length;Q++){const le=b[Q];le!==null&&(b[Q]=null,R[Q].disconnect(le))}$=null,j=null,_.reset();for(const Q in f)delete f[Q];e.setRenderTarget(C),d=null,h=null,m=null,r=null,S=null,Ye.stop(),n.isPresenting=!1,e.setPixelRatio(g),e.setSize(P.width,P.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Q){s=Q,n.isPresenting===!0&&we("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Q){o=Q,n.isPresenting===!0&&we("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(Q){l=Q},this.getBaseLayer=function(){return h!==null?h:d},this.getBinding=function(){return m===null&&y&&(m=new XRWebGLBinding(r,t)),m},this.getFrame=function(){return x},this.getSession=function(){return r},this.setSession=async function(Q){if(r=Q,r!==null){if(C=e.getRenderTarget(),r.addEventListener("select",H),r.addEventListener("selectstart",H),r.addEventListener("selectend",H),r.addEventListener("squeeze",H),r.addEventListener("squeezestart",H),r.addEventListener("squeezeend",H),r.addEventListener("end",Z),r.addEventListener("inputsourceschange",X),w.xrCompatible!==!0&&await t.makeXRCompatible(),g=e.getPixelRatio(),e.getSize(P),y&&"createProjectionLayer"in XRWebGLBinding.prototype){let re=null,Pe=null,De=null;w.depth&&(De=w.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,re=w.stencil?Jn:vn,Pe=w.stencil?Ki:on);const Re={colorFormat:t.RGBA8,depthFormat:De,scaleFactor:s};m=this.getBinding(),h=m.createProjectionLayer(Re),r.updateRenderState({layers:[h]}),e.setPixelRatio(1),e.setSize(h.textureWidth,h.textureHeight,!1),S=new an(h.textureWidth,h.textureHeight,{format:Zt,type:kt,depthTexture:new Di(h.textureWidth,h.textureHeight,Pe,void 0,void 0,void 0,void 0,void 0,void 0,re),stencilBuffer:w.stencil,colorSpace:e.outputColorSpace,samples:w.antialias?4:0,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1})}else{const re={antialias:w.antialias,alpha:!0,depth:w.depth,stencil:w.stencil,framebufferScaleFactor:s};d=new XRWebGLLayer(r,t,re),r.updateRenderState({baseLayer:d}),e.setPixelRatio(1),e.setSize(d.framebufferWidth,d.framebufferHeight,!1),S=new an(d.framebufferWidth,d.framebufferHeight,{format:Zt,type:kt,colorSpace:e.outputColorSpace,stencilBuffer:w.stencil,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}S.isXRRenderTarget=!0,this.setFoveation(c),l=null,a=await r.requestReferenceSpace(o),Ye.setContext(r),Ye.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return _.getDepthTexture()};function X(Q){for(let le=0;le<Q.removed.length;le++){const re=Q.removed[le],Pe=b.indexOf(re);Pe>=0&&(b[Pe]=null,R[Pe].disconnect(re))}for(let le=0;le<Q.added.length;le++){const re=Q.added[le];let Pe=b.indexOf(re);if(Pe===-1){for(let Re=0;Re<R.length;Re++)if(Re>=b.length){b.push(re),Pe=Re;break}else if(b[Re]===null){b[Re]=re,Pe=Re;break}if(Pe===-1)break}const De=R[Pe];De&&De.connect(re)}}const te=new D,ie=new D;function fe(Q,le,re){te.setFromMatrixPosition(le.matrixWorld),ie.setFromMatrixPosition(re.matrixWorld);const Pe=te.distanceTo(ie),De=le.projectionMatrix.elements,Re=re.projectionMatrix.elements,ot=De[14]/(De[10]-1),Fe=De[14]/(De[10]+1),Ze=(De[9]+1)/De[5],We=(De[9]-1)/De[5],Ve=(De[8]-1)/De[0],lt=(Re[8]+1)/Re[0],ht=ot*Ve,_t=ot*lt,xt=Pe/(-Ve+lt),it=xt*-Ve;if(le.matrixWorld.decompose(Q.position,Q.quaternion,Q.scale),Q.translateX(it),Q.translateZ(xt),Q.matrixWorld.compose(Q.position,Q.quaternion,Q.scale),Q.matrixWorldInverse.copy(Q.matrixWorld).invert(),De[10]===-1)Q.projectionMatrix.copy(le.projectionMatrix),Q.projectionMatrixInverse.copy(le.projectionMatrixInverse);else{const ut=ot+xt,I=Fe+xt,yt=ht-it,Ke=_t+(Pe-it),E=Ze*Fe/I*ut,p=We*Fe/I*ut;Q.projectionMatrix.makePerspective(yt,Ke,E,p,ut,I),Q.projectionMatrixInverse.copy(Q.projectionMatrix).invert()}}function me(Q,le){le===null?Q.matrixWorld.copy(Q.matrix):Q.matrixWorld.multiplyMatrices(le.matrixWorld,Q.matrix),Q.matrixWorldInverse.copy(Q.matrixWorld).invert()}this.updateCamera=function(Q){if(r===null)return;let le=Q.near,re=Q.far;_.texture!==null&&(_.depthNear>0&&(le=_.depthNear),_.depthFar>0&&(re=_.depthFar)),z.near=U.near=T.near=le,z.far=U.far=T.far=re,($!==z.near||j!==z.far)&&(r.updateRenderState({depthNear:z.near,depthFar:z.far}),$=z.near,j=z.far),z.layers.mask=Q.layers.mask|6,T.layers.mask=z.layers.mask&-5,U.layers.mask=z.layers.mask&-3;const Pe=Q.parent,De=z.cameras;me(z,Pe);for(let Re=0;Re<De.length;Re++)me(De[Re],Pe);De.length===2?fe(z,T,U):z.projectionMatrix.copy(T.projectionMatrix),Me(Q,z,Pe)};function Me(Q,le,re){re===null?Q.matrix.copy(le.matrixWorld):(Q.matrix.copy(re.matrixWorld),Q.matrix.invert(),Q.matrix.multiply(le.matrixWorld)),Q.matrix.decompose(Q.position,Q.quaternion,Q.scale),Q.updateMatrixWorld(!0),Q.projectionMatrix.copy(le.projectionMatrix),Q.projectionMatrixInverse.copy(le.projectionMatrixInverse),Q.isPerspectiveCamera&&(Q.fov=wa*2*Math.atan(1/Q.projectionMatrix.elements[5]),Q.zoom=1)}this.getCamera=function(){return z},this.getFoveation=function(){if(!(h===null&&d===null))return c},this.setFoveation=function(Q){c=Q,h!==null&&(h.fixedFoveation=Q),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=Q)},this.hasDepthSensing=function(){return _.texture!==null},this.getDepthSensingMesh=function(){return _.getMesh(z)},this.getCameraTexture=function(Q){return f[Q]};let Xe=null;function rt(Q,le){if(u=le.getViewerPose(l||a),x=le,u!==null){const re=u.views;d!==null&&(e.setRenderTargetFramebuffer(S,d.framebuffer),e.setRenderTarget(S));let Pe=!1;re.length!==z.cameras.length&&(z.cameras.length=0,Pe=!0);for(let Fe=0;Fe<re.length;Fe++){const Ze=re[Fe];let We=null;if(d!==null)We=d.getViewport(Ze);else{const lt=m.getViewSubImage(h,Ze);We=lt.viewport,Fe===0&&(e.setRenderTargetTextures(S,lt.colorTexture,lt.depthStencilTexture),e.setRenderTarget(S))}let Ve=L[Fe];Ve===void 0&&(Ve=new Ht,Ve.layers.enable(Fe),Ve.viewport=new dt,L[Fe]=Ve),Ve.matrix.fromArray(Ze.transform.matrix),Ve.matrix.decompose(Ve.position,Ve.quaternion,Ve.scale),Ve.projectionMatrix.fromArray(Ze.projectionMatrix),Ve.projectionMatrixInverse.copy(Ve.projectionMatrix).invert(),Ve.viewport.set(We.x,We.y,We.width,We.height),Fe===0&&(z.matrix.copy(Ve.matrix),z.matrix.decompose(z.position,z.quaternion,z.scale)),Pe===!0&&z.cameras.push(Ve)}const De=r.enabledFeatures;if(De&&De.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&y){m=n.getBinding();const Fe=m.getDepthInformation(re[0]);Fe&&Fe.isValid&&Fe.texture&&_.init(Fe,r.renderState)}if(De&&De.includes("camera-access")&&y){e.state.unbindTexture(),m=n.getBinding();for(let Fe=0;Fe<re.length;Fe++){const Ze=re[Fe].camera;if(Ze){let We=f[Ze];We||(We=new Wl,f[Ze]=We);const Ve=m.getCameraImage(Ze);We.sourceTexture=Ve}}}}for(let re=0;re<R.length;re++){const Pe=b[re],De=R[re];Pe!==null&&De!==void 0&&De.update(Pe,le,l||a)}Xe&&Xe(Q,le),le.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:le}),x=null}const Ye=new Kl;Ye.setAnimationLoop(rt),this.setAnimationLoop=function(Q){Xe=Q},this.dispose=function(){}}}const Hm=new at,tc=new Le;tc.set(-1,0,0,0,1,0,0,0,1);function km(i,e){function t(_,f){_.matrixAutoUpdate===!0&&_.updateMatrix(),f.value.copy(_.matrix)}function n(_,f){f.color.getRGB(_.fogColor.value,Xl(i)),f.isFog?(_.fogNear.value=f.near,_.fogFar.value=f.far):f.isFogExp2&&(_.fogDensity.value=f.density)}function r(_,f,w,C,S){f.isNodeMaterial?f.uniformsNeedUpdate=!1:f.isMeshBasicMaterial?s(_,f):f.isMeshLambertMaterial?(s(_,f),f.envMap&&(_.envMapIntensity.value=f.envMapIntensity)):f.isMeshToonMaterial?(s(_,f),m(_,f)):f.isMeshPhongMaterial?(s(_,f),u(_,f),f.envMap&&(_.envMapIntensity.value=f.envMapIntensity)):f.isMeshStandardMaterial?(s(_,f),h(_,f),f.isMeshPhysicalMaterial&&d(_,f,S)):f.isMeshMatcapMaterial?(s(_,f),x(_,f)):f.isMeshDepthMaterial?s(_,f):f.isMeshDistanceMaterial?(s(_,f),y(_,f)):f.isMeshNormalMaterial?s(_,f):f.isLineBasicMaterial?(a(_,f),f.isLineDashedMaterial&&o(_,f)):f.isPointsMaterial?c(_,f,w,C):f.isSpriteMaterial?l(_,f):f.isShadowMaterial?(_.color.value.copy(f.color),_.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function s(_,f){_.opacity.value=f.opacity,f.color&&_.diffuse.value.copy(f.color),f.emissive&&_.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity),f.map&&(_.map.value=f.map,t(f.map,_.mapTransform)),f.alphaMap&&(_.alphaMap.value=f.alphaMap,t(f.alphaMap,_.alphaMapTransform)),f.bumpMap&&(_.bumpMap.value=f.bumpMap,t(f.bumpMap,_.bumpMapTransform),_.bumpScale.value=f.bumpScale,f.side===Nt&&(_.bumpScale.value*=-1)),f.normalMap&&(_.normalMap.value=f.normalMap,t(f.normalMap,_.normalMapTransform),_.normalScale.value.copy(f.normalScale),f.side===Nt&&_.normalScale.value.negate()),f.displacementMap&&(_.displacementMap.value=f.displacementMap,t(f.displacementMap,_.displacementMapTransform),_.displacementScale.value=f.displacementScale,_.displacementBias.value=f.displacementBias),f.emissiveMap&&(_.emissiveMap.value=f.emissiveMap,t(f.emissiveMap,_.emissiveMapTransform)),f.specularMap&&(_.specularMap.value=f.specularMap,t(f.specularMap,_.specularMapTransform)),f.alphaTest>0&&(_.alphaTest.value=f.alphaTest);const w=e.get(f),C=w.envMap,S=w.envMapRotation;C&&(_.envMap.value=C,_.envMapRotation.value.setFromMatrix4(Hm.makeRotationFromEuler(S)).transpose(),C.isCubeTexture&&C.isRenderTargetTexture===!1&&_.envMapRotation.value.premultiply(tc),_.reflectivity.value=f.reflectivity,_.ior.value=f.ior,_.refractionRatio.value=f.refractionRatio),f.lightMap&&(_.lightMap.value=f.lightMap,_.lightMapIntensity.value=f.lightMapIntensity,t(f.lightMap,_.lightMapTransform)),f.aoMap&&(_.aoMap.value=f.aoMap,_.aoMapIntensity.value=f.aoMapIntensity,t(f.aoMap,_.aoMapTransform))}function a(_,f){_.diffuse.value.copy(f.color),_.opacity.value=f.opacity,f.map&&(_.map.value=f.map,t(f.map,_.mapTransform))}function o(_,f){_.dashSize.value=f.dashSize,_.totalSize.value=f.dashSize+f.gapSize,_.scale.value=f.scale}function c(_,f,w,C){_.diffuse.value.copy(f.color),_.opacity.value=f.opacity,_.size.value=f.size*w,_.scale.value=C*.5,f.map&&(_.map.value=f.map,t(f.map,_.uvTransform)),f.alphaMap&&(_.alphaMap.value=f.alphaMap,t(f.alphaMap,_.alphaMapTransform)),f.alphaTest>0&&(_.alphaTest.value=f.alphaTest)}function l(_,f){_.diffuse.value.copy(f.color),_.opacity.value=f.opacity,_.rotation.value=f.rotation,f.map&&(_.map.value=f.map,t(f.map,_.mapTransform)),f.alphaMap&&(_.alphaMap.value=f.alphaMap,t(f.alphaMap,_.alphaMapTransform)),f.alphaTest>0&&(_.alphaTest.value=f.alphaTest)}function u(_,f){_.specular.value.copy(f.specular),_.shininess.value=Math.max(f.shininess,1e-4)}function m(_,f){f.gradientMap&&(_.gradientMap.value=f.gradientMap)}function h(_,f){_.metalness.value=f.metalness,f.metalnessMap&&(_.metalnessMap.value=f.metalnessMap,t(f.metalnessMap,_.metalnessMapTransform)),_.roughness.value=f.roughness,f.roughnessMap&&(_.roughnessMap.value=f.roughnessMap,t(f.roughnessMap,_.roughnessMapTransform)),f.envMap&&(_.envMapIntensity.value=f.envMapIntensity)}function d(_,f,w){_.ior.value=f.ior,f.sheen>0&&(_.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),_.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(_.sheenColorMap.value=f.sheenColorMap,t(f.sheenColorMap,_.sheenColorMapTransform)),f.sheenRoughnessMap&&(_.sheenRoughnessMap.value=f.sheenRoughnessMap,t(f.sheenRoughnessMap,_.sheenRoughnessMapTransform))),f.clearcoat>0&&(_.clearcoat.value=f.clearcoat,_.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(_.clearcoatMap.value=f.clearcoatMap,t(f.clearcoatMap,_.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(_.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,t(f.clearcoatRoughnessMap,_.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(_.clearcoatNormalMap.value=f.clearcoatNormalMap,t(f.clearcoatNormalMap,_.clearcoatNormalMapTransform),_.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===Nt&&_.clearcoatNormalScale.value.negate())),f.dispersion>0&&(_.dispersion.value=f.dispersion),f.iridescence>0&&(_.iridescence.value=f.iridescence,_.iridescenceIOR.value=f.iridescenceIOR,_.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],_.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap&&(_.iridescenceMap.value=f.iridescenceMap,t(f.iridescenceMap,_.iridescenceMapTransform)),f.iridescenceThicknessMap&&(_.iridescenceThicknessMap.value=f.iridescenceThicknessMap,t(f.iridescenceThicknessMap,_.iridescenceThicknessMapTransform))),f.transmission>0&&(_.transmission.value=f.transmission,_.transmissionSamplerMap.value=w.texture,_.transmissionSamplerSize.value.set(w.width,w.height),f.transmissionMap&&(_.transmissionMap.value=f.transmissionMap,t(f.transmissionMap,_.transmissionMapTransform)),_.thickness.value=f.thickness,f.thicknessMap&&(_.thicknessMap.value=f.thicknessMap,t(f.thicknessMap,_.thicknessMapTransform)),_.attenuationDistance.value=f.attenuationDistance,_.attenuationColor.value.copy(f.attenuationColor)),f.anisotropy>0&&(_.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap&&(_.anisotropyMap.value=f.anisotropyMap,t(f.anisotropyMap,_.anisotropyMapTransform))),_.specularIntensity.value=f.specularIntensity,_.specularColor.value.copy(f.specularColor),f.specularColorMap&&(_.specularColorMap.value=f.specularColorMap,t(f.specularColorMap,_.specularColorMapTransform)),f.specularIntensityMap&&(_.specularIntensityMap.value=f.specularIntensityMap,t(f.specularIntensityMap,_.specularIntensityMapTransform))}function x(_,f){f.matcap&&(_.matcap.value=f.matcap)}function y(_,f){const w=e.get(f).light;_.referencePosition.value.setFromMatrixPosition(w.matrixWorld),_.nearDistance.value=w.shadow.camera.near,_.farDistance.value=w.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function Wm(i,e,t,n){let r={},s={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function c(S,R){const b=R.program;n.uniformBlockBinding(S,b)}function l(S,R){let b=r[S.id];b===void 0&&(_(S),b=u(S),r[S.id]=b,S.addEventListener("dispose",w));const P=R.program;n.updateUBOMapping(S,P);const g=e.render.frame;s[S.id]!==g&&(h(S),s[S.id]=g)}function u(S){const R=m();S.__bindingPointIndex=R;const b=i.createBuffer(),P=S.__size,g=S.usage;return i.bindBuffer(i.UNIFORM_BUFFER,b),i.bufferData(i.UNIFORM_BUFFER,P,g),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,R,b),b}function m(){for(let S=0;S<o;S++)if(a.indexOf(S)===-1)return a.push(S),S;return He("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(S){const R=r[S.id],b=S.uniforms,P=S.__cache;i.bindBuffer(i.UNIFORM_BUFFER,R);for(let g=0,T=b.length;g<T;g++){const U=b[g];if(Array.isArray(U))for(let L=0,z=U.length;L<z;L++)d(U[L],g,L,P);else d(U,g,0,P)}i.bindBuffer(i.UNIFORM_BUFFER,null)}function d(S,R,b,P){if(y(S,R,b,P)===!0){const g=S.__offset,T=S.value;if(Array.isArray(T)){let U=0;for(let L=0;L<T.length;L++){const z=T[L],$=f(z);x(z,S.__data,U),typeof z!="number"&&typeof z!="boolean"&&!z.isMatrix3&&!ArrayBuffer.isView(z)&&(U+=$.storage/Float32Array.BYTES_PER_ELEMENT)}}else x(T,S.__data,0);i.bufferSubData(i.UNIFORM_BUFFER,g,S.__data)}}function x(S,R,b){typeof S=="number"||typeof S=="boolean"?R[0]=S:S.isMatrix3?(R[0]=S.elements[0],R[1]=S.elements[1],R[2]=S.elements[2],R[3]=0,R[4]=S.elements[3],R[5]=S.elements[4],R[6]=S.elements[5],R[7]=0,R[8]=S.elements[6],R[9]=S.elements[7],R[10]=S.elements[8],R[11]=0):ArrayBuffer.isView(S)?R.set(new S.constructor(S.buffer,S.byteOffset,R.length)):S.toArray(R,b)}function y(S,R,b,P){const g=S.value,T=R+"_"+b;if(P[T]===void 0)return typeof g=="number"||typeof g=="boolean"?P[T]=g:ArrayBuffer.isView(g)?P[T]=g.slice():P[T]=g.clone(),!0;{const U=P[T];if(typeof g=="number"||typeof g=="boolean"){if(U!==g)return P[T]=g,!0}else{if(ArrayBuffer.isView(g))return!0;if(U.equals(g)===!1)return U.copy(g),!0}}return!1}function _(S){const R=S.uniforms;let b=0;const P=16;for(let T=0,U=R.length;T<U;T++){const L=Array.isArray(R[T])?R[T]:[R[T]];for(let z=0,$=L.length;z<$;z++){const j=L[z],H=Array.isArray(j.value)?j.value:[j.value];for(let Z=0,X=H.length;Z<X;Z++){const te=H[Z],ie=f(te),fe=b%P,me=fe%ie.boundary,Me=fe+me;b+=me,Me!==0&&P-Me<ie.storage&&(b+=P-Me),j.__data=new Float32Array(ie.storage/Float32Array.BYTES_PER_ELEMENT),j.__offset=b,b+=ie.storage}}}const g=b%P;return g>0&&(b+=P-g),S.__size=b,S.__cache={},this}function f(S){const R={boundary:0,storage:0};return typeof S=="number"||typeof S=="boolean"?(R.boundary=4,R.storage=4):S.isVector2?(R.boundary=8,R.storage=8):S.isVector3||S.isColor?(R.boundary=16,R.storage=12):S.isVector4?(R.boundary=16,R.storage=16):S.isMatrix3?(R.boundary=48,R.storage=48):S.isMatrix4?(R.boundary=64,R.storage=64):S.isTexture?we("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(S)?(R.boundary=16,R.storage=S.byteLength):we("WebGLRenderer: Unsupported uniform value type.",S),R}function w(S){const R=S.target;R.removeEventListener("dispose",w);const b=a.indexOf(R.__bindingPointIndex);a.splice(b,1),i.deleteBuffer(r[R.id]),delete r[R.id],delete s[R.id]}function C(){for(const S in r)i.deleteBuffer(r[S]);a=[],r={},s={}}return{bind:c,update:l,dispose:C}}const Xm=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let jt=null;function Ym(){return jt===null&&(jt=new Rh(Xm,16,16,jn,xn),jt.name="DFG_LUT",jt.minFilter=wt,jt.magFilter=wt,jt.wrapS=mn,jt.wrapT=mn,jt.generateMipmaps=!1,jt.needsUpdate=!0),jt}class qm{constructor(e={}){const{canvas:t=th(),context:n=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:m=!1,reversedDepthBuffer:h=!1,outputBufferType:d=kt}=e;this.isWebGLRenderer=!0;let x;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");x=n.getContextAttributes().alpha}else x=a;const y=d,_=new Set([za,Ba,Oa]),f=new Set([kt,on,qi,Ki,Na,Fa]),w=new Uint32Array(4),C=new Int32Array(4),S=new D;let R=null,b=null;const P=[],g=[];let T=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=sn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const U=this;let L=!1,z=null,$=null,j=null,H=null;this._outputColorSpace=Ut;let Z=0,X=0,te=null,ie=-1,fe=null;const me=new dt,Me=new dt;let Xe=null;const rt=new ze(0);let Ye=0,Q=t.width,le=t.height,re=1,Pe=null,De=null;const Re=new dt(0,0,Q,le),ot=new dt(0,0,Q,le);let Fe=!1;const Ze=new Vl;let We=!1,Ve=!1;const lt=new at,ht=new D,_t=new dt,xt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let it=!1;function ut(){return te===null?re:1}let I=n;function yt(v,F){return t.getContext(v,F)}try{const v={alpha:!0,depth:r,stencil:s,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:u,failIfMajorPerformanceCaveat:m};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Ia}`),t.addEventListener("webglcontextlost",Ge,!1),t.addEventListener("webglcontextrestored",Ie,!1),t.addEventListener("webglcontextcreationerror",ct,!1),I===null){const F="webgl2";if(I=yt(F,v),I===null)throw yt(F)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(v){throw He("WebGLRenderer: "+v.message),v}let Ke,E,p,O,k,Y,se,ae,K,J,oe,Se,he,ce,ye,be,A,M,B,N,ee,ne,q;function de(){Ke=new Yd(I),Ke.init(),ee=new Om(I,Ke),E=new Bd(I,Ke,e,ee),p=new Nm(I,Ke),E.reversedDepthBuffer&&h&&p.buffers.depth.setReversed(!0),$=I.createFramebuffer(),j=I.createFramebuffer(),H=I.createFramebuffer(),O=new Zd(I),k=new Sm,Y=new Fm(I,Ke,p,k,E,ee,O),se=new Xd(U),ae=new Qh(I),ne=new Fd(I,ae),K=new qd(I,ae,O,ne),J=new Jd(I,K,ae,ne,O),M=new $d(I,E,Y),ye=new zd(k),oe=new Mm(U,se,Ke,E,ne,ye),Se=new km(U,k),he=new ym,ce=new Cm(Ke),A=new Nd(U,se,p,J,x,c),be=new Um(U,J,E),q=new Wm(I,O,E,p),B=new Od(I,Ke,O),N=new Kd(I,Ke,O),O.programs=oe.programs,U.capabilities=E,U.extensions=Ke,U.properties=k,U.renderLists=he,U.shadowMap=be,U.state=p,U.info=O}de(),y!==kt&&(T=new jd(y,t.width,t.height,o,r,s));const ue=new Vm(U,I);this.xr=ue,this.getContext=function(){return I},this.getContextAttributes=function(){return I.getContextAttributes()},this.forceContextLoss=function(){const v=Ke.get("WEBGL_lose_context");v&&v.loseContext()},this.forceContextRestore=function(){const v=Ke.get("WEBGL_lose_context");v&&v.restoreContext()},this.getPixelRatio=function(){return re},this.setPixelRatio=function(v){v!==void 0&&(re=v,this.setSize(Q,le,!1))},this.getSize=function(v){return v.set(Q,le)},this.setSize=function(v,F,W=!0){if(ue.isPresenting){we("WebGLRenderer: Can't change size while VR device is presenting.");return}Q=v,le=F,t.width=Math.floor(v*re),t.height=Math.floor(F*re),W===!0&&(t.style.width=v+"px",t.style.height=F+"px"),T!==null&&T.setSize(t.width,t.height),this.setViewport(0,0,v,F)},this.getDrawingBufferSize=function(v){return v.set(Q*re,le*re).floor()},this.setDrawingBufferSize=function(v,F,W){Q=v,le=F,re=W,t.width=Math.floor(v*W),t.height=Math.floor(F*W),this.setViewport(0,0,v,F)},this.setEffects=function(v){if(y===kt){He("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(v){for(let F=0;F<v.length;F++)if(v[F].isOutputPass===!0){we("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}T.setEffects(v||[])},this.getCurrentViewport=function(v){return v.copy(me)},this.getViewport=function(v){return v.copy(Re)},this.setViewport=function(v,F,W,G){v.isVector4?Re.set(v.x,v.y,v.z,v.w):Re.set(v,F,W,G),p.viewport(me.copy(Re).multiplyScalar(re).round())},this.getScissor=function(v){return v.copy(ot)},this.setScissor=function(v,F,W,G){v.isVector4?ot.set(v.x,v.y,v.z,v.w):ot.set(v,F,W,G),p.scissor(Me.copy(ot).multiplyScalar(re).round())},this.getScissorTest=function(){return Fe},this.setScissorTest=function(v){p.setScissorTest(Fe=v)},this.setOpaqueSort=function(v){Pe=v},this.setTransparentSort=function(v){De=v},this.getClearColor=function(v){return v.copy(A.getClearColor())},this.setClearColor=function(){A.setClearColor(...arguments)},this.getClearAlpha=function(){return A.getClearAlpha()},this.setClearAlpha=function(){A.setClearAlpha(...arguments)},this.clear=function(v=!0,F=!0,W=!0){let G=0;if(v){let V=!1;if(te!==null){const ge=te.texture.format;V=_.has(ge)}if(V){const ge=te.texture.type,ve=f.has(ge),_e=A.getClearColor(),Ee=A.getClearAlpha(),Te=_e.r,Ue=_e.g,Oe=_e.b;ve?(w[0]=Te,w[1]=Ue,w[2]=Oe,w[3]=Ee,I.clearBufferuiv(I.COLOR,0,w)):(C[0]=Te,C[1]=Ue,C[2]=Oe,C[3]=Ee,I.clearBufferiv(I.COLOR,0,C))}else G|=I.COLOR_BUFFER_BIT}F&&(G|=I.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),W&&(G|=I.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),G!==0&&I.clear(G)},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.setNodesHandler=function(v){v.setRenderer(this),z=v},this.dispose=function(){t.removeEventListener("webglcontextlost",Ge,!1),t.removeEventListener("webglcontextrestored",Ie,!1),t.removeEventListener("webglcontextcreationerror",ct,!1),A.dispose(),he.dispose(),ce.dispose(),k.dispose(),se.dispose(),J.dispose(),ne.dispose(),q.dispose(),oe.dispose(),ue.dispose(),ue.removeEventListener("sessionstart",ni),ue.removeEventListener("sessionend",ii),kn.stop()};function Ge(v){v.preventDefault(),Vr("WebGLRenderer: Context Lost."),L=!0}function Ie(){Vr("WebGLRenderer: Context Restored."),L=!1;const v=O.autoReset,F=be.enabled,W=be.autoUpdate,G=be.needsUpdate,V=be.type;de(),O.autoReset=v,be.enabled=F,be.autoUpdate=W,be.needsUpdate=G,be.type=V}function ct(v){He("WebGLRenderer: A WebGL context could not be created. Reason: ",v.statusMessage)}function st(v){const F=v.target;F.removeEventListener("dispose",st),Sn(F)}function Sn(v){Qr(v),k.remove(v)}function Qr(v){const F=k.get(v).programs;F!==void 0&&(F.forEach(function(W){oe.releaseProgram(W)}),v.isShaderMaterial&&oe.releaseShaderCache(v))}this.renderBufferDirect=function(v,F,W,G,V,ge){F===null&&(F=xt);const ve=V.isMesh&&V.matrixWorld.determinantAffine()<0,_e=sc(v,F,W,G,V);p.setMaterial(G,ve);let Ee=W.index,Te=1;if(G.wireframe===!0){if(Ee=K.getWireframeAttribute(W),Ee===void 0)return;Te=2}const Ue=W.drawRange,Oe=W.attributes.position;let Ae=Ue.start*Te,Je=(Ue.start+Ue.count)*Te;ge!==null&&(Ae=Math.max(Ae,ge.start*Te),Je=Math.min(Je,(ge.start+ge.count)*Te)),Ee!==null?(Ae=Math.max(Ae,0),Je=Math.min(Je,Ee.count)):Oe!=null&&(Ae=Math.max(Ae,0),Je=Math.min(Je,Oe.count));const pt=Je-Ae;if(pt<0||pt===1/0)return;ne.setup(V,G,_e,W,Ee);let ft,et=B;if(Ee!==null&&(ft=ae.get(Ee),et=N,et.setIndex(ft)),V.isMesh)G.wireframe===!0?(p.setLineWidth(G.wireframeLinewidth*ut()),et.setMode(I.LINES)):et.setMode(I.TRIANGLES);else if(V.isLine){let Tt=G.linewidth;Tt===void 0&&(Tt=1),p.setLineWidth(Tt*ut()),V.isLineSegments?et.setMode(I.LINES):V.isLineLoop?et.setMode(I.LINE_LOOP):et.setMode(I.LINE_STRIP)}else V.isPoints?et.setMode(I.POINTS):V.isSprite&&et.setMode(I.TRIANGLES);if(V.isBatchedMesh)if(Ke.get("WEBGL_multi_draw"))et.renderMultiDraw(V._multiDrawStarts,V._multiDrawCounts,V._multiDrawCount);else{const Tt=V._multiDrawStarts,xe=V._multiDrawCounts,Ft=V._multiDrawCount,qe=Ee?ae.get(Ee).bytesPerElement:1,Gt=k.get(G).currentProgram.getUniforms();for(let Jt=0;Jt<Ft;Jt++)Gt.setValue(I,"_gl_DrawID",Jt),et.render(Tt[Jt]/qe,xe[Jt])}else if(V.isInstancedMesh)et.renderInstances(Ae,pt,V.count);else if(W.isInstancedBufferGeometry){const Tt=W._maxInstanceCount!==void 0?W._maxInstanceCount:1/0,xe=Math.min(W.instanceCount,Tt);et.renderInstances(Ae,pt,xe)}else et.render(Ae,pt)};function Hn(v,F,W){v.transparent===!0&&v.side===pn&&v.forceSinglePass===!1?(v.side=Nt,v.needsUpdate=!0,Qi(v,F,W),v.side=zn,v.needsUpdate=!0,Qi(v,F,W),v.side=pn):Qi(v,F,W)}this.compile=function(v,F,W=null){W===null&&(W=v),b=ce.get(W),b.init(F),g.push(b),W.traverseVisible(function(V){V.isLight&&V.layers.test(F.layers)&&(b.pushLight(V),V.castShadow&&b.pushShadow(V))}),v!==W&&v.traverseVisible(function(V){V.isLight&&V.layers.test(F.layers)&&(b.pushLight(V),V.castShadow&&b.pushShadow(V))}),b.setupLights();const G=new Set;return v.traverse(function(V){if(!(V.isMesh||V.isPoints||V.isLine||V.isSprite))return;const ge=V.material;if(ge)if(Array.isArray(ge))for(let ve=0;ve<ge.length;ve++){const _e=ge[ve];Hn(_e,W,V),G.add(_e)}else Hn(ge,W,V),G.add(ge)}),b=g.pop(),G},this.compileAsync=function(v,F,W=null){const G=this.compile(v,F,W);return new Promise(V=>{function ge(){if(G.forEach(function(ve){k.get(ve).currentProgram.isReady()&&G.delete(ve)}),G.size===0){V(v);return}setTimeout(ge,10)}Ke.get("KHR_parallel_shader_compile")!==null?ge():setTimeout(ge,10)})};let ti=null;function En(v){ti&&ti(v)}function ni(){kn.stop()}function ii(){kn.start()}const kn=new Kl;kn.setAnimationLoop(En),typeof self<"u"&&kn.setContext(self),this.setAnimationLoop=function(v){ti=v,ue.setAnimationLoop(v),v===null?kn.stop():kn.start()},ue.addEventListener("sessionstart",ni),ue.addEventListener("sessionend",ii),this.render=function(v,F){if(F!==void 0&&F.isCamera!==!0){He("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(L===!0)return;z!==null&&z.renderStart(v,F);const W=ue.enabled===!0&&ue.isPresenting===!0,G=T!==null&&(te===null||W)&&T.begin(U,te);if(v.matrixWorldAutoUpdate===!0&&v.updateMatrixWorld(),F.parent===null&&F.matrixWorldAutoUpdate===!0&&F.updateMatrixWorld(),ue.enabled===!0&&ue.isPresenting===!0&&(T===null||T.isCompositing()===!1)&&(ue.cameraAutoUpdate===!0&&ue.updateCamera(F),F=ue.getCamera()),v.isScene===!0&&v.onBeforeRender(U,v,F,te),b=ce.get(v,g.length),b.init(F),b.state.textureUnits=Y.getTextureUnits(),g.push(b),lt.multiplyMatrices(F.projectionMatrix,F.matrixWorldInverse),Ze.setFromProjectionMatrix(lt,rn,F.reversedDepth),Ve=this.localClippingEnabled,We=ye.init(this.clippingPlanes,Ve),R=he.get(v,P.length),R.init(),P.push(R),ue.enabled===!0&&ue.isPresenting===!0){const ve=U.xr.getDepthSensingMesh();ve!==null&&jr(ve,F,-1/0,U.sortObjects)}jr(v,F,0,U.sortObjects),R.finish(),U.sortObjects===!0&&R.sort(Pe,De,F.reversedDepth),it=ue.enabled===!1||ue.isPresenting===!1||ue.hasDepthSensing()===!1,it&&A.addToRenderList(R,v),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),We===!0&&ye.beginShadows();const V=b.state.shadowsArray;if(be.render(V,v,F),We===!0&&ye.endShadows(),(G&&T.hasRenderPass())===!1){const ve=R.opaque,_e=R.transmissive;if(b.setupLights(),F.isArrayCamera){const Ee=F.cameras;if(_e.length>0)for(let Te=0,Ue=Ee.length;Te<Ue;Te++){const Oe=Ee[Te];Qa(ve,_e,v,Oe)}it&&A.render(v);for(let Te=0,Ue=Ee.length;Te<Ue;Te++){const Oe=Ee[Te];Ja(R,v,Oe,Oe.viewport)}}else _e.length>0&&Qa(ve,_e,v,F),it&&A.render(v),Ja(R,v,F)}te!==null&&X===0&&(Y.updateMultisampleRenderTarget(te),Y.updateRenderTargetMipmap(te)),G&&T.end(U),v.isScene===!0&&v.onAfterRender(U,v,F),ne.resetDefaultState(),ie=-1,fe=null,g.pop(),g.length>0?(b=g[g.length-1],Y.setTextureUnits(b.state.textureUnits),We===!0&&ye.setGlobalState(U.clippingPlanes,b.state.camera)):b=null,P.pop(),P.length>0?R=P[P.length-1]:R=null,z!==null&&z.renderEnd()};function jr(v,F,W,G){if(v.visible===!1)return;if(v.layers.test(F.layers)){if(v.isGroup)W=v.renderOrder;else if(v.isLOD)v.autoUpdate===!0&&v.update(F);else if(v.isLightProbeGrid)b.pushLightProbeGrid(v);else if(v.isLight)b.pushLight(v),v.castShadow&&b.pushShadow(v);else if(v.isSprite){if(!v.frustumCulled||Ze.intersectsSprite(v)){G&&_t.setFromMatrixPosition(v.matrixWorld).applyMatrix4(lt);const ve=J.update(v),_e=v.material;_e.visible&&R.push(v,ve,_e,W,_t.z,null)}}else if((v.isMesh||v.isLine||v.isPoints)&&(!v.frustumCulled||Ze.intersectsObject(v))){const ve=J.update(v),_e=v.material;if(G&&(v.boundingSphere!==void 0?(v.boundingSphere===null&&v.computeBoundingSphere(),_t.copy(v.boundingSphere.center)):(ve.boundingSphere===null&&ve.computeBoundingSphere(),_t.copy(ve.boundingSphere.center)),_t.applyMatrix4(v.matrixWorld).applyMatrix4(lt)),Array.isArray(_e)){const Ee=ve.groups;for(let Te=0,Ue=Ee.length;Te<Ue;Te++){const Oe=Ee[Te],Ae=_e[Oe.materialIndex];Ae&&Ae.visible&&R.push(v,ve,Ae,W,_t.z,Oe)}}else _e.visible&&R.push(v,ve,_e,W,_t.z,null)}}const ge=v.children;for(let ve=0,_e=ge.length;ve<_e;ve++)jr(ge[ve],F,W,G)}function Ja(v,F,W,G){const{opaque:V,transmissive:ge,transparent:ve}=v;b.setupLightsView(W),We===!0&&ye.setGlobalState(U.clippingPlanes,W),G&&p.viewport(me.copy(G)),V.length>0&&Ji(V,F,W),ge.length>0&&Ji(ge,F,W),ve.length>0&&Ji(ve,F,W),p.buffers.depth.setTest(!0),p.buffers.depth.setMask(!0),p.buffers.color.setMask(!0),p.setPolygonOffset(!1)}function Qa(v,F,W,G){if((W.isScene===!0?W.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[G.id]===void 0){const Ae=Ke.has("EXT_color_buffer_half_float")||Ke.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[G.id]=new an(1,1,{generateMipmaps:!0,type:Ae?xn:kt,minFilter:$n,samples:Math.max(4,E.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:ke.workingColorSpace})}const ge=b.state.transmissionRenderTarget[G.id],ve=G.viewport||me;ge.setSize(ve.z*U.transmissionResolutionScale,ve.w*U.transmissionResolutionScale);const _e=U.getRenderTarget(),Ee=U.getActiveCubeFace(),Te=U.getActiveMipmapLevel();U.setRenderTarget(ge),U.getClearColor(rt),Ye=U.getClearAlpha(),Ye<1&&U.setClearColor(16777215,.5),U.clear(),it&&A.render(W);const Ue=U.toneMapping;U.toneMapping=sn;const Oe=G.viewport;if(G.viewport!==void 0&&(G.viewport=void 0),b.setupLightsView(G),We===!0&&ye.setGlobalState(U.clippingPlanes,G),Ji(v,W,G),Y.updateMultisampleRenderTarget(ge),Y.updateRenderTargetMipmap(ge),Ke.has("WEBGL_multisampled_render_to_texture")===!1){let Ae=!1;for(let Je=0,pt=F.length;Je<pt;Je++){const ft=F[Je],{object:et,geometry:Tt,material:xe,group:Ft}=ft;if(xe.side===pn&&et.layers.test(G.layers)){const qe=xe.side;xe.side=Nt,xe.needsUpdate=!0,ja(et,W,G,Tt,xe,Ft),xe.side=qe,xe.needsUpdate=!0,Ae=!0}}Ae===!0&&(Y.updateMultisampleRenderTarget(ge),Y.updateRenderTargetMipmap(ge))}U.setRenderTarget(_e,Ee,Te),U.setClearColor(rt,Ye),Oe!==void 0&&(G.viewport=Oe),U.toneMapping=Ue}function Ji(v,F,W){const G=F.isScene===!0?F.overrideMaterial:null;for(let V=0,ge=v.length;V<ge;V++){const ve=v[V],{object:_e,geometry:Ee,group:Te}=ve;let Ue=ve.material;Ue.allowOverride===!0&&G!==null&&(Ue=G),_e.layers.test(W.layers)&&ja(_e,F,W,Ee,Ue,Te)}}function ja(v,F,W,G,V,ge){v.onBeforeRender(U,F,W,G,V,ge),v.modelViewMatrix.multiplyMatrices(W.matrixWorldInverse,v.matrixWorld),v.normalMatrix.getNormalMatrix(v.modelViewMatrix),V.onBeforeRender(U,F,W,G,v,ge),V.transparent===!0&&V.side===pn&&V.forceSinglePass===!1?(V.side=Nt,V.needsUpdate=!0,U.renderBufferDirect(W,F,G,V,v,ge),V.side=zn,V.needsUpdate=!0,U.renderBufferDirect(W,F,G,V,v,ge),V.side=pn):U.renderBufferDirect(W,F,G,V,v,ge),v.onAfterRender(U,F,W,G,V,ge)}function Qi(v,F,W){F.isScene!==!0&&(F=xt);const G=k.get(v),V=b.state.lights,ge=b.state.shadowsArray,ve=V.state.version,_e=oe.getParameters(v,V.state,ge,F,W,b.state.lightProbeGridArray),Ee=oe.getProgramCacheKey(_e);let Te=G.programs;G.environment=v.isMeshStandardMaterial||v.isMeshLambertMaterial||v.isMeshPhongMaterial?F.environment:null,G.fog=F.fog;const Ue=v.isMeshStandardMaterial||v.isMeshLambertMaterial&&!v.envMap||v.isMeshPhongMaterial&&!v.envMap;G.envMap=se.get(v.envMap||G.environment,Ue),G.envMapRotation=G.environment!==null&&v.envMap===null?F.environmentRotation:v.envMapRotation,Te===void 0&&(v.addEventListener("dispose",st),Te=new Map,G.programs=Te);let Oe=Te.get(Ee);if(Oe!==void 0){if(G.currentProgram===Oe&&G.lightsStateVersion===ve)return to(v,_e),Oe}else _e.uniforms=oe.getUniforms(v),z!==null&&v.isNodeMaterial&&z.build(v,W,_e),v.onBeforeCompile(_e,U),Oe=oe.acquireProgram(_e,Ee),Te.set(Ee,Oe),G.uniforms=_e.uniforms;const Ae=G.uniforms;return(!v.isShaderMaterial&&!v.isRawShaderMaterial||v.clipping===!0)&&(Ae.clippingPlanes=ye.uniform),to(v,_e),G.needsLights=oc(v),G.lightsStateVersion=ve,G.needsLights&&(Ae.ambientLightColor.value=V.state.ambient,Ae.lightProbe.value=V.state.probe,Ae.directionalLights.value=V.state.directional,Ae.directionalLightShadows.value=V.state.directionalShadow,Ae.spotLights.value=V.state.spot,Ae.spotLightShadows.value=V.state.spotShadow,Ae.rectAreaLights.value=V.state.rectArea,Ae.ltc_1.value=V.state.rectAreaLTC1,Ae.ltc_2.value=V.state.rectAreaLTC2,Ae.pointLights.value=V.state.point,Ae.pointLightShadows.value=V.state.pointShadow,Ae.hemisphereLights.value=V.state.hemi,Ae.directionalShadowMatrix.value=V.state.directionalShadowMatrix,Ae.spotLightMatrix.value=V.state.spotLightMatrix,Ae.spotLightMap.value=V.state.spotLightMap,Ae.pointShadowMatrix.value=V.state.pointShadowMatrix),G.lightProbeGrid=b.state.lightProbeGridArray.length>0,G.currentProgram=Oe,G.uniformsList=null,Oe}function eo(v){if(v.uniformsList===null){const F=v.currentProgram.getUniforms();v.uniformsList=Ur.seqWithValue(F.seq,v.uniforms)}return v.uniformsList}function to(v,F){const W=k.get(v);W.outputColorSpace=F.outputColorSpace,W.batching=F.batching,W.batchingColor=F.batchingColor,W.instancing=F.instancing,W.instancingColor=F.instancingColor,W.instancingMorph=F.instancingMorph,W.skinning=F.skinning,W.morphTargets=F.morphTargets,W.morphNormals=F.morphNormals,W.morphColors=F.morphColors,W.morphTargetsCount=F.morphTargetsCount,W.numClippingPlanes=F.numClippingPlanes,W.numIntersection=F.numClipIntersection,W.vertexAlphas=F.vertexAlphas,W.vertexTangents=F.vertexTangents,W.toneMapping=F.toneMapping}function rc(v,F){if(v.length===0)return null;if(v.length===1)return v[0].texture!==null?v[0]:null;S.setFromMatrixPosition(F.matrixWorld);for(let W=0,G=v.length;W<G;W++){const V=v[W];if(V.texture!==null&&V.boundingBox.containsPoint(S))return V}return null}function sc(v,F,W,G,V){F.isScene!==!0&&(F=xt),Y.resetTextureUnits();const ge=F.fog,ve=G.isMeshStandardMaterial||G.isMeshLambertMaterial||G.isMeshPhongMaterial?F.environment:null,_e=te===null?U.outputColorSpace:te.isXRRenderTarget===!0?te.texture.colorSpace:ke.workingColorSpace,Ee=G.isMeshStandardMaterial||G.isMeshLambertMaterial&&!G.envMap||G.isMeshPhongMaterial&&!G.envMap,Te=se.get(G.envMap||ve,Ee),Ue=G.vertexColors===!0&&!!W.attributes.color&&W.attributes.color.itemSize===4,Oe=!!W.attributes.tangent&&(!!G.normalMap||G.anisotropy>0),Ae=!!W.morphAttributes.position,Je=!!W.morphAttributes.normal,pt=!!W.morphAttributes.color;let ft=sn;G.toneMapped&&(te===null||te.isXRRenderTarget===!0)&&(ft=U.toneMapping);const et=W.morphAttributes.position||W.morphAttributes.normal||W.morphAttributes.color,Tt=et!==void 0?et.length:0,xe=k.get(G),Ft=b.state.lights;if(We===!0&&(Ve===!0||v!==fe)){const nt=v===fe&&G.id===ie;ye.setState(G,v,nt)}let qe=!1;G.version===xe.__version?(xe.needsLights&&xe.lightsStateVersion!==Ft.state.version||xe.outputColorSpace!==_e||V.isBatchedMesh&&xe.batching===!1||!V.isBatchedMesh&&xe.batching===!0||V.isBatchedMesh&&xe.batchingColor===!0&&V.colorTexture===null||V.isBatchedMesh&&xe.batchingColor===!1&&V.colorTexture!==null||V.isInstancedMesh&&xe.instancing===!1||!V.isInstancedMesh&&xe.instancing===!0||V.isSkinnedMesh&&xe.skinning===!1||!V.isSkinnedMesh&&xe.skinning===!0||V.isInstancedMesh&&xe.instancingColor===!0&&V.instanceColor===null||V.isInstancedMesh&&xe.instancingColor===!1&&V.instanceColor!==null||V.isInstancedMesh&&xe.instancingMorph===!0&&V.morphTexture===null||V.isInstancedMesh&&xe.instancingMorph===!1&&V.morphTexture!==null||xe.envMap!==Te||G.fog===!0&&xe.fog!==ge||xe.numClippingPlanes!==void 0&&(xe.numClippingPlanes!==ye.numPlanes||xe.numIntersection!==ye.numIntersection)||xe.vertexAlphas!==Ue||xe.vertexTangents!==Oe||xe.morphTargets!==Ae||xe.morphNormals!==Je||xe.morphColors!==pt||xe.toneMapping!==ft||xe.morphTargetsCount!==Tt||!!xe.lightProbeGrid!=b.state.lightProbeGridArray.length>0)&&(qe=!0):(qe=!0,xe.__version=G.version);let Gt=xe.currentProgram;qe===!0&&(Gt=Qi(G,F,V),z&&G.isNodeMaterial&&z.onUpdateProgram(G,Gt,xe));let Jt=!1,yn=!1,ri=!1;const tt=Gt.getUniforms(),mt=xe.uniforms;if(p.useProgram(Gt.program)&&(Jt=!0,yn=!0,ri=!0),G.id!==ie&&(ie=G.id,yn=!0),xe.needsLights){const nt=rc(b.state.lightProbeGridArray,V);xe.lightProbeGrid!==nt&&(xe.lightProbeGrid=nt,yn=!0)}if(Jt||fe!==v){p.buffers.depth.getReversed()&&v.reversedDepth!==!0&&(v._reversedDepth=!0,v.updateProjectionMatrix()),tt.setValue(I,"projectionMatrix",v.projectionMatrix),tt.setValue(I,"viewMatrix",v.matrixWorldInverse);const Tn=tt.map.cameraPosition;Tn!==void 0&&Tn.setValue(I,ht.setFromMatrixPosition(v.matrixWorld)),E.logarithmicDepthBuffer&&tt.setValue(I,"logDepthBufFC",2/(Math.log(v.far+1)/Math.LN2)),(G.isMeshPhongMaterial||G.isMeshToonMaterial||G.isMeshLambertMaterial||G.isMeshBasicMaterial||G.isMeshStandardMaterial||G.isShaderMaterial)&&tt.setValue(I,"isOrthographic",v.isOrthographicCamera===!0),fe!==v&&(fe=v,yn=!0,ri=!0)}if(xe.needsLights&&(Ft.state.directionalShadowMap.length>0&&tt.setValue(I,"directionalShadowMap",Ft.state.directionalShadowMap,Y),Ft.state.spotShadowMap.length>0&&tt.setValue(I,"spotShadowMap",Ft.state.spotShadowMap,Y),Ft.state.pointShadowMap.length>0&&tt.setValue(I,"pointShadowMap",Ft.state.pointShadowMap,Y)),V.isSkinnedMesh){tt.setOptional(I,V,"bindMatrix"),tt.setOptional(I,V,"bindMatrixInverse");const nt=V.skeleton;nt&&(nt.boneTexture===null&&nt.computeBoneTexture(),tt.setValue(I,"boneTexture",nt.boneTexture,Y))}V.isBatchedMesh&&(tt.setOptional(I,V,"batchingTexture"),tt.setValue(I,"batchingTexture",V._matricesTexture,Y),tt.setOptional(I,V,"batchingIdTexture"),tt.setValue(I,"batchingIdTexture",V._indirectTexture,Y),tt.setOptional(I,V,"batchingColorTexture"),V._colorsTexture!==null&&tt.setValue(I,"batchingColorTexture",V._colorsTexture,Y));const bn=W.morphAttributes;if((bn.position!==void 0||bn.normal!==void 0||bn.color!==void 0)&&M.update(V,W,Gt),(yn||xe.receiveShadow!==V.receiveShadow)&&(xe.receiveShadow=V.receiveShadow,tt.setValue(I,"receiveShadow",V.receiveShadow)),(G.isMeshStandardMaterial||G.isMeshLambertMaterial||G.isMeshPhongMaterial)&&G.envMap===null&&F.environment!==null&&(mt.envMapIntensity.value=F.environmentIntensity),mt.dfgLUT!==void 0&&(mt.dfgLUT.value=Ym()),yn){if(tt.setValue(I,"toneMappingExposure",U.toneMappingExposure),xe.needsLights&&ac(mt,ri),ge&&G.fog===!0&&Se.refreshFogUniforms(mt,ge),Se.refreshMaterialUniforms(mt,G,re,le,b.state.transmissionRenderTarget[v.id]),xe.needsLights&&xe.lightProbeGrid){const nt=xe.lightProbeGrid;mt.probesSH.value=nt.texture,mt.probesMin.value.copy(nt.boundingBox.min),mt.probesMax.value.copy(nt.boundingBox.max),mt.probesResolution.value.copy(nt.resolution)}Ur.upload(I,eo(xe),mt,Y)}if(G.isShaderMaterial&&G.uniformsNeedUpdate===!0&&(Ur.upload(I,eo(xe),mt,Y),G.uniformsNeedUpdate=!1),G.isSpriteMaterial&&tt.setValue(I,"center",V.center),tt.setValue(I,"modelViewMatrix",V.modelViewMatrix),tt.setValue(I,"normalMatrix",V.normalMatrix),tt.setValue(I,"modelMatrix",V.matrixWorld),G.uniformsGroups!==void 0){const nt=G.uniformsGroups;for(let Tn=0,si=nt.length;Tn<si;Tn++){const no=nt[Tn];q.update(no,Gt),q.bind(no,Gt)}}return Gt}function ac(v,F){v.ambientLightColor.needsUpdate=F,v.lightProbe.needsUpdate=F,v.directionalLights.needsUpdate=F,v.directionalLightShadows.needsUpdate=F,v.pointLights.needsUpdate=F,v.pointLightShadows.needsUpdate=F,v.spotLights.needsUpdate=F,v.spotLightShadows.needsUpdate=F,v.rectAreaLights.needsUpdate=F,v.hemisphereLights.needsUpdate=F}function oc(v){return v.isMeshLambertMaterial||v.isMeshToonMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isShadowMaterial||v.isShaderMaterial&&v.lights===!0}this.getActiveCubeFace=function(){return Z},this.getActiveMipmapLevel=function(){return X},this.getRenderTarget=function(){return te},this.setRenderTargetTextures=function(v,F,W){const G=k.get(v);G.__autoAllocateDepthBuffer=v.resolveDepthBuffer===!1,G.__autoAllocateDepthBuffer===!1&&(G.__useRenderToTexture=!1),k.get(v.texture).__webglTexture=F,k.get(v.depthTexture).__webglTexture=G.__autoAllocateDepthBuffer?void 0:W,G.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(v,F){const W=k.get(v);W.__webglFramebuffer=F,W.__useDefaultFramebuffer=F===void 0},this.setRenderTarget=function(v,F=0,W=0){te=v,Z=F,X=W;let G=null,V=!1,ge=!1;if(v){const _e=k.get(v);if(_e.__useDefaultFramebuffer!==void 0){p.bindFramebuffer(I.FRAMEBUFFER,_e.__webglFramebuffer),me.copy(v.viewport),Me.copy(v.scissor),Xe=v.scissorTest,p.viewport(me),p.scissor(Me),p.setScissorTest(Xe),ie=-1;return}else if(_e.__webglFramebuffer===void 0)Y.setupRenderTarget(v);else if(_e.__hasExternalTextures)Y.rebindTextures(v,k.get(v.texture).__webglTexture,k.get(v.depthTexture).__webglTexture);else if(v.depthBuffer){const Ue=v.depthTexture;if(_e.__boundDepthTexture!==Ue){if(Ue!==null&&k.has(Ue)&&(v.width!==Ue.image.width||v.height!==Ue.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");Y.setupDepthRenderbuffer(v)}}const Ee=v.texture;(Ee.isData3DTexture||Ee.isDataArrayTexture||Ee.isCompressedArrayTexture)&&(ge=!0);const Te=k.get(v).__webglFramebuffer;v.isWebGLCubeRenderTarget?(Array.isArray(Te[F])?G=Te[F][W]:G=Te[F],V=!0):v.samples>0&&Y.useMultisampledRTT(v)===!1?G=k.get(v).__webglMultisampledFramebuffer:Array.isArray(Te)?G=Te[W]:G=Te,me.copy(v.viewport),Me.copy(v.scissor),Xe=v.scissorTest}else me.copy(Re).multiplyScalar(re).floor(),Me.copy(ot).multiplyScalar(re).floor(),Xe=Fe;if(W!==0&&(G=$),p.bindFramebuffer(I.FRAMEBUFFER,G)&&p.drawBuffers(v,G),p.viewport(me),p.scissor(Me),p.setScissorTest(Xe),V){const _e=k.get(v.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_CUBE_MAP_POSITIVE_X+F,_e.__webglTexture,W)}else if(ge){const _e=F;for(let Ee=0;Ee<v.textures.length;Ee++){const Te=k.get(v.textures[Ee]);I.framebufferTextureLayer(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0+Ee,Te.__webglTexture,W,_e)}}else if(v!==null&&W!==0){const _e=k.get(v.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,_e.__webglTexture,W)}ie=-1},this.readRenderTargetPixels=function(v,F,W,G,V,ge,ve,_e=0){if(!(v&&v.isWebGLRenderTarget)){He("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ee=k.get(v).__webglFramebuffer;if(v.isWebGLCubeRenderTarget&&ve!==void 0&&(Ee=Ee[ve]),Ee){p.bindFramebuffer(I.FRAMEBUFFER,Ee);try{const Te=v.textures[_e],Ue=Te.format,Oe=Te.type;if(v.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+_e),!E.textureFormatReadable(Ue)){He("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!E.textureTypeReadable(Oe)){He("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}F>=0&&F<=v.width-G&&W>=0&&W<=v.height-V&&I.readPixels(F,W,G,V,ee.convert(Ue),ee.convert(Oe),ge)}finally{const Te=te!==null?k.get(te).__webglFramebuffer:null;p.bindFramebuffer(I.FRAMEBUFFER,Te)}}},this.readRenderTargetPixelsAsync=async function(v,F,W,G,V,ge,ve,_e=0){if(!(v&&v.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Ee=k.get(v).__webglFramebuffer;if(v.isWebGLCubeRenderTarget&&ve!==void 0&&(Ee=Ee[ve]),Ee)if(F>=0&&F<=v.width-G&&W>=0&&W<=v.height-V){p.bindFramebuffer(I.FRAMEBUFFER,Ee);const Te=v.textures[_e],Ue=Te.format,Oe=Te.type;if(v.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+_e),!E.textureFormatReadable(Ue))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!E.textureTypeReadable(Oe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ae=I.createBuffer();I.bindBuffer(I.PIXEL_PACK_BUFFER,Ae),I.bufferData(I.PIXEL_PACK_BUFFER,ge.byteLength,I.STREAM_READ),I.readPixels(F,W,G,V,ee.convert(Ue),ee.convert(Oe),0);const Je=te!==null?k.get(te).__webglFramebuffer:null;p.bindFramebuffer(I.FRAMEBUFFER,Je);const pt=I.fenceSync(I.SYNC_GPU_COMMANDS_COMPLETE,0);return I.flush(),await nh(I,pt,4),I.bindBuffer(I.PIXEL_PACK_BUFFER,Ae),I.getBufferSubData(I.PIXEL_PACK_BUFFER,0,ge),I.deleteBuffer(Ae),I.deleteSync(pt),ge}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(v,F=null,W=0){const G=Math.pow(2,-W),V=Math.floor(v.image.width*G),ge=Math.floor(v.image.height*G),ve=F!==null?F.x:0,_e=F!==null?F.y:0;Y.setTexture2D(v,0),I.copyTexSubImage2D(I.TEXTURE_2D,W,0,0,ve,_e,V,ge),p.unbindTexture()},this.copyTextureToTexture=function(v,F,W=null,G=null,V=0,ge=0){let ve,_e,Ee,Te,Ue,Oe,Ae,Je,pt;const ft=v.isCompressedTexture?v.mipmaps[ge]:v.image;if(W!==null)ve=W.max.x-W.min.x,_e=W.max.y-W.min.y,Ee=W.isBox3?W.max.z-W.min.z:1,Te=W.min.x,Ue=W.min.y,Oe=W.isBox3?W.min.z:0;else{const mt=Math.pow(2,-V);ve=Math.floor(ft.width*mt),_e=Math.floor(ft.height*mt),v.isDataArrayTexture?Ee=ft.depth:v.isData3DTexture?Ee=Math.floor(ft.depth*mt):Ee=1,Te=0,Ue=0,Oe=0}G!==null?(Ae=G.x,Je=G.y,pt=G.z):(Ae=0,Je=0,pt=0);const et=ee.convert(F.format),Tt=ee.convert(F.type);let xe;F.isData3DTexture?(Y.setTexture3D(F,0),xe=I.TEXTURE_3D):F.isDataArrayTexture||F.isCompressedArrayTexture?(Y.setTexture2DArray(F,0),xe=I.TEXTURE_2D_ARRAY):(Y.setTexture2D(F,0),xe=I.TEXTURE_2D),p.activeTexture(I.TEXTURE0),p.pixelStorei(I.UNPACK_FLIP_Y_WEBGL,F.flipY),p.pixelStorei(I.UNPACK_PREMULTIPLY_ALPHA_WEBGL,F.premultiplyAlpha),p.pixelStorei(I.UNPACK_ALIGNMENT,F.unpackAlignment);const Ft=p.getParameter(I.UNPACK_ROW_LENGTH),qe=p.getParameter(I.UNPACK_IMAGE_HEIGHT),Gt=p.getParameter(I.UNPACK_SKIP_PIXELS),Jt=p.getParameter(I.UNPACK_SKIP_ROWS),yn=p.getParameter(I.UNPACK_SKIP_IMAGES);p.pixelStorei(I.UNPACK_ROW_LENGTH,ft.width),p.pixelStorei(I.UNPACK_IMAGE_HEIGHT,ft.height),p.pixelStorei(I.UNPACK_SKIP_PIXELS,Te),p.pixelStorei(I.UNPACK_SKIP_ROWS,Ue),p.pixelStorei(I.UNPACK_SKIP_IMAGES,Oe);const ri=v.isDataArrayTexture||v.isData3DTexture,tt=F.isDataArrayTexture||F.isData3DTexture;if(v.isDepthTexture){const mt=k.get(v),bn=k.get(F),nt=k.get(mt.__renderTarget),Tn=k.get(bn.__renderTarget);p.bindFramebuffer(I.READ_FRAMEBUFFER,nt.__webglFramebuffer),p.bindFramebuffer(I.DRAW_FRAMEBUFFER,Tn.__webglFramebuffer);for(let si=0;si<Ee;si++)ri&&(I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,k.get(v).__webglTexture,V,Oe+si),I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,k.get(F).__webglTexture,ge,pt+si)),I.blitFramebuffer(Te,Ue,ve,_e,Ae,Je,ve,_e,I.DEPTH_BUFFER_BIT,I.NEAREST);p.bindFramebuffer(I.READ_FRAMEBUFFER,null),p.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else if(V!==0||v.isRenderTargetTexture||k.has(v)){const mt=k.get(v),bn=k.get(F);p.bindFramebuffer(I.READ_FRAMEBUFFER,j),p.bindFramebuffer(I.DRAW_FRAMEBUFFER,H);for(let nt=0;nt<Ee;nt++)ri?I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,mt.__webglTexture,V,Oe+nt):I.framebufferTexture2D(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,mt.__webglTexture,V),tt?I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,bn.__webglTexture,ge,pt+nt):I.framebufferTexture2D(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,bn.__webglTexture,ge),V!==0?I.blitFramebuffer(Te,Ue,ve,_e,Ae,Je,ve,_e,I.COLOR_BUFFER_BIT,I.NEAREST):tt?I.copyTexSubImage3D(xe,ge,Ae,Je,pt+nt,Te,Ue,ve,_e):I.copyTexSubImage2D(xe,ge,Ae,Je,Te,Ue,ve,_e);p.bindFramebuffer(I.READ_FRAMEBUFFER,null),p.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else tt?v.isDataTexture||v.isData3DTexture?I.texSubImage3D(xe,ge,Ae,Je,pt,ve,_e,Ee,et,Tt,ft.data):F.isCompressedArrayTexture?I.compressedTexSubImage3D(xe,ge,Ae,Je,pt,ve,_e,Ee,et,ft.data):I.texSubImage3D(xe,ge,Ae,Je,pt,ve,_e,Ee,et,Tt,ft):v.isDataTexture?I.texSubImage2D(I.TEXTURE_2D,ge,Ae,Je,ve,_e,et,Tt,ft.data):v.isCompressedTexture?I.compressedTexSubImage2D(I.TEXTURE_2D,ge,Ae,Je,ft.width,ft.height,et,ft.data):I.texSubImage2D(I.TEXTURE_2D,ge,Ae,Je,ve,_e,et,Tt,ft);p.pixelStorei(I.UNPACK_ROW_LENGTH,Ft),p.pixelStorei(I.UNPACK_IMAGE_HEIGHT,qe),p.pixelStorei(I.UNPACK_SKIP_PIXELS,Gt),p.pixelStorei(I.UNPACK_SKIP_ROWS,Jt),p.pixelStorei(I.UNPACK_SKIP_IMAGES,yn),ge===0&&F.generateMipmaps&&I.generateMipmap(xe),p.unbindTexture()},this.initRenderTarget=function(v){k.get(v).__webglFramebuffer===void 0&&Y.setupRenderTarget(v)},this.initTexture=function(v){v.isCubeTexture?Y.setTextureCube(v,0):v.isData3DTexture?Y.setTexture3D(v,0):v.isDataArrayTexture||v.isCompressedArrayTexture?Y.setTexture2DArray(v,0):Y.setTexture2D(v,0),p.unbindTexture()},this.resetState=function(){Z=0,X=0,te=null,p.reset(),ne.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return rn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=ke._getDrawingBufferColorSpace(e),t.unpackColorSpace=ke._getUnpackColorSpace()}}const hl={type:"change"},Xa={type:"start"},nc={type:"end"},Rr=new Kr,ul=new Ln,Km=Math.cos(70*sh.DEG2RAD),vt=new D,It=2*Math.PI,je={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Bs=1e-6;class Zm extends $h{constructor(e,t=null){super(e,t),this.state=je.NONE,this.target=new D,this.cursor=new D,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Ti.ROTATE,MIDDLE:Ti.DOLLY,RIGHT:Ti.PAN},this.touches={ONE:bi.ROTATE,TWO:bi.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new D,this._lastQuaternion=new Gn,this._lastTargetPosition=new D,this._quat=new Gn().setFromUnitVectors(e.up,new D(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Bo,this._sphericalDelta=new Bo,this._scale=1,this._panOffset=new D,this._rotateStart=new Ce,this._rotateEnd=new Ce,this._rotateDelta=new Ce,this._panStart=new Ce,this._panEnd=new Ce,this._panDelta=new Ce,this._dollyStart=new Ce,this._dollyEnd=new Ce,this._dollyDelta=new Ce,this._dollyDirection=new D,this._mouse=new Ce,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Jm.bind(this),this._onPointerDown=$m.bind(this),this._onPointerUp=Qm.bind(this),this._onContextMenu=s_.bind(this),this._onMouseWheel=t_.bind(this),this._onKeyDown=n_.bind(this),this._onTouchStart=i_.bind(this),this._onTouchMove=r_.bind(this),this._onMouseDown=jm.bind(this),this._onMouseMove=e_.bind(this),this._interceptControlDown=a_.bind(this),this._interceptControlUp=o_.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(e){this._cursorStyle=e,e==="grab"?this.domElement.style.cursor="grab":this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction=""}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(hl),this.update(),this.state=je.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){const t=this.object.position;vt.copy(t).sub(this.target),vt.applyQuaternion(this._quat),this._spherical.setFromVector3(vt),this.autoRotate&&this.state===je.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,r=this.maxAzimuthAngle;isFinite(n)&&isFinite(r)&&(n<-Math.PI?n+=It:n>Math.PI&&(n-=It),r<-Math.PI?r+=It:r>Math.PI&&(r-=It),n<=r?this._spherical.theta=Math.max(n,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+r)/2?Math.max(n,this._spherical.theta):Math.min(r,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=a!=this._spherical.radius}if(vt.setFromSpherical(this._spherical),vt.applyQuaternion(this._quatInverse),t.copy(this.target).add(vt),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=vt.length();a=this._clampDistance(o*this._scale);const c=o-a;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),s=!!c}else if(this.object.isOrthographicCamera){const o=new D(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=c!==this.object.zoom;const l=new D(this._mouse.x,this._mouse.y,0);l.unproject(this.object),this.object.position.sub(l).add(o),this.object.updateMatrixWorld(),a=vt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(Rr.origin.copy(this.object.position),Rr.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Rr.direction))<Km?this.object.lookAt(this.target):(ul.setFromNormalAndCoplanarPoint(this.object.up,this.target),Rr.intersectPlane(ul,this.target))))}else if(this.object.isOrthographicCamera){const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),s=!0)}return this._scale=1,this._performCursorZoom=!1,s||this._lastPosition.distanceToSquared(this.object.position)>Bs||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Bs||this._lastTargetPosition.distanceToSquared(this.target)>Bs?(this.dispatchEvent(hl),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?It/60*this.autoRotateSpeed*e:It/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){vt.setFromMatrixColumn(t,0),vt.multiplyScalar(-e),this._panOffset.add(vt)}_panUp(e,t){this.screenSpacePanning===!0?vt.setFromMatrixColumn(t,1):(vt.setFromMatrixColumn(t,0),vt.crossVectors(this.object.up,vt)),vt.multiplyScalar(e),this._panOffset.add(vt)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const r=this.object.position;vt.copy(r).sub(this.target);let s=vt.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/n.clientHeight,this.object.matrix),this._panUp(2*t*s/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),r=e-n.left,s=t-n.top,a=n.width,o=n.height;this._mouse.x=r/a*2-1,this._mouse.y=-(s/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(It*this._rotateDelta.x/t.clientHeight),this._rotateUp(It*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(It*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-It*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(It*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-It*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(n,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(n,r)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(n*n+r*r);this._dollyStart.set(0,s)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),s=.5*(e.pageY+n.y);this._rotateEnd.set(r,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(It*this._rotateDelta.x/t.clientHeight),this._rotateUp(It*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(n,r)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(n*n+r*r);this._dollyEnd.set(0,s),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new Ce,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function $m(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function Jm(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function Qm(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(nc),this.state=je.NONE,this._cursorStyle==="grab"&&(this.domElement.style.cursor="grab");break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function jm(i){let e;switch(i.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case Ti.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=je.DOLLY;break;case Ti.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=je.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=je.ROTATE}break;case Ti.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=je.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=je.PAN}break;default:this.state=je.NONE}this.state!==je.NONE&&this.dispatchEvent(Xa)}function e_(i){switch(this.state){case je.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case je.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case je.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function t_(i){this.enabled===!1||this.enableZoom===!1||this.state!==je.NONE||(i.preventDefault(),this.dispatchEvent(Xa),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(nc))}function n_(i){this.enabled!==!1&&this._handleKeyDown(i)}function i_(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case bi.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=je.TOUCH_ROTATE;break;case bi.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=je.TOUCH_PAN;break;default:this.state=je.NONE}break;case 2:switch(this.touches.TWO){case bi.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=je.TOUCH_DOLLY_PAN;break;case bi.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=je.TOUCH_DOLLY_ROTATE;break;default:this.state=je.NONE}break;default:this.state=je.NONE}this.state!==je.NONE&&this.dispatchEvent(Xa)}function r_(i){switch(this._trackPointer(i),this.state){case je.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case je.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case je.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case je.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=je.NONE}}function s_(i){this.enabled!==!1&&i.preventDefault()}function a_(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function o_(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const l_=16317439,c_=[16748467,16762967,8246268,10980346,8843180,16478597,3718648,15772668,16639626,6220500],h_=[16758891,6333946,3462041,15235577,16436245,6220500,12616956,16020150,10741301,9684477],wi=1700,u_={x:1.42,y:.84,z:1},f_={x:1,y:1,z:1};function fl(i,e={}){const t=e.selectedKey??null,n=Mc(i,t),r=d_(n.edges,t),s=t?ml(n,t):null,a=n.nodes.map(l=>{const u=m_(l.key,t,r),m=La(l.key),h=__(l,u,t,m),d=M_(l,u),x=S_(l,u,n.nodes.length,s);return{key:l.key,node:l,x:h.x,y:h.y,z:h.z,radius:d,color:b_(l),state:u,labelTier:x,opacity:E_(u),seed:m}}),o=new Map(a.map(l=>[l.key,l])),c=n.edges.flatMap(l=>{const u=o.get(l.sourceKey),m=o.get(l.targetKey);if(!u||!m)return[];const h=!!(t&&(l.sourceKey===t||l.targetKey===t)),d=!!(t&&!h),x=d?.018:h?.32+Math.min(.2,l.weight*.2):l.visibility===2?.09:.06;return[{edge:l,source:u,target:m,color:u.color,alpha:x,width:p_(l,h,d),highlighted:h}]});return{nodes:a,edges:c,selectedNeighborKeys:r,bounds:y_(a,!!t)}}function d_(i,e){const t=new Set;if(!e)return t;for(const n of i)n.sourceKey===e&&t.add(n.targetKey),n.targetKey===e&&t.add(n.sourceKey);return t}function p_(i,e,t){const n=.75+Math.log10(i.weight+1)*.7+(i.visibility===2?.18:0);return e?Math.min(2.2,Math.max(1.65,n+.65)):t?Math.min(.8,Math.max(.55,n*.58)):Math.min(1.35,Math.max(.85,n))}function m_(i,e,t){return e?i===e?"selected":t.has(i)?"neighbor":"dimmed":"normal"}function __(i,e,t,n){if(e==="selected")return{x:0,y:0,z:0};if(!t&&i.kind==="owner")return{x:0,y:0,z:0};const r=g_(i,t),s=x_(i,e,!!t,n),a=t?f_:u_;return{x:zs(r.x*s*a.x,2),y:zs(r.y*s*a.y,2),z:zs(r.z*s*a.z,2)}}function g_(i,e){const t=e??"panorama",n=dl(`community:${t}:${i.communityId||"default"}`),r=dl(`node:${t}:${i.key}`),s=e?.7:1.15,a=e?1.15:.95;return A_({x:n.x*s+r.x*a,y:n.y*s+r.y*a,z:n.z*s+r.z*a})}function x_(i,e,t,n){const r=v_(i),s=(n-.5)*120;if(t&&e==="neighbor")return Un(980-r*650+s,220,1050);if(t&&e==="dimmed")return Un(1670-r*260+s,1280,wi);const a=i.pool==="friend"?280:620,o=i.pool==="friend"?1180:wi,c=i.pool==="non_friend"?Math.max(0,(i.rank-80)/220)*160:0;return Un(o-r*(o-a)+c+s,180,wi)}function v_(i){if(i.kind==="owner")return 1;const e=Un(i.score,0,1),t=Un(1-(i.rank-1)/120,0,1),n=Un(Math.log10(i.privateMessageCount+1)/4,0,1),r=Un(Math.log10(i.groupMessageCount+1)/4.5,0,1),s=i.pool==="friend"?.12:0;return Un(e*.36+t*.36+n*.18+r*.08+s,0,1)}function M_(i,e){let t=Math.max(i.size*.5,i.kind==="owner"?14:1.6);const n=Math.max(0,1-(i.rank-1)/50);return t+=Math.pow(n,1.35)*6,i.rank<=3?t+=2.5:i.rank<=10&&(t+=1.2),e==="selected"?t+5.5:e==="neighbor"?t+1.5:t}function S_(i,e,t,n){return n?n.has(i.key)?e==="selected"||i.kind==="owner"?2:1:0:e==="selected"||i.labelVisibility===2||i.kind==="owner"?2:e==="neighbor"&&i.rank<=30||i.labelVisibility===1&&t<=300||i.rank<=6?1:0}function E_(i){return i==="selected"?1:i==="neighbor"?.95:i==="dimmed"?.1:.82}function y_(i,e){if(i.length===0)return{minX:-500,maxX:500,minY:-500,maxY:500,minZ:-wi,maxZ:wi,width:1e3,height:1e3,depth:wi*2};let t=0,n=0,r=0;for(const l of i)t=Math.max(t,Math.abs(l.x)),n=Math.max(n,Math.abs(l.y)),r=Math.max(r,Math.abs(l.z));const s=Math.max(400,t,n,r);if(e)return{minX:-s,maxX:s,minY:-s,maxY:s,minZ:-s,maxZ:s,width:s*2,height:s*2,depth:s*2};const a=Math.max(400,t),o=Math.max(400,n),c=Math.max(400,r);return{minX:-a,maxX:a,minY:-o,maxY:o,minZ:-c,maxZ:c,width:a*2,height:o*2,depth:c*2}}function b_(i){return i.kind==="owner"?l_:T_(i)}function T_(i){const e=i.pool==="friend"?c_:h_,t=ic(`${i.communityId}:${i.key}:${i.rank}:${i.pool}`)%e.length;return e[t]??e[0]}function dl(i){const e=La(`${i}:azimuth`)*Math.PI*2,t=La(`${i}:z`)*2-1,n=Math.sqrt(Math.max(0,1-t*t));return{x:Math.cos(e)*n,y:Math.sin(e)*n,z:t}}function A_(i){const e=Math.hypot(i.x,i.y,i.z);return e<=1e-4?{x:1,y:0,z:0}:{x:i.x/e,y:i.y/e,z:i.z/e}}function La(i){return ic(i)/4294967295}function ic(i){let e=2166136261;for(let t=0;t<i.length;t++)e^=i.charCodeAt(t),e=Math.imul(e,16777619);return e>>>0}function zs(i,e=2){const t=10**e;return Math.round(i*t)/t}function Un(i,e,t){return Math.min(t,Math.max(e,i))}const R_=6;function w_(i,e,t){const n=i.distanceTo(e);if(n<=.001)return[i.clone(),e.clone()];const r=e.clone().sub(i).normalize(),s=new D(0,1,0);Math.abs(r.y)>.9&&s.set(1,0,0);const a=new D().crossVectors(r,s).normalize(),o=new D().crossVectors(r,a).normalize(),c=C_(a,o,t).multiplyScalar(Math.max(5,n*.08)),l=i.clone().lerp(e,.5).add(c);return new zh(i,l,e).getPoints(R_)}function C_(i,e,t){const n=t*7.1%1-.5,r=t*13.3%1-.5,s=i.clone().multiplyScalar(n).add(e.clone().multiplyScalar(r));return s.lengthSq()<=1e-4?i.clone():s.normalize()}const P_=new ze(16777215);function D_(i,e,t,n,r){return i.copy(e).lerp(t,L_(r)),i.lerp(P_,I_(n)),i.multiplyScalar(U_(n)),i}function L_(i){return i<=0?0:i>=1?1:i}function I_(i){return i==="highlight"?.06:i==="normal"?.16:.26}function U_(i){return i==="highlight"?1:i==="normal"?.56:.38}const pl=.9;function N_(i){const e=Math.max(i.width,i.height,i.depth,900);return{position:{x:0,y:-e*.5*pl,z:e*.5*pl},target:{x:0,y:0,z:0}}}function F_(i,e){const t=_l(e),n=Math.max(1,e.viewportWidth);if(t<=0)return i;const r=V_({x:i.target.x-i.position.x,y:i.target.y-i.position.y,z:i.target.z-i.position.z}),s=Math.max(1,G_(i.position,i.target)),a=Math.max(.001,(n-t)/n),o=s/a;return{position:B_(i.target,z_(r,-o)),target:i.target}}function O_(i){const e=Math.max(1,Math.floor(i.viewportWidth)),t=Math.max(1,Math.floor(i.viewportHeight)),n=Math.floor(_l(i));return n<=0?null:{fullWidth:e+n,fullHeight:t,offsetX:n,offsetY:0,width:e,height:t}}function B_(i,e){return{x:i.x+e.x,y:i.y+e.y,z:i.z+e.z}}function z_(i,e){return{x:i.x*e,y:i.y*e,z:i.z*e}}function G_(i,e){return Math.hypot(i.x-e.x,i.y-e.y,i.z-e.z)}function V_(i){const e=Math.hypot(i.x,i.y,i.z);return e<=0?{x:1,y:0,z:0}:{x:i.x/e,y:i.y/e,z:i.z/e}}const H_=["aria-label"],k_={class:"pointer-events-none absolute inset-0 z-10 overflow-hidden"},W_=["onBlur","onClick","onFocus","onMouseenter","onMouseleave"],X_=lc({__name:"RelationshipGalaxyThreeCanvas",props:{graph:{},selectedKey:{default:null},privacyMode:{type:Boolean,default:!1},safeInsetRight:{default:0},emphasizeEdges:{type:Boolean,default:!1},label:{},ownerLabel:{}},emits:["select-node","fallback"],setup(i,{expose:e,emit:t}){const n=i,r=t,s=io(null),a=es([]),o=io(null),c=es(fl(n.graph,{selectedKey:n.selectedKey})),l=es(null);let u=null,m=null,h=null,d=null,x=null,y=0,_=0,f=0,w=!1,C=null,S=null;const R=new Nn,b=new Nn,P=new Nn,g=new Map,T=[],U=new Map,L=new Zh,z=new Ce,$=new D;function j(A){if(A.kind==="owner")return n.ownerLabel;const M=A.displayName||A.platformId||A.key;return n.privacyMode?Sc(M):M}function H(){const A=s.value?.getBoundingClientRect();return{width:Math.max(1,Math.floor(A?.width??1)),height:Math.max(1,Math.floor(A?.height??1))}}function Z(A,M){const B=(M.bounds.minX+M.bounds.maxX)/2,N=(M.bounds.minY+M.bounds.maxY)/2;return new D(A.x-B,-(A.y-N),A.z)}function X(A=!1){if(!m||!h||!u)return;const M=fl(n.graph,{selectedKey:n.selectedKey});c.value=M,te(),ae(b),ae(P),g.clear(),T.length=0,U.clear(),o.value=null,f=0,a.value=[];for(const B of M.edges)U.has(B.edge.sourceKey)||U.set(B.edge.sourceKey,new Set),U.has(B.edge.targetKey)||U.set(B.edge.targetKey,new Set),U.get(B.edge.sourceKey).add(B.edge.targetKey),U.get(B.edge.targetKey).add(B.edge.sourceKey);ie(M,"dim"),ie(M,"normal"),ie(M,"highlight");for(const B of M.nodes){const N=Z(B,M),ee=Ye(B,N);g.set(B.key,ee),T.push(ee.core),P.add(ee.group)}(A||!w)&&yt(),xt()}function te(){l.value=n.selectedKey?ml(n.graph,n.selectedKey):null}function ie(A,M){const B=A.edges.filter(N=>M==="highlight"?N.highlighted:M==="dim"?N.alpha<=.05:!N.highlighted&&N.alpha>.05);if(B.length!==0)for(const N of Me(B,M))fe(A,N.edges,M,N.linewidth)}function fe(A,M,B,N){const ee=new Hl({vertexColors:!0,transparent:!0,opacity:B==="highlight"?.62:B==="normal"?n.emphasizeEdges?.27:.21:.05,linewidth:N,blending:On,depthTest:!0,depthWrite:!1}),ne=new ze,q=new ze,de=new ze,ue=[],Ge=[];for(const st of M){const Sn=Z(st.source,A),Qr=Z(st.target,A),Hn=w_(Sn,Qr,st.source.seed+st.target.seed),ti=Math.max(1,Hn.length-1);ne.setHex(st.source.color),q.setHex(st.target.color);for(let En=0;En<Hn.length-1;En+=1){const ni=Hn[En],ii=Hn[En+1];ue.push(ni.x,ni.y,ni.z,ii.x,ii.y,ii.z),me(Ge,de,ne,q,B,En/ti),me(Ge,de,ne,q,B,(En+1)/ti)}}if(ue.length===0){ee.dispose();return}const Ie=new Xt;Ie.setAttribute("position",new zt(ue,3)),Ie.setAttribute("color",new zt(Ge,3));const ct=new Lh(Ie,ee);ct.frustumCulled=!1,b.add(ct)}function me(A,M,B,N,ee,ne){D_(M,B,N,ee,ne),A.push(M.r,M.g,M.b)}function Me(A,M){const B=new Map;for(const N of A){const ee=Xe(N,M),ne=B.get(ee)??[];ne.push(N),B.set(ee,ne)}return[...B.entries()].map(([N,ee])=>({linewidth:N,edges:ee}))}function Xe(A,M){return M==="highlight"?A.width>=2?2:1.65:M==="dim"?.55:A.width>=1.2?1.12:A.width>=.95?.96:.82}function rt(A){return A.state==="selected"?2.18:A.node.kind==="owner"?2.04:A.node.rank<=10?1.76:1.52}function Ye(A,M){const B=new Nn;B.position.copy(M);const N=new Th(new Bl({map:he(A.color,Math.floor(A.seed*8)),color:16777215,transparent:!0,opacity:A.opacity,blending:On,depthWrite:!1,alphaTest:.02}));return N.scale.setScalar(A.radius*rt(A)),N.userData.key=A.key,B.add(N),{group:B,core:N,sceneNode:A,basePosition:M,phase:A.seed*Math.PI*2}}function Q(){if(!u||!m||!h||!d)return;const A=performance.now()-_;le();const M=w?.003:.008;R.rotation.y=Math.sin(A/25e3)*M,R.rotation.x=Math.cos(A/3e4)*M*.4;const B=o.value||n.selectedKey;for(const N of g.values()){const ee=A/1e3+N.phase,ne=N.sceneNode.key===n.selectedKey,q=N.sceneNode.key===B,de=!!(B&&U.get(B)?.has(N.sceneNode.key)),ue=ne?.3:.8,Ge=o.value===N.sceneNode.key?1.28:1,Ie=ne?1.22:1,ct=de?1.08:1;N.group.position.set(N.basePosition.x+Math.sin(ee*.3)*2*ue,N.basePosition.y+Math.cos(ee*.25)*1.5*ue,N.basePosition.z+Math.sin(ee*.2)*4*ue),N.group.scale.setScalar((1+Math.sin(ee*.8)*.006)*Ge*Ie*ct);const st=N.core.material;let Sn=N.sceneNode.opacity;B&&(q?Sn=1:de?Sn=.85:Sn=.1),st.opacity+=(Sn-st.opacity)*.16}d.update(),re(),u.render(m,h),y=requestAnimationFrame(Q)}function le(){if(!d||!h||!S)return;const A=Math.min(1,(performance.now()-S.startedAt)/S.duration),M=J(A);h.position.lerpVectors(S.fromPosition,S.toPosition,M),d.target.lerpVectors(S.fromTarget,S.toTarget,M),A>=1&&(S=null)}function re(){if(!u||!h||(f+=1,f%2!==0))return;const{width:A,height:M}=H(),B=[],N=n.selectedKey,ee=N?U.get(N):null;for(const ne of g.values()){const q=ne.sceneNode.key===N,de=!!(N&&ee?.has(ne.sceneNode.key)),ue=Pe(ne.sceneNode,N??null,o.value);if(ue===0)continue;ne.group.getWorldPosition($);const Ge=$.clone().project(h);if(Ge.z<-1||Ge.z>1)continue;const Ie=(Ge.x*.5+.5)*A,ct=(-Ge.y*.5+.5)*M;Ie<-80||Ie>A+80||ct<-40||ct>M+40||B.push({key:ne.sceneNode.key,text:j(ne.sceneNode.node),x:Ie,y:ct+ne.sceneNode.radius+8,opacity:q?1:Math.max(.42,ne.core.material.opacity),selected:q,emphasis:De(ne.sceneNode,de,ue)})}a.value=B}function Pe(A,M,B){return A.key===B?A.labelTier===2?2:1:M?l.value?.has(A.key)?A.key===M||A.node.kind==="owner"?2:1:0:A.labelTier}function De(A,M=!1,B=A.labelTier){return B===2||A.node.kind==="owner"||A.node.rank<=5?"major":M||A.node.rank<=30?"medium":"minor"}async function Re(){const A=s.value;if(!A||u)return;const M=H();m=new vh,m.fog=new Wa(656643,32e-5),h=new Ht(45,M.width/M.height,1,3e4),h.position.set(0,-150,900);try{u=new qm({antialias:!0,alpha:!0,powerPreference:"high-performance"})}catch(B){console.warn("relationship galaxy 3d renderer unavailable",B),r("fallback");return}u.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),u.setSize(M.width,M.height),u.outputColorSpace=Ut,u.domElement.className="h-full w-full",A.appendChild(u.domElement),d=new Zm(h,u.domElement),d.enableDamping=!0,d.dampingFactor=.055,d.rotateSpeed=.34,d.zoomSpeed=.72,d.panSpeed=.58,d.minDistance=160,d.maxDistance=9e3,d.addEventListener("start",()=>{w=!0,S=null}),R.add(b),R.add(P),m.add(R),u.domElement.addEventListener("pointermove",Fe),u.domElement.addEventListener("pointerleave",Ze),u.domElement.addEventListener("click",We),x=new ResizeObserver(ot),x.observe(A),X(!0),_=performance.now(),y=requestAnimationFrame(Q)}function ot(){if(!u||!h)return;const A=H();h.aspect=A.width/A.height,u.setSize(A.width,A.height),E(A)}function Fe(A){if(!u||!h)return;const M=u.domElement.getBoundingClientRect();z.x=(A.clientX-M.left)/M.width*2-1,z.y=-((A.clientY-M.top)/M.height)*2+1,L.setFromCamera(z,h);const[B]=L.intersectObjects(T,!1);o.value=typeof B?.object.userData.key=="string"?B.object.userData.key:null}function Ze(){o.value=null}function We(){const A=o.value;if(!A)return;const M=g.get(A);M&&r("select-node",M.sceneNode.node)}function Ve(A){const M=g.get(A);M&&r("select-node",M.sceneNode.node)}function lt(A){o.value=A}function ht(A){o.value===A&&(o.value=null)}function _t(A){A.preventDefault(),A.stopPropagation();const M=u?.domElement;M&&M.dispatchEvent(new WheelEvent("wheel",{bubbles:!0,cancelable:!0,clientX:A.clientX,clientY:A.clientY,ctrlKey:A.ctrlKey,deltaMode:A.deltaMode,deltaX:A.deltaX,deltaY:A.deltaY,deltaZ:A.deltaZ,metaKey:A.metaKey,screenX:A.screenX,screenY:A.screenY,shiftKey:A.shiftKey}))}function xt(){if(!C)return;const A=C;if(!g.has(A)){C=null;return}it(A)}function it(A){if(!h||!d)return C=A,!1;const M=g.get(A);if(!M)return C=A,!1;C=null,w=!0;const B=M.basePosition.clone(),N=Math.max(180,Math.min(600,c.value.bounds.width*.18)),ee=Ke({position:p(B.clone().add(new D(0,-N*.25,N))),target:p(B)});return se(new D(ee.position.x,ee.position.y,ee.position.z),new D(ee.target.x,ee.target.y,ee.target.z),540),!0}function ut(){return!h||!d?null:{kind:"3d",position:p(h.position),target:p(d.target),hasUserMovedCamera:w}}function I(A){return!O(A)||!h||!d?!1:(C=null,w=A.hasUserMovedCamera,E(),se(new D(A.position.x,A.position.y,A.position.z),new D(A.target.x,A.target.y,A.target.z),620),!0)}function yt(){if(!h||!d)return;w=!1;const A=Ke(N_(c.value.bounds));se(new D(A.position.x,A.position.y,A.position.z),new D(A.target.x,A.target.y,A.target.z),620)}function Ke(A){const M=H();return E(M),F_(A,{viewportWidth:M.width,viewportHeight:M.height,safeInsetRight:n.safeInsetRight,fovDegrees:h?.fov??45})}function E(A=H()){if(!h)return;const M=O_({viewportWidth:A.width,viewportHeight:A.height,safeInsetRight:n.safeInsetRight});if(!M){h.clearViewOffset();return}h.setViewOffset(M.fullWidth,M.fullHeight,M.offsetX,M.offsetY,M.width,M.height)}function p(A){return{x:A.x,y:A.y,z:A.z}}function O(A){return Y(A)?A.kind==="3d"&&k(A.position)&&k(A.target)&&typeof A.hasUserMovedCamera=="boolean":!1}function k(A){return Y(A)?typeof A.x=="number"&&Number.isFinite(A.x)&&typeof A.y=="number"&&Number.isFinite(A.y)&&typeof A.z=="number"&&Number.isFinite(A.z):!1}function Y(A){return typeof A=="object"&&A!==null}function se(A,M,B){!h||!d||(S={startedAt:performance.now(),duration:B,fromPosition:h.position.clone(),toPosition:A,fromTarget:d.target.clone(),toTarget:M})}function ae(A){for(;A.children.length>0;){const M=A.children.pop();M&&K(M)}}function K(A){A.traverse(M=>{const B=M;if(B.geometry?.dispose(),Array.isArray(B.material))for(const N of B.material)N.dispose();else B.material?.dispose()})}function J(A){return A<.5?4*A*A*A:1-Math.pow(-2*A+2,3)/2}function oe(A){const M=Math.sin(A*12.9898)*43758.5453;return M-Math.floor(M)}const Se=new Map;function he(A,M){const N=`star:${A.toString(16).padStart(6,"0")}:${M}`,ee=Se.get(N);if(ee)return ee;const ne=document.createElement("canvas");ne.width=128,ne.height=128;const q=ne.getContext("2d");if(!q)throw new Error("failed to create galaxy texture context");const de=new ze(A),ue=1.04+oe(M+4.2)*.06,Ge=.94+oe(M+9.8)*.05,Ie=(oe(M+17.4)-.5)*.32,ct=.18+oe(M+21.7)*.12;ce(q,ue,Ge,Ie,38,[[0,"rgba(255,255,255,0.1)"],[.26,be(de,.16)],[.58,be(de,.04)],[1,"rgba(255,255,255,0)"]]),ye(q,Ie,48,2.2,ct,de),ye(q,Ie+Math.PI/2,32,1.35,ct*.62,de),M%3===0&&ye(q,Ie+Math.PI/4,22,.9,ct*.34,de),ce(q,ue,Ge,Ie,18,[[0,"rgba(255,255,255,1)"],[.28,"rgba(255,255,255,0.94)"],[.54,be(de,.95)],[.78,be(de,.38)],[1,"rgba(255,255,255,0)"]]);const st=new Ih(ne);return st.colorSpace=Ut,Se.set(N,st),st}function ce(A,M,B,N,ee,ne){A.save(),A.translate(64,64),A.rotate(N),A.scale(M,B);const q=A.createRadialGradient(0,0,0,0,0,ee);for(const[de,ue]of ne)q.addColorStop(de,ue);A.fillStyle=q,A.beginPath(),A.arc(0,0,ee,0,Math.PI*2),A.fill(),A.restore()}function ye(A,M,B,N,ee,ne){A.save(),A.translate(64,64),A.rotate(M);const q=A.createLinearGradient(-B,0,B,0);q.addColorStop(0,"rgba(255,255,255,0)"),q.addColorStop(.43,be(ne,ee*.32)),q.addColorStop(.5,`rgba(255,255,255,${ee})`),q.addColorStop(.57,be(ne,ee*.32)),q.addColorStop(1,"rgba(255,255,255,0)"),A.fillStyle=q,A.fillRect(-B,-N/2,B*2,N),A.restore()}function be(A,M){return`rgba(${Math.round(A.r*255)},${Math.round(A.g*255)},${Math.round(A.b*255)},${M})`}return cc(async()=>{await hc(),await Re()}),ji(()=>n.graph,()=>{X(!1)},{flush:"post"}),ji(()=>n.selectedKey,()=>{X(!1)},{flush:"post"}),ji(()=>n.emphasizeEdges,()=>{X(!1)},{flush:"post"}),ji(()=>n.privacyMode,()=>{f=1,re()},{flush:"post"}),uc(()=>{y&&cancelAnimationFrame(y),x?.disconnect(),x=null,u&&(u.domElement.removeEventListener("pointermove",Fe),u.domElement.removeEventListener("pointerleave",Ze),u.domElement.removeEventListener("click",We)),ae(b),ae(P);for(const A of Se.values())A.dispose();Se.clear(),R.clear(),m?.clear(),d?.dispose(),u?.dispose(),u?.domElement.remove(),u=null,m=null,h=null,d=null,a.value=[]}),e({focusNode:it,fitView:yt,captureView:ut,restoreView:I}),(A,M)=>(ts(),ns("div",{ref_key:"canvasRoot",ref:s,class:"relationship-galaxy-3d relative h-full w-full overflow-hidden",role:"img","aria-label":i.label},[fc("div",k_,[(ts(!0),ns(dc,null,pc(a.value,B=>(ts(),ns("button",{key:B.key,type:"button",class:gc(["relationship-galaxy-3d__label",[`relationship-galaxy-3d__label--${B.emphasis}`,{"relationship-galaxy-3d__label--selected":B.selected}]]),style:_c({left:`${B.x}px`,top:`${B.y}px`,opacity:B.opacity}),onBlur:N=>ht(B.key),onClick:mc(N=>Ve(B.key),["stop"]),onFocus:N=>lt(B.key),onMouseenter:N=>lt(B.key),onMouseleave:N=>ht(B.key),onWheel:_t},xc(B.text),47,W_))),128))])],8,H_))}}),Q_=vc(X_,[["__scopeId","data-v-a525ac17"]]);export{Q_ as default};