mixdashboards 1.0.32 → 1.0.39

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 (413) hide show
  1. package/dist/CoordinateSystem-BMkAxlii.js +6 -0
  2. package/dist/CoordinateSystem-DWnjjFwb.cjs +1 -0
  3. package/dist/EChartComponentBase-BQOhWkz2.js +114 -0
  4. package/dist/EChartComponentBase-BaQpBzVC.cjs +1 -0
  5. package/dist/LegendVisualProvider-BDw4_0K3.cjs +1 -0
  6. package/dist/LegendVisualProvider-BP9kA8co.js +44 -0
  7. package/dist/MarkerView-BG_nYESR.cjs +1 -0
  8. package/dist/MarkerView-CtWJi5UZ.js +192 -0
  9. package/dist/RoamController--cgD3aNm.cjs +1 -0
  10. package/dist/RoamController-DmBIwcAZ.js +124 -0
  11. package/dist/UniverSheet-KlvmL1Yw.cjs +1 -0
  12. package/dist/UniverSheet-MSHzUXq0.js +180 -0
  13. package/dist/VisualMapping-D-MA7S0X.js +260 -0
  14. package/dist/VisualMapping-MilpZvD_.cjs +1 -0
  15. package/dist/accelerationChart-B1HPMmd2.js +577 -0
  16. package/dist/accelerationChart-DZj2V2vD.cjs +6 -0
  17. package/dist/actionItem-BYCPoQK7.cjs +1 -0
  18. package/dist/actionItem-Bb2xiYlY.js +686 -0
  19. package/dist/alarmLevelChart-Bb0mAbwQ.cjs +2 -0
  20. package/dist/alarmLevelChart-CCioESvL.js +182 -0
  21. package/dist/alertTable-CQwr8YYt.js +301 -0
  22. package/dist/alertTable-oaX5eJC0.cjs +1 -0
  23. package/dist/annualRainfallChart-C21jEMBe.js +185 -0
  24. package/dist/annualRainfallChart-pO8q6aUJ.cjs +1 -0
  25. package/dist/api-C0GhBpqd.js +125 -0
  26. package/dist/api-P_s372dW.cjs +1 -0
  27. package/dist/aqi-DlY2r7OA.cjs +3 -0
  28. package/dist/aqi-iLwQH4rc.js +145 -0
  29. package/dist/aqiIndass-BaIVBfdC.cjs +3 -0
  30. package/dist/aqiIndass-DBeVSBdy.js +301 -0
  31. package/dist/arrayCard-DNNUEPvW.js +93 -0
  32. package/dist/arrayCard-OlVAAsZq.cjs +1 -0
  33. package/dist/audio-CAP4D-J2.js +301 -0
  34. package/dist/audio-CThzVIDU.cjs +1 -0
  35. package/dist/axisAlignTicks-BqVUa467.js +481 -0
  36. package/dist/axisAlignTicks-CDNWKJRo.cjs +1 -0
  37. package/dist/bar-BjR566__.cjs +2 -0
  38. package/dist/bar-D8C06GO4.js +232 -0
  39. package/dist/bmp-Cjizh2x6.js +226 -0
  40. package/dist/bmp-DsmTzyce.cjs +1 -0
  41. package/dist/box-DqewT3MF.js +352 -0
  42. package/dist/box-qgu_67OD.cjs +1 -0
  43. package/dist/chartConfigPanel-BiQArCoQ.cjs +1 -0
  44. package/dist/chartConfigPanel-DwAUq3pf.js +408 -0
  45. package/dist/circleBar-CO89T7kj.cjs +4 -0
  46. package/dist/circleBar-DGHDWQih.js +196 -0
  47. package/dist/clock-32hGccm4.cjs +1 -0
  48. package/dist/clock-CT8YXEU3.js +274 -0
  49. package/dist/clt-5bP_g1O-.cjs +1 -0
  50. package/dist/clt-FfIEfGtn.js +293 -0
  51. package/dist/cmc-B2nQFZIS.js +269 -0
  52. package/dist/cmc-dbuLkE8o.cjs +1 -0
  53. package/dist/cmp-QQlYcnqo.js +378 -0
  54. package/dist/cmp-l3U9fIrz.cjs +6 -0
  55. package/dist/composite-CbsUYl-u.js +136 -0
  56. package/dist/composite-Cf24lSyN.cjs +1 -0
  57. package/dist/composite-DjhrBgG1.js +323 -0
  58. package/dist/composite-DlY2_x6P.cjs +3 -0
  59. package/dist/config-BLSroAzs.cjs +1 -0
  60. package/dist/config-Cc2W4vke.js +9 -0
  61. package/dist/controlList-BdF8xNAi.js +879 -0
  62. package/dist/controlList-De6PXdOc.cjs +1 -0
  63. package/dist/controlRecordList-CKpAr1ON.js +421 -0
  64. package/dist/controlRecordList-u5a7chIX.cjs +1 -0
  65. package/dist/crd-BVAf41oX.js +113 -0
  66. package/dist/crd-BoaXQhFQ.cjs +1 -0
  67. package/dist/createSeriesData-Cz83cqoZ.cjs +1 -0
  68. package/dist/createSeriesData-E53TTCAt.js +116 -0
  69. package/dist/createSeriesDataSimply-Bsly4zZA.js +14 -0
  70. package/dist/createSeriesDataSimply-CjfZL_jf.cjs +1 -0
  71. package/dist/ctrBtn-C9kQiqY1.cjs +1 -0
  72. package/dist/ctrBtn-ZPRYWE66.js +215 -0
  73. package/dist/ctrSet-C87dxLfQ.js +247 -0
  74. package/dist/ctrSet-CNCrnLSs.cjs +1 -0
  75. package/dist/ctrSwitch-CVEtbdfb.cjs +1 -0
  76. package/dist/ctrSwitch-CkC_Axtp.js +207 -0
  77. package/dist/cursorHelper-DE0KU4_J.js +29 -0
  78. package/dist/cursorHelper-DsTR8jVF.cjs +1 -0
  79. package/dist/customGraphicKeyframeAnimation-BJ_z0kB3.js +330 -0
  80. package/dist/customGraphicKeyframeAnimation-CEIvOjMs.cjs +1 -0
  81. package/dist/dataManagement-CjlNfeYq.js +672 -0
  82. package/dist/dataManagement-n711sd1g.cjs +1 -0
  83. package/dist/dataReport-BsVjW3p7.cjs +4 -0
  84. package/dist/dataReport-ByjswEqq.js +787 -0
  85. package/dist/dataSample-BXwc06Sb.js +114 -0
  86. package/dist/dataSample-D4ycwmll.cjs +1 -0
  87. package/dist/dataTable-DX500R1i.js +217 -0
  88. package/dist/dataTable-K7j4fhnq.cjs +1 -0
  89. package/dist/datetime-DVbJtALf.js +113 -0
  90. package/dist/datetime-DYXWKrXI.cjs +1 -0
  91. package/dist/deepClusterSlipSurface-B7nkEM9A.cjs +1 -0
  92. package/dist/deepClusterSlipSurface-CQUE05cK.js +372 -0
  93. package/dist/deepDataMatrix-DHZA0IAm.cjs +1 -0
  94. package/dist/deepDataMatrix-ai5rB6ET.js +238 -0
  95. package/dist/deepDisplacement3D-BFqKqSYg.cjs +4289 -0
  96. package/dist/deepDisplacement3D-BsUzvbQb.js +26052 -0
  97. package/dist/deepDisplacementChart-2JZNrhrw.cjs +5 -0
  98. package/dist/deepDisplacementChart-BCIuCMdK.js +585 -0
  99. package/dist/deepDisplacementChart-Ba67v6um.cjs +6 -0
  100. package/dist/deepDisplacementChart-igl4rW1K.js +340 -0
  101. package/dist/deepDisplacementView-BedWJsx7.js +231 -0
  102. package/dist/deepDisplacementView-wQxyKzB-.cjs +8 -0
  103. package/dist/deepNodeTemperatureChart-DLeb9jKp.js +347 -0
  104. package/dist/deepNodeTemperatureChart-albL8hKa.cjs +1 -0
  105. package/dist/deepTangentAngleChart-C6xOiITk.js +420 -0
  106. package/dist/deepTangentAngleChart-DukevXaM.cjs +1 -0
  107. package/dist/deepTemperatureField-B-y94GPV.js +398 -0
  108. package/dist/deepTemperatureField-De4xKoHw.cjs +1 -0
  109. package/dist/deepTrendChart-DCkV2HNv.js +345 -0
  110. package/dist/deepTrendChart-MmuYSXtu.cjs +1 -0
  111. package/dist/deviceOnlineStatus-B5cCjhNA.cjs +2 -0
  112. package/dist/deviceOnlineStatus-CFuCTx7_.js +178 -0
  113. package/dist/deviceStatus-B2ibBDSi.js +194 -0
  114. package/dist/deviceStatus-DsEtKiGo.cjs +1 -0
  115. package/dist/displacementDataTable-BDqG1IvI.js +256 -0
  116. package/dist/displacementDataTable-oLnUdafv.cjs +1 -0
  117. package/dist/displacementTrajectoryChart-CBhPwZhe.cjs +22 -0
  118. package/dist/displacementTrajectoryChart-Crf55oKi.js +597 -0
  119. package/dist/displacementTrendChart-10n_lC9j.js +364 -0
  120. package/dist/displacementTrendChart-CWihCuIJ.cjs +5 -0
  121. package/dist/dxf-D8zHpz5g.js +2768 -0
  122. package/dist/dxf-DDh_DcQy.cjs +1 -0
  123. package/dist/dzc-DLCdTCwW.js +144 -0
  124. package/dist/dzc-uNTDJqpi.cjs +2 -0
  125. package/dist/echarts-BB8O2KSA.cjs +21 -0
  126. package/dist/echarts-BVht3HHb.js +13787 -0
  127. package/dist/ele-aqi-icon-BMm9WgFH.cjs +1 -0
  128. package/dist/ele-aqi-icon-DsYfU5th.js +5 -0
  129. package/dist/ele-bar-icon-C-GiCs2a.js +5 -0
  130. package/dist/ele-bar-icon-V94clxg_.cjs +1 -0
  131. package/dist/ele-bmp-icon-BBI0-SX7.cjs +1 -0
  132. package/dist/ele-bmp-icon-Pdolk1J5.js +5 -0
  133. package/dist/ele-circleBar-icon-DNBUxt0A.js +5 -0
  134. package/dist/ele-circleBar-icon-Da0-L9sa.cjs +1 -0
  135. package/dist/ele-clt-icon-BEVOS7Tq.cjs +1 -0
  136. package/dist/ele-clt-icon-DuU4Q401.js +5 -0
  137. package/dist/ele-cmp-icon-CEP91RUe.js +5 -0
  138. package/dist/ele-cmp-icon-yUlU6c_Q.cjs +1 -0
  139. package/dist/ele-crd-icon-BXxB7P3T.js +5 -0
  140. package/dist/ele-crd-icon-BvNgAPKW.cjs +1 -0
  141. package/dist/ele-ctrSet-icon-BtKGrCid.js +5 -0
  142. package/dist/ele-ctrSet-icon-DCsPO0tL.cjs +1 -0
  143. package/dist/ele-dateTime-icon-BEGFlwID.js +5 -0
  144. package/dist/ele-dateTime-icon-BgZ2_KWW.cjs +1 -0
  145. package/dist/ele-dzc-icon-D6eVpaHp.js +5 -0
  146. package/dist/ele-dzc-icon-h5wOUHF0.cjs +1 -0
  147. package/dist/ele-evn-icon-DUQMS-9T.cjs +1 -0
  148. package/dist/ele-evn-icon-MWzAujnD.js +5 -0
  149. package/dist/ele-gag-icon-CB5dJeYF.js +5 -0
  150. package/dist/ele-gag-icon-Ce1hl9NI.cjs +1 -0
  151. package/dist/ele-glbModel-icon-ByACDCrv.cjs +1 -0
  152. package/dist/ele-glbModel-icon-l_SMi3ik.js +5 -0
  153. package/dist/ele-grd-icon-DR52zwGR.js +5 -0
  154. package/dist/ele-grd-icon-ZUb-megQ.cjs +1 -0
  155. package/dist/ele-gridview-icon-D3GcssP6.cjs +1 -0
  156. package/dist/ele-gridview-icon-cSd1oIDi.js +5 -0
  157. package/dist/ele-lin-icon-Dax-ZiWV.js +5 -0
  158. package/dist/ele-lin-icon-Dke_1AmT.cjs +1 -0
  159. package/dist/ele-lst-icon-CKpeRKmk.js +5 -0
  160. package/dist/ele-lst-icon-CrxnHZ-A.cjs +1 -0
  161. package/dist/ele-mxa-icon-CJWttkCK.js +5 -0
  162. package/dist/ele-mxa-icon-fgN0MLnh.cjs +1 -0
  163. package/dist/ele-rtn-icon-BrsJIU8J.cjs +1 -0
  164. package/dist/ele-rtn-icon-CqCKSHIw.js +5 -0
  165. package/dist/ele-textbox-icon-ClGaLi5p.js +5 -0
  166. package/dist/ele-textbox-icon-g_5kV8t6.cjs +1 -0
  167. package/dist/ele-vdo-icon-Bgp9gaT6.cjs +1 -0
  168. package/dist/ele-vdo-icon-DcWebTR5.js +5 -0
  169. package/dist/ele-vlu-icon-Bg6EHZdJ.js +5 -0
  170. package/dist/ele-vlu-icon-Dv-R7Xuc.cjs +1 -0
  171. package/dist/element-resize-detector-Bo5uDQAu.cjs +6 -0
  172. package/dist/element-resize-detector-DJcsrJ8s.js +1547 -0
  173. package/dist/evn-DuL5oVRl.cjs +1 -0
  174. package/dist/evn-YwCALVXj.js +116 -0
  175. package/dist/evolutionChart-4noZSdLX.js +406 -0
  176. package/dist/evolutionChart-AeL67MAt.cjs +1 -0
  177. package/dist/fileViewer-DiH3PM0r.js +415 -0
  178. package/dist/fileViewer-bsrjlJkC.cjs +1 -0
  179. package/dist/filterBar-CWEguwYc.js +394 -0
  180. package/dist/filterBar-Ct1BFhrS.cjs +1 -0
  181. package/dist/fireCombustionCurve-DYPC4zKJ.js +405 -0
  182. package/dist/fireCombustionCurve-DyiQn-WA.cjs +1 -0
  183. package/dist/fireFilterBar-Bdm2ljuO.cjs +1 -0
  184. package/dist/fireFilterBar-DGHPNTwF.js +221 -0
  185. package/dist/gag-HiNaL81R.cjs +1 -0
  186. package/dist/gag-kvkKzJuO.js +125 -0
  187. package/dist/glbModel-CUz6CyVF.js +2724 -0
  188. package/dist/glbModel-DtBI72ap.cjs +5 -0
  189. package/dist/gnssFilterBar-BQgY5x1W.cjs +1 -0
  190. package/dist/gnssFilterBar-TBtirXIB.js +310 -0
  191. package/dist/gnssHistoryTable-D1ZLJOgh.cjs +3 -0
  192. package/dist/gnssHistoryTable-U8O7nyO7.js +398 -0
  193. package/dist/gnssMapView-42zmAd9q.cjs +7 -0
  194. package/dist/gnssMapView-CaBfWeT1.js +699 -0
  195. package/dist/gnssTimeSeriesChart-BrXYvuh6.js +421 -0
  196. package/dist/gnssTimeSeriesChart-CV2w_Aik.cjs +1 -0
  197. package/dist/gnssXYTrajectory-BmzSYjQ_.cjs +5 -0
  198. package/dist/gnssXYTrajectory-D2DoYnze.js +304 -0
  199. package/dist/grd-B0GUjLm9.js +339 -0
  200. package/dist/grd-DW8cSFVR.cjs +1 -0
  201. package/dist/grdIndass-BeBXVsos.cjs +1 -0
  202. package/dist/grdIndass-DduUKZJm.js +216 -0
  203. package/dist/grg-CeX0pirQ.js +194 -0
  204. package/dist/grg-fnpcXtju.cjs +1 -0
  205. package/dist/gridview-BPwWXza9.js +183 -0
  206. package/dist/gridview-DpABhCIw.cjs +1 -0
  207. package/dist/groupCard-De1E15mW.js +132 -0
  208. package/dist/groupCard-WNE6gAAl.cjs +1 -0
  209. package/dist/headerBar-CZ3qcLHo.js +210 -0
  210. package/dist/headerBar-Qi1EXrr6.cjs +1 -0
  211. package/dist/{history-DigzRtjC.js → history-BkZhlpdY.js} +5 -3
  212. package/dist/history-DAmBl4_5.cjs +1 -0
  213. package/dist/index-ButoLLAe.js +8655 -0
  214. package/dist/index-Mh5Dw2sd.cjs +585 -0
  215. package/dist/index-kShjySl9.js +5313 -0
  216. package/dist/index-mAPVa0s4.cjs +11 -0
  217. package/dist/insarDeformChart-BGr2xe7w.cjs +1 -0
  218. package/dist/insarDeformChart-CnuSL1d9.js +216 -0
  219. package/dist/insarImageViewer-DRgGdQmN.cjs +1 -0
  220. package/dist/insarImageViewer-EmVThmVQ.js +268 -0
  221. package/dist/install-8XfFtnlL.js +853 -0
  222. package/dist/install-9_V0b6vf.js +497 -0
  223. package/dist/install-B0x4IqQr.js +1258 -0
  224. package/dist/install-B1IEhhn3.cjs +1 -0
  225. package/dist/install-B2TChEcT.js +895 -0
  226. package/dist/install-B65ZIqAx.cjs +1 -0
  227. package/dist/install-BBrAry2m.js +8 -0
  228. package/dist/install-BRjgycz_.cjs +1 -0
  229. package/dist/install-BUu5ESB7.js +447 -0
  230. package/dist/install-BamnGDPb.cjs +1 -0
  231. package/dist/install-BifpoHNI.js +1817 -0
  232. package/dist/install-BvOpNm0Y.cjs +1 -0
  233. package/dist/install-ByPD0oOh.cjs +1 -0
  234. package/dist/install-BzdOSCzO.js +785 -0
  235. package/dist/install-C8buXQPI.cjs +1 -0
  236. package/dist/install-C9Cdzkc6.js +265 -0
  237. package/dist/install-CBde4hAM.js +112 -0
  238. package/dist/install-CIT6k8Ga.cjs +1 -0
  239. package/dist/install-CYwVETsi.cjs +1 -0
  240. package/dist/install-C_3uGWLu.js +2328 -0
  241. package/dist/install-Ch5d8i37.cjs +1 -0
  242. package/dist/install-CltTFs4e.cjs +3 -0
  243. package/dist/install-Csxa7Kv7.cjs +18 -0
  244. package/dist/install-Cx1i_m0k.js +1168 -0
  245. package/dist/install-D1QM80AD.js +227 -0
  246. package/dist/install-D7znHb-b.js +604 -0
  247. package/dist/install-DHY9y86B.cjs +3 -0
  248. package/dist/install-DIlB2q7w.cjs +1 -0
  249. package/dist/install-DV5cEgNV.cjs +1 -0
  250. package/dist/install-DWm3j_D3.js +38 -0
  251. package/dist/install-FDYiy_gL.js +250 -0
  252. package/dist/install-LtoYukZU.cjs +1 -0
  253. package/dist/install-MS3ZY7fF.js +685 -0
  254. package/dist/install-hfre7yvV.js +727 -0
  255. package/dist/install-kGXY_57n.cjs +1 -0
  256. package/dist/install-nDY6w-GK.cjs +1 -0
  257. package/dist/install-oGjJ0_bF.js +588 -0
  258. package/dist/install-z6wShIZI.cjs +1 -0
  259. package/dist/installCanvasRenderer-CLT2hquJ.js +4260 -0
  260. package/dist/installCanvasRenderer-CyhM1Qpl.cjs +3 -0
  261. package/dist/installMarkArea-Cdg4iciO.js +206 -0
  262. package/dist/installMarkArea-CjyaJPLE.cjs +1 -0
  263. package/dist/installMarkLine-BgE0YACE.js +533 -0
  264. package/dist/installMarkLine-Bv53Iw9G.cjs +1 -0
  265. package/dist/installSimple-BWTCwMdY.js +586 -0
  266. package/dist/installSimple-c87Ufc4_.cjs +1 -0
  267. package/dist/kds-CpIQFgeY.js +1203 -0
  268. package/dist/kds-DTYWOq4K.cjs +3 -0
  269. package/dist/labelHelper-Cd8oB-sZ.js +26 -0
  270. package/dist/labelHelper-npJGYQ1j.cjs +1 -0
  271. package/dist/layerTabs-BATcBkTA.cjs +1 -0
  272. package/dist/layerTabs-uze6K91A.js +139 -0
  273. package/dist/lin-Ba6fHkYf.cjs +2 -0
  274. package/dist/lin-DU_EuPRg.js +239 -0
  275. package/dist/linIndass-XHKElG7L.js +273 -0
  276. package/dist/linIndass-urYe5inp.cjs +2 -0
  277. package/dist/lst-C7aee1cU.js +147 -0
  278. package/dist/lst-CpmoEQDY.cjs +1 -0
  279. package/dist/manualEntry-CJPiO5nh.cjs +1 -0
  280. package/dist/manualEntry-D9m_WPw3.js +662 -0
  281. package/dist/mapBackground-6g_71Fwa.js +6658 -0
  282. package/dist/mapBackground-CF_TqNBy.cjs +17 -0
  283. package/dist/mappingList-CR55Tq4t.cjs +1 -0
  284. package/dist/mappingList-luT5YE0d.js +917 -0
  285. package/dist/markdownViewer-CnguoUr8.js +261 -0
  286. package/dist/markdownViewer-D1hDk2Y7.cjs +3 -0
  287. package/dist/mix-control-modal-BDHAB4Tw.cjs +1 -0
  288. package/dist/mix-control-modal-CHiX3hQs.js +147 -0
  289. package/dist/mixDataPermission-BTA1jNd1.cjs +1 -0
  290. package/dist/mixDataPermission-BaqV0Z6N.js +760 -0
  291. package/dist/mixGrid-3BqQCvg8.cjs +1 -0
  292. package/dist/mixGrid-C0eEvwPy.js +180 -0
  293. package/dist/mixMap-7upgYwWk.js +258 -0
  294. package/dist/mixMap-Bw-We4Cm.cjs +1 -0
  295. package/dist/mixModel-BqE_Kd4c.js +245 -0
  296. package/dist/mixModel-CgV4XptM.cjs +3 -0
  297. package/dist/mixPie-9LfMCTQV.cjs +2 -0
  298. package/dist/mixPie-B-HeglUn.js +168 -0
  299. package/dist/mixdashboards.cjs +1 -1
  300. package/dist/mixdashboards.css +1 -1
  301. package/dist/mixdashboards.js +7 -7
  302. package/dist/mjpegCamera-Cfw3rzT5.js +158 -0
  303. package/dist/mjpegCamera-nxKfhobY.cjs +1 -0
  304. package/dist/monitorAlert-Bg5vzzyG.js +225 -0
  305. package/dist/monitorAlert-Bt0baNh4.cjs +1 -0
  306. package/dist/monitorData-BvAMeOrp.js +319 -0
  307. package/dist/monitorData-CzPVIk_4.cjs +1 -0
  308. package/dist/monitorSpeedChart-0bDuU3Kj.js +603 -0
  309. package/dist/monitorSpeedChart-C52QjA5K.cjs +16 -0
  310. package/dist/mxa-BW80xKCc.js +143 -0
  311. package/dist/mxa-eLAgZPMC.cjs +2 -0
  312. package/dist/no-image-icon-CPA7RKkF.cjs +1 -0
  313. package/dist/no-image-icon-n2ZlEjxS.js +1864 -0
  314. package/dist/objectList-Cf9GMyXN.js +1809 -0
  315. package/dist/objectList-CpqQxG8L.cjs +1 -0
  316. package/dist/params-3W3p8QeC.cjs +1 -0
  317. package/dist/params-DfgBemk0.js +75 -0
  318. package/dist/photo-BODEtaYh.cjs +1 -0
  319. package/dist/photo-BfLkWAo8.js +256 -0
  320. package/dist/pie-BDLg-Rls.js +199 -0
  321. package/dist/pie-DxoBrm0D.cjs +2 -0
  322. package/dist/points-DcRmizmA.cjs +1 -0
  323. package/dist/points-DkG9FRF9.js +277 -0
  324. package/dist/pressBtn-CXG1eSWC.js +242 -0
  325. package/dist/pressBtn-t0g4vk7s.cjs +1 -0
  326. package/dist/progressBar-BXaFKSCq.js +130 -0
  327. package/dist/progressBar-CJEWkZ42.cjs +1 -0
  328. package/dist/progressCircle-DpOI5D5z.js +168 -0
  329. package/dist/progressCircle-uQ7vaMKM.cjs +1 -0
  330. package/dist/qrcode-CX8aymYZ.js +814 -0
  331. package/dist/qrcode-DHCRfp0M.cjs +1 -0
  332. package/dist/raceBar-Cv0-0ogd.cjs +4 -0
  333. package/dist/raceBar-DFaH342G.js +197 -0
  334. package/dist/rad-CFswUTwi.cjs +1 -0
  335. package/dist/rad-NS2G_nMg.js +143 -0
  336. package/dist/rainfallFilterBar-BI45QvJm.cjs +1 -0
  337. package/dist/rainfallFilterBar-D_Ye_NeB.js +221 -0
  338. package/dist/rainfallTimeCurve-BHWqX47Q.js +443 -0
  339. package/dist/rainfallTimeCurve-Ke1JvSWq.cjs +1 -0
  340. package/dist/rangeLin-D6VZ2U3C.cjs +3 -0
  341. package/dist/rangeLin-GMYEgLeP.js +278 -0
  342. package/dist/request-BD0x5Hkt.js +75 -0
  343. package/dist/request-Bn100qAJ.cjs +1 -0
  344. package/dist/retainer1-D2XmjXYH.cjs +1 -0
  345. package/dist/retainer1-h-Whr2c9.js +290 -0
  346. package/dist/retainer2-ByQdiRjq.js +504 -0
  347. package/dist/retainer2-cF-trL2g.cjs +1 -0
  348. package/dist/riskRegionTable-CQxAkG7k.js +170 -0
  349. package/dist/riskRegionTable-cKnxra4_.cjs +1 -0
  350. package/dist/sankey-Bk1IcVJQ.js +171 -0
  351. package/dist/sankey-MRirEgU0.cjs +1 -0
  352. package/dist/sausage-DRCw7Qmr.cjs +1 -0
  353. package/dist/sausage-xU3hOdxD.js +30 -0
  354. package/dist/scd-BDRpzmsa.js +2577 -0
  355. package/dist/scd-J-mN3eI5.cjs +1 -0
  356. package/dist/sectorHelper-BFEnYqut.cjs +1 -0
  357. package/dist/sectorHelper-DIlWFMnU.js +18 -0
  358. package/dist/sideMenu-BgTMtnMq.js +225 -0
  359. package/dist/sideMenu-l8X2E00H.cjs +1 -0
  360. package/dist/slopeStability-BPf7m0fJ.cjs +1 -0
  361. package/dist/slopeStability-C5RqZ1im.js +331 -0
  362. package/dist/speedCurve-C3pK-zZy.js +394 -0
  363. package/dist/speedCurve-CluwNAZl.cjs +1 -0
  364. package/dist/staticLine-C6tGGXcN.cjs +1 -0
  365. package/dist/staticLine-DXWOLj15.js +362 -0
  366. package/dist/store-BJW2NQkK.cjs +5 -0
  367. package/dist/store-DzDtVfSX.js +1673 -0
  368. package/dist/swiper-DGqDoUkX.cjs +1 -0
  369. package/dist/swiper-IMlGje3t.js +128 -0
  370. package/dist/terminalConfigList-D6xDHsnb.cjs +1 -0
  371. package/dist/terminalConfigList-SAyXi-BK.js +1017 -0
  372. package/dist/terminalList-CjSHshiR.js +1211 -0
  373. package/dist/terminalList-ml2C18MY.cjs +1 -0
  374. package/dist/textbox-AQtCe25j.cjs +1 -0
  375. package/dist/textbox-BLV-SY8e.js +172 -0
  376. package/dist/three.module-DNVo041Q.cjs +3824 -0
  377. package/dist/three.module-DcOQNgKS.js +16561 -0
  378. package/dist/timeQueryBar-BeMu_DYr.js +155 -0
  379. package/dist/timeQueryBar-BuKakMy8.cjs +1 -0
  380. package/dist/timeSeries-DP5iZKVM.js +587 -0
  381. package/dist/timeSeries-DfGgFWiF.cjs +4 -0
  382. package/dist/timeSeriesCurve-B0Mw6eNK.cjs +1 -0
  383. package/dist/timeSeriesCurve-BSgtPqYw.js +463 -0
  384. package/dist/titleStyle-BT5GlpAb.js +49 -0
  385. package/dist/titleStyle-NSnz6cUg.cjs +1 -0
  386. package/dist/toggleBtn-Dh64vVWo.cjs +1 -0
  387. package/dist/toggleBtn-O2Y75Uen.js +249 -0
  388. package/dist/trajectoryConfigPanel--C1h3tK6.js +635 -0
  389. package/dist/trajectoryConfigPanel-P_Qa4omj.cjs +1 -0
  390. package/dist/trajectoryScatter-BbpbgNb8.cjs +1 -0
  391. package/dist/trajectoryScatter-VLrmImlq.js +525 -0
  392. package/dist/universalConfigPanel-C0lDSzOB.cjs +1 -0
  393. package/dist/universalConfigPanel-DBg76b4F.js +477 -0
  394. package/dist/universalTable-Bzq9VqzA.cjs +2 -0
  395. package/dist/universalTable-DGK02ywi.js +410 -0
  396. package/dist/universalTransition-Bv7ibBUh.js +988 -0
  397. package/dist/universalTransition-CIN_u2Cu.cjs +1 -0
  398. package/dist/video-CyRoSQf1.cjs +1 -0
  399. package/dist/video-DCzzaEmV.js +310 -0
  400. package/dist/videoMonitor-BjD-ZFS0.cjs +1 -0
  401. package/dist/videoMonitor-ByaQeIWR.js +241 -0
  402. package/dist/vlu-CYZjYHaV.cjs +1 -0
  403. package/dist/vlu-h-9twmCr.js +100 -0
  404. package/dist/vue-i18n-5Nahpzrm.js +2732 -0
  405. package/dist/vue-i18n-BvHMBi_b.cjs +5 -0
  406. package/dist/weather-B7B5E1EJ.cjs +1 -0
  407. package/dist/weather-C_aC0XJ1.js +94 -0
  408. package/dist/windLin-B7V4NUV8.js +1226 -0
  409. package/dist/windLin-DPNzX7JN.cjs +1 -0
  410. package/package.json +17 -10
  411. package/dist/history-fvcbbxGa.cjs +0 -1
  412. package/dist/index-B-aA7889.js +0 -154003
  413. package/dist/index-CdJ-j9Gj.cjs +0 -8893
@@ -0,0 +1,3824 @@
1
+ "use strict";var ka=Math.pow;var Hr=(i,t,e)=>new Promise((n,r)=>{var s=l=>{try{o(e.next(l))}catch(c){r(c)}},a=l=>{try{o(e.throw(l))}catch(c){r(c)}},o=l=>l.done?n(l.value):Promise.resolve(l.value).then(s,a);o((e=e.apply(i,t)).next())});const Ql={ROTATE:0,DOLLY:1,PAN:2},tc={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},ec=0,Ga=1,nc=2,dl=1,ic=2,sn=3,ln=0,Me=1,qe=2,Tn=0,ai=1,Wa=2,Xa=3,qa=4,rc=5,Fn=100,sc=101,ac=102,oc=103,lc=104,cc=200,hc=201,uc=202,dc=203,Ts=204,bs=205,fc=206,pc=207,mc=208,gc=209,_c=210,vc=211,xc=212,Mc=213,Sc=214,As=0,ws=1,Rs=2,ci=3,Cs=4,Ps=5,Ls=6,Ds=7,fl=0,yc=1,Ec=2,bn=0,Tc=1,bc=2,Ac=3,wc=4,Rc=5,Cc=6,Pc=7,Ya="attached",Lc="detached",pl=300,hi=301,ui=302,Is=303,Us=304,Fr=306,Pr=1e3,Sn=1001,Lr=1002,Se=1003,ml=1004,Li=1005,He=1006,Er=1007,yn=1008,cn=1009,gl=1010,_l=1011,Oi=1012,da=1013,Bn=1014,ke=1015,ki=1016,fa=1017,pa=1018,di=1020,vl=35902,xl=1021,Ml=1022,De=1023,Sl=1024,yl=1025,oi=1026,fi=1027,ma=1028,ga=1029,El=1030,_a=1031,va=1033,Tr=33776,br=33777,Ar=33778,wr=33779,Ns=35840,Fs=35841,Os=35842,Bs=35843,zs=36196,Vs=37492,Hs=37496,ks=37808,Gs=37809,Ws=37810,Xs=37811,qs=37812,Ys=37813,Ks=37814,Zs=37815,$s=37816,js=37817,Js=37818,Qs=37819,ta=37820,ea=37821,Rr=36492,na=36494,ia=36495,Tl=36283,ra=36284,sa=36285,aa=36286,Bi=2300,Dr=2301,kr=2302,Ka=2400,Za=2401,$a=2402,Dc=2500,Ic=0,Uc=1,Nc=2,Fc=3200,Oc=3201,bl=0,Bc=1,Mn="",Ae="srgb",Vn="srgb-linear",Or="linear",$t="srgb",Wn=7680,ja=519,zc=512,Vc=513,Hc=514,Al=515,kc=516,Gc=517,Wc=518,Xc=519,oa=35044,Ja="300 es",an=2e3,Ir=2001;class Hn{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const n=this._listeners;return n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const r=this._listeners[t];if(r!==void 0){const s=r.indexOf(e);s!==-1&&r.splice(s,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const n=this._listeners[t.type];if(n!==void 0){t.target=this;const r=n.slice(0);for(let s=0,a=r.length;s<a;s++)r[s].call(this,t);t.target=null}}}const pe=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Qa=1234567;const Ni=Math.PI/180,pi=180/Math.PI;function Ge(){const i=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(pe[i&255]+pe[i>>8&255]+pe[i>>16&255]+pe[i>>24&255]+"-"+pe[t&255]+pe[t>>8&255]+"-"+pe[t>>16&15|64]+pe[t>>24&255]+"-"+pe[e&63|128]+pe[e>>8&255]+"-"+pe[e>>16&255]+pe[e>>24&255]+pe[n&255]+pe[n>>8&255]+pe[n>>16&255]+pe[n>>24&255]).toLowerCase()}function le(i,t,e){return Math.max(t,Math.min(e,i))}function xa(i,t){return(i%t+t)%t}function qc(i,t,e,n,r){return n+(i-t)*(r-n)/(e-t)}function Yc(i,t,e){return i!==t?(e-i)/(t-i):0}function Fi(i,t,e){return(1-e)*i+e*t}function Kc(i,t,e,n){return Fi(i,t,1-Math.exp(-e*n))}function Zc(i,t=1){return t-Math.abs(xa(i,t*2)-t)}function $c(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*(3-2*i))}function jc(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*i*(i*(i*6-15)+10))}function Jc(i,t){return i+Math.floor(Math.random()*(t-i+1))}function Qc(i,t){return i+Math.random()*(t-i)}function th(i){return i*(.5-Math.random())}function eh(i){i!==void 0&&(Qa=i);let t=Qa+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function nh(i){return i*Ni}function ih(i){return i*pi}function rh(i){return(i&i-1)===0&&i!==0}function sh(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function ah(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function oh(i,t,e,n,r){const s=Math.cos,a=Math.sin,o=s(e/2),l=a(e/2),c=s((t+n)/2),h=a((t+n)/2),u=s((t-n)/2),d=a((t-n)/2),p=s((n-t)/2),g=a((n-t)/2);switch(r){case"XYX":i.set(o*h,l*u,l*d,o*c);break;case"YZY":i.set(l*d,o*h,l*u,o*c);break;case"ZXZ":i.set(l*u,l*d,o*h,o*c);break;case"XZX":i.set(o*h,l*g,l*p,o*c);break;case"YXY":i.set(l*p,o*h,l*g,o*c);break;case"ZYZ":i.set(l*g,l*p,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function ze(i,t){switch(t.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("Invalid component type.")}}function Kt(i,t){switch(t.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("Invalid component type.")}}const lh={DEG2RAD:Ni,RAD2DEG:pi,generateUUID:Ge,clamp:le,euclideanModulo:xa,mapLinear:qc,inverseLerp:Yc,lerp:Fi,damp:Kc,pingpong:Zc,smoothstep:$c,smootherstep:jc,randInt:Jc,randFloat:Qc,randFloatSpread:th,seededRandom:eh,degToRad:nh,radToDeg:ih,isPowerOfTwo:rh,ceilPowerOfTwo:sh,floorPowerOfTwo:ah,setQuaternionFromProperEuler:oh,normalize:Kt,denormalize:ze};class Ft{constructor(t=0,e=0){Ft.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6],this.y=r[1]*e+r[4]*n+r[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(le(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),r=Math.sin(e),s=this.x-t.x,a=this.y-t.y;return this.x=s*n-a*r+t.x,this.y=s*r+a*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Ct{constructor(t,e,n,r,s,a,o,l,c){Ct.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,r,s,a,o,l,c)}set(t,e,n,r,s,a,o,l,c){const h=this.elements;return h[0]=t,h[1]=r,h[2]=o,h[3]=e,h[4]=s,h[5]=l,h[6]=n,h[7]=a,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,r=e.elements,s=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],h=n[4],u=n[7],d=n[2],p=n[5],g=n[8],v=r[0],m=r[3],f=r[6],b=r[1],T=r[4],S=r[7],B=r[2],A=r[5],w=r[8];return s[0]=a*v+o*b+l*B,s[3]=a*m+o*T+l*A,s[6]=a*f+o*S+l*w,s[1]=c*v+h*b+u*B,s[4]=c*m+h*T+u*A,s[7]=c*f+h*S+u*w,s[2]=d*v+p*b+g*B,s[5]=d*m+p*T+g*A,s[8]=d*f+p*S+g*w,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],r=t[2],s=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8];return e*a*h-e*o*c-n*s*h+n*o*l+r*s*c-r*a*l}invert(){const t=this.elements,e=t[0],n=t[1],r=t[2],s=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8],u=h*a-o*c,d=o*l-h*s,p=c*s-a*l,g=e*u+n*d+r*p;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/g;return t[0]=u*v,t[1]=(r*c-h*n)*v,t[2]=(o*n-r*a)*v,t[3]=d*v,t[4]=(h*e-r*l)*v,t[5]=(r*s-o*e)*v,t[6]=p*v,t[7]=(n*l-c*e)*v,t[8]=(a*e-n*s)*v,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,r,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*a+c*o)+a+t,-r*c,r*l,-r*(-c*a+l*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(Gr.makeScale(t,e)),this}rotate(t){return this.premultiply(Gr.makeRotation(-t)),this}translate(t,e){return this.premultiply(Gr.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let r=0;r<9;r++)if(e[r]!==n[r])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const Gr=new Ct;function wl(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function zi(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function ch(){const i=zi("canvas");return i.style.display="block",i}const to={};function Di(i){i in to||(to[i]=!0,console.warn(i))}function hh(i,t,e){return new Promise(function(n,r){function s(){switch(i.clientWaitSync(t,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(s,e);break;default:n()}}setTimeout(s,e)})}function uh(i){const t=i.elements;t[2]=.5*t[2]+.5*t[3],t[6]=.5*t[6]+.5*t[7],t[10]=.5*t[10]+.5*t[11],t[14]=.5*t[14]+.5*t[15]}function dh(i){const t=i.elements;t[11]===-1?(t[10]=-t[10]-1,t[14]=-t[14]):(t[10]=-t[10],t[14]=-t[14]+1)}const Vt={enabled:!0,workingColorSpace:Vn,spaces:{},convert:function(i,t,e){return this.enabled===!1||t===e||!t||!e||(this.spaces[t].transfer===$t&&(i.r=on(i.r),i.g=on(i.g),i.b=on(i.b)),this.spaces[t].primaries!==this.spaces[e].primaries&&(i.applyMatrix3(this.spaces[t].toXYZ),i.applyMatrix3(this.spaces[e].fromXYZ)),this.spaces[e].transfer===$t&&(i.r=li(i.r),i.g=li(i.g),i.b=li(i.b))),i},fromWorkingColorSpace:function(i,t){return this.convert(i,this.workingColorSpace,t)},toWorkingColorSpace:function(i,t){return this.convert(i,t,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===Mn?Or:this.spaces[i].transfer},getLuminanceCoefficients:function(i,t=this.workingColorSpace){return i.fromArray(this.spaces[t].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,t,e){return i.copy(this.spaces[t].toXYZ).multiply(this.spaces[e].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace}};function on(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function li(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}const eo=[.64,.33,.3,.6,.15,.06],no=[.2126,.7152,.0722],io=[.3127,.329],ro=new Ct().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),so=new Ct().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);Vt.define({[Vn]:{primaries:eo,whitePoint:io,transfer:Or,toXYZ:ro,fromXYZ:so,luminanceCoefficients:no,workingColorSpaceConfig:{unpackColorSpace:Ae},outputColorSpaceConfig:{drawingBufferColorSpace:Ae}},[Ae]:{primaries:eo,whitePoint:io,transfer:$t,toXYZ:ro,fromXYZ:so,luminanceCoefficients:no,outputColorSpaceConfig:{drawingBufferColorSpace:Ae}}});let Xn;class fh{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement=="undefined")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{Xn===void 0&&(Xn=zi("canvas")),Xn.width=t.width,Xn.height=t.height;const n=Xn.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=Xn}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement!="undefined"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&t instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&t instanceof ImageBitmap){const e=zi("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const r=n.getImageData(0,0,t.width,t.height),s=r.data;for(let a=0;a<s.length;a++)s[a]=on(s[a]/255)*255;return n.putImageData(r,0,0),e}else if(t.data){const e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(on(e[n]/255)*255):e[n]=on(e[n]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let ph=0;class Rl{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:ph++}),this.uuid=Ge(),this.data=t,this.dataReady=!0,this.version=0}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.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(Wr(r[a].image)):s.push(Wr(r[a]))}else s=Wr(r);n.url=s}return e||(t.images[this.uuid]=n),n}}function Wr(i){return typeof HTMLImageElement!="undefined"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&i instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&i instanceof ImageBitmap?fh.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let mh=0;class de extends Hn{constructor(t=de.DEFAULT_IMAGE,e=de.DEFAULT_MAPPING,n=Sn,r=Sn,s=He,a=yn,o=De,l=cn,c=de.DEFAULT_ANISOTROPY,h=Mn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:mh++}),this.uuid=Ge(),this.name="",this.source=new Rl(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Ft(0,0),this.repeat=new Ft(1,1),this.center=new Ft(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ct,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==pl)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Pr:t.x=t.x-Math.floor(t.x);break;case Sn:t.x=t.x<0?0:1;break;case Lr:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case Pr:t.y=t.y-Math.floor(t.y);break;case Sn:t.y=t.y<0?0:1;break;case Lr:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}de.DEFAULT_IMAGE=null;de.DEFAULT_MAPPING=pl;de.DEFAULT_ANISOTROPY=1;class Wt{constructor(t=0,e=0,n=0,r=1){Wt.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=r}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,r){return this.x=t,this.y=e,this.z=n,this.w=r,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,r=this.z,s=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*r+a[12]*s,this.y=a[1]*e+a[5]*n+a[9]*r+a[13]*s,this.z=a[2]*e+a[6]*n+a[10]*r+a[14]*s,this.w=a[3]*e+a[7]*n+a[11]*r+a[15]*s,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,r,s;const l=t.elements,c=l[0],h=l[4],u=l[8],d=l[1],p=l[5],g=l[9],v=l[2],m=l[6],f=l[10];if(Math.abs(h-d)<.01&&Math.abs(u-v)<.01&&Math.abs(g-m)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+v)<.1&&Math.abs(g+m)<.1&&Math.abs(c+p+f-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const T=(c+1)/2,S=(p+1)/2,B=(f+1)/2,A=(h+d)/4,w=(u+v)/4,U=(g+m)/4;return T>S&&T>B?T<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(T),r=A/n,s=w/n):S>B?S<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(S),n=A/r,s=U/r):B<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(B),n=w/s,r=U/s),this.set(n,r,s,e),this}let b=Math.sqrt((m-g)*(m-g)+(u-v)*(u-v)+(d-h)*(d-h));return Math.abs(b)<.001&&(b=1),this.x=(m-g)/b,this.y=(u-v)/b,this.z=(d-h)/b,this.w=Math.acos((c+p+f-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class gh extends Hn{constructor(t=1,e=1,n={}){super(),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new Wt(0,0,t,e),this.scissorTest=!1,this.viewport=new Wt(0,0,t,e);const r={width:t,height:e,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:He,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);const s=new de(r,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);s.flipY=!1,s.generateMipmaps=n.generateMipmaps,s.internalFormat=n.internalFormat,this.textures=[];const a=n.count;for(let o=0;o<a;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0;this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.depthTexture=n.depthTexture,this.samples=n.samples}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=t,this.textures[r].image.height=e,this.textures[r].image.depth=n;this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let n=0,r=t.textures.length;n<r;n++)this.textures[n]=t.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0;const e=Object.assign({},t.texture.image);return this.texture.source=new Rl(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class zn extends gh{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}}class Cl extends de{constructor(t=null,e=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:r},this.magFilter=Se,this.minFilter=Se,this.wrapR=Sn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class _h extends de{constructor(t=null,e=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:r},this.magFilter=Se,this.minFilter=Se,this.wrapR=Sn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class kn{constructor(t=0,e=0,n=0,r=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=r}static slerpFlat(t,e,n,r,s,a,o){let l=n[r+0],c=n[r+1],h=n[r+2],u=n[r+3];const d=s[a+0],p=s[a+1],g=s[a+2],v=s[a+3];if(o===0){t[e+0]=l,t[e+1]=c,t[e+2]=h,t[e+3]=u;return}if(o===1){t[e+0]=d,t[e+1]=p,t[e+2]=g,t[e+3]=v;return}if(u!==v||l!==d||c!==p||h!==g){let m=1-o;const f=l*d+c*p+h*g+u*v,b=f>=0?1:-1,T=1-f*f;if(T>Number.EPSILON){const B=Math.sqrt(T),A=Math.atan2(B,f*b);m=Math.sin(m*A)/B,o=Math.sin(o*A)/B}const S=o*b;if(l=l*m+d*S,c=c*m+p*S,h=h*m+g*S,u=u*m+v*S,m===1-o){const B=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=B,c*=B,h*=B,u*=B}}t[e]=l,t[e+1]=c,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,r,s,a){const o=n[r],l=n[r+1],c=n[r+2],h=n[r+3],u=s[a],d=s[a+1],p=s[a+2],g=s[a+3];return t[e]=o*g+h*u+l*p-c*d,t[e+1]=l*g+h*d+c*u-o*p,t[e+2]=c*g+h*p+o*d-l*u,t[e+3]=h*g-o*u-l*d-c*p,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,r){return this._x=t,this._y=e,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,r=t._y,s=t._z,a=t._order,o=Math.cos,l=Math.sin,c=o(n/2),h=o(r/2),u=o(s/2),d=l(n/2),p=l(r/2),g=l(s/2);switch(a){case"XYZ":this._x=d*h*u+c*p*g,this._y=c*p*u-d*h*g,this._z=c*h*g+d*p*u,this._w=c*h*u-d*p*g;break;case"YXZ":this._x=d*h*u+c*p*g,this._y=c*p*u-d*h*g,this._z=c*h*g-d*p*u,this._w=c*h*u+d*p*g;break;case"ZXY":this._x=d*h*u-c*p*g,this._y=c*p*u+d*h*g,this._z=c*h*g+d*p*u,this._w=c*h*u-d*p*g;break;case"ZYX":this._x=d*h*u-c*p*g,this._y=c*p*u+d*h*g,this._z=c*h*g-d*p*u,this._w=c*h*u+d*p*g;break;case"YZX":this._x=d*h*u+c*p*g,this._y=c*p*u+d*h*g,this._z=c*h*g-d*p*u,this._w=c*h*u-d*p*g;break;case"XZY":this._x=d*h*u-c*p*g,this._y=c*p*u-d*h*g,this._z=c*h*g+d*p*u,this._w=c*h*u+d*p*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,r=Math.sin(n);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],r=e[4],s=e[8],a=e[1],o=e[5],l=e[9],c=e[2],h=e[6],u=e[10],d=n+o+u;if(d>0){const p=.5/Math.sqrt(d+1);this._w=.25/p,this._x=(h-l)*p,this._y=(s-c)*p,this._z=(a-r)*p}else if(n>o&&n>u){const p=2*Math.sqrt(1+n-o-u);this._w=(h-l)/p,this._x=.25*p,this._y=(r+a)/p,this._z=(s+c)/p}else if(o>u){const p=2*Math.sqrt(1+o-n-u);this._w=(s-c)/p,this._x=(r+a)/p,this._y=.25*p,this._z=(l+h)/p}else{const p=2*Math.sqrt(1+u-n-o);this._w=(a-r)/p,this._x=(s+c)/p,this._y=(l+h)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<Number.EPSILON?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(le(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(n===0)return this;const r=Math.min(1,e/n);return this.slerp(t,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(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,r=t._y,s=t._z,a=t._w,o=e._x,l=e._y,c=e._z,h=e._w;return this._x=n*h+a*o+r*c-s*l,this._y=r*h+a*l+s*o-n*c,this._z=s*h+a*c+n*l-r*o,this._w=a*h-n*o-r*l-s*c,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const n=this._x,r=this._y,s=this._z,a=this._w;let o=a*t._w+n*t._x+r*t._y+s*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=n,this._y=r,this._z=s,this;const l=1-o*o;if(l<=Number.EPSILON){const p=1-e;return this._w=p*a+e*this._w,this._x=p*n+e*this._x,this._y=p*r+e*this._y,this._z=p*s+e*this._z,this.normalize(),this}const c=Math.sqrt(l),h=Math.atan2(c,o),u=Math.sin((1-e)*h)/c,d=Math.sin(e*h)/c;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=r*u+this._y*d,this._z=s*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(r*Math.sin(t),r*Math.cos(t),s*Math.sin(e),s*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class L{constructor(t=0,e=0,n=0){L.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(ao.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(ao.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,r=this.z,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6]*r,this.y=s[1]*e+s[4]*n+s[7]*r,this.z=s[2]*e+s[5]*n+s[8]*r,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,r=this.z,s=t.elements,a=1/(s[3]*e+s[7]*n+s[11]*r+s[15]);return this.x=(s[0]*e+s[4]*n+s[8]*r+s[12])*a,this.y=(s[1]*e+s[5]*n+s[9]*r+s[13])*a,this.z=(s[2]*e+s[6]*n+s[10]*r+s[14])*a,this}applyQuaternion(t){const e=this.x,n=this.y,r=this.z,s=t.x,a=t.y,o=t.z,l=t.w,c=2*(a*r-o*n),h=2*(o*e-s*r),u=2*(s*n-a*e);return this.x=e+l*c+a*u-o*h,this.y=n+l*h+o*c-s*u,this.z=r+l*u+s*h-a*c,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,r=this.z,s=t.elements;return this.x=s[0]*e+s[4]*n+s[8]*r,this.y=s[1]*e+s[5]*n+s[9]*r,this.z=s[2]*e+s[6]*n+s[10]*r,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,r=t.y,s=t.z,a=e.x,o=e.y,l=e.z;return this.x=r*l-s*o,this.y=s*a-n*l,this.z=n*o-r*a,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Xr.copy(this).projectOnVector(t),this.sub(Xr)}reflect(t){return this.sub(Xr.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(le(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,r=this.z-t.z;return e*e+n*n+r*r}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const r=Math.sin(e)*t;return this.x=r*Math.sin(n),this.y=Math.cos(e)*t,this.z=r*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=r,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Xr=new L,ao=new kn;class hn{constructor(t=new L(1/0,1/0,1/0),e=new L(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint(Fe.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(Fe.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=Fe.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const n=t.geometry;if(n!==void 0){const s=n.getAttribute("position");if(e===!0&&s!==void 0&&t.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)t.isMesh===!0?t.getVertexPosition(a,Fe):Fe.fromBufferAttribute(s,a),Fe.applyMatrix4(t.matrixWorld),this.expandByPoint(Fe);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),Zi.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Zi.copy(n.boundingBox)),Zi.applyMatrix4(t.matrixWorld),this.union(Zi)}const r=t.children;for(let s=0,a=r.length;s<a;s++)this.expandByObject(r[s],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,Fe),Fe.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Ei),$i.subVectors(this.max,Ei),qn.subVectors(t.a,Ei),Yn.subVectors(t.b,Ei),Kn.subVectors(t.c,Ei),fn.subVectors(Yn,qn),pn.subVectors(Kn,Yn),Cn.subVectors(qn,Kn);let e=[0,-fn.z,fn.y,0,-pn.z,pn.y,0,-Cn.z,Cn.y,fn.z,0,-fn.x,pn.z,0,-pn.x,Cn.z,0,-Cn.x,-fn.y,fn.x,0,-pn.y,pn.x,0,-Cn.y,Cn.x,0];return!qr(e,qn,Yn,Kn,$i)||(e=[1,0,0,0,1,0,0,0,1],!qr(e,qn,Yn,Kn,$i))?!1:(ji.crossVectors(fn,pn),e=[ji.x,ji.y,ji.z],qr(e,qn,Yn,Kn,$i))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Fe).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(Fe).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(Je[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Je[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Je[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Je[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Je[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Je[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Je[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Je[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Je),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const Je=[new L,new L,new L,new L,new L,new L,new L,new L],Fe=new L,Zi=new hn,qn=new L,Yn=new L,Kn=new L,fn=new L,pn=new L,Cn=new L,Ei=new L,$i=new L,ji=new L,Pn=new L;function qr(i,t,e,n,r){for(let s=0,a=i.length-3;s<=a;s+=3){Pn.fromArray(i,s);const o=r.x*Math.abs(Pn.x)+r.y*Math.abs(Pn.y)+r.z*Math.abs(Pn.z),l=t.dot(Pn),c=e.dot(Pn),h=n.dot(Pn);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const vh=new hn,Ti=new L,Yr=new L;class Ke{constructor(t=new L,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;e!==void 0?n.copy(e):vh.setFromPoints(t).getCenter(n);let r=0;for(let s=0,a=t.length;s<a;s++)r=Math.max(r,n.distanceToSquared(t[s]));return this.radius=Math.sqrt(r),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Ti.subVectors(t,this.center);const e=Ti.lengthSq();if(e>this.radius*this.radius){const n=Math.sqrt(e),r=(n-this.radius)*.5;this.center.addScaledVector(Ti,r/n),this.radius+=r}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(Yr.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Ti.copy(t.center).add(Yr)),this.expandByPoint(Ti.copy(t.center).sub(Yr))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Qe=new L,Kr=new L,Ji=new L,mn=new L,Zr=new L,Qi=new L,$r=new L;class gi{constructor(t=new L,e=new L(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Qe)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Qe.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Qe.copy(this.origin).addScaledVector(this.direction,e),Qe.distanceToSquared(t))}distanceSqToSegment(t,e,n,r){Kr.copy(t).add(e).multiplyScalar(.5),Ji.copy(e).sub(t).normalize(),mn.copy(this.origin).sub(Kr);const s=t.distanceTo(e)*.5,a=-this.direction.dot(Ji),o=mn.dot(this.direction),l=-mn.dot(Ji),c=mn.lengthSq(),h=Math.abs(1-a*a);let u,d,p,g;if(h>0)if(u=a*l-o,d=a*o-l,g=s*h,u>=0)if(d>=-g)if(d<=g){const v=1/h;u*=v,d*=v,p=u*(u+a*d+2*o)+d*(a*u+d+2*l)+c}else d=s,u=Math.max(0,-(a*d+o)),p=-u*u+d*(d+2*l)+c;else d=-s,u=Math.max(0,-(a*d+o)),p=-u*u+d*(d+2*l)+c;else d<=-g?(u=Math.max(0,-(-a*s+o)),d=u>0?-s:Math.min(Math.max(-s,-l),s),p=-u*u+d*(d+2*l)+c):d<=g?(u=0,d=Math.min(Math.max(-s,-l),s),p=d*(d+2*l)+c):(u=Math.max(0,-(a*s+o)),d=u>0?s:Math.min(Math.max(-s,-l),s),p=-u*u+d*(d+2*l)+c);else d=a>0?-s:s,u=Math.max(0,-(a*d+o)),p=-u*u+d*(d+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(Kr).addScaledVector(Ji,d),p}intersectSphere(t,e){Qe.subVectors(t.center,this.origin);const n=Qe.dot(this.direction),r=Qe.dot(Qe)-n*n,s=t.radius*t.radius;if(r>s)return null;const a=Math.sqrt(s-r),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,e):this.at(o,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,r,s,a,o,l;const c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(t.min.x-d.x)*c,r=(t.max.x-d.x)*c):(n=(t.max.x-d.x)*c,r=(t.min.x-d.x)*c),h>=0?(s=(t.min.y-d.y)*h,a=(t.max.y-d.y)*h):(s=(t.max.y-d.y)*h,a=(t.min.y-d.y)*h),n>a||s>r||((s>n||isNaN(n))&&(n=s),(a<r||isNaN(r))&&(r=a),u>=0?(o=(t.min.z-d.z)*u,l=(t.max.z-d.z)*u):(o=(t.max.z-d.z)*u,l=(t.min.z-d.z)*u),n>l||o>r)||((o>n||n!==n)&&(n=o),(l<r||r!==r)&&(r=l),r<0)?null:this.at(n>=0?n:r,e)}intersectsBox(t){return this.intersectBox(t,Qe)!==null}intersectTriangle(t,e,n,r,s){Zr.subVectors(e,t),Qi.subVectors(n,t),$r.crossVectors(Zr,Qi);let a=this.direction.dot($r),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;mn.subVectors(this.origin,t);const l=o*this.direction.dot(Qi.crossVectors(mn,Qi));if(l<0)return null;const c=o*this.direction.dot(Zr.cross(mn));if(c<0||l+c>a)return null;const h=-o*mn.dot($r);return h<0?null:this.at(h/a,s)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Dt{constructor(t,e,n,r,s,a,o,l,c,h,u,d,p,g,v,m){Dt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,r,s,a,o,l,c,h,u,d,p,g,v,m)}set(t,e,n,r,s,a,o,l,c,h,u,d,p,g,v,m){const f=this.elements;return f[0]=t,f[4]=e,f[8]=n,f[12]=r,f[1]=s,f[5]=a,f[9]=o,f[13]=l,f[2]=c,f[6]=h,f[10]=u,f[14]=d,f[3]=p,f[7]=g,f[11]=v,f[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Dt().fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,r=1/Zn.setFromMatrixColumn(t,0).length(),s=1/Zn.setFromMatrixColumn(t,1).length(),a=1/Zn.setFromMatrixColumn(t,2).length();return e[0]=n[0]*r,e[1]=n[1]*r,e[2]=n[2]*r,e[3]=0,e[4]=n[4]*s,e[5]=n[5]*s,e[6]=n[6]*s,e[7]=0,e[8]=n[8]*a,e[9]=n[9]*a,e[10]=n[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,r=t.y,s=t.z,a=Math.cos(n),o=Math.sin(n),l=Math.cos(r),c=Math.sin(r),h=Math.cos(s),u=Math.sin(s);if(t.order==="XYZ"){const d=a*h,p=a*u,g=o*h,v=o*u;e[0]=l*h,e[4]=-l*u,e[8]=c,e[1]=p+g*c,e[5]=d-v*c,e[9]=-o*l,e[2]=v-d*c,e[6]=g+p*c,e[10]=a*l}else if(t.order==="YXZ"){const d=l*h,p=l*u,g=c*h,v=c*u;e[0]=d+v*o,e[4]=g*o-p,e[8]=a*c,e[1]=a*u,e[5]=a*h,e[9]=-o,e[2]=p*o-g,e[6]=v+d*o,e[10]=a*l}else if(t.order==="ZXY"){const d=l*h,p=l*u,g=c*h,v=c*u;e[0]=d-v*o,e[4]=-a*u,e[8]=g+p*o,e[1]=p+g*o,e[5]=a*h,e[9]=v-d*o,e[2]=-a*c,e[6]=o,e[10]=a*l}else if(t.order==="ZYX"){const d=a*h,p=a*u,g=o*h,v=o*u;e[0]=l*h,e[4]=g*c-p,e[8]=d*c+v,e[1]=l*u,e[5]=v*c+d,e[9]=p*c-g,e[2]=-c,e[6]=o*l,e[10]=a*l}else if(t.order==="YZX"){const d=a*l,p=a*c,g=o*l,v=o*c;e[0]=l*h,e[4]=v-d*u,e[8]=g*u+p,e[1]=u,e[5]=a*h,e[9]=-o*h,e[2]=-c*h,e[6]=p*u+g,e[10]=d-v*u}else if(t.order==="XZY"){const d=a*l,p=a*c,g=o*l,v=o*c;e[0]=l*h,e[4]=-u,e[8]=c*h,e[1]=d*u+v,e[5]=a*h,e[9]=p*u-g,e[2]=g*u-p,e[6]=o*h,e[10]=v*u+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(xh,t,Mh)}lookAt(t,e,n){const r=this.elements;return Te.subVectors(t,e),Te.lengthSq()===0&&(Te.z=1),Te.normalize(),gn.crossVectors(n,Te),gn.lengthSq()===0&&(Math.abs(n.z)===1?Te.x+=1e-4:Te.z+=1e-4,Te.normalize(),gn.crossVectors(n,Te)),gn.normalize(),tr.crossVectors(Te,gn),r[0]=gn.x,r[4]=tr.x,r[8]=Te.x,r[1]=gn.y,r[5]=tr.y,r[9]=Te.y,r[2]=gn.z,r[6]=tr.z,r[10]=Te.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,r=e.elements,s=this.elements,a=n[0],o=n[4],l=n[8],c=n[12],h=n[1],u=n[5],d=n[9],p=n[13],g=n[2],v=n[6],m=n[10],f=n[14],b=n[3],T=n[7],S=n[11],B=n[15],A=r[0],w=r[4],U=r[8],y=r[12],M=r[1],R=r[5],q=r[9],z=r[13],W=r[2],$=r[6],k=r[10],Q=r[14],H=r[3],it=r[7],ct=r[11],xt=r[15];return s[0]=a*A+o*M+l*W+c*H,s[4]=a*w+o*R+l*$+c*it,s[8]=a*U+o*q+l*k+c*ct,s[12]=a*y+o*z+l*Q+c*xt,s[1]=h*A+u*M+d*W+p*H,s[5]=h*w+u*R+d*$+p*it,s[9]=h*U+u*q+d*k+p*ct,s[13]=h*y+u*z+d*Q+p*xt,s[2]=g*A+v*M+m*W+f*H,s[6]=g*w+v*R+m*$+f*it,s[10]=g*U+v*q+m*k+f*ct,s[14]=g*y+v*z+m*Q+f*xt,s[3]=b*A+T*M+S*W+B*H,s[7]=b*w+T*R+S*$+B*it,s[11]=b*U+T*q+S*k+B*ct,s[15]=b*y+T*z+S*Q+B*xt,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],r=t[8],s=t[12],a=t[1],o=t[5],l=t[9],c=t[13],h=t[2],u=t[6],d=t[10],p=t[14],g=t[3],v=t[7],m=t[11],f=t[15];return g*(+s*l*u-r*c*u-s*o*d+n*c*d+r*o*p-n*l*p)+v*(+e*l*p-e*c*d+s*a*d-r*a*p+r*c*h-s*l*h)+m*(+e*c*u-e*o*p-s*a*u+n*a*p+s*o*h-n*c*h)+f*(-r*o*h-e*l*u+e*o*d+r*a*u-n*a*d+n*l*h)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const r=this.elements;return t.isVector3?(r[12]=t.x,r[13]=t.y,r[14]=t.z):(r[12]=t,r[13]=e,r[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],r=t[2],s=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8],u=t[9],d=t[10],p=t[11],g=t[12],v=t[13],m=t[14],f=t[15],b=u*m*c-v*d*c+v*l*p-o*m*p-u*l*f+o*d*f,T=g*d*c-h*m*c-g*l*p+a*m*p+h*l*f-a*d*f,S=h*v*c-g*u*c+g*o*p-a*v*p-h*o*f+a*u*f,B=g*u*l-h*v*l-g*o*d+a*v*d+h*o*m-a*u*m,A=e*b+n*T+r*S+s*B;if(A===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/A;return t[0]=b*w,t[1]=(v*d*s-u*m*s-v*r*p+n*m*p+u*r*f-n*d*f)*w,t[2]=(o*m*s-v*l*s+v*r*c-n*m*c-o*r*f+n*l*f)*w,t[3]=(u*l*s-o*d*s-u*r*c+n*d*c+o*r*p-n*l*p)*w,t[4]=T*w,t[5]=(h*m*s-g*d*s+g*r*p-e*m*p-h*r*f+e*d*f)*w,t[6]=(g*l*s-a*m*s-g*r*c+e*m*c+a*r*f-e*l*f)*w,t[7]=(a*d*s-h*l*s+h*r*c-e*d*c-a*r*p+e*l*p)*w,t[8]=S*w,t[9]=(g*u*s-h*v*s-g*n*p+e*v*p+h*n*f-e*u*f)*w,t[10]=(a*v*s-g*o*s+g*n*c-e*v*c-a*n*f+e*o*f)*w,t[11]=(h*o*s-a*u*s-h*n*c+e*u*c+a*n*p-e*o*p)*w,t[12]=B*w,t[13]=(h*v*r-g*u*r+g*n*d-e*v*d-h*n*m+e*u*m)*w,t[14]=(g*o*r-a*v*r-g*n*l+e*v*l+a*n*m-e*o*m)*w,t[15]=(a*u*r-h*o*r+h*n*l-e*u*l-a*n*d+e*o*d)*w,this}scale(t){const e=this.elements,n=t.x,r=t.y,s=t.z;return e[0]*=n,e[4]*=r,e[8]*=s,e[1]*=n,e[5]*=r,e[9]*=s,e[2]*=n,e[6]*=r,e[10]*=s,e[3]*=n,e[7]*=r,e[11]*=s,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],r=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,r))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),r=Math.sin(e),s=1-n,a=t.x,o=t.y,l=t.z,c=s*a,h=s*o;return this.set(c*a+n,c*o-r*l,c*l+r*o,0,c*o+r*l,h*o+n,h*l-r*a,0,c*l-r*o,h*l+r*a,s*l*l+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,r,s,a){return this.set(1,n,s,0,t,1,a,0,e,r,1,0,0,0,0,1),this}compose(t,e,n){const r=this.elements,s=e._x,a=e._y,o=e._z,l=e._w,c=s+s,h=a+a,u=o+o,d=s*c,p=s*h,g=s*u,v=a*h,m=a*u,f=o*u,b=l*c,T=l*h,S=l*u,B=n.x,A=n.y,w=n.z;return r[0]=(1-(v+f))*B,r[1]=(p+S)*B,r[2]=(g-T)*B,r[3]=0,r[4]=(p-S)*A,r[5]=(1-(d+f))*A,r[6]=(m+b)*A,r[7]=0,r[8]=(g+T)*w,r[9]=(m-b)*w,r[10]=(1-(d+v))*w,r[11]=0,r[12]=t.x,r[13]=t.y,r[14]=t.z,r[15]=1,this}decompose(t,e,n){const r=this.elements;let s=Zn.set(r[0],r[1],r[2]).length();const a=Zn.set(r[4],r[5],r[6]).length(),o=Zn.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),t.x=r[12],t.y=r[13],t.z=r[14],Oe.copy(this);const c=1/s,h=1/a,u=1/o;return Oe.elements[0]*=c,Oe.elements[1]*=c,Oe.elements[2]*=c,Oe.elements[4]*=h,Oe.elements[5]*=h,Oe.elements[6]*=h,Oe.elements[8]*=u,Oe.elements[9]*=u,Oe.elements[10]*=u,e.setFromRotationMatrix(Oe),n.x=s,n.y=a,n.z=o,this}makePerspective(t,e,n,r,s,a,o=an){const l=this.elements,c=2*s/(e-t),h=2*s/(n-r),u=(e+t)/(e-t),d=(n+r)/(n-r);let p,g;if(o===an)p=-(a+s)/(a-s),g=-2*a*s/(a-s);else if(o===Ir)p=-a/(a-s),g=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=c,l[4]=0,l[8]=u,l[12]=0,l[1]=0,l[5]=h,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=g,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,n,r,s,a,o=an){const l=this.elements,c=1/(e-t),h=1/(n-r),u=1/(a-s),d=(e+t)*c,p=(n+r)*h;let g,v;if(o===an)g=(a+s)*u,v=-2*u;else if(o===Ir)g=s*u,v=-1*u;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-d,l[1]=0,l[5]=2*h,l[9]=0,l[13]=-p,l[2]=0,l[6]=0,l[10]=v,l[14]=-g,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let r=0;r<16;r++)if(e[r]!==n[r])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const Zn=new L,Oe=new Dt,xh=new L(0,0,0),Mh=new L(1,1,1),gn=new L,tr=new L,Te=new L,oo=new Dt,lo=new kn;class Ye{constructor(t=0,e=0,n=0,r=Ye.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=r}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,r=this._order){return this._x=t,this._y=e,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const r=t.elements,s=r[0],a=r[4],o=r[8],l=r[1],c=r[5],h=r[9],u=r[2],d=r[6],p=r[10];switch(e){case"XYZ":this._y=Math.asin(le(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-le(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(le(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,p),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-le(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(le(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-le(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return oo.makeRotationFromQuaternion(t),this.setFromRotationMatrix(oo,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return lo.setFromEuler(this),this.setFromQuaternion(lo,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Ye.DEFAULT_ORDER="XYZ";class Ma{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let Sh=0;const co=new L,$n=new kn,tn=new Dt,er=new L,bi=new L,yh=new L,Eh=new kn,ho=new L(1,0,0),uo=new L(0,1,0),fo=new L(0,0,1),po={type:"added"},Th={type:"removed"},jn={type:"childadded",child:null},jr={type:"childremoved",child:null};class se extends Hn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Sh++}),this.uuid=Ge(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=se.DEFAULT_UP.clone();const t=new L,e=new Ye,n=new kn,r=new L(1,1,1);function s(){n.setFromEuler(e,!1)}function a(){e.setFromQuaternion(n,void 0,!1)}e._onChange(s),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new Dt},normalMatrix:{value:new Ct}}),this.matrix=new Dt,this.matrixWorld=new Dt,this.matrixAutoUpdate=se.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=se.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Ma,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return $n.setFromAxisAngle(t,e),this.quaternion.multiply($n),this}rotateOnWorldAxis(t,e){return $n.setFromAxisAngle(t,e),this.quaternion.premultiply($n),this}rotateX(t){return this.rotateOnAxis(ho,t)}rotateY(t){return this.rotateOnAxis(uo,t)}rotateZ(t){return this.rotateOnAxis(fo,t)}translateOnAxis(t,e){return co.copy(t).applyQuaternion(this.quaternion),this.position.add(co.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(ho,t)}translateY(t){return this.translateOnAxis(uo,t)}translateZ(t){return this.translateOnAxis(fo,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(tn.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?er.copy(t):er.set(t,e,n);const r=this.parent;this.updateWorldMatrix(!0,!1),bi.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?tn.lookAt(bi,er,this.up):tn.lookAt(er,bi,this.up),this.quaternion.setFromRotationMatrix(tn),r&&(tn.extractRotation(r.matrixWorld),$n.setFromRotationMatrix(tn),this.quaternion.premultiply($n.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(po),jn.child=t,this.dispatchEvent(jn),jn.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Th),jr.child=t,this.dispatchEvent(jr),jr.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),tn.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),tn.multiply(t.parent.matrixWorld)),t.applyMatrix4(tn),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(po),jn.child=t,this.dispatchEvent(jn),jn.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,r=this.children.length;n<r;n++){const a=this.children[n].getObjectByProperty(t,e);if(a!==void 0)return a}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(bi,t,yh),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(bi,Eh,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let n=0,r=e.length;n<r;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let n=0,r=e.length;n<r;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,r=e.length;n<r;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e){const n=this.parent;if(t===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),e===!0){const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].updateWorldMatrix(!1,!0)}}toJSON(t){const e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,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),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.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),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.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(o=>({boxInitialized:o.boxInitialized,boxMin:o.box.min.toArray(),boxMax:o.box.max.toArray(),sphereInitialized:o.sphereInitialized,sphereRadius:o.sphere.radius,sphereCenter:o.sphere.center.toArray()})),r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(t),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function s(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(t.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const u=l[c];s(t.shapes,u)}else s(t.shapes,l)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(t.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(s(t.materials,this.material[l]));r.material=o}else r.material=s(t.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(t).object)}if(this.animations.length>0){r.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];r.animations.push(s(t.animations,l))}}if(e){const o=a(t.geometries),l=a(t.materials),c=a(t.textures),h=a(t.images),u=a(t.shapes),d=a(t.skeletons),p=a(t.animations),g=a(t.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),p.length>0&&(n.animations=p),g.length>0&&(n.nodes=g)}return n.object=r,n;function a(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}return l}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){const r=t.children[n];this.add(r.clone())}return this}}se.DEFAULT_UP=new L(0,1,0);se.DEFAULT_MATRIX_AUTO_UPDATE=!0;se.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Be=new L,en=new L,Jr=new L,nn=new L,Jn=new L,Qn=new L,mo=new L,Qr=new L,ts=new L,es=new L,ns=new Wt,is=new Wt,rs=new Wt;class Ve{constructor(t=new L,e=new L,n=new L){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,r){r.subVectors(n,e),Be.subVectors(t,e),r.cross(Be);const s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(t,e,n,r,s){Be.subVectors(r,e),en.subVectors(n,e),Jr.subVectors(t,e);const a=Be.dot(Be),o=Be.dot(en),l=Be.dot(Jr),c=en.dot(en),h=en.dot(Jr),u=a*c-o*o;if(u===0)return s.set(0,0,0),null;const d=1/u,p=(c*l-o*h)*d,g=(a*h-o*l)*d;return s.set(1-p-g,g,p)}static containsPoint(t,e,n,r){return this.getBarycoord(t,e,n,r,nn)===null?!1:nn.x>=0&&nn.y>=0&&nn.x+nn.y<=1}static getInterpolation(t,e,n,r,s,a,o,l){return this.getBarycoord(t,e,n,r,nn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,nn.x),l.addScaledVector(a,nn.y),l.addScaledVector(o,nn.z),l)}static getInterpolatedAttribute(t,e,n,r,s,a){return ns.setScalar(0),is.setScalar(0),rs.setScalar(0),ns.fromBufferAttribute(t,e),is.fromBufferAttribute(t,n),rs.fromBufferAttribute(t,r),a.setScalar(0),a.addScaledVector(ns,s.x),a.addScaledVector(is,s.y),a.addScaledVector(rs,s.z),a}static isFrontFacing(t,e,n,r){return Be.subVectors(n,e),en.subVectors(t,e),Be.cross(en).dot(r)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,r){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[r]),this}setFromAttributeAndIndices(t,e,n,r){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,r),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Be.subVectors(this.c,this.b),en.subVectors(this.a,this.b),Be.cross(en).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Ve.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Ve.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,r,s){return Ve.getInterpolation(t,this.a,this.b,this.c,e,n,r,s)}containsPoint(t){return Ve.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Ve.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,r=this.b,s=this.c;let a,o;Jn.subVectors(r,n),Qn.subVectors(s,n),Qr.subVectors(t,n);const l=Jn.dot(Qr),c=Qn.dot(Qr);if(l<=0&&c<=0)return e.copy(n);ts.subVectors(t,r);const h=Jn.dot(ts),u=Qn.dot(ts);if(h>=0&&u<=h)return e.copy(r);const d=l*u-h*c;if(d<=0&&l>=0&&h<=0)return a=l/(l-h),e.copy(n).addScaledVector(Jn,a);es.subVectors(t,s);const p=Jn.dot(es),g=Qn.dot(es);if(g>=0&&p<=g)return e.copy(s);const v=p*c-l*g;if(v<=0&&c>=0&&g<=0)return o=c/(c-g),e.copy(n).addScaledVector(Qn,o);const m=h*g-p*u;if(m<=0&&u-h>=0&&p-g>=0)return mo.subVectors(s,r),o=(u-h)/(u-h+(p-g)),e.copy(r).addScaledVector(mo,o);const f=1/(m+v+d);return a=v*f,o=d*f,e.copy(n).addScaledVector(Jn,a).addScaledVector(Qn,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const Pl={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},_n={h:0,s:0,l:0},nr={h:0,s:0,l:0};function ss(i,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?i+(t-i)*6*e:e<1/2?t:e<2/3?i+(t-i)*6*(2/3-e):i}class It{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){const r=t;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Ae){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Vt.toWorkingColorSpace(this,e),this}setRGB(t,e,n,r=Vt.workingColorSpace){return this.r=t,this.g=e,this.b=n,Vt.toWorkingColorSpace(this,r),this}setHSL(t,e,n,r=Vt.workingColorSpace){if(t=xa(t,1),e=le(e,0,1),n=le(n,0,1),e===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+e):n+e-n*e,a=2*n-s;this.r=ss(a,s,t+1/3),this.g=ss(a,s,t),this.b=ss(a,s,t-1/3)}return Vt.toWorkingColorSpace(this,r),this}setStyle(t,e=Ae){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(t)){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,e);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,e);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,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(t)){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,e);if(a===6)return this.setHex(parseInt(s,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Ae){const n=Pl[t.toLowerCase()];return n!==void 0?this.setHex(n,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=on(t.r),this.g=on(t.g),this.b=on(t.b),this}copyLinearToSRGB(t){return this.r=li(t.r),this.g=li(t.g),this.b=li(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Ae){return Vt.fromWorkingColorSpace(me.copy(this),t),Math.round(le(me.r*255,0,255))*65536+Math.round(le(me.g*255,0,255))*256+Math.round(le(me.b*255,0,255))}getHexString(t=Ae){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Vt.workingColorSpace){Vt.fromWorkingColorSpace(me.copy(this),e);const n=me.r,r=me.g,s=me.b,a=Math.max(n,r,s),o=Math.min(n,r,s);let l,c;const h=(o+a)/2;if(o===a)l=0,c=0;else{const u=a-o;switch(c=h<=.5?u/(a+o):u/(2-a-o),a){case n:l=(r-s)/u+(r<s?6:0);break;case r:l=(s-n)/u+2;break;case s:l=(n-r)/u+4;break}l/=6}return t.h=l,t.s=c,t.l=h,t}getRGB(t,e=Vt.workingColorSpace){return Vt.fromWorkingColorSpace(me.copy(this),e),t.r=me.r,t.g=me.g,t.b=me.b,t}getStyle(t=Ae){Vt.fromWorkingColorSpace(me.copy(this),t);const e=me.r,n=me.g,r=me.b;return t!==Ae?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(r*255)})`}offsetHSL(t,e,n){return this.getHSL(_n),this.setHSL(_n.h+t,_n.s+e,_n.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(_n),t.getHSL(nr);const n=Fi(_n.h,nr.h,e),r=Fi(_n.s,nr.s,e),s=Fi(_n.l,nr.l,e);return this.setHSL(n,r,s),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,n=this.g,r=this.b,s=t.elements;return this.r=s[0]*e+s[3]*n+s[6]*r,this.g=s[1]*e+s[4]*n+s[7]*r,this.b=s[2]*e+s[5]*n+s[8]*r,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const me=new It;It.NAMES=Pl;let bh=0;class wn extends Hn{static get type(){return"Material"}get type(){return this.constructor.type}set type(t){}constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:bh++}),this.uuid=Ge(),this.name="",this.blending=ai,this.side=ln,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Ts,this.blendDst=bs,this.blendEquation=Fn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new It(0,0,0),this.blendAlpha=0,this.depthFunc=ci,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=ja,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Wn,this.stencilZFail=Wn,this.stencilZPass=Wn,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const n=t[e];if(n===void 0){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const r=this[e];if(r===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==ai&&(n.blending=this.blending),this.side!==ln&&(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!==Ts&&(n.blendSrc=this.blendSrc),this.blendDst!==bs&&(n.blendDst=this.blendDst),this.blendEquation!==Fn&&(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!==ja&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Wn&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Wn&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Wn&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(e){const s=r(t.textures),a=r(t.images);s.length>0&&(n.textures=s),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(e!==null){const r=e.length;n=new Array(r);for(let s=0;s!==r;++s)n[s]=e[s].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class Sa extends wn{static get type(){return"MeshBasicMaterial"}constructor(t){super(),this.isMeshBasicMaterial=!0,this.color=new It(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 Ye,this.combine=fl,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const oe=new L,ir=new Ft;class Re{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=oa,this.updateRanges=[],this.gpuType=ke,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[t+r]=e.array[n+r];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)ir.fromBufferAttribute(this,e),ir.applyMatrix3(t),this.setXY(e,ir.x,ir.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)oe.fromBufferAttribute(this,e),oe.applyMatrix3(t),this.setXYZ(e,oe.x,oe.y,oe.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)oe.fromBufferAttribute(this,e),oe.applyMatrix4(t),this.setXYZ(e,oe.x,oe.y,oe.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)oe.fromBufferAttribute(this,e),oe.applyNormalMatrix(t),this.setXYZ(e,oe.x,oe.y,oe.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)oe.fromBufferAttribute(this,e),oe.transformDirection(t),this.setXYZ(e,oe.x,oe.y,oe.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=ze(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=Kt(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=ze(e,this.array)),e}setX(t,e){return this.normalized&&(e=Kt(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=ze(e,this.array)),e}setY(t,e){return this.normalized&&(e=Kt(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=ze(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Kt(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=ze(e,this.array)),e}setW(t,e){return this.normalized&&(e=Kt(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=Kt(e,this.array),n=Kt(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,r){return t*=this.itemSize,this.normalized&&(e=Kt(e,this.array),n=Kt(n,this.array),r=Kt(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=r,this}setXYZW(t,e,n,r,s){return t*=this.itemSize,this.normalized&&(e=Kt(e,this.array),n=Kt(n,this.array),r=Kt(r,this.array),s=Kt(s,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=r,this.array[t+3]=s,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==oa&&(t.usage=this.usage),t}}class Ll extends Re{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class Dl extends Re{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class ye extends Re{constructor(t,e,n){super(new Float32Array(t),e,n)}}let Ah=0;const Le=new Dt,as=new se,ti=new L,be=new hn,Ai=new hn,ue=new L;class Ie extends Hn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Ah++}),this.uuid=Ge(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(wl(t)?Dl:Ll)(t,1):this.index=t,this}setIndirect(t){return this.indirect=t,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const s=new Ct().getNormalMatrix(t);n.applyNormalMatrix(s),n.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(t),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return Le.makeRotationFromQuaternion(t),this.applyMatrix4(Le),this}rotateX(t){return Le.makeRotationX(t),this.applyMatrix4(Le),this}rotateY(t){return Le.makeRotationY(t),this.applyMatrix4(Le),this}rotateZ(t){return Le.makeRotationZ(t),this.applyMatrix4(Le),this}translate(t,e,n){return Le.makeTranslation(t,e,n),this.applyMatrix4(Le),this}scale(t,e,n){return Le.makeScale(t,e,n),this.applyMatrix4(Le),this}lookAt(t){return as.lookAt(t),as.updateMatrix(),this.applyMatrix4(as.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ti).negate(),this.translate(ti.x,ti.y,ti.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const n=[];for(let r=0,s=t.length;r<s;r++){const a=t[r];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new ye(n,3))}else{for(let n=0,r=e.count;n<r;n++){const s=t[n];e.setXYZ(n,s.x,s.y,s.z||0)}t.length>e.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new hn);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new L(-1/0,-1/0,-1/0),new L(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,r=e.length;n<r;n++){const s=e[n];be.setFromBufferAttribute(s),this.morphTargetsRelative?(ue.addVectors(this.boundingBox.min,be.min),this.boundingBox.expandByPoint(ue),ue.addVectors(this.boundingBox.max,be.max),this.boundingBox.expandByPoint(ue)):(this.boundingBox.expandByPoint(be.min),this.boundingBox.expandByPoint(be.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ke);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new L,1/0);return}if(t){const n=this.boundingSphere.center;if(be.setFromBufferAttribute(t),e)for(let s=0,a=e.length;s<a;s++){const o=e[s];Ai.setFromBufferAttribute(o),this.morphTargetsRelative?(ue.addVectors(be.min,Ai.min),be.expandByPoint(ue),ue.addVectors(be.max,Ai.max),be.expandByPoint(ue)):(be.expandByPoint(Ai.min),be.expandByPoint(Ai.max))}be.getCenter(n);let r=0;for(let s=0,a=t.count;s<a;s++)ue.fromBufferAttribute(t,s),r=Math.max(r,n.distanceToSquared(ue));if(e)for(let s=0,a=e.length;s<a;s++){const o=e[s],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)ue.fromBufferAttribute(o,c),l&&(ti.fromBufferAttribute(t,c),ue.add(ti)),r=Math.max(r,n.distanceToSquared(ue))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=e.position,r=e.normal,s=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Re(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let U=0;U<n.count;U++)o[U]=new L,l[U]=new L;const c=new L,h=new L,u=new L,d=new Ft,p=new Ft,g=new Ft,v=new L,m=new L;function f(U,y,M){c.fromBufferAttribute(n,U),h.fromBufferAttribute(n,y),u.fromBufferAttribute(n,M),d.fromBufferAttribute(s,U),p.fromBufferAttribute(s,y),g.fromBufferAttribute(s,M),h.sub(c),u.sub(c),p.sub(d),g.sub(d);const R=1/(p.x*g.y-g.x*p.y);isFinite(R)&&(v.copy(h).multiplyScalar(g.y).addScaledVector(u,-p.y).multiplyScalar(R),m.copy(u).multiplyScalar(p.x).addScaledVector(h,-g.x).multiplyScalar(R),o[U].add(v),o[y].add(v),o[M].add(v),l[U].add(m),l[y].add(m),l[M].add(m))}let b=this.groups;b.length===0&&(b=[{start:0,count:t.count}]);for(let U=0,y=b.length;U<y;++U){const M=b[U],R=M.start,q=M.count;for(let z=R,W=R+q;z<W;z+=3)f(t.getX(z+0),t.getX(z+1),t.getX(z+2))}const T=new L,S=new L,B=new L,A=new L;function w(U){B.fromBufferAttribute(r,U),A.copy(B);const y=o[U];T.copy(y),T.sub(B.multiplyScalar(B.dot(y))).normalize(),S.crossVectors(A,y);const R=S.dot(l[U])<0?-1:1;a.setXYZW(U,T.x,T.y,T.z,R)}for(let U=0,y=b.length;U<y;++U){const M=b[U],R=M.start,q=M.count;for(let z=R,W=R+q;z<W;z+=3)w(t.getX(z+0)),w(t.getX(z+1)),w(t.getX(z+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new Re(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let d=0,p=n.count;d<p;d++)n.setXYZ(d,0,0,0);const r=new L,s=new L,a=new L,o=new L,l=new L,c=new L,h=new L,u=new L;if(t)for(let d=0,p=t.count;d<p;d+=3){const g=t.getX(d+0),v=t.getX(d+1),m=t.getX(d+2);r.fromBufferAttribute(e,g),s.fromBufferAttribute(e,v),a.fromBufferAttribute(e,m),h.subVectors(a,s),u.subVectors(r,s),h.cross(u),o.fromBufferAttribute(n,g),l.fromBufferAttribute(n,v),c.fromBufferAttribute(n,m),o.add(h),l.add(h),c.add(h),n.setXYZ(g,o.x,o.y,o.z),n.setXYZ(v,l.x,l.y,l.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let d=0,p=e.count;d<p;d+=3)r.fromBufferAttribute(e,d+0),s.fromBufferAttribute(e,d+1),a.fromBufferAttribute(e,d+2),h.subVectors(a,s),u.subVectors(r,s),h.cross(u),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)ue.fromBufferAttribute(t,e),ue.normalize(),t.setXYZ(e,ue.x,ue.y,ue.z)}toNonIndexed(){function t(o,l){const c=o.array,h=o.itemSize,u=o.normalized,d=new c.constructor(l.length*h);let p=0,g=0;for(let v=0,m=l.length;v<m;v++){o.isInterleavedBufferAttribute?p=l[v]*o.data.stride+o.offset:p=l[v]*h;for(let f=0;f<h;f++)d[g++]=c[p++]}return new Re(d,h,u)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new Ie,n=this.index.array,r=this.attributes;for(const o in r){const l=r[o],c=t(l,n);e.setAttribute(o,c)}const s=this.morphAttributes;for(const o in s){const l=[],c=s[o];for(let h=0,u=c.length;h<u;h++){const d=c[h],p=t(d,n);l.push(p)}e.morphAttributes[o]=l}e.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];e.addGroup(c.start,c.count,c.materialIndex)}return e}toJSON(){const t={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(t[c]=l[c]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const l in n){const c=n[l];t.data.attributes[l]=c.toJSON(t.data)}const r={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let u=0,d=c.length;u<d;u++){const p=c[u];h.push(p.toJSON(t.data))}h.length>0&&(r[l]=h,s=!0)}s&&(t.data.morphAttributes=r,t.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(t.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;n!==null&&this.setIndex(n.clone(e));const r=t.attributes;for(const c in r){const h=r[c];this.setAttribute(c,h.clone(e))}const s=t.morphAttributes;for(const c in s){const h=[],u=s[c];for(let d=0,p=u.length;d<p;d++)h.push(u[d].clone(e));this.morphAttributes[c]=h}this.morphTargetsRelative=t.morphTargetsRelative;const a=t.groups;for(let c=0,h=a.length;c<h;c++){const u=a[c];this.addGroup(u.start,u.count,u.materialIndex)}const o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=t.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const go=new Dt,Ln=new gi,rr=new Ke,_o=new L,sr=new L,ar=new L,or=new L,os=new L,lr=new L,vo=new L,cr=new L;class we extends se{constructor(t=new Ie,e=new Sa){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const r=e[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(t,e){const n=this.geometry,r=n.attributes.position,s=n.morphAttributes.position,a=n.morphTargetsRelative;e.fromBufferAttribute(r,t);const o=this.morphTargetInfluences;if(s&&o){lr.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const h=o[l],u=s[l];h!==0&&(os.fromBufferAttribute(u,t),a?lr.addScaledVector(os,h):lr.addScaledVector(os.sub(e),h))}e.add(lr)}return e}raycast(t,e){const n=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),rr.copy(n.boundingSphere),rr.applyMatrix4(s),Ln.copy(t.ray).recast(t.near),!(rr.containsPoint(Ln.origin)===!1&&(Ln.intersectSphere(rr,_o)===null||Ln.origin.distanceToSquared(_o)>ka(t.far-t.near,2)))&&(go.copy(s).invert(),Ln.copy(t.ray).applyMatrix4(go),!(n.boundingBox!==null&&Ln.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,Ln)))}_computeIntersections(t,e,n){let r;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,h=s.attributes.uv1,u=s.attributes.normal,d=s.groups,p=s.drawRange;if(o!==null)if(Array.isArray(a))for(let g=0,v=d.length;g<v;g++){const m=d[g],f=a[m.materialIndex],b=Math.max(m.start,p.start),T=Math.min(o.count,Math.min(m.start+m.count,p.start+p.count));for(let S=b,B=T;S<B;S+=3){const A=o.getX(S),w=o.getX(S+1),U=o.getX(S+2);r=hr(this,f,t,n,c,h,u,A,w,U),r&&(r.faceIndex=Math.floor(S/3),r.face.materialIndex=m.materialIndex,e.push(r))}}else{const g=Math.max(0,p.start),v=Math.min(o.count,p.start+p.count);for(let m=g,f=v;m<f;m+=3){const b=o.getX(m),T=o.getX(m+1),S=o.getX(m+2);r=hr(this,a,t,n,c,h,u,b,T,S),r&&(r.faceIndex=Math.floor(m/3),e.push(r))}}else if(l!==void 0)if(Array.isArray(a))for(let g=0,v=d.length;g<v;g++){const m=d[g],f=a[m.materialIndex],b=Math.max(m.start,p.start),T=Math.min(l.count,Math.min(m.start+m.count,p.start+p.count));for(let S=b,B=T;S<B;S+=3){const A=S,w=S+1,U=S+2;r=hr(this,f,t,n,c,h,u,A,w,U),r&&(r.faceIndex=Math.floor(S/3),r.face.materialIndex=m.materialIndex,e.push(r))}}else{const g=Math.max(0,p.start),v=Math.min(l.count,p.start+p.count);for(let m=g,f=v;m<f;m+=3){const b=m,T=m+1,S=m+2;r=hr(this,a,t,n,c,h,u,b,T,S),r&&(r.faceIndex=Math.floor(m/3),e.push(r))}}}}function wh(i,t,e,n,r,s,a,o){let l;if(t.side===Me?l=n.intersectTriangle(a,s,r,!0,o):l=n.intersectTriangle(r,s,a,t.side===ln,o),l===null)return null;cr.copy(o),cr.applyMatrix4(i.matrixWorld);const c=e.ray.origin.distanceTo(cr);return c<e.near||c>e.far?null:{distance:c,point:cr.clone(),object:i}}function hr(i,t,e,n,r,s,a,o,l,c){i.getVertexPosition(o,sr),i.getVertexPosition(l,ar),i.getVertexPosition(c,or);const h=wh(i,t,e,n,sr,ar,or,vo);if(h){const u=new L;Ve.getBarycoord(vo,sr,ar,or,u),r&&(h.uv=Ve.getInterpolatedAttribute(r,o,l,c,u,new Ft)),s&&(h.uv1=Ve.getInterpolatedAttribute(s,o,l,c,u,new Ft)),a&&(h.normal=Ve.getInterpolatedAttribute(a,o,l,c,u,new L),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:l,c,normal:new L,materialIndex:0};Ve.getNormal(sr,ar,or,d.normal),h.face=d,h.barycoord=u}return h}class Gi extends Ie{constructor(t=1,e=1,n=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:r,heightSegments:s,depthSegments:a};const o=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],h=[],u=[];let d=0,p=0;g("z","y","x",-1,-1,n,e,t,a,s,0),g("z","y","x",1,-1,n,e,-t,a,s,1),g("x","z","y",1,1,t,n,e,r,a,2),g("x","z","y",1,-1,t,n,-e,r,a,3),g("x","y","z",1,-1,t,e,n,r,s,4),g("x","y","z",-1,-1,t,e,-n,r,s,5),this.setIndex(l),this.setAttribute("position",new ye(c,3)),this.setAttribute("normal",new ye(h,3)),this.setAttribute("uv",new ye(u,2));function g(v,m,f,b,T,S,B,A,w,U,y){const M=S/w,R=B/U,q=S/2,z=B/2,W=A/2,$=w+1,k=U+1;let Q=0,H=0;const it=new L;for(let ct=0;ct<k;ct++){const xt=ct*R-z;for(let Ut=0;Ut<$;Ut++){const jt=Ut*M-q;it[v]=jt*b,it[m]=xt*T,it[f]=W,c.push(it.x,it.y,it.z),it[v]=0,it[m]=0,it[f]=A>0?1:-1,h.push(it.x,it.y,it.z),u.push(Ut/w),u.push(1-ct/U),Q+=1}}for(let ct=0;ct<U;ct++)for(let xt=0;xt<w;xt++){const Ut=d+xt+$*ct,jt=d+xt+$*(ct+1),X=d+(xt+1)+$*(ct+1),tt=d+(xt+1)+$*ct;l.push(Ut,jt,tt),l.push(jt,X,tt),H+=6}o.addGroup(p,H,y),p+=H,d+=Q}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Gi(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}function mi(i){const t={};for(const e in i){t[e]={};for(const n in i[e]){const r=i[e][n];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=r.clone():Array.isArray(r)?t[e][n]=r.slice():t[e][n]=r}}return t}function _e(i){const t={};for(let e=0;e<i.length;e++){const n=mi(i[e]);for(const r in n)t[r]=n[r]}return t}function Rh(i){const t=[];for(let e=0;e<i.length;e++)t.push(i[e].clone());return t}function Il(i){const t=i.getRenderTarget();return t===null?i.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:Vt.workingColorSpace}const Ch={clone:mi,merge:_e};var Ph=`void main() {
2
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
3
+ }`,Lh=`void main() {
4
+ gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
5
+ }`;class An extends wn{static get type(){return"ShaderMaterial"}constructor(t){super(),this.isShaderMaterial=!0,this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Ph,this.fragmentShader=Lh,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,t!==void 0&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=mi(t.uniforms),this.uniformsGroups=Rh(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const r in this.uniforms){const a=this.uniforms[r].value;a&&a.isTexture?e.uniforms[r]={type:"t",value:a.toJSON(t).uuid}:a&&a.isColor?e.uniforms[r]={type:"c",value:a.getHex()}:a&&a.isVector2?e.uniforms[r]={type:"v2",value:a.toArray()}:a&&a.isVector3?e.uniforms[r]={type:"v3",value:a.toArray()}:a&&a.isVector4?e.uniforms[r]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?e.uniforms[r]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?e.uniforms[r]={type:"m4",value:a.toArray()}:e.uniforms[r]={value:a}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const n={};for(const r in this.extensions)this.extensions[r]===!0&&(n[r]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}}class Ul extends se{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Dt,this.projectionMatrix=new Dt,this.projectionMatrixInverse=new Dt,this.coordinateSystem=an}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const vn=new L,xo=new Ft,Mo=new Ft;class xe extends Ul{constructor(t=50,e=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=pi*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(Ni*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return pi*2*Math.atan(Math.tan(Ni*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){vn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(vn.x,vn.y).multiplyScalar(-t/vn.z),vn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(vn.x,vn.y).multiplyScalar(-t/vn.z)}getViewSize(t,e){return this.getViewBounds(t,xo,Mo),e.subVectors(Mo,xo)}setViewOffset(t,e,n,r,s,a){this.aspect=t/e,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(Ni*.5*this.fov)/this.zoom,n=2*e,r=this.aspect*n,s=-.5*r;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;s+=a.offsetX*r/l,e-=a.offsetY*n/c,r*=a.width/l,n*=a.height/c}const o=this.filmOffset;o!==0&&(s+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,e,e-n,t,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}const ei=-90,ni=1;class Dh extends se{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new xe(ei,ni,t,e);r.layers=this.layers,this.add(r);const s=new xe(ei,ni,t,e);s.layers=this.layers,this.add(s);const a=new xe(ei,ni,t,e);a.layers=this.layers,this.add(a);const o=new xe(ei,ni,t,e);o.layers=this.layers,this.add(o);const l=new xe(ei,ni,t,e);l.layers=this.layers,this.add(l);const c=new xe(ei,ni,t,e);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,r,s,a,o,l]=e;for(const c of e)this.remove(c);if(t===an)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),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(t===Ir)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),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(const c of e)this.add(c),c.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,l,c,h]=this.children,u=t.getRenderTarget(),d=t.getActiveCubeFace(),p=t.getActiveMipmapLevel(),g=t.xr.enabled;t.xr.enabled=!1;const v=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0,r),t.render(e,s),t.setRenderTarget(n,1,r),t.render(e,a),t.setRenderTarget(n,2,r),t.render(e,o),t.setRenderTarget(n,3,r),t.render(e,l),t.setRenderTarget(n,4,r),t.render(e,c),n.texture.generateMipmaps=v,t.setRenderTarget(n,5,r),t.render(e,h),t.setRenderTarget(u,d,p),t.xr.enabled=g,n.texture.needsPMREMUpdate=!0}}class Nl extends de{constructor(t,e,n,r,s,a,o,l,c,h){t=t!==void 0?t:[],e=e!==void 0?e:hi,super(t,e,n,r,s,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class Ih extends zn{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const n={width:t,height:t,depth:1},r=[n,n,n,n,n,n];this.texture=new Nl(r,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=e.generateMipmaps!==void 0?e.generateMipmaps:!1,this.texture.minFilter=e.minFilter!==void 0?e.minFilter:He}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:`
6
+
7
+ varying vec3 vWorldDirection;
8
+
9
+ vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
10
+
11
+ return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
12
+
13
+ }
14
+
15
+ void main() {
16
+
17
+ vWorldDirection = transformDirection( position, modelMatrix );
18
+
19
+ #include <begin_vertex>
20
+ #include <project_vertex>
21
+
22
+ }
23
+ `,fragmentShader:`
24
+
25
+ uniform sampler2D tEquirect;
26
+
27
+ varying vec3 vWorldDirection;
28
+
29
+ #include <common>
30
+
31
+ void main() {
32
+
33
+ vec3 direction = normalize( vWorldDirection );
34
+
35
+ vec2 sampleUV = equirectUv( direction );
36
+
37
+ gl_FragColor = texture2D( tEquirect, sampleUV );
38
+
39
+ }
40
+ `},r=new Gi(5,5,5),s=new An({name:"CubemapFromEquirect",uniforms:mi(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Me,blending:Tn});s.uniforms.tEquirect.value=e;const a=new we(r,s),o=e.minFilter;return e.minFilter===yn&&(e.minFilter=He),new Dh(1,10,this).update(t,a),e.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(t,e,n,r){const s=t.getRenderTarget();for(let a=0;a<6;a++)t.setRenderTarget(this,a),t.clear(e,n,r);t.setRenderTarget(s)}}const ls=new L,Uh=new L,Nh=new Ct;class xn{constructor(t=new L(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,r){return this.normal.set(t,e,n),this.constant=r,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const r=ls.subVectors(n,e).cross(Uh.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(r,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const n=t.delta(ls),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const s=-(t.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:e.copy(t.start).addScaledVector(n,s)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||Nh.getNormalMatrix(t),r=this.coplanarPoint(ls).applyMatrix4(t),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(s),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Dn=new Ke,ur=new L;class ya{constructor(t=new xn,e=new xn,n=new xn,r=new xn,s=new xn,a=new xn){this.planes=[t,e,n,r,s,a]}set(t,e,n,r,s,a){const o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(r),o[4].copy(s),o[5].copy(a),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=an){const n=this.planes,r=t.elements,s=r[0],a=r[1],o=r[2],l=r[3],c=r[4],h=r[5],u=r[6],d=r[7],p=r[8],g=r[9],v=r[10],m=r[11],f=r[12],b=r[13],T=r[14],S=r[15];if(n[0].setComponents(l-s,d-c,m-p,S-f).normalize(),n[1].setComponents(l+s,d+c,m+p,S+f).normalize(),n[2].setComponents(l+a,d+h,m+g,S+b).normalize(),n[3].setComponents(l-a,d-h,m-g,S-b).normalize(),n[4].setComponents(l-o,d-u,m-v,S-T).normalize(),e===an)n[5].setComponents(l+o,d+u,m+v,S+T).normalize();else if(e===Ir)n[5].setComponents(o,u,v,T).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),Dn.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),Dn.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Dn)}intersectsSprite(t){return Dn.center.set(0,0,0),Dn.radius=.7071067811865476,Dn.applyMatrix4(t.matrixWorld),this.intersectsSphere(Dn)}intersectsSphere(t){const e=this.planes,n=t.center,r=-t.radius;for(let s=0;s<6;s++)if(e[s].distanceToPoint(n)<r)return!1;return!0}intersectsBox(t){const e=this.planes;for(let n=0;n<6;n++){const r=e[n];if(ur.x=r.normal.x>0?t.max.x:t.min.x,ur.y=r.normal.y>0?t.max.y:t.min.y,ur.z=r.normal.z>0?t.max.z:t.min.z,r.distanceToPoint(ur)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function Fl(){let i=null,t=!1,e=null,n=null;function r(s,a){e(s,a),n=i.requestAnimationFrame(r)}return{start:function(){t!==!0&&e!==null&&(n=i.requestAnimationFrame(r),t=!0)},stop:function(){i.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(s){e=s},setContext:function(s){i=s}}}function Fh(i){const t=new WeakMap;function e(o,l){const c=o.array,h=o.usage,u=c.byteLength,d=i.createBuffer();i.bindBuffer(l,d),i.bufferData(l,c,h),o.onUploadCallback();let p;if(c instanceof Float32Array)p=i.FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?p=i.HALF_FLOAT:p=i.UNSIGNED_SHORT;else if(c instanceof Int16Array)p=i.SHORT;else if(c instanceof Uint32Array)p=i.UNSIGNED_INT;else if(c instanceof Int32Array)p=i.INT;else if(c instanceof Int8Array)p=i.BYTE;else if(c instanceof Uint8Array)p=i.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)p=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:d,type:p,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:u}}function n(o,l,c){const h=l.array,u=l.updateRanges;if(i.bindBuffer(c,o),u.length===0)i.bufferSubData(c,0,h);else{u.sort((p,g)=>p.start-g.start);let d=0;for(let p=1;p<u.length;p++){const g=u[d],v=u[p];v.start<=g.start+g.count+1?g.count=Math.max(g.count,v.start+v.count-g.start):(++d,u[d]=v)}u.length=d+1;for(let p=0,g=u.length;p<g;p++){const v=u[p];i.bufferSubData(c,v.start*h.BYTES_PER_ELEMENT,h,v.start,v.count)}l.clearUpdateRanges()}l.onUploadCallback()}function r(o){return o.isInterleavedBufferAttribute&&(o=o.data),t.get(o)}function s(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=t.get(o);l&&(i.deleteBuffer(l.buffer),t.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const h=t.get(o);(!h||h.version<o.version)&&t.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const c=t.get(o);if(c===void 0)t.set(o,e(o,l));else if(c.version<o.version){if(c.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(c.buffer,o,l),c.version=o.version}}return{get:r,remove:s,update:a}}class Wi extends Ie{constructor(t=1,e=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:r};const s=t/2,a=e/2,o=Math.floor(n),l=Math.floor(r),c=o+1,h=l+1,u=t/o,d=e/l,p=[],g=[],v=[],m=[];for(let f=0;f<h;f++){const b=f*d-a;for(let T=0;T<c;T++){const S=T*u-s;g.push(S,-b,0),v.push(0,0,1),m.push(T/o),m.push(1-f/l)}}for(let f=0;f<l;f++)for(let b=0;b<o;b++){const T=b+c*f,S=b+c*(f+1),B=b+1+c*(f+1),A=b+1+c*f;p.push(T,S,A),p.push(S,B,A)}this.setIndex(p),this.setAttribute("position",new ye(g,3)),this.setAttribute("normal",new ye(v,3)),this.setAttribute("uv",new ye(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Wi(t.width,t.height,t.widthSegments,t.heightSegments)}}var Oh=`#ifdef USE_ALPHAHASH
41
+ if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
42
+ #endif`,Bh=`#ifdef USE_ALPHAHASH
43
+ const float ALPHA_HASH_SCALE = 0.05;
44
+ float hash2D( vec2 value ) {
45
+ return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
46
+ }
47
+ float hash3D( vec3 value ) {
48
+ return hash2D( vec2( hash2D( value.xy ), value.z ) );
49
+ }
50
+ float getAlphaHashThreshold( vec3 position ) {
51
+ float maxDeriv = max(
52
+ length( dFdx( position.xyz ) ),
53
+ length( dFdy( position.xyz ) )
54
+ );
55
+ float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
56
+ vec2 pixScales = vec2(
57
+ exp2( floor( log2( pixScale ) ) ),
58
+ exp2( ceil( log2( pixScale ) ) )
59
+ );
60
+ vec2 alpha = vec2(
61
+ hash3D( floor( pixScales.x * position.xyz ) ),
62
+ hash3D( floor( pixScales.y * position.xyz ) )
63
+ );
64
+ float lerpFactor = fract( log2( pixScale ) );
65
+ float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
66
+ float a = min( lerpFactor, 1.0 - lerpFactor );
67
+ vec3 cases = vec3(
68
+ x * x / ( 2.0 * a * ( 1.0 - a ) ),
69
+ ( x - 0.5 * a ) / ( 1.0 - a ),
70
+ 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
71
+ );
72
+ float threshold = ( x < ( 1.0 - a ) )
73
+ ? ( ( x < a ) ? cases.x : cases.y )
74
+ : cases.z;
75
+ return clamp( threshold , 1.0e-6, 1.0 );
76
+ }
77
+ #endif`,zh=`#ifdef USE_ALPHAMAP
78
+ diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
79
+ #endif`,Vh=`#ifdef USE_ALPHAMAP
80
+ uniform sampler2D alphaMap;
81
+ #endif`,Hh=`#ifdef USE_ALPHATEST
82
+ #ifdef ALPHA_TO_COVERAGE
83
+ diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
84
+ if ( diffuseColor.a == 0.0 ) discard;
85
+ #else
86
+ if ( diffuseColor.a < alphaTest ) discard;
87
+ #endif
88
+ #endif`,kh=`#ifdef USE_ALPHATEST
89
+ uniform float alphaTest;
90
+ #endif`,Gh=`#ifdef USE_AOMAP
91
+ float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
92
+ reflectedLight.indirectDiffuse *= ambientOcclusion;
93
+ #if defined( USE_CLEARCOAT )
94
+ clearcoatSpecularIndirect *= ambientOcclusion;
95
+ #endif
96
+ #if defined( USE_SHEEN )
97
+ sheenSpecularIndirect *= ambientOcclusion;
98
+ #endif
99
+ #if defined( USE_ENVMAP ) && defined( STANDARD )
100
+ float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
101
+ reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
102
+ #endif
103
+ #endif`,Wh=`#ifdef USE_AOMAP
104
+ uniform sampler2D aoMap;
105
+ uniform float aoMapIntensity;
106
+ #endif`,Xh=`#ifdef USE_BATCHING
107
+ #if ! defined( GL_ANGLE_multi_draw )
108
+ #define gl_DrawID _gl_DrawID
109
+ uniform int _gl_DrawID;
110
+ #endif
111
+ uniform highp sampler2D batchingTexture;
112
+ uniform highp usampler2D batchingIdTexture;
113
+ mat4 getBatchingMatrix( const in float i ) {
114
+ int size = textureSize( batchingTexture, 0 ).x;
115
+ int j = int( i ) * 4;
116
+ int x = j % size;
117
+ int y = j / size;
118
+ vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
119
+ vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
120
+ vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
121
+ vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
122
+ return mat4( v1, v2, v3, v4 );
123
+ }
124
+ float getIndirectIndex( const in int i ) {
125
+ int size = textureSize( batchingIdTexture, 0 ).x;
126
+ int x = i % size;
127
+ int y = i / size;
128
+ return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
129
+ }
130
+ #endif
131
+ #ifdef USE_BATCHING_COLOR
132
+ uniform sampler2D batchingColorTexture;
133
+ vec3 getBatchingColor( const in float i ) {
134
+ int size = textureSize( batchingColorTexture, 0 ).x;
135
+ int j = int( i );
136
+ int x = j % size;
137
+ int y = j / size;
138
+ return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
139
+ }
140
+ #endif`,qh=`#ifdef USE_BATCHING
141
+ mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
142
+ #endif`,Yh=`vec3 transformed = vec3( position );
143
+ #ifdef USE_ALPHAHASH
144
+ vPosition = vec3( position );
145
+ #endif`,Kh=`vec3 objectNormal = vec3( normal );
146
+ #ifdef USE_TANGENT
147
+ vec3 objectTangent = vec3( tangent.xyz );
148
+ #endif`,Zh=`float G_BlinnPhong_Implicit( ) {
149
+ return 0.25;
150
+ }
151
+ float D_BlinnPhong( const in float shininess, const in float dotNH ) {
152
+ return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
153
+ }
154
+ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
155
+ vec3 halfDir = normalize( lightDir + viewDir );
156
+ float dotNH = saturate( dot( normal, halfDir ) );
157
+ float dotVH = saturate( dot( viewDir, halfDir ) );
158
+ vec3 F = F_Schlick( specularColor, 1.0, dotVH );
159
+ float G = G_BlinnPhong_Implicit( );
160
+ float D = D_BlinnPhong( shininess, dotNH );
161
+ return F * ( G * D );
162
+ } // validated`,$h=`#ifdef USE_IRIDESCENCE
163
+ const mat3 XYZ_TO_REC709 = mat3(
164
+ 3.2404542, -0.9692660, 0.0556434,
165
+ -1.5371385, 1.8760108, -0.2040259,
166
+ -0.4985314, 0.0415560, 1.0572252
167
+ );
168
+ vec3 Fresnel0ToIor( vec3 fresnel0 ) {
169
+ vec3 sqrtF0 = sqrt( fresnel0 );
170
+ return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
171
+ }
172
+ vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
173
+ return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
174
+ }
175
+ float IorToFresnel0( float transmittedIor, float incidentIor ) {
176
+ return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
177
+ }
178
+ vec3 evalSensitivity( float OPD, vec3 shift ) {
179
+ float phase = 2.0 * PI * OPD * 1.0e-9;
180
+ vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
181
+ vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
182
+ vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
183
+ vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
184
+ xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
185
+ xyz /= 1.0685e-7;
186
+ vec3 rgb = XYZ_TO_REC709 * xyz;
187
+ return rgb;
188
+ }
189
+ vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
190
+ vec3 I;
191
+ float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
192
+ float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
193
+ float cosTheta2Sq = 1.0 - sinTheta2Sq;
194
+ if ( cosTheta2Sq < 0.0 ) {
195
+ return vec3( 1.0 );
196
+ }
197
+ float cosTheta2 = sqrt( cosTheta2Sq );
198
+ float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
199
+ float R12 = F_Schlick( R0, 1.0, cosTheta1 );
200
+ float T121 = 1.0 - R12;
201
+ float phi12 = 0.0;
202
+ if ( iridescenceIOR < outsideIOR ) phi12 = PI;
203
+ float phi21 = PI - phi12;
204
+ vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
205
+ vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
206
+ vec3 phi23 = vec3( 0.0 );
207
+ if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
208
+ if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
209
+ if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
210
+ float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
211
+ vec3 phi = vec3( phi21 ) + phi23;
212
+ vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
213
+ vec3 r123 = sqrt( R123 );
214
+ vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
215
+ vec3 C0 = R12 + Rs;
216
+ I = C0;
217
+ vec3 Cm = Rs - T121;
218
+ for ( int m = 1; m <= 2; ++ m ) {
219
+ Cm *= r123;
220
+ vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
221
+ I += Cm * Sm;
222
+ }
223
+ return max( I, vec3( 0.0 ) );
224
+ }
225
+ #endif`,jh=`#ifdef USE_BUMPMAP
226
+ uniform sampler2D bumpMap;
227
+ uniform float bumpScale;
228
+ vec2 dHdxy_fwd() {
229
+ vec2 dSTdx = dFdx( vBumpMapUv );
230
+ vec2 dSTdy = dFdy( vBumpMapUv );
231
+ float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
232
+ float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
233
+ float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
234
+ return vec2( dBx, dBy );
235
+ }
236
+ vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
237
+ vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
238
+ vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
239
+ vec3 vN = surf_norm;
240
+ vec3 R1 = cross( vSigmaY, vN );
241
+ vec3 R2 = cross( vN, vSigmaX );
242
+ float fDet = dot( vSigmaX, R1 ) * faceDirection;
243
+ vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
244
+ return normalize( abs( fDet ) * surf_norm - vGrad );
245
+ }
246
+ #endif`,Jh=`#if NUM_CLIPPING_PLANES > 0
247
+ vec4 plane;
248
+ #ifdef ALPHA_TO_COVERAGE
249
+ float distanceToPlane, distanceGradient;
250
+ float clipOpacity = 1.0;
251
+ #pragma unroll_loop_start
252
+ for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
253
+ plane = clippingPlanes[ i ];
254
+ distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
255
+ distanceGradient = fwidth( distanceToPlane ) / 2.0;
256
+ clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
257
+ if ( clipOpacity == 0.0 ) discard;
258
+ }
259
+ #pragma unroll_loop_end
260
+ #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
261
+ float unionClipOpacity = 1.0;
262
+ #pragma unroll_loop_start
263
+ for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
264
+ plane = clippingPlanes[ i ];
265
+ distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
266
+ distanceGradient = fwidth( distanceToPlane ) / 2.0;
267
+ unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
268
+ }
269
+ #pragma unroll_loop_end
270
+ clipOpacity *= 1.0 - unionClipOpacity;
271
+ #endif
272
+ diffuseColor.a *= clipOpacity;
273
+ if ( diffuseColor.a == 0.0 ) discard;
274
+ #else
275
+ #pragma unroll_loop_start
276
+ for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
277
+ plane = clippingPlanes[ i ];
278
+ if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
279
+ }
280
+ #pragma unroll_loop_end
281
+ #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
282
+ bool clipped = true;
283
+ #pragma unroll_loop_start
284
+ for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
285
+ plane = clippingPlanes[ i ];
286
+ clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
287
+ }
288
+ #pragma unroll_loop_end
289
+ if ( clipped ) discard;
290
+ #endif
291
+ #endif
292
+ #endif`,Qh=`#if NUM_CLIPPING_PLANES > 0
293
+ varying vec3 vClipPosition;
294
+ uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
295
+ #endif`,tu=`#if NUM_CLIPPING_PLANES > 0
296
+ varying vec3 vClipPosition;
297
+ #endif`,eu=`#if NUM_CLIPPING_PLANES > 0
298
+ vClipPosition = - mvPosition.xyz;
299
+ #endif`,nu=`#if defined( USE_COLOR_ALPHA )
300
+ diffuseColor *= vColor;
301
+ #elif defined( USE_COLOR )
302
+ diffuseColor.rgb *= vColor;
303
+ #endif`,iu=`#if defined( USE_COLOR_ALPHA )
304
+ varying vec4 vColor;
305
+ #elif defined( USE_COLOR )
306
+ varying vec3 vColor;
307
+ #endif`,ru=`#if defined( USE_COLOR_ALPHA )
308
+ varying vec4 vColor;
309
+ #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
310
+ varying vec3 vColor;
311
+ #endif`,su=`#if defined( USE_COLOR_ALPHA )
312
+ vColor = vec4( 1.0 );
313
+ #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
314
+ vColor = vec3( 1.0 );
315
+ #endif
316
+ #ifdef USE_COLOR
317
+ vColor *= color;
318
+ #endif
319
+ #ifdef USE_INSTANCING_COLOR
320
+ vColor.xyz *= instanceColor.xyz;
321
+ #endif
322
+ #ifdef USE_BATCHING_COLOR
323
+ vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
324
+ vColor.xyz *= batchingColor.xyz;
325
+ #endif`,au=`#define PI 3.141592653589793
326
+ #define PI2 6.283185307179586
327
+ #define PI_HALF 1.5707963267948966
328
+ #define RECIPROCAL_PI 0.3183098861837907
329
+ #define RECIPROCAL_PI2 0.15915494309189535
330
+ #define EPSILON 1e-6
331
+ #ifndef saturate
332
+ #define saturate( a ) clamp( a, 0.0, 1.0 )
333
+ #endif
334
+ #define whiteComplement( a ) ( 1.0 - saturate( a ) )
335
+ float pow2( const in float x ) { return x*x; }
336
+ vec3 pow2( const in vec3 x ) { return x*x; }
337
+ float pow3( const in float x ) { return x*x*x; }
338
+ float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
339
+ float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
340
+ float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
341
+ highp float rand( const in vec2 uv ) {
342
+ const highp float a = 12.9898, b = 78.233, c = 43758.5453;
343
+ highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
344
+ return fract( sin( sn ) * c );
345
+ }
346
+ #ifdef HIGH_PRECISION
347
+ float precisionSafeLength( vec3 v ) { return length( v ); }
348
+ #else
349
+ float precisionSafeLength( vec3 v ) {
350
+ float maxComponent = max3( abs( v ) );
351
+ return length( v / maxComponent ) * maxComponent;
352
+ }
353
+ #endif
354
+ struct IncidentLight {
355
+ vec3 color;
356
+ vec3 direction;
357
+ bool visible;
358
+ };
359
+ struct ReflectedLight {
360
+ vec3 directDiffuse;
361
+ vec3 directSpecular;
362
+ vec3 indirectDiffuse;
363
+ vec3 indirectSpecular;
364
+ };
365
+ #ifdef USE_ALPHAHASH
366
+ varying vec3 vPosition;
367
+ #endif
368
+ vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
369
+ return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
370
+ }
371
+ vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
372
+ return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
373
+ }
374
+ mat3 transposeMat3( const in mat3 m ) {
375
+ mat3 tmp;
376
+ tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
377
+ tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
378
+ tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
379
+ return tmp;
380
+ }
381
+ bool isPerspectiveMatrix( mat4 m ) {
382
+ return m[ 2 ][ 3 ] == - 1.0;
383
+ }
384
+ vec2 equirectUv( in vec3 dir ) {
385
+ float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
386
+ float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
387
+ return vec2( u, v );
388
+ }
389
+ vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
390
+ return RECIPROCAL_PI * diffuseColor;
391
+ }
392
+ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
393
+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
394
+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
395
+ }
396
+ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
397
+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
398
+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
399
+ } // validated`,ou=`#ifdef ENVMAP_TYPE_CUBE_UV
400
+ #define cubeUV_minMipLevel 4.0
401
+ #define cubeUV_minTileSize 16.0
402
+ float getFace( vec3 direction ) {
403
+ vec3 absDirection = abs( direction );
404
+ float face = - 1.0;
405
+ if ( absDirection.x > absDirection.z ) {
406
+ if ( absDirection.x > absDirection.y )
407
+ face = direction.x > 0.0 ? 0.0 : 3.0;
408
+ else
409
+ face = direction.y > 0.0 ? 1.0 : 4.0;
410
+ } else {
411
+ if ( absDirection.z > absDirection.y )
412
+ face = direction.z > 0.0 ? 2.0 : 5.0;
413
+ else
414
+ face = direction.y > 0.0 ? 1.0 : 4.0;
415
+ }
416
+ return face;
417
+ }
418
+ vec2 getUV( vec3 direction, float face ) {
419
+ vec2 uv;
420
+ if ( face == 0.0 ) {
421
+ uv = vec2( direction.z, direction.y ) / abs( direction.x );
422
+ } else if ( face == 1.0 ) {
423
+ uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
424
+ } else if ( face == 2.0 ) {
425
+ uv = vec2( - direction.x, direction.y ) / abs( direction.z );
426
+ } else if ( face == 3.0 ) {
427
+ uv = vec2( - direction.z, direction.y ) / abs( direction.x );
428
+ } else if ( face == 4.0 ) {
429
+ uv = vec2( - direction.x, direction.z ) / abs( direction.y );
430
+ } else {
431
+ uv = vec2( direction.x, direction.y ) / abs( direction.z );
432
+ }
433
+ return 0.5 * ( uv + 1.0 );
434
+ }
435
+ vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
436
+ float face = getFace( direction );
437
+ float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
438
+ mipInt = max( mipInt, cubeUV_minMipLevel );
439
+ float faceSize = exp2( mipInt );
440
+ highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
441
+ if ( face > 2.0 ) {
442
+ uv.y += faceSize;
443
+ face -= 3.0;
444
+ }
445
+ uv.x += face * faceSize;
446
+ uv.x += filterInt * 3.0 * cubeUV_minTileSize;
447
+ uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
448
+ uv.x *= CUBEUV_TEXEL_WIDTH;
449
+ uv.y *= CUBEUV_TEXEL_HEIGHT;
450
+ #ifdef texture2DGradEXT
451
+ return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
452
+ #else
453
+ return texture2D( envMap, uv ).rgb;
454
+ #endif
455
+ }
456
+ #define cubeUV_r0 1.0
457
+ #define cubeUV_m0 - 2.0
458
+ #define cubeUV_r1 0.8
459
+ #define cubeUV_m1 - 1.0
460
+ #define cubeUV_r4 0.4
461
+ #define cubeUV_m4 2.0
462
+ #define cubeUV_r5 0.305
463
+ #define cubeUV_m5 3.0
464
+ #define cubeUV_r6 0.21
465
+ #define cubeUV_m6 4.0
466
+ float roughnessToMip( float roughness ) {
467
+ float mip = 0.0;
468
+ if ( roughness >= cubeUV_r1 ) {
469
+ mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
470
+ } else if ( roughness >= cubeUV_r4 ) {
471
+ mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
472
+ } else if ( roughness >= cubeUV_r5 ) {
473
+ mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
474
+ } else if ( roughness >= cubeUV_r6 ) {
475
+ mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
476
+ } else {
477
+ mip = - 2.0 * log2( 1.16 * roughness ); }
478
+ return mip;
479
+ }
480
+ vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
481
+ float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
482
+ float mipF = fract( mip );
483
+ float mipInt = floor( mip );
484
+ vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
485
+ if ( mipF == 0.0 ) {
486
+ return vec4( color0, 1.0 );
487
+ } else {
488
+ vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
489
+ return vec4( mix( color0, color1, mipF ), 1.0 );
490
+ }
491
+ }
492
+ #endif`,lu=`vec3 transformedNormal = objectNormal;
493
+ #ifdef USE_TANGENT
494
+ vec3 transformedTangent = objectTangent;
495
+ #endif
496
+ #ifdef USE_BATCHING
497
+ mat3 bm = mat3( batchingMatrix );
498
+ transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
499
+ transformedNormal = bm * transformedNormal;
500
+ #ifdef USE_TANGENT
501
+ transformedTangent = bm * transformedTangent;
502
+ #endif
503
+ #endif
504
+ #ifdef USE_INSTANCING
505
+ mat3 im = mat3( instanceMatrix );
506
+ transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
507
+ transformedNormal = im * transformedNormal;
508
+ #ifdef USE_TANGENT
509
+ transformedTangent = im * transformedTangent;
510
+ #endif
511
+ #endif
512
+ transformedNormal = normalMatrix * transformedNormal;
513
+ #ifdef FLIP_SIDED
514
+ transformedNormal = - transformedNormal;
515
+ #endif
516
+ #ifdef USE_TANGENT
517
+ transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
518
+ #ifdef FLIP_SIDED
519
+ transformedTangent = - transformedTangent;
520
+ #endif
521
+ #endif`,cu=`#ifdef USE_DISPLACEMENTMAP
522
+ uniform sampler2D displacementMap;
523
+ uniform float displacementScale;
524
+ uniform float displacementBias;
525
+ #endif`,hu=`#ifdef USE_DISPLACEMENTMAP
526
+ transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
527
+ #endif`,uu=`#ifdef USE_EMISSIVEMAP
528
+ vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
529
+ #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
530
+ emissiveColor = sRGBTransferEOTF( emissiveColor );
531
+ #endif
532
+ totalEmissiveRadiance *= emissiveColor.rgb;
533
+ #endif`,du=`#ifdef USE_EMISSIVEMAP
534
+ uniform sampler2D emissiveMap;
535
+ #endif`,fu="gl_FragColor = linearToOutputTexel( gl_FragColor );",pu=`vec4 LinearTransferOETF( in vec4 value ) {
536
+ return value;
537
+ }
538
+ vec4 sRGBTransferEOTF( in vec4 value ) {
539
+ return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
540
+ }
541
+ vec4 sRGBTransferOETF( in vec4 value ) {
542
+ return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
543
+ }`,mu=`#ifdef USE_ENVMAP
544
+ #ifdef ENV_WORLDPOS
545
+ vec3 cameraToFrag;
546
+ if ( isOrthographic ) {
547
+ cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
548
+ } else {
549
+ cameraToFrag = normalize( vWorldPosition - cameraPosition );
550
+ }
551
+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
552
+ #ifdef ENVMAP_MODE_REFLECTION
553
+ vec3 reflectVec = reflect( cameraToFrag, worldNormal );
554
+ #else
555
+ vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
556
+ #endif
557
+ #else
558
+ vec3 reflectVec = vReflect;
559
+ #endif
560
+ #ifdef ENVMAP_TYPE_CUBE
561
+ vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
562
+ #else
563
+ vec4 envColor = vec4( 0.0 );
564
+ #endif
565
+ #ifdef ENVMAP_BLENDING_MULTIPLY
566
+ outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
567
+ #elif defined( ENVMAP_BLENDING_MIX )
568
+ outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
569
+ #elif defined( ENVMAP_BLENDING_ADD )
570
+ outgoingLight += envColor.xyz * specularStrength * reflectivity;
571
+ #endif
572
+ #endif`,gu=`#ifdef USE_ENVMAP
573
+ uniform float envMapIntensity;
574
+ uniform float flipEnvMap;
575
+ uniform mat3 envMapRotation;
576
+ #ifdef ENVMAP_TYPE_CUBE
577
+ uniform samplerCube envMap;
578
+ #else
579
+ uniform sampler2D envMap;
580
+ #endif
581
+
582
+ #endif`,_u=`#ifdef USE_ENVMAP
583
+ uniform float reflectivity;
584
+ #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
585
+ #define ENV_WORLDPOS
586
+ #endif
587
+ #ifdef ENV_WORLDPOS
588
+ varying vec3 vWorldPosition;
589
+ uniform float refractionRatio;
590
+ #else
591
+ varying vec3 vReflect;
592
+ #endif
593
+ #endif`,vu=`#ifdef USE_ENVMAP
594
+ #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
595
+ #define ENV_WORLDPOS
596
+ #endif
597
+ #ifdef ENV_WORLDPOS
598
+
599
+ varying vec3 vWorldPosition;
600
+ #else
601
+ varying vec3 vReflect;
602
+ uniform float refractionRatio;
603
+ #endif
604
+ #endif`,xu=`#ifdef USE_ENVMAP
605
+ #ifdef ENV_WORLDPOS
606
+ vWorldPosition = worldPosition.xyz;
607
+ #else
608
+ vec3 cameraToVertex;
609
+ if ( isOrthographic ) {
610
+ cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
611
+ } else {
612
+ cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
613
+ }
614
+ vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
615
+ #ifdef ENVMAP_MODE_REFLECTION
616
+ vReflect = reflect( cameraToVertex, worldNormal );
617
+ #else
618
+ vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
619
+ #endif
620
+ #endif
621
+ #endif`,Mu=`#ifdef USE_FOG
622
+ vFogDepth = - mvPosition.z;
623
+ #endif`,Su=`#ifdef USE_FOG
624
+ varying float vFogDepth;
625
+ #endif`,yu=`#ifdef USE_FOG
626
+ #ifdef FOG_EXP2
627
+ float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
628
+ #else
629
+ float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
630
+ #endif
631
+ gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
632
+ #endif`,Eu=`#ifdef USE_FOG
633
+ uniform vec3 fogColor;
634
+ varying float vFogDepth;
635
+ #ifdef FOG_EXP2
636
+ uniform float fogDensity;
637
+ #else
638
+ uniform float fogNear;
639
+ uniform float fogFar;
640
+ #endif
641
+ #endif`,Tu=`#ifdef USE_GRADIENTMAP
642
+ uniform sampler2D gradientMap;
643
+ #endif
644
+ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
645
+ float dotNL = dot( normal, lightDirection );
646
+ vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
647
+ #ifdef USE_GRADIENTMAP
648
+ return vec3( texture2D( gradientMap, coord ).r );
649
+ #else
650
+ vec2 fw = fwidth( coord ) * 0.5;
651
+ return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
652
+ #endif
653
+ }`,bu=`#ifdef USE_LIGHTMAP
654
+ uniform sampler2D lightMap;
655
+ uniform float lightMapIntensity;
656
+ #endif`,Au=`LambertMaterial material;
657
+ material.diffuseColor = diffuseColor.rgb;
658
+ material.specularStrength = specularStrength;`,wu=`varying vec3 vViewPosition;
659
+ struct LambertMaterial {
660
+ vec3 diffuseColor;
661
+ float specularStrength;
662
+ };
663
+ void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
664
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
665
+ vec3 irradiance = dotNL * directLight.color;
666
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
667
+ }
668
+ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
669
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
670
+ }
671
+ #define RE_Direct RE_Direct_Lambert
672
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Ru=`uniform bool receiveShadow;
673
+ uniform vec3 ambientLightColor;
674
+ #if defined( USE_LIGHT_PROBES )
675
+ uniform vec3 lightProbe[ 9 ];
676
+ #endif
677
+ vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
678
+ float x = normal.x, y = normal.y, z = normal.z;
679
+ vec3 result = shCoefficients[ 0 ] * 0.886227;
680
+ result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
681
+ result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
682
+ result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
683
+ result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
684
+ result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
685
+ result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
686
+ result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
687
+ result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
688
+ return result;
689
+ }
690
+ vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
691
+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
692
+ vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
693
+ return irradiance;
694
+ }
695
+ vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
696
+ vec3 irradiance = ambientLightColor;
697
+ return irradiance;
698
+ }
699
+ float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
700
+ float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
701
+ if ( cutoffDistance > 0.0 ) {
702
+ distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
703
+ }
704
+ return distanceFalloff;
705
+ }
706
+ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
707
+ return smoothstep( coneCosine, penumbraCosine, angleCosine );
708
+ }
709
+ #if NUM_DIR_LIGHTS > 0
710
+ struct DirectionalLight {
711
+ vec3 direction;
712
+ vec3 color;
713
+ };
714
+ uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
715
+ void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
716
+ light.color = directionalLight.color;
717
+ light.direction = directionalLight.direction;
718
+ light.visible = true;
719
+ }
720
+ #endif
721
+ #if NUM_POINT_LIGHTS > 0
722
+ struct PointLight {
723
+ vec3 position;
724
+ vec3 color;
725
+ float distance;
726
+ float decay;
727
+ };
728
+ uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
729
+ void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
730
+ vec3 lVector = pointLight.position - geometryPosition;
731
+ light.direction = normalize( lVector );
732
+ float lightDistance = length( lVector );
733
+ light.color = pointLight.color;
734
+ light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
735
+ light.visible = ( light.color != vec3( 0.0 ) );
736
+ }
737
+ #endif
738
+ #if NUM_SPOT_LIGHTS > 0
739
+ struct SpotLight {
740
+ vec3 position;
741
+ vec3 direction;
742
+ vec3 color;
743
+ float distance;
744
+ float decay;
745
+ float coneCos;
746
+ float penumbraCos;
747
+ };
748
+ uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
749
+ void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
750
+ vec3 lVector = spotLight.position - geometryPosition;
751
+ light.direction = normalize( lVector );
752
+ float angleCos = dot( light.direction, spotLight.direction );
753
+ float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
754
+ if ( spotAttenuation > 0.0 ) {
755
+ float lightDistance = length( lVector );
756
+ light.color = spotLight.color * spotAttenuation;
757
+ light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
758
+ light.visible = ( light.color != vec3( 0.0 ) );
759
+ } else {
760
+ light.color = vec3( 0.0 );
761
+ light.visible = false;
762
+ }
763
+ }
764
+ #endif
765
+ #if NUM_RECT_AREA_LIGHTS > 0
766
+ struct RectAreaLight {
767
+ vec3 color;
768
+ vec3 position;
769
+ vec3 halfWidth;
770
+ vec3 halfHeight;
771
+ };
772
+ uniform sampler2D ltc_1; uniform sampler2D ltc_2;
773
+ uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
774
+ #endif
775
+ #if NUM_HEMI_LIGHTS > 0
776
+ struct HemisphereLight {
777
+ vec3 direction;
778
+ vec3 skyColor;
779
+ vec3 groundColor;
780
+ };
781
+ uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
782
+ vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
783
+ float dotNL = dot( normal, hemiLight.direction );
784
+ float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
785
+ vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
786
+ return irradiance;
787
+ }
788
+ #endif`,Cu=`#ifdef USE_ENVMAP
789
+ vec3 getIBLIrradiance( const in vec3 normal ) {
790
+ #ifdef ENVMAP_TYPE_CUBE_UV
791
+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
792
+ vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
793
+ return PI * envMapColor.rgb * envMapIntensity;
794
+ #else
795
+ return vec3( 0.0 );
796
+ #endif
797
+ }
798
+ vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
799
+ #ifdef ENVMAP_TYPE_CUBE_UV
800
+ vec3 reflectVec = reflect( - viewDir, normal );
801
+ reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
802
+ reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
803
+ vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
804
+ return envMapColor.rgb * envMapIntensity;
805
+ #else
806
+ return vec3( 0.0 );
807
+ #endif
808
+ }
809
+ #ifdef USE_ANISOTROPY
810
+ vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
811
+ #ifdef ENVMAP_TYPE_CUBE_UV
812
+ vec3 bentNormal = cross( bitangent, viewDir );
813
+ bentNormal = normalize( cross( bentNormal, bitangent ) );
814
+ bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
815
+ return getIBLRadiance( viewDir, bentNormal, roughness );
816
+ #else
817
+ return vec3( 0.0 );
818
+ #endif
819
+ }
820
+ #endif
821
+ #endif`,Pu=`ToonMaterial material;
822
+ material.diffuseColor = diffuseColor.rgb;`,Lu=`varying vec3 vViewPosition;
823
+ struct ToonMaterial {
824
+ vec3 diffuseColor;
825
+ };
826
+ void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
827
+ vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
828
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
829
+ }
830
+ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
831
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
832
+ }
833
+ #define RE_Direct RE_Direct_Toon
834
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Du=`BlinnPhongMaterial material;
835
+ material.diffuseColor = diffuseColor.rgb;
836
+ material.specularColor = specular;
837
+ material.specularShininess = shininess;
838
+ material.specularStrength = specularStrength;`,Iu=`varying vec3 vViewPosition;
839
+ struct BlinnPhongMaterial {
840
+ vec3 diffuseColor;
841
+ vec3 specularColor;
842
+ float specularShininess;
843
+ float specularStrength;
844
+ };
845
+ void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
846
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
847
+ vec3 irradiance = dotNL * directLight.color;
848
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
849
+ reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
850
+ }
851
+ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
852
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
853
+ }
854
+ #define RE_Direct RE_Direct_BlinnPhong
855
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Uu=`PhysicalMaterial material;
856
+ material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
857
+ vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
858
+ float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
859
+ material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
860
+ material.roughness = min( material.roughness, 1.0 );
861
+ #ifdef IOR
862
+ material.ior = ior;
863
+ #ifdef USE_SPECULAR
864
+ float specularIntensityFactor = specularIntensity;
865
+ vec3 specularColorFactor = specularColor;
866
+ #ifdef USE_SPECULAR_COLORMAP
867
+ specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
868
+ #endif
869
+ #ifdef USE_SPECULAR_INTENSITYMAP
870
+ specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
871
+ #endif
872
+ material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
873
+ #else
874
+ float specularIntensityFactor = 1.0;
875
+ vec3 specularColorFactor = vec3( 1.0 );
876
+ material.specularF90 = 1.0;
877
+ #endif
878
+ material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
879
+ #else
880
+ material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
881
+ material.specularF90 = 1.0;
882
+ #endif
883
+ #ifdef USE_CLEARCOAT
884
+ material.clearcoat = clearcoat;
885
+ material.clearcoatRoughness = clearcoatRoughness;
886
+ material.clearcoatF0 = vec3( 0.04 );
887
+ material.clearcoatF90 = 1.0;
888
+ #ifdef USE_CLEARCOATMAP
889
+ material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
890
+ #endif
891
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
892
+ material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
893
+ #endif
894
+ material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
895
+ material.clearcoatRoughness += geometryRoughness;
896
+ material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
897
+ #endif
898
+ #ifdef USE_DISPERSION
899
+ material.dispersion = dispersion;
900
+ #endif
901
+ #ifdef USE_IRIDESCENCE
902
+ material.iridescence = iridescence;
903
+ material.iridescenceIOR = iridescenceIOR;
904
+ #ifdef USE_IRIDESCENCEMAP
905
+ material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
906
+ #endif
907
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
908
+ material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
909
+ #else
910
+ material.iridescenceThickness = iridescenceThicknessMaximum;
911
+ #endif
912
+ #endif
913
+ #ifdef USE_SHEEN
914
+ material.sheenColor = sheenColor;
915
+ #ifdef USE_SHEEN_COLORMAP
916
+ material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
917
+ #endif
918
+ material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
919
+ #ifdef USE_SHEEN_ROUGHNESSMAP
920
+ material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
921
+ #endif
922
+ #endif
923
+ #ifdef USE_ANISOTROPY
924
+ #ifdef USE_ANISOTROPYMAP
925
+ mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
926
+ vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
927
+ vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
928
+ #else
929
+ vec2 anisotropyV = anisotropyVector;
930
+ #endif
931
+ material.anisotropy = length( anisotropyV );
932
+ if( material.anisotropy == 0.0 ) {
933
+ anisotropyV = vec2( 1.0, 0.0 );
934
+ } else {
935
+ anisotropyV /= material.anisotropy;
936
+ material.anisotropy = saturate( material.anisotropy );
937
+ }
938
+ material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
939
+ material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
940
+ material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
941
+ #endif`,Nu=`struct PhysicalMaterial {
942
+ vec3 diffuseColor;
943
+ float roughness;
944
+ vec3 specularColor;
945
+ float specularF90;
946
+ float dispersion;
947
+ #ifdef USE_CLEARCOAT
948
+ float clearcoat;
949
+ float clearcoatRoughness;
950
+ vec3 clearcoatF0;
951
+ float clearcoatF90;
952
+ #endif
953
+ #ifdef USE_IRIDESCENCE
954
+ float iridescence;
955
+ float iridescenceIOR;
956
+ float iridescenceThickness;
957
+ vec3 iridescenceFresnel;
958
+ vec3 iridescenceF0;
959
+ #endif
960
+ #ifdef USE_SHEEN
961
+ vec3 sheenColor;
962
+ float sheenRoughness;
963
+ #endif
964
+ #ifdef IOR
965
+ float ior;
966
+ #endif
967
+ #ifdef USE_TRANSMISSION
968
+ float transmission;
969
+ float transmissionAlpha;
970
+ float thickness;
971
+ float attenuationDistance;
972
+ vec3 attenuationColor;
973
+ #endif
974
+ #ifdef USE_ANISOTROPY
975
+ float anisotropy;
976
+ float alphaT;
977
+ vec3 anisotropyT;
978
+ vec3 anisotropyB;
979
+ #endif
980
+ };
981
+ vec3 clearcoatSpecularDirect = vec3( 0.0 );
982
+ vec3 clearcoatSpecularIndirect = vec3( 0.0 );
983
+ vec3 sheenSpecularDirect = vec3( 0.0 );
984
+ vec3 sheenSpecularIndirect = vec3(0.0 );
985
+ vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
986
+ float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
987
+ float x2 = x * x;
988
+ float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
989
+ return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
990
+ }
991
+ float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
992
+ float a2 = pow2( alpha );
993
+ float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
994
+ float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
995
+ return 0.5 / max( gv + gl, EPSILON );
996
+ }
997
+ float D_GGX( const in float alpha, const in float dotNH ) {
998
+ float a2 = pow2( alpha );
999
+ float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
1000
+ return RECIPROCAL_PI * a2 / pow2( denom );
1001
+ }
1002
+ #ifdef USE_ANISOTROPY
1003
+ float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
1004
+ float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
1005
+ float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
1006
+ float v = 0.5 / ( gv + gl );
1007
+ return saturate(v);
1008
+ }
1009
+ float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
1010
+ float a2 = alphaT * alphaB;
1011
+ highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
1012
+ highp float v2 = dot( v, v );
1013
+ float w2 = a2 / v2;
1014
+ return RECIPROCAL_PI * a2 * pow2 ( w2 );
1015
+ }
1016
+ #endif
1017
+ #ifdef USE_CLEARCOAT
1018
+ vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
1019
+ vec3 f0 = material.clearcoatF0;
1020
+ float f90 = material.clearcoatF90;
1021
+ float roughness = material.clearcoatRoughness;
1022
+ float alpha = pow2( roughness );
1023
+ vec3 halfDir = normalize( lightDir + viewDir );
1024
+ float dotNL = saturate( dot( normal, lightDir ) );
1025
+ float dotNV = saturate( dot( normal, viewDir ) );
1026
+ float dotNH = saturate( dot( normal, halfDir ) );
1027
+ float dotVH = saturate( dot( viewDir, halfDir ) );
1028
+ vec3 F = F_Schlick( f0, f90, dotVH );
1029
+ float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
1030
+ float D = D_GGX( alpha, dotNH );
1031
+ return F * ( V * D );
1032
+ }
1033
+ #endif
1034
+ vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
1035
+ vec3 f0 = material.specularColor;
1036
+ float f90 = material.specularF90;
1037
+ float roughness = material.roughness;
1038
+ float alpha = pow2( roughness );
1039
+ vec3 halfDir = normalize( lightDir + viewDir );
1040
+ float dotNL = saturate( dot( normal, lightDir ) );
1041
+ float dotNV = saturate( dot( normal, viewDir ) );
1042
+ float dotNH = saturate( dot( normal, halfDir ) );
1043
+ float dotVH = saturate( dot( viewDir, halfDir ) );
1044
+ vec3 F = F_Schlick( f0, f90, dotVH );
1045
+ #ifdef USE_IRIDESCENCE
1046
+ F = mix( F, material.iridescenceFresnel, material.iridescence );
1047
+ #endif
1048
+ #ifdef USE_ANISOTROPY
1049
+ float dotTL = dot( material.anisotropyT, lightDir );
1050
+ float dotTV = dot( material.anisotropyT, viewDir );
1051
+ float dotTH = dot( material.anisotropyT, halfDir );
1052
+ float dotBL = dot( material.anisotropyB, lightDir );
1053
+ float dotBV = dot( material.anisotropyB, viewDir );
1054
+ float dotBH = dot( material.anisotropyB, halfDir );
1055
+ float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
1056
+ float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
1057
+ #else
1058
+ float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
1059
+ float D = D_GGX( alpha, dotNH );
1060
+ #endif
1061
+ return F * ( V * D );
1062
+ }
1063
+ vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
1064
+ const float LUT_SIZE = 64.0;
1065
+ const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
1066
+ const float LUT_BIAS = 0.5 / LUT_SIZE;
1067
+ float dotNV = saturate( dot( N, V ) );
1068
+ vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
1069
+ uv = uv * LUT_SCALE + LUT_BIAS;
1070
+ return uv;
1071
+ }
1072
+ float LTC_ClippedSphereFormFactor( const in vec3 f ) {
1073
+ float l = length( f );
1074
+ return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
1075
+ }
1076
+ vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
1077
+ float x = dot( v1, v2 );
1078
+ float y = abs( x );
1079
+ float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
1080
+ float b = 3.4175940 + ( 4.1616724 + y ) * y;
1081
+ float v = a / b;
1082
+ float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
1083
+ return cross( v1, v2 ) * theta_sintheta;
1084
+ }
1085
+ vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
1086
+ vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
1087
+ vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
1088
+ vec3 lightNormal = cross( v1, v2 );
1089
+ if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
1090
+ vec3 T1, T2;
1091
+ T1 = normalize( V - N * dot( V, N ) );
1092
+ T2 = - cross( N, T1 );
1093
+ mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
1094
+ vec3 coords[ 4 ];
1095
+ coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
1096
+ coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
1097
+ coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
1098
+ coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
1099
+ coords[ 0 ] = normalize( coords[ 0 ] );
1100
+ coords[ 1 ] = normalize( coords[ 1 ] );
1101
+ coords[ 2 ] = normalize( coords[ 2 ] );
1102
+ coords[ 3 ] = normalize( coords[ 3 ] );
1103
+ vec3 vectorFormFactor = vec3( 0.0 );
1104
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
1105
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
1106
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
1107
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
1108
+ float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
1109
+ return vec3( result );
1110
+ }
1111
+ #if defined( USE_SHEEN )
1112
+ float D_Charlie( float roughness, float dotNH ) {
1113
+ float alpha = pow2( roughness );
1114
+ float invAlpha = 1.0 / alpha;
1115
+ float cos2h = dotNH * dotNH;
1116
+ float sin2h = max( 1.0 - cos2h, 0.0078125 );
1117
+ return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
1118
+ }
1119
+ float V_Neubelt( float dotNV, float dotNL ) {
1120
+ return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
1121
+ }
1122
+ vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
1123
+ vec3 halfDir = normalize( lightDir + viewDir );
1124
+ float dotNL = saturate( dot( normal, lightDir ) );
1125
+ float dotNV = saturate( dot( normal, viewDir ) );
1126
+ float dotNH = saturate( dot( normal, halfDir ) );
1127
+ float D = D_Charlie( sheenRoughness, dotNH );
1128
+ float V = V_Neubelt( dotNV, dotNL );
1129
+ return sheenColor * ( D * V );
1130
+ }
1131
+ #endif
1132
+ float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
1133
+ float dotNV = saturate( dot( normal, viewDir ) );
1134
+ float r2 = roughness * roughness;
1135
+ float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
1136
+ float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
1137
+ float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
1138
+ return saturate( DG * RECIPROCAL_PI );
1139
+ }
1140
+ vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
1141
+ float dotNV = saturate( dot( normal, viewDir ) );
1142
+ const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
1143
+ const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
1144
+ vec4 r = roughness * c0 + c1;
1145
+ float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
1146
+ vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
1147
+ return fab;
1148
+ }
1149
+ vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
1150
+ vec2 fab = DFGApprox( normal, viewDir, roughness );
1151
+ return specularColor * fab.x + specularF90 * fab.y;
1152
+ }
1153
+ #ifdef USE_IRIDESCENCE
1154
+ void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
1155
+ #else
1156
+ void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
1157
+ #endif
1158
+ vec2 fab = DFGApprox( normal, viewDir, roughness );
1159
+ #ifdef USE_IRIDESCENCE
1160
+ vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
1161
+ #else
1162
+ vec3 Fr = specularColor;
1163
+ #endif
1164
+ vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
1165
+ float Ess = fab.x + fab.y;
1166
+ float Ems = 1.0 - Ess;
1167
+ vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
1168
+ singleScatter += FssEss;
1169
+ multiScatter += Fms * Ems;
1170
+ }
1171
+ #if NUM_RECT_AREA_LIGHTS > 0
1172
+ void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
1173
+ vec3 normal = geometryNormal;
1174
+ vec3 viewDir = geometryViewDir;
1175
+ vec3 position = geometryPosition;
1176
+ vec3 lightPos = rectAreaLight.position;
1177
+ vec3 halfWidth = rectAreaLight.halfWidth;
1178
+ vec3 halfHeight = rectAreaLight.halfHeight;
1179
+ vec3 lightColor = rectAreaLight.color;
1180
+ float roughness = material.roughness;
1181
+ vec3 rectCoords[ 4 ];
1182
+ rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
1183
+ rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
1184
+ rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
1185
+ vec2 uv = LTC_Uv( normal, viewDir, roughness );
1186
+ vec4 t1 = texture2D( ltc_1, uv );
1187
+ vec4 t2 = texture2D( ltc_2, uv );
1188
+ mat3 mInv = mat3(
1189
+ vec3( t1.x, 0, t1.y ),
1190
+ vec3( 0, 1, 0 ),
1191
+ vec3( t1.z, 0, t1.w )
1192
+ );
1193
+ vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
1194
+ reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
1195
+ reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
1196
+ }
1197
+ #endif
1198
+ void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
1199
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
1200
+ vec3 irradiance = dotNL * directLight.color;
1201
+ #ifdef USE_CLEARCOAT
1202
+ float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
1203
+ vec3 ccIrradiance = dotNLcc * directLight.color;
1204
+ clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
1205
+ #endif
1206
+ #ifdef USE_SHEEN
1207
+ sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
1208
+ #endif
1209
+ reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
1210
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1211
+ }
1212
+ void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
1213
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1214
+ }
1215
+ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
1216
+ #ifdef USE_CLEARCOAT
1217
+ clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
1218
+ #endif
1219
+ #ifdef USE_SHEEN
1220
+ sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
1221
+ #endif
1222
+ vec3 singleScattering = vec3( 0.0 );
1223
+ vec3 multiScattering = vec3( 0.0 );
1224
+ vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
1225
+ #ifdef USE_IRIDESCENCE
1226
+ computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
1227
+ #else
1228
+ computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
1229
+ #endif
1230
+ vec3 totalScattering = singleScattering + multiScattering;
1231
+ vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
1232
+ reflectedLight.indirectSpecular += radiance * singleScattering;
1233
+ reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
1234
+ reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
1235
+ }
1236
+ #define RE_Direct RE_Direct_Physical
1237
+ #define RE_Direct_RectArea RE_Direct_RectArea_Physical
1238
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
1239
+ #define RE_IndirectSpecular RE_IndirectSpecular_Physical
1240
+ float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
1241
+ return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
1242
+ }`,Fu=`
1243
+ vec3 geometryPosition = - vViewPosition;
1244
+ vec3 geometryNormal = normal;
1245
+ vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
1246
+ vec3 geometryClearcoatNormal = vec3( 0.0 );
1247
+ #ifdef USE_CLEARCOAT
1248
+ geometryClearcoatNormal = clearcoatNormal;
1249
+ #endif
1250
+ #ifdef USE_IRIDESCENCE
1251
+ float dotNVi = saturate( dot( normal, geometryViewDir ) );
1252
+ if ( material.iridescenceThickness == 0.0 ) {
1253
+ material.iridescence = 0.0;
1254
+ } else {
1255
+ material.iridescence = saturate( material.iridescence );
1256
+ }
1257
+ if ( material.iridescence > 0.0 ) {
1258
+ material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
1259
+ material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
1260
+ }
1261
+ #endif
1262
+ IncidentLight directLight;
1263
+ #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
1264
+ PointLight pointLight;
1265
+ #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
1266
+ PointLightShadow pointLightShadow;
1267
+ #endif
1268
+ #pragma unroll_loop_start
1269
+ for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
1270
+ pointLight = pointLights[ i ];
1271
+ getPointLightInfo( pointLight, geometryPosition, directLight );
1272
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
1273
+ pointLightShadow = pointLightShadows[ i ];
1274
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
1275
+ #endif
1276
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1277
+ }
1278
+ #pragma unroll_loop_end
1279
+ #endif
1280
+ #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
1281
+ SpotLight spotLight;
1282
+ vec4 spotColor;
1283
+ vec3 spotLightCoord;
1284
+ bool inSpotLightMap;
1285
+ #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
1286
+ SpotLightShadow spotLightShadow;
1287
+ #endif
1288
+ #pragma unroll_loop_start
1289
+ for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
1290
+ spotLight = spotLights[ i ];
1291
+ getSpotLightInfo( spotLight, geometryPosition, directLight );
1292
+ #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
1293
+ #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
1294
+ #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1295
+ #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
1296
+ #else
1297
+ #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
1298
+ #endif
1299
+ #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
1300
+ spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
1301
+ inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
1302
+ spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
1303
+ directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
1304
+ #endif
1305
+ #undef SPOT_LIGHT_MAP_INDEX
1306
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1307
+ spotLightShadow = spotLightShadows[ i ];
1308
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
1309
+ #endif
1310
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1311
+ }
1312
+ #pragma unroll_loop_end
1313
+ #endif
1314
+ #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
1315
+ DirectionalLight directionalLight;
1316
+ #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
1317
+ DirectionalLightShadow directionalLightShadow;
1318
+ #endif
1319
+ #pragma unroll_loop_start
1320
+ for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
1321
+ directionalLight = directionalLights[ i ];
1322
+ getDirectionalLightInfo( directionalLight, directLight );
1323
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
1324
+ directionalLightShadow = directionalLightShadows[ i ];
1325
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
1326
+ #endif
1327
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1328
+ }
1329
+ #pragma unroll_loop_end
1330
+ #endif
1331
+ #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
1332
+ RectAreaLight rectAreaLight;
1333
+ #pragma unroll_loop_start
1334
+ for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
1335
+ rectAreaLight = rectAreaLights[ i ];
1336
+ RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1337
+ }
1338
+ #pragma unroll_loop_end
1339
+ #endif
1340
+ #if defined( RE_IndirectDiffuse )
1341
+ vec3 iblIrradiance = vec3( 0.0 );
1342
+ vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
1343
+ #if defined( USE_LIGHT_PROBES )
1344
+ irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
1345
+ #endif
1346
+ #if ( NUM_HEMI_LIGHTS > 0 )
1347
+ #pragma unroll_loop_start
1348
+ for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
1349
+ irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
1350
+ }
1351
+ #pragma unroll_loop_end
1352
+ #endif
1353
+ #endif
1354
+ #if defined( RE_IndirectSpecular )
1355
+ vec3 radiance = vec3( 0.0 );
1356
+ vec3 clearcoatRadiance = vec3( 0.0 );
1357
+ #endif`,Ou=`#if defined( RE_IndirectDiffuse )
1358
+ #ifdef USE_LIGHTMAP
1359
+ vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
1360
+ vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
1361
+ irradiance += lightMapIrradiance;
1362
+ #endif
1363
+ #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
1364
+ iblIrradiance += getIBLIrradiance( geometryNormal );
1365
+ #endif
1366
+ #endif
1367
+ #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
1368
+ #ifdef USE_ANISOTROPY
1369
+ radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
1370
+ #else
1371
+ radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
1372
+ #endif
1373
+ #ifdef USE_CLEARCOAT
1374
+ clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
1375
+ #endif
1376
+ #endif`,Bu=`#if defined( RE_IndirectDiffuse )
1377
+ RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1378
+ #endif
1379
+ #if defined( RE_IndirectSpecular )
1380
+ RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1381
+ #endif`,zu=`#if defined( USE_LOGDEPTHBUF )
1382
+ gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1383
+ #endif`,Vu=`#if defined( USE_LOGDEPTHBUF )
1384
+ uniform float logDepthBufFC;
1385
+ varying float vFragDepth;
1386
+ varying float vIsPerspective;
1387
+ #endif`,Hu=`#ifdef USE_LOGDEPTHBUF
1388
+ varying float vFragDepth;
1389
+ varying float vIsPerspective;
1390
+ #endif`,ku=`#ifdef USE_LOGDEPTHBUF
1391
+ vFragDepth = 1.0 + gl_Position.w;
1392
+ vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
1393
+ #endif`,Gu=`#ifdef USE_MAP
1394
+ vec4 sampledDiffuseColor = texture2D( map, vMapUv );
1395
+ #ifdef DECODE_VIDEO_TEXTURE
1396
+ sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
1397
+ #endif
1398
+ diffuseColor *= sampledDiffuseColor;
1399
+ #endif`,Wu=`#ifdef USE_MAP
1400
+ uniform sampler2D map;
1401
+ #endif`,Xu=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1402
+ #if defined( USE_POINTS_UV )
1403
+ vec2 uv = vUv;
1404
+ #else
1405
+ vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
1406
+ #endif
1407
+ #endif
1408
+ #ifdef USE_MAP
1409
+ diffuseColor *= texture2D( map, uv );
1410
+ #endif
1411
+ #ifdef USE_ALPHAMAP
1412
+ diffuseColor.a *= texture2D( alphaMap, uv ).g;
1413
+ #endif`,qu=`#if defined( USE_POINTS_UV )
1414
+ varying vec2 vUv;
1415
+ #else
1416
+ #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1417
+ uniform mat3 uvTransform;
1418
+ #endif
1419
+ #endif
1420
+ #ifdef USE_MAP
1421
+ uniform sampler2D map;
1422
+ #endif
1423
+ #ifdef USE_ALPHAMAP
1424
+ uniform sampler2D alphaMap;
1425
+ #endif`,Yu=`float metalnessFactor = metalness;
1426
+ #ifdef USE_METALNESSMAP
1427
+ vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
1428
+ metalnessFactor *= texelMetalness.b;
1429
+ #endif`,Ku=`#ifdef USE_METALNESSMAP
1430
+ uniform sampler2D metalnessMap;
1431
+ #endif`,Zu=`#ifdef USE_INSTANCING_MORPH
1432
+ float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1433
+ float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
1434
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1435
+ morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
1436
+ }
1437
+ #endif`,$u=`#if defined( USE_MORPHCOLORS )
1438
+ vColor *= morphTargetBaseInfluence;
1439
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1440
+ #if defined( USE_COLOR_ALPHA )
1441
+ if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
1442
+ #elif defined( USE_COLOR )
1443
+ if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
1444
+ #endif
1445
+ }
1446
+ #endif`,ju=`#ifdef USE_MORPHNORMALS
1447
+ objectNormal *= morphTargetBaseInfluence;
1448
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1449
+ if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
1450
+ }
1451
+ #endif`,Ju=`#ifdef USE_MORPHTARGETS
1452
+ #ifndef USE_INSTANCING_MORPH
1453
+ uniform float morphTargetBaseInfluence;
1454
+ uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1455
+ #endif
1456
+ uniform sampler2DArray morphTargetsTexture;
1457
+ uniform ivec2 morphTargetsTextureSize;
1458
+ vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
1459
+ int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
1460
+ int y = texelIndex / morphTargetsTextureSize.x;
1461
+ int x = texelIndex - y * morphTargetsTextureSize.x;
1462
+ ivec3 morphUV = ivec3( x, y, morphTargetIndex );
1463
+ return texelFetch( morphTargetsTexture, morphUV, 0 );
1464
+ }
1465
+ #endif`,Qu=`#ifdef USE_MORPHTARGETS
1466
+ transformed *= morphTargetBaseInfluence;
1467
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1468
+ if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
1469
+ }
1470
+ #endif`,td=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1471
+ #ifdef FLAT_SHADED
1472
+ vec3 fdx = dFdx( vViewPosition );
1473
+ vec3 fdy = dFdy( vViewPosition );
1474
+ vec3 normal = normalize( cross( fdx, fdy ) );
1475
+ #else
1476
+ vec3 normal = normalize( vNormal );
1477
+ #ifdef DOUBLE_SIDED
1478
+ normal *= faceDirection;
1479
+ #endif
1480
+ #endif
1481
+ #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
1482
+ #ifdef USE_TANGENT
1483
+ mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
1484
+ #else
1485
+ mat3 tbn = getTangentFrame( - vViewPosition, normal,
1486
+ #if defined( USE_NORMALMAP )
1487
+ vNormalMapUv
1488
+ #elif defined( USE_CLEARCOAT_NORMALMAP )
1489
+ vClearcoatNormalMapUv
1490
+ #else
1491
+ vUv
1492
+ #endif
1493
+ );
1494
+ #endif
1495
+ #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
1496
+ tbn[0] *= faceDirection;
1497
+ tbn[1] *= faceDirection;
1498
+ #endif
1499
+ #endif
1500
+ #ifdef USE_CLEARCOAT_NORMALMAP
1501
+ #ifdef USE_TANGENT
1502
+ mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
1503
+ #else
1504
+ mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
1505
+ #endif
1506
+ #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
1507
+ tbn2[0] *= faceDirection;
1508
+ tbn2[1] *= faceDirection;
1509
+ #endif
1510
+ #endif
1511
+ vec3 nonPerturbedNormal = normal;`,ed=`#ifdef USE_NORMALMAP_OBJECTSPACE
1512
+ normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1513
+ #ifdef FLIP_SIDED
1514
+ normal = - normal;
1515
+ #endif
1516
+ #ifdef DOUBLE_SIDED
1517
+ normal = normal * faceDirection;
1518
+ #endif
1519
+ normal = normalize( normalMatrix * normal );
1520
+ #elif defined( USE_NORMALMAP_TANGENTSPACE )
1521
+ vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1522
+ mapN.xy *= normalScale;
1523
+ normal = normalize( tbn * mapN );
1524
+ #elif defined( USE_BUMPMAP )
1525
+ normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
1526
+ #endif`,nd=`#ifndef FLAT_SHADED
1527
+ varying vec3 vNormal;
1528
+ #ifdef USE_TANGENT
1529
+ varying vec3 vTangent;
1530
+ varying vec3 vBitangent;
1531
+ #endif
1532
+ #endif`,id=`#ifndef FLAT_SHADED
1533
+ varying vec3 vNormal;
1534
+ #ifdef USE_TANGENT
1535
+ varying vec3 vTangent;
1536
+ varying vec3 vBitangent;
1537
+ #endif
1538
+ #endif`,rd=`#ifndef FLAT_SHADED
1539
+ vNormal = normalize( transformedNormal );
1540
+ #ifdef USE_TANGENT
1541
+ vTangent = normalize( transformedTangent );
1542
+ vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
1543
+ #endif
1544
+ #endif`,sd=`#ifdef USE_NORMALMAP
1545
+ uniform sampler2D normalMap;
1546
+ uniform vec2 normalScale;
1547
+ #endif
1548
+ #ifdef USE_NORMALMAP_OBJECTSPACE
1549
+ uniform mat3 normalMatrix;
1550
+ #endif
1551
+ #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
1552
+ mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
1553
+ vec3 q0 = dFdx( eye_pos.xyz );
1554
+ vec3 q1 = dFdy( eye_pos.xyz );
1555
+ vec2 st0 = dFdx( uv.st );
1556
+ vec2 st1 = dFdy( uv.st );
1557
+ vec3 N = surf_norm;
1558
+ vec3 q1perp = cross( q1, N );
1559
+ vec3 q0perp = cross( N, q0 );
1560
+ vec3 T = q1perp * st0.x + q0perp * st1.x;
1561
+ vec3 B = q1perp * st0.y + q0perp * st1.y;
1562
+ float det = max( dot( T, T ), dot( B, B ) );
1563
+ float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
1564
+ return mat3( T * scale, B * scale, N );
1565
+ }
1566
+ #endif`,ad=`#ifdef USE_CLEARCOAT
1567
+ vec3 clearcoatNormal = nonPerturbedNormal;
1568
+ #endif`,od=`#ifdef USE_CLEARCOAT_NORMALMAP
1569
+ vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
1570
+ clearcoatMapN.xy *= clearcoatNormalScale;
1571
+ clearcoatNormal = normalize( tbn2 * clearcoatMapN );
1572
+ #endif`,ld=`#ifdef USE_CLEARCOATMAP
1573
+ uniform sampler2D clearcoatMap;
1574
+ #endif
1575
+ #ifdef USE_CLEARCOAT_NORMALMAP
1576
+ uniform sampler2D clearcoatNormalMap;
1577
+ uniform vec2 clearcoatNormalScale;
1578
+ #endif
1579
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
1580
+ uniform sampler2D clearcoatRoughnessMap;
1581
+ #endif`,cd=`#ifdef USE_IRIDESCENCEMAP
1582
+ uniform sampler2D iridescenceMap;
1583
+ #endif
1584
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
1585
+ uniform sampler2D iridescenceThicknessMap;
1586
+ #endif`,hd=`#ifdef OPAQUE
1587
+ diffuseColor.a = 1.0;
1588
+ #endif
1589
+ #ifdef USE_TRANSMISSION
1590
+ diffuseColor.a *= material.transmissionAlpha;
1591
+ #endif
1592
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,ud=`vec3 packNormalToRGB( const in vec3 normal ) {
1593
+ return normalize( normal ) * 0.5 + 0.5;
1594
+ }
1595
+ vec3 unpackRGBToNormal( const in vec3 rgb ) {
1596
+ return 2.0 * rgb.xyz - 1.0;
1597
+ }
1598
+ const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
1599
+ const float Inv255 = 1. / 255.;
1600
+ const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
1601
+ const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
1602
+ const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
1603
+ const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
1604
+ vec4 packDepthToRGBA( const in float v ) {
1605
+ if( v <= 0.0 )
1606
+ return vec4( 0., 0., 0., 0. );
1607
+ if( v >= 1.0 )
1608
+ return vec4( 1., 1., 1., 1. );
1609
+ float vuf;
1610
+ float af = modf( v * PackFactors.a, vuf );
1611
+ float bf = modf( vuf * ShiftRight8, vuf );
1612
+ float gf = modf( vuf * ShiftRight8, vuf );
1613
+ return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
1614
+ }
1615
+ vec3 packDepthToRGB( const in float v ) {
1616
+ if( v <= 0.0 )
1617
+ return vec3( 0., 0., 0. );
1618
+ if( v >= 1.0 )
1619
+ return vec3( 1., 1., 1. );
1620
+ float vuf;
1621
+ float bf = modf( v * PackFactors.b, vuf );
1622
+ float gf = modf( vuf * ShiftRight8, vuf );
1623
+ return vec3( vuf * Inv255, gf * PackUpscale, bf );
1624
+ }
1625
+ vec2 packDepthToRG( const in float v ) {
1626
+ if( v <= 0.0 )
1627
+ return vec2( 0., 0. );
1628
+ if( v >= 1.0 )
1629
+ return vec2( 1., 1. );
1630
+ float vuf;
1631
+ float gf = modf( v * 256., vuf );
1632
+ return vec2( vuf * Inv255, gf );
1633
+ }
1634
+ float unpackRGBAToDepth( const in vec4 v ) {
1635
+ return dot( v, UnpackFactors4 );
1636
+ }
1637
+ float unpackRGBToDepth( const in vec3 v ) {
1638
+ return dot( v, UnpackFactors3 );
1639
+ }
1640
+ float unpackRGToDepth( const in vec2 v ) {
1641
+ return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
1642
+ }
1643
+ vec4 pack2HalfToRGBA( const in vec2 v ) {
1644
+ vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
1645
+ return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
1646
+ }
1647
+ vec2 unpackRGBATo2Half( const in vec4 v ) {
1648
+ return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
1649
+ }
1650
+ float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
1651
+ return ( viewZ + near ) / ( near - far );
1652
+ }
1653
+ float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
1654
+ return depth * ( near - far ) - near;
1655
+ }
1656
+ float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
1657
+ return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
1658
+ }
1659
+ float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
1660
+ return ( near * far ) / ( ( far - near ) * depth - far );
1661
+ }`,dd=`#ifdef PREMULTIPLIED_ALPHA
1662
+ gl_FragColor.rgb *= gl_FragColor.a;
1663
+ #endif`,fd=`vec4 mvPosition = vec4( transformed, 1.0 );
1664
+ #ifdef USE_BATCHING
1665
+ mvPosition = batchingMatrix * mvPosition;
1666
+ #endif
1667
+ #ifdef USE_INSTANCING
1668
+ mvPosition = instanceMatrix * mvPosition;
1669
+ #endif
1670
+ mvPosition = modelViewMatrix * mvPosition;
1671
+ gl_Position = projectionMatrix * mvPosition;`,pd=`#ifdef DITHERING
1672
+ gl_FragColor.rgb = dithering( gl_FragColor.rgb );
1673
+ #endif`,md=`#ifdef DITHERING
1674
+ vec3 dithering( vec3 color ) {
1675
+ float grid_position = rand( gl_FragCoord.xy );
1676
+ vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
1677
+ dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
1678
+ return color + dither_shift_RGB;
1679
+ }
1680
+ #endif`,gd=`float roughnessFactor = roughness;
1681
+ #ifdef USE_ROUGHNESSMAP
1682
+ vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
1683
+ roughnessFactor *= texelRoughness.g;
1684
+ #endif`,_d=`#ifdef USE_ROUGHNESSMAP
1685
+ uniform sampler2D roughnessMap;
1686
+ #endif`,vd=`#if NUM_SPOT_LIGHT_COORDS > 0
1687
+ varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1688
+ #endif
1689
+ #if NUM_SPOT_LIGHT_MAPS > 0
1690
+ uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
1691
+ #endif
1692
+ #ifdef USE_SHADOWMAP
1693
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1694
+ uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
1695
+ varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
1696
+ struct DirectionalLightShadow {
1697
+ float shadowIntensity;
1698
+ float shadowBias;
1699
+ float shadowNormalBias;
1700
+ float shadowRadius;
1701
+ vec2 shadowMapSize;
1702
+ };
1703
+ uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
1704
+ #endif
1705
+ #if NUM_SPOT_LIGHT_SHADOWS > 0
1706
+ uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
1707
+ struct SpotLightShadow {
1708
+ float shadowIntensity;
1709
+ float shadowBias;
1710
+ float shadowNormalBias;
1711
+ float shadowRadius;
1712
+ vec2 shadowMapSize;
1713
+ };
1714
+ uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
1715
+ #endif
1716
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1717
+ uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
1718
+ varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
1719
+ struct PointLightShadow {
1720
+ float shadowIntensity;
1721
+ float shadowBias;
1722
+ float shadowNormalBias;
1723
+ float shadowRadius;
1724
+ vec2 shadowMapSize;
1725
+ float shadowCameraNear;
1726
+ float shadowCameraFar;
1727
+ };
1728
+ uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1729
+ #endif
1730
+ float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
1731
+ return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
1732
+ }
1733
+ vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
1734
+ return unpackRGBATo2Half( texture2D( shadow, uv ) );
1735
+ }
1736
+ float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
1737
+ float occlusion = 1.0;
1738
+ vec2 distribution = texture2DDistribution( shadow, uv );
1739
+ float hard_shadow = step( compare , distribution.x );
1740
+ if (hard_shadow != 1.0 ) {
1741
+ float distance = compare - distribution.x ;
1742
+ float variance = max( 0.00000, distribution.y * distribution.y );
1743
+ float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
1744
+ }
1745
+ return occlusion;
1746
+ }
1747
+ float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
1748
+ float shadow = 1.0;
1749
+ shadowCoord.xyz /= shadowCoord.w;
1750
+ shadowCoord.z += shadowBias;
1751
+ bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
1752
+ bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
1753
+ if ( frustumTest ) {
1754
+ #if defined( SHADOWMAP_TYPE_PCF )
1755
+ vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
1756
+ float dx0 = - texelSize.x * shadowRadius;
1757
+ float dy0 = - texelSize.y * shadowRadius;
1758
+ float dx1 = + texelSize.x * shadowRadius;
1759
+ float dy1 = + texelSize.y * shadowRadius;
1760
+ float dx2 = dx0 / 2.0;
1761
+ float dy2 = dy0 / 2.0;
1762
+ float dx3 = dx1 / 2.0;
1763
+ float dy3 = dy1 / 2.0;
1764
+ shadow = (
1765
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
1766
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
1767
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
1768
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
1769
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
1770
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
1771
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
1772
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
1773
+ texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
1774
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
1775
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
1776
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
1777
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
1778
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
1779
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
1780
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
1781
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
1782
+ ) * ( 1.0 / 17.0 );
1783
+ #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
1784
+ vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
1785
+ float dx = texelSize.x;
1786
+ float dy = texelSize.y;
1787
+ vec2 uv = shadowCoord.xy;
1788
+ vec2 f = fract( uv * shadowMapSize + 0.5 );
1789
+ uv -= f * texelSize;
1790
+ shadow = (
1791
+ texture2DCompare( shadowMap, uv, shadowCoord.z ) +
1792
+ texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
1793
+ texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
1794
+ texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
1795
+ mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
1796
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
1797
+ f.x ) +
1798
+ mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
1799
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
1800
+ f.x ) +
1801
+ mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
1802
+ texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
1803
+ f.y ) +
1804
+ mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
1805
+ texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
1806
+ f.y ) +
1807
+ mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
1808
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
1809
+ f.x ),
1810
+ mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
1811
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
1812
+ f.x ),
1813
+ f.y )
1814
+ ) * ( 1.0 / 9.0 );
1815
+ #elif defined( SHADOWMAP_TYPE_VSM )
1816
+ shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
1817
+ #else
1818
+ shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
1819
+ #endif
1820
+ }
1821
+ return mix( 1.0, shadow, shadowIntensity );
1822
+ }
1823
+ vec2 cubeToUV( vec3 v, float texelSizeY ) {
1824
+ vec3 absV = abs( v );
1825
+ float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
1826
+ absV *= scaleToCube;
1827
+ v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
1828
+ vec2 planar = v.xy;
1829
+ float almostATexel = 1.5 * texelSizeY;
1830
+ float almostOne = 1.0 - almostATexel;
1831
+ if ( absV.z >= almostOne ) {
1832
+ if ( v.z > 0.0 )
1833
+ planar.x = 4.0 - v.x;
1834
+ } else if ( absV.x >= almostOne ) {
1835
+ float signX = sign( v.x );
1836
+ planar.x = v.z * signX + 2.0 * signX;
1837
+ } else if ( absV.y >= almostOne ) {
1838
+ float signY = sign( v.y );
1839
+ planar.x = v.x + 2.0 * signY + 2.0;
1840
+ planar.y = v.z * signY - 2.0;
1841
+ }
1842
+ return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
1843
+ }
1844
+ float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
1845
+ float shadow = 1.0;
1846
+ vec3 lightToPosition = shadowCoord.xyz;
1847
+
1848
+ float lightToPositionLength = length( lightToPosition );
1849
+ if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
1850
+ float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
1851
+ vec3 bd3D = normalize( lightToPosition );
1852
+ vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
1853
+ #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
1854
+ vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
1855
+ shadow = (
1856
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
1857
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
1858
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
1859
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
1860
+ texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
1861
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
1862
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
1863
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
1864
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
1865
+ ) * ( 1.0 / 9.0 );
1866
+ #else
1867
+ shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
1868
+ #endif
1869
+ }
1870
+ return mix( 1.0, shadow, shadowIntensity );
1871
+ }
1872
+ #endif`,xd=`#if NUM_SPOT_LIGHT_COORDS > 0
1873
+ uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
1874
+ varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1875
+ #endif
1876
+ #ifdef USE_SHADOWMAP
1877
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1878
+ uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
1879
+ varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
1880
+ struct DirectionalLightShadow {
1881
+ float shadowIntensity;
1882
+ float shadowBias;
1883
+ float shadowNormalBias;
1884
+ float shadowRadius;
1885
+ vec2 shadowMapSize;
1886
+ };
1887
+ uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
1888
+ #endif
1889
+ #if NUM_SPOT_LIGHT_SHADOWS > 0
1890
+ struct SpotLightShadow {
1891
+ float shadowIntensity;
1892
+ float shadowBias;
1893
+ float shadowNormalBias;
1894
+ float shadowRadius;
1895
+ vec2 shadowMapSize;
1896
+ };
1897
+ uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
1898
+ #endif
1899
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1900
+ uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
1901
+ varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
1902
+ struct PointLightShadow {
1903
+ float shadowIntensity;
1904
+ float shadowBias;
1905
+ float shadowNormalBias;
1906
+ float shadowRadius;
1907
+ vec2 shadowMapSize;
1908
+ float shadowCameraNear;
1909
+ float shadowCameraFar;
1910
+ };
1911
+ uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1912
+ #endif
1913
+ #endif`,Md=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
1914
+ vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
1915
+ vec4 shadowWorldPosition;
1916
+ #endif
1917
+ #if defined( USE_SHADOWMAP )
1918
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1919
+ #pragma unroll_loop_start
1920
+ for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
1921
+ shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
1922
+ vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
1923
+ }
1924
+ #pragma unroll_loop_end
1925
+ #endif
1926
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1927
+ #pragma unroll_loop_start
1928
+ for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
1929
+ shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
1930
+ vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
1931
+ }
1932
+ #pragma unroll_loop_end
1933
+ #endif
1934
+ #endif
1935
+ #if NUM_SPOT_LIGHT_COORDS > 0
1936
+ #pragma unroll_loop_start
1937
+ for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
1938
+ shadowWorldPosition = worldPosition;
1939
+ #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1940
+ shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
1941
+ #endif
1942
+ vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
1943
+ }
1944
+ #pragma unroll_loop_end
1945
+ #endif`,Sd=`float getShadowMask() {
1946
+ float shadow = 1.0;
1947
+ #ifdef USE_SHADOWMAP
1948
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1949
+ DirectionalLightShadow directionalLight;
1950
+ #pragma unroll_loop_start
1951
+ for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
1952
+ directionalLight = directionalLightShadows[ i ];
1953
+ shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
1954
+ }
1955
+ #pragma unroll_loop_end
1956
+ #endif
1957
+ #if NUM_SPOT_LIGHT_SHADOWS > 0
1958
+ SpotLightShadow spotLight;
1959
+ #pragma unroll_loop_start
1960
+ for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
1961
+ spotLight = spotLightShadows[ i ];
1962
+ shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
1963
+ }
1964
+ #pragma unroll_loop_end
1965
+ #endif
1966
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1967
+ PointLightShadow pointLight;
1968
+ #pragma unroll_loop_start
1969
+ for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
1970
+ pointLight = pointLightShadows[ i ];
1971
+ shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
1972
+ }
1973
+ #pragma unroll_loop_end
1974
+ #endif
1975
+ #endif
1976
+ return shadow;
1977
+ }`,yd=`#ifdef USE_SKINNING
1978
+ mat4 boneMatX = getBoneMatrix( skinIndex.x );
1979
+ mat4 boneMatY = getBoneMatrix( skinIndex.y );
1980
+ mat4 boneMatZ = getBoneMatrix( skinIndex.z );
1981
+ mat4 boneMatW = getBoneMatrix( skinIndex.w );
1982
+ #endif`,Ed=`#ifdef USE_SKINNING
1983
+ uniform mat4 bindMatrix;
1984
+ uniform mat4 bindMatrixInverse;
1985
+ uniform highp sampler2D boneTexture;
1986
+ mat4 getBoneMatrix( const in float i ) {
1987
+ int size = textureSize( boneTexture, 0 ).x;
1988
+ int j = int( i ) * 4;
1989
+ int x = j % size;
1990
+ int y = j / size;
1991
+ vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
1992
+ vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
1993
+ vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
1994
+ vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
1995
+ return mat4( v1, v2, v3, v4 );
1996
+ }
1997
+ #endif`,Td=`#ifdef USE_SKINNING
1998
+ vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
1999
+ vec4 skinned = vec4( 0.0 );
2000
+ skinned += boneMatX * skinVertex * skinWeight.x;
2001
+ skinned += boneMatY * skinVertex * skinWeight.y;
2002
+ skinned += boneMatZ * skinVertex * skinWeight.z;
2003
+ skinned += boneMatW * skinVertex * skinWeight.w;
2004
+ transformed = ( bindMatrixInverse * skinned ).xyz;
2005
+ #endif`,bd=`#ifdef USE_SKINNING
2006
+ mat4 skinMatrix = mat4( 0.0 );
2007
+ skinMatrix += skinWeight.x * boneMatX;
2008
+ skinMatrix += skinWeight.y * boneMatY;
2009
+ skinMatrix += skinWeight.z * boneMatZ;
2010
+ skinMatrix += skinWeight.w * boneMatW;
2011
+ skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
2012
+ objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
2013
+ #ifdef USE_TANGENT
2014
+ objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
2015
+ #endif
2016
+ #endif`,Ad=`float specularStrength;
2017
+ #ifdef USE_SPECULARMAP
2018
+ vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
2019
+ specularStrength = texelSpecular.r;
2020
+ #else
2021
+ specularStrength = 1.0;
2022
+ #endif`,wd=`#ifdef USE_SPECULARMAP
2023
+ uniform sampler2D specularMap;
2024
+ #endif`,Rd=`#if defined( TONE_MAPPING )
2025
+ gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2026
+ #endif`,Cd=`#ifndef saturate
2027
+ #define saturate( a ) clamp( a, 0.0, 1.0 )
2028
+ #endif
2029
+ uniform float toneMappingExposure;
2030
+ vec3 LinearToneMapping( vec3 color ) {
2031
+ return saturate( toneMappingExposure * color );
2032
+ }
2033
+ vec3 ReinhardToneMapping( vec3 color ) {
2034
+ color *= toneMappingExposure;
2035
+ return saturate( color / ( vec3( 1.0 ) + color ) );
2036
+ }
2037
+ vec3 CineonToneMapping( vec3 color ) {
2038
+ color *= toneMappingExposure;
2039
+ color = max( vec3( 0.0 ), color - 0.004 );
2040
+ return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
2041
+ }
2042
+ vec3 RRTAndODTFit( vec3 v ) {
2043
+ vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
2044
+ vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
2045
+ return a / b;
2046
+ }
2047
+ vec3 ACESFilmicToneMapping( vec3 color ) {
2048
+ const mat3 ACESInputMat = mat3(
2049
+ vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
2050
+ vec3( 0.04823, 0.01566, 0.83777 )
2051
+ );
2052
+ const mat3 ACESOutputMat = mat3(
2053
+ vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
2054
+ vec3( -0.07367, -0.00605, 1.07602 )
2055
+ );
2056
+ color *= toneMappingExposure / 0.6;
2057
+ color = ACESInputMat * color;
2058
+ color = RRTAndODTFit( color );
2059
+ color = ACESOutputMat * color;
2060
+ return saturate( color );
2061
+ }
2062
+ const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
2063
+ vec3( 1.6605, - 0.1246, - 0.0182 ),
2064
+ vec3( - 0.5876, 1.1329, - 0.1006 ),
2065
+ vec3( - 0.0728, - 0.0083, 1.1187 )
2066
+ );
2067
+ const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
2068
+ vec3( 0.6274, 0.0691, 0.0164 ),
2069
+ vec3( 0.3293, 0.9195, 0.0880 ),
2070
+ vec3( 0.0433, 0.0113, 0.8956 )
2071
+ );
2072
+ vec3 agxDefaultContrastApprox( vec3 x ) {
2073
+ vec3 x2 = x * x;
2074
+ vec3 x4 = x2 * x2;
2075
+ return + 15.5 * x4 * x2
2076
+ - 40.14 * x4 * x
2077
+ + 31.96 * x4
2078
+ - 6.868 * x2 * x
2079
+ + 0.4298 * x2
2080
+ + 0.1191 * x
2081
+ - 0.00232;
2082
+ }
2083
+ vec3 AgXToneMapping( vec3 color ) {
2084
+ const mat3 AgXInsetMatrix = mat3(
2085
+ vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
2086
+ vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
2087
+ vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
2088
+ );
2089
+ const mat3 AgXOutsetMatrix = mat3(
2090
+ vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
2091
+ vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
2092
+ vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
2093
+ );
2094
+ const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
2095
+ color *= toneMappingExposure;
2096
+ color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
2097
+ color = AgXInsetMatrix * color;
2098
+ color = max( color, 1e-10 ); color = log2( color );
2099
+ color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
2100
+ color = clamp( color, 0.0, 1.0 );
2101
+ color = agxDefaultContrastApprox( color );
2102
+ color = AgXOutsetMatrix * color;
2103
+ color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
2104
+ color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
2105
+ color = clamp( color, 0.0, 1.0 );
2106
+ return color;
2107
+ }
2108
+ vec3 NeutralToneMapping( vec3 color ) {
2109
+ const float StartCompression = 0.8 - 0.04;
2110
+ const float Desaturation = 0.15;
2111
+ color *= toneMappingExposure;
2112
+ float x = min( color.r, min( color.g, color.b ) );
2113
+ float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
2114
+ color -= offset;
2115
+ float peak = max( color.r, max( color.g, color.b ) );
2116
+ if ( peak < StartCompression ) return color;
2117
+ float d = 1. - StartCompression;
2118
+ float newPeak = 1. - d * d / ( peak + d - StartCompression );
2119
+ color *= newPeak / peak;
2120
+ float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
2121
+ return mix( color, vec3( newPeak ), g );
2122
+ }
2123
+ vec3 CustomToneMapping( vec3 color ) { return color; }`,Pd=`#ifdef USE_TRANSMISSION
2124
+ material.transmission = transmission;
2125
+ material.transmissionAlpha = 1.0;
2126
+ material.thickness = thickness;
2127
+ material.attenuationDistance = attenuationDistance;
2128
+ material.attenuationColor = attenuationColor;
2129
+ #ifdef USE_TRANSMISSIONMAP
2130
+ material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
2131
+ #endif
2132
+ #ifdef USE_THICKNESSMAP
2133
+ material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
2134
+ #endif
2135
+ vec3 pos = vWorldPosition;
2136
+ vec3 v = normalize( cameraPosition - pos );
2137
+ vec3 n = inverseTransformDirection( normal, viewMatrix );
2138
+ vec4 transmitted = getIBLVolumeRefraction(
2139
+ n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
2140
+ pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
2141
+ material.attenuationColor, material.attenuationDistance );
2142
+ material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
2143
+ totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
2144
+ #endif`,Ld=`#ifdef USE_TRANSMISSION
2145
+ uniform float transmission;
2146
+ uniform float thickness;
2147
+ uniform float attenuationDistance;
2148
+ uniform vec3 attenuationColor;
2149
+ #ifdef USE_TRANSMISSIONMAP
2150
+ uniform sampler2D transmissionMap;
2151
+ #endif
2152
+ #ifdef USE_THICKNESSMAP
2153
+ uniform sampler2D thicknessMap;
2154
+ #endif
2155
+ uniform vec2 transmissionSamplerSize;
2156
+ uniform sampler2D transmissionSamplerMap;
2157
+ uniform mat4 modelMatrix;
2158
+ uniform mat4 projectionMatrix;
2159
+ varying vec3 vWorldPosition;
2160
+ float w0( float a ) {
2161
+ return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
2162
+ }
2163
+ float w1( float a ) {
2164
+ return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
2165
+ }
2166
+ float w2( float a ){
2167
+ return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
2168
+ }
2169
+ float w3( float a ) {
2170
+ return ( 1.0 / 6.0 ) * ( a * a * a );
2171
+ }
2172
+ float g0( float a ) {
2173
+ return w0( a ) + w1( a );
2174
+ }
2175
+ float g1( float a ) {
2176
+ return w2( a ) + w3( a );
2177
+ }
2178
+ float h0( float a ) {
2179
+ return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
2180
+ }
2181
+ float h1( float a ) {
2182
+ return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
2183
+ }
2184
+ vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
2185
+ uv = uv * texelSize.zw + 0.5;
2186
+ vec2 iuv = floor( uv );
2187
+ vec2 fuv = fract( uv );
2188
+ float g0x = g0( fuv.x );
2189
+ float g1x = g1( fuv.x );
2190
+ float h0x = h0( fuv.x );
2191
+ float h1x = h1( fuv.x );
2192
+ float h0y = h0( fuv.y );
2193
+ float h1y = h1( fuv.y );
2194
+ vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
2195
+ vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
2196
+ vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
2197
+ vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
2198
+ return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
2199
+ g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
2200
+ }
2201
+ vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
2202
+ vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
2203
+ vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
2204
+ vec2 fLodSizeInv = 1.0 / fLodSize;
2205
+ vec2 cLodSizeInv = 1.0 / cLodSize;
2206
+ vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
2207
+ vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
2208
+ return mix( fSample, cSample, fract( lod ) );
2209
+ }
2210
+ vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
2211
+ vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
2212
+ vec3 modelScale;
2213
+ modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
2214
+ modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
2215
+ modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
2216
+ return normalize( refractionVector ) * thickness * modelScale;
2217
+ }
2218
+ float applyIorToRoughness( const in float roughness, const in float ior ) {
2219
+ return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
2220
+ }
2221
+ vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
2222
+ float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
2223
+ return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
2224
+ }
2225
+ vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
2226
+ if ( isinf( attenuationDistance ) ) {
2227
+ return vec3( 1.0 );
2228
+ } else {
2229
+ vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
2230
+ vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
2231
+ }
2232
+ }
2233
+ vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
2234
+ const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
2235
+ const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
2236
+ const in vec3 attenuationColor, const in float attenuationDistance ) {
2237
+ vec4 transmittedLight;
2238
+ vec3 transmittance;
2239
+ #ifdef USE_DISPERSION
2240
+ float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
2241
+ vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
2242
+ for ( int i = 0; i < 3; i ++ ) {
2243
+ vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
2244
+ vec3 refractedRayExit = position + transmissionRay;
2245
+
2246
+ vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
2247
+ vec2 refractionCoords = ndcPos.xy / ndcPos.w;
2248
+ refractionCoords += 1.0;
2249
+ refractionCoords /= 2.0;
2250
+
2251
+ vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
2252
+ transmittedLight[ i ] = transmissionSample[ i ];
2253
+ transmittedLight.a += transmissionSample.a;
2254
+ transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
2255
+ }
2256
+ transmittedLight.a /= 3.0;
2257
+
2258
+ #else
2259
+
2260
+ vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
2261
+ vec3 refractedRayExit = position + transmissionRay;
2262
+ vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
2263
+ vec2 refractionCoords = ndcPos.xy / ndcPos.w;
2264
+ refractionCoords += 1.0;
2265
+ refractionCoords /= 2.0;
2266
+ transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
2267
+ transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
2268
+
2269
+ #endif
2270
+ vec3 attenuatedColor = transmittance * transmittedLight.rgb;
2271
+ vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
2272
+ float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
2273
+ return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
2274
+ }
2275
+ #endif`,Dd=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2276
+ varying vec2 vUv;
2277
+ #endif
2278
+ #ifdef USE_MAP
2279
+ varying vec2 vMapUv;
2280
+ #endif
2281
+ #ifdef USE_ALPHAMAP
2282
+ varying vec2 vAlphaMapUv;
2283
+ #endif
2284
+ #ifdef USE_LIGHTMAP
2285
+ varying vec2 vLightMapUv;
2286
+ #endif
2287
+ #ifdef USE_AOMAP
2288
+ varying vec2 vAoMapUv;
2289
+ #endif
2290
+ #ifdef USE_BUMPMAP
2291
+ varying vec2 vBumpMapUv;
2292
+ #endif
2293
+ #ifdef USE_NORMALMAP
2294
+ varying vec2 vNormalMapUv;
2295
+ #endif
2296
+ #ifdef USE_EMISSIVEMAP
2297
+ varying vec2 vEmissiveMapUv;
2298
+ #endif
2299
+ #ifdef USE_METALNESSMAP
2300
+ varying vec2 vMetalnessMapUv;
2301
+ #endif
2302
+ #ifdef USE_ROUGHNESSMAP
2303
+ varying vec2 vRoughnessMapUv;
2304
+ #endif
2305
+ #ifdef USE_ANISOTROPYMAP
2306
+ varying vec2 vAnisotropyMapUv;
2307
+ #endif
2308
+ #ifdef USE_CLEARCOATMAP
2309
+ varying vec2 vClearcoatMapUv;
2310
+ #endif
2311
+ #ifdef USE_CLEARCOAT_NORMALMAP
2312
+ varying vec2 vClearcoatNormalMapUv;
2313
+ #endif
2314
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2315
+ varying vec2 vClearcoatRoughnessMapUv;
2316
+ #endif
2317
+ #ifdef USE_IRIDESCENCEMAP
2318
+ varying vec2 vIridescenceMapUv;
2319
+ #endif
2320
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
2321
+ varying vec2 vIridescenceThicknessMapUv;
2322
+ #endif
2323
+ #ifdef USE_SHEEN_COLORMAP
2324
+ varying vec2 vSheenColorMapUv;
2325
+ #endif
2326
+ #ifdef USE_SHEEN_ROUGHNESSMAP
2327
+ varying vec2 vSheenRoughnessMapUv;
2328
+ #endif
2329
+ #ifdef USE_SPECULARMAP
2330
+ varying vec2 vSpecularMapUv;
2331
+ #endif
2332
+ #ifdef USE_SPECULAR_COLORMAP
2333
+ varying vec2 vSpecularColorMapUv;
2334
+ #endif
2335
+ #ifdef USE_SPECULAR_INTENSITYMAP
2336
+ varying vec2 vSpecularIntensityMapUv;
2337
+ #endif
2338
+ #ifdef USE_TRANSMISSIONMAP
2339
+ uniform mat3 transmissionMapTransform;
2340
+ varying vec2 vTransmissionMapUv;
2341
+ #endif
2342
+ #ifdef USE_THICKNESSMAP
2343
+ uniform mat3 thicknessMapTransform;
2344
+ varying vec2 vThicknessMapUv;
2345
+ #endif`,Id=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2346
+ varying vec2 vUv;
2347
+ #endif
2348
+ #ifdef USE_MAP
2349
+ uniform mat3 mapTransform;
2350
+ varying vec2 vMapUv;
2351
+ #endif
2352
+ #ifdef USE_ALPHAMAP
2353
+ uniform mat3 alphaMapTransform;
2354
+ varying vec2 vAlphaMapUv;
2355
+ #endif
2356
+ #ifdef USE_LIGHTMAP
2357
+ uniform mat3 lightMapTransform;
2358
+ varying vec2 vLightMapUv;
2359
+ #endif
2360
+ #ifdef USE_AOMAP
2361
+ uniform mat3 aoMapTransform;
2362
+ varying vec2 vAoMapUv;
2363
+ #endif
2364
+ #ifdef USE_BUMPMAP
2365
+ uniform mat3 bumpMapTransform;
2366
+ varying vec2 vBumpMapUv;
2367
+ #endif
2368
+ #ifdef USE_NORMALMAP
2369
+ uniform mat3 normalMapTransform;
2370
+ varying vec2 vNormalMapUv;
2371
+ #endif
2372
+ #ifdef USE_DISPLACEMENTMAP
2373
+ uniform mat3 displacementMapTransform;
2374
+ varying vec2 vDisplacementMapUv;
2375
+ #endif
2376
+ #ifdef USE_EMISSIVEMAP
2377
+ uniform mat3 emissiveMapTransform;
2378
+ varying vec2 vEmissiveMapUv;
2379
+ #endif
2380
+ #ifdef USE_METALNESSMAP
2381
+ uniform mat3 metalnessMapTransform;
2382
+ varying vec2 vMetalnessMapUv;
2383
+ #endif
2384
+ #ifdef USE_ROUGHNESSMAP
2385
+ uniform mat3 roughnessMapTransform;
2386
+ varying vec2 vRoughnessMapUv;
2387
+ #endif
2388
+ #ifdef USE_ANISOTROPYMAP
2389
+ uniform mat3 anisotropyMapTransform;
2390
+ varying vec2 vAnisotropyMapUv;
2391
+ #endif
2392
+ #ifdef USE_CLEARCOATMAP
2393
+ uniform mat3 clearcoatMapTransform;
2394
+ varying vec2 vClearcoatMapUv;
2395
+ #endif
2396
+ #ifdef USE_CLEARCOAT_NORMALMAP
2397
+ uniform mat3 clearcoatNormalMapTransform;
2398
+ varying vec2 vClearcoatNormalMapUv;
2399
+ #endif
2400
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2401
+ uniform mat3 clearcoatRoughnessMapTransform;
2402
+ varying vec2 vClearcoatRoughnessMapUv;
2403
+ #endif
2404
+ #ifdef USE_SHEEN_COLORMAP
2405
+ uniform mat3 sheenColorMapTransform;
2406
+ varying vec2 vSheenColorMapUv;
2407
+ #endif
2408
+ #ifdef USE_SHEEN_ROUGHNESSMAP
2409
+ uniform mat3 sheenRoughnessMapTransform;
2410
+ varying vec2 vSheenRoughnessMapUv;
2411
+ #endif
2412
+ #ifdef USE_IRIDESCENCEMAP
2413
+ uniform mat3 iridescenceMapTransform;
2414
+ varying vec2 vIridescenceMapUv;
2415
+ #endif
2416
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
2417
+ uniform mat3 iridescenceThicknessMapTransform;
2418
+ varying vec2 vIridescenceThicknessMapUv;
2419
+ #endif
2420
+ #ifdef USE_SPECULARMAP
2421
+ uniform mat3 specularMapTransform;
2422
+ varying vec2 vSpecularMapUv;
2423
+ #endif
2424
+ #ifdef USE_SPECULAR_COLORMAP
2425
+ uniform mat3 specularColorMapTransform;
2426
+ varying vec2 vSpecularColorMapUv;
2427
+ #endif
2428
+ #ifdef USE_SPECULAR_INTENSITYMAP
2429
+ uniform mat3 specularIntensityMapTransform;
2430
+ varying vec2 vSpecularIntensityMapUv;
2431
+ #endif
2432
+ #ifdef USE_TRANSMISSIONMAP
2433
+ uniform mat3 transmissionMapTransform;
2434
+ varying vec2 vTransmissionMapUv;
2435
+ #endif
2436
+ #ifdef USE_THICKNESSMAP
2437
+ uniform mat3 thicknessMapTransform;
2438
+ varying vec2 vThicknessMapUv;
2439
+ #endif`,Ud=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2440
+ vUv = vec3( uv, 1 ).xy;
2441
+ #endif
2442
+ #ifdef USE_MAP
2443
+ vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
2444
+ #endif
2445
+ #ifdef USE_ALPHAMAP
2446
+ vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
2447
+ #endif
2448
+ #ifdef USE_LIGHTMAP
2449
+ vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
2450
+ #endif
2451
+ #ifdef USE_AOMAP
2452
+ vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
2453
+ #endif
2454
+ #ifdef USE_BUMPMAP
2455
+ vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
2456
+ #endif
2457
+ #ifdef USE_NORMALMAP
2458
+ vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
2459
+ #endif
2460
+ #ifdef USE_DISPLACEMENTMAP
2461
+ vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
2462
+ #endif
2463
+ #ifdef USE_EMISSIVEMAP
2464
+ vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
2465
+ #endif
2466
+ #ifdef USE_METALNESSMAP
2467
+ vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
2468
+ #endif
2469
+ #ifdef USE_ROUGHNESSMAP
2470
+ vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
2471
+ #endif
2472
+ #ifdef USE_ANISOTROPYMAP
2473
+ vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
2474
+ #endif
2475
+ #ifdef USE_CLEARCOATMAP
2476
+ vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
2477
+ #endif
2478
+ #ifdef USE_CLEARCOAT_NORMALMAP
2479
+ vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
2480
+ #endif
2481
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2482
+ vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
2483
+ #endif
2484
+ #ifdef USE_IRIDESCENCEMAP
2485
+ vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
2486
+ #endif
2487
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
2488
+ vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
2489
+ #endif
2490
+ #ifdef USE_SHEEN_COLORMAP
2491
+ vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
2492
+ #endif
2493
+ #ifdef USE_SHEEN_ROUGHNESSMAP
2494
+ vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
2495
+ #endif
2496
+ #ifdef USE_SPECULARMAP
2497
+ vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
2498
+ #endif
2499
+ #ifdef USE_SPECULAR_COLORMAP
2500
+ vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
2501
+ #endif
2502
+ #ifdef USE_SPECULAR_INTENSITYMAP
2503
+ vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
2504
+ #endif
2505
+ #ifdef USE_TRANSMISSIONMAP
2506
+ vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
2507
+ #endif
2508
+ #ifdef USE_THICKNESSMAP
2509
+ vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
2510
+ #endif`,Nd=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2511
+ vec4 worldPosition = vec4( transformed, 1.0 );
2512
+ #ifdef USE_BATCHING
2513
+ worldPosition = batchingMatrix * worldPosition;
2514
+ #endif
2515
+ #ifdef USE_INSTANCING
2516
+ worldPosition = instanceMatrix * worldPosition;
2517
+ #endif
2518
+ worldPosition = modelMatrix * worldPosition;
2519
+ #endif`;const Fd=`varying vec2 vUv;
2520
+ uniform mat3 uvTransform;
2521
+ void main() {
2522
+ vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
2523
+ gl_Position = vec4( position.xy, 1.0, 1.0 );
2524
+ }`,Od=`uniform sampler2D t2D;
2525
+ uniform float backgroundIntensity;
2526
+ varying vec2 vUv;
2527
+ void main() {
2528
+ vec4 texColor = texture2D( t2D, vUv );
2529
+ #ifdef DECODE_VIDEO_TEXTURE
2530
+ texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
2531
+ #endif
2532
+ texColor.rgb *= backgroundIntensity;
2533
+ gl_FragColor = texColor;
2534
+ #include <tonemapping_fragment>
2535
+ #include <colorspace_fragment>
2536
+ }`,Bd=`varying vec3 vWorldDirection;
2537
+ #include <common>
2538
+ void main() {
2539
+ vWorldDirection = transformDirection( position, modelMatrix );
2540
+ #include <begin_vertex>
2541
+ #include <project_vertex>
2542
+ gl_Position.z = gl_Position.w;
2543
+ }`,zd=`#ifdef ENVMAP_TYPE_CUBE
2544
+ uniform samplerCube envMap;
2545
+ #elif defined( ENVMAP_TYPE_CUBE_UV )
2546
+ uniform sampler2D envMap;
2547
+ #endif
2548
+ uniform float flipEnvMap;
2549
+ uniform float backgroundBlurriness;
2550
+ uniform float backgroundIntensity;
2551
+ uniform mat3 backgroundRotation;
2552
+ varying vec3 vWorldDirection;
2553
+ #include <cube_uv_reflection_fragment>
2554
+ void main() {
2555
+ #ifdef ENVMAP_TYPE_CUBE
2556
+ vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
2557
+ #elif defined( ENVMAP_TYPE_CUBE_UV )
2558
+ vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
2559
+ #else
2560
+ vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
2561
+ #endif
2562
+ texColor.rgb *= backgroundIntensity;
2563
+ gl_FragColor = texColor;
2564
+ #include <tonemapping_fragment>
2565
+ #include <colorspace_fragment>
2566
+ }`,Vd=`varying vec3 vWorldDirection;
2567
+ #include <common>
2568
+ void main() {
2569
+ vWorldDirection = transformDirection( position, modelMatrix );
2570
+ #include <begin_vertex>
2571
+ #include <project_vertex>
2572
+ gl_Position.z = gl_Position.w;
2573
+ }`,Hd=`uniform samplerCube tCube;
2574
+ uniform float tFlip;
2575
+ uniform float opacity;
2576
+ varying vec3 vWorldDirection;
2577
+ void main() {
2578
+ vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
2579
+ gl_FragColor = texColor;
2580
+ gl_FragColor.a *= opacity;
2581
+ #include <tonemapping_fragment>
2582
+ #include <colorspace_fragment>
2583
+ }`,kd=`#include <common>
2584
+ #include <batching_pars_vertex>
2585
+ #include <uv_pars_vertex>
2586
+ #include <displacementmap_pars_vertex>
2587
+ #include <morphtarget_pars_vertex>
2588
+ #include <skinning_pars_vertex>
2589
+ #include <logdepthbuf_pars_vertex>
2590
+ #include <clipping_planes_pars_vertex>
2591
+ varying vec2 vHighPrecisionZW;
2592
+ void main() {
2593
+ #include <uv_vertex>
2594
+ #include <batching_vertex>
2595
+ #include <skinbase_vertex>
2596
+ #include <morphinstance_vertex>
2597
+ #ifdef USE_DISPLACEMENTMAP
2598
+ #include <beginnormal_vertex>
2599
+ #include <morphnormal_vertex>
2600
+ #include <skinnormal_vertex>
2601
+ #endif
2602
+ #include <begin_vertex>
2603
+ #include <morphtarget_vertex>
2604
+ #include <skinning_vertex>
2605
+ #include <displacementmap_vertex>
2606
+ #include <project_vertex>
2607
+ #include <logdepthbuf_vertex>
2608
+ #include <clipping_planes_vertex>
2609
+ vHighPrecisionZW = gl_Position.zw;
2610
+ }`,Gd=`#if DEPTH_PACKING == 3200
2611
+ uniform float opacity;
2612
+ #endif
2613
+ #include <common>
2614
+ #include <packing>
2615
+ #include <uv_pars_fragment>
2616
+ #include <map_pars_fragment>
2617
+ #include <alphamap_pars_fragment>
2618
+ #include <alphatest_pars_fragment>
2619
+ #include <alphahash_pars_fragment>
2620
+ #include <logdepthbuf_pars_fragment>
2621
+ #include <clipping_planes_pars_fragment>
2622
+ varying vec2 vHighPrecisionZW;
2623
+ void main() {
2624
+ vec4 diffuseColor = vec4( 1.0 );
2625
+ #include <clipping_planes_fragment>
2626
+ #if DEPTH_PACKING == 3200
2627
+ diffuseColor.a = opacity;
2628
+ #endif
2629
+ #include <map_fragment>
2630
+ #include <alphamap_fragment>
2631
+ #include <alphatest_fragment>
2632
+ #include <alphahash_fragment>
2633
+ #include <logdepthbuf_fragment>
2634
+ float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
2635
+ #if DEPTH_PACKING == 3200
2636
+ gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
2637
+ #elif DEPTH_PACKING == 3201
2638
+ gl_FragColor = packDepthToRGBA( fragCoordZ );
2639
+ #elif DEPTH_PACKING == 3202
2640
+ gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
2641
+ #elif DEPTH_PACKING == 3203
2642
+ gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
2643
+ #endif
2644
+ }`,Wd=`#define DISTANCE
2645
+ varying vec3 vWorldPosition;
2646
+ #include <common>
2647
+ #include <batching_pars_vertex>
2648
+ #include <uv_pars_vertex>
2649
+ #include <displacementmap_pars_vertex>
2650
+ #include <morphtarget_pars_vertex>
2651
+ #include <skinning_pars_vertex>
2652
+ #include <clipping_planes_pars_vertex>
2653
+ void main() {
2654
+ #include <uv_vertex>
2655
+ #include <batching_vertex>
2656
+ #include <skinbase_vertex>
2657
+ #include <morphinstance_vertex>
2658
+ #ifdef USE_DISPLACEMENTMAP
2659
+ #include <beginnormal_vertex>
2660
+ #include <morphnormal_vertex>
2661
+ #include <skinnormal_vertex>
2662
+ #endif
2663
+ #include <begin_vertex>
2664
+ #include <morphtarget_vertex>
2665
+ #include <skinning_vertex>
2666
+ #include <displacementmap_vertex>
2667
+ #include <project_vertex>
2668
+ #include <worldpos_vertex>
2669
+ #include <clipping_planes_vertex>
2670
+ vWorldPosition = worldPosition.xyz;
2671
+ }`,Xd=`#define DISTANCE
2672
+ uniform vec3 referencePosition;
2673
+ uniform float nearDistance;
2674
+ uniform float farDistance;
2675
+ varying vec3 vWorldPosition;
2676
+ #include <common>
2677
+ #include <packing>
2678
+ #include <uv_pars_fragment>
2679
+ #include <map_pars_fragment>
2680
+ #include <alphamap_pars_fragment>
2681
+ #include <alphatest_pars_fragment>
2682
+ #include <alphahash_pars_fragment>
2683
+ #include <clipping_planes_pars_fragment>
2684
+ void main () {
2685
+ vec4 diffuseColor = vec4( 1.0 );
2686
+ #include <clipping_planes_fragment>
2687
+ #include <map_fragment>
2688
+ #include <alphamap_fragment>
2689
+ #include <alphatest_fragment>
2690
+ #include <alphahash_fragment>
2691
+ float dist = length( vWorldPosition - referencePosition );
2692
+ dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
2693
+ dist = saturate( dist );
2694
+ gl_FragColor = packDepthToRGBA( dist );
2695
+ }`,qd=`varying vec3 vWorldDirection;
2696
+ #include <common>
2697
+ void main() {
2698
+ vWorldDirection = transformDirection( position, modelMatrix );
2699
+ #include <begin_vertex>
2700
+ #include <project_vertex>
2701
+ }`,Yd=`uniform sampler2D tEquirect;
2702
+ varying vec3 vWorldDirection;
2703
+ #include <common>
2704
+ void main() {
2705
+ vec3 direction = normalize( vWorldDirection );
2706
+ vec2 sampleUV = equirectUv( direction );
2707
+ gl_FragColor = texture2D( tEquirect, sampleUV );
2708
+ #include <tonemapping_fragment>
2709
+ #include <colorspace_fragment>
2710
+ }`,Kd=`uniform float scale;
2711
+ attribute float lineDistance;
2712
+ varying float vLineDistance;
2713
+ #include <common>
2714
+ #include <uv_pars_vertex>
2715
+ #include <color_pars_vertex>
2716
+ #include <fog_pars_vertex>
2717
+ #include <morphtarget_pars_vertex>
2718
+ #include <logdepthbuf_pars_vertex>
2719
+ #include <clipping_planes_pars_vertex>
2720
+ void main() {
2721
+ vLineDistance = scale * lineDistance;
2722
+ #include <uv_vertex>
2723
+ #include <color_vertex>
2724
+ #include <morphinstance_vertex>
2725
+ #include <morphcolor_vertex>
2726
+ #include <begin_vertex>
2727
+ #include <morphtarget_vertex>
2728
+ #include <project_vertex>
2729
+ #include <logdepthbuf_vertex>
2730
+ #include <clipping_planes_vertex>
2731
+ #include <fog_vertex>
2732
+ }`,Zd=`uniform vec3 diffuse;
2733
+ uniform float opacity;
2734
+ uniform float dashSize;
2735
+ uniform float totalSize;
2736
+ varying float vLineDistance;
2737
+ #include <common>
2738
+ #include <color_pars_fragment>
2739
+ #include <uv_pars_fragment>
2740
+ #include <map_pars_fragment>
2741
+ #include <fog_pars_fragment>
2742
+ #include <logdepthbuf_pars_fragment>
2743
+ #include <clipping_planes_pars_fragment>
2744
+ void main() {
2745
+ vec4 diffuseColor = vec4( diffuse, opacity );
2746
+ #include <clipping_planes_fragment>
2747
+ if ( mod( vLineDistance, totalSize ) > dashSize ) {
2748
+ discard;
2749
+ }
2750
+ vec3 outgoingLight = vec3( 0.0 );
2751
+ #include <logdepthbuf_fragment>
2752
+ #include <map_fragment>
2753
+ #include <color_fragment>
2754
+ outgoingLight = diffuseColor.rgb;
2755
+ #include <opaque_fragment>
2756
+ #include <tonemapping_fragment>
2757
+ #include <colorspace_fragment>
2758
+ #include <fog_fragment>
2759
+ #include <premultiplied_alpha_fragment>
2760
+ }`,$d=`#include <common>
2761
+ #include <batching_pars_vertex>
2762
+ #include <uv_pars_vertex>
2763
+ #include <envmap_pars_vertex>
2764
+ #include <color_pars_vertex>
2765
+ #include <fog_pars_vertex>
2766
+ #include <morphtarget_pars_vertex>
2767
+ #include <skinning_pars_vertex>
2768
+ #include <logdepthbuf_pars_vertex>
2769
+ #include <clipping_planes_pars_vertex>
2770
+ void main() {
2771
+ #include <uv_vertex>
2772
+ #include <color_vertex>
2773
+ #include <morphinstance_vertex>
2774
+ #include <morphcolor_vertex>
2775
+ #include <batching_vertex>
2776
+ #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
2777
+ #include <beginnormal_vertex>
2778
+ #include <morphnormal_vertex>
2779
+ #include <skinbase_vertex>
2780
+ #include <skinnormal_vertex>
2781
+ #include <defaultnormal_vertex>
2782
+ #endif
2783
+ #include <begin_vertex>
2784
+ #include <morphtarget_vertex>
2785
+ #include <skinning_vertex>
2786
+ #include <project_vertex>
2787
+ #include <logdepthbuf_vertex>
2788
+ #include <clipping_planes_vertex>
2789
+ #include <worldpos_vertex>
2790
+ #include <envmap_vertex>
2791
+ #include <fog_vertex>
2792
+ }`,jd=`uniform vec3 diffuse;
2793
+ uniform float opacity;
2794
+ #ifndef FLAT_SHADED
2795
+ varying vec3 vNormal;
2796
+ #endif
2797
+ #include <common>
2798
+ #include <dithering_pars_fragment>
2799
+ #include <color_pars_fragment>
2800
+ #include <uv_pars_fragment>
2801
+ #include <map_pars_fragment>
2802
+ #include <alphamap_pars_fragment>
2803
+ #include <alphatest_pars_fragment>
2804
+ #include <alphahash_pars_fragment>
2805
+ #include <aomap_pars_fragment>
2806
+ #include <lightmap_pars_fragment>
2807
+ #include <envmap_common_pars_fragment>
2808
+ #include <envmap_pars_fragment>
2809
+ #include <fog_pars_fragment>
2810
+ #include <specularmap_pars_fragment>
2811
+ #include <logdepthbuf_pars_fragment>
2812
+ #include <clipping_planes_pars_fragment>
2813
+ void main() {
2814
+ vec4 diffuseColor = vec4( diffuse, opacity );
2815
+ #include <clipping_planes_fragment>
2816
+ #include <logdepthbuf_fragment>
2817
+ #include <map_fragment>
2818
+ #include <color_fragment>
2819
+ #include <alphamap_fragment>
2820
+ #include <alphatest_fragment>
2821
+ #include <alphahash_fragment>
2822
+ #include <specularmap_fragment>
2823
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
2824
+ #ifdef USE_LIGHTMAP
2825
+ vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
2826
+ reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
2827
+ #else
2828
+ reflectedLight.indirectDiffuse += vec3( 1.0 );
2829
+ #endif
2830
+ #include <aomap_fragment>
2831
+ reflectedLight.indirectDiffuse *= diffuseColor.rgb;
2832
+ vec3 outgoingLight = reflectedLight.indirectDiffuse;
2833
+ #include <envmap_fragment>
2834
+ #include <opaque_fragment>
2835
+ #include <tonemapping_fragment>
2836
+ #include <colorspace_fragment>
2837
+ #include <fog_fragment>
2838
+ #include <premultiplied_alpha_fragment>
2839
+ #include <dithering_fragment>
2840
+ }`,Jd=`#define LAMBERT
2841
+ varying vec3 vViewPosition;
2842
+ #include <common>
2843
+ #include <batching_pars_vertex>
2844
+ #include <uv_pars_vertex>
2845
+ #include <displacementmap_pars_vertex>
2846
+ #include <envmap_pars_vertex>
2847
+ #include <color_pars_vertex>
2848
+ #include <fog_pars_vertex>
2849
+ #include <normal_pars_vertex>
2850
+ #include <morphtarget_pars_vertex>
2851
+ #include <skinning_pars_vertex>
2852
+ #include <shadowmap_pars_vertex>
2853
+ #include <logdepthbuf_pars_vertex>
2854
+ #include <clipping_planes_pars_vertex>
2855
+ void main() {
2856
+ #include <uv_vertex>
2857
+ #include <color_vertex>
2858
+ #include <morphinstance_vertex>
2859
+ #include <morphcolor_vertex>
2860
+ #include <batching_vertex>
2861
+ #include <beginnormal_vertex>
2862
+ #include <morphnormal_vertex>
2863
+ #include <skinbase_vertex>
2864
+ #include <skinnormal_vertex>
2865
+ #include <defaultnormal_vertex>
2866
+ #include <normal_vertex>
2867
+ #include <begin_vertex>
2868
+ #include <morphtarget_vertex>
2869
+ #include <skinning_vertex>
2870
+ #include <displacementmap_vertex>
2871
+ #include <project_vertex>
2872
+ #include <logdepthbuf_vertex>
2873
+ #include <clipping_planes_vertex>
2874
+ vViewPosition = - mvPosition.xyz;
2875
+ #include <worldpos_vertex>
2876
+ #include <envmap_vertex>
2877
+ #include <shadowmap_vertex>
2878
+ #include <fog_vertex>
2879
+ }`,Qd=`#define LAMBERT
2880
+ uniform vec3 diffuse;
2881
+ uniform vec3 emissive;
2882
+ uniform float opacity;
2883
+ #include <common>
2884
+ #include <packing>
2885
+ #include <dithering_pars_fragment>
2886
+ #include <color_pars_fragment>
2887
+ #include <uv_pars_fragment>
2888
+ #include <map_pars_fragment>
2889
+ #include <alphamap_pars_fragment>
2890
+ #include <alphatest_pars_fragment>
2891
+ #include <alphahash_pars_fragment>
2892
+ #include <aomap_pars_fragment>
2893
+ #include <lightmap_pars_fragment>
2894
+ #include <emissivemap_pars_fragment>
2895
+ #include <envmap_common_pars_fragment>
2896
+ #include <envmap_pars_fragment>
2897
+ #include <fog_pars_fragment>
2898
+ #include <bsdfs>
2899
+ #include <lights_pars_begin>
2900
+ #include <normal_pars_fragment>
2901
+ #include <lights_lambert_pars_fragment>
2902
+ #include <shadowmap_pars_fragment>
2903
+ #include <bumpmap_pars_fragment>
2904
+ #include <normalmap_pars_fragment>
2905
+ #include <specularmap_pars_fragment>
2906
+ #include <logdepthbuf_pars_fragment>
2907
+ #include <clipping_planes_pars_fragment>
2908
+ void main() {
2909
+ vec4 diffuseColor = vec4( diffuse, opacity );
2910
+ #include <clipping_planes_fragment>
2911
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
2912
+ vec3 totalEmissiveRadiance = emissive;
2913
+ #include <logdepthbuf_fragment>
2914
+ #include <map_fragment>
2915
+ #include <color_fragment>
2916
+ #include <alphamap_fragment>
2917
+ #include <alphatest_fragment>
2918
+ #include <alphahash_fragment>
2919
+ #include <specularmap_fragment>
2920
+ #include <normal_fragment_begin>
2921
+ #include <normal_fragment_maps>
2922
+ #include <emissivemap_fragment>
2923
+ #include <lights_lambert_fragment>
2924
+ #include <lights_fragment_begin>
2925
+ #include <lights_fragment_maps>
2926
+ #include <lights_fragment_end>
2927
+ #include <aomap_fragment>
2928
+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
2929
+ #include <envmap_fragment>
2930
+ #include <opaque_fragment>
2931
+ #include <tonemapping_fragment>
2932
+ #include <colorspace_fragment>
2933
+ #include <fog_fragment>
2934
+ #include <premultiplied_alpha_fragment>
2935
+ #include <dithering_fragment>
2936
+ }`,tf=`#define MATCAP
2937
+ varying vec3 vViewPosition;
2938
+ #include <common>
2939
+ #include <batching_pars_vertex>
2940
+ #include <uv_pars_vertex>
2941
+ #include <color_pars_vertex>
2942
+ #include <displacementmap_pars_vertex>
2943
+ #include <fog_pars_vertex>
2944
+ #include <normal_pars_vertex>
2945
+ #include <morphtarget_pars_vertex>
2946
+ #include <skinning_pars_vertex>
2947
+ #include <logdepthbuf_pars_vertex>
2948
+ #include <clipping_planes_pars_vertex>
2949
+ void main() {
2950
+ #include <uv_vertex>
2951
+ #include <color_vertex>
2952
+ #include <morphinstance_vertex>
2953
+ #include <morphcolor_vertex>
2954
+ #include <batching_vertex>
2955
+ #include <beginnormal_vertex>
2956
+ #include <morphnormal_vertex>
2957
+ #include <skinbase_vertex>
2958
+ #include <skinnormal_vertex>
2959
+ #include <defaultnormal_vertex>
2960
+ #include <normal_vertex>
2961
+ #include <begin_vertex>
2962
+ #include <morphtarget_vertex>
2963
+ #include <skinning_vertex>
2964
+ #include <displacementmap_vertex>
2965
+ #include <project_vertex>
2966
+ #include <logdepthbuf_vertex>
2967
+ #include <clipping_planes_vertex>
2968
+ #include <fog_vertex>
2969
+ vViewPosition = - mvPosition.xyz;
2970
+ }`,ef=`#define MATCAP
2971
+ uniform vec3 diffuse;
2972
+ uniform float opacity;
2973
+ uniform sampler2D matcap;
2974
+ varying vec3 vViewPosition;
2975
+ #include <common>
2976
+ #include <dithering_pars_fragment>
2977
+ #include <color_pars_fragment>
2978
+ #include <uv_pars_fragment>
2979
+ #include <map_pars_fragment>
2980
+ #include <alphamap_pars_fragment>
2981
+ #include <alphatest_pars_fragment>
2982
+ #include <alphahash_pars_fragment>
2983
+ #include <fog_pars_fragment>
2984
+ #include <normal_pars_fragment>
2985
+ #include <bumpmap_pars_fragment>
2986
+ #include <normalmap_pars_fragment>
2987
+ #include <logdepthbuf_pars_fragment>
2988
+ #include <clipping_planes_pars_fragment>
2989
+ void main() {
2990
+ vec4 diffuseColor = vec4( diffuse, opacity );
2991
+ #include <clipping_planes_fragment>
2992
+ #include <logdepthbuf_fragment>
2993
+ #include <map_fragment>
2994
+ #include <color_fragment>
2995
+ #include <alphamap_fragment>
2996
+ #include <alphatest_fragment>
2997
+ #include <alphahash_fragment>
2998
+ #include <normal_fragment_begin>
2999
+ #include <normal_fragment_maps>
3000
+ vec3 viewDir = normalize( vViewPosition );
3001
+ vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
3002
+ vec3 y = cross( viewDir, x );
3003
+ vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
3004
+ #ifdef USE_MATCAP
3005
+ vec4 matcapColor = texture2D( matcap, uv );
3006
+ #else
3007
+ vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
3008
+ #endif
3009
+ vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
3010
+ #include <opaque_fragment>
3011
+ #include <tonemapping_fragment>
3012
+ #include <colorspace_fragment>
3013
+ #include <fog_fragment>
3014
+ #include <premultiplied_alpha_fragment>
3015
+ #include <dithering_fragment>
3016
+ }`,nf=`#define NORMAL
3017
+ #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3018
+ varying vec3 vViewPosition;
3019
+ #endif
3020
+ #include <common>
3021
+ #include <batching_pars_vertex>
3022
+ #include <uv_pars_vertex>
3023
+ #include <displacementmap_pars_vertex>
3024
+ #include <normal_pars_vertex>
3025
+ #include <morphtarget_pars_vertex>
3026
+ #include <skinning_pars_vertex>
3027
+ #include <logdepthbuf_pars_vertex>
3028
+ #include <clipping_planes_pars_vertex>
3029
+ void main() {
3030
+ #include <uv_vertex>
3031
+ #include <batching_vertex>
3032
+ #include <beginnormal_vertex>
3033
+ #include <morphinstance_vertex>
3034
+ #include <morphnormal_vertex>
3035
+ #include <skinbase_vertex>
3036
+ #include <skinnormal_vertex>
3037
+ #include <defaultnormal_vertex>
3038
+ #include <normal_vertex>
3039
+ #include <begin_vertex>
3040
+ #include <morphtarget_vertex>
3041
+ #include <skinning_vertex>
3042
+ #include <displacementmap_vertex>
3043
+ #include <project_vertex>
3044
+ #include <logdepthbuf_vertex>
3045
+ #include <clipping_planes_vertex>
3046
+ #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3047
+ vViewPosition = - mvPosition.xyz;
3048
+ #endif
3049
+ }`,rf=`#define NORMAL
3050
+ uniform float opacity;
3051
+ #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3052
+ varying vec3 vViewPosition;
3053
+ #endif
3054
+ #include <packing>
3055
+ #include <uv_pars_fragment>
3056
+ #include <normal_pars_fragment>
3057
+ #include <bumpmap_pars_fragment>
3058
+ #include <normalmap_pars_fragment>
3059
+ #include <logdepthbuf_pars_fragment>
3060
+ #include <clipping_planes_pars_fragment>
3061
+ void main() {
3062
+ vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
3063
+ #include <clipping_planes_fragment>
3064
+ #include <logdepthbuf_fragment>
3065
+ #include <normal_fragment_begin>
3066
+ #include <normal_fragment_maps>
3067
+ gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
3068
+ #ifdef OPAQUE
3069
+ gl_FragColor.a = 1.0;
3070
+ #endif
3071
+ }`,sf=`#define PHONG
3072
+ varying vec3 vViewPosition;
3073
+ #include <common>
3074
+ #include <batching_pars_vertex>
3075
+ #include <uv_pars_vertex>
3076
+ #include <displacementmap_pars_vertex>
3077
+ #include <envmap_pars_vertex>
3078
+ #include <color_pars_vertex>
3079
+ #include <fog_pars_vertex>
3080
+ #include <normal_pars_vertex>
3081
+ #include <morphtarget_pars_vertex>
3082
+ #include <skinning_pars_vertex>
3083
+ #include <shadowmap_pars_vertex>
3084
+ #include <logdepthbuf_pars_vertex>
3085
+ #include <clipping_planes_pars_vertex>
3086
+ void main() {
3087
+ #include <uv_vertex>
3088
+ #include <color_vertex>
3089
+ #include <morphcolor_vertex>
3090
+ #include <batching_vertex>
3091
+ #include <beginnormal_vertex>
3092
+ #include <morphinstance_vertex>
3093
+ #include <morphnormal_vertex>
3094
+ #include <skinbase_vertex>
3095
+ #include <skinnormal_vertex>
3096
+ #include <defaultnormal_vertex>
3097
+ #include <normal_vertex>
3098
+ #include <begin_vertex>
3099
+ #include <morphtarget_vertex>
3100
+ #include <skinning_vertex>
3101
+ #include <displacementmap_vertex>
3102
+ #include <project_vertex>
3103
+ #include <logdepthbuf_vertex>
3104
+ #include <clipping_planes_vertex>
3105
+ vViewPosition = - mvPosition.xyz;
3106
+ #include <worldpos_vertex>
3107
+ #include <envmap_vertex>
3108
+ #include <shadowmap_vertex>
3109
+ #include <fog_vertex>
3110
+ }`,af=`#define PHONG
3111
+ uniform vec3 diffuse;
3112
+ uniform vec3 emissive;
3113
+ uniform vec3 specular;
3114
+ uniform float shininess;
3115
+ uniform float opacity;
3116
+ #include <common>
3117
+ #include <packing>
3118
+ #include <dithering_pars_fragment>
3119
+ #include <color_pars_fragment>
3120
+ #include <uv_pars_fragment>
3121
+ #include <map_pars_fragment>
3122
+ #include <alphamap_pars_fragment>
3123
+ #include <alphatest_pars_fragment>
3124
+ #include <alphahash_pars_fragment>
3125
+ #include <aomap_pars_fragment>
3126
+ #include <lightmap_pars_fragment>
3127
+ #include <emissivemap_pars_fragment>
3128
+ #include <envmap_common_pars_fragment>
3129
+ #include <envmap_pars_fragment>
3130
+ #include <fog_pars_fragment>
3131
+ #include <bsdfs>
3132
+ #include <lights_pars_begin>
3133
+ #include <normal_pars_fragment>
3134
+ #include <lights_phong_pars_fragment>
3135
+ #include <shadowmap_pars_fragment>
3136
+ #include <bumpmap_pars_fragment>
3137
+ #include <normalmap_pars_fragment>
3138
+ #include <specularmap_pars_fragment>
3139
+ #include <logdepthbuf_pars_fragment>
3140
+ #include <clipping_planes_pars_fragment>
3141
+ void main() {
3142
+ vec4 diffuseColor = vec4( diffuse, opacity );
3143
+ #include <clipping_planes_fragment>
3144
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3145
+ vec3 totalEmissiveRadiance = emissive;
3146
+ #include <logdepthbuf_fragment>
3147
+ #include <map_fragment>
3148
+ #include <color_fragment>
3149
+ #include <alphamap_fragment>
3150
+ #include <alphatest_fragment>
3151
+ #include <alphahash_fragment>
3152
+ #include <specularmap_fragment>
3153
+ #include <normal_fragment_begin>
3154
+ #include <normal_fragment_maps>
3155
+ #include <emissivemap_fragment>
3156
+ #include <lights_phong_fragment>
3157
+ #include <lights_fragment_begin>
3158
+ #include <lights_fragment_maps>
3159
+ #include <lights_fragment_end>
3160
+ #include <aomap_fragment>
3161
+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
3162
+ #include <envmap_fragment>
3163
+ #include <opaque_fragment>
3164
+ #include <tonemapping_fragment>
3165
+ #include <colorspace_fragment>
3166
+ #include <fog_fragment>
3167
+ #include <premultiplied_alpha_fragment>
3168
+ #include <dithering_fragment>
3169
+ }`,of=`#define STANDARD
3170
+ varying vec3 vViewPosition;
3171
+ #ifdef USE_TRANSMISSION
3172
+ varying vec3 vWorldPosition;
3173
+ #endif
3174
+ #include <common>
3175
+ #include <batching_pars_vertex>
3176
+ #include <uv_pars_vertex>
3177
+ #include <displacementmap_pars_vertex>
3178
+ #include <color_pars_vertex>
3179
+ #include <fog_pars_vertex>
3180
+ #include <normal_pars_vertex>
3181
+ #include <morphtarget_pars_vertex>
3182
+ #include <skinning_pars_vertex>
3183
+ #include <shadowmap_pars_vertex>
3184
+ #include <logdepthbuf_pars_vertex>
3185
+ #include <clipping_planes_pars_vertex>
3186
+ void main() {
3187
+ #include <uv_vertex>
3188
+ #include <color_vertex>
3189
+ #include <morphinstance_vertex>
3190
+ #include <morphcolor_vertex>
3191
+ #include <batching_vertex>
3192
+ #include <beginnormal_vertex>
3193
+ #include <morphnormal_vertex>
3194
+ #include <skinbase_vertex>
3195
+ #include <skinnormal_vertex>
3196
+ #include <defaultnormal_vertex>
3197
+ #include <normal_vertex>
3198
+ #include <begin_vertex>
3199
+ #include <morphtarget_vertex>
3200
+ #include <skinning_vertex>
3201
+ #include <displacementmap_vertex>
3202
+ #include <project_vertex>
3203
+ #include <logdepthbuf_vertex>
3204
+ #include <clipping_planes_vertex>
3205
+ vViewPosition = - mvPosition.xyz;
3206
+ #include <worldpos_vertex>
3207
+ #include <shadowmap_vertex>
3208
+ #include <fog_vertex>
3209
+ #ifdef USE_TRANSMISSION
3210
+ vWorldPosition = worldPosition.xyz;
3211
+ #endif
3212
+ }`,lf=`#define STANDARD
3213
+ #ifdef PHYSICAL
3214
+ #define IOR
3215
+ #define USE_SPECULAR
3216
+ #endif
3217
+ uniform vec3 diffuse;
3218
+ uniform vec3 emissive;
3219
+ uniform float roughness;
3220
+ uniform float metalness;
3221
+ uniform float opacity;
3222
+ #ifdef IOR
3223
+ uniform float ior;
3224
+ #endif
3225
+ #ifdef USE_SPECULAR
3226
+ uniform float specularIntensity;
3227
+ uniform vec3 specularColor;
3228
+ #ifdef USE_SPECULAR_COLORMAP
3229
+ uniform sampler2D specularColorMap;
3230
+ #endif
3231
+ #ifdef USE_SPECULAR_INTENSITYMAP
3232
+ uniform sampler2D specularIntensityMap;
3233
+ #endif
3234
+ #endif
3235
+ #ifdef USE_CLEARCOAT
3236
+ uniform float clearcoat;
3237
+ uniform float clearcoatRoughness;
3238
+ #endif
3239
+ #ifdef USE_DISPERSION
3240
+ uniform float dispersion;
3241
+ #endif
3242
+ #ifdef USE_IRIDESCENCE
3243
+ uniform float iridescence;
3244
+ uniform float iridescenceIOR;
3245
+ uniform float iridescenceThicknessMinimum;
3246
+ uniform float iridescenceThicknessMaximum;
3247
+ #endif
3248
+ #ifdef USE_SHEEN
3249
+ uniform vec3 sheenColor;
3250
+ uniform float sheenRoughness;
3251
+ #ifdef USE_SHEEN_COLORMAP
3252
+ uniform sampler2D sheenColorMap;
3253
+ #endif
3254
+ #ifdef USE_SHEEN_ROUGHNESSMAP
3255
+ uniform sampler2D sheenRoughnessMap;
3256
+ #endif
3257
+ #endif
3258
+ #ifdef USE_ANISOTROPY
3259
+ uniform vec2 anisotropyVector;
3260
+ #ifdef USE_ANISOTROPYMAP
3261
+ uniform sampler2D anisotropyMap;
3262
+ #endif
3263
+ #endif
3264
+ varying vec3 vViewPosition;
3265
+ #include <common>
3266
+ #include <packing>
3267
+ #include <dithering_pars_fragment>
3268
+ #include <color_pars_fragment>
3269
+ #include <uv_pars_fragment>
3270
+ #include <map_pars_fragment>
3271
+ #include <alphamap_pars_fragment>
3272
+ #include <alphatest_pars_fragment>
3273
+ #include <alphahash_pars_fragment>
3274
+ #include <aomap_pars_fragment>
3275
+ #include <lightmap_pars_fragment>
3276
+ #include <emissivemap_pars_fragment>
3277
+ #include <iridescence_fragment>
3278
+ #include <cube_uv_reflection_fragment>
3279
+ #include <envmap_common_pars_fragment>
3280
+ #include <envmap_physical_pars_fragment>
3281
+ #include <fog_pars_fragment>
3282
+ #include <lights_pars_begin>
3283
+ #include <normal_pars_fragment>
3284
+ #include <lights_physical_pars_fragment>
3285
+ #include <transmission_pars_fragment>
3286
+ #include <shadowmap_pars_fragment>
3287
+ #include <bumpmap_pars_fragment>
3288
+ #include <normalmap_pars_fragment>
3289
+ #include <clearcoat_pars_fragment>
3290
+ #include <iridescence_pars_fragment>
3291
+ #include <roughnessmap_pars_fragment>
3292
+ #include <metalnessmap_pars_fragment>
3293
+ #include <logdepthbuf_pars_fragment>
3294
+ #include <clipping_planes_pars_fragment>
3295
+ void main() {
3296
+ vec4 diffuseColor = vec4( diffuse, opacity );
3297
+ #include <clipping_planes_fragment>
3298
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3299
+ vec3 totalEmissiveRadiance = emissive;
3300
+ #include <logdepthbuf_fragment>
3301
+ #include <map_fragment>
3302
+ #include <color_fragment>
3303
+ #include <alphamap_fragment>
3304
+ #include <alphatest_fragment>
3305
+ #include <alphahash_fragment>
3306
+ #include <roughnessmap_fragment>
3307
+ #include <metalnessmap_fragment>
3308
+ #include <normal_fragment_begin>
3309
+ #include <normal_fragment_maps>
3310
+ #include <clearcoat_normal_fragment_begin>
3311
+ #include <clearcoat_normal_fragment_maps>
3312
+ #include <emissivemap_fragment>
3313
+ #include <lights_physical_fragment>
3314
+ #include <lights_fragment_begin>
3315
+ #include <lights_fragment_maps>
3316
+ #include <lights_fragment_end>
3317
+ #include <aomap_fragment>
3318
+ vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
3319
+ vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
3320
+ #include <transmission_fragment>
3321
+ vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
3322
+ #ifdef USE_SHEEN
3323
+ float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
3324
+ outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
3325
+ #endif
3326
+ #ifdef USE_CLEARCOAT
3327
+ float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
3328
+ vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
3329
+ outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
3330
+ #endif
3331
+ #include <opaque_fragment>
3332
+ #include <tonemapping_fragment>
3333
+ #include <colorspace_fragment>
3334
+ #include <fog_fragment>
3335
+ #include <premultiplied_alpha_fragment>
3336
+ #include <dithering_fragment>
3337
+ }`,cf=`#define TOON
3338
+ varying vec3 vViewPosition;
3339
+ #include <common>
3340
+ #include <batching_pars_vertex>
3341
+ #include <uv_pars_vertex>
3342
+ #include <displacementmap_pars_vertex>
3343
+ #include <color_pars_vertex>
3344
+ #include <fog_pars_vertex>
3345
+ #include <normal_pars_vertex>
3346
+ #include <morphtarget_pars_vertex>
3347
+ #include <skinning_pars_vertex>
3348
+ #include <shadowmap_pars_vertex>
3349
+ #include <logdepthbuf_pars_vertex>
3350
+ #include <clipping_planes_pars_vertex>
3351
+ void main() {
3352
+ #include <uv_vertex>
3353
+ #include <color_vertex>
3354
+ #include <morphinstance_vertex>
3355
+ #include <morphcolor_vertex>
3356
+ #include <batching_vertex>
3357
+ #include <beginnormal_vertex>
3358
+ #include <morphnormal_vertex>
3359
+ #include <skinbase_vertex>
3360
+ #include <skinnormal_vertex>
3361
+ #include <defaultnormal_vertex>
3362
+ #include <normal_vertex>
3363
+ #include <begin_vertex>
3364
+ #include <morphtarget_vertex>
3365
+ #include <skinning_vertex>
3366
+ #include <displacementmap_vertex>
3367
+ #include <project_vertex>
3368
+ #include <logdepthbuf_vertex>
3369
+ #include <clipping_planes_vertex>
3370
+ vViewPosition = - mvPosition.xyz;
3371
+ #include <worldpos_vertex>
3372
+ #include <shadowmap_vertex>
3373
+ #include <fog_vertex>
3374
+ }`,hf=`#define TOON
3375
+ uniform vec3 diffuse;
3376
+ uniform vec3 emissive;
3377
+ uniform float opacity;
3378
+ #include <common>
3379
+ #include <packing>
3380
+ #include <dithering_pars_fragment>
3381
+ #include <color_pars_fragment>
3382
+ #include <uv_pars_fragment>
3383
+ #include <map_pars_fragment>
3384
+ #include <alphamap_pars_fragment>
3385
+ #include <alphatest_pars_fragment>
3386
+ #include <alphahash_pars_fragment>
3387
+ #include <aomap_pars_fragment>
3388
+ #include <lightmap_pars_fragment>
3389
+ #include <emissivemap_pars_fragment>
3390
+ #include <gradientmap_pars_fragment>
3391
+ #include <fog_pars_fragment>
3392
+ #include <bsdfs>
3393
+ #include <lights_pars_begin>
3394
+ #include <normal_pars_fragment>
3395
+ #include <lights_toon_pars_fragment>
3396
+ #include <shadowmap_pars_fragment>
3397
+ #include <bumpmap_pars_fragment>
3398
+ #include <normalmap_pars_fragment>
3399
+ #include <logdepthbuf_pars_fragment>
3400
+ #include <clipping_planes_pars_fragment>
3401
+ void main() {
3402
+ vec4 diffuseColor = vec4( diffuse, opacity );
3403
+ #include <clipping_planes_fragment>
3404
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3405
+ vec3 totalEmissiveRadiance = emissive;
3406
+ #include <logdepthbuf_fragment>
3407
+ #include <map_fragment>
3408
+ #include <color_fragment>
3409
+ #include <alphamap_fragment>
3410
+ #include <alphatest_fragment>
3411
+ #include <alphahash_fragment>
3412
+ #include <normal_fragment_begin>
3413
+ #include <normal_fragment_maps>
3414
+ #include <emissivemap_fragment>
3415
+ #include <lights_toon_fragment>
3416
+ #include <lights_fragment_begin>
3417
+ #include <lights_fragment_maps>
3418
+ #include <lights_fragment_end>
3419
+ #include <aomap_fragment>
3420
+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
3421
+ #include <opaque_fragment>
3422
+ #include <tonemapping_fragment>
3423
+ #include <colorspace_fragment>
3424
+ #include <fog_fragment>
3425
+ #include <premultiplied_alpha_fragment>
3426
+ #include <dithering_fragment>
3427
+ }`,uf=`uniform float size;
3428
+ uniform float scale;
3429
+ #include <common>
3430
+ #include <color_pars_vertex>
3431
+ #include <fog_pars_vertex>
3432
+ #include <morphtarget_pars_vertex>
3433
+ #include <logdepthbuf_pars_vertex>
3434
+ #include <clipping_planes_pars_vertex>
3435
+ #ifdef USE_POINTS_UV
3436
+ varying vec2 vUv;
3437
+ uniform mat3 uvTransform;
3438
+ #endif
3439
+ void main() {
3440
+ #ifdef USE_POINTS_UV
3441
+ vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
3442
+ #endif
3443
+ #include <color_vertex>
3444
+ #include <morphinstance_vertex>
3445
+ #include <morphcolor_vertex>
3446
+ #include <begin_vertex>
3447
+ #include <morphtarget_vertex>
3448
+ #include <project_vertex>
3449
+ gl_PointSize = size;
3450
+ #ifdef USE_SIZEATTENUATION
3451
+ bool isPerspective = isPerspectiveMatrix( projectionMatrix );
3452
+ if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
3453
+ #endif
3454
+ #include <logdepthbuf_vertex>
3455
+ #include <clipping_planes_vertex>
3456
+ #include <worldpos_vertex>
3457
+ #include <fog_vertex>
3458
+ }`,df=`uniform vec3 diffuse;
3459
+ uniform float opacity;
3460
+ #include <common>
3461
+ #include <color_pars_fragment>
3462
+ #include <map_particle_pars_fragment>
3463
+ #include <alphatest_pars_fragment>
3464
+ #include <alphahash_pars_fragment>
3465
+ #include <fog_pars_fragment>
3466
+ #include <logdepthbuf_pars_fragment>
3467
+ #include <clipping_planes_pars_fragment>
3468
+ void main() {
3469
+ vec4 diffuseColor = vec4( diffuse, opacity );
3470
+ #include <clipping_planes_fragment>
3471
+ vec3 outgoingLight = vec3( 0.0 );
3472
+ #include <logdepthbuf_fragment>
3473
+ #include <map_particle_fragment>
3474
+ #include <color_fragment>
3475
+ #include <alphatest_fragment>
3476
+ #include <alphahash_fragment>
3477
+ outgoingLight = diffuseColor.rgb;
3478
+ #include <opaque_fragment>
3479
+ #include <tonemapping_fragment>
3480
+ #include <colorspace_fragment>
3481
+ #include <fog_fragment>
3482
+ #include <premultiplied_alpha_fragment>
3483
+ }`,ff=`#include <common>
3484
+ #include <batching_pars_vertex>
3485
+ #include <fog_pars_vertex>
3486
+ #include <morphtarget_pars_vertex>
3487
+ #include <skinning_pars_vertex>
3488
+ #include <logdepthbuf_pars_vertex>
3489
+ #include <shadowmap_pars_vertex>
3490
+ void main() {
3491
+ #include <batching_vertex>
3492
+ #include <beginnormal_vertex>
3493
+ #include <morphinstance_vertex>
3494
+ #include <morphnormal_vertex>
3495
+ #include <skinbase_vertex>
3496
+ #include <skinnormal_vertex>
3497
+ #include <defaultnormal_vertex>
3498
+ #include <begin_vertex>
3499
+ #include <morphtarget_vertex>
3500
+ #include <skinning_vertex>
3501
+ #include <project_vertex>
3502
+ #include <logdepthbuf_vertex>
3503
+ #include <worldpos_vertex>
3504
+ #include <shadowmap_vertex>
3505
+ #include <fog_vertex>
3506
+ }`,pf=`uniform vec3 color;
3507
+ uniform float opacity;
3508
+ #include <common>
3509
+ #include <packing>
3510
+ #include <fog_pars_fragment>
3511
+ #include <bsdfs>
3512
+ #include <lights_pars_begin>
3513
+ #include <logdepthbuf_pars_fragment>
3514
+ #include <shadowmap_pars_fragment>
3515
+ #include <shadowmask_pars_fragment>
3516
+ void main() {
3517
+ #include <logdepthbuf_fragment>
3518
+ gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
3519
+ #include <tonemapping_fragment>
3520
+ #include <colorspace_fragment>
3521
+ #include <fog_fragment>
3522
+ }`,mf=`uniform float rotation;
3523
+ uniform vec2 center;
3524
+ #include <common>
3525
+ #include <uv_pars_vertex>
3526
+ #include <fog_pars_vertex>
3527
+ #include <logdepthbuf_pars_vertex>
3528
+ #include <clipping_planes_pars_vertex>
3529
+ void main() {
3530
+ #include <uv_vertex>
3531
+ vec4 mvPosition = modelViewMatrix[ 3 ];
3532
+ vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
3533
+ #ifndef USE_SIZEATTENUATION
3534
+ bool isPerspective = isPerspectiveMatrix( projectionMatrix );
3535
+ if ( isPerspective ) scale *= - mvPosition.z;
3536
+ #endif
3537
+ vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
3538
+ vec2 rotatedPosition;
3539
+ rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
3540
+ rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
3541
+ mvPosition.xy += rotatedPosition;
3542
+ gl_Position = projectionMatrix * mvPosition;
3543
+ #include <logdepthbuf_vertex>
3544
+ #include <clipping_planes_vertex>
3545
+ #include <fog_vertex>
3546
+ }`,gf=`uniform vec3 diffuse;
3547
+ uniform float opacity;
3548
+ #include <common>
3549
+ #include <uv_pars_fragment>
3550
+ #include <map_pars_fragment>
3551
+ #include <alphamap_pars_fragment>
3552
+ #include <alphatest_pars_fragment>
3553
+ #include <alphahash_pars_fragment>
3554
+ #include <fog_pars_fragment>
3555
+ #include <logdepthbuf_pars_fragment>
3556
+ #include <clipping_planes_pars_fragment>
3557
+ void main() {
3558
+ vec4 diffuseColor = vec4( diffuse, opacity );
3559
+ #include <clipping_planes_fragment>
3560
+ vec3 outgoingLight = vec3( 0.0 );
3561
+ #include <logdepthbuf_fragment>
3562
+ #include <map_fragment>
3563
+ #include <alphamap_fragment>
3564
+ #include <alphatest_fragment>
3565
+ #include <alphahash_fragment>
3566
+ outgoingLight = diffuseColor.rgb;
3567
+ #include <opaque_fragment>
3568
+ #include <tonemapping_fragment>
3569
+ #include <colorspace_fragment>
3570
+ #include <fog_fragment>
3571
+ }`,Lt={alphahash_fragment:Oh,alphahash_pars_fragment:Bh,alphamap_fragment:zh,alphamap_pars_fragment:Vh,alphatest_fragment:Hh,alphatest_pars_fragment:kh,aomap_fragment:Gh,aomap_pars_fragment:Wh,batching_pars_vertex:Xh,batching_vertex:qh,begin_vertex:Yh,beginnormal_vertex:Kh,bsdfs:Zh,iridescence_fragment:$h,bumpmap_pars_fragment:jh,clipping_planes_fragment:Jh,clipping_planes_pars_fragment:Qh,clipping_planes_pars_vertex:tu,clipping_planes_vertex:eu,color_fragment:nu,color_pars_fragment:iu,color_pars_vertex:ru,color_vertex:su,common:au,cube_uv_reflection_fragment:ou,defaultnormal_vertex:lu,displacementmap_pars_vertex:cu,displacementmap_vertex:hu,emissivemap_fragment:uu,emissivemap_pars_fragment:du,colorspace_fragment:fu,colorspace_pars_fragment:pu,envmap_fragment:mu,envmap_common_pars_fragment:gu,envmap_pars_fragment:_u,envmap_pars_vertex:vu,envmap_physical_pars_fragment:Cu,envmap_vertex:xu,fog_vertex:Mu,fog_pars_vertex:Su,fog_fragment:yu,fog_pars_fragment:Eu,gradientmap_pars_fragment:Tu,lightmap_pars_fragment:bu,lights_lambert_fragment:Au,lights_lambert_pars_fragment:wu,lights_pars_begin:Ru,lights_toon_fragment:Pu,lights_toon_pars_fragment:Lu,lights_phong_fragment:Du,lights_phong_pars_fragment:Iu,lights_physical_fragment:Uu,lights_physical_pars_fragment:Nu,lights_fragment_begin:Fu,lights_fragment_maps:Ou,lights_fragment_end:Bu,logdepthbuf_fragment:zu,logdepthbuf_pars_fragment:Vu,logdepthbuf_pars_vertex:Hu,logdepthbuf_vertex:ku,map_fragment:Gu,map_pars_fragment:Wu,map_particle_fragment:Xu,map_particle_pars_fragment:qu,metalnessmap_fragment:Yu,metalnessmap_pars_fragment:Ku,morphinstance_vertex:Zu,morphcolor_vertex:$u,morphnormal_vertex:ju,morphtarget_pars_vertex:Ju,morphtarget_vertex:Qu,normal_fragment_begin:td,normal_fragment_maps:ed,normal_pars_fragment:nd,normal_pars_vertex:id,normal_vertex:rd,normalmap_pars_fragment:sd,clearcoat_normal_fragment_begin:ad,clearcoat_normal_fragment_maps:od,clearcoat_pars_fragment:ld,iridescence_pars_fragment:cd,opaque_fragment:hd,packing:ud,premultiplied_alpha_fragment:dd,project_vertex:fd,dithering_fragment:pd,dithering_pars_fragment:md,roughnessmap_fragment:gd,roughnessmap_pars_fragment:_d,shadowmap_pars_fragment:vd,shadowmap_pars_vertex:xd,shadowmap_vertex:Md,shadowmask_pars_fragment:Sd,skinbase_vertex:yd,skinning_pars_vertex:Ed,skinning_vertex:Td,skinnormal_vertex:bd,specularmap_fragment:Ad,specularmap_pars_fragment:wd,tonemapping_fragment:Rd,tonemapping_pars_fragment:Cd,transmission_fragment:Pd,transmission_pars_fragment:Ld,uv_pars_fragment:Dd,uv_pars_vertex:Id,uv_vertex:Ud,worldpos_vertex:Nd,background_vert:Fd,background_frag:Od,backgroundCube_vert:Bd,backgroundCube_frag:zd,cube_vert:Vd,cube_frag:Hd,depth_vert:kd,depth_frag:Gd,distanceRGBA_vert:Wd,distanceRGBA_frag:Xd,equirect_vert:qd,equirect_frag:Yd,linedashed_vert:Kd,linedashed_frag:Zd,meshbasic_vert:$d,meshbasic_frag:jd,meshlambert_vert:Jd,meshlambert_frag:Qd,meshmatcap_vert:tf,meshmatcap_frag:ef,meshnormal_vert:nf,meshnormal_frag:rf,meshphong_vert:sf,meshphong_frag:af,meshphysical_vert:of,meshphysical_frag:lf,meshtoon_vert:cf,meshtoon_frag:hf,points_vert:uf,points_frag:df,shadow_vert:ff,shadow_frag:pf,sprite_vert:mf,sprite_frag:gf},et={common:{diffuse:{value:new It(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ct},alphaMap:{value:null},alphaMapTransform:{value:new Ct},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ct}},envmap:{envMap:{value:null},envMapRotation:{value:new Ct},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ct}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ct}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ct},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ct},normalScale:{value:new Ft(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ct},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ct}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ct}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ct}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new It(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new It(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ct},alphaTest:{value:0},uvTransform:{value:new Ct}},sprite:{diffuse:{value:new It(16777215)},opacity:{value:1},center:{value:new Ft(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ct},alphaMap:{value:null},alphaMapTransform:{value:new Ct},alphaTest:{value:0}}},Xe={basic:{uniforms:_e([et.common,et.specularmap,et.envmap,et.aomap,et.lightmap,et.fog]),vertexShader:Lt.meshbasic_vert,fragmentShader:Lt.meshbasic_frag},lambert:{uniforms:_e([et.common,et.specularmap,et.envmap,et.aomap,et.lightmap,et.emissivemap,et.bumpmap,et.normalmap,et.displacementmap,et.fog,et.lights,{emissive:{value:new It(0)}}]),vertexShader:Lt.meshlambert_vert,fragmentShader:Lt.meshlambert_frag},phong:{uniforms:_e([et.common,et.specularmap,et.envmap,et.aomap,et.lightmap,et.emissivemap,et.bumpmap,et.normalmap,et.displacementmap,et.fog,et.lights,{emissive:{value:new It(0)},specular:{value:new It(1118481)},shininess:{value:30}}]),vertexShader:Lt.meshphong_vert,fragmentShader:Lt.meshphong_frag},standard:{uniforms:_e([et.common,et.envmap,et.aomap,et.lightmap,et.emissivemap,et.bumpmap,et.normalmap,et.displacementmap,et.roughnessmap,et.metalnessmap,et.fog,et.lights,{emissive:{value:new It(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Lt.meshphysical_vert,fragmentShader:Lt.meshphysical_frag},toon:{uniforms:_e([et.common,et.aomap,et.lightmap,et.emissivemap,et.bumpmap,et.normalmap,et.displacementmap,et.gradientmap,et.fog,et.lights,{emissive:{value:new It(0)}}]),vertexShader:Lt.meshtoon_vert,fragmentShader:Lt.meshtoon_frag},matcap:{uniforms:_e([et.common,et.bumpmap,et.normalmap,et.displacementmap,et.fog,{matcap:{value:null}}]),vertexShader:Lt.meshmatcap_vert,fragmentShader:Lt.meshmatcap_frag},points:{uniforms:_e([et.points,et.fog]),vertexShader:Lt.points_vert,fragmentShader:Lt.points_frag},dashed:{uniforms:_e([et.common,et.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Lt.linedashed_vert,fragmentShader:Lt.linedashed_frag},depth:{uniforms:_e([et.common,et.displacementmap]),vertexShader:Lt.depth_vert,fragmentShader:Lt.depth_frag},normal:{uniforms:_e([et.common,et.bumpmap,et.normalmap,et.displacementmap,{opacity:{value:1}}]),vertexShader:Lt.meshnormal_vert,fragmentShader:Lt.meshnormal_frag},sprite:{uniforms:_e([et.sprite,et.fog]),vertexShader:Lt.sprite_vert,fragmentShader:Lt.sprite_frag},background:{uniforms:{uvTransform:{value:new Ct},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Lt.background_vert,fragmentShader:Lt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ct}},vertexShader:Lt.backgroundCube_vert,fragmentShader:Lt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Lt.cube_vert,fragmentShader:Lt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Lt.equirect_vert,fragmentShader:Lt.equirect_frag},distanceRGBA:{uniforms:_e([et.common,et.displacementmap,{referencePosition:{value:new L},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Lt.distanceRGBA_vert,fragmentShader:Lt.distanceRGBA_frag},shadow:{uniforms:_e([et.lights,et.fog,{color:{value:new It(0)},opacity:{value:1}}]),vertexShader:Lt.shadow_vert,fragmentShader:Lt.shadow_frag}};Xe.physical={uniforms:_e([Xe.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ct},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ct},clearcoatNormalScale:{value:new Ft(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ct},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ct},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ct},sheen:{value:0},sheenColor:{value:new It(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ct},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ct},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ct},transmissionSamplerSize:{value:new Ft},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ct},attenuationDistance:{value:0},attenuationColor:{value:new It(0)},specularColor:{value:new It(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ct},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ct},anisotropyVector:{value:new Ft},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ct}}]),vertexShader:Lt.meshphysical_vert,fragmentShader:Lt.meshphysical_frag};const dr={r:0,b:0,g:0},In=new Ye,_f=new Dt;function vf(i,t,e,n,r,s,a){const o=new It(0);let l=s===!0?0:1,c,h,u=null,d=0,p=null;function g(b){let T=b.isScene===!0?b.background:null;return T&&T.isTexture&&(T=(b.backgroundBlurriness>0?e:t).get(T)),T}function v(b){let T=!1;const S=g(b);S===null?f(o,l):S&&S.isColor&&(f(S,1),T=!0);const B=i.xr.getEnvironmentBlendMode();B==="additive"?n.buffers.color.setClear(0,0,0,1,a):B==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(i.autoClear||T)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function m(b,T){const S=g(T);S&&(S.isCubeTexture||S.mapping===Fr)?(h===void 0&&(h=new we(new Gi(1,1,1),new An({name:"BackgroundCubeMaterial",uniforms:mi(Xe.backgroundCube.uniforms),vertexShader:Xe.backgroundCube.vertexShader,fragmentShader:Xe.backgroundCube.fragmentShader,side:Me,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(B,A,w){this.matrixWorld.copyPosition(w.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(h)),In.copy(T.backgroundRotation),In.x*=-1,In.y*=-1,In.z*=-1,S.isCubeTexture&&S.isRenderTargetTexture===!1&&(In.y*=-1,In.z*=-1),h.material.uniforms.envMap.value=S,h.material.uniforms.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=T.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(_f.makeRotationFromEuler(In)),h.material.toneMapped=Vt.getTransfer(S.colorSpace)!==$t,(u!==S||d!==S.version||p!==i.toneMapping)&&(h.material.needsUpdate=!0,u=S,d=S.version,p=i.toneMapping),h.layers.enableAll(),b.unshift(h,h.geometry,h.material,0,0,null)):S&&S.isTexture&&(c===void 0&&(c=new we(new Wi(2,2),new An({name:"BackgroundMaterial",uniforms:mi(Xe.background.uniforms),vertexShader:Xe.background.vertexShader,fragmentShader:Xe.background.fragmentShader,side:ln,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=S,c.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,c.material.toneMapped=Vt.getTransfer(S.colorSpace)!==$t,S.matrixAutoUpdate===!0&&S.updateMatrix(),c.material.uniforms.uvTransform.value.copy(S.matrix),(u!==S||d!==S.version||p!==i.toneMapping)&&(c.material.needsUpdate=!0,u=S,d=S.version,p=i.toneMapping),c.layers.enableAll(),b.unshift(c,c.geometry,c.material,0,0,null))}function f(b,T){b.getRGB(dr,Il(i)),n.buffers.color.setClear(dr.r,dr.g,dr.b,T,a)}return{getClearColor:function(){return o},setClearColor:function(b,T=1){o.set(b),l=T,f(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(b){l=b,f(o,l)},render:v,addToRenderList:m}}function xf(i,t){const e=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=d(null);let s=r,a=!1;function o(M,R,q,z,W){let $=!1;const k=u(z,q,R);s!==k&&(s=k,c(s.object)),$=p(M,z,q,W),$&&g(M,z,q,W),W!==null&&t.update(W,i.ELEMENT_ARRAY_BUFFER),($||a)&&(a=!1,S(M,R,q,z),W!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t.get(W).buffer))}function l(){return i.createVertexArray()}function c(M){return i.bindVertexArray(M)}function h(M){return i.deleteVertexArray(M)}function u(M,R,q){const z=q.wireframe===!0;let W=n[M.id];W===void 0&&(W={},n[M.id]=W);let $=W[R.id];$===void 0&&($={},W[R.id]=$);let k=$[z];return k===void 0&&(k=d(l()),$[z]=k),k}function d(M){const R=[],q=[],z=[];for(let W=0;W<e;W++)R[W]=0,q[W]=0,z[W]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:R,enabledAttributes:q,attributeDivisors:z,object:M,attributes:{},index:null}}function p(M,R,q,z){const W=s.attributes,$=R.attributes;let k=0;const Q=q.getAttributes();for(const H in Q)if(Q[H].location>=0){const ct=W[H];let xt=$[H];if(xt===void 0&&(H==="instanceMatrix"&&M.instanceMatrix&&(xt=M.instanceMatrix),H==="instanceColor"&&M.instanceColor&&(xt=M.instanceColor)),ct===void 0||ct.attribute!==xt||xt&&ct.data!==xt.data)return!0;k++}return s.attributesNum!==k||s.index!==z}function g(M,R,q,z){const W={},$=R.attributes;let k=0;const Q=q.getAttributes();for(const H in Q)if(Q[H].location>=0){let ct=$[H];ct===void 0&&(H==="instanceMatrix"&&M.instanceMatrix&&(ct=M.instanceMatrix),H==="instanceColor"&&M.instanceColor&&(ct=M.instanceColor));const xt={};xt.attribute=ct,ct&&ct.data&&(xt.data=ct.data),W[H]=xt,k++}s.attributes=W,s.attributesNum=k,s.index=z}function v(){const M=s.newAttributes;for(let R=0,q=M.length;R<q;R++)M[R]=0}function m(M){f(M,0)}function f(M,R){const q=s.newAttributes,z=s.enabledAttributes,W=s.attributeDivisors;q[M]=1,z[M]===0&&(i.enableVertexAttribArray(M),z[M]=1),W[M]!==R&&(i.vertexAttribDivisor(M,R),W[M]=R)}function b(){const M=s.newAttributes,R=s.enabledAttributes;for(let q=0,z=R.length;q<z;q++)R[q]!==M[q]&&(i.disableVertexAttribArray(q),R[q]=0)}function T(M,R,q,z,W,$,k){k===!0?i.vertexAttribIPointer(M,R,q,W,$):i.vertexAttribPointer(M,R,q,z,W,$)}function S(M,R,q,z){v();const W=z.attributes,$=q.getAttributes(),k=R.defaultAttributeValues;for(const Q in $){const H=$[Q];if(H.location>=0){let it=W[Q];if(it===void 0&&(Q==="instanceMatrix"&&M.instanceMatrix&&(it=M.instanceMatrix),Q==="instanceColor"&&M.instanceColor&&(it=M.instanceColor)),it!==void 0){const ct=it.normalized,xt=it.itemSize,Ut=t.get(it);if(Ut===void 0)continue;const jt=Ut.buffer,X=Ut.type,tt=Ut.bytesPerElement,gt=X===i.INT||X===i.UNSIGNED_INT||it.gpuType===da;if(it.isInterleavedBufferAttribute){const rt=it.data,Et=rt.stride,At=it.offset;if(rt.isInstancedInterleavedBuffer){for(let Nt=0;Nt<H.locationSize;Nt++)f(H.location+Nt,rt.meshPerAttribute);M.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=rt.meshPerAttribute*rt.count)}else for(let Nt=0;Nt<H.locationSize;Nt++)m(H.location+Nt);i.bindBuffer(i.ARRAY_BUFFER,jt);for(let Nt=0;Nt<H.locationSize;Nt++)T(H.location+Nt,xt/H.locationSize,X,ct,Et*tt,(At+xt/H.locationSize*Nt)*tt,gt)}else{if(it.isInstancedBufferAttribute){for(let rt=0;rt<H.locationSize;rt++)f(H.location+rt,it.meshPerAttribute);M.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=it.meshPerAttribute*it.count)}else for(let rt=0;rt<H.locationSize;rt++)m(H.location+rt);i.bindBuffer(i.ARRAY_BUFFER,jt);for(let rt=0;rt<H.locationSize;rt++)T(H.location+rt,xt/H.locationSize,X,ct,xt*tt,xt/H.locationSize*rt*tt,gt)}}else if(k!==void 0){const ct=k[Q];if(ct!==void 0)switch(ct.length){case 2:i.vertexAttrib2fv(H.location,ct);break;case 3:i.vertexAttrib3fv(H.location,ct);break;case 4:i.vertexAttrib4fv(H.location,ct);break;default:i.vertexAttrib1fv(H.location,ct)}}}}b()}function B(){U();for(const M in n){const R=n[M];for(const q in R){const z=R[q];for(const W in z)h(z[W].object),delete z[W];delete R[q]}delete n[M]}}function A(M){if(n[M.id]===void 0)return;const R=n[M.id];for(const q in R){const z=R[q];for(const W in z)h(z[W].object),delete z[W];delete R[q]}delete n[M.id]}function w(M){for(const R in n){const q=n[R];if(q[M.id]===void 0)continue;const z=q[M.id];for(const W in z)h(z[W].object),delete z[W];delete q[M.id]}}function U(){y(),a=!0,s!==r&&(s=r,c(s.object))}function y(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:U,resetDefaultState:y,dispose:B,releaseStatesOfGeometry:A,releaseStatesOfProgram:w,initAttributes:v,enableAttribute:m,disableUnusedAttributes:b}}function Mf(i,t,e){let n;function r(c){n=c}function s(c,h){i.drawArrays(n,c,h),e.update(h,n,1)}function a(c,h,u){u!==0&&(i.drawArraysInstanced(n,c,h,u),e.update(h,n,u))}function o(c,h,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,h,0,u);let p=0;for(let g=0;g<u;g++)p+=h[g];e.update(p,n,1)}function l(c,h,u,d){if(u===0)return;const p=t.get("WEBGL_multi_draw");if(p===null)for(let g=0;g<c.length;g++)a(c[g],h[g],d[g]);else{p.multiDrawArraysInstancedWEBGL(n,c,0,h,0,d,0,u);let g=0;for(let v=0;v<u;v++)g+=h[v]*d[v];e.update(g,n,1)}}this.setMode=r,this.render=s,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function Sf(i,t,e,n){let r;function s(){if(r!==void 0)return r;if(t.has("EXT_texture_filter_anisotropic")===!0){const w=t.get("EXT_texture_filter_anisotropic");r=i.getParameter(w.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(w){return!(w!==De&&n.convert(w)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(w){const U=w===ki&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(w!==cn&&n.convert(w)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&w!==ke&&!U)}function l(w){if(w==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";w="mediump"}return w==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=e.precision!==void 0?e.precision:"highp";const h=l(c);h!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const u=e.logarithmicDepthBuffer===!0,d=e.reverseDepthBuffer===!0&&t.has("EXT_clip_control"),p=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),g=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=i.getParameter(i.MAX_TEXTURE_SIZE),m=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),f=i.getParameter(i.MAX_VERTEX_ATTRIBS),b=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),T=i.getParameter(i.MAX_VARYING_VECTORS),S=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),B=g>0,A=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:u,reverseDepthBuffer:d,maxTextures:p,maxVertexTextures:g,maxTextureSize:v,maxCubemapSize:m,maxAttributes:f,maxVertexUniforms:b,maxVaryings:T,maxFragmentUniforms:S,vertexTextures:B,maxSamples:A}}function yf(i){const t=this;let e=null,n=0,r=!1,s=!1;const a=new xn,o=new Ct,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const p=u.length!==0||d||n!==0||r;return r=d,n=u.length,p},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(u,d){e=h(u,d,0)},this.setState=function(u,d,p){const g=u.clippingPlanes,v=u.clipIntersection,m=u.clipShadows,f=i.get(u);if(!r||g===null||g.length===0||s&&!m)s?h(null):c();else{const b=s?0:n,T=b*4;let S=f.clippingState||null;l.value=S,S=h(g,d,T,p);for(let B=0;B!==T;++B)S[B]=e[B];f.clippingState=S,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=b}};function c(){l.value!==e&&(l.value=e,l.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(u,d,p,g){const v=u!==null?u.length:0;let m=null;if(v!==0){if(m=l.value,g!==!0||m===null){const f=p+v*4,b=d.matrixWorldInverse;o.getNormalMatrix(b),(m===null||m.length<f)&&(m=new Float32Array(f));for(let T=0,S=p;T!==v;++T,S+=4)a.copy(u[T]).applyMatrix4(b,o),a.normal.toArray(m,S),m[S+3]=a.constant}l.value=m,l.needsUpdate=!0}return t.numPlanes=v,t.numIntersection=0,m}}function Ef(i){let t=new WeakMap;function e(a,o){return o===Is?a.mapping=hi:o===Us&&(a.mapping=ui),a}function n(a){if(a&&a.isTexture){const o=a.mapping;if(o===Is||o===Us)if(t.has(a)){const l=t.get(a).texture;return e(l,a.mapping)}else{const l=a.image;if(l&&l.height>0){const c=new Ih(l.height);return c.fromEquirectangularTexture(i,a),t.set(a,c),a.addEventListener("dispose",r),e(c.texture,a.mapping)}else return null}}return a}function r(a){const o=a.target;o.removeEventListener("dispose",r);const l=t.get(o);l!==void 0&&(t.delete(o),l.dispose())}function s(){t=new WeakMap}return{get:n,dispose:s}}class Ea extends Ul{constructor(t=-1,e=1,n=1,r=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=r,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,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=t,this.view.fullHeight=e,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 t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let s=n-t,a=n+t,o=r+e,l=r-e;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}}const si=4,So=[.125,.215,.35,.446,.526,.582],On=20,cs=new Ea,yo=new It;let hs=null,us=0,ds=0,fs=!1;const Nn=(1+Math.sqrt(5))/2,ii=1/Nn,Eo=[new L(-Nn,ii,0),new L(Nn,ii,0),new L(-ii,0,Nn),new L(ii,0,Nn),new L(0,Nn,-ii),new L(0,Nn,ii),new L(-1,1,-1),new L(1,1,-1),new L(-1,1,1),new L(1,1,1)];class To{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,n=.1,r=100){hs=this._renderer.getRenderTarget(),us=this._renderer.getActiveCubeFace(),ds=this._renderer.getActiveMipmapLevel(),fs=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(t,n,r,s),e>0&&this._blur(s,0,0,e),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=wo(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Ao(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(hs,us,ds),this._renderer.xr.enabled=fs,t.scissorTest=!1,fr(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===hi||t.mapping===ui?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),hs=this._renderer.getRenderTarget(),us=this._renderer.getActiveCubeFace(),ds=this._renderer.getActiveMipmapLevel(),fs=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:He,minFilter:He,generateMipmaps:!1,type:ki,format:De,colorSpace:Vn,depthBuffer:!1},r=bo(t,e,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=bo(t,e,n);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Tf(s)),this._blurMaterial=bf(s,t,e)}return r}_compileMaterial(t){const e=new we(this._lodPlanes[0],t);this._renderer.compile(e,cs)}_sceneToCubeUV(t,e,n,r){const o=new xe(90,1,e,n),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],h=this._renderer,u=h.autoClear,d=h.toneMapping;h.getClearColor(yo),h.toneMapping=bn,h.autoClear=!1;const p=new Sa({name:"PMREM.Background",side:Me,depthWrite:!1,depthTest:!1}),g=new we(new Gi,p);let v=!1;const m=t.background;m?m.isColor&&(p.color.copy(m),t.background=null,v=!0):(p.color.copy(yo),v=!0);for(let f=0;f<6;f++){const b=f%3;b===0?(o.up.set(0,l[f],0),o.lookAt(c[f],0,0)):b===1?(o.up.set(0,0,l[f]),o.lookAt(0,c[f],0)):(o.up.set(0,l[f],0),o.lookAt(0,0,c[f]));const T=this._cubeSize;fr(r,b*T,f>2?T:0,T,T),h.setRenderTarget(r),v&&h.render(g,o),h.render(t,o)}g.geometry.dispose(),g.material.dispose(),h.toneMapping=d,h.autoClear=u,t.background=m}_textureToCubeUV(t,e){const n=this._renderer,r=t.mapping===hi||t.mapping===ui;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=wo()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Ao());const s=r?this._cubemapMaterial:this._equirectMaterial,a=new we(this._lodPlanes[0],s),o=s.uniforms;o.envMap.value=t;const l=this._cubeSize;fr(e,0,0,3*l,2*l),n.setRenderTarget(e),n.render(a,cs)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const r=this._lodPlanes.length;for(let s=1;s<r;s++){const a=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),o=Eo[(r-s-1)%Eo.length];this._blur(t,s-1,s,a,o)}e.autoClear=n}_blur(t,e,n,r,s){const a=this._pingPongRenderTarget;this._halfBlur(t,a,e,n,r,"latitudinal",s),this._halfBlur(a,t,n,n,r,"longitudinal",s)}_halfBlur(t,e,n,r,s,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const h=3,u=new we(this._lodPlanes[r],c),d=c.uniforms,p=this._sizeLods[n]-1,g=isFinite(s)?Math.PI/(2*p):2*Math.PI/(2*On-1),v=s/g,m=isFinite(s)?1+Math.floor(h*v):On;m>On&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${On}`);const f=[];let b=0;for(let w=0;w<On;++w){const U=w/v,y=Math.exp(-U*U/2);f.push(y),w===0?b+=y:w<m&&(b+=2*y)}for(let w=0;w<f.length;w++)f[w]=f[w]/b;d.envMap.value=t.texture,d.samples.value=m,d.weights.value=f,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:T}=this;d.dTheta.value=g,d.mipInt.value=T-n;const S=this._sizeLods[r],B=3*S*(r>T-si?r-T+si:0),A=4*(this._cubeSize-S);fr(e,B,A,3*S,2*S),l.setRenderTarget(e),l.render(u,cs)}}function Tf(i){const t=[],e=[],n=[];let r=i;const s=i-si+1+So.length;for(let a=0;a<s;a++){const o=Math.pow(2,r);e.push(o);let l=1/o;a>i-si?l=So[a-i+si-1]:a===0&&(l=0),n.push(l);const c=1/(o-2),h=-c,u=1+c,d=[h,h,u,h,u,u,h,h,u,u,h,u],p=6,g=6,v=3,m=2,f=1,b=new Float32Array(v*g*p),T=new Float32Array(m*g*p),S=new Float32Array(f*g*p);for(let A=0;A<p;A++){const w=A%3*2/3-1,U=A>2?0:-1,y=[w,U,0,w+2/3,U,0,w+2/3,U+1,0,w,U,0,w+2/3,U+1,0,w,U+1,0];b.set(y,v*g*A),T.set(d,m*g*A);const M=[A,A,A,A,A,A];S.set(M,f*g*A)}const B=new Ie;B.setAttribute("position",new Re(b,v)),B.setAttribute("uv",new Re(T,m)),B.setAttribute("faceIndex",new Re(S,f)),t.push(B),r>si&&r--}return{lodPlanes:t,sizeLods:e,sigmas:n}}function bo(i,t,e){const n=new zn(i,t,e);return n.texture.mapping=Fr,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function fr(i,t,e,n,r){i.viewport.set(t,e,n,r),i.scissor.set(t,e,n,r)}function bf(i,t,e){const n=new Float32Array(On),r=new L(0,1,0);return new An({name:"SphericalGaussianBlur",defines:{n:On,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,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:Ta(),fragmentShader:`
3572
+
3573
+ precision mediump float;
3574
+ precision mediump int;
3575
+
3576
+ varying vec3 vOutputDirection;
3577
+
3578
+ uniform sampler2D envMap;
3579
+ uniform int samples;
3580
+ uniform float weights[ n ];
3581
+ uniform bool latitudinal;
3582
+ uniform float dTheta;
3583
+ uniform float mipInt;
3584
+ uniform vec3 poleAxis;
3585
+
3586
+ #define ENVMAP_TYPE_CUBE_UV
3587
+ #include <cube_uv_reflection_fragment>
3588
+
3589
+ vec3 getSample( float theta, vec3 axis ) {
3590
+
3591
+ float cosTheta = cos( theta );
3592
+ // Rodrigues' axis-angle rotation
3593
+ vec3 sampleDirection = vOutputDirection * cosTheta
3594
+ + cross( axis, vOutputDirection ) * sin( theta )
3595
+ + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
3596
+
3597
+ return bilinearCubeUV( envMap, sampleDirection, mipInt );
3598
+
3599
+ }
3600
+
3601
+ void main() {
3602
+
3603
+ vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
3604
+
3605
+ if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
3606
+
3607
+ axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
3608
+
3609
+ }
3610
+
3611
+ axis = normalize( axis );
3612
+
3613
+ gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
3614
+ gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
3615
+
3616
+ for ( int i = 1; i < n; i++ ) {
3617
+
3618
+ if ( i >= samples ) {
3619
+
3620
+ break;
3621
+
3622
+ }
3623
+
3624
+ float theta = dTheta * float( i );
3625
+ gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
3626
+ gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
3627
+
3628
+ }
3629
+
3630
+ }
3631
+ `,blending:Tn,depthTest:!1,depthWrite:!1})}function Ao(){return new An({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Ta(),fragmentShader:`
3632
+
3633
+ precision mediump float;
3634
+ precision mediump int;
3635
+
3636
+ varying vec3 vOutputDirection;
3637
+
3638
+ uniform sampler2D envMap;
3639
+
3640
+ #include <common>
3641
+
3642
+ void main() {
3643
+
3644
+ vec3 outputDirection = normalize( vOutputDirection );
3645
+ vec2 uv = equirectUv( outputDirection );
3646
+
3647
+ gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
3648
+
3649
+ }
3650
+ `,blending:Tn,depthTest:!1,depthWrite:!1})}function wo(){return new An({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Ta(),fragmentShader:`
3651
+
3652
+ precision mediump float;
3653
+ precision mediump int;
3654
+
3655
+ uniform float flipEnvMap;
3656
+
3657
+ varying vec3 vOutputDirection;
3658
+
3659
+ uniform samplerCube envMap;
3660
+
3661
+ void main() {
3662
+
3663
+ gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
3664
+
3665
+ }
3666
+ `,blending:Tn,depthTest:!1,depthWrite:!1})}function Ta(){return`
3667
+
3668
+ precision mediump float;
3669
+ precision mediump int;
3670
+
3671
+ attribute float faceIndex;
3672
+
3673
+ varying vec3 vOutputDirection;
3674
+
3675
+ // RH coordinate system; PMREM face-indexing convention
3676
+ vec3 getDirection( vec2 uv, float face ) {
3677
+
3678
+ uv = 2.0 * uv - 1.0;
3679
+
3680
+ vec3 direction = vec3( uv, 1.0 );
3681
+
3682
+ if ( face == 0.0 ) {
3683
+
3684
+ direction = direction.zyx; // ( 1, v, u ) pos x
3685
+
3686
+ } else if ( face == 1.0 ) {
3687
+
3688
+ direction = direction.xzy;
3689
+ direction.xz *= -1.0; // ( -u, 1, -v ) pos y
3690
+
3691
+ } else if ( face == 2.0 ) {
3692
+
3693
+ direction.x *= -1.0; // ( -u, v, 1 ) pos z
3694
+
3695
+ } else if ( face == 3.0 ) {
3696
+
3697
+ direction = direction.zyx;
3698
+ direction.xz *= -1.0; // ( -1, v, -u ) neg x
3699
+
3700
+ } else if ( face == 4.0 ) {
3701
+
3702
+ direction = direction.xzy;
3703
+ direction.xy *= -1.0; // ( -u, -1, v ) neg y
3704
+
3705
+ } else if ( face == 5.0 ) {
3706
+
3707
+ direction.z *= -1.0; // ( u, v, -1 ) neg z
3708
+
3709
+ }
3710
+
3711
+ return direction;
3712
+
3713
+ }
3714
+
3715
+ void main() {
3716
+
3717
+ vOutputDirection = getDirection( uv, faceIndex );
3718
+ gl_Position = vec4( position, 1.0 );
3719
+
3720
+ }
3721
+ `}function Af(i){let t=new WeakMap,e=null;function n(o){if(o&&o.isTexture){const l=o.mapping,c=l===Is||l===Us,h=l===hi||l===ui;if(c||h){let u=t.get(o);const d=u!==void 0?u.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==d)return e===null&&(e=new To(i)),u=c?e.fromEquirectangular(o,u):e.fromCubemap(o,u),u.texture.pmremVersion=o.pmremVersion,t.set(o,u),u.texture;if(u!==void 0)return u.texture;{const p=o.image;return c&&p&&p.height>0||h&&p&&r(p)?(e===null&&(e=new To(i)),u=c?e.fromEquirectangular(o):e.fromCubemap(o),u.texture.pmremVersion=o.pmremVersion,t.set(o,u),o.addEventListener("dispose",s),u.texture):null}}}return o}function r(o){let l=0;const c=6;for(let h=0;h<c;h++)o[h]!==void 0&&l++;return l===c}function s(o){const l=o.target;l.removeEventListener("dispose",s);const c=t.get(l);c!==void 0&&(t.delete(l),c.dispose())}function a(){t=new WeakMap,e!==null&&(e.dispose(),e=null)}return{get:n,dispose:a}}function wf(i){const t={};function e(n){if(t[n]!==void 0)return t[n];let r;switch(n){case"WEBGL_depth_texture":r=i.getExtension("WEBGL_depth_texture")||i.getExtension("MOZ_WEBGL_depth_texture")||i.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=i.getExtension("WEBGL_compressed_texture_s3tc")||i.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=i.getExtension("WEBGL_compressed_texture_pvrtc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=i.getExtension(n)}return t[n]=r,r}return{has:function(n){return e(n)!==null},init:function(){e("EXT_color_buffer_float"),e("WEBGL_clip_cull_distance"),e("OES_texture_float_linear"),e("EXT_color_buffer_half_float"),e("WEBGL_multisampled_render_to_texture"),e("WEBGL_render_shared_exponent")},get:function(n){const r=e(n);return r===null&&Di("THREE.WebGLRenderer: "+n+" extension not supported."),r}}}function Rf(i,t,e,n){const r={},s=new WeakMap;function a(u){const d=u.target;d.index!==null&&t.remove(d.index);for(const g in d.attributes)t.remove(d.attributes[g]);for(const g in d.morphAttributes){const v=d.morphAttributes[g];for(let m=0,f=v.length;m<f;m++)t.remove(v[m])}d.removeEventListener("dispose",a),delete r[d.id];const p=s.get(d);p&&(t.remove(p),s.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,e.memory.geometries--}function o(u,d){return r[d.id]===!0||(d.addEventListener("dispose",a),r[d.id]=!0,e.memory.geometries++),d}function l(u){const d=u.attributes;for(const g in d)t.update(d[g],i.ARRAY_BUFFER);const p=u.morphAttributes;for(const g in p){const v=p[g];for(let m=0,f=v.length;m<f;m++)t.update(v[m],i.ARRAY_BUFFER)}}function c(u){const d=[],p=u.index,g=u.attributes.position;let v=0;if(p!==null){const b=p.array;v=p.version;for(let T=0,S=b.length;T<S;T+=3){const B=b[T+0],A=b[T+1],w=b[T+2];d.push(B,A,A,w,w,B)}}else if(g!==void 0){const b=g.array;v=g.version;for(let T=0,S=b.length/3-1;T<S;T+=3){const B=T+0,A=T+1,w=T+2;d.push(B,A,A,w,w,B)}}else return;const m=new(wl(d)?Dl:Ll)(d,1);m.version=v;const f=s.get(u);f&&t.remove(f),s.set(u,m)}function h(u){const d=s.get(u);if(d){const p=u.index;p!==null&&d.version<p.version&&c(u)}else c(u);return s.get(u)}return{get:o,update:l,getWireframeAttribute:h}}function Cf(i,t,e){let n;function r(d){n=d}let s,a;function o(d){s=d.type,a=d.bytesPerElement}function l(d,p){i.drawElements(n,p,s,d*a),e.update(p,n,1)}function c(d,p,g){g!==0&&(i.drawElementsInstanced(n,p,s,d*a,g),e.update(p,n,g))}function h(d,p,g){if(g===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,p,0,s,d,0,g);let m=0;for(let f=0;f<g;f++)m+=p[f];e.update(m,n,1)}function u(d,p,g,v){if(g===0)return;const m=t.get("WEBGL_multi_draw");if(m===null)for(let f=0;f<d.length;f++)c(d[f]/a,p[f],v[f]);else{m.multiDrawElementsInstancedWEBGL(n,p,0,s,d,0,v,0,g);let f=0;for(let b=0;b<g;b++)f+=p[b]*v[b];e.update(f,n,1)}}this.setMode=r,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=h,this.renderMultiDrawInstances=u}function Pf(i){const t={geometries:0,textures:0},e={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,a,o){switch(e.calls++,a){case i.TRIANGLES:e.triangles+=o*(s/3);break;case i.LINES:e.lines+=o*(s/2);break;case i.LINE_STRIP:e.lines+=o*(s-1);break;case i.LINE_LOOP:e.lines+=o*s;break;case i.POINTS:e.points+=o*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",a);break}}function r(){e.calls=0,e.triangles=0,e.points=0,e.lines=0}return{memory:t,render:e,programs:null,autoReset:!0,reset:r,update:n}}function Lf(i,t,e){const n=new WeakMap,r=new Wt;function s(a,o,l){const c=a.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,u=h!==void 0?h.length:0;let d=n.get(o);if(d===void 0||d.count!==u){let y=function(){w.dispose(),n.delete(o),o.removeEventListener("dispose",y)};d!==void 0&&d.texture.dispose();const p=o.morphAttributes.position!==void 0,g=o.morphAttributes.normal!==void 0,v=o.morphAttributes.color!==void 0,m=o.morphAttributes.position||[],f=o.morphAttributes.normal||[],b=o.morphAttributes.color||[];let T=0;p===!0&&(T=1),g===!0&&(T=2),v===!0&&(T=3);let S=o.attributes.position.count*T,B=1;S>t.maxTextureSize&&(B=Math.ceil(S/t.maxTextureSize),S=t.maxTextureSize);const A=new Float32Array(S*B*4*u),w=new Cl(A,S,B,u);w.type=ke,w.needsUpdate=!0;const U=T*4;for(let M=0;M<u;M++){const R=m[M],q=f[M],z=b[M],W=S*B*4*M;for(let $=0;$<R.count;$++){const k=$*U;p===!0&&(r.fromBufferAttribute(R,$),A[W+k+0]=r.x,A[W+k+1]=r.y,A[W+k+2]=r.z,A[W+k+3]=0),g===!0&&(r.fromBufferAttribute(q,$),A[W+k+4]=r.x,A[W+k+5]=r.y,A[W+k+6]=r.z,A[W+k+7]=0),v===!0&&(r.fromBufferAttribute(z,$),A[W+k+8]=r.x,A[W+k+9]=r.y,A[W+k+10]=r.z,A[W+k+11]=z.itemSize===4?r.w:1)}}d={count:u,texture:w,size:new Ft(S,B)},n.set(o,d),o.addEventListener("dispose",y)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(i,"morphTexture",a.morphTexture,e);else{let p=0;for(let v=0;v<c.length;v++)p+=c[v];const g=o.morphTargetsRelative?1:1-p;l.getUniforms().setValue(i,"morphTargetBaseInfluence",g),l.getUniforms().setValue(i,"morphTargetInfluences",c)}l.getUniforms().setValue(i,"morphTargetsTexture",d.texture,e),l.getUniforms().setValue(i,"morphTargetsTextureSize",d.size)}return{update:s}}function Df(i,t,e,n){let r=new WeakMap;function s(l){const c=n.render.frame,h=l.geometry,u=t.get(l,h);if(r.get(u)!==c&&(t.update(u),r.set(u,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),r.get(l)!==c&&(e.update(l.instanceMatrix,i.ARRAY_BUFFER),l.instanceColor!==null&&e.update(l.instanceColor,i.ARRAY_BUFFER),r.set(l,c))),l.isSkinnedMesh){const d=l.skeleton;r.get(d)!==c&&(d.update(),r.set(d,c))}return u}function a(){r=new WeakMap}function o(l){const c=l.target;c.removeEventListener("dispose",o),e.remove(c.instanceMatrix),c.instanceColor!==null&&e.remove(c.instanceColor)}return{update:s,dispose:a}}class Ol extends de{constructor(t,e,n,r,s,a,o,l,c,h=oi){if(h!==oi&&h!==fi)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&h===oi&&(n=Bn),n===void 0&&h===fi&&(n=di),super(null,r,s,a,o,l,h,n,c),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=o!==void 0?o:Se,this.minFilter=l!==void 0?l:Se,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}}const Bl=new de,Ro=new Ol(1,1),zl=new Cl,Vl=new _h,Hl=new Nl,Co=[],Po=[],Lo=new Float32Array(16),Do=new Float32Array(9),Io=new Float32Array(4);function _i(i,t,e){const n=i[0];if(n<=0||n>0)return i;const r=t*e;let s=Co[r];if(s===void 0&&(s=new Float32Array(r),Co[r]=s),t!==0){n.toArray(s,0);for(let a=1,o=0;a!==t;++a)o+=e,i[a].toArray(s,o)}return s}function ce(i,t){if(i.length!==t.length)return!1;for(let e=0,n=i.length;e<n;e++)if(i[e]!==t[e])return!1;return!0}function he(i,t){for(let e=0,n=t.length;e<n;e++)i[e]=t[e]}function Br(i,t){let e=Po[t];e===void 0&&(e=new Int32Array(t),Po[t]=e);for(let n=0;n!==t;++n)e[n]=i.allocateTextureUnit();return e}function If(i,t){const e=this.cache;e[0]!==t&&(i.uniform1f(this.addr,t),e[0]=t)}function Uf(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2f(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(ce(e,t))return;i.uniform2fv(this.addr,t),he(e,t)}}function Nf(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3f(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else if(t.r!==void 0)(e[0]!==t.r||e[1]!==t.g||e[2]!==t.b)&&(i.uniform3f(this.addr,t.r,t.g,t.b),e[0]=t.r,e[1]=t.g,e[2]=t.b);else{if(ce(e,t))return;i.uniform3fv(this.addr,t),he(e,t)}}function Ff(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4f(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(ce(e,t))return;i.uniform4fv(this.addr,t),he(e,t)}}function Of(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(ce(e,t))return;i.uniformMatrix2fv(this.addr,!1,t),he(e,t)}else{if(ce(e,n))return;Io.set(n),i.uniformMatrix2fv(this.addr,!1,Io),he(e,n)}}function Bf(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(ce(e,t))return;i.uniformMatrix3fv(this.addr,!1,t),he(e,t)}else{if(ce(e,n))return;Do.set(n),i.uniformMatrix3fv(this.addr,!1,Do),he(e,n)}}function zf(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(ce(e,t))return;i.uniformMatrix4fv(this.addr,!1,t),he(e,t)}else{if(ce(e,n))return;Lo.set(n),i.uniformMatrix4fv(this.addr,!1,Lo),he(e,n)}}function Vf(i,t){const e=this.cache;e[0]!==t&&(i.uniform1i(this.addr,t),e[0]=t)}function Hf(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2i(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(ce(e,t))return;i.uniform2iv(this.addr,t),he(e,t)}}function kf(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3i(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(ce(e,t))return;i.uniform3iv(this.addr,t),he(e,t)}}function Gf(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4i(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(ce(e,t))return;i.uniform4iv(this.addr,t),he(e,t)}}function Wf(i,t){const e=this.cache;e[0]!==t&&(i.uniform1ui(this.addr,t),e[0]=t)}function Xf(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2ui(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(ce(e,t))return;i.uniform2uiv(this.addr,t),he(e,t)}}function qf(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3ui(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(ce(e,t))return;i.uniform3uiv(this.addr,t),he(e,t)}}function Yf(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4ui(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(ce(e,t))return;i.uniform4uiv(this.addr,t),he(e,t)}}function Kf(i,t,e){const n=this.cache,r=e.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r);let s;this.type===i.SAMPLER_2D_SHADOW?(Ro.compareFunction=Al,s=Ro):s=Bl,e.setTexture2D(t||s,r)}function Zf(i,t,e){const n=this.cache,r=e.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),e.setTexture3D(t||Vl,r)}function $f(i,t,e){const n=this.cache,r=e.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),e.setTextureCube(t||Hl,r)}function jf(i,t,e){const n=this.cache,r=e.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),e.setTexture2DArray(t||zl,r)}function Jf(i){switch(i){case 5126:return If;case 35664:return Uf;case 35665:return Nf;case 35666:return Ff;case 35674:return Of;case 35675:return Bf;case 35676:return zf;case 5124:case 35670:return Vf;case 35667:case 35671:return Hf;case 35668:case 35672:return kf;case 35669:case 35673:return Gf;case 5125:return Wf;case 36294:return Xf;case 36295:return qf;case 36296:return Yf;case 35678:case 36198:case 36298:case 36306:case 35682:return Kf;case 35679:case 36299:case 36307:return Zf;case 35680:case 36300:case 36308:case 36293:return $f;case 36289:case 36303:case 36311:case 36292:return jf}}function Qf(i,t){i.uniform1fv(this.addr,t)}function tp(i,t){const e=_i(t,this.size,2);i.uniform2fv(this.addr,e)}function ep(i,t){const e=_i(t,this.size,3);i.uniform3fv(this.addr,e)}function np(i,t){const e=_i(t,this.size,4);i.uniform4fv(this.addr,e)}function ip(i,t){const e=_i(t,this.size,4);i.uniformMatrix2fv(this.addr,!1,e)}function rp(i,t){const e=_i(t,this.size,9);i.uniformMatrix3fv(this.addr,!1,e)}function sp(i,t){const e=_i(t,this.size,16);i.uniformMatrix4fv(this.addr,!1,e)}function ap(i,t){i.uniform1iv(this.addr,t)}function op(i,t){i.uniform2iv(this.addr,t)}function lp(i,t){i.uniform3iv(this.addr,t)}function cp(i,t){i.uniform4iv(this.addr,t)}function hp(i,t){i.uniform1uiv(this.addr,t)}function up(i,t){i.uniform2uiv(this.addr,t)}function dp(i,t){i.uniform3uiv(this.addr,t)}function fp(i,t){i.uniform4uiv(this.addr,t)}function pp(i,t,e){const n=this.cache,r=t.length,s=Br(e,r);ce(n,s)||(i.uniform1iv(this.addr,s),he(n,s));for(let a=0;a!==r;++a)e.setTexture2D(t[a]||Bl,s[a])}function mp(i,t,e){const n=this.cache,r=t.length,s=Br(e,r);ce(n,s)||(i.uniform1iv(this.addr,s),he(n,s));for(let a=0;a!==r;++a)e.setTexture3D(t[a]||Vl,s[a])}function gp(i,t,e){const n=this.cache,r=t.length,s=Br(e,r);ce(n,s)||(i.uniform1iv(this.addr,s),he(n,s));for(let a=0;a!==r;++a)e.setTextureCube(t[a]||Hl,s[a])}function _p(i,t,e){const n=this.cache,r=t.length,s=Br(e,r);ce(n,s)||(i.uniform1iv(this.addr,s),he(n,s));for(let a=0;a!==r;++a)e.setTexture2DArray(t[a]||zl,s[a])}function vp(i){switch(i){case 5126:return Qf;case 35664:return tp;case 35665:return ep;case 35666:return np;case 35674:return ip;case 35675:return rp;case 35676:return sp;case 5124:case 35670:return ap;case 35667:case 35671:return op;case 35668:case 35672:return lp;case 35669:case 35673:return cp;case 5125:return hp;case 36294:return up;case 36295:return dp;case 36296:return fp;case 35678:case 36198:case 36298:case 36306:case 35682:return pp;case 35679:case 36299:case 36307:return mp;case 35680:case 36300:case 36308:case 36293:return gp;case 36289:case 36303:case 36311:case 36292:return _p}}class xp{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=Jf(e.type)}}class Mp{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=vp(e.type)}}class Sp{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){const r=this.seq;for(let s=0,a=r.length;s!==a;++s){const o=r[s];o.setValue(t,e[o.id],n)}}}const ps=/(\w+)(\])?(\[|\.)?/g;function Uo(i,t){i.seq.push(t),i.map[t.id]=t}function yp(i,t,e){const n=i.name,r=n.length;for(ps.lastIndex=0;;){const s=ps.exec(n),a=ps.lastIndex;let o=s[1];const l=s[2]==="]",c=s[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===r){Uo(e,c===void 0?new xp(o,i,t):new Mp(o,i,t));break}else{let u=e.map[o];u===void 0&&(u=new Sp(o),Uo(e,u)),e=u}}}class Cr{constructor(t,e){this.seq=[],this.map={};const n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let r=0;r<n;++r){const s=t.getActiveUniform(e,r),a=t.getUniformLocation(e,s.name);yp(s,a,this)}}setValue(t,e,n,r){const s=this.map[e];s!==void 0&&s.setValue(t,n,r)}setOptional(t,e,n){const r=e[n];r!==void 0&&this.setValue(t,n,r)}static upload(t,e,n,r){for(let s=0,a=e.length;s!==a;++s){const o=e[s],l=n[o.id];l.needsUpdate!==!1&&o.setValue(t,l.value,r)}}static seqWithValue(t,e){const n=[];for(let r=0,s=t.length;r!==s;++r){const a=t[r];a.id in e&&n.push(a)}return n}}function No(i,t,e){const n=i.createShader(t);return i.shaderSource(n,e),i.compileShader(n),n}const Ep=37297;let Tp=0;function bp(i,t){const e=i.split(`
3722
+ `),n=[],r=Math.max(t-6,0),s=Math.min(t+6,e.length);for(let a=r;a<s;a++){const o=a+1;n.push(`${o===t?">":" "} ${o}: ${e[a]}`)}return n.join(`
3723
+ `)}const Fo=new Ct;function Ap(i){Vt._getMatrix(Fo,Vt.workingColorSpace,i);const t=`mat3( ${Fo.elements.map(e=>e.toFixed(4))} )`;switch(Vt.getTransfer(i)){case Or:return[t,"LinearTransferOETF"];case $t:return[t,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",i),[t,"LinearTransferOETF"]}}function Oo(i,t,e){const n=i.getShaderParameter(t,i.COMPILE_STATUS),r=i.getShaderInfoLog(t).trim();if(n&&r==="")return"";const s=/ERROR: 0:(\d+)/.exec(r);if(s){const a=parseInt(s[1]);return e.toUpperCase()+`
3724
+
3725
+ `+r+`
3726
+
3727
+ `+bp(i.getShaderSource(t),a)}else return r}function wp(i,t){const e=Ap(t);return[`vec4 ${i}( vec4 value ) {`,` return ${e[1]}( vec4( value.rgb * ${e[0]}, value.a ) );`,"}"].join(`
3728
+ `)}function Rp(i,t){let e;switch(t){case Tc:e="Linear";break;case bc:e="Reinhard";break;case Ac:e="Cineon";break;case wc:e="ACESFilmic";break;case Cc:e="AgX";break;case Pc:e="Neutral";break;case Rc:e="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),e="Linear"}return"vec3 "+i+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}const pr=new L;function Cp(){Vt.getLuminanceCoefficients(pr);const i=pr.x.toFixed(4),t=pr.y.toFixed(4),e=pr.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${t}, ${e} );`," return dot( weights, rgb );","}"].join(`
3729
+ `)}function Pp(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Ii).join(`
3730
+ `)}function Lp(i){const t=[];for(const e in i){const n=i[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(`
3731
+ `)}function Dp(i,t){const e={},n=i.getProgramParameter(t,i.ACTIVE_ATTRIBUTES);for(let r=0;r<n;r++){const s=i.getActiveAttrib(t,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),e[a]={type:s.type,location:i.getAttribLocation(t,a),locationSize:o}}return e}function Ii(i){return i!==""}function Bo(i,t){const e=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,e).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function zo(i,t){return i.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const Ip=/^[ \t]*#include +<([\w\d./]+)>/gm;function la(i){return i.replace(Ip,Np)}const Up=new Map;function Np(i,t){let e=Lt[t];if(e===void 0){const n=Up.get(t);if(n!==void 0)e=Lt[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,n);else throw new Error("Can not resolve #include <"+t+">")}return la(e)}const Fp=/#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 Vo(i){return i.replace(Fp,Op)}function Op(i,t,e,n){let r="";for(let s=parseInt(t);s<parseInt(e);s++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function Ho(i){let t=`precision ${i.precision} float;
3732
+ precision ${i.precision} int;
3733
+ precision ${i.precision} sampler2D;
3734
+ precision ${i.precision} samplerCube;
3735
+ precision ${i.precision} sampler3D;
3736
+ precision ${i.precision} sampler2DArray;
3737
+ precision ${i.precision} sampler2DShadow;
3738
+ precision ${i.precision} samplerCubeShadow;
3739
+ precision ${i.precision} sampler2DArrayShadow;
3740
+ precision ${i.precision} isampler2D;
3741
+ precision ${i.precision} isampler3D;
3742
+ precision ${i.precision} isamplerCube;
3743
+ precision ${i.precision} isampler2DArray;
3744
+ precision ${i.precision} usampler2D;
3745
+ precision ${i.precision} usampler3D;
3746
+ precision ${i.precision} usamplerCube;
3747
+ precision ${i.precision} usampler2DArray;
3748
+ `;return i.precision==="highp"?t+=`
3749
+ #define HIGH_PRECISION`:i.precision==="mediump"?t+=`
3750
+ #define MEDIUM_PRECISION`:i.precision==="lowp"&&(t+=`
3751
+ #define LOW_PRECISION`),t}function Bp(i){let t="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===dl?t="SHADOWMAP_TYPE_PCF":i.shadowMapType===ic?t="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===sn&&(t="SHADOWMAP_TYPE_VSM"),t}function zp(i){let t="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case hi:case ui:t="ENVMAP_TYPE_CUBE";break;case Fr:t="ENVMAP_TYPE_CUBE_UV";break}return t}function Vp(i){let t="ENVMAP_MODE_REFLECTION";return i.envMap&&i.envMapMode===ui&&(t="ENVMAP_MODE_REFRACTION"),t}function Hp(i){let t="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case fl:t="ENVMAP_BLENDING_MULTIPLY";break;case yc:t="ENVMAP_BLENDING_MIX";break;case Ec:t="ENVMAP_BLENDING_ADD";break}return t}function kp(i){const t=i.envMapCubeUVHeight;if(t===null)return null;const e=Math.log2(t)-2,n=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,e),112)),texelHeight:n,maxMip:e}}function Gp(i,t,e,n){const r=i.getContext(),s=e.defines;let a=e.vertexShader,o=e.fragmentShader;const l=Bp(e),c=zp(e),h=Vp(e),u=Hp(e),d=kp(e),p=Pp(e),g=Lp(s),v=r.createProgram();let m,f,b=e.glslVersion?"#version "+e.glslVersion+`
3752
+ `:"";e.isRawShaderMaterial?(m=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(Ii).join(`
3753
+ `),m.length>0&&(m+=`
3754
+ `),f=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(Ii).join(`
3755
+ `),f.length>0&&(f+=`
3756
+ `)):(m=[Ho(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g,e.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",e.batching?"#define USE_BATCHING":"",e.batchingColor?"#define USE_BATCHING_COLOR":"",e.instancing?"#define USE_INSTANCING":"",e.instancingColor?"#define USE_INSTANCING_COLOR":"",e.instancingMorph?"#define USE_INSTANCING_MORPH":"",e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+h:"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.displacementMap?"#define USE_DISPLACEMENTMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.mapUv?"#define MAP_UV "+e.mapUv:"",e.alphaMapUv?"#define ALPHAMAP_UV "+e.alphaMapUv:"",e.lightMapUv?"#define LIGHTMAP_UV "+e.lightMapUv:"",e.aoMapUv?"#define AOMAP_UV "+e.aoMapUv:"",e.emissiveMapUv?"#define EMISSIVEMAP_UV "+e.emissiveMapUv:"",e.bumpMapUv?"#define BUMPMAP_UV "+e.bumpMapUv:"",e.normalMapUv?"#define NORMALMAP_UV "+e.normalMapUv:"",e.displacementMapUv?"#define DISPLACEMENTMAP_UV "+e.displacementMapUv:"",e.metalnessMapUv?"#define METALNESSMAP_UV "+e.metalnessMapUv:"",e.roughnessMapUv?"#define ROUGHNESSMAP_UV "+e.roughnessMapUv:"",e.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+e.anisotropyMapUv:"",e.clearcoatMapUv?"#define CLEARCOATMAP_UV "+e.clearcoatMapUv:"",e.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+e.clearcoatNormalMapUv:"",e.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+e.clearcoatRoughnessMapUv:"",e.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+e.iridescenceMapUv:"",e.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+e.iridescenceThicknessMapUv:"",e.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+e.sheenColorMapUv:"",e.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+e.sheenRoughnessMapUv:"",e.specularMapUv?"#define SPECULARMAP_UV "+e.specularMapUv:"",e.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+e.specularColorMapUv:"",e.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+e.specularIntensityMapUv:"",e.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+e.transmissionMapUv:"",e.thicknessMapUv?"#define THICKNESSMAP_UV "+e.thicknessMapUv:"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.flatShading?"#define FLAT_SHADED":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.morphNormals&&e.flatShading===!1?"#define USE_MORPHNORMALS":"",e.morphColors?"#define USE_MORPHCOLORS":"",e.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+e.morphTextureStride:"",e.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+e.morphTargetsCount:"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",e.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
3757
+ `].filter(Ii).join(`
3758
+ `),f=[Ho(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",e.map?"#define USE_MAP":"",e.matcap?"#define USE_MATCAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+c:"",e.envMap?"#define "+h:"",e.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoat?"#define USE_CLEARCOAT":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.dispersion?"#define USE_DISPERSION":"",e.iridescence?"#define USE_IRIDESCENCE":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaTest?"#define USE_ALPHATEST":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.sheen?"#define USE_SHEEN":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors||e.instancingColor||e.batchingColor?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.gradientMap?"#define USE_GRADIENTMAP":"",e.flatShading?"#define FLAT_SHADED":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",e.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",e.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==bn?"#define TONE_MAPPING":"",e.toneMapping!==bn?Lt.tonemapping_pars_fragment:"",e.toneMapping!==bn?Rp("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",Lt.colorspace_pars_fragment,wp("linearToOutputTexel",e.outputColorSpace),Cp(),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",`
3759
+ `].filter(Ii).join(`
3760
+ `)),a=la(a),a=Bo(a,e),a=zo(a,e),o=la(o),o=Bo(o,e),o=zo(o,e),a=Vo(a),o=Vo(o),e.isRawShaderMaterial!==!0&&(b=`#version 300 es
3761
+ `,m=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
3762
+ `)+`
3763
+ `+m,f=["#define varying in",e.glslVersion===Ja?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===Ja?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
3764
+ `)+`
3765
+ `+f);const T=b+m+a,S=b+f+o,B=No(r,r.VERTEX_SHADER,T),A=No(r,r.FRAGMENT_SHADER,S);r.attachShader(v,B),r.attachShader(v,A),e.index0AttributeName!==void 0?r.bindAttribLocation(v,0,e.index0AttributeName):e.morphTargets===!0&&r.bindAttribLocation(v,0,"position"),r.linkProgram(v);function w(R){if(i.debug.checkShaderErrors){const q=r.getProgramInfoLog(v).trim(),z=r.getShaderInfoLog(B).trim(),W=r.getShaderInfoLog(A).trim();let $=!0,k=!0;if(r.getProgramParameter(v,r.LINK_STATUS)===!1)if($=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(r,v,B,A);else{const Q=Oo(r,B,"vertex"),H=Oo(r,A,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(v,r.VALIDATE_STATUS)+`
3766
+
3767
+ Material Name: `+R.name+`
3768
+ Material Type: `+R.type+`
3769
+
3770
+ Program Info Log: `+q+`
3771
+ `+Q+`
3772
+ `+H)}else q!==""?console.warn("THREE.WebGLProgram: Program Info Log:",q):(z===""||W==="")&&(k=!1);k&&(R.diagnostics={runnable:$,programLog:q,vertexShader:{log:z,prefix:m},fragmentShader:{log:W,prefix:f}})}r.deleteShader(B),r.deleteShader(A),U=new Cr(r,v),y=Dp(r,v)}let U;this.getUniforms=function(){return U===void 0&&w(this),U};let y;this.getAttributes=function(){return y===void 0&&w(this),y};let M=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return M===!1&&(M=r.getProgramParameter(v,Ep)),M},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(v),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=Tp++,this.cacheKey=t,this.usedTimes=1,this.program=v,this.vertexShader=B,this.fragmentShader=A,this}let Wp=0;class Xp{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,n=t.fragmentShader,r=this._getShaderStage(e),s=this._getShaderStage(n),a=this._getShaderCacheForMaterial(t);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){const e=this.shaderCache;let n=e.get(t);return n===void 0&&(n=new qp(t),e.set(t,n)),n}}class qp{constructor(t){this.id=Wp++,this.code=t,this.usedTimes=0}}function Yp(i,t,e,n,r,s,a){const o=new Ma,l=new Xp,c=new Set,h=[],u=r.logarithmicDepthBuffer,d=r.vertexTextures;let p=r.precision;const g={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function v(y){return c.add(y),y===0?"uv":`uv${y}`}function m(y,M,R,q,z){const W=q.fog,$=z.geometry,k=y.isMeshStandardMaterial?q.environment:null,Q=(y.isMeshStandardMaterial?e:t).get(y.envMap||k),H=Q&&Q.mapping===Fr?Q.image.height:null,it=g[y.type];y.precision!==null&&(p=r.getMaxPrecision(y.precision),p!==y.precision&&console.warn("THREE.WebGLProgram.getParameters:",y.precision,"not supported, using",p,"instead."));const ct=$.morphAttributes.position||$.morphAttributes.normal||$.morphAttributes.color,xt=ct!==void 0?ct.length:0;let Ut=0;$.morphAttributes.position!==void 0&&(Ut=1),$.morphAttributes.normal!==void 0&&(Ut=2),$.morphAttributes.color!==void 0&&(Ut=3);let jt,X,tt,gt;if(it){const Yt=Xe[it];jt=Yt.vertexShader,X=Yt.fragmentShader}else jt=y.vertexShader,X=y.fragmentShader,l.update(y),tt=l.getVertexShaderID(y),gt=l.getFragmentShaderID(y);const rt=i.getRenderTarget(),Et=i.state.buffers.depth.getReversed(),At=z.isInstancedMesh===!0,Nt=z.isBatchedMesh===!0,ie=!!y.map,Ht=!!y.matcap,ae=!!Q,I=!!y.aoMap,Ce=!!y.lightMap,Ot=!!y.bumpMap,Bt=!!y.normalMap,St=!!y.displacementMap,te=!!y.emissiveMap,Mt=!!y.metalnessMap,E=!!y.roughnessMap,_=y.anisotropy>0,N=y.clearcoat>0,Y=y.dispersion>0,Z=y.iridescence>0,G=y.sheen>0,_t=y.transmission>0,st=_&&!!y.anisotropyMap,ht=N&&!!y.clearcoatMap,kt=N&&!!y.clearcoatNormalMap,j=N&&!!y.clearcoatRoughnessMap,ut=Z&&!!y.iridescenceMap,yt=Z&&!!y.iridescenceThicknessMap,Tt=G&&!!y.sheenColorMap,dt=G&&!!y.sheenRoughnessMap,zt=!!y.specularMap,Pt=!!y.specularColorMap,Jt=!!y.specularIntensityMap,C=_t&&!!y.transmissionMap,nt=_t&&!!y.thicknessMap,V=!!y.gradientMap,K=!!y.alphaMap,lt=y.alphaTest>0,at=!!y.alphaHash,wt=!!y.extensions;let re=bn;y.toneMapped&&(rt===null||rt.isXRRenderTarget===!0)&&(re=i.toneMapping);const fe={shaderID:it,shaderType:y.type,shaderName:y.name,vertexShader:jt,fragmentShader:X,defines:y.defines,customVertexShaderID:tt,customFragmentShaderID:gt,isRawShaderMaterial:y.isRawShaderMaterial===!0,glslVersion:y.glslVersion,precision:p,batching:Nt,batchingColor:Nt&&z._colorsTexture!==null,instancing:At,instancingColor:At&&z.instanceColor!==null,instancingMorph:At&&z.morphTexture!==null,supportsVertexTextures:d,outputColorSpace:rt===null?i.outputColorSpace:rt.isXRRenderTarget===!0?rt.texture.colorSpace:Vn,alphaToCoverage:!!y.alphaToCoverage,map:ie,matcap:Ht,envMap:ae,envMapMode:ae&&Q.mapping,envMapCubeUVHeight:H,aoMap:I,lightMap:Ce,bumpMap:Ot,normalMap:Bt,displacementMap:d&&St,emissiveMap:te,normalMapObjectSpace:Bt&&y.normalMapType===Bc,normalMapTangentSpace:Bt&&y.normalMapType===bl,metalnessMap:Mt,roughnessMap:E,anisotropy:_,anisotropyMap:st,clearcoat:N,clearcoatMap:ht,clearcoatNormalMap:kt,clearcoatRoughnessMap:j,dispersion:Y,iridescence:Z,iridescenceMap:ut,iridescenceThicknessMap:yt,sheen:G,sheenColorMap:Tt,sheenRoughnessMap:dt,specularMap:zt,specularColorMap:Pt,specularIntensityMap:Jt,transmission:_t,transmissionMap:C,thicknessMap:nt,gradientMap:V,opaque:y.transparent===!1&&y.blending===ai&&y.alphaToCoverage===!1,alphaMap:K,alphaTest:lt,alphaHash:at,combine:y.combine,mapUv:ie&&v(y.map.channel),aoMapUv:I&&v(y.aoMap.channel),lightMapUv:Ce&&v(y.lightMap.channel),bumpMapUv:Ot&&v(y.bumpMap.channel),normalMapUv:Bt&&v(y.normalMap.channel),displacementMapUv:St&&v(y.displacementMap.channel),emissiveMapUv:te&&v(y.emissiveMap.channel),metalnessMapUv:Mt&&v(y.metalnessMap.channel),roughnessMapUv:E&&v(y.roughnessMap.channel),anisotropyMapUv:st&&v(y.anisotropyMap.channel),clearcoatMapUv:ht&&v(y.clearcoatMap.channel),clearcoatNormalMapUv:kt&&v(y.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:j&&v(y.clearcoatRoughnessMap.channel),iridescenceMapUv:ut&&v(y.iridescenceMap.channel),iridescenceThicknessMapUv:yt&&v(y.iridescenceThicknessMap.channel),sheenColorMapUv:Tt&&v(y.sheenColorMap.channel),sheenRoughnessMapUv:dt&&v(y.sheenRoughnessMap.channel),specularMapUv:zt&&v(y.specularMap.channel),specularColorMapUv:Pt&&v(y.specularColorMap.channel),specularIntensityMapUv:Jt&&v(y.specularIntensityMap.channel),transmissionMapUv:C&&v(y.transmissionMap.channel),thicknessMapUv:nt&&v(y.thicknessMap.channel),alphaMapUv:K&&v(y.alphaMap.channel),vertexTangents:!!$.attributes.tangent&&(Bt||_),vertexColors:y.vertexColors,vertexAlphas:y.vertexColors===!0&&!!$.attributes.color&&$.attributes.color.itemSize===4,pointsUvs:z.isPoints===!0&&!!$.attributes.uv&&(ie||K),fog:!!W,useFog:y.fog===!0,fogExp2:!!W&&W.isFogExp2,flatShading:y.flatShading===!0,sizeAttenuation:y.sizeAttenuation===!0,logarithmicDepthBuffer:u,reverseDepthBuffer:Et,skinning:z.isSkinnedMesh===!0,morphTargets:$.morphAttributes.position!==void 0,morphNormals:$.morphAttributes.normal!==void 0,morphColors:$.morphAttributes.color!==void 0,morphTargetsCount:xt,morphTextureStride:Ut,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:y.dithering,shadowMapEnabled:i.shadowMap.enabled&&R.length>0,shadowMapType:i.shadowMap.type,toneMapping:re,decodeVideoTexture:ie&&y.map.isVideoTexture===!0&&Vt.getTransfer(y.map.colorSpace)===$t,decodeVideoTextureEmissive:te&&y.emissiveMap.isVideoTexture===!0&&Vt.getTransfer(y.emissiveMap.colorSpace)===$t,premultipliedAlpha:y.premultipliedAlpha,doubleSided:y.side===qe,flipSided:y.side===Me,useDepthPacking:y.depthPacking>=0,depthPacking:y.depthPacking||0,index0AttributeName:y.index0AttributeName,extensionClipCullDistance:wt&&y.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(wt&&y.extensions.multiDraw===!0||Nt)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:y.customProgramCacheKey()};return fe.vertexUv1s=c.has(1),fe.vertexUv2s=c.has(2),fe.vertexUv3s=c.has(3),c.clear(),fe}function f(y){const M=[];if(y.shaderID?M.push(y.shaderID):(M.push(y.customVertexShaderID),M.push(y.customFragmentShaderID)),y.defines!==void 0)for(const R in y.defines)M.push(R),M.push(y.defines[R]);return y.isRawShaderMaterial===!1&&(b(M,y),T(M,y),M.push(i.outputColorSpace)),M.push(y.customProgramCacheKey),M.join()}function b(y,M){y.push(M.precision),y.push(M.outputColorSpace),y.push(M.envMapMode),y.push(M.envMapCubeUVHeight),y.push(M.mapUv),y.push(M.alphaMapUv),y.push(M.lightMapUv),y.push(M.aoMapUv),y.push(M.bumpMapUv),y.push(M.normalMapUv),y.push(M.displacementMapUv),y.push(M.emissiveMapUv),y.push(M.metalnessMapUv),y.push(M.roughnessMapUv),y.push(M.anisotropyMapUv),y.push(M.clearcoatMapUv),y.push(M.clearcoatNormalMapUv),y.push(M.clearcoatRoughnessMapUv),y.push(M.iridescenceMapUv),y.push(M.iridescenceThicknessMapUv),y.push(M.sheenColorMapUv),y.push(M.sheenRoughnessMapUv),y.push(M.specularMapUv),y.push(M.specularColorMapUv),y.push(M.specularIntensityMapUv),y.push(M.transmissionMapUv),y.push(M.thicknessMapUv),y.push(M.combine),y.push(M.fogExp2),y.push(M.sizeAttenuation),y.push(M.morphTargetsCount),y.push(M.morphAttributeCount),y.push(M.numDirLights),y.push(M.numPointLights),y.push(M.numSpotLights),y.push(M.numSpotLightMaps),y.push(M.numHemiLights),y.push(M.numRectAreaLights),y.push(M.numDirLightShadows),y.push(M.numPointLightShadows),y.push(M.numSpotLightShadows),y.push(M.numSpotLightShadowsWithMaps),y.push(M.numLightProbes),y.push(M.shadowMapType),y.push(M.toneMapping),y.push(M.numClippingPlanes),y.push(M.numClipIntersection),y.push(M.depthPacking)}function T(y,M){o.disableAll(),M.supportsVertexTextures&&o.enable(0),M.instancing&&o.enable(1),M.instancingColor&&o.enable(2),M.instancingMorph&&o.enable(3),M.matcap&&o.enable(4),M.envMap&&o.enable(5),M.normalMapObjectSpace&&o.enable(6),M.normalMapTangentSpace&&o.enable(7),M.clearcoat&&o.enable(8),M.iridescence&&o.enable(9),M.alphaTest&&o.enable(10),M.vertexColors&&o.enable(11),M.vertexAlphas&&o.enable(12),M.vertexUv1s&&o.enable(13),M.vertexUv2s&&o.enable(14),M.vertexUv3s&&o.enable(15),M.vertexTangents&&o.enable(16),M.anisotropy&&o.enable(17),M.alphaHash&&o.enable(18),M.batching&&o.enable(19),M.dispersion&&o.enable(20),M.batchingColor&&o.enable(21),y.push(o.mask),o.disableAll(),M.fog&&o.enable(0),M.useFog&&o.enable(1),M.flatShading&&o.enable(2),M.logarithmicDepthBuffer&&o.enable(3),M.reverseDepthBuffer&&o.enable(4),M.skinning&&o.enable(5),M.morphTargets&&o.enable(6),M.morphNormals&&o.enable(7),M.morphColors&&o.enable(8),M.premultipliedAlpha&&o.enable(9),M.shadowMapEnabled&&o.enable(10),M.doubleSided&&o.enable(11),M.flipSided&&o.enable(12),M.useDepthPacking&&o.enable(13),M.dithering&&o.enable(14),M.transmission&&o.enable(15),M.sheen&&o.enable(16),M.opaque&&o.enable(17),M.pointsUvs&&o.enable(18),M.decodeVideoTexture&&o.enable(19),M.decodeVideoTextureEmissive&&o.enable(20),M.alphaToCoverage&&o.enable(21),y.push(o.mask)}function S(y){const M=g[y.type];let R;if(M){const q=Xe[M];R=Ch.clone(q.uniforms)}else R=y.uniforms;return R}function B(y,M){let R;for(let q=0,z=h.length;q<z;q++){const W=h[q];if(W.cacheKey===M){R=W,++R.usedTimes;break}}return R===void 0&&(R=new Gp(i,M,y,s),h.push(R)),R}function A(y){if(--y.usedTimes===0){const M=h.indexOf(y);h[M]=h[h.length-1],h.pop(),y.destroy()}}function w(y){l.remove(y)}function U(){l.dispose()}return{getParameters:m,getProgramCacheKey:f,getUniforms:S,acquireProgram:B,releaseProgram:A,releaseShaderCache:w,programs:h,dispose:U}}function Kp(){let i=new WeakMap;function t(a){return i.has(a)}function e(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,l){i.get(a)[o]=l}function s(){i=new WeakMap}return{has:t,get:e,remove:n,update:r,dispose:s}}function Zp(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.material.id!==t.material.id?i.material.id-t.material.id:i.z!==t.z?i.z-t.z:i.id-t.id}function ko(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.z!==t.z?t.z-i.z:i.id-t.id}function Go(){const i=[];let t=0;const e=[],n=[],r=[];function s(){t=0,e.length=0,n.length=0,r.length=0}function a(u,d,p,g,v,m){let f=i[t];return f===void 0?(f={id:u.id,object:u,geometry:d,material:p,groupOrder:g,renderOrder:u.renderOrder,z:v,group:m},i[t]=f):(f.id=u.id,f.object=u,f.geometry=d,f.material=p,f.groupOrder=g,f.renderOrder=u.renderOrder,f.z=v,f.group=m),t++,f}function o(u,d,p,g,v,m){const f=a(u,d,p,g,v,m);p.transmission>0?n.push(f):p.transparent===!0?r.push(f):e.push(f)}function l(u,d,p,g,v,m){const f=a(u,d,p,g,v,m);p.transmission>0?n.unshift(f):p.transparent===!0?r.unshift(f):e.unshift(f)}function c(u,d){e.length>1&&e.sort(u||Zp),n.length>1&&n.sort(d||ko),r.length>1&&r.sort(d||ko)}function h(){for(let u=t,d=i.length;u<d;u++){const p=i[u];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:e,transmissive:n,transparent:r,init:s,push:o,unshift:l,finish:h,sort:c}}function $p(){let i=new WeakMap;function t(n,r){const s=i.get(n);let a;return s===void 0?(a=new Go,i.set(n,[a])):r>=s.length?(a=new Go,s.push(a)):a=s[r],a}function e(){i=new WeakMap}return{get:t,dispose:e}}function jp(){const i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new L,color:new It};break;case"SpotLight":e={position:new L,direction:new L,color:new It,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new L,color:new It,distance:0,decay:0};break;case"HemisphereLight":e={direction:new L,skyColor:new It,groundColor:new It};break;case"RectAreaLight":e={color:new It,position:new L,halfWidth:new L,halfHeight:new L};break}return i[t.id]=e,e}}}function Jp(){const i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ft};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ft};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ft,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}let Qp=0;function tm(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function em(i){const t=new jp,e=Jp(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new L);const r=new L,s=new Dt,a=new Dt;function o(c){let h=0,u=0,d=0;for(let y=0;y<9;y++)n.probe[y].set(0,0,0);let p=0,g=0,v=0,m=0,f=0,b=0,T=0,S=0,B=0,A=0,w=0;c.sort(tm);for(let y=0,M=c.length;y<M;y++){const R=c[y],q=R.color,z=R.intensity,W=R.distance,$=R.shadow&&R.shadow.map?R.shadow.map.texture:null;if(R.isAmbientLight)h+=q.r*z,u+=q.g*z,d+=q.b*z;else if(R.isLightProbe){for(let k=0;k<9;k++)n.probe[k].addScaledVector(R.sh.coefficients[k],z);w++}else if(R.isDirectionalLight){const k=t.get(R);if(k.color.copy(R.color).multiplyScalar(R.intensity),R.castShadow){const Q=R.shadow,H=e.get(R);H.shadowIntensity=Q.intensity,H.shadowBias=Q.bias,H.shadowNormalBias=Q.normalBias,H.shadowRadius=Q.radius,H.shadowMapSize=Q.mapSize,n.directionalShadow[p]=H,n.directionalShadowMap[p]=$,n.directionalShadowMatrix[p]=R.shadow.matrix,b++}n.directional[p]=k,p++}else if(R.isSpotLight){const k=t.get(R);k.position.setFromMatrixPosition(R.matrixWorld),k.color.copy(q).multiplyScalar(z),k.distance=W,k.coneCos=Math.cos(R.angle),k.penumbraCos=Math.cos(R.angle*(1-R.penumbra)),k.decay=R.decay,n.spot[v]=k;const Q=R.shadow;if(R.map&&(n.spotLightMap[B]=R.map,B++,Q.updateMatrices(R),R.castShadow&&A++),n.spotLightMatrix[v]=Q.matrix,R.castShadow){const H=e.get(R);H.shadowIntensity=Q.intensity,H.shadowBias=Q.bias,H.shadowNormalBias=Q.normalBias,H.shadowRadius=Q.radius,H.shadowMapSize=Q.mapSize,n.spotShadow[v]=H,n.spotShadowMap[v]=$,S++}v++}else if(R.isRectAreaLight){const k=t.get(R);k.color.copy(q).multiplyScalar(z),k.halfWidth.set(R.width*.5,0,0),k.halfHeight.set(0,R.height*.5,0),n.rectArea[m]=k,m++}else if(R.isPointLight){const k=t.get(R);if(k.color.copy(R.color).multiplyScalar(R.intensity),k.distance=R.distance,k.decay=R.decay,R.castShadow){const Q=R.shadow,H=e.get(R);H.shadowIntensity=Q.intensity,H.shadowBias=Q.bias,H.shadowNormalBias=Q.normalBias,H.shadowRadius=Q.radius,H.shadowMapSize=Q.mapSize,H.shadowCameraNear=Q.camera.near,H.shadowCameraFar=Q.camera.far,n.pointShadow[g]=H,n.pointShadowMap[g]=$,n.pointShadowMatrix[g]=R.shadow.matrix,T++}n.point[g]=k,g++}else if(R.isHemisphereLight){const k=t.get(R);k.skyColor.copy(R.color).multiplyScalar(z),k.groundColor.copy(R.groundColor).multiplyScalar(z),n.hemi[f]=k,f++}}m>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=et.LTC_FLOAT_1,n.rectAreaLTC2=et.LTC_FLOAT_2):(n.rectAreaLTC1=et.LTC_HALF_1,n.rectAreaLTC2=et.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=d;const U=n.hash;(U.directionalLength!==p||U.pointLength!==g||U.spotLength!==v||U.rectAreaLength!==m||U.hemiLength!==f||U.numDirectionalShadows!==b||U.numPointShadows!==T||U.numSpotShadows!==S||U.numSpotMaps!==B||U.numLightProbes!==w)&&(n.directional.length=p,n.spot.length=v,n.rectArea.length=m,n.point.length=g,n.hemi.length=f,n.directionalShadow.length=b,n.directionalShadowMap.length=b,n.pointShadow.length=T,n.pointShadowMap.length=T,n.spotShadow.length=S,n.spotShadowMap.length=S,n.directionalShadowMatrix.length=b,n.pointShadowMatrix.length=T,n.spotLightMatrix.length=S+B-A,n.spotLightMap.length=B,n.numSpotLightShadowsWithMaps=A,n.numLightProbes=w,U.directionalLength=p,U.pointLength=g,U.spotLength=v,U.rectAreaLength=m,U.hemiLength=f,U.numDirectionalShadows=b,U.numPointShadows=T,U.numSpotShadows=S,U.numSpotMaps=B,U.numLightProbes=w,n.version=Qp++)}function l(c,h){let u=0,d=0,p=0,g=0,v=0;const m=h.matrixWorldInverse;for(let f=0,b=c.length;f<b;f++){const T=c[f];if(T.isDirectionalLight){const S=n.directional[u];S.direction.setFromMatrixPosition(T.matrixWorld),r.setFromMatrixPosition(T.target.matrixWorld),S.direction.sub(r),S.direction.transformDirection(m),u++}else if(T.isSpotLight){const S=n.spot[p];S.position.setFromMatrixPosition(T.matrixWorld),S.position.applyMatrix4(m),S.direction.setFromMatrixPosition(T.matrixWorld),r.setFromMatrixPosition(T.target.matrixWorld),S.direction.sub(r),S.direction.transformDirection(m),p++}else if(T.isRectAreaLight){const S=n.rectArea[g];S.position.setFromMatrixPosition(T.matrixWorld),S.position.applyMatrix4(m),a.identity(),s.copy(T.matrixWorld),s.premultiply(m),a.extractRotation(s),S.halfWidth.set(T.width*.5,0,0),S.halfHeight.set(0,T.height*.5,0),S.halfWidth.applyMatrix4(a),S.halfHeight.applyMatrix4(a),g++}else if(T.isPointLight){const S=n.point[d];S.position.setFromMatrixPosition(T.matrixWorld),S.position.applyMatrix4(m),d++}else if(T.isHemisphereLight){const S=n.hemi[v];S.direction.setFromMatrixPosition(T.matrixWorld),S.direction.transformDirection(m),v++}}}return{setup:o,setupView:l,state:n}}function Wo(i){const t=new em(i),e=[],n=[];function r(h){c.camera=h,e.length=0,n.length=0}function s(h){e.push(h)}function a(h){n.push(h)}function o(){t.setup(e)}function l(h){t.setupView(e,h)}const c={lightsArray:e,shadowsArray:n,camera:null,lights:t,transmissionRenderTarget:{}};return{init:r,state:c,setupLights:o,setupLightsView:l,pushLight:s,pushShadow:a}}function nm(i){let t=new WeakMap;function e(r,s=0){const a=t.get(r);let o;return a===void 0?(o=new Wo(i),t.set(r,[o])):s>=a.length?(o=new Wo(i),a.push(o)):o=a[s],o}function n(){t=new WeakMap}return{get:e,dispose:n}}class im extends wn{static get type(){return"MeshDepthMaterial"}constructor(t){super(),this.isMeshDepthMaterial=!0,this.depthPacking=Fc,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class rm extends wn{static get type(){return"MeshDistanceMaterial"}constructor(t){super(),this.isMeshDistanceMaterial=!0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}const sm=`void main() {
3773
+ gl_Position = vec4( position, 1.0 );
3774
+ }`,am=`uniform sampler2D shadow_pass;
3775
+ uniform vec2 resolution;
3776
+ uniform float radius;
3777
+ #include <packing>
3778
+ void main() {
3779
+ const float samples = float( VSM_SAMPLES );
3780
+ float mean = 0.0;
3781
+ float squared_mean = 0.0;
3782
+ float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
3783
+ float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
3784
+ for ( float i = 0.0; i < samples; i ++ ) {
3785
+ float uvOffset = uvStart + i * uvStride;
3786
+ #ifdef HORIZONTAL_PASS
3787
+ vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
3788
+ mean += distribution.x;
3789
+ squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
3790
+ #else
3791
+ float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
3792
+ mean += depth;
3793
+ squared_mean += depth * depth;
3794
+ #endif
3795
+ }
3796
+ mean = mean / samples;
3797
+ squared_mean = squared_mean / samples;
3798
+ float std_dev = sqrt( squared_mean - mean * mean );
3799
+ gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3800
+ }`;function om(i,t,e){let n=new ya;const r=new Ft,s=new Ft,a=new Wt,o=new im({depthPacking:Oc}),l=new rm,c={},h=e.maxTextureSize,u={[ln]:Me,[Me]:ln,[qe]:qe},d=new An({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ft},radius:{value:4}},vertexShader:sm,fragmentShader:am}),p=d.clone();p.defines.HORIZONTAL_PASS=1;const g=new Ie;g.setAttribute("position",new Re(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new we(g,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=dl;let f=this.type;this.render=function(A,w,U){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||A.length===0)return;const y=i.getRenderTarget(),M=i.getActiveCubeFace(),R=i.getActiveMipmapLevel(),q=i.state;q.setBlending(Tn),q.buffers.color.setClear(1,1,1,1),q.buffers.depth.setTest(!0),q.setScissorTest(!1);const z=f!==sn&&this.type===sn,W=f===sn&&this.type!==sn;for(let $=0,k=A.length;$<k;$++){const Q=A[$],H=Q.shadow;if(H===void 0){console.warn("THREE.WebGLShadowMap:",Q,"has no shadow.");continue}if(H.autoUpdate===!1&&H.needsUpdate===!1)continue;r.copy(H.mapSize);const it=H.getFrameExtents();if(r.multiply(it),s.copy(H.mapSize),(r.x>h||r.y>h)&&(r.x>h&&(s.x=Math.floor(h/it.x),r.x=s.x*it.x,H.mapSize.x=s.x),r.y>h&&(s.y=Math.floor(h/it.y),r.y=s.y*it.y,H.mapSize.y=s.y)),H.map===null||z===!0||W===!0){const xt=this.type!==sn?{minFilter:Se,magFilter:Se}:{};H.map!==null&&H.map.dispose(),H.map=new zn(r.x,r.y,xt),H.map.texture.name=Q.name+".shadowMap",H.camera.updateProjectionMatrix()}i.setRenderTarget(H.map),i.clear();const ct=H.getViewportCount();for(let xt=0;xt<ct;xt++){const Ut=H.getViewport(xt);a.set(s.x*Ut.x,s.y*Ut.y,s.x*Ut.z,s.y*Ut.w),q.viewport(a),H.updateMatrices(Q,xt),n=H.getFrustum(),S(w,U,H.camera,Q,this.type)}H.isPointLightShadow!==!0&&this.type===sn&&b(H,U),H.needsUpdate=!1}f=this.type,m.needsUpdate=!1,i.setRenderTarget(y,M,R)};function b(A,w){const U=t.update(v);d.defines.VSM_SAMPLES!==A.blurSamples&&(d.defines.VSM_SAMPLES=A.blurSamples,p.defines.VSM_SAMPLES=A.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),A.mapPass===null&&(A.mapPass=new zn(r.x,r.y)),d.uniforms.shadow_pass.value=A.map.texture,d.uniforms.resolution.value=A.mapSize,d.uniforms.radius.value=A.radius,i.setRenderTarget(A.mapPass),i.clear(),i.renderBufferDirect(w,null,U,d,v,null),p.uniforms.shadow_pass.value=A.mapPass.texture,p.uniforms.resolution.value=A.mapSize,p.uniforms.radius.value=A.radius,i.setRenderTarget(A.map),i.clear(),i.renderBufferDirect(w,null,U,p,v,null)}function T(A,w,U,y){let M=null;const R=U.isPointLight===!0?A.customDistanceMaterial:A.customDepthMaterial;if(R!==void 0)M=R;else if(M=U.isPointLight===!0?l:o,i.localClippingEnabled&&w.clipShadows===!0&&Array.isArray(w.clippingPlanes)&&w.clippingPlanes.length!==0||w.displacementMap&&w.displacementScale!==0||w.alphaMap&&w.alphaTest>0||w.map&&w.alphaTest>0){const q=M.uuid,z=w.uuid;let W=c[q];W===void 0&&(W={},c[q]=W);let $=W[z];$===void 0&&($=M.clone(),W[z]=$,w.addEventListener("dispose",B)),M=$}if(M.visible=w.visible,M.wireframe=w.wireframe,y===sn?M.side=w.shadowSide!==null?w.shadowSide:w.side:M.side=w.shadowSide!==null?w.shadowSide:u[w.side],M.alphaMap=w.alphaMap,M.alphaTest=w.alphaTest,M.map=w.map,M.clipShadows=w.clipShadows,M.clippingPlanes=w.clippingPlanes,M.clipIntersection=w.clipIntersection,M.displacementMap=w.displacementMap,M.displacementScale=w.displacementScale,M.displacementBias=w.displacementBias,M.wireframeLinewidth=w.wireframeLinewidth,M.linewidth=w.linewidth,U.isPointLight===!0&&M.isMeshDistanceMaterial===!0){const q=i.properties.get(M);q.light=U}return M}function S(A,w,U,y,M){if(A.visible===!1)return;if(A.layers.test(w.layers)&&(A.isMesh||A.isLine||A.isPoints)&&(A.castShadow||A.receiveShadow&&M===sn)&&(!A.frustumCulled||n.intersectsObject(A))){A.modelViewMatrix.multiplyMatrices(U.matrixWorldInverse,A.matrixWorld);const z=t.update(A),W=A.material;if(Array.isArray(W)){const $=z.groups;for(let k=0,Q=$.length;k<Q;k++){const H=$[k],it=W[H.materialIndex];if(it&&it.visible){const ct=T(A,it,y,M);A.onBeforeShadow(i,A,w,U,z,ct,H),i.renderBufferDirect(U,null,z,ct,A,H),A.onAfterShadow(i,A,w,U,z,ct,H)}}}else if(W.visible){const $=T(A,W,y,M);A.onBeforeShadow(i,A,w,U,z,$,null),i.renderBufferDirect(U,null,z,$,A,null),A.onAfterShadow(i,A,w,U,z,$,null)}}const q=A.children;for(let z=0,W=q.length;z<W;z++)S(q[z],w,U,y,M)}function B(A){A.target.removeEventListener("dispose",B);for(const U in c){const y=c[U],M=A.target.uuid;M in y&&(y[M].dispose(),delete y[M])}}}const lm={[As]:ws,[Rs]:Ls,[Cs]:Ds,[ci]:Ps,[ws]:As,[Ls]:Rs,[Ds]:Cs,[Ps]:ci};function cm(i,t){function e(){let C=!1;const nt=new Wt;let V=null;const K=new Wt(0,0,0,0);return{setMask:function(lt){V!==lt&&!C&&(i.colorMask(lt,lt,lt,lt),V=lt)},setLocked:function(lt){C=lt},setClear:function(lt,at,wt,re,fe){fe===!0&&(lt*=re,at*=re,wt*=re),nt.set(lt,at,wt,re),K.equals(nt)===!1&&(i.clearColor(lt,at,wt,re),K.copy(nt))},reset:function(){C=!1,V=null,K.set(-1,0,0,0)}}}function n(){let C=!1,nt=!1,V=null,K=null,lt=null;return{setReversed:function(at){if(nt!==at){const wt=t.get("EXT_clip_control");nt?wt.clipControlEXT(wt.LOWER_LEFT_EXT,wt.ZERO_TO_ONE_EXT):wt.clipControlEXT(wt.LOWER_LEFT_EXT,wt.NEGATIVE_ONE_TO_ONE_EXT);const re=lt;lt=null,this.setClear(re)}nt=at},getReversed:function(){return nt},setTest:function(at){at?rt(i.DEPTH_TEST):Et(i.DEPTH_TEST)},setMask:function(at){V!==at&&!C&&(i.depthMask(at),V=at)},setFunc:function(at){if(nt&&(at=lm[at]),K!==at){switch(at){case As:i.depthFunc(i.NEVER);break;case ws:i.depthFunc(i.ALWAYS);break;case Rs:i.depthFunc(i.LESS);break;case ci:i.depthFunc(i.LEQUAL);break;case Cs:i.depthFunc(i.EQUAL);break;case Ps:i.depthFunc(i.GEQUAL);break;case Ls:i.depthFunc(i.GREATER);break;case Ds:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}K=at}},setLocked:function(at){C=at},setClear:function(at){lt!==at&&(nt&&(at=1-at),i.clearDepth(at),lt=at)},reset:function(){C=!1,V=null,K=null,lt=null,nt=!1}}}function r(){let C=!1,nt=null,V=null,K=null,lt=null,at=null,wt=null,re=null,fe=null;return{setTest:function(Yt){C||(Yt?rt(i.STENCIL_TEST):Et(i.STENCIL_TEST))},setMask:function(Yt){nt!==Yt&&!C&&(i.stencilMask(Yt),nt=Yt)},setFunc:function(Yt,Ue,$e){(V!==Yt||K!==Ue||lt!==$e)&&(i.stencilFunc(Yt,Ue,$e),V=Yt,K=Ue,lt=$e)},setOp:function(Yt,Ue,$e){(at!==Yt||wt!==Ue||re!==$e)&&(i.stencilOp(Yt,Ue,$e),at=Yt,wt=Ue,re=$e)},setLocked:function(Yt){C=Yt},setClear:function(Yt){fe!==Yt&&(i.clearStencil(Yt),fe=Yt)},reset:function(){C=!1,nt=null,V=null,K=null,lt=null,at=null,wt=null,re=null,fe=null}}}const s=new e,a=new n,o=new r,l=new WeakMap,c=new WeakMap;let h={},u={},d=new WeakMap,p=[],g=null,v=!1,m=null,f=null,b=null,T=null,S=null,B=null,A=null,w=new It(0,0,0),U=0,y=!1,M=null,R=null,q=null,z=null,W=null;const $=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let k=!1,Q=0;const H=i.getParameter(i.VERSION);H.indexOf("WebGL")!==-1?(Q=parseFloat(/^WebGL (\d)/.exec(H)[1]),k=Q>=1):H.indexOf("OpenGL ES")!==-1&&(Q=parseFloat(/^OpenGL ES (\d)/.exec(H)[1]),k=Q>=2);let it=null,ct={};const xt=i.getParameter(i.SCISSOR_BOX),Ut=i.getParameter(i.VIEWPORT),jt=new Wt().fromArray(xt),X=new Wt().fromArray(Ut);function tt(C,nt,V,K){const lt=new Uint8Array(4),at=i.createTexture();i.bindTexture(C,at),i.texParameteri(C,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(C,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let wt=0;wt<V;wt++)C===i.TEXTURE_3D||C===i.TEXTURE_2D_ARRAY?i.texImage3D(nt,0,i.RGBA,1,1,K,0,i.RGBA,i.UNSIGNED_BYTE,lt):i.texImage2D(nt+wt,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,lt);return at}const gt={};gt[i.TEXTURE_2D]=tt(i.TEXTURE_2D,i.TEXTURE_2D,1),gt[i.TEXTURE_CUBE_MAP]=tt(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),gt[i.TEXTURE_2D_ARRAY]=tt(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),gt[i.TEXTURE_3D]=tt(i.TEXTURE_3D,i.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),rt(i.DEPTH_TEST),a.setFunc(ci),Ot(!1),Bt(Ga),rt(i.CULL_FACE),I(Tn);function rt(C){h[C]!==!0&&(i.enable(C),h[C]=!0)}function Et(C){h[C]!==!1&&(i.disable(C),h[C]=!1)}function At(C,nt){return u[C]!==nt?(i.bindFramebuffer(C,nt),u[C]=nt,C===i.DRAW_FRAMEBUFFER&&(u[i.FRAMEBUFFER]=nt),C===i.FRAMEBUFFER&&(u[i.DRAW_FRAMEBUFFER]=nt),!0):!1}function Nt(C,nt){let V=p,K=!1;if(C){V=d.get(nt),V===void 0&&(V=[],d.set(nt,V));const lt=C.textures;if(V.length!==lt.length||V[0]!==i.COLOR_ATTACHMENT0){for(let at=0,wt=lt.length;at<wt;at++)V[at]=i.COLOR_ATTACHMENT0+at;V.length=lt.length,K=!0}}else V[0]!==i.BACK&&(V[0]=i.BACK,K=!0);K&&i.drawBuffers(V)}function ie(C){return g!==C?(i.useProgram(C),g=C,!0):!1}const Ht={[Fn]:i.FUNC_ADD,[sc]:i.FUNC_SUBTRACT,[ac]:i.FUNC_REVERSE_SUBTRACT};Ht[oc]=i.MIN,Ht[lc]=i.MAX;const ae={[cc]:i.ZERO,[hc]:i.ONE,[uc]:i.SRC_COLOR,[Ts]:i.SRC_ALPHA,[_c]:i.SRC_ALPHA_SATURATE,[mc]:i.DST_COLOR,[fc]:i.DST_ALPHA,[dc]:i.ONE_MINUS_SRC_COLOR,[bs]:i.ONE_MINUS_SRC_ALPHA,[gc]:i.ONE_MINUS_DST_COLOR,[pc]:i.ONE_MINUS_DST_ALPHA,[vc]:i.CONSTANT_COLOR,[xc]:i.ONE_MINUS_CONSTANT_COLOR,[Mc]:i.CONSTANT_ALPHA,[Sc]:i.ONE_MINUS_CONSTANT_ALPHA};function I(C,nt,V,K,lt,at,wt,re,fe,Yt){if(C===Tn){v===!0&&(Et(i.BLEND),v=!1);return}if(v===!1&&(rt(i.BLEND),v=!0),C!==rc){if(C!==m||Yt!==y){if((f!==Fn||S!==Fn)&&(i.blendEquation(i.FUNC_ADD),f=Fn,S=Fn),Yt)switch(C){case ai:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Wa:i.blendFunc(i.ONE,i.ONE);break;case Xa:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case qa:i.blendFuncSeparate(i.ZERO,i.SRC_COLOR,i.ZERO,i.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",C);break}else switch(C){case ai:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Wa:i.blendFunc(i.SRC_ALPHA,i.ONE);break;case Xa:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case qa:i.blendFunc(i.ZERO,i.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",C);break}b=null,T=null,B=null,A=null,w.set(0,0,0),U=0,m=C,y=Yt}return}lt=lt||nt,at=at||V,wt=wt||K,(nt!==f||lt!==S)&&(i.blendEquationSeparate(Ht[nt],Ht[lt]),f=nt,S=lt),(V!==b||K!==T||at!==B||wt!==A)&&(i.blendFuncSeparate(ae[V],ae[K],ae[at],ae[wt]),b=V,T=K,B=at,A=wt),(re.equals(w)===!1||fe!==U)&&(i.blendColor(re.r,re.g,re.b,fe),w.copy(re),U=fe),m=C,y=!1}function Ce(C,nt){C.side===qe?Et(i.CULL_FACE):rt(i.CULL_FACE);let V=C.side===Me;nt&&(V=!V),Ot(V),C.blending===ai&&C.transparent===!1?I(Tn):I(C.blending,C.blendEquation,C.blendSrc,C.blendDst,C.blendEquationAlpha,C.blendSrcAlpha,C.blendDstAlpha,C.blendColor,C.blendAlpha,C.premultipliedAlpha),a.setFunc(C.depthFunc),a.setTest(C.depthTest),a.setMask(C.depthWrite),s.setMask(C.colorWrite);const K=C.stencilWrite;o.setTest(K),K&&(o.setMask(C.stencilWriteMask),o.setFunc(C.stencilFunc,C.stencilRef,C.stencilFuncMask),o.setOp(C.stencilFail,C.stencilZFail,C.stencilZPass)),te(C.polygonOffset,C.polygonOffsetFactor,C.polygonOffsetUnits),C.alphaToCoverage===!0?rt(i.SAMPLE_ALPHA_TO_COVERAGE):Et(i.SAMPLE_ALPHA_TO_COVERAGE)}function Ot(C){M!==C&&(C?i.frontFace(i.CW):i.frontFace(i.CCW),M=C)}function Bt(C){C!==ec?(rt(i.CULL_FACE),C!==R&&(C===Ga?i.cullFace(i.BACK):C===nc?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):Et(i.CULL_FACE),R=C}function St(C){C!==q&&(k&&i.lineWidth(C),q=C)}function te(C,nt,V){C?(rt(i.POLYGON_OFFSET_FILL),(z!==nt||W!==V)&&(i.polygonOffset(nt,V),z=nt,W=V)):Et(i.POLYGON_OFFSET_FILL)}function Mt(C){C?rt(i.SCISSOR_TEST):Et(i.SCISSOR_TEST)}function E(C){C===void 0&&(C=i.TEXTURE0+$-1),it!==C&&(i.activeTexture(C),it=C)}function _(C,nt,V){V===void 0&&(it===null?V=i.TEXTURE0+$-1:V=it);let K=ct[V];K===void 0&&(K={type:void 0,texture:void 0},ct[V]=K),(K.type!==C||K.texture!==nt)&&(it!==V&&(i.activeTexture(V),it=V),i.bindTexture(C,nt||gt[C]),K.type=C,K.texture=nt)}function N(){const C=ct[it];C!==void 0&&C.type!==void 0&&(i.bindTexture(C.type,null),C.type=void 0,C.texture=void 0)}function Y(){try{i.compressedTexImage2D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function Z(){try{i.compressedTexImage3D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function G(){try{i.texSubImage2D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function _t(){try{i.texSubImage3D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function st(){try{i.compressedTexSubImage2D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function ht(){try{i.compressedTexSubImage3D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function kt(){try{i.texStorage2D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function j(){try{i.texStorage3D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function ut(){try{i.texImage2D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function yt(){try{i.texImage3D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function Tt(C){jt.equals(C)===!1&&(i.scissor(C.x,C.y,C.z,C.w),jt.copy(C))}function dt(C){X.equals(C)===!1&&(i.viewport(C.x,C.y,C.z,C.w),X.copy(C))}function zt(C,nt){let V=c.get(nt);V===void 0&&(V=new WeakMap,c.set(nt,V));let K=V.get(C);K===void 0&&(K=i.getUniformBlockIndex(nt,C.name),V.set(C,K))}function Pt(C,nt){const K=c.get(nt).get(C);l.get(nt)!==K&&(i.uniformBlockBinding(nt,K,C.__bindingPointIndex),l.set(nt,K))}function Jt(){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),h={},it=null,ct={},u={},d=new WeakMap,p=[],g=null,v=!1,m=null,f=null,b=null,T=null,S=null,B=null,A=null,w=new It(0,0,0),U=0,y=!1,M=null,R=null,q=null,z=null,W=null,jt.set(0,0,i.canvas.width,i.canvas.height),X.set(0,0,i.canvas.width,i.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:rt,disable:Et,bindFramebuffer:At,drawBuffers:Nt,useProgram:ie,setBlending:I,setMaterial:Ce,setFlipSided:Ot,setCullFace:Bt,setLineWidth:St,setPolygonOffset:te,setScissorTest:Mt,activeTexture:E,bindTexture:_,unbindTexture:N,compressedTexImage2D:Y,compressedTexImage3D:Z,texImage2D:ut,texImage3D:yt,updateUBOMapping:zt,uniformBlockBinding:Pt,texStorage2D:kt,texStorage3D:j,texSubImage2D:G,texSubImage3D:_t,compressedTexSubImage2D:st,compressedTexSubImage3D:ht,scissor:Tt,viewport:dt,reset:Jt}}function Xo(i,t,e,n){const r=hm(n);switch(e){case xl:return i*t;case Sl:return i*t;case yl:return i*t*2;case ma:return i*t/r.components*r.byteLength;case ga:return i*t/r.components*r.byteLength;case El:return i*t*2/r.components*r.byteLength;case _a:return i*t*2/r.components*r.byteLength;case Ml:return i*t*3/r.components*r.byteLength;case De:return i*t*4/r.components*r.byteLength;case va:return i*t*4/r.components*r.byteLength;case Tr:case br:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case Ar:case wr:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case Fs:case Bs:return Math.max(i,16)*Math.max(t,8)/4;case Ns:case Os:return Math.max(i,8)*Math.max(t,8)/2;case zs:case Vs:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case Hs:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case ks:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case Gs:return Math.floor((i+4)/5)*Math.floor((t+3)/4)*16;case Ws:return Math.floor((i+4)/5)*Math.floor((t+4)/5)*16;case Xs:return Math.floor((i+5)/6)*Math.floor((t+4)/5)*16;case qs:return Math.floor((i+5)/6)*Math.floor((t+5)/6)*16;case Ys:return Math.floor((i+7)/8)*Math.floor((t+4)/5)*16;case Ks:return Math.floor((i+7)/8)*Math.floor((t+5)/6)*16;case Zs:return Math.floor((i+7)/8)*Math.floor((t+7)/8)*16;case $s:return Math.floor((i+9)/10)*Math.floor((t+4)/5)*16;case js:return Math.floor((i+9)/10)*Math.floor((t+5)/6)*16;case Js:return Math.floor((i+9)/10)*Math.floor((t+7)/8)*16;case Qs:return Math.floor((i+9)/10)*Math.floor((t+9)/10)*16;case ta:return Math.floor((i+11)/12)*Math.floor((t+9)/10)*16;case ea:return Math.floor((i+11)/12)*Math.floor((t+11)/12)*16;case Rr:case na:case ia:return Math.ceil(i/4)*Math.ceil(t/4)*16;case Tl:case ra:return Math.ceil(i/4)*Math.ceil(t/4)*8;case sa:case aa:return Math.ceil(i/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function hm(i){switch(i){case cn:case gl:return{byteLength:1,components:1};case Oi:case _l:case ki:return{byteLength:2,components:1};case fa:case pa:return{byteLength:2,components:4};case Bn:case da:case ke:return{byteLength:4,components:1};case vl:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}function um(i,t,e,n,r,s,a){const o=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator=="undefined"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Ft,h=new WeakMap;let u;const d=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas!="undefined"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(E){}function g(E,_){return p?new OffscreenCanvas(E,_):zi("canvas")}function v(E,_,N){let Y=1;const Z=Mt(E);if((Z.width>N||Z.height>N)&&(Y=N/Math.max(Z.width,Z.height)),Y<1)if(typeof HTMLImageElement!="undefined"&&E instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&E instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&E instanceof ImageBitmap||typeof VideoFrame!="undefined"&&E instanceof VideoFrame){const G=Math.floor(Y*Z.width),_t=Math.floor(Y*Z.height);u===void 0&&(u=g(G,_t));const st=_?g(G,_t):u;return st.width=G,st.height=_t,st.getContext("2d").drawImage(E,0,0,G,_t),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+Z.width+"x"+Z.height+") to ("+G+"x"+_t+")."),st}else return"data"in E&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+Z.width+"x"+Z.height+")."),E;return E}function m(E){return E.generateMipmaps}function f(E){i.generateMipmap(E)}function b(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 T(E,_,N,Y,Z=!1){if(E!==null){if(i[E]!==void 0)return i[E];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+E+"'")}let G=_;if(_===i.RED&&(N===i.FLOAT&&(G=i.R32F),N===i.HALF_FLOAT&&(G=i.R16F),N===i.UNSIGNED_BYTE&&(G=i.R8)),_===i.RED_INTEGER&&(N===i.UNSIGNED_BYTE&&(G=i.R8UI),N===i.UNSIGNED_SHORT&&(G=i.R16UI),N===i.UNSIGNED_INT&&(G=i.R32UI),N===i.BYTE&&(G=i.R8I),N===i.SHORT&&(G=i.R16I),N===i.INT&&(G=i.R32I)),_===i.RG&&(N===i.FLOAT&&(G=i.RG32F),N===i.HALF_FLOAT&&(G=i.RG16F),N===i.UNSIGNED_BYTE&&(G=i.RG8)),_===i.RG_INTEGER&&(N===i.UNSIGNED_BYTE&&(G=i.RG8UI),N===i.UNSIGNED_SHORT&&(G=i.RG16UI),N===i.UNSIGNED_INT&&(G=i.RG32UI),N===i.BYTE&&(G=i.RG8I),N===i.SHORT&&(G=i.RG16I),N===i.INT&&(G=i.RG32I)),_===i.RGB_INTEGER&&(N===i.UNSIGNED_BYTE&&(G=i.RGB8UI),N===i.UNSIGNED_SHORT&&(G=i.RGB16UI),N===i.UNSIGNED_INT&&(G=i.RGB32UI),N===i.BYTE&&(G=i.RGB8I),N===i.SHORT&&(G=i.RGB16I),N===i.INT&&(G=i.RGB32I)),_===i.RGBA_INTEGER&&(N===i.UNSIGNED_BYTE&&(G=i.RGBA8UI),N===i.UNSIGNED_SHORT&&(G=i.RGBA16UI),N===i.UNSIGNED_INT&&(G=i.RGBA32UI),N===i.BYTE&&(G=i.RGBA8I),N===i.SHORT&&(G=i.RGBA16I),N===i.INT&&(G=i.RGBA32I)),_===i.RGB&&N===i.UNSIGNED_INT_5_9_9_9_REV&&(G=i.RGB9_E5),_===i.RGBA){const _t=Z?Or:Vt.getTransfer(Y);N===i.FLOAT&&(G=i.RGBA32F),N===i.HALF_FLOAT&&(G=i.RGBA16F),N===i.UNSIGNED_BYTE&&(G=_t===$t?i.SRGB8_ALPHA8:i.RGBA8),N===i.UNSIGNED_SHORT_4_4_4_4&&(G=i.RGBA4),N===i.UNSIGNED_SHORT_5_5_5_1&&(G=i.RGB5_A1)}return(G===i.R16F||G===i.R32F||G===i.RG16F||G===i.RG32F||G===i.RGBA16F||G===i.RGBA32F)&&t.get("EXT_color_buffer_float"),G}function S(E,_){let N;return E?_===null||_===Bn||_===di?N=i.DEPTH24_STENCIL8:_===ke?N=i.DEPTH32F_STENCIL8:_===Oi&&(N=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):_===null||_===Bn||_===di?N=i.DEPTH_COMPONENT24:_===ke?N=i.DEPTH_COMPONENT32F:_===Oi&&(N=i.DEPTH_COMPONENT16),N}function B(E,_){return m(E)===!0||E.isFramebufferTexture&&E.minFilter!==Se&&E.minFilter!==He?Math.log2(Math.max(_.width,_.height))+1:E.mipmaps!==void 0&&E.mipmaps.length>0?E.mipmaps.length:E.isCompressedTexture&&Array.isArray(E.image)?_.mipmaps.length:1}function A(E){const _=E.target;_.removeEventListener("dispose",A),U(_),_.isVideoTexture&&h.delete(_)}function w(E){const _=E.target;_.removeEventListener("dispose",w),M(_)}function U(E){const _=n.get(E);if(_.__webglInit===void 0)return;const N=E.source,Y=d.get(N);if(Y){const Z=Y[_.__cacheKey];Z.usedTimes--,Z.usedTimes===0&&y(E),Object.keys(Y).length===0&&d.delete(N)}n.remove(E)}function y(E){const _=n.get(E);i.deleteTexture(_.__webglTexture);const N=E.source,Y=d.get(N);delete Y[_.__cacheKey],a.memory.textures--}function M(E){const _=n.get(E);if(E.depthTexture&&(E.depthTexture.dispose(),n.remove(E.depthTexture)),E.isWebGLCubeRenderTarget)for(let Y=0;Y<6;Y++){if(Array.isArray(_.__webglFramebuffer[Y]))for(let Z=0;Z<_.__webglFramebuffer[Y].length;Z++)i.deleteFramebuffer(_.__webglFramebuffer[Y][Z]);else i.deleteFramebuffer(_.__webglFramebuffer[Y]);_.__webglDepthbuffer&&i.deleteRenderbuffer(_.__webglDepthbuffer[Y])}else{if(Array.isArray(_.__webglFramebuffer))for(let Y=0;Y<_.__webglFramebuffer.length;Y++)i.deleteFramebuffer(_.__webglFramebuffer[Y]);else i.deleteFramebuffer(_.__webglFramebuffer);if(_.__webglDepthbuffer&&i.deleteRenderbuffer(_.__webglDepthbuffer),_.__webglMultisampledFramebuffer&&i.deleteFramebuffer(_.__webglMultisampledFramebuffer),_.__webglColorRenderbuffer)for(let Y=0;Y<_.__webglColorRenderbuffer.length;Y++)_.__webglColorRenderbuffer[Y]&&i.deleteRenderbuffer(_.__webglColorRenderbuffer[Y]);_.__webglDepthRenderbuffer&&i.deleteRenderbuffer(_.__webglDepthRenderbuffer)}const N=E.textures;for(let Y=0,Z=N.length;Y<Z;Y++){const G=n.get(N[Y]);G.__webglTexture&&(i.deleteTexture(G.__webglTexture),a.memory.textures--),n.remove(N[Y])}n.remove(E)}let R=0;function q(){R=0}function z(){const E=R;return E>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+E+" texture units while this GPU supports only "+r.maxTextures),R+=1,E}function W(E){const _=[];return _.push(E.wrapS),_.push(E.wrapT),_.push(E.wrapR||0),_.push(E.magFilter),_.push(E.minFilter),_.push(E.anisotropy),_.push(E.internalFormat),_.push(E.format),_.push(E.type),_.push(E.generateMipmaps),_.push(E.premultiplyAlpha),_.push(E.flipY),_.push(E.unpackAlignment),_.push(E.colorSpace),_.join()}function $(E,_){const N=n.get(E);if(E.isVideoTexture&&St(E),E.isRenderTargetTexture===!1&&E.version>0&&N.__version!==E.version){const Y=E.image;if(Y===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Y.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{X(N,E,_);return}}e.bindTexture(i.TEXTURE_2D,N.__webglTexture,i.TEXTURE0+_)}function k(E,_){const N=n.get(E);if(E.version>0&&N.__version!==E.version){X(N,E,_);return}e.bindTexture(i.TEXTURE_2D_ARRAY,N.__webglTexture,i.TEXTURE0+_)}function Q(E,_){const N=n.get(E);if(E.version>0&&N.__version!==E.version){X(N,E,_);return}e.bindTexture(i.TEXTURE_3D,N.__webglTexture,i.TEXTURE0+_)}function H(E,_){const N=n.get(E);if(E.version>0&&N.__version!==E.version){tt(N,E,_);return}e.bindTexture(i.TEXTURE_CUBE_MAP,N.__webglTexture,i.TEXTURE0+_)}const it={[Pr]:i.REPEAT,[Sn]:i.CLAMP_TO_EDGE,[Lr]:i.MIRRORED_REPEAT},ct={[Se]:i.NEAREST,[ml]:i.NEAREST_MIPMAP_NEAREST,[Li]:i.NEAREST_MIPMAP_LINEAR,[He]:i.LINEAR,[Er]:i.LINEAR_MIPMAP_NEAREST,[yn]:i.LINEAR_MIPMAP_LINEAR},xt={[zc]:i.NEVER,[Xc]:i.ALWAYS,[Vc]:i.LESS,[Al]:i.LEQUAL,[Hc]:i.EQUAL,[Wc]:i.GEQUAL,[kc]:i.GREATER,[Gc]:i.NOTEQUAL};function Ut(E,_){if(_.type===ke&&t.has("OES_texture_float_linear")===!1&&(_.magFilter===He||_.magFilter===Er||_.magFilter===Li||_.magFilter===yn||_.minFilter===He||_.minFilter===Er||_.minFilter===Li||_.minFilter===yn)&&console.warn("THREE.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,it[_.wrapS]),i.texParameteri(E,i.TEXTURE_WRAP_T,it[_.wrapT]),(E===i.TEXTURE_3D||E===i.TEXTURE_2D_ARRAY)&&i.texParameteri(E,i.TEXTURE_WRAP_R,it[_.wrapR]),i.texParameteri(E,i.TEXTURE_MAG_FILTER,ct[_.magFilter]),i.texParameteri(E,i.TEXTURE_MIN_FILTER,ct[_.minFilter]),_.compareFunction&&(i.texParameteri(E,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(E,i.TEXTURE_COMPARE_FUNC,xt[_.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(_.magFilter===Se||_.minFilter!==Li&&_.minFilter!==yn||_.type===ke&&t.has("OES_texture_float_linear")===!1)return;if(_.anisotropy>1||n.get(_).__currentAnisotropy){const N=t.get("EXT_texture_filter_anisotropic");i.texParameterf(E,N.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(_.anisotropy,r.getMaxAnisotropy())),n.get(_).__currentAnisotropy=_.anisotropy}}}function jt(E,_){let N=!1;E.__webglInit===void 0&&(E.__webglInit=!0,_.addEventListener("dispose",A));const Y=_.source;let Z=d.get(Y);Z===void 0&&(Z={},d.set(Y,Z));const G=W(_);if(G!==E.__cacheKey){Z[G]===void 0&&(Z[G]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,N=!0),Z[G].usedTimes++;const _t=Z[E.__cacheKey];_t!==void 0&&(Z[E.__cacheKey].usedTimes--,_t.usedTimes===0&&y(_)),E.__cacheKey=G,E.__webglTexture=Z[G].texture}return N}function X(E,_,N){let Y=i.TEXTURE_2D;(_.isDataArrayTexture||_.isCompressedArrayTexture)&&(Y=i.TEXTURE_2D_ARRAY),_.isData3DTexture&&(Y=i.TEXTURE_3D);const Z=jt(E,_),G=_.source;e.bindTexture(Y,E.__webglTexture,i.TEXTURE0+N);const _t=n.get(G);if(G.version!==_t.__version||Z===!0){e.activeTexture(i.TEXTURE0+N);const st=Vt.getPrimaries(Vt.workingColorSpace),ht=_.colorSpace===Mn?null:Vt.getPrimaries(_.colorSpace),kt=_.colorSpace===Mn||st===ht?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,_.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,_.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,kt);let j=v(_.image,!1,r.maxTextureSize);j=te(_,j);const ut=s.convert(_.format,_.colorSpace),yt=s.convert(_.type);let Tt=T(_.internalFormat,ut,yt,_.colorSpace,_.isVideoTexture);Ut(Y,_);let dt;const zt=_.mipmaps,Pt=_.isVideoTexture!==!0,Jt=_t.__version===void 0||Z===!0,C=G.dataReady,nt=B(_,j);if(_.isDepthTexture)Tt=S(_.format===fi,_.type),Jt&&(Pt?e.texStorage2D(i.TEXTURE_2D,1,Tt,j.width,j.height):e.texImage2D(i.TEXTURE_2D,0,Tt,j.width,j.height,0,ut,yt,null));else if(_.isDataTexture)if(zt.length>0){Pt&&Jt&&e.texStorage2D(i.TEXTURE_2D,nt,Tt,zt[0].width,zt[0].height);for(let V=0,K=zt.length;V<K;V++)dt=zt[V],Pt?C&&e.texSubImage2D(i.TEXTURE_2D,V,0,0,dt.width,dt.height,ut,yt,dt.data):e.texImage2D(i.TEXTURE_2D,V,Tt,dt.width,dt.height,0,ut,yt,dt.data);_.generateMipmaps=!1}else Pt?(Jt&&e.texStorage2D(i.TEXTURE_2D,nt,Tt,j.width,j.height),C&&e.texSubImage2D(i.TEXTURE_2D,0,0,0,j.width,j.height,ut,yt,j.data)):e.texImage2D(i.TEXTURE_2D,0,Tt,j.width,j.height,0,ut,yt,j.data);else if(_.isCompressedTexture)if(_.isCompressedArrayTexture){Pt&&Jt&&e.texStorage3D(i.TEXTURE_2D_ARRAY,nt,Tt,zt[0].width,zt[0].height,j.depth);for(let V=0,K=zt.length;V<K;V++)if(dt=zt[V],_.format!==De)if(ut!==null)if(Pt){if(C)if(_.layerUpdates.size>0){const lt=Xo(dt.width,dt.height,_.format,_.type);for(const at of _.layerUpdates){const wt=dt.data.subarray(at*lt/dt.data.BYTES_PER_ELEMENT,(at+1)*lt/dt.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,V,0,0,at,dt.width,dt.height,1,ut,wt)}_.clearLayerUpdates()}else e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,V,0,0,0,dt.width,dt.height,j.depth,ut,dt.data)}else e.compressedTexImage3D(i.TEXTURE_2D_ARRAY,V,Tt,dt.width,dt.height,j.depth,0,dt.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Pt?C&&e.texSubImage3D(i.TEXTURE_2D_ARRAY,V,0,0,0,dt.width,dt.height,j.depth,ut,yt,dt.data):e.texImage3D(i.TEXTURE_2D_ARRAY,V,Tt,dt.width,dt.height,j.depth,0,ut,yt,dt.data)}else{Pt&&Jt&&e.texStorage2D(i.TEXTURE_2D,nt,Tt,zt[0].width,zt[0].height);for(let V=0,K=zt.length;V<K;V++)dt=zt[V],_.format!==De?ut!==null?Pt?C&&e.compressedTexSubImage2D(i.TEXTURE_2D,V,0,0,dt.width,dt.height,ut,dt.data):e.compressedTexImage2D(i.TEXTURE_2D,V,Tt,dt.width,dt.height,0,dt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Pt?C&&e.texSubImage2D(i.TEXTURE_2D,V,0,0,dt.width,dt.height,ut,yt,dt.data):e.texImage2D(i.TEXTURE_2D,V,Tt,dt.width,dt.height,0,ut,yt,dt.data)}else if(_.isDataArrayTexture)if(Pt){if(Jt&&e.texStorage3D(i.TEXTURE_2D_ARRAY,nt,Tt,j.width,j.height,j.depth),C)if(_.layerUpdates.size>0){const V=Xo(j.width,j.height,_.format,_.type);for(const K of _.layerUpdates){const lt=j.data.subarray(K*V/j.data.BYTES_PER_ELEMENT,(K+1)*V/j.data.BYTES_PER_ELEMENT);e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,K,j.width,j.height,1,ut,yt,lt)}_.clearLayerUpdates()}else e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,j.width,j.height,j.depth,ut,yt,j.data)}else e.texImage3D(i.TEXTURE_2D_ARRAY,0,Tt,j.width,j.height,j.depth,0,ut,yt,j.data);else if(_.isData3DTexture)Pt?(Jt&&e.texStorage3D(i.TEXTURE_3D,nt,Tt,j.width,j.height,j.depth),C&&e.texSubImage3D(i.TEXTURE_3D,0,0,0,0,j.width,j.height,j.depth,ut,yt,j.data)):e.texImage3D(i.TEXTURE_3D,0,Tt,j.width,j.height,j.depth,0,ut,yt,j.data);else if(_.isFramebufferTexture){if(Jt)if(Pt)e.texStorage2D(i.TEXTURE_2D,nt,Tt,j.width,j.height);else{let V=j.width,K=j.height;for(let lt=0;lt<nt;lt++)e.texImage2D(i.TEXTURE_2D,lt,Tt,V,K,0,ut,yt,null),V>>=1,K>>=1}}else if(zt.length>0){if(Pt&&Jt){const V=Mt(zt[0]);e.texStorage2D(i.TEXTURE_2D,nt,Tt,V.width,V.height)}for(let V=0,K=zt.length;V<K;V++)dt=zt[V],Pt?C&&e.texSubImage2D(i.TEXTURE_2D,V,0,0,ut,yt,dt):e.texImage2D(i.TEXTURE_2D,V,Tt,ut,yt,dt);_.generateMipmaps=!1}else if(Pt){if(Jt){const V=Mt(j);e.texStorage2D(i.TEXTURE_2D,nt,Tt,V.width,V.height)}C&&e.texSubImage2D(i.TEXTURE_2D,0,0,0,ut,yt,j)}else e.texImage2D(i.TEXTURE_2D,0,Tt,ut,yt,j);m(_)&&f(Y),_t.__version=G.version,_.onUpdate&&_.onUpdate(_)}E.__version=_.version}function tt(E,_,N){if(_.image.length!==6)return;const Y=jt(E,_),Z=_.source;e.bindTexture(i.TEXTURE_CUBE_MAP,E.__webglTexture,i.TEXTURE0+N);const G=n.get(Z);if(Z.version!==G.__version||Y===!0){e.activeTexture(i.TEXTURE0+N);const _t=Vt.getPrimaries(Vt.workingColorSpace),st=_.colorSpace===Mn?null:Vt.getPrimaries(_.colorSpace),ht=_.colorSpace===Mn||_t===st?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,_.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,_.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,ht);const kt=_.isCompressedTexture||_.image[0].isCompressedTexture,j=_.image[0]&&_.image[0].isDataTexture,ut=[];for(let K=0;K<6;K++)!kt&&!j?ut[K]=v(_.image[K],!0,r.maxCubemapSize):ut[K]=j?_.image[K].image:_.image[K],ut[K]=te(_,ut[K]);const yt=ut[0],Tt=s.convert(_.format,_.colorSpace),dt=s.convert(_.type),zt=T(_.internalFormat,Tt,dt,_.colorSpace),Pt=_.isVideoTexture!==!0,Jt=G.__version===void 0||Y===!0,C=Z.dataReady;let nt=B(_,yt);Ut(i.TEXTURE_CUBE_MAP,_);let V;if(kt){Pt&&Jt&&e.texStorage2D(i.TEXTURE_CUBE_MAP,nt,zt,yt.width,yt.height);for(let K=0;K<6;K++){V=ut[K].mipmaps;for(let lt=0;lt<V.length;lt++){const at=V[lt];_.format!==De?Tt!==null?Pt?C&&e.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,lt,0,0,at.width,at.height,Tt,at.data):e.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,lt,zt,at.width,at.height,0,at.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Pt?C&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,lt,0,0,at.width,at.height,Tt,dt,at.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,lt,zt,at.width,at.height,0,Tt,dt,at.data)}}}else{if(V=_.mipmaps,Pt&&Jt){V.length>0&&nt++;const K=Mt(ut[0]);e.texStorage2D(i.TEXTURE_CUBE_MAP,nt,zt,K.width,K.height)}for(let K=0;K<6;K++)if(j){Pt?C&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,0,0,0,ut[K].width,ut[K].height,Tt,dt,ut[K].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,0,zt,ut[K].width,ut[K].height,0,Tt,dt,ut[K].data);for(let lt=0;lt<V.length;lt++){const wt=V[lt].image[K].image;Pt?C&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,lt+1,0,0,wt.width,wt.height,Tt,dt,wt.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,lt+1,zt,wt.width,wt.height,0,Tt,dt,wt.data)}}else{Pt?C&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,0,0,0,Tt,dt,ut[K]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,0,zt,Tt,dt,ut[K]);for(let lt=0;lt<V.length;lt++){const at=V[lt];Pt?C&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,lt+1,0,0,Tt,dt,at.image[K]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,lt+1,zt,Tt,dt,at.image[K])}}}m(_)&&f(i.TEXTURE_CUBE_MAP),G.__version=Z.version,_.onUpdate&&_.onUpdate(_)}E.__version=_.version}function gt(E,_,N,Y,Z,G){const _t=s.convert(N.format,N.colorSpace),st=s.convert(N.type),ht=T(N.internalFormat,_t,st,N.colorSpace),kt=n.get(_),j=n.get(N);if(j.__renderTarget=_,!kt.__hasExternalTextures){const ut=Math.max(1,_.width>>G),yt=Math.max(1,_.height>>G);Z===i.TEXTURE_3D||Z===i.TEXTURE_2D_ARRAY?e.texImage3D(Z,G,ht,ut,yt,_.depth,0,_t,st,null):e.texImage2D(Z,G,ht,ut,yt,0,_t,st,null)}e.bindFramebuffer(i.FRAMEBUFFER,E),Bt(_)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Y,Z,j.__webglTexture,0,Ot(_)):(Z===i.TEXTURE_2D||Z>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&Z<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,Y,Z,j.__webglTexture,G),e.bindFramebuffer(i.FRAMEBUFFER,null)}function rt(E,_,N){if(i.bindRenderbuffer(i.RENDERBUFFER,E),_.depthBuffer){const Y=_.depthTexture,Z=Y&&Y.isDepthTexture?Y.type:null,G=S(_.stencilBuffer,Z),_t=_.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,st=Ot(_);Bt(_)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,st,G,_.width,_.height):N?i.renderbufferStorageMultisample(i.RENDERBUFFER,st,G,_.width,_.height):i.renderbufferStorage(i.RENDERBUFFER,G,_.width,_.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,_t,i.RENDERBUFFER,E)}else{const Y=_.textures;for(let Z=0;Z<Y.length;Z++){const G=Y[Z],_t=s.convert(G.format,G.colorSpace),st=s.convert(G.type),ht=T(G.internalFormat,_t,st,G.colorSpace),kt=Ot(_);N&&Bt(_)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,kt,ht,_.width,_.height):Bt(_)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,kt,ht,_.width,_.height):i.renderbufferStorage(i.RENDERBUFFER,ht,_.width,_.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function Et(E,_){if(_&&_.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(i.FRAMEBUFFER,E),!(_.depthTexture&&_.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const Y=n.get(_.depthTexture);Y.__renderTarget=_,(!Y.__webglTexture||_.depthTexture.image.width!==_.width||_.depthTexture.image.height!==_.height)&&(_.depthTexture.image.width=_.width,_.depthTexture.image.height=_.height,_.depthTexture.needsUpdate=!0),$(_.depthTexture,0);const Z=Y.__webglTexture,G=Ot(_);if(_.depthTexture.format===oi)Bt(_)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,Z,0,G):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,Z,0);else if(_.depthTexture.format===fi)Bt(_)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,Z,0,G):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,Z,0);else throw new Error("Unknown depthTexture format")}function At(E){const _=n.get(E),N=E.isWebGLCubeRenderTarget===!0;if(_.__boundDepthTexture!==E.depthTexture){const Y=E.depthTexture;if(_.__depthDisposeCallback&&_.__depthDisposeCallback(),Y){const Z=()=>{delete _.__boundDepthTexture,delete _.__depthDisposeCallback,Y.removeEventListener("dispose",Z)};Y.addEventListener("dispose",Z),_.__depthDisposeCallback=Z}_.__boundDepthTexture=Y}if(E.depthTexture&&!_.__autoAllocateDepthBuffer){if(N)throw new Error("target.depthTexture not supported in Cube render targets");Et(_.__webglFramebuffer,E)}else if(N){_.__webglDepthbuffer=[];for(let Y=0;Y<6;Y++)if(e.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer[Y]),_.__webglDepthbuffer[Y]===void 0)_.__webglDepthbuffer[Y]=i.createRenderbuffer(),rt(_.__webglDepthbuffer[Y],E,!1);else{const Z=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,G=_.__webglDepthbuffer[Y];i.bindRenderbuffer(i.RENDERBUFFER,G),i.framebufferRenderbuffer(i.FRAMEBUFFER,Z,i.RENDERBUFFER,G)}}else if(e.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer),_.__webglDepthbuffer===void 0)_.__webglDepthbuffer=i.createRenderbuffer(),rt(_.__webglDepthbuffer,E,!1);else{const Y=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Z=_.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,Z),i.framebufferRenderbuffer(i.FRAMEBUFFER,Y,i.RENDERBUFFER,Z)}e.bindFramebuffer(i.FRAMEBUFFER,null)}function Nt(E,_,N){const Y=n.get(E);_!==void 0&&gt(Y.__webglFramebuffer,E,E.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),N!==void 0&&At(E)}function ie(E){const _=E.texture,N=n.get(E),Y=n.get(_);E.addEventListener("dispose",w);const Z=E.textures,G=E.isWebGLCubeRenderTarget===!0,_t=Z.length>1;if(_t||(Y.__webglTexture===void 0&&(Y.__webglTexture=i.createTexture()),Y.__version=_.version,a.memory.textures++),G){N.__webglFramebuffer=[];for(let st=0;st<6;st++)if(_.mipmaps&&_.mipmaps.length>0){N.__webglFramebuffer[st]=[];for(let ht=0;ht<_.mipmaps.length;ht++)N.__webglFramebuffer[st][ht]=i.createFramebuffer()}else N.__webglFramebuffer[st]=i.createFramebuffer()}else{if(_.mipmaps&&_.mipmaps.length>0){N.__webglFramebuffer=[];for(let st=0;st<_.mipmaps.length;st++)N.__webglFramebuffer[st]=i.createFramebuffer()}else N.__webglFramebuffer=i.createFramebuffer();if(_t)for(let st=0,ht=Z.length;st<ht;st++){const kt=n.get(Z[st]);kt.__webglTexture===void 0&&(kt.__webglTexture=i.createTexture(),a.memory.textures++)}if(E.samples>0&&Bt(E)===!1){N.__webglMultisampledFramebuffer=i.createFramebuffer(),N.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,N.__webglMultisampledFramebuffer);for(let st=0;st<Z.length;st++){const ht=Z[st];N.__webglColorRenderbuffer[st]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,N.__webglColorRenderbuffer[st]);const kt=s.convert(ht.format,ht.colorSpace),j=s.convert(ht.type),ut=T(ht.internalFormat,kt,j,ht.colorSpace,E.isXRRenderTarget===!0),yt=Ot(E);i.renderbufferStorageMultisample(i.RENDERBUFFER,yt,ut,E.width,E.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+st,i.RENDERBUFFER,N.__webglColorRenderbuffer[st])}i.bindRenderbuffer(i.RENDERBUFFER,null),E.depthBuffer&&(N.__webglDepthRenderbuffer=i.createRenderbuffer(),rt(N.__webglDepthRenderbuffer,E,!0)),e.bindFramebuffer(i.FRAMEBUFFER,null)}}if(G){e.bindTexture(i.TEXTURE_CUBE_MAP,Y.__webglTexture),Ut(i.TEXTURE_CUBE_MAP,_);for(let st=0;st<6;st++)if(_.mipmaps&&_.mipmaps.length>0)for(let ht=0;ht<_.mipmaps.length;ht++)gt(N.__webglFramebuffer[st][ht],E,_,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+st,ht);else gt(N.__webglFramebuffer[st],E,_,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+st,0);m(_)&&f(i.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(_t){for(let st=0,ht=Z.length;st<ht;st++){const kt=Z[st],j=n.get(kt);e.bindTexture(i.TEXTURE_2D,j.__webglTexture),Ut(i.TEXTURE_2D,kt),gt(N.__webglFramebuffer,E,kt,i.COLOR_ATTACHMENT0+st,i.TEXTURE_2D,0),m(kt)&&f(i.TEXTURE_2D)}e.unbindTexture()}else{let st=i.TEXTURE_2D;if((E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)&&(st=E.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),e.bindTexture(st,Y.__webglTexture),Ut(st,_),_.mipmaps&&_.mipmaps.length>0)for(let ht=0;ht<_.mipmaps.length;ht++)gt(N.__webglFramebuffer[ht],E,_,i.COLOR_ATTACHMENT0,st,ht);else gt(N.__webglFramebuffer,E,_,i.COLOR_ATTACHMENT0,st,0);m(_)&&f(st),e.unbindTexture()}E.depthBuffer&&At(E)}function Ht(E){const _=E.textures;for(let N=0,Y=_.length;N<Y;N++){const Z=_[N];if(m(Z)){const G=b(E),_t=n.get(Z).__webglTexture;e.bindTexture(G,_t),f(G),e.unbindTexture()}}}const ae=[],I=[];function Ce(E){if(E.samples>0){if(Bt(E)===!1){const _=E.textures,N=E.width,Y=E.height;let Z=i.COLOR_BUFFER_BIT;const G=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,_t=n.get(E),st=_.length>1;if(st)for(let ht=0;ht<_.length;ht++)e.bindFramebuffer(i.FRAMEBUFFER,_t.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ht,i.RENDERBUFFER,null),e.bindFramebuffer(i.FRAMEBUFFER,_t.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+ht,i.TEXTURE_2D,null,0);e.bindFramebuffer(i.READ_FRAMEBUFFER,_t.__webglMultisampledFramebuffer),e.bindFramebuffer(i.DRAW_FRAMEBUFFER,_t.__webglFramebuffer);for(let ht=0;ht<_.length;ht++){if(E.resolveDepthBuffer&&(E.depthBuffer&&(Z|=i.DEPTH_BUFFER_BIT),E.stencilBuffer&&E.resolveStencilBuffer&&(Z|=i.STENCIL_BUFFER_BIT)),st){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,_t.__webglColorRenderbuffer[ht]);const kt=n.get(_[ht]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,kt,0)}i.blitFramebuffer(0,0,N,Y,0,0,N,Y,Z,i.NEAREST),l===!0&&(ae.length=0,I.length=0,ae.push(i.COLOR_ATTACHMENT0+ht),E.depthBuffer&&E.resolveDepthBuffer===!1&&(ae.push(G),I.push(G),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,I)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,ae))}if(e.bindFramebuffer(i.READ_FRAMEBUFFER,null),e.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),st)for(let ht=0;ht<_.length;ht++){e.bindFramebuffer(i.FRAMEBUFFER,_t.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ht,i.RENDERBUFFER,_t.__webglColorRenderbuffer[ht]);const kt=n.get(_[ht]).__webglTexture;e.bindFramebuffer(i.FRAMEBUFFER,_t.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+ht,i.TEXTURE_2D,kt,0)}e.bindFramebuffer(i.DRAW_FRAMEBUFFER,_t.__webglMultisampledFramebuffer)}else if(E.depthBuffer&&E.resolveDepthBuffer===!1&&l){const _=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[_])}}}function Ot(E){return Math.min(r.maxSamples,E.samples)}function Bt(E){const _=n.get(E);return E.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&_.__useRenderToTexture!==!1}function St(E){const _=a.render.frame;h.get(E)!==_&&(h.set(E,_),E.update())}function te(E,_){const N=E.colorSpace,Y=E.format,Z=E.type;return E.isCompressedTexture===!0||E.isVideoTexture===!0||N!==Vn&&N!==Mn&&(Vt.getTransfer(N)===$t?(Y!==De||Z!==cn)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",N)),_}function Mt(E){return typeof HTMLImageElement!="undefined"&&E instanceof HTMLImageElement?(c.width=E.naturalWidth||E.width,c.height=E.naturalHeight||E.height):typeof VideoFrame!="undefined"&&E instanceof VideoFrame?(c.width=E.displayWidth,c.height=E.displayHeight):(c.width=E.width,c.height=E.height),c}this.allocateTextureUnit=z,this.resetTextureUnits=q,this.setTexture2D=$,this.setTexture2DArray=k,this.setTexture3D=Q,this.setTextureCube=H,this.rebindTextures=Nt,this.setupRenderTarget=ie,this.updateRenderTargetMipmap=Ht,this.updateMultisampleRenderTarget=Ce,this.setupDepthRenderbuffer=At,this.setupFrameBufferTexture=gt,this.useMultisampledRTT=Bt}function dm(i,t){function e(n,r=Mn){let s;const a=Vt.getTransfer(r);if(n===cn)return i.UNSIGNED_BYTE;if(n===fa)return i.UNSIGNED_SHORT_4_4_4_4;if(n===pa)return i.UNSIGNED_SHORT_5_5_5_1;if(n===vl)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===gl)return i.BYTE;if(n===_l)return i.SHORT;if(n===Oi)return i.UNSIGNED_SHORT;if(n===da)return i.INT;if(n===Bn)return i.UNSIGNED_INT;if(n===ke)return i.FLOAT;if(n===ki)return i.HALF_FLOAT;if(n===xl)return i.ALPHA;if(n===Ml)return i.RGB;if(n===De)return i.RGBA;if(n===Sl)return i.LUMINANCE;if(n===yl)return i.LUMINANCE_ALPHA;if(n===oi)return i.DEPTH_COMPONENT;if(n===fi)return i.DEPTH_STENCIL;if(n===ma)return i.RED;if(n===ga)return i.RED_INTEGER;if(n===El)return i.RG;if(n===_a)return i.RG_INTEGER;if(n===va)return i.RGBA_INTEGER;if(n===Tr||n===br||n===Ar||n===wr)if(a===$t)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===Tr)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===br)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Ar)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===wr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===Tr)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===br)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Ar)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===wr)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Ns||n===Fs||n===Os||n===Bs)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===Ns)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Fs)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Os)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Bs)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===zs||n===Vs||n===Hs)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(n===zs||n===Vs)return a===$t?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===Hs)return a===$t?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===ks||n===Gs||n===Ws||n===Xs||n===qs||n===Ys||n===Ks||n===Zs||n===$s||n===js||n===Js||n===Qs||n===ta||n===ea)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(n===ks)return a===$t?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Gs)return a===$t?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Ws)return a===$t?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Xs)return a===$t?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===qs)return a===$t?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Ys)return a===$t?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Ks)return a===$t?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Zs)return a===$t?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===$s)return a===$t?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===js)return a===$t?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Js)return a===$t?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Qs)return a===$t?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===ta)return a===$t?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===ea)return a===$t?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Rr||n===na||n===ia)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(n===Rr)return a===$t?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===na)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===ia)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Tl||n===ra||n===sa||n===aa)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(n===Rr)return s.COMPRESSED_RED_RGTC1_EXT;if(n===ra)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===sa)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===aa)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===di?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:e}}class fm extends xe{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}}class Ui extends se{constructor(){super(),this.isGroup=!0,this.type="Group"}}const pm={type:"move"};class ms{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ui,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 Ui,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new L,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new L),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Ui,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new L,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new L),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let r=null,s=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(c&&t.hand){a=!0;for(const v of t.hand.values()){const m=e.getJointPose(v,n),f=this._getHandJoint(c,v);m!==null&&(f.matrix.fromArray(m.transform.matrix),f.matrix.decompose(f.position,f.rotation,f.scale),f.matrixWorldNeedsUpdate=!0,f.jointRadius=m.radius),f.visible=m!==null}const h=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=h.position.distanceTo(u.position),p=.02,g=.005;c.inputState.pinching&&d>p+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!c.inputState.pinching&&d<=p-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(s=e.getPose(t.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(r=e.getPose(t.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(pm)))}return o!==null&&(o.visible=r!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){const n=new Ui;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}const mm=`
3801
+ void main() {
3802
+
3803
+ gl_Position = vec4( position, 1.0 );
3804
+
3805
+ }`,gm=`
3806
+ uniform sampler2DArray depthColor;
3807
+ uniform float depthWidth;
3808
+ uniform float depthHeight;
3809
+
3810
+ void main() {
3811
+
3812
+ vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
3813
+
3814
+ if ( coord.x >= 1.0 ) {
3815
+
3816
+ gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
3817
+
3818
+ } else {
3819
+
3820
+ gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
3821
+
3822
+ }
3823
+
3824
+ }`;class _m{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e,n){if(this.texture===null){const r=new de,s=t.properties.get(r);s.__webglTexture=e.texture,(e.depthNear!=n.depthNear||e.depthFar!=n.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=r}}getMesh(t){if(this.texture!==null&&this.mesh===null){const e=t.cameras[0].viewport,n=new An({vertexShader:mm,fragmentShader:gm,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new we(new Wi(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class vm extends Hn{constructor(t,e){super();const n=this;let r=null,s=1,a=null,o="local-floor",l=1,c=null,h=null,u=null,d=null,p=null,g=null;const v=new _m,m=e.getContextAttributes();let f=null,b=null;const T=[],S=[],B=new Ft;let A=null;const w=new xe;w.viewport=new Wt;const U=new xe;U.viewport=new Wt;const y=[w,U],M=new fm;let R=null,q=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(X){let tt=T[X];return tt===void 0&&(tt=new ms,T[X]=tt),tt.getTargetRaySpace()},this.getControllerGrip=function(X){let tt=T[X];return tt===void 0&&(tt=new ms,T[X]=tt),tt.getGripSpace()},this.getHand=function(X){let tt=T[X];return tt===void 0&&(tt=new ms,T[X]=tt),tt.getHandSpace()};function z(X){const tt=S.indexOf(X.inputSource);if(tt===-1)return;const gt=T[tt];gt!==void 0&&(gt.update(X.inputSource,X.frame,c||a),gt.dispatchEvent({type:X.type,data:X.inputSource}))}function W(){r.removeEventListener("select",z),r.removeEventListener("selectstart",z),r.removeEventListener("selectend",z),r.removeEventListener("squeeze",z),r.removeEventListener("squeezestart",z),r.removeEventListener("squeezeend",z),r.removeEventListener("end",W),r.removeEventListener("inputsourceschange",$);for(let X=0;X<T.length;X++){const tt=S[X];tt!==null&&(S[X]=null,T[X].disconnect(tt))}R=null,q=null,v.reset(),t.setRenderTarget(f),p=null,d=null,u=null,r=null,b=null,jt.stop(),n.isPresenting=!1,t.setPixelRatio(A),t.setSize(B.width,B.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(X){s=X,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(X){o=X,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(X){c=X},this.getBaseLayer=function(){return d!==null?d:p},this.getBinding=function(){return u},this.getFrame=function(){return g},this.getSession=function(){return r},this.setSession=function(X){return Hr(this,null,function*(){if(r=X,r!==null){if(f=t.getRenderTarget(),r.addEventListener("select",z),r.addEventListener("selectstart",z),r.addEventListener("selectend",z),r.addEventListener("squeeze",z),r.addEventListener("squeezestart",z),r.addEventListener("squeezeend",z),r.addEventListener("end",W),r.addEventListener("inputsourceschange",$),m.xrCompatible!==!0&&(yield e.makeXRCompatible()),A=t.getPixelRatio(),t.getSize(B),r.renderState.layers===void 0){const tt={antialias:m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:s};p=new XRWebGLLayer(r,e,tt),r.updateRenderState({baseLayer:p}),t.setPixelRatio(1),t.setSize(p.framebufferWidth,p.framebufferHeight,!1),b=new zn(p.framebufferWidth,p.framebufferHeight,{format:De,type:cn,colorSpace:t.outputColorSpace,stencilBuffer:m.stencil})}else{let tt=null,gt=null,rt=null;m.depth&&(rt=m.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,tt=m.stencil?fi:oi,gt=m.stencil?di:Bn);const Et={colorFormat:e.RGBA8,depthFormat:rt,scaleFactor:s};u=new XRWebGLBinding(r,e),d=u.createProjectionLayer(Et),r.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),b=new zn(d.textureWidth,d.textureHeight,{format:De,type:cn,depthTexture:new Ol(d.textureWidth,d.textureHeight,gt,void 0,void 0,void 0,void 0,void 0,void 0,tt),stencilBuffer:m.stencil,colorSpace:t.outputColorSpace,samples:m.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1})}b.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=yield r.requestReferenceSpace(o),jt.setContext(r),jt.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}})},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return v.getDepthTexture()};function $(X){for(let tt=0;tt<X.removed.length;tt++){const gt=X.removed[tt],rt=S.indexOf(gt);rt>=0&&(S[rt]=null,T[rt].disconnect(gt))}for(let tt=0;tt<X.added.length;tt++){const gt=X.added[tt];let rt=S.indexOf(gt);if(rt===-1){for(let At=0;At<T.length;At++)if(At>=S.length){S.push(gt),rt=At;break}else if(S[At]===null){S[At]=gt,rt=At;break}if(rt===-1)break}const Et=T[rt];Et&&Et.connect(gt)}}const k=new L,Q=new L;function H(X,tt,gt){k.setFromMatrixPosition(tt.matrixWorld),Q.setFromMatrixPosition(gt.matrixWorld);const rt=k.distanceTo(Q),Et=tt.projectionMatrix.elements,At=gt.projectionMatrix.elements,Nt=Et[14]/(Et[10]-1),ie=Et[14]/(Et[10]+1),Ht=(Et[9]+1)/Et[5],ae=(Et[9]-1)/Et[5],I=(Et[8]-1)/Et[0],Ce=(At[8]+1)/At[0],Ot=Nt*I,Bt=Nt*Ce,St=rt/(-I+Ce),te=St*-I;if(tt.matrixWorld.decompose(X.position,X.quaternion,X.scale),X.translateX(te),X.translateZ(St),X.matrixWorld.compose(X.position,X.quaternion,X.scale),X.matrixWorldInverse.copy(X.matrixWorld).invert(),Et[10]===-1)X.projectionMatrix.copy(tt.projectionMatrix),X.projectionMatrixInverse.copy(tt.projectionMatrixInverse);else{const Mt=Nt+St,E=ie+St,_=Ot-te,N=Bt+(rt-te),Y=Ht*ie/E*Mt,Z=ae*ie/E*Mt;X.projectionMatrix.makePerspective(_,N,Y,Z,Mt,E),X.projectionMatrixInverse.copy(X.projectionMatrix).invert()}}function it(X,tt){tt===null?X.matrixWorld.copy(X.matrix):X.matrixWorld.multiplyMatrices(tt.matrixWorld,X.matrix),X.matrixWorldInverse.copy(X.matrixWorld).invert()}this.updateCamera=function(X){if(r===null)return;let tt=X.near,gt=X.far;v.texture!==null&&(v.depthNear>0&&(tt=v.depthNear),v.depthFar>0&&(gt=v.depthFar)),M.near=U.near=w.near=tt,M.far=U.far=w.far=gt,(R!==M.near||q!==M.far)&&(r.updateRenderState({depthNear:M.near,depthFar:M.far}),R=M.near,q=M.far),w.layers.mask=X.layers.mask|2,U.layers.mask=X.layers.mask|4,M.layers.mask=w.layers.mask|U.layers.mask;const rt=X.parent,Et=M.cameras;it(M,rt);for(let At=0;At<Et.length;At++)it(Et[At],rt);Et.length===2?H(M,w,U):M.projectionMatrix.copy(w.projectionMatrix),ct(X,M,rt)};function ct(X,tt,gt){gt===null?X.matrix.copy(tt.matrixWorld):(X.matrix.copy(gt.matrixWorld),X.matrix.invert(),X.matrix.multiply(tt.matrixWorld)),X.matrix.decompose(X.position,X.quaternion,X.scale),X.updateMatrixWorld(!0),X.projectionMatrix.copy(tt.projectionMatrix),X.projectionMatrixInverse.copy(tt.projectionMatrixInverse),X.isPerspectiveCamera&&(X.fov=pi*2*Math.atan(1/X.projectionMatrix.elements[5]),X.zoom=1)}this.getCamera=function(){return M},this.getFoveation=function(){if(!(d===null&&p===null))return l},this.setFoveation=function(X){l=X,d!==null&&(d.fixedFoveation=X),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=X)},this.hasDepthSensing=function(){return v.texture!==null},this.getDepthSensingMesh=function(){return v.getMesh(M)};let xt=null;function Ut(X,tt){if(h=tt.getViewerPose(c||a),g=tt,h!==null){const gt=h.views;p!==null&&(t.setRenderTargetFramebuffer(b,p.framebuffer),t.setRenderTarget(b));let rt=!1;gt.length!==M.cameras.length&&(M.cameras.length=0,rt=!0);for(let At=0;At<gt.length;At++){const Nt=gt[At];let ie=null;if(p!==null)ie=p.getViewport(Nt);else{const ae=u.getViewSubImage(d,Nt);ie=ae.viewport,At===0&&(t.setRenderTargetTextures(b,ae.colorTexture,d.ignoreDepthValues?void 0:ae.depthStencilTexture),t.setRenderTarget(b))}let Ht=y[At];Ht===void 0&&(Ht=new xe,Ht.layers.enable(At),Ht.viewport=new Wt,y[At]=Ht),Ht.matrix.fromArray(Nt.transform.matrix),Ht.matrix.decompose(Ht.position,Ht.quaternion,Ht.scale),Ht.projectionMatrix.fromArray(Nt.projectionMatrix),Ht.projectionMatrixInverse.copy(Ht.projectionMatrix).invert(),Ht.viewport.set(ie.x,ie.y,ie.width,ie.height),At===0&&(M.matrix.copy(Ht.matrix),M.matrix.decompose(M.position,M.quaternion,M.scale)),rt===!0&&M.cameras.push(Ht)}const Et=r.enabledFeatures;if(Et&&Et.includes("depth-sensing")){const At=u.getDepthInformation(gt[0]);At&&At.isValid&&At.texture&&v.init(t,At,r.renderState)}}for(let gt=0;gt<T.length;gt++){const rt=S[gt],Et=T[gt];rt!==null&&Et!==void 0&&Et.update(rt,tt,c||a)}xt&&xt(X,tt),tt.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:tt}),g=null}const jt=new Fl;jt.setAnimationLoop(Ut),this.setAnimationLoop=function(X){xt=X},this.dispose=function(){}}}const Un=new Ye,xm=new Dt;function Mm(i,t){function e(m,f){m.matrixAutoUpdate===!0&&m.updateMatrix(),f.value.copy(m.matrix)}function n(m,f){f.color.getRGB(m.fogColor.value,Il(i)),f.isFog?(m.fogNear.value=f.near,m.fogFar.value=f.far):f.isFogExp2&&(m.fogDensity.value=f.density)}function r(m,f,b,T,S){f.isMeshBasicMaterial||f.isMeshLambertMaterial?s(m,f):f.isMeshToonMaterial?(s(m,f),u(m,f)):f.isMeshPhongMaterial?(s(m,f),h(m,f)):f.isMeshStandardMaterial?(s(m,f),d(m,f),f.isMeshPhysicalMaterial&&p(m,f,S)):f.isMeshMatcapMaterial?(s(m,f),g(m,f)):f.isMeshDepthMaterial?s(m,f):f.isMeshDistanceMaterial?(s(m,f),v(m,f)):f.isMeshNormalMaterial?s(m,f):f.isLineBasicMaterial?(a(m,f),f.isLineDashedMaterial&&o(m,f)):f.isPointsMaterial?l(m,f,b,T):f.isSpriteMaterial?c(m,f):f.isShadowMaterial?(m.color.value.copy(f.color),m.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function s(m,f){m.opacity.value=f.opacity,f.color&&m.diffuse.value.copy(f.color),f.emissive&&m.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity),f.map&&(m.map.value=f.map,e(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,e(f.alphaMap,m.alphaMapTransform)),f.bumpMap&&(m.bumpMap.value=f.bumpMap,e(f.bumpMap,m.bumpMapTransform),m.bumpScale.value=f.bumpScale,f.side===Me&&(m.bumpScale.value*=-1)),f.normalMap&&(m.normalMap.value=f.normalMap,e(f.normalMap,m.normalMapTransform),m.normalScale.value.copy(f.normalScale),f.side===Me&&m.normalScale.value.negate()),f.displacementMap&&(m.displacementMap.value=f.displacementMap,e(f.displacementMap,m.displacementMapTransform),m.displacementScale.value=f.displacementScale,m.displacementBias.value=f.displacementBias),f.emissiveMap&&(m.emissiveMap.value=f.emissiveMap,e(f.emissiveMap,m.emissiveMapTransform)),f.specularMap&&(m.specularMap.value=f.specularMap,e(f.specularMap,m.specularMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest);const b=t.get(f),T=b.envMap,S=b.envMapRotation;T&&(m.envMap.value=T,Un.copy(S),Un.x*=-1,Un.y*=-1,Un.z*=-1,T.isCubeTexture&&T.isRenderTargetTexture===!1&&(Un.y*=-1,Un.z*=-1),m.envMapRotation.value.setFromMatrix4(xm.makeRotationFromEuler(Un)),m.flipEnvMap.value=T.isCubeTexture&&T.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=f.reflectivity,m.ior.value=f.ior,m.refractionRatio.value=f.refractionRatio),f.lightMap&&(m.lightMap.value=f.lightMap,m.lightMapIntensity.value=f.lightMapIntensity,e(f.lightMap,m.lightMapTransform)),f.aoMap&&(m.aoMap.value=f.aoMap,m.aoMapIntensity.value=f.aoMapIntensity,e(f.aoMap,m.aoMapTransform))}function a(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,f.map&&(m.map.value=f.map,e(f.map,m.mapTransform))}function o(m,f){m.dashSize.value=f.dashSize,m.totalSize.value=f.dashSize+f.gapSize,m.scale.value=f.scale}function l(m,f,b,T){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.size.value=f.size*b,m.scale.value=T*.5,f.map&&(m.map.value=f.map,e(f.map,m.uvTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,e(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function c(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.rotation.value=f.rotation,f.map&&(m.map.value=f.map,e(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,e(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function h(m,f){m.specular.value.copy(f.specular),m.shininess.value=Math.max(f.shininess,1e-4)}function u(m,f){f.gradientMap&&(m.gradientMap.value=f.gradientMap)}function d(m,f){m.metalness.value=f.metalness,f.metalnessMap&&(m.metalnessMap.value=f.metalnessMap,e(f.metalnessMap,m.metalnessMapTransform)),m.roughness.value=f.roughness,f.roughnessMap&&(m.roughnessMap.value=f.roughnessMap,e(f.roughnessMap,m.roughnessMapTransform)),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)}function p(m,f,b){m.ior.value=f.ior,f.sheen>0&&(m.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),m.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(m.sheenColorMap.value=f.sheenColorMap,e(f.sheenColorMap,m.sheenColorMapTransform)),f.sheenRoughnessMap&&(m.sheenRoughnessMap.value=f.sheenRoughnessMap,e(f.sheenRoughnessMap,m.sheenRoughnessMapTransform))),f.clearcoat>0&&(m.clearcoat.value=f.clearcoat,m.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(m.clearcoatMap.value=f.clearcoatMap,e(f.clearcoatMap,m.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,e(f.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(m.clearcoatNormalMap.value=f.clearcoatNormalMap,e(f.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===Me&&m.clearcoatNormalScale.value.negate())),f.dispersion>0&&(m.dispersion.value=f.dispersion),f.iridescence>0&&(m.iridescence.value=f.iridescence,m.iridescenceIOR.value=f.iridescenceIOR,m.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap&&(m.iridescenceMap.value=f.iridescenceMap,e(f.iridescenceMap,m.iridescenceMapTransform)),f.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=f.iridescenceThicknessMap,e(f.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),f.transmission>0&&(m.transmission.value=f.transmission,m.transmissionSamplerMap.value=b.texture,m.transmissionSamplerSize.value.set(b.width,b.height),f.transmissionMap&&(m.transmissionMap.value=f.transmissionMap,e(f.transmissionMap,m.transmissionMapTransform)),m.thickness.value=f.thickness,f.thicknessMap&&(m.thicknessMap.value=f.thicknessMap,e(f.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=f.attenuationDistance,m.attenuationColor.value.copy(f.attenuationColor)),f.anisotropy>0&&(m.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap&&(m.anisotropyMap.value=f.anisotropyMap,e(f.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=f.specularIntensity,m.specularColor.value.copy(f.specularColor),f.specularColorMap&&(m.specularColorMap.value=f.specularColorMap,e(f.specularColorMap,m.specularColorMapTransform)),f.specularIntensityMap&&(m.specularIntensityMap.value=f.specularIntensityMap,e(f.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,f){f.matcap&&(m.matcap.value=f.matcap)}function v(m,f){const b=t.get(f).light;m.referencePosition.value.setFromMatrixPosition(b.matrixWorld),m.nearDistance.value=b.shadow.camera.near,m.farDistance.value=b.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function Sm(i,t,e,n){let r={},s={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(b,T){const S=T.program;n.uniformBlockBinding(b,S)}function c(b,T){let S=r[b.id];S===void 0&&(g(b),S=h(b),r[b.id]=S,b.addEventListener("dispose",m));const B=T.program;n.updateUBOMapping(b,B);const A=t.render.frame;s[b.id]!==A&&(d(b),s[b.id]=A)}function h(b){const T=u();b.__bindingPointIndex=T;const S=i.createBuffer(),B=b.__size,A=b.usage;return i.bindBuffer(i.UNIFORM_BUFFER,S),i.bufferData(i.UNIFORM_BUFFER,B,A),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,T,S),S}function u(){for(let b=0;b<o;b++)if(a.indexOf(b)===-1)return a.push(b),b;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(b){const T=r[b.id],S=b.uniforms,B=b.__cache;i.bindBuffer(i.UNIFORM_BUFFER,T);for(let A=0,w=S.length;A<w;A++){const U=Array.isArray(S[A])?S[A]:[S[A]];for(let y=0,M=U.length;y<M;y++){const R=U[y];if(p(R,A,y,B)===!0){const q=R.__offset,z=Array.isArray(R.value)?R.value:[R.value];let W=0;for(let $=0;$<z.length;$++){const k=z[$],Q=v(k);typeof k=="number"||typeof k=="boolean"?(R.__data[0]=k,i.bufferSubData(i.UNIFORM_BUFFER,q+W,R.__data)):k.isMatrix3?(R.__data[0]=k.elements[0],R.__data[1]=k.elements[1],R.__data[2]=k.elements[2],R.__data[3]=0,R.__data[4]=k.elements[3],R.__data[5]=k.elements[4],R.__data[6]=k.elements[5],R.__data[7]=0,R.__data[8]=k.elements[6],R.__data[9]=k.elements[7],R.__data[10]=k.elements[8],R.__data[11]=0):(k.toArray(R.__data,W),W+=Q.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,q,R.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function p(b,T,S,B){const A=b.value,w=T+"_"+S;if(B[w]===void 0)return typeof A=="number"||typeof A=="boolean"?B[w]=A:B[w]=A.clone(),!0;{const U=B[w];if(typeof A=="number"||typeof A=="boolean"){if(U!==A)return B[w]=A,!0}else if(U.equals(A)===!1)return U.copy(A),!0}return!1}function g(b){const T=b.uniforms;let S=0;const B=16;for(let w=0,U=T.length;w<U;w++){const y=Array.isArray(T[w])?T[w]:[T[w]];for(let M=0,R=y.length;M<R;M++){const q=y[M],z=Array.isArray(q.value)?q.value:[q.value];for(let W=0,$=z.length;W<$;W++){const k=z[W],Q=v(k),H=S%B,it=H%Q.boundary,ct=H+it;S+=it,ct!==0&&B-ct<Q.storage&&(S+=B-ct),q.__data=new Float32Array(Q.storage/Float32Array.BYTES_PER_ELEMENT),q.__offset=S,S+=Q.storage}}}const A=S%B;return A>0&&(S+=B-A),b.__size=S,b.__cache={},this}function v(b){const T={boundary:0,storage:0};return typeof b=="number"||typeof b=="boolean"?(T.boundary=4,T.storage=4):b.isVector2?(T.boundary=8,T.storage=8):b.isVector3||b.isColor?(T.boundary=16,T.storage=12):b.isVector4?(T.boundary=16,T.storage=16):b.isMatrix3?(T.boundary=48,T.storage=48):b.isMatrix4?(T.boundary=64,T.storage=64):b.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",b),T}function m(b){const T=b.target;T.removeEventListener("dispose",m);const S=a.indexOf(T.__bindingPointIndex);a.splice(S,1),i.deleteBuffer(r[T.id]),delete r[T.id],delete s[T.id]}function f(){for(const b in r)i.deleteBuffer(r[b]);a=[],r={},s={}}return{bind:l,update:c,dispose:f}}class ym{constructor(t={}){const{canvas:e=ch(),context:n=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reverseDepthBuffer:d=!1}=t;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext!="undefined"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=n.getContextAttributes().alpha}else p=a;const g=new Uint32Array(4),v=new Int32Array(4);let m=null,f=null;const b=[],T=[];this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Ae,this.toneMapping=bn,this.toneMappingExposure=1;const S=this;let B=!1,A=0,w=0,U=null,y=-1,M=null;const R=new Wt,q=new Wt;let z=null;const W=new It(0);let $=0,k=e.width,Q=e.height,H=1,it=null,ct=null;const xt=new Wt(0,0,k,Q),Ut=new Wt(0,0,k,Q);let jt=!1;const X=new ya;let tt=!1,gt=!1;const rt=new Dt,Et=new Dt,At=new L,Nt=new Wt,ie={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ht=!1;function ae(){return U===null?H:1}let I=n;function Ce(x,P){return e.getContext(x,P)}try{const x={alpha:!0,depth:r,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine","three.js r170"),e.addEventListener("webglcontextlost",K,!1),e.addEventListener("webglcontextrestored",lt,!1),e.addEventListener("webglcontextcreationerror",at,!1),I===null){const P="webgl2";if(I=Ce(P,x),I===null)throw Ce(P)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(x){throw console.error("THREE.WebGLRenderer: "+x.message),x}let Ot,Bt,St,te,Mt,E,_,N,Y,Z,G,_t,st,ht,kt,j,ut,yt,Tt,dt,zt,Pt,Jt,C;function nt(){Ot=new wf(I),Ot.init(),Pt=new dm(I,Ot),Bt=new Sf(I,Ot,t,Pt),St=new cm(I,Ot),Bt.reverseDepthBuffer&&d&&St.buffers.depth.setReversed(!0),te=new Pf(I),Mt=new Kp,E=new um(I,Ot,St,Mt,Bt,Pt,te),_=new Ef(S),N=new Af(S),Y=new Fh(I),Jt=new xf(I,Y),Z=new Rf(I,Y,te,Jt),G=new Df(I,Z,Y,te),Tt=new Lf(I,Bt,E),j=new yf(Mt),_t=new Yp(S,_,N,Ot,Bt,Jt,j),st=new Mm(S,Mt),ht=new $p,kt=new nm(Ot),yt=new vf(S,_,N,St,G,p,l),ut=new om(S,G,Bt),C=new Sm(I,te,Bt,St),dt=new Mf(I,Ot,te),zt=new Cf(I,Ot,te),te.programs=_t.programs,S.capabilities=Bt,S.extensions=Ot,S.properties=Mt,S.renderLists=ht,S.shadowMap=ut,S.state=St,S.info=te}nt();const V=new vm(S,I);this.xr=V,this.getContext=function(){return I},this.getContextAttributes=function(){return I.getContextAttributes()},this.forceContextLoss=function(){const x=Ot.get("WEBGL_lose_context");x&&x.loseContext()},this.forceContextRestore=function(){const x=Ot.get("WEBGL_lose_context");x&&x.restoreContext()},this.getPixelRatio=function(){return H},this.setPixelRatio=function(x){x!==void 0&&(H=x,this.setSize(k,Q,!1))},this.getSize=function(x){return x.set(k,Q)},this.setSize=function(x,P,F=!0){if(V.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}k=x,Q=P,e.width=Math.floor(x*H),e.height=Math.floor(P*H),F===!0&&(e.style.width=x+"px",e.style.height=P+"px"),this.setViewport(0,0,x,P)},this.getDrawingBufferSize=function(x){return x.set(k*H,Q*H).floor()},this.setDrawingBufferSize=function(x,P,F){k=x,Q=P,H=F,e.width=Math.floor(x*F),e.height=Math.floor(P*F),this.setViewport(0,0,x,P)},this.getCurrentViewport=function(x){return x.copy(R)},this.getViewport=function(x){return x.copy(xt)},this.setViewport=function(x,P,F,O){x.isVector4?xt.set(x.x,x.y,x.z,x.w):xt.set(x,P,F,O),St.viewport(R.copy(xt).multiplyScalar(H).round())},this.getScissor=function(x){return x.copy(Ut)},this.setScissor=function(x,P,F,O){x.isVector4?Ut.set(x.x,x.y,x.z,x.w):Ut.set(x,P,F,O),St.scissor(q.copy(Ut).multiplyScalar(H).round())},this.getScissorTest=function(){return jt},this.setScissorTest=function(x){St.setScissorTest(jt=x)},this.setOpaqueSort=function(x){it=x},this.setTransparentSort=function(x){ct=x},this.getClearColor=function(x){return x.copy(yt.getClearColor())},this.setClearColor=function(){yt.setClearColor.apply(yt,arguments)},this.getClearAlpha=function(){return yt.getClearAlpha()},this.setClearAlpha=function(){yt.setClearAlpha.apply(yt,arguments)},this.clear=function(x=!0,P=!0,F=!0){let O=0;if(x){let D=!1;if(U!==null){const J=U.texture.format;D=J===va||J===_a||J===ga}if(D){const J=U.texture.type,ot=J===cn||J===Bn||J===Oi||J===di||J===fa||J===pa,ft=yt.getClearColor(),pt=yt.getClearAlpha(),bt=ft.r,Rt=ft.g,mt=ft.b;ot?(g[0]=bt,g[1]=Rt,g[2]=mt,g[3]=pt,I.clearBufferuiv(I.COLOR,0,g)):(v[0]=bt,v[1]=Rt,v[2]=mt,v[3]=pt,I.clearBufferiv(I.COLOR,0,v))}else O|=I.COLOR_BUFFER_BIT}P&&(O|=I.DEPTH_BUFFER_BIT),F&&(O|=I.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),I.clear(O)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",K,!1),e.removeEventListener("webglcontextrestored",lt,!1),e.removeEventListener("webglcontextcreationerror",at,!1),ht.dispose(),kt.dispose(),Mt.dispose(),_.dispose(),N.dispose(),G.dispose(),Jt.dispose(),C.dispose(),_t.dispose(),V.dispose(),V.removeEventListener("sessionstart",Ua),V.removeEventListener("sessionend",Na),Rn.stop()};function K(x){x.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),B=!0}function lt(){console.log("THREE.WebGLRenderer: Context Restored."),B=!1;const x=te.autoReset,P=ut.enabled,F=ut.autoUpdate,O=ut.needsUpdate,D=ut.type;nt(),te.autoReset=x,ut.enabled=P,ut.autoUpdate=F,ut.needsUpdate=O,ut.type=D}function at(x){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",x.statusMessage)}function wt(x){const P=x.target;P.removeEventListener("dispose",wt),re(P)}function re(x){fe(x),Mt.remove(x)}function fe(x){const P=Mt.get(x).programs;P!==void 0&&(P.forEach(function(F){_t.releaseProgram(F)}),x.isShaderMaterial&&_t.releaseShaderCache(x))}this.renderBufferDirect=function(x,P,F,O,D,J){P===null&&(P=ie);const ot=D.isMesh&&D.matrixWorld.determinant()<0,ft=$l(x,P,F,O,D);St.setMaterial(O,ot);let pt=F.index,bt=1;if(O.wireframe===!0){if(pt=Z.getWireframeAttribute(F),pt===void 0)return;bt=2}const Rt=F.drawRange,mt=F.attributes.position;let Gt=Rt.start*bt,Qt=(Rt.start+Rt.count)*bt;J!==null&&(Gt=Math.max(Gt,J.start*bt),Qt=Math.min(Qt,(J.start+J.count)*bt)),pt!==null?(Gt=Math.max(Gt,0),Qt=Math.min(Qt,pt.count)):mt!=null&&(Gt=Math.max(Gt,0),Qt=Math.min(Qt,mt.count));const ee=Qt-Gt;if(ee<0||ee===1/0)return;Jt.setup(D,O,ft,F,pt);let ve,Xt=dt;if(pt!==null&&(ve=Y.get(pt),Xt=zt,Xt.setIndex(ve)),D.isMesh)O.wireframe===!0?(St.setLineWidth(O.wireframeLinewidth*ae()),Xt.setMode(I.LINES)):Xt.setMode(I.TRIANGLES);else if(D.isLine){let vt=O.linewidth;vt===void 0&&(vt=1),St.setLineWidth(vt*ae()),D.isLineSegments?Xt.setMode(I.LINES):D.isLineLoop?Xt.setMode(I.LINE_LOOP):Xt.setMode(I.LINE_STRIP)}else D.isPoints?Xt.setMode(I.POINTS):D.isSprite&&Xt.setMode(I.TRIANGLES);if(D.isBatchedMesh)if(D._multiDrawInstances!==null)Xt.renderMultiDrawInstances(D._multiDrawStarts,D._multiDrawCounts,D._multiDrawCount,D._multiDrawInstances);else if(Ot.get("WEBGL_multi_draw"))Xt.renderMultiDraw(D._multiDrawStarts,D._multiDrawCounts,D._multiDrawCount);else{const vt=D._multiDrawStarts,je=D._multiDrawCounts,qt=D._multiDrawCount,Ne=pt?Y.get(pt).bytesPerElement:1,Gn=Mt.get(O).currentProgram.getUniforms();for(let Ee=0;Ee<qt;Ee++)Gn.setValue(I,"_gl_DrawID",Ee),Xt.render(vt[Ee]/Ne,je[Ee])}else if(D.isInstancedMesh)Xt.renderInstances(Gt,ee,D.count);else if(F.isInstancedBufferGeometry){const vt=F._maxInstanceCount!==void 0?F._maxInstanceCount:1/0,je=Math.min(F.instanceCount,vt);Xt.renderInstances(Gt,ee,je)}else Xt.render(Gt,ee)};function Yt(x,P,F){x.transparent===!0&&x.side===qe&&x.forceSinglePass===!1?(x.side=Me,x.needsUpdate=!0,Ki(x,P,F),x.side=ln,x.needsUpdate=!0,Ki(x,P,F),x.side=qe):Ki(x,P,F)}this.compile=function(x,P,F=null){F===null&&(F=x),f=kt.get(F),f.init(P),T.push(f),F.traverseVisible(function(D){D.isLight&&D.layers.test(P.layers)&&(f.pushLight(D),D.castShadow&&f.pushShadow(D))}),x!==F&&x.traverseVisible(function(D){D.isLight&&D.layers.test(P.layers)&&(f.pushLight(D),D.castShadow&&f.pushShadow(D))}),f.setupLights();const O=new Set;return x.traverse(function(D){if(!(D.isMesh||D.isPoints||D.isLine||D.isSprite))return;const J=D.material;if(J)if(Array.isArray(J))for(let ot=0;ot<J.length;ot++){const ft=J[ot];Yt(ft,F,D),O.add(ft)}else Yt(J,F,D),O.add(J)}),T.pop(),f=null,O},this.compileAsync=function(x,P,F=null){const O=this.compile(x,P,F);return new Promise(D=>{function J(){if(O.forEach(function(ot){Mt.get(ot).currentProgram.isReady()&&O.delete(ot)}),O.size===0){D(x);return}setTimeout(J,10)}Ot.get("KHR_parallel_shader_compile")!==null?J():setTimeout(J,10)})};let Ue=null;function $e(x){Ue&&Ue(x)}function Ua(){Rn.stop()}function Na(){Rn.start()}const Rn=new Fl;Rn.setAnimationLoop($e),typeof self!="undefined"&&Rn.setContext(self),this.setAnimationLoop=function(x){Ue=x,V.setAnimationLoop(x),x===null?Rn.stop():Rn.start()},V.addEventListener("sessionstart",Ua),V.addEventListener("sessionend",Na),this.render=function(x,P){if(P!==void 0&&P.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(B===!0)return;if(x.matrixWorldAutoUpdate===!0&&x.updateMatrixWorld(),P.parent===null&&P.matrixWorldAutoUpdate===!0&&P.updateMatrixWorld(),V.enabled===!0&&V.isPresenting===!0&&(V.cameraAutoUpdate===!0&&V.updateCamera(P),P=V.getCamera()),x.isScene===!0&&x.onBeforeRender(S,x,P,U),f=kt.get(x,T.length),f.init(P),T.push(f),Et.multiplyMatrices(P.projectionMatrix,P.matrixWorldInverse),X.setFromProjectionMatrix(Et),gt=this.localClippingEnabled,tt=j.init(this.clippingPlanes,gt),m=ht.get(x,b.length),m.init(),b.push(m),V.enabled===!0&&V.isPresenting===!0){const J=S.xr.getDepthSensingMesh();J!==null&&Vr(J,P,-1/0,S.sortObjects)}Vr(x,P,0,S.sortObjects),m.finish(),S.sortObjects===!0&&m.sort(it,ct),Ht=V.enabled===!1||V.isPresenting===!1||V.hasDepthSensing()===!1,Ht&&yt.addToRenderList(m,x),this.info.render.frame++,tt===!0&&j.beginShadows();const F=f.state.shadowsArray;ut.render(F,x,P),tt===!0&&j.endShadows(),this.info.autoReset===!0&&this.info.reset();const O=m.opaque,D=m.transmissive;if(f.setupLights(),P.isArrayCamera){const J=P.cameras;if(D.length>0)for(let ot=0,ft=J.length;ot<ft;ot++){const pt=J[ot];Oa(O,D,x,pt)}Ht&&yt.render(x);for(let ot=0,ft=J.length;ot<ft;ot++){const pt=J[ot];Fa(m,x,pt,pt.viewport)}}else D.length>0&&Oa(O,D,x,P),Ht&&yt.render(x),Fa(m,x,P);U!==null&&(E.updateMultisampleRenderTarget(U),E.updateRenderTargetMipmap(U)),x.isScene===!0&&x.onAfterRender(S,x,P),Jt.resetDefaultState(),y=-1,M=null,T.pop(),T.length>0?(f=T[T.length-1],tt===!0&&j.setGlobalState(S.clippingPlanes,f.state.camera)):f=null,b.pop(),b.length>0?m=b[b.length-1]:m=null};function Vr(x,P,F,O){if(x.visible===!1)return;if(x.layers.test(P.layers)){if(x.isGroup)F=x.renderOrder;else if(x.isLOD)x.autoUpdate===!0&&x.update(P);else if(x.isLight)f.pushLight(x),x.castShadow&&f.pushShadow(x);else if(x.isSprite){if(!x.frustumCulled||X.intersectsSprite(x)){O&&Nt.setFromMatrixPosition(x.matrixWorld).applyMatrix4(Et);const ot=G.update(x),ft=x.material;ft.visible&&m.push(x,ot,ft,F,Nt.z,null)}}else if((x.isMesh||x.isLine||x.isPoints)&&(!x.frustumCulled||X.intersectsObject(x))){const ot=G.update(x),ft=x.material;if(O&&(x.boundingSphere!==void 0?(x.boundingSphere===null&&x.computeBoundingSphere(),Nt.copy(x.boundingSphere.center)):(ot.boundingSphere===null&&ot.computeBoundingSphere(),Nt.copy(ot.boundingSphere.center)),Nt.applyMatrix4(x.matrixWorld).applyMatrix4(Et)),Array.isArray(ft)){const pt=ot.groups;for(let bt=0,Rt=pt.length;bt<Rt;bt++){const mt=pt[bt],Gt=ft[mt.materialIndex];Gt&&Gt.visible&&m.push(x,ot,Gt,F,Nt.z,mt)}}else ft.visible&&m.push(x,ot,ft,F,Nt.z,null)}}const J=x.children;for(let ot=0,ft=J.length;ot<ft;ot++)Vr(J[ot],P,F,O)}function Fa(x,P,F,O){const D=x.opaque,J=x.transmissive,ot=x.transparent;f.setupLightsView(F),tt===!0&&j.setGlobalState(S.clippingPlanes,F),O&&St.viewport(R.copy(O)),D.length>0&&Yi(D,P,F),J.length>0&&Yi(J,P,F),ot.length>0&&Yi(ot,P,F),St.buffers.depth.setTest(!0),St.buffers.depth.setMask(!0),St.buffers.color.setMask(!0),St.setPolygonOffset(!1)}function Oa(x,P,F,O){if((F.isScene===!0?F.overrideMaterial:null)!==null)return;f.state.transmissionRenderTarget[O.id]===void 0&&(f.state.transmissionRenderTarget[O.id]=new zn(1,1,{generateMipmaps:!0,type:Ot.has("EXT_color_buffer_half_float")||Ot.has("EXT_color_buffer_float")?ki:cn,minFilter:yn,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Vt.workingColorSpace}));const J=f.state.transmissionRenderTarget[O.id],ot=O.viewport||R;J.setSize(ot.z,ot.w);const ft=S.getRenderTarget();S.setRenderTarget(J),S.getClearColor(W),$=S.getClearAlpha(),$<1&&S.setClearColor(16777215,.5),S.clear(),Ht&&yt.render(F);const pt=S.toneMapping;S.toneMapping=bn;const bt=O.viewport;if(O.viewport!==void 0&&(O.viewport=void 0),f.setupLightsView(O),tt===!0&&j.setGlobalState(S.clippingPlanes,O),Yi(x,F,O),E.updateMultisampleRenderTarget(J),E.updateRenderTargetMipmap(J),Ot.has("WEBGL_multisampled_render_to_texture")===!1){let Rt=!1;for(let mt=0,Gt=P.length;mt<Gt;mt++){const Qt=P[mt],ee=Qt.object,ve=Qt.geometry,Xt=Qt.material,vt=Qt.group;if(Xt.side===qe&&ee.layers.test(O.layers)){const je=Xt.side;Xt.side=Me,Xt.needsUpdate=!0,Ba(ee,F,O,ve,Xt,vt),Xt.side=je,Xt.needsUpdate=!0,Rt=!0}}Rt===!0&&(E.updateMultisampleRenderTarget(J),E.updateRenderTargetMipmap(J))}S.setRenderTarget(ft),S.setClearColor(W,$),bt!==void 0&&(O.viewport=bt),S.toneMapping=pt}function Yi(x,P,F){const O=P.isScene===!0?P.overrideMaterial:null;for(let D=0,J=x.length;D<J;D++){const ot=x[D],ft=ot.object,pt=ot.geometry,bt=O===null?ot.material:O,Rt=ot.group;ft.layers.test(F.layers)&&Ba(ft,P,F,pt,bt,Rt)}}function Ba(x,P,F,O,D,J){x.onBeforeRender(S,P,F,O,D,J),x.modelViewMatrix.multiplyMatrices(F.matrixWorldInverse,x.matrixWorld),x.normalMatrix.getNormalMatrix(x.modelViewMatrix),D.onBeforeRender(S,P,F,O,x,J),D.transparent===!0&&D.side===qe&&D.forceSinglePass===!1?(D.side=Me,D.needsUpdate=!0,S.renderBufferDirect(F,P,O,D,x,J),D.side=ln,D.needsUpdate=!0,S.renderBufferDirect(F,P,O,D,x,J),D.side=qe):S.renderBufferDirect(F,P,O,D,x,J),x.onAfterRender(S,P,F,O,D,J)}function Ki(x,P,F){P.isScene!==!0&&(P=ie);const O=Mt.get(x),D=f.state.lights,J=f.state.shadowsArray,ot=D.state.version,ft=_t.getParameters(x,D.state,J,P,F),pt=_t.getProgramCacheKey(ft);let bt=O.programs;O.environment=x.isMeshStandardMaterial?P.environment:null,O.fog=P.fog,O.envMap=(x.isMeshStandardMaterial?N:_).get(x.envMap||O.environment),O.envMapRotation=O.environment!==null&&x.envMap===null?P.environmentRotation:x.envMapRotation,bt===void 0&&(x.addEventListener("dispose",wt),bt=new Map,O.programs=bt);let Rt=bt.get(pt);if(Rt!==void 0){if(O.currentProgram===Rt&&O.lightsStateVersion===ot)return Va(x,ft),Rt}else ft.uniforms=_t.getUniforms(x),x.onBeforeCompile(ft,S),Rt=_t.acquireProgram(ft,pt),bt.set(pt,Rt),O.uniforms=ft.uniforms;const mt=O.uniforms;return(!x.isShaderMaterial&&!x.isRawShaderMaterial||x.clipping===!0)&&(mt.clippingPlanes=j.uniform),Va(x,ft),O.needsLights=Jl(x),O.lightsStateVersion=ot,O.needsLights&&(mt.ambientLightColor.value=D.state.ambient,mt.lightProbe.value=D.state.probe,mt.directionalLights.value=D.state.directional,mt.directionalLightShadows.value=D.state.directionalShadow,mt.spotLights.value=D.state.spot,mt.spotLightShadows.value=D.state.spotShadow,mt.rectAreaLights.value=D.state.rectArea,mt.ltc_1.value=D.state.rectAreaLTC1,mt.ltc_2.value=D.state.rectAreaLTC2,mt.pointLights.value=D.state.point,mt.pointLightShadows.value=D.state.pointShadow,mt.hemisphereLights.value=D.state.hemi,mt.directionalShadowMap.value=D.state.directionalShadowMap,mt.directionalShadowMatrix.value=D.state.directionalShadowMatrix,mt.spotShadowMap.value=D.state.spotShadowMap,mt.spotLightMatrix.value=D.state.spotLightMatrix,mt.spotLightMap.value=D.state.spotLightMap,mt.pointShadowMap.value=D.state.pointShadowMap,mt.pointShadowMatrix.value=D.state.pointShadowMatrix),O.currentProgram=Rt,O.uniformsList=null,Rt}function za(x){if(x.uniformsList===null){const P=x.currentProgram.getUniforms();x.uniformsList=Cr.seqWithValue(P.seq,x.uniforms)}return x.uniformsList}function Va(x,P){const F=Mt.get(x);F.outputColorSpace=P.outputColorSpace,F.batching=P.batching,F.batchingColor=P.batchingColor,F.instancing=P.instancing,F.instancingColor=P.instancingColor,F.instancingMorph=P.instancingMorph,F.skinning=P.skinning,F.morphTargets=P.morphTargets,F.morphNormals=P.morphNormals,F.morphColors=P.morphColors,F.morphTargetsCount=P.morphTargetsCount,F.numClippingPlanes=P.numClippingPlanes,F.numIntersection=P.numClipIntersection,F.vertexAlphas=P.vertexAlphas,F.vertexTangents=P.vertexTangents,F.toneMapping=P.toneMapping}function $l(x,P,F,O,D){P.isScene!==!0&&(P=ie),E.resetTextureUnits();const J=P.fog,ot=O.isMeshStandardMaterial?P.environment:null,ft=U===null?S.outputColorSpace:U.isXRRenderTarget===!0?U.texture.colorSpace:Vn,pt=(O.isMeshStandardMaterial?N:_).get(O.envMap||ot),bt=O.vertexColors===!0&&!!F.attributes.color&&F.attributes.color.itemSize===4,Rt=!!F.attributes.tangent&&(!!O.normalMap||O.anisotropy>0),mt=!!F.morphAttributes.position,Gt=!!F.morphAttributes.normal,Qt=!!F.morphAttributes.color;let ee=bn;O.toneMapped&&(U===null||U.isXRRenderTarget===!0)&&(ee=S.toneMapping);const ve=F.morphAttributes.position||F.morphAttributes.normal||F.morphAttributes.color,Xt=ve!==void 0?ve.length:0,vt=Mt.get(O),je=f.state.lights;if(tt===!0&&(gt===!0||x!==M)){const Pe=x===M&&O.id===y;j.setState(O,x,Pe)}let qt=!1;O.version===vt.__version?(vt.needsLights&&vt.lightsStateVersion!==je.state.version||vt.outputColorSpace!==ft||D.isBatchedMesh&&vt.batching===!1||!D.isBatchedMesh&&vt.batching===!0||D.isBatchedMesh&&vt.batchingColor===!0&&D.colorTexture===null||D.isBatchedMesh&&vt.batchingColor===!1&&D.colorTexture!==null||D.isInstancedMesh&&vt.instancing===!1||!D.isInstancedMesh&&vt.instancing===!0||D.isSkinnedMesh&&vt.skinning===!1||!D.isSkinnedMesh&&vt.skinning===!0||D.isInstancedMesh&&vt.instancingColor===!0&&D.instanceColor===null||D.isInstancedMesh&&vt.instancingColor===!1&&D.instanceColor!==null||D.isInstancedMesh&&vt.instancingMorph===!0&&D.morphTexture===null||D.isInstancedMesh&&vt.instancingMorph===!1&&D.morphTexture!==null||vt.envMap!==pt||O.fog===!0&&vt.fog!==J||vt.numClippingPlanes!==void 0&&(vt.numClippingPlanes!==j.numPlanes||vt.numIntersection!==j.numIntersection)||vt.vertexAlphas!==bt||vt.vertexTangents!==Rt||vt.morphTargets!==mt||vt.morphNormals!==Gt||vt.morphColors!==Qt||vt.toneMapping!==ee||vt.morphTargetsCount!==Xt)&&(qt=!0):(qt=!0,vt.__version=O.version);let Ne=vt.currentProgram;qt===!0&&(Ne=Ki(O,P,D));let Gn=!1,Ee=!1,Si=!1;const ne=Ne.getUniforms(),We=vt.uniforms;if(St.useProgram(Ne.program)&&(Gn=!0,Ee=!0,Si=!0),O.id!==y&&(y=O.id,Ee=!0),Gn||M!==x){St.buffers.depth.getReversed()?(rt.copy(x.projectionMatrix),uh(rt),dh(rt),ne.setValue(I,"projectionMatrix",rt)):ne.setValue(I,"projectionMatrix",x.projectionMatrix),ne.setValue(I,"viewMatrix",x.matrixWorldInverse);const un=ne.map.cameraPosition;un!==void 0&&un.setValue(I,At.setFromMatrixPosition(x.matrixWorld)),Bt.logarithmicDepthBuffer&&ne.setValue(I,"logDepthBufFC",2/(Math.log(x.far+1)/Math.LN2)),(O.isMeshPhongMaterial||O.isMeshToonMaterial||O.isMeshLambertMaterial||O.isMeshBasicMaterial||O.isMeshStandardMaterial||O.isShaderMaterial)&&ne.setValue(I,"isOrthographic",x.isOrthographicCamera===!0),M!==x&&(M=x,Ee=!0,Si=!0)}if(D.isSkinnedMesh){ne.setOptional(I,D,"bindMatrix"),ne.setOptional(I,D,"bindMatrixInverse");const Pe=D.skeleton;Pe&&(Pe.boneTexture===null&&Pe.computeBoneTexture(),ne.setValue(I,"boneTexture",Pe.boneTexture,E))}D.isBatchedMesh&&(ne.setOptional(I,D,"batchingTexture"),ne.setValue(I,"batchingTexture",D._matricesTexture,E),ne.setOptional(I,D,"batchingIdTexture"),ne.setValue(I,"batchingIdTexture",D._indirectTexture,E),ne.setOptional(I,D,"batchingColorTexture"),D._colorsTexture!==null&&ne.setValue(I,"batchingColorTexture",D._colorsTexture,E));const yi=F.morphAttributes;if((yi.position!==void 0||yi.normal!==void 0||yi.color!==void 0)&&Tt.update(D,F,Ne),(Ee||vt.receiveShadow!==D.receiveShadow)&&(vt.receiveShadow=D.receiveShadow,ne.setValue(I,"receiveShadow",D.receiveShadow)),O.isMeshGouraudMaterial&&O.envMap!==null&&(We.envMap.value=pt,We.flipEnvMap.value=pt.isCubeTexture&&pt.isRenderTargetTexture===!1?-1:1),O.isMeshStandardMaterial&&O.envMap===null&&P.environment!==null&&(We.envMapIntensity.value=P.environmentIntensity),Ee&&(ne.setValue(I,"toneMappingExposure",S.toneMappingExposure),vt.needsLights&&jl(We,Si),J&&O.fog===!0&&st.refreshFogUniforms(We,J),st.refreshMaterialUniforms(We,O,H,Q,f.state.transmissionRenderTarget[x.id]),Cr.upload(I,za(vt),We,E)),O.isShaderMaterial&&O.uniformsNeedUpdate===!0&&(Cr.upload(I,za(vt),We,E),O.uniformsNeedUpdate=!1),O.isSpriteMaterial&&ne.setValue(I,"center",D.center),ne.setValue(I,"modelViewMatrix",D.modelViewMatrix),ne.setValue(I,"normalMatrix",D.normalMatrix),ne.setValue(I,"modelMatrix",D.matrixWorld),O.isShaderMaterial||O.isRawShaderMaterial){const Pe=O.uniformsGroups;for(let un=0,dn=Pe.length;un<dn;un++){const Ha=Pe[un];C.update(Ha,Ne),C.bind(Ha,Ne)}}return Ne}function jl(x,P){x.ambientLightColor.needsUpdate=P,x.lightProbe.needsUpdate=P,x.directionalLights.needsUpdate=P,x.directionalLightShadows.needsUpdate=P,x.pointLights.needsUpdate=P,x.pointLightShadows.needsUpdate=P,x.spotLights.needsUpdate=P,x.spotLightShadows.needsUpdate=P,x.rectAreaLights.needsUpdate=P,x.hemisphereLights.needsUpdate=P}function Jl(x){return x.isMeshLambertMaterial||x.isMeshToonMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isShadowMaterial||x.isShaderMaterial&&x.lights===!0}this.getActiveCubeFace=function(){return A},this.getActiveMipmapLevel=function(){return w},this.getRenderTarget=function(){return U},this.setRenderTargetTextures=function(x,P,F){Mt.get(x.texture).__webglTexture=P,Mt.get(x.depthTexture).__webglTexture=F;const O=Mt.get(x);O.__hasExternalTextures=!0,O.__autoAllocateDepthBuffer=F===void 0,O.__autoAllocateDepthBuffer||Ot.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),O.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(x,P){const F=Mt.get(x);F.__webglFramebuffer=P,F.__useDefaultFramebuffer=P===void 0},this.setRenderTarget=function(x,P=0,F=0){U=x,A=P,w=F;let O=!0,D=null,J=!1,ot=!1;if(x){const pt=Mt.get(x);if(pt.__useDefaultFramebuffer!==void 0)St.bindFramebuffer(I.FRAMEBUFFER,null),O=!1;else if(pt.__webglFramebuffer===void 0)E.setupRenderTarget(x);else if(pt.__hasExternalTextures)E.rebindTextures(x,Mt.get(x.texture).__webglTexture,Mt.get(x.depthTexture).__webglTexture);else if(x.depthBuffer){const mt=x.depthTexture;if(pt.__boundDepthTexture!==mt){if(mt!==null&&Mt.has(mt)&&(x.width!==mt.image.width||x.height!==mt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");E.setupDepthRenderbuffer(x)}}const bt=x.texture;(bt.isData3DTexture||bt.isDataArrayTexture||bt.isCompressedArrayTexture)&&(ot=!0);const Rt=Mt.get(x).__webglFramebuffer;x.isWebGLCubeRenderTarget?(Array.isArray(Rt[P])?D=Rt[P][F]:D=Rt[P],J=!0):x.samples>0&&E.useMultisampledRTT(x)===!1?D=Mt.get(x).__webglMultisampledFramebuffer:Array.isArray(Rt)?D=Rt[F]:D=Rt,R.copy(x.viewport),q.copy(x.scissor),z=x.scissorTest}else R.copy(xt).multiplyScalar(H).floor(),q.copy(Ut).multiplyScalar(H).floor(),z=jt;if(St.bindFramebuffer(I.FRAMEBUFFER,D)&&O&&St.drawBuffers(x,D),St.viewport(R),St.scissor(q),St.setScissorTest(z),J){const pt=Mt.get(x.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_CUBE_MAP_POSITIVE_X+P,pt.__webglTexture,F)}else if(ot){const pt=Mt.get(x.texture),bt=P||0;I.framebufferTextureLayer(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,pt.__webglTexture,F||0,bt)}y=-1},this.readRenderTargetPixels=function(x,P,F,O,D,J,ot){if(!(x&&x.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ft=Mt.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget&&ot!==void 0&&(ft=ft[ot]),ft){St.bindFramebuffer(I.FRAMEBUFFER,ft);try{const pt=x.texture,bt=pt.format,Rt=pt.type;if(!Bt.textureFormatReadable(bt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Bt.textureTypeReadable(Rt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}P>=0&&P<=x.width-O&&F>=0&&F<=x.height-D&&I.readPixels(P,F,O,D,Pt.convert(bt),Pt.convert(Rt),J)}finally{const pt=U!==null?Mt.get(U).__webglFramebuffer:null;St.bindFramebuffer(I.FRAMEBUFFER,pt)}}},this.readRenderTargetPixelsAsync=function(x,P,F,O,D,J,ot){return Hr(this,null,function*(){if(!(x&&x.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ft=Mt.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget&&ot!==void 0&&(ft=ft[ot]),ft){const pt=x.texture,bt=pt.format,Rt=pt.type;if(!Bt.textureFormatReadable(bt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Bt.textureTypeReadable(Rt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(P>=0&&P<=x.width-O&&F>=0&&F<=x.height-D){St.bindFramebuffer(I.FRAMEBUFFER,ft);const mt=I.createBuffer();I.bindBuffer(I.PIXEL_PACK_BUFFER,mt),I.bufferData(I.PIXEL_PACK_BUFFER,J.byteLength,I.STREAM_READ),I.readPixels(P,F,O,D,Pt.convert(bt),Pt.convert(Rt),0);const Gt=U!==null?Mt.get(U).__webglFramebuffer:null;St.bindFramebuffer(I.FRAMEBUFFER,Gt);const Qt=I.fenceSync(I.SYNC_GPU_COMMANDS_COMPLETE,0);return I.flush(),yield hh(I,Qt,4),I.bindBuffer(I.PIXEL_PACK_BUFFER,mt),I.getBufferSubData(I.PIXEL_PACK_BUFFER,0,J),I.deleteBuffer(mt),I.deleteSync(Qt),J}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}})},this.copyFramebufferToTexture=function(x,P=null,F=0){x.isTexture!==!0&&(Di("WebGLRenderer: copyFramebufferToTexture function signature has changed."),P=arguments[0]||null,x=arguments[1]);const O=Math.pow(2,-F),D=Math.floor(x.image.width*O),J=Math.floor(x.image.height*O),ot=P!==null?P.x:0,ft=P!==null?P.y:0;E.setTexture2D(x,0),I.copyTexSubImage2D(I.TEXTURE_2D,F,0,0,ot,ft,D,J),St.unbindTexture()},this.copyTextureToTexture=function(x,P,F=null,O=null,D=0){x.isTexture!==!0&&(Di("WebGLRenderer: copyTextureToTexture function signature has changed."),O=arguments[0]||null,x=arguments[1],P=arguments[2],D=arguments[3]||0,F=null);let J,ot,ft,pt,bt,Rt,mt,Gt,Qt;const ee=x.isCompressedTexture?x.mipmaps[D]:x.image;F!==null?(J=F.max.x-F.min.x,ot=F.max.y-F.min.y,ft=F.isBox3?F.max.z-F.min.z:1,pt=F.min.x,bt=F.min.y,Rt=F.isBox3?F.min.z:0):(J=ee.width,ot=ee.height,ft=ee.depth||1,pt=0,bt=0,Rt=0),O!==null?(mt=O.x,Gt=O.y,Qt=O.z):(mt=0,Gt=0,Qt=0);const ve=Pt.convert(P.format),Xt=Pt.convert(P.type);let vt;P.isData3DTexture?(E.setTexture3D(P,0),vt=I.TEXTURE_3D):P.isDataArrayTexture||P.isCompressedArrayTexture?(E.setTexture2DArray(P,0),vt=I.TEXTURE_2D_ARRAY):(E.setTexture2D(P,0),vt=I.TEXTURE_2D),I.pixelStorei(I.UNPACK_FLIP_Y_WEBGL,P.flipY),I.pixelStorei(I.UNPACK_PREMULTIPLY_ALPHA_WEBGL,P.premultiplyAlpha),I.pixelStorei(I.UNPACK_ALIGNMENT,P.unpackAlignment);const je=I.getParameter(I.UNPACK_ROW_LENGTH),qt=I.getParameter(I.UNPACK_IMAGE_HEIGHT),Ne=I.getParameter(I.UNPACK_SKIP_PIXELS),Gn=I.getParameter(I.UNPACK_SKIP_ROWS),Ee=I.getParameter(I.UNPACK_SKIP_IMAGES);I.pixelStorei(I.UNPACK_ROW_LENGTH,ee.width),I.pixelStorei(I.UNPACK_IMAGE_HEIGHT,ee.height),I.pixelStorei(I.UNPACK_SKIP_PIXELS,pt),I.pixelStorei(I.UNPACK_SKIP_ROWS,bt),I.pixelStorei(I.UNPACK_SKIP_IMAGES,Rt);const Si=x.isDataArrayTexture||x.isData3DTexture,ne=P.isDataArrayTexture||P.isData3DTexture;if(x.isRenderTargetTexture||x.isDepthTexture){const We=Mt.get(x),yi=Mt.get(P),Pe=Mt.get(We.__renderTarget),un=Mt.get(yi.__renderTarget);St.bindFramebuffer(I.READ_FRAMEBUFFER,Pe.__webglFramebuffer),St.bindFramebuffer(I.DRAW_FRAMEBUFFER,un.__webglFramebuffer);for(let dn=0;dn<ft;dn++)Si&&I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,Mt.get(x).__webglTexture,D,Rt+dn),x.isDepthTexture?(ne&&I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,Mt.get(P).__webglTexture,D,Qt+dn),I.blitFramebuffer(pt,bt,J,ot,mt,Gt,J,ot,I.DEPTH_BUFFER_BIT,I.NEAREST)):ne?I.copyTexSubImage3D(vt,D,mt,Gt,Qt+dn,pt,bt,J,ot):I.copyTexSubImage2D(vt,D,mt,Gt,Qt+dn,pt,bt,J,ot);St.bindFramebuffer(I.READ_FRAMEBUFFER,null),St.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else ne?x.isDataTexture||x.isData3DTexture?I.texSubImage3D(vt,D,mt,Gt,Qt,J,ot,ft,ve,Xt,ee.data):P.isCompressedArrayTexture?I.compressedTexSubImage3D(vt,D,mt,Gt,Qt,J,ot,ft,ve,ee.data):I.texSubImage3D(vt,D,mt,Gt,Qt,J,ot,ft,ve,Xt,ee):x.isDataTexture?I.texSubImage2D(I.TEXTURE_2D,D,mt,Gt,J,ot,ve,Xt,ee.data):x.isCompressedTexture?I.compressedTexSubImage2D(I.TEXTURE_2D,D,mt,Gt,ee.width,ee.height,ve,ee.data):I.texSubImage2D(I.TEXTURE_2D,D,mt,Gt,J,ot,ve,Xt,ee);I.pixelStorei(I.UNPACK_ROW_LENGTH,je),I.pixelStorei(I.UNPACK_IMAGE_HEIGHT,qt),I.pixelStorei(I.UNPACK_SKIP_PIXELS,Ne),I.pixelStorei(I.UNPACK_SKIP_ROWS,Gn),I.pixelStorei(I.UNPACK_SKIP_IMAGES,Ee),D===0&&P.generateMipmaps&&I.generateMipmap(vt),St.unbindTexture()},this.copyTextureToTexture3D=function(x,P,F=null,O=null,D=0){return x.isTexture!==!0&&(Di("WebGLRenderer: copyTextureToTexture3D function signature has changed."),F=arguments[0]||null,O=arguments[1]||null,x=arguments[2],P=arguments[3],D=arguments[4]||0),Di('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(x,P,F,O,D)},this.initRenderTarget=function(x){Mt.get(x).__webglFramebuffer===void 0&&E.setupRenderTarget(x)},this.initTexture=function(x){x.isCubeTexture?E.setTextureCube(x,0):x.isData3DTexture?E.setTexture3D(x,0):x.isDataArrayTexture||x.isCompressedArrayTexture?E.setTexture2DArray(x,0):E.setTexture2D(x,0),St.unbindTexture()},this.resetState=function(){A=0,w=0,U=null,St.reset(),Jt.reset()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return an}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorspace=Vt._getDrawingBufferColorSpace(t),e.unpackColorSpace=Vt._getUnpackColorSpace()}}class Em extends se{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 Ye,this.environmentIntensity=1,this.environmentRotation=new Ye,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}class Tm{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=oa,this.updateRanges=[],this.version=0,this.uuid=Ge()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let r=0,s=this.stride;r<s;r++)this.array[t+r]=e.array[n+r];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ge()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ge()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const ge=new L;class ba{constructor(t,e,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)ge.fromBufferAttribute(this,e),ge.applyMatrix4(t),this.setXYZ(e,ge.x,ge.y,ge.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)ge.fromBufferAttribute(this,e),ge.applyNormalMatrix(t),this.setXYZ(e,ge.x,ge.y,ge.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)ge.fromBufferAttribute(this,e),ge.transformDirection(t),this.setXYZ(e,ge.x,ge.y,ge.z);return this}getComponent(t,e){let n=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(n=ze(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=Kt(n,this.array)),this.data.array[t*this.data.stride+this.offset+e]=n,this}setX(t,e){return this.normalized&&(e=Kt(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=Kt(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=Kt(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=Kt(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=ze(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=ze(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=ze(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=ze(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=Kt(e,this.array),n=Kt(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=Kt(e,this.array),n=Kt(n,this.array),r=Kt(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=r,this}setXYZW(t,e,n,r,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=Kt(e,this.array),n=Kt(n,this.array),r=Kt(r,this.array),s=Kt(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=r,this.data.array[t+3]=s,this}clone(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let n=0;n<this.count;n++){const r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[r+s])}return new Re(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new ba(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let n=0;n<this.count;n++){const r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}const qo=new L,Yo=new Wt,Ko=new Wt,bm=new L,Zo=new Dt,mr=new L,gs=new Ke,$o=new Dt,_s=new gi;class Am extends we{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Ya,this.bindMatrix=new Dt,this.bindMatrixInverse=new Dt,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const t=this.geometry;this.boundingBox===null&&(this.boundingBox=new hn),this.boundingBox.makeEmpty();const e=t.getAttribute("position");for(let n=0;n<e.count;n++)this.getVertexPosition(n,mr),this.boundingBox.expandByPoint(mr)}computeBoundingSphere(){const t=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Ke),this.boundingSphere.makeEmpty();const e=t.getAttribute("position");for(let n=0;n<e.count;n++)this.getVertexPosition(n,mr),this.boundingSphere.expandByPoint(mr)}copy(t,e){return super.copy(t,e),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}raycast(t,e){const n=this.material,r=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),gs.copy(this.boundingSphere),gs.applyMatrix4(r),t.ray.intersectsSphere(gs)!==!1&&($o.copy(r).invert(),_s.copy(t.ray).applyMatrix4($o),!(this.boundingBox!==null&&_s.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(t,e,_s)))}getVertexPosition(t,e){return super.getVertexPosition(t,e),this.applyBoneTransform(t,e),e}bind(t,e){this.skeleton=t,e===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const t=new Wt,e=this.geometry.attributes.skinWeight;for(let n=0,r=e.count;n<r;n++){t.fromBufferAttribute(e,n);const s=1/t.manhattanLength();s!==1/0?t.multiplyScalar(s):t.set(1,0,0,0),e.setXYZW(n,t.x,t.y,t.z,t.w)}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode===Ya?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===Lc?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(t,e){const n=this.skeleton,r=this.geometry;Yo.fromBufferAttribute(r.attributes.skinIndex,t),Ko.fromBufferAttribute(r.attributes.skinWeight,t),qo.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let s=0;s<4;s++){const a=Ko.getComponent(s);if(a!==0){const o=Yo.getComponent(s);Zo.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),e.addScaledVector(bm.copy(qo).applyMatrix4(Zo),a)}}return e.applyMatrix4(this.bindMatrixInverse)}}class kl extends se{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Gl extends de{constructor(t=null,e=1,n=1,r,s,a,o,l,c=Se,h=Se,u,d){super(null,a,o,l,c,h,r,s,u,d),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const jo=new Dt,wm=new Dt;class Aa{constructor(t=[],e=[]){this.uuid=Ge(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(t.length*16),e.length===0)this.calculateInverses();else if(t.length!==e.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,r=this.bones.length;n<r;n++)this.boneInverses.push(new Dt)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const n=new Dt;this.bones[t]&&n.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){const n=this.bones[t];n&&n.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){const n=this.bones[t];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const t=this.bones,e=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let s=0,a=t.length;s<a;s++){const o=t[s]?t[s].matrixWorld:wm;jo.multiplyMatrices(o,e[s]),jo.toArray(n,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new Aa(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(this.bones.length*4);t=Math.ceil(t/4)*4,t=Math.max(t,4);const e=new Float32Array(t*t*4);e.set(this.boneMatrices);const n=new Gl(e,t,t,De,ke);return n.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=n,this}getBoneByName(t){for(let e=0,n=this.bones.length;e<n;e++){const r=this.bones[e];if(r.name===t)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let n=0,r=t.bones.length;n<r;n++){const s=t.bones[n];let a=e[s];a===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),a=new kl),this.bones.push(a),this.boneInverses.push(new Dt().fromArray(t.boneInverses[n]))}return this.init(),this}toJSON(){const t={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;const e=this.bones,n=this.boneInverses;for(let r=0,s=e.length;r<s;r++){const a=e[r];t.bones.push(a.uuid);const o=n[r];t.boneInverses.push(o.toArray())}return t}}class ca extends Re{constructor(t,e,n,r=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){const t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}const ri=new Dt,Jo=new Dt,gr=[],Qo=new hn,Rm=new Dt,wi=new we,Ri=new Ke;class Cm extends we{constructor(t,e,n){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new ca(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<n;r++)this.setMatrixAt(r,Rm)}computeBoundingBox(){const t=this.geometry,e=this.count;this.boundingBox===null&&(this.boundingBox=new hn),t.boundingBox===null&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,ri),Qo.copy(t.boundingBox).applyMatrix4(ri),this.boundingBox.union(Qo)}computeBoundingSphere(){const t=this.geometry,e=this.count;this.boundingSphere===null&&(this.boundingSphere=new Ke),t.boundingSphere===null&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,ri),Ri.copy(t.boundingSphere).applyMatrix4(ri),this.boundingSphere.union(Ri)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),t.morphTexture!==null&&(this.morphTexture=t.morphTexture.clone()),t.instanceColor!==null&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}getColorAt(t,e){e.fromArray(this.instanceColor.array,t*3)}getMatrixAt(t,e){e.fromArray(this.instanceMatrix.array,t*16)}getMorphAt(t,e){const n=e.morphTargetInfluences,r=this.morphTexture.source.data.data,s=n.length+1,a=t*s+1;for(let o=0;o<n.length;o++)n[o]=r[a+o]}raycast(t,e){const n=this.matrixWorld,r=this.count;if(wi.geometry=this.geometry,wi.material=this.material,wi.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Ri.copy(this.boundingSphere),Ri.applyMatrix4(n),t.ray.intersectsSphere(Ri)!==!1))for(let s=0;s<r;s++){this.getMatrixAt(s,ri),Jo.multiplyMatrices(n,ri),wi.matrixWorld=Jo,wi.raycast(t,gr);for(let a=0,o=gr.length;a<o;a++){const l=gr[a];l.instanceId=s,l.object=this,e.push(l)}gr.length=0}}setColorAt(t,e){this.instanceColor===null&&(this.instanceColor=new ca(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),e.toArray(this.instanceColor.array,t*3)}setMatrixAt(t,e){e.toArray(this.instanceMatrix.array,t*16)}setMorphAt(t,e){const n=e.morphTargetInfluences,r=n.length+1;this.morphTexture===null&&(this.morphTexture=new Gl(new Float32Array(r*this.count),r,this.count,ma,ke));const s=this.morphTexture.source.data.data;let a=0;for(let c=0;c<n.length;c++)a+=n[c];const o=this.geometry.morphTargetsRelative?1:1-a,l=r*t;s[l]=o,s.set(n,l+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}}class wa extends wn{static get type(){return"LineBasicMaterial"}constructor(t){super(),this.isLineBasicMaterial=!0,this.color=new It(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}}const Ur=new L,Nr=new L,tl=new Dt,Ci=new gi,_r=new Ke,vs=new L,el=new L;class Ra extends se{constructor(t=new Ie,e=new wa){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,n=[0];for(let r=1,s=e.count;r<s;r++)Ur.fromBufferAttribute(e,r-1),Nr.fromBufferAttribute(e,r),n[r]=n[r-1],n[r]+=Ur.distanceTo(Nr);t.setAttribute("lineDistance",new ye(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){const n=this.geometry,r=this.matrixWorld,s=t.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),_r.copy(n.boundingSphere),_r.applyMatrix4(r),_r.radius+=s,t.ray.intersectsSphere(_r)===!1)return;tl.copy(r).invert(),Ci.copy(t.ray).applyMatrix4(tl);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,h=n.index,d=n.attributes.position;if(h!==null){const p=Math.max(0,a.start),g=Math.min(h.count,a.start+a.count);for(let v=p,m=g-1;v<m;v+=c){const f=h.getX(v),b=h.getX(v+1),T=vr(this,t,Ci,l,f,b);T&&e.push(T)}if(this.isLineLoop){const v=h.getX(g-1),m=h.getX(p),f=vr(this,t,Ci,l,v,m);f&&e.push(f)}}else{const p=Math.max(0,a.start),g=Math.min(d.count,a.start+a.count);for(let v=p,m=g-1;v<m;v+=c){const f=vr(this,t,Ci,l,v,v+1);f&&e.push(f)}if(this.isLineLoop){const v=vr(this,t,Ci,l,g-1,p);v&&e.push(v)}}}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const r=e[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 vr(i,t,e,n,r,s){const a=i.geometry.attributes.position;if(Ur.fromBufferAttribute(a,r),Nr.fromBufferAttribute(a,s),e.distanceSqToSegment(Ur,Nr,vs,el)>n)return;vs.applyMatrix4(i.matrixWorld);const l=t.ray.origin.distanceTo(vs);if(!(l<t.near||l>t.far))return{distance:l,point:el.clone().applyMatrix4(i.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:i}}const nl=new L,il=new L;class Wl extends Ra{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,n=[];for(let r=0,s=e.count;r<s;r+=2)nl.fromBufferAttribute(e,r),il.fromBufferAttribute(e,r+1),n[r]=r===0?0:n[r-1],n[r+1]=n[r]+nl.distanceTo(il);t.setAttribute("lineDistance",new ye(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Pm extends Ra{constructor(t,e){super(t,e),this.isLineLoop=!0,this.type="LineLoop"}}class Xl extends wn{static get type(){return"PointsMaterial"}constructor(t){super(),this.isPointsMaterial=!0,this.color=new It(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}const rl=new Dt,ha=new gi,xr=new Ke,Mr=new L;class Lm extends se{constructor(t=new Ie,e=new Xl){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){const n=this.geometry,r=this.matrixWorld,s=t.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),xr.copy(n.boundingSphere),xr.applyMatrix4(r),xr.radius+=s,t.ray.intersectsSphere(xr)===!1)return;rl.copy(r).invert(),ha.copy(t.ray).applyMatrix4(rl);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=n.index,u=n.attributes.position;if(c!==null){const d=Math.max(0,a.start),p=Math.min(c.count,a.start+a.count);for(let g=d,v=p;g<v;g++){const m=c.getX(g);Mr.fromBufferAttribute(u,m),sl(Mr,m,l,r,t,e,this)}}else{const d=Math.max(0,a.start),p=Math.min(u.count,a.start+a.count);for(let g=d,v=p;g<v;g++)Mr.fromBufferAttribute(u,g),sl(Mr,g,l,r,t,e,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const r=e[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 sl(i,t,e,n,r,s,a){const o=ha.distanceSqToPoint(i);if(o<e){const l=new L;ha.closestPointToPoint(i,l),l.applyMatrix4(n);const c=r.ray.origin.distanceTo(l);if(c<r.near||c>r.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:t,face:null,faceIndex:null,barycoord:null,object:a})}}class ql{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){const n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let n,r=this.getPoint(0),s=0;e.push(0);for(let a=1;a<=t;a++)n=this.getPoint(a/t),s+=n.distanceTo(r),e.push(s),r=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){const n=this.getLengths();let r=0;const s=n.length;let a;e?a=e:a=t*n[s-1];let o=0,l=s-1,c;for(;o<=l;)if(r=Math.floor(o+(l-o)/2),c=n[r]-a,c<0)o=r+1;else if(c>0)l=r-1;else{l=r;break}if(r=l,n[r]===a)return r/(s-1);const h=n[r],d=n[r+1]-h,p=(a-h)/d;return(r+p)/(s-1)}getTangent(t,e){let r=t-1e-4,s=t+1e-4;r<0&&(r=0),s>1&&(s=1);const a=this.getPoint(r),o=this.getPoint(s),l=e||(a.isVector2?new Ft:new L);return l.copy(o).sub(a).normalize(),l}getTangentAt(t,e){const n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){const n=new L,r=[],s=[],a=[],o=new L,l=new Dt;for(let p=0;p<=t;p++){const g=p/t;r[p]=this.getTangentAt(g,new L)}s[0]=new L,a[0]=new L;let c=Number.MAX_VALUE;const h=Math.abs(r[0].x),u=Math.abs(r[0].y),d=Math.abs(r[0].z);h<=c&&(c=h,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),o.crossVectors(r[0],n).normalize(),s[0].crossVectors(r[0],o),a[0].crossVectors(r[0],s[0]);for(let p=1;p<=t;p++){if(s[p]=s[p-1].clone(),a[p]=a[p-1].clone(),o.crossVectors(r[p-1],r[p]),o.length()>Number.EPSILON){o.normalize();const g=Math.acos(le(r[p-1].dot(r[p]),-1,1));s[p].applyMatrix4(l.makeRotationAxis(o,g))}a[p].crossVectors(r[p],s[p])}if(e===!0){let p=Math.acos(le(s[0].dot(s[t]),-1,1));p/=t,r[0].dot(o.crossVectors(s[0],s[t]))>0&&(p=-p);for(let g=1;g<=t;g++)s[g].applyMatrix4(l.makeRotationAxis(r[g],p*g)),a[g].crossVectors(r[g],s[g])}return{tangents:r,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class Dm extends ql{constructor(t=0,e=0,n=1,r=1,s=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(t,e=new Ft){const n=e,r=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const a=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(a?s=0:s=r),this.aClockwise===!0&&!a&&(s===r?s=-r:s=s-r);const o=this.aStartAngle+t*s;let l=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){const h=Math.cos(this.aRotation),u=Math.sin(this.aRotation),d=l-this.aX,p=c-this.aY;l=d*h-p*u+this.aX,c=d*u+p*h+this.aY}return n.set(l,c)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){const t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}}function Ca(){let i=0,t=0,e=0,n=0;function r(s,a,o,l){i=s,t=o,e=-3*s+3*a-2*o-l,n=2*s-2*a+o+l}return{initCatmullRom:function(s,a,o,l,c){r(a,o,c*(o-s),c*(l-a))},initNonuniformCatmullRom:function(s,a,o,l,c,h,u){let d=(a-s)/c-(o-s)/(c+h)+(o-a)/h,p=(o-a)/h-(l-a)/(h+u)+(l-o)/u;d*=h,p*=h,r(a,o,d,p)},calc:function(s){const a=s*s,o=a*s;return i+t*s+e*a+n*o}}}const Sr=new L,xs=new Ca,Ms=new Ca,Ss=new Ca;class Im extends ql{constructor(t=[],e=!1,n="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=r}getPoint(t,e=new L){const n=e,r=this.points,s=r.length,a=(s-(this.closed?0:1))*t;let o=Math.floor(a),l=a-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/s)+1)*s:l===0&&o===s-1&&(o=s-2,l=1);let c,h;this.closed||o>0?c=r[(o-1)%s]:(Sr.subVectors(r[0],r[1]).add(r[0]),c=Sr);const u=r[o%s],d=r[(o+1)%s];if(this.closed||o+2<s?h=r[(o+2)%s]:(Sr.subVectors(r[s-1],r[s-2]).add(r[s-1]),h=Sr),this.curveType==="centripetal"||this.curveType==="chordal"){const p=this.curveType==="chordal"?.5:.25;let g=Math.pow(c.distanceToSquared(u),p),v=Math.pow(u.distanceToSquared(d),p),m=Math.pow(d.distanceToSquared(h),p);v<1e-4&&(v=1),g<1e-4&&(g=v),m<1e-4&&(m=v),xs.initNonuniformCatmullRom(c.x,u.x,d.x,h.x,g,v,m),Ms.initNonuniformCatmullRom(c.y,u.y,d.y,h.y,g,v,m),Ss.initNonuniformCatmullRom(c.z,u.z,d.z,h.z,g,v,m)}else this.curveType==="catmullrom"&&(xs.initCatmullRom(c.x,u.x,d.x,h.x,this.tension),Ms.initCatmullRom(c.y,u.y,d.y,h.y,this.tension),Ss.initCatmullRom(c.z,u.z,d.z,h.z,this.tension));return n.set(xs.calc(l),Ms.calc(l),Ss.calc(l)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const r=t.points[e];this.points.push(r.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const r=this.points[e];t.points.push(r.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const r=t.points[e];this.points.push(new L().fromArray(r))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}}class Pa extends Ie{constructor(t=1,e=32,n=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:r},e=Math.max(3,e);const s=[],a=[],o=[],l=[],c=new L,h=new Ft;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let u=0,d=3;u<=e;u++,d+=3){const p=n+u/e*r;c.x=t*Math.cos(p),c.y=t*Math.sin(p),a.push(c.x,c.y,c.z),o.push(0,0,1),h.x=(a[d]/t+1)/2,h.y=(a[d+1]/t+1)/2,l.push(h.x,h.y)}for(let u=1;u<=e;u++)s.push(u,u+1,0);this.setIndex(s),this.setAttribute("position",new ye(a,3)),this.setAttribute("normal",new ye(o,3)),this.setAttribute("uv",new ye(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Pa(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class Yl extends wn{static get type(){return"MeshStandardMaterial"}constructor(t){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.color=new It(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new It(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=bl,this.normalScale=new Ft(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ye,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Um extends Yl{static get type(){return"MeshPhysicalMaterial"}constructor(t){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ft(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return le(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new It(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new It(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new It(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(t)}get anisotropy(){return this._anisotropy}set anisotropy(t){this._anisotropy>0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}function yr(i,t,e){return!i||!e&&i.constructor===t?i:typeof t.BYTES_PER_ELEMENT=="number"?new t(i):Array.prototype.slice.call(i)}function Nm(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function Fm(i){function t(r,s){return i[r]-i[s]}const e=i.length,n=new Array(e);for(let r=0;r!==e;++r)n[r]=r;return n.sort(t),n}function al(i,t,e){const n=i.length,r=new i.constructor(n);for(let s=0,a=0;a!==n;++s){const o=e[s]*t;for(let l=0;l!==t;++l)r[a++]=i[o+l]}return r}function Kl(i,t,e,n){let r=1,s=i[0];for(;s!==void 0&&s[n]===void 0;)s=i[r++];if(s===void 0)return;let a=s[n];if(a!==void 0)if(Array.isArray(a))do a=s[n],a!==void 0&&(t.push(s.time),e.push.apply(e,a)),s=i[r++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[n],a!==void 0&&(t.push(s.time),a.toArray(e,e.length)),s=i[r++];while(s!==void 0);else do a=s[n],a!==void 0&&(t.push(s.time),e.push(a)),s=i[r++];while(s!==void 0)}class Xi{constructor(t,e,n,r){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){const e=this.parameterPositions;let n=this._cachedIndex,r=e[n],s=e[n-1];n:{t:{let a;e:{i:if(!(t<r)){for(let o=n+2;;){if(r===void 0){if(t<s)break i;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(s=r,r=e[++n],t<r)break t}a=e.length;break e}if(!(t>=s)){const o=e[1];t<o&&(n=2,s=o);for(let l=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(r=s,s=e[--n-1],t>=s)break t}a=n,n=0;break e}break n}for(;n<a;){const o=n+a>>>1;t<e[o]?a=o:n=o+1}if(r=e[n],s=e[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,r)}return this.interpolate_(n,s,t,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){const e=this.resultBuffer,n=this.sampleValues,r=this.valueSize,s=t*r;for(let a=0;a!==r;++a)e[a]=n[s+a];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class Om extends Xi{constructor(t,e,n,r){super(t,e,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Ka,endingEnd:Ka}}intervalChanged_(t,e,n){const r=this.parameterPositions;let s=t-2,a=t+1,o=r[s],l=r[a];if(o===void 0)switch(this.getSettings_().endingStart){case Za:s=t,o=2*e-n;break;case $a:s=r.length-2,o=e+r[s]-r[s+1];break;default:s=t,o=n}if(l===void 0)switch(this.getSettings_().endingEnd){case Za:a=t,l=2*n-e;break;case $a:a=1,l=n+r[1]-r[0];break;default:a=t-1,l=e}const c=(n-e)*.5,h=this.valueSize;this._weightPrev=c/(e-o),this._weightNext=c/(l-n),this._offsetPrev=s*h,this._offsetNext=a*h}interpolate_(t,e,n,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=t*o,c=l-o,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,p=this._weightNext,g=(n-e)/(r-e),v=g*g,m=v*g,f=-d*m+2*d*v-d*g,b=(1+d)*m+(-1.5-2*d)*v+(-.5+d)*g+1,T=(-1-p)*m+(1.5+p)*v+.5*g,S=p*m-p*v;for(let B=0;B!==o;++B)s[B]=f*a[h+B]+b*a[c+B]+T*a[l+B]+S*a[u+B];return s}}class Bm extends Xi{constructor(t,e,n,r){super(t,e,n,r)}interpolate_(t,e,n,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=t*o,c=l-o,h=(n-e)/(r-e),u=1-h;for(let d=0;d!==o;++d)s[d]=a[c+d]*u+a[l+d]*h;return s}}class zm extends Xi{constructor(t,e,n,r){super(t,e,n,r)}interpolate_(t){return this.copySampleValue_(t-1)}}class Ze{constructor(t,e,n,r){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=yr(e,this.TimeBufferType),this.values=yr(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(t){const e=t.constructor;let n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:yr(t.times,Array),values:yr(t.values,Array)};const r=t.getInterpolation();r!==t.DefaultInterpolation&&(n.interpolation=r)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new zm(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Bm(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new Om(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case Bi:e=this.InterpolantFactoryMethodDiscrete;break;case Dr:e=this.InterpolantFactoryMethodLinear;break;case kr:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Bi;case this.InterpolantFactoryMethodLinear:return Dr;case this.InterpolantFactoryMethodSmooth:return kr}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){const e=this.times;for(let n=0,r=e.length;n!==r;++n)e[n]+=t}return this}scale(t){if(t!==1){const e=this.times;for(let n=0,r=e.length;n!==r;++n)e[n]*=t}return this}trim(t,e){const n=this.times,r=n.length;let s=0,a=r-1;for(;s!==r&&n[s]<t;)++s;for(;a!==-1&&n[a]>e;)--a;if(++a,s!==0||a!==r){s>=a&&(a=Math.max(a,1),s=a-1);const o=this.getValueSize();this.times=n.slice(s,a),this.values=this.values.slice(s*o,a*o)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const n=this.times,r=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let a=null;for(let o=0;o!==s;o++){const l=n[o];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,l),t=!1;break}if(a!==null&&a>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,l,a),t=!1;break}a=l}if(r!==void 0&&Nm(r))for(let o=0,l=r.length;o!==l;++o){const c=r[o];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,c),t=!1;break}}return t}optimize(){const t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===kr,s=t.length-1;let a=1;for(let o=1;o<s;++o){let l=!1;const c=t[o],h=t[o+1];if(c!==h&&(o!==1||c!==t[0]))if(r)l=!0;else{const u=o*n,d=u-n,p=u+n;for(let g=0;g!==n;++g){const v=e[u+g];if(v!==e[d+g]||v!==e[p+g]){l=!0;break}}}if(l){if(o!==a){t[a]=t[o];const u=o*n,d=a*n;for(let p=0;p!==n;++p)e[d+p]=e[u+p]}++a}}if(s>0){t[a]=t[s];for(let o=s*n,l=a*n,c=0;c!==n;++c)e[l+c]=e[o+c];++a}return a!==t.length?(this.times=t.slice(0,a),this.values=e.slice(0,a*n)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),n=this.constructor,r=new n(this.name,t,e);return r.createInterpolant=this.createInterpolant,r}}Ze.prototype.TimeBufferType=Float32Array;Ze.prototype.ValueBufferType=Float32Array;Ze.prototype.DefaultInterpolation=Dr;class vi extends Ze{constructor(t,e,n){super(t,e,n)}}vi.prototype.ValueTypeName="bool";vi.prototype.ValueBufferType=Array;vi.prototype.DefaultInterpolation=Bi;vi.prototype.InterpolantFactoryMethodLinear=void 0;vi.prototype.InterpolantFactoryMethodSmooth=void 0;class Zl extends Ze{}Zl.prototype.ValueTypeName="color";class Vi extends Ze{}Vi.prototype.ValueTypeName="number";class Vm extends Xi{constructor(t,e,n,r){super(t,e,n,r)}interpolate_(t,e,n,r){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(n-e)/(r-e);let c=t*o;for(let h=c+o;c!==h;c+=4)kn.slerpFlat(s,0,a,c-o,a,c,l);return s}}class qi extends Ze{InterpolantFactoryMethodLinear(t){return new Vm(this.times,this.values,this.getValueSize(),t)}}qi.prototype.ValueTypeName="quaternion";qi.prototype.InterpolantFactoryMethodSmooth=void 0;class xi extends Ze{constructor(t,e,n){super(t,e,n)}}xi.prototype.ValueTypeName="string";xi.prototype.ValueBufferType=Array;xi.prototype.DefaultInterpolation=Bi;xi.prototype.InterpolantFactoryMethodLinear=void 0;xi.prototype.InterpolantFactoryMethodSmooth=void 0;class Hi extends Ze{}Hi.prototype.ValueTypeName="vector";class Hm{constructor(t="",e=-1,n=[],r=Dc){this.name=t,this.tracks=n,this.duration=e,this.blendMode=r,this.uuid=Ge(),this.duration<0&&this.resetDuration()}static parse(t){const e=[],n=t.tracks,r=1/(t.fps||1);for(let a=0,o=n.length;a!==o;++a)e.push(Gm(n[a]).scale(r));const s=new this(t.name,t.duration,e,t.blendMode);return s.uuid=t.uuid,s}static toJSON(t){const e=[],n=t.tracks,r={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let s=0,a=n.length;s!==a;++s)e.push(Ze.toJSON(n[s]));return r}static CreateFromMorphTargetSequence(t,e,n,r){const s=e.length,a=[];for(let o=0;o<s;o++){let l=[],c=[];l.push((o+s-1)%s,o,(o+1)%s),c.push(0,1,0);const h=Fm(l);l=al(l,1,h),c=al(c,1,h),!r&&l[0]===0&&(l.push(s),c.push(c[0])),a.push(new Vi(".morphTargetInfluences["+e[o].name+"]",l,c).scale(1/n))}return new this(t,-1,a)}static findByName(t,e){let n=t;if(!Array.isArray(t)){const r=t;n=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<n.length;r++)if(n[r].name===e)return n[r];return null}static CreateClipsFromMorphTargetSequences(t,e,n){const r={},s=/^([\w-]*?)([\d]+)$/;for(let o=0,l=t.length;o<l;o++){const c=t[o],h=c.name.match(s);if(h&&h.length>1){const u=h[1];let d=r[u];d||(r[u]=d=[]),d.push(c)}}const a=[];for(const o in r)a.push(this.CreateFromMorphTargetSequence(o,r[o],e,n));return a}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(u,d,p,g,v){if(p.length!==0){const m=[],f=[];Kl(p,m,f,g),m.length!==0&&v.push(new u(d,m,f))}},r=[],s=t.name||"default",a=t.fps||30,o=t.blendMode;let l=t.length||-1;const c=t.hierarchy||[];for(let u=0;u<c.length;u++){const d=c[u].keys;if(!(!d||d.length===0))if(d[0].morphTargets){const p={};let g;for(g=0;g<d.length;g++)if(d[g].morphTargets)for(let v=0;v<d[g].morphTargets.length;v++)p[d[g].morphTargets[v]]=-1;for(const v in p){const m=[],f=[];for(let b=0;b!==d[g].morphTargets.length;++b){const T=d[g];m.push(T.time),f.push(T.morphTarget===v?1:0)}r.push(new Vi(".morphTargetInfluence["+v+"]",m,f))}l=p.length*a}else{const p=".bones["+e[u].name+"]";n(Hi,p+".position",d,"pos",r),n(qi,p+".quaternion",d,"rot",r),n(Hi,p+".scale",d,"scl",r)}}return r.length===0?null:new this(s,l,r,o)}resetDuration(){const t=this.tracks;let e=0;for(let n=0,r=t.length;n!==r;++n){const s=this.tracks[n];e=Math.max(e,s.times[s.times.length-1])}return this.duration=e,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){const t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,t,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function km(i){switch(i.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Vi;case"vector":case"vector2":case"vector3":case"vector4":return Hi;case"color":return Zl;case"quaternion":return qi;case"bool":case"boolean":return vi;case"string":return xi}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+i)}function Gm(i){if(i.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=km(i.type);if(i.times===void 0){const e=[],n=[];Kl(i.keys,e,n,"value"),i.times=e,i.values=n}return t.parse!==void 0?t.parse(i):new t(i.name,i.times,i.values,i.interpolation)}const En={enabled:!1,files:{},add:function(i,t){this.enabled!==!1&&(this.files[i]=t)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};class Wm{constructor(t,e,n){const r=this;let s=!1,a=0,o=0,l;const c=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(h){o++,s===!1&&r.onStart!==void 0&&r.onStart(h,a,o),s=!0},this.itemEnd=function(h){a++,r.onProgress!==void 0&&r.onProgress(h,a,o),a===o&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(h){r.onError!==void 0&&r.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,u){return c.push(h,u),this},this.removeHandler=function(h){const u=c.indexOf(h);return u!==-1&&c.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=c.length;u<d;u+=2){const p=c[u],g=c[u+1];if(p.global&&(p.lastIndex=0),p.test(h))return g}return null}}}const Xm=new Wm;class Mi{constructor(t){this.manager=t!==void 0?t:Xm,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){const n=this;return new Promise(function(r,s){n.load(t,r,e,s)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}}Mi.DEFAULT_MATERIAL_NAME="__DEFAULT";const rn={};class qm extends Error{constructor(t,e){super(t),this.response=e}}class Ym extends Mi{constructor(t){super(t)}load(t,e,n,r){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=En.get(t);if(s!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0),s;if(rn[t]!==void 0){rn[t].push({onLoad:e,onProgress:n,onError:r});return}rn[t]=[],rn[t].push({onLoad:e,onProgress:n,onError:r});const a=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream=="undefined"||c.body===void 0||c.body.getReader===void 0)return c;const h=rn[t],u=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),p=d?parseInt(d):0,g=p!==0;let v=0;const m=new ReadableStream({start(f){b();function b(){u.read().then(({done:T,value:S})=>{if(T)f.close();else{v+=S.byteLength;const B=new ProgressEvent("progress",{lengthComputable:g,loaded:v,total:p});for(let A=0,w=h.length;A<w;A++){const U=h[A];U.onProgress&&U.onProgress(B)}f.enqueue(S),b()}},T=>{f.error(T)})}}});return new Response(m)}else throw new qm(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return c.json();default:if(o===void 0)return c.text();{const u=/charset="?([^;"\s]*)"?/i.exec(o),d=u&&u[1]?u[1].toLowerCase():void 0,p=new TextDecoder(d);return c.arrayBuffer().then(g=>p.decode(g))}}}).then(c=>{En.add(t,c);const h=rn[t];delete rn[t];for(let u=0,d=h.length;u<d;u++){const p=h[u];p.onLoad&&p.onLoad(c)}}).catch(c=>{const h=rn[t];if(h===void 0)throw this.manager.itemError(t),c;delete rn[t];for(let u=0,d=h.length;u<d;u++){const p=h[u];p.onError&&p.onError(c)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}class Km extends Mi{constructor(t){super(t)}load(t,e,n,r){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,a=En.get(t);if(a!==void 0)return s.manager.itemStart(t),setTimeout(function(){e&&e(a),s.manager.itemEnd(t)},0),a;const o=zi("img");function l(){h(),En.add(t,this),e&&e(this),s.manager.itemEnd(t)}function c(u){h(),r&&r(u),s.manager.itemError(t),s.manager.itemEnd(t)}function h(){o.removeEventListener("load",l,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",c,!1),t.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),s.manager.itemStart(t),o.src=t,o}}class Zm extends Mi{constructor(t){super(t)}load(t,e,n,r){const s=new de,a=new Km(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(t,function(o){s.image=o,s.needsUpdate=!0,e!==void 0&&e(s)},n,r),s}}class zr extends se{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new It(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(e.object.target=this.target.uuid),e}}const ys=new Dt,ol=new L,ll=new L;class La{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ft(512,512),this.map=null,this.mapPass=null,this.matrix=new Dt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new ya,this._frameExtents=new Ft(1,1),this._viewportCount=1,this._viewports=[new Wt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;ol.setFromMatrixPosition(t.matrixWorld),e.position.copy(ol),ll.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(ll),e.updateMatrixWorld(),ys.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(ys),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(ys)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const t={};return this.intensity!==1&&(t.intensity=this.intensity),this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}class $m extends La{constructor(){super(new xe(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){const e=this.camera,n=pi*2*t.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=t.distance||e.far;(n!==e.fov||r!==e.aspect||s!==e.far)&&(e.fov=n,e.aspect=r,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class jm extends zr{constructor(t,e,n=0,r=Math.PI/3,s=0,a=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(se.DEFAULT_UP),this.updateMatrix(),this.target=new se,this.distance=n,this.angle=r,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new $m}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}const cl=new Dt,Pi=new L,Es=new L;class Jm extends La{constructor(){super(new xe(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Ft(4,2),this._viewportCount=6,this._viewports=[new Wt(2,1,1,1),new Wt(0,1,1,1),new Wt(3,1,1,1),new Wt(1,1,1,1),new Wt(3,0,1,1),new Wt(1,0,1,1)],this._cubeDirections=[new L(1,0,0),new L(-1,0,0),new L(0,0,1),new L(0,0,-1),new L(0,1,0),new L(0,-1,0)],this._cubeUps=[new L(0,1,0),new L(0,1,0),new L(0,1,0),new L(0,1,0),new L(0,0,1),new L(0,0,-1)]}updateMatrices(t,e=0){const n=this.camera,r=this.matrix,s=t.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),Pi.setFromMatrixPosition(t.matrixWorld),n.position.copy(Pi),Es.copy(n.position),Es.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(Es),n.updateMatrixWorld(),r.makeTranslation(-Pi.x,-Pi.y,-Pi.z),cl.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(cl)}}class Qm extends zr{constructor(t,e,n=0,r=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new Jm}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}class tg extends La{constructor(){super(new Ea(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class eg extends zr{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(se.DEFAULT_UP),this.updateMatrix(),this.target=new se,this.shadow=new tg}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class ng extends zr{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}}class ig{static decodeText(t){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder!="undefined")return new TextDecoder().decode(t);let e="";for(let n=0,r=t.length;n<r;n++)e+=String.fromCharCode(t[n]);try{return decodeURIComponent(escape(e))}catch(n){return e}}static extractUrlBase(t){const e=t.lastIndexOf("/");return e===-1?"./":t.slice(0,e+1)}static resolveURL(t,e){return typeof t!="string"||t===""?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:e+t)}}class rg extends Mi{constructor(t){super(t),this.isImageBitmapLoader=!0,typeof createImageBitmap=="undefined"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch=="undefined"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(t){return this.options=t,this}load(t,e,n,r){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,a=En.get(t);if(a!==void 0){if(s.manager.itemStart(t),a.then){a.then(c=>{e&&e(c),s.manager.itemEnd(t)}).catch(c=>{r&&r(c)});return}return setTimeout(function(){e&&e(a),s.manager.itemEnd(t)},0),a}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader;const l=fetch(t,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){return En.add(t,c),e&&e(c),s.manager.itemEnd(t),c}).catch(function(c){r&&r(c),En.remove(t),s.manager.itemError(t),s.manager.itemEnd(t)});En.add(t,l),s.manager.itemStart(t)}}const Da="\\[\\]\\.:\\/",sg=new RegExp("["+Da+"]","g"),Ia="[^"+Da+"]",ag="[^"+Da.replace("\\.","")+"]",og=/((?:WC+[\/:])*)/.source.replace("WC",Ia),lg=/(WCOD+)?/.source.replace("WCOD",ag),cg=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Ia),hg=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Ia),ug=new RegExp("^"+og+lg+cg+hg+"$"),dg=["material","materials","bones","map"];class fg{constructor(t,e,n){const r=n||Zt.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,r)}getValue(t,e){this.bind();const n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(t,e)}setValue(t,e){const n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=n.length;r!==s;++r)n[r].setValue(t,e)}bind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}}class Zt{constructor(t,e,n){this.path=e,this.parsedPath=n||Zt.parseTrackName(e),this.node=Zt.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new Zt.Composite(t,e,n):new Zt(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(sg,"")}static parseTrackName(t){const e=ug.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){const s=n.nodeName.substring(r+1);dg.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){const n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){const n=function(s){for(let a=0;a<s.length;a++){const o=s[a];if(o.name===e||o.uuid===e)return o;const l=n(o.children);if(l)return l}return null},r=n(t.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){const n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)t[e++]=n[r]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){const n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=t[e++]}_setValue_array_setNeedsUpdate(t,e){const n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){const n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node;const e=this.parsedPath,n=e.objectName,r=e.propertyName;let s=e.propertyIndex;if(t||(t=Zt.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=e.objectIndex;switch(n){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let h=0;h<t.length;h++)if(t[h].name===c){c=h;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[n]}if(c!==void 0){if(t[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[c]}}const a=t[r];if(a===void 0){const c=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+r+" but it wasn't found.",t);return}let o=this.Versioning.None;this.targetObject=t,t.needsUpdate!==void 0?o=this.Versioning.NeedsUpdate:t.matrixWorldNeedsUpdate!==void 0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[s]!==void 0&&(s=t.morphTargetDictionary[s])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=s}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=r;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Zt.Composite=fg;Zt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Zt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Zt.prototype.GetterByBindingType=[Zt.prototype._getValue_direct,Zt.prototype._getValue_array,Zt.prototype._getValue_arrayElement,Zt.prototype._getValue_toArray];Zt.prototype.SetterByBindingTypeAndVersioning=[[Zt.prototype._setValue_direct,Zt.prototype._setValue_direct_setNeedsUpdate,Zt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Zt.prototype._setValue_array,Zt.prototype._setValue_array_setNeedsUpdate,Zt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Zt.prototype._setValue_arrayElement,Zt.prototype._setValue_arrayElement_setNeedsUpdate,Zt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Zt.prototype._setValue_fromArray,Zt.prototype._setValue_fromArray_setNeedsUpdate,Zt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const hl=new Dt;class pg{constructor(t,e,n=0,r=1/0){this.ray=new gi(t,e),this.near=n,this.far=r,this.camera=null,this.layers=new Ma,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return hl.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(hl),this}intersectObject(t,e=!0,n=[]){return ua(t,this,n,e),n.sort(ul),n}intersectObjects(t,e=!0,n=[]){for(let r=0,s=t.length;r<s;r++)ua(t[r],this,n,e);return n.sort(ul),n}}function ul(i,t){return i.distance-t.distance}function ua(i,t,e,n){let r=!0;if(i.layers.test(t.layers)&&i.raycast(t,e)===!1&&(r=!1),r===!0&&n===!0){const s=i.children;for(let a=0,o=s.length;a<o;a++)ua(s[a],t,e,!0)}}class mg{constructor(t=1,e=0,n=0){return this.radius=t,this.phi=e,this.theta=n,this}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(le(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class gg extends Wl{constructor(t=10,e=10,n=4473924,r=8947848){n=new It(n),r=new It(r);const s=e/2,a=t/e,o=t/2,l=[],c=[];for(let d=0,p=0,g=-o;d<=e;d++,g+=a){l.push(-o,0,g,o,0,g),l.push(g,0,-o,g,0,o);const v=d===s?n:r;v.toArray(c,p),p+=3,v.toArray(c,p),p+=3,v.toArray(c,p),p+=3,v.toArray(c,p),p+=3}const h=new Ie;h.setAttribute("position",new ye(l,3)),h.setAttribute("color",new ye(c,3));const u=new wa({vertexColors:!0,toneMapped:!1});super(h,u),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class _g extends Hn{constructor(t,e=null){super(),this.object=t,this.domElement=e,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(){}disconnect(){}dispose(){}update(){}}typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"170"}}));typeof window!="undefined"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="170");exports.AmbientLight=ng;exports.AnimationClip=Hm;exports.Bone=kl;exports.Box3=hn;exports.BufferAttribute=Re;exports.BufferGeometry=Ie;exports.CatmullRomCurve3=Im;exports.CircleGeometry=Pa;exports.ClampToEdgeWrapping=Sn;exports.Color=It;exports.ColorManagement=Vt;exports.Controls=_g;exports.DirectionalLight=eg;exports.DoubleSide=qe;exports.EllipseCurve=Dm;exports.FileLoader=Ym;exports.FrontSide=ln;exports.GridHelper=gg;exports.Group=Ui;exports.ImageBitmapLoader=rg;exports.InstancedBufferAttribute=ca;exports.InstancedMesh=Cm;exports.InterleavedBuffer=Tm;exports.InterleavedBufferAttribute=ba;exports.Interpolant=Xi;exports.InterpolateDiscrete=Bi;exports.InterpolateLinear=Dr;exports.Line=Ra;exports.LineBasicMaterial=wa;exports.LineLoop=Pm;exports.LineSegments=Wl;exports.LinearFilter=He;exports.LinearMipmapLinearFilter=yn;exports.LinearMipmapNearestFilter=Er;exports.LinearSRGBColorSpace=Vn;exports.Loader=Mi;exports.LoaderUtils=ig;exports.MOUSE=Ql;exports.Material=wn;exports.MathUtils=lh;exports.Matrix4=Dt;exports.Mesh=we;exports.MeshBasicMaterial=Sa;exports.MeshPhysicalMaterial=Um;exports.MeshStandardMaterial=Yl;exports.MirroredRepeatWrapping=Lr;exports.NearestFilter=Se;exports.NearestMipmapLinearFilter=Li;exports.NearestMipmapNearestFilter=ml;exports.NumberKeyframeTrack=Vi;exports.Object3D=se;exports.OrthographicCamera=Ea;exports.PerspectiveCamera=xe;exports.Plane=xn;exports.PlaneGeometry=Wi;exports.PointLight=Qm;exports.Points=Lm;exports.PointsMaterial=Xl;exports.PropertyBinding=Zt;exports.Quaternion=kn;exports.QuaternionKeyframeTrack=qi;exports.Ray=gi;exports.Raycaster=pg;exports.RepeatWrapping=Pr;exports.SRGBColorSpace=Ae;exports.Scene=Em;exports.Skeleton=Aa;exports.SkinnedMesh=Am;exports.Sphere=Ke;exports.Spherical=mg;exports.SpotLight=jm;exports.TOUCH=tc;exports.Texture=de;exports.TextureLoader=Zm;exports.TriangleFanDrawMode=Nc;exports.TriangleStripDrawMode=Uc;exports.TrianglesDrawMode=Ic;exports.Vector2=Ft;exports.Vector3=L;exports.VectorKeyframeTrack=Hi;exports.WebGLRenderer=ym;