termdock 1.4.281 → 1.4.283

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 (340) hide show
  1. package/dist/client/assets/App-DIYNv8nX.js +157 -0
  2. package/dist/client/assets/App-DIYNv8nX.js.br +0 -0
  3. package/dist/client/assets/App-DIYNv8nX.js.gz +0 -0
  4. package/dist/client/assets/{ChangeWalkthroughPanel-CpJIxJoa.js → ChangeWalkthroughPanel-D3P0LWfU.js} +1 -1
  5. package/dist/client/assets/ChangeWalkthroughPanel-D3P0LWfU.js.br +0 -0
  6. package/dist/client/assets/ChangeWalkthroughPanel-D3P0LWfU.js.gz +0 -0
  7. package/dist/client/assets/{DagPlayground-DsZ_TzMA.js → DagPlayground-DHLTKfYe.js} +1 -1
  8. package/dist/client/assets/DagPlayground-DHLTKfYe.js.br +0 -0
  9. package/dist/client/assets/DagPlayground-DHLTKfYe.js.gz +0 -0
  10. package/dist/client/assets/{DiffLab-DVzd5Djx.js → DiffLab-DyapQhFp.js} +1 -1
  11. package/dist/client/assets/DiffLab-DyapQhFp.js.br +0 -0
  12. package/dist/client/assets/DiffLab-DyapQhFp.js.gz +0 -0
  13. package/dist/client/assets/{DiffReview-5MLGwl3s.js → DiffReview-CtlVXUuM.js} +1 -1
  14. package/dist/client/assets/DiffReview-CtlVXUuM.js.br +0 -0
  15. package/dist/client/assets/DiffReview-CtlVXUuM.js.gz +0 -0
  16. package/dist/client/assets/{DiffReviewLab-B53N-9cX.js → DiffReviewLab-CcATFm0V.js} +1 -1
  17. package/dist/client/assets/DiffReviewLab-CcATFm0V.js.br +0 -0
  18. package/dist/client/assets/DiffReviewLab-CcATFm0V.js.gz +0 -0
  19. package/dist/client/assets/{DiffViewer-PrcRXQq0.js → DiffViewer-DbAcE-rO.js} +2 -2
  20. package/dist/client/assets/DiffViewer-DbAcE-rO.js.br +0 -0
  21. package/dist/client/assets/DiffViewer-DbAcE-rO.js.gz +0 -0
  22. package/dist/client/assets/{ModelPreview-C98dbuUF.js → ModelPreview-DFsugreu.js} +161 -161
  23. package/dist/client/assets/ModelPreview-DFsugreu.js.br +0 -0
  24. package/dist/client/assets/ModelPreview-DFsugreu.js.gz +0 -0
  25. package/dist/client/assets/{RightSidebar-B52JGGs9.js → RightSidebar-BljTZjyo.js} +39 -39
  26. package/dist/client/assets/RightSidebar-BljTZjyo.js.br +0 -0
  27. package/dist/client/assets/RightSidebar-BljTZjyo.js.gz +0 -0
  28. package/dist/client/assets/{abnfDiagram-VCTEODGH-B5gA9_Ty.js → abnfDiagram-VCTEODGH-C6Qn78Kl.js} +1 -1
  29. package/dist/client/assets/abnfDiagram-VCTEODGH-C6Qn78Kl.js.br +0 -0
  30. package/dist/client/assets/abnfDiagram-VCTEODGH-C6Qn78Kl.js.gz +0 -0
  31. package/dist/client/assets/app-BT_37rUb.js +35 -0
  32. package/dist/client/assets/app-BT_37rUb.js.br +0 -0
  33. package/dist/client/assets/app-BT_37rUb.js.gz +0 -0
  34. package/dist/client/assets/{arc-Bq6Y_399.js → arc-DlrdXzuL.js} +1 -1
  35. package/dist/client/assets/arc-DlrdXzuL.js.br +0 -0
  36. package/dist/client/assets/arc-DlrdXzuL.js.gz +0 -0
  37. package/dist/client/assets/{architectureDiagram-5GKGNRK7-D7bXmRrP.js → architectureDiagram-5GKGNRK7-yDm6ZlLB.js} +1 -1
  38. package/dist/client/assets/architectureDiagram-5GKGNRK7-yDm6ZlLB.js.br +0 -0
  39. package/dist/client/assets/architectureDiagram-5GKGNRK7-yDm6ZlLB.js.gz +0 -0
  40. package/dist/client/assets/{blockDiagram-I7D4REHJ-vmiTllrb.js → blockDiagram-I7D4REHJ-CQ_ev6HF.js} +1 -1
  41. package/dist/client/assets/blockDiagram-I7D4REHJ-CQ_ev6HF.js.br +0 -0
  42. package/dist/client/assets/blockDiagram-I7D4REHJ-CQ_ev6HF.js.gz +0 -0
  43. package/dist/client/assets/{c4Diagram-7LVT6UL2-C6ThUVSU.js → c4Diagram-7LVT6UL2-Xc0eRnWn.js} +1 -1
  44. package/dist/client/assets/c4Diagram-7LVT6UL2-Xc0eRnWn.js.br +0 -0
  45. package/dist/client/assets/c4Diagram-7LVT6UL2-Xc0eRnWn.js.gz +0 -0
  46. package/dist/client/assets/channel-JBVMoCs6.js +1 -0
  47. package/dist/client/assets/{chunk-2Q5K7J3B-DR-yB9IL.js → chunk-2Q5K7J3B-DOea--M6.js} +1 -1
  48. package/dist/client/assets/{chunk-5VM5RSS4-B1nK9YvE.js → chunk-5VM5RSS4-5BTB5aOY.js} +1 -1
  49. package/dist/client/assets/{chunk-F27PBJKO-C7W0s-qY.js → chunk-F27PBJKO-D4bPuUCL.js} +1 -1
  50. package/dist/client/assets/chunk-F27PBJKO-D4bPuUCL.js.br +0 -0
  51. package/dist/client/assets/chunk-F27PBJKO-D4bPuUCL.js.gz +0 -0
  52. package/dist/client/assets/{chunk-IMKFNOWR-CTjPfIKT.js → chunk-IMKFNOWR-CcpsYCGR.js} +1 -1
  53. package/dist/client/assets/chunk-IMKFNOWR-CcpsYCGR.js.br +0 -0
  54. package/dist/client/assets/chunk-IMKFNOWR-CcpsYCGR.js.gz +0 -0
  55. package/dist/client/assets/{chunk-JWPE2WC7-DdFiULME.js → chunk-JWPE2WC7-DrVzbPfl.js} +1 -1
  56. package/dist/client/assets/{chunk-POPQ4Y6H-7D3Xkf9O.js → chunk-POPQ4Y6H-D2vQ6I_d.js} +1 -1
  57. package/dist/client/assets/{chunk-SVP7TREG-CCuDpBKr.js → chunk-SVP7TREG-BK9PycPu.js} +1 -1
  58. package/dist/client/assets/chunk-SVP7TREG-BK9PycPu.js.br +0 -0
  59. package/dist/client/assets/chunk-SVP7TREG-BK9PycPu.js.gz +0 -0
  60. package/dist/client/assets/{chunk-TICWLB2K-DtYX2TNH.js → chunk-TICWLB2K-LPhjhi7S.js} +1 -1
  61. package/dist/client/assets/chunk-TICWLB2K-LPhjhi7S.js.br +0 -0
  62. package/dist/client/assets/chunk-TICWLB2K-LPhjhi7S.js.gz +0 -0
  63. package/dist/client/assets/{chunk-XXDRQBXY-DhzCdSBY.js → chunk-XXDRQBXY-qujR76f5.js} +1 -1
  64. package/dist/client/assets/classDiagram-ZZMXUADV-BkraiclO.js +1 -0
  65. package/dist/client/assets/classDiagram-v2-VYDZK3BY-BkraiclO.js +1 -0
  66. package/dist/client/assets/{cose-bilkent-JH36ORCC-CyoiG3NB.js → cose-bilkent-JH36ORCC-BArSIiIO.js} +1 -1
  67. package/dist/client/assets/cose-bilkent-JH36ORCC-BArSIiIO.js.br +0 -0
  68. package/dist/client/assets/cose-bilkent-JH36ORCC-BArSIiIO.js.gz +0 -0
  69. package/dist/client/assets/{cynefin-OW5HDTMX-SeWSNPvK.js → cynefin-OW5HDTMX-CCs1or7w.js} +1 -1
  70. package/dist/client/assets/cynefin-OW5HDTMX-CCs1or7w.js.br +0 -0
  71. package/dist/client/assets/cynefin-OW5HDTMX-CCs1or7w.js.gz +0 -0
  72. package/dist/client/assets/{cynefinDiagram-5FMLGOSQ-C6Z9w461.js → cynefinDiagram-5FMLGOSQ-CZtiCwpH.js} +1 -1
  73. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-CZtiCwpH.js.br +0 -0
  74. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-CZtiCwpH.js.gz +0 -0
  75. package/dist/client/assets/{dagre-GXQ25YYZ-DgQ7oSI3.js → dagre-GXQ25YYZ-sxi6dz48.js} +1 -1
  76. package/dist/client/assets/dagre-GXQ25YYZ-sxi6dz48.js.br +0 -0
  77. package/dist/client/assets/dagre-GXQ25YYZ-sxi6dz48.js.gz +0 -0
  78. package/dist/client/assets/{diagram-S7CK7UJ4-BrFJNnZh.js → diagram-S7CK7UJ4-CqA9RxCi.js} +1 -1
  79. package/dist/client/assets/diagram-S7CK7UJ4-CqA9RxCi.js.br +0 -0
  80. package/dist/client/assets/diagram-S7CK7UJ4-CqA9RxCi.js.gz +0 -0
  81. package/dist/client/assets/{diagram-UQ7AKVKN-DW2EFMOu.js → diagram-UQ7AKVKN-DI6HGWgF.js} +1 -1
  82. package/dist/client/assets/diagram-UQ7AKVKN-DI6HGWgF.js.br +0 -0
  83. package/dist/client/assets/diagram-UQ7AKVKN-DI6HGWgF.js.gz +0 -0
  84. package/dist/client/assets/{diagram-VSXAHHWV-C5lTJcKk.js → diagram-VSXAHHWV-CMZi8lNh.js} +1 -1
  85. package/dist/client/assets/diagram-VSXAHHWV-CMZi8lNh.js.br +0 -0
  86. package/dist/client/assets/diagram-VSXAHHWV-CMZi8lNh.js.gz +0 -0
  87. package/dist/client/assets/{diagram-VX7I27RA-CObqcJqB.js → diagram-VX7I27RA-C7C5Wauj.js} +1 -1
  88. package/dist/client/assets/diagram-VX7I27RA-C7C5Wauj.js.br +0 -0
  89. package/dist/client/assets/diagram-VX7I27RA-C7C5Wauj.js.gz +0 -0
  90. package/dist/client/assets/{diagram-Z3DM3KII-br3lGnhW.js → diagram-Z3DM3KII-5gZWUza2.js} +1 -1
  91. package/dist/client/assets/diagram-Z3DM3KII-5gZWUza2.js.br +0 -0
  92. package/dist/client/assets/diagram-Z3DM3KII-5gZWUza2.js.gz +0 -0
  93. package/dist/client/assets/{ebnfDiagram-PWID7BFC-CkXxS9Pq.js → ebnfDiagram-PWID7BFC-_UeIqZQ9.js} +1 -1
  94. package/dist/client/assets/ebnfDiagram-PWID7BFC-_UeIqZQ9.js.br +0 -0
  95. package/dist/client/assets/ebnfDiagram-PWID7BFC-_UeIqZQ9.js.gz +0 -0
  96. package/dist/client/assets/{erDiagram-RLTQ6QDP-CMBJEKp-.js → erDiagram-RLTQ6QDP-Xmw2qbA7.js} +1 -1
  97. package/dist/client/assets/erDiagram-RLTQ6QDP-Xmw2qbA7.js.br +0 -0
  98. package/dist/client/assets/erDiagram-RLTQ6QDP-Xmw2qbA7.js.gz +0 -0
  99. package/dist/client/assets/{flowDiagram-HODETNUW-CuO0cLki.js → flowDiagram-HODETNUW-KRYKHFDk.js} +1 -1
  100. package/dist/client/assets/flowDiagram-HODETNUW-KRYKHFDk.js.br +0 -0
  101. package/dist/client/assets/flowDiagram-HODETNUW-KRYKHFDk.js.gz +0 -0
  102. package/dist/client/assets/{ganttDiagram-EL5Y4UJY-BIt0Y40Q.js → ganttDiagram-EL5Y4UJY-UcoHnpCx.js} +1 -1
  103. package/dist/client/assets/ganttDiagram-EL5Y4UJY-UcoHnpCx.js.br +0 -0
  104. package/dist/client/assets/ganttDiagram-EL5Y4UJY-UcoHnpCx.js.gz +0 -0
  105. package/dist/client/assets/{gestureArbiter--6cZMOnD.js → gestureArbiter-B6OZhQjV.js} +1 -1
  106. package/dist/client/assets/gestureArbiter-B6OZhQjV.js.br +0 -0
  107. package/dist/client/assets/gestureArbiter-B6OZhQjV.js.gz +0 -0
  108. package/dist/client/assets/{gitGraphDiagram-WWUBYQGX-C1ljbYw7.js → gitGraphDiagram-WWUBYQGX-Evwvg64n.js} +1 -1
  109. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-Evwvg64n.js.br +0 -0
  110. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-Evwvg64n.js.gz +0 -0
  111. package/dist/client/assets/imageCompression-DaUBNTq-.js +1 -0
  112. package/dist/client/assets/index-607UPNXL.js +1 -0
  113. package/dist/client/assets/index-607UPNXL.js.br +0 -0
  114. package/dist/client/assets/index-607UPNXL.js.gz +0 -0
  115. package/dist/client/assets/index-CUxsIblL.js +1 -0
  116. package/dist/client/assets/index-CUxsIblL.js.br +0 -0
  117. package/dist/client/assets/index-CUxsIblL.js.gz +0 -0
  118. package/dist/client/assets/{index-DeTcW7aT.css → index-IknuJMxJ.css} +1 -1
  119. package/dist/client/assets/index-IknuJMxJ.css.br +0 -0
  120. package/dist/client/assets/index-IknuJMxJ.css.gz +0 -0
  121. package/dist/client/assets/{infoDiagram-27XIBGKW-CrOPvG9H.js → infoDiagram-27XIBGKW-CdTYa6sH.js} +1 -1
  122. package/dist/client/assets/{ishikawaDiagram-5VMMS53U-Ch5ze9LB.js → ishikawaDiagram-5VMMS53U-D1-1rWNL.js} +1 -1
  123. package/dist/client/assets/ishikawaDiagram-5VMMS53U-D1-1rWNL.js.br +0 -0
  124. package/dist/client/assets/ishikawaDiagram-5VMMS53U-D1-1rWNL.js.gz +0 -0
  125. package/dist/client/assets/{journeyDiagram-3NMN7TZE-C3vqa0wB.js → journeyDiagram-3NMN7TZE-DNF2Xeph.js} +1 -1
  126. package/dist/client/assets/journeyDiagram-3NMN7TZE-DNF2Xeph.js.br +0 -0
  127. package/dist/client/assets/journeyDiagram-3NMN7TZE-DNF2Xeph.js.gz +0 -0
  128. package/dist/client/assets/{kanban-definition-UXKFOSKX-rEL2pKx0.js → kanban-definition-UXKFOSKX-nNy4MKl1.js} +1 -1
  129. package/dist/client/assets/kanban-definition-UXKFOSKX-nNy4MKl1.js.br +0 -0
  130. package/dist/client/assets/kanban-definition-UXKFOSKX-nNy4MKl1.js.gz +0 -0
  131. package/dist/client/assets/{layout-CeDdQRYz.js → layout-eOsGqyyy.js} +1 -1
  132. package/dist/client/assets/layout-eOsGqyyy.js.br +0 -0
  133. package/dist/client/assets/layout-eOsGqyyy.js.gz +0 -0
  134. package/dist/client/assets/{linear-C9xkTlXu.js → linear-BvPFVZ5r.js} +1 -1
  135. package/dist/client/assets/linear-BvPFVZ5r.js.br +0 -0
  136. package/dist/client/assets/linear-BvPFVZ5r.js.gz +0 -0
  137. package/dist/client/assets/{mermaid.core-CIW1IDpX.js → mermaid.core-xgi3W3HJ.js} +5 -5
  138. package/dist/client/assets/mermaid.core-xgi3W3HJ.js.br +0 -0
  139. package/dist/client/assets/mermaid.core-xgi3W3HJ.js.gz +0 -0
  140. package/dist/client/assets/{mindmap-definition-YA3MSWOX-CT9M_dpw.js → mindmap-definition-YA3MSWOX-C0Y8K-f6.js} +1 -1
  141. package/dist/client/assets/mindmap-definition-YA3MSWOX-C0Y8K-f6.js.br +0 -0
  142. package/dist/client/assets/mindmap-definition-YA3MSWOX-C0Y8K-f6.js.gz +0 -0
  143. package/dist/client/assets/{passwordBootstrap-B8awl9Cz.js → passwordBootstrap-dH2p1UXM.js} +1 -1
  144. package/dist/client/assets/passwordBootstrap-dH2p1UXM.js.br +0 -0
  145. package/dist/client/assets/passwordBootstrap-dH2p1UXM.js.gz +0 -0
  146. package/dist/client/assets/{pegDiagram-XKGWAZYB-BkaUHxk6.js → pegDiagram-XKGWAZYB-DDphzW5Y.js} +1 -1
  147. package/dist/client/assets/pegDiagram-XKGWAZYB-DDphzW5Y.js.br +0 -0
  148. package/dist/client/assets/pegDiagram-XKGWAZYB-DDphzW5Y.js.gz +0 -0
  149. package/dist/client/assets/{pieDiagram-E7YTZNPT-Di_VEsZA.js → pieDiagram-E7YTZNPT-GDu--HqE.js} +1 -1
  150. package/dist/client/assets/pieDiagram-E7YTZNPT-GDu--HqE.js.br +0 -0
  151. package/dist/client/assets/pieDiagram-E7YTZNPT-GDu--HqE.js.gz +0 -0
  152. package/dist/client/assets/{quadrantDiagram-AXDQQJYC-B--Y1EgY.js → quadrantDiagram-AXDQQJYC-NSIlEYZd.js} +1 -1
  153. package/dist/client/assets/quadrantDiagram-AXDQQJYC-NSIlEYZd.js.br +0 -0
  154. package/dist/client/assets/quadrantDiagram-AXDQQJYC-NSIlEYZd.js.gz +0 -0
  155. package/dist/client/assets/{railroadDiagram-O6MQD6OU-CTTF__yz.js → railroadDiagram-O6MQD6OU-BMr8_470.js} +1 -1
  156. package/dist/client/assets/railroadDiagram-O6MQD6OU-BMr8_470.js.br +0 -0
  157. package/dist/client/assets/railroadDiagram-O6MQD6OU-BMr8_470.js.gz +0 -0
  158. package/dist/client/assets/{referenceLongPress-jOxtSE5l.js → referenceLongPress-5KOTIE_2.js} +1 -1
  159. package/dist/client/assets/referenceLongPress-5KOTIE_2.js.br +0 -0
  160. package/dist/client/assets/referenceLongPress-5KOTIE_2.js.gz +0 -0
  161. package/dist/client/assets/{requirementDiagram-BXWQKSXE-DI0C2RWw.js → requirementDiagram-BXWQKSXE-BYfx-BnY.js} +1 -1
  162. package/dist/client/assets/requirementDiagram-BXWQKSXE-BYfx-BnY.js.br +0 -0
  163. package/dist/client/assets/requirementDiagram-BXWQKSXE-BYfx-BnY.js.gz +0 -0
  164. package/dist/client/assets/{sankeyDiagram-P5KCCOFB-W5HRSQpx.js → sankeyDiagram-P5KCCOFB-Sjw1moBs.js} +1 -1
  165. package/dist/client/assets/sankeyDiagram-P5KCCOFB-Sjw1moBs.js.br +0 -0
  166. package/dist/client/assets/sankeyDiagram-P5KCCOFB-Sjw1moBs.js.gz +0 -0
  167. package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-BKkAIBat.js → sequenceDiagram-WJ2MYXX4-BdB4bAuv.js} +1 -1
  168. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-BdB4bAuv.js.br +0 -0
  169. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-BdB4bAuv.js.gz +0 -0
  170. package/dist/client/assets/{sizeCapture-INFHLROL-DXBwqyIS.js → sizeCapture-INFHLROL-Bqjs5SmV.js} +1 -1
  171. package/dist/client/assets/sizeCapture-INFHLROL-Bqjs5SmV.js.br +0 -0
  172. package/dist/client/assets/sizeCapture-INFHLROL-Bqjs5SmV.js.gz +0 -0
  173. package/dist/client/assets/{sparkles-DceTfvKw.js → sparkles-BqYxpm2T.js} +1 -1
  174. package/dist/client/assets/{stateDiagram-D77RDMKH-BBVi-dyW.js → stateDiagram-D77RDMKH-CeGiiS-A.js} +1 -1
  175. package/dist/client/assets/stateDiagram-D77RDMKH-CeGiiS-A.js.br +0 -0
  176. package/dist/client/assets/stateDiagram-D77RDMKH-CeGiiS-A.js.gz +0 -0
  177. package/dist/client/assets/stateDiagram-v2-MP3YSRHH-DAcs8J97.js +1 -0
  178. package/dist/client/assets/{swimlanes-42K2YHIH-DwJjgXte.js → swimlanes-42K2YHIH-CfKdzOcE.js} +1 -1
  179. package/dist/client/assets/swimlanes-42K2YHIH-CfKdzOcE.js.br +0 -0
  180. package/dist/client/assets/swimlanes-42K2YHIH-CfKdzOcE.js.gz +0 -0
  181. package/dist/client/assets/swimlanesDiagram-VR7AAH4N-ByPh86Cc.js +8 -0
  182. package/dist/client/assets/{timeline-definition-24CTP7MA-COX39iJ6.js → timeline-definition-24CTP7MA-BQHm94LP.js} +1 -1
  183. package/dist/client/assets/timeline-definition-24CTP7MA-BQHm94LP.js.br +0 -0
  184. package/dist/client/assets/timeline-definition-24CTP7MA-BQHm94LP.js.gz +0 -0
  185. package/dist/client/assets/{triangle-alert-DjtUXw4T.js → triangle-alert-9JebA9Zi.js} +1 -1
  186. package/dist/client/assets/{vennDiagram-4TSXK5OY-46HA9L0l.js → vennDiagram-4TSXK5OY-CiDKvpY7.js} +1 -1
  187. package/dist/client/assets/vennDiagram-4TSXK5OY-CiDKvpY7.js.br +0 -0
  188. package/dist/client/assets/vennDiagram-4TSXK5OY-CiDKvpY7.js.gz +0 -0
  189. package/dist/client/assets/videoCompression-BZCAJl_H.js +3 -0
  190. package/dist/client/assets/videoCompression-BZCAJl_H.js.br +0 -0
  191. package/dist/client/assets/videoCompression-BZCAJl_H.js.gz +0 -0
  192. package/dist/client/assets/{wardleyDiagram-VM6X3IG4-DfkGMObP.js → wardleyDiagram-VM6X3IG4-DOUAhlES.js} +1 -1
  193. package/dist/client/assets/wardleyDiagram-VM6X3IG4-DOUAhlES.js.br +0 -0
  194. package/dist/client/assets/wardleyDiagram-VM6X3IG4-DOUAhlES.js.gz +0 -0
  195. package/dist/client/assets/worker-BAOIWoxA.js +1 -0
  196. package/dist/client/assets/worker-BAOIWoxA.js.br +0 -0
  197. package/dist/client/assets/worker-BAOIWoxA.js.gz +0 -0
  198. package/dist/client/assets/{xychartDiagram-S5SC5T6Z-vlKat3e7.js → xychartDiagram-S5SC5T6Z-BV7ihxFK.js} +1 -1
  199. package/dist/client/assets/xychartDiagram-S5SC5T6Z-BV7ihxFK.js.br +0 -0
  200. package/dist/client/assets/xychartDiagram-S5SC5T6Z-BV7ihxFK.js.gz +0 -0
  201. package/dist/client/index.html +44 -4
  202. package/dist/client/index.html.br +0 -0
  203. package/dist/client/index.html.gz +0 -0
  204. package/dist/client/licenses/loading-dev.txt +21 -0
  205. package/dist/client/licenses/loading-dev.txt.br +0 -0
  206. package/dist/client/licenses/loading-dev.txt.gz +0 -0
  207. package/dist/client/sw-encrypted-background.js +1 -1
  208. package/dist/client/sw-encrypted-background.js.br +0 -0
  209. package/dist/client/sw-encrypted-background.js.gz +0 -0
  210. package/dist/client/sw.js +1 -1
  211. package/dist/client/sw.js.br +0 -0
  212. package/dist/client/sw.js.gz +0 -0
  213. package/dist/server/entry.js +38 -1
  214. package/dist/server/routes/terminal.js +2 -1
  215. package/dist/server/utils/runtimeClient.js +34 -0
  216. package/package.json +4 -1
  217. package/runtime-manifest.json +4 -4
  218. package/dist/client/assets/App-VGKzpPWO.js +0 -156
  219. package/dist/client/assets/App-VGKzpPWO.js.br +0 -0
  220. package/dist/client/assets/App-VGKzpPWO.js.gz +0 -0
  221. package/dist/client/assets/ChangeWalkthroughPanel-CpJIxJoa.js.br +0 -0
  222. package/dist/client/assets/ChangeWalkthroughPanel-CpJIxJoa.js.gz +0 -0
  223. package/dist/client/assets/DagPlayground-DsZ_TzMA.js.br +0 -0
  224. package/dist/client/assets/DagPlayground-DsZ_TzMA.js.gz +0 -0
  225. package/dist/client/assets/DiffLab-DVzd5Djx.js.br +0 -0
  226. package/dist/client/assets/DiffLab-DVzd5Djx.js.gz +0 -0
  227. package/dist/client/assets/DiffReview-5MLGwl3s.js.br +0 -0
  228. package/dist/client/assets/DiffReview-5MLGwl3s.js.gz +0 -0
  229. package/dist/client/assets/DiffReviewLab-B53N-9cX.js.br +0 -0
  230. package/dist/client/assets/DiffReviewLab-B53N-9cX.js.gz +0 -0
  231. package/dist/client/assets/DiffViewer-PrcRXQq0.js.br +0 -0
  232. package/dist/client/assets/DiffViewer-PrcRXQq0.js.gz +0 -0
  233. package/dist/client/assets/ModelPreview-C98dbuUF.js.br +0 -0
  234. package/dist/client/assets/ModelPreview-C98dbuUF.js.gz +0 -0
  235. package/dist/client/assets/RightSidebar-B52JGGs9.js.br +0 -0
  236. package/dist/client/assets/RightSidebar-B52JGGs9.js.gz +0 -0
  237. package/dist/client/assets/abnfDiagram-VCTEODGH-B5gA9_Ty.js.br +0 -0
  238. package/dist/client/assets/abnfDiagram-VCTEODGH-B5gA9_Ty.js.gz +0 -0
  239. package/dist/client/assets/app-DnjpR35Q.js +0 -35
  240. package/dist/client/assets/app-DnjpR35Q.js.br +0 -0
  241. package/dist/client/assets/app-DnjpR35Q.js.gz +0 -0
  242. package/dist/client/assets/arc-Bq6Y_399.js.br +0 -0
  243. package/dist/client/assets/arc-Bq6Y_399.js.gz +0 -0
  244. package/dist/client/assets/architectureDiagram-5GKGNRK7-D7bXmRrP.js.br +0 -0
  245. package/dist/client/assets/architectureDiagram-5GKGNRK7-D7bXmRrP.js.gz +0 -0
  246. package/dist/client/assets/blockDiagram-I7D4REHJ-vmiTllrb.js.br +0 -0
  247. package/dist/client/assets/blockDiagram-I7D4REHJ-vmiTllrb.js.gz +0 -0
  248. package/dist/client/assets/c4Diagram-7LVT6UL2-C6ThUVSU.js.br +0 -0
  249. package/dist/client/assets/c4Diagram-7LVT6UL2-C6ThUVSU.js.gz +0 -0
  250. package/dist/client/assets/channel-DLM_eD7J.js +0 -1
  251. package/dist/client/assets/chunk-F27PBJKO-C7W0s-qY.js.br +0 -0
  252. package/dist/client/assets/chunk-F27PBJKO-C7W0s-qY.js.gz +0 -0
  253. package/dist/client/assets/chunk-IMKFNOWR-CTjPfIKT.js.br +0 -0
  254. package/dist/client/assets/chunk-IMKFNOWR-CTjPfIKT.js.gz +0 -0
  255. package/dist/client/assets/chunk-SVP7TREG-CCuDpBKr.js.br +0 -0
  256. package/dist/client/assets/chunk-SVP7TREG-CCuDpBKr.js.gz +0 -0
  257. package/dist/client/assets/chunk-TICWLB2K-DtYX2TNH.js.br +0 -0
  258. package/dist/client/assets/chunk-TICWLB2K-DtYX2TNH.js.gz +0 -0
  259. package/dist/client/assets/classDiagram-ZZMXUADV-C1zXUzCS.js +0 -1
  260. package/dist/client/assets/classDiagram-v2-VYDZK3BY-C1zXUzCS.js +0 -1
  261. package/dist/client/assets/cose-bilkent-JH36ORCC-CyoiG3NB.js.br +0 -0
  262. package/dist/client/assets/cose-bilkent-JH36ORCC-CyoiG3NB.js.gz +0 -0
  263. package/dist/client/assets/cynefin-OW5HDTMX-SeWSNPvK.js.br +0 -0
  264. package/dist/client/assets/cynefin-OW5HDTMX-SeWSNPvK.js.gz +0 -0
  265. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-C6Z9w461.js.br +0 -0
  266. package/dist/client/assets/cynefinDiagram-5FMLGOSQ-C6Z9w461.js.gz +0 -0
  267. package/dist/client/assets/dagre-GXQ25YYZ-DgQ7oSI3.js.br +0 -0
  268. package/dist/client/assets/dagre-GXQ25YYZ-DgQ7oSI3.js.gz +0 -0
  269. package/dist/client/assets/diagram-S7CK7UJ4-BrFJNnZh.js.br +0 -0
  270. package/dist/client/assets/diagram-S7CK7UJ4-BrFJNnZh.js.gz +0 -0
  271. package/dist/client/assets/diagram-UQ7AKVKN-DW2EFMOu.js.br +0 -0
  272. package/dist/client/assets/diagram-UQ7AKVKN-DW2EFMOu.js.gz +0 -0
  273. package/dist/client/assets/diagram-VSXAHHWV-C5lTJcKk.js.br +0 -0
  274. package/dist/client/assets/diagram-VSXAHHWV-C5lTJcKk.js.gz +0 -0
  275. package/dist/client/assets/diagram-VX7I27RA-CObqcJqB.js.br +0 -0
  276. package/dist/client/assets/diagram-VX7I27RA-CObqcJqB.js.gz +0 -0
  277. package/dist/client/assets/diagram-Z3DM3KII-br3lGnhW.js.br +0 -0
  278. package/dist/client/assets/diagram-Z3DM3KII-br3lGnhW.js.gz +0 -0
  279. package/dist/client/assets/ebnfDiagram-PWID7BFC-CkXxS9Pq.js.br +0 -0
  280. package/dist/client/assets/ebnfDiagram-PWID7BFC-CkXxS9Pq.js.gz +0 -0
  281. package/dist/client/assets/erDiagram-RLTQ6QDP-CMBJEKp-.js.br +0 -0
  282. package/dist/client/assets/erDiagram-RLTQ6QDP-CMBJEKp-.js.gz +0 -0
  283. package/dist/client/assets/flowDiagram-HODETNUW-CuO0cLki.js.br +0 -0
  284. package/dist/client/assets/flowDiagram-HODETNUW-CuO0cLki.js.gz +0 -0
  285. package/dist/client/assets/ganttDiagram-EL5Y4UJY-BIt0Y40Q.js.br +0 -0
  286. package/dist/client/assets/ganttDiagram-EL5Y4UJY-BIt0Y40Q.js.gz +0 -0
  287. package/dist/client/assets/gestureArbiter--6cZMOnD.js.br +0 -0
  288. package/dist/client/assets/gestureArbiter--6cZMOnD.js.gz +0 -0
  289. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-C1ljbYw7.js.br +0 -0
  290. package/dist/client/assets/gitGraphDiagram-WWUBYQGX-C1ljbYw7.js.gz +0 -0
  291. package/dist/client/assets/index-DeTcW7aT.css.br +0 -0
  292. package/dist/client/assets/index-DeTcW7aT.css.gz +0 -0
  293. package/dist/client/assets/ishikawaDiagram-5VMMS53U-Ch5ze9LB.js.br +0 -0
  294. package/dist/client/assets/ishikawaDiagram-5VMMS53U-Ch5ze9LB.js.gz +0 -0
  295. package/dist/client/assets/journeyDiagram-3NMN7TZE-C3vqa0wB.js.br +0 -0
  296. package/dist/client/assets/journeyDiagram-3NMN7TZE-C3vqa0wB.js.gz +0 -0
  297. package/dist/client/assets/kanban-definition-UXKFOSKX-rEL2pKx0.js.br +0 -0
  298. package/dist/client/assets/kanban-definition-UXKFOSKX-rEL2pKx0.js.gz +0 -0
  299. package/dist/client/assets/layout-CeDdQRYz.js.br +0 -0
  300. package/dist/client/assets/layout-CeDdQRYz.js.gz +0 -0
  301. package/dist/client/assets/linear-C9xkTlXu.js.br +0 -0
  302. package/dist/client/assets/linear-C9xkTlXu.js.gz +0 -0
  303. package/dist/client/assets/mermaid.core-CIW1IDpX.js.br +0 -0
  304. package/dist/client/assets/mermaid.core-CIW1IDpX.js.gz +0 -0
  305. package/dist/client/assets/mindmap-definition-YA3MSWOX-CT9M_dpw.js.br +0 -0
  306. package/dist/client/assets/mindmap-definition-YA3MSWOX-CT9M_dpw.js.gz +0 -0
  307. package/dist/client/assets/passwordBootstrap-B8awl9Cz.js.br +0 -0
  308. package/dist/client/assets/passwordBootstrap-B8awl9Cz.js.gz +0 -0
  309. package/dist/client/assets/pegDiagram-XKGWAZYB-BkaUHxk6.js.br +0 -0
  310. package/dist/client/assets/pegDiagram-XKGWAZYB-BkaUHxk6.js.gz +0 -0
  311. package/dist/client/assets/pieDiagram-E7YTZNPT-Di_VEsZA.js.br +0 -0
  312. package/dist/client/assets/pieDiagram-E7YTZNPT-Di_VEsZA.js.gz +0 -0
  313. package/dist/client/assets/quadrantDiagram-AXDQQJYC-B--Y1EgY.js.br +0 -0
  314. package/dist/client/assets/quadrantDiagram-AXDQQJYC-B--Y1EgY.js.gz +0 -0
  315. package/dist/client/assets/railroadDiagram-O6MQD6OU-CTTF__yz.js.br +0 -0
  316. package/dist/client/assets/railroadDiagram-O6MQD6OU-CTTF__yz.js.gz +0 -0
  317. package/dist/client/assets/referenceLongPress-jOxtSE5l.js.br +0 -0
  318. package/dist/client/assets/referenceLongPress-jOxtSE5l.js.gz +0 -0
  319. package/dist/client/assets/requirementDiagram-BXWQKSXE-DI0C2RWw.js.br +0 -0
  320. package/dist/client/assets/requirementDiagram-BXWQKSXE-DI0C2RWw.js.gz +0 -0
  321. package/dist/client/assets/sankeyDiagram-P5KCCOFB-W5HRSQpx.js.br +0 -0
  322. package/dist/client/assets/sankeyDiagram-P5KCCOFB-W5HRSQpx.js.gz +0 -0
  323. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-BKkAIBat.js.br +0 -0
  324. package/dist/client/assets/sequenceDiagram-WJ2MYXX4-BKkAIBat.js.gz +0 -0
  325. package/dist/client/assets/sizeCapture-INFHLROL-DXBwqyIS.js.br +0 -0
  326. package/dist/client/assets/sizeCapture-INFHLROL-DXBwqyIS.js.gz +0 -0
  327. package/dist/client/assets/stateDiagram-D77RDMKH-BBVi-dyW.js.br +0 -0
  328. package/dist/client/assets/stateDiagram-D77RDMKH-BBVi-dyW.js.gz +0 -0
  329. package/dist/client/assets/stateDiagram-v2-MP3YSRHH-DjAtlfPn.js +0 -1
  330. package/dist/client/assets/swimlanes-42K2YHIH-DwJjgXte.js.br +0 -0
  331. package/dist/client/assets/swimlanes-42K2YHIH-DwJjgXte.js.gz +0 -0
  332. package/dist/client/assets/swimlanesDiagram-VR7AAH4N-BRWkDBH5.js +0 -8
  333. package/dist/client/assets/timeline-definition-24CTP7MA-COX39iJ6.js.br +0 -0
  334. package/dist/client/assets/timeline-definition-24CTP7MA-COX39iJ6.js.gz +0 -0
  335. package/dist/client/assets/vennDiagram-4TSXK5OY-46HA9L0l.js.br +0 -0
  336. package/dist/client/assets/vennDiagram-4TSXK5OY-46HA9L0l.js.gz +0 -0
  337. package/dist/client/assets/wardleyDiagram-VM6X3IG4-DfkGMObP.js.br +0 -0
  338. package/dist/client/assets/wardleyDiagram-VM6X3IG4-DfkGMObP.js.gz +0 -0
  339. package/dist/client/assets/xychartDiagram-S5SC5T6Z-vlKat3e7.js.br +0 -0
  340. package/dist/client/assets/xychartDiagram-S5SC5T6Z-vlKat3e7.js.gz +0 -0
@@ -1,10 +1,10 @@
1
- import{a6 as ss,cM as Do,bi as ie,X as Da,g as ku}from"./app-DnjpR35Q.js";import{b as we,r as zu}from"./dnd-BCFAPC0L.js";import{S as Vu,u as Hu,j as Gu,R as Wu,L as Xu,i as Yu,M as qu,H as Ku,p as Zu}from"./App-VGKzpPWO.js";import{a as Yc,E as qc,m as ms,c as $u}from"./RightSidebar-B52JGGs9.js";import{L as dl}from"./DiffReview-5MLGwl3s.js";import"./react-XDCjal2T.js";import"./terminal-C7X98Amf.js";import"./gestureArbiter--6cZMOnD.js";import"./triangle-alert-DjtUXw4T.js";import"./referenceLongPress-jOxtSE5l.js";import"./sparkles-DceTfvKw.js";import"./ChangeWalkthroughPanel-CpJIxJoa.js";import"./DiffViewer-PrcRXQq0.js";const ju=[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]],Ju=ss("arrow-left-right",ju);const Qu=[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]],Kc=ss("focus",Qu);const eh=[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]],th=ss("quote",eh);const nh=[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]],ih=ss("scissors",nh);const sh=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],rh=ss("tag",sh);const ah=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],Na=ss("undo-2",ah);const No="185",Yi={ROTATE:0,DOLLY:1,PAN:2},Xi={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},oh=0,fl=1,lh=2,Sr=1,ch=2,ws=3,Dn=0,tn=1,an=2,Kn=0,qi=1,pl=2,ml=3,gl=4,uh=5,xi=100,hh=101,dh=102,fh=103,ph=104,mh=200,gh=201,_h=202,xh=203,Ua=204,Fa=205,vh=206,Mh=207,Sh=208,yh=209,bh=210,Eh=211,Th=212,Ah=213,wh=214,Oa=0,Ba=1,ka=2,Ji=3,za=4,Va=5,Ha=6,Ga=7,Zc=0,Rh=1,Ch=2,Pn=0,$c=1,jc=2,Jc=3,Qc=4,eu=5,tu=6,nu=7,_l="attached",Ph="detached",iu=300,bi=301,Qi=302,Xr=303,Yr=304,Or=306,es=1e3,Rn=1001,Rr=1002,Ot=1003,su=1004,Rs=1005,Bt=1006,yr=1007,Yn=1008,on=1009,ru=1010,au=1011,Ds=1012,Uo=1013,Nn=1014,fn=1015,$n=1016,Fo=1017,Oo=1018,Ns=1020,ou=35902,lu=35899,cu=1021,uu=1022,pn=1023,jn=1026,Mi=1027,Bo=1028,ko=1029,Ei=1030,zo=1031,Vo=1033,br=33776,Er=33777,Tr=33778,Ar=33779,Wa=35840,Xa=35841,Ya=35842,qa=35843,Ka=36196,Za=37492,$a=37496,ja=37488,Ja=37489,Cr=37490,Qa=37491,eo=37808,to=37809,no=37810,io=37811,so=37812,ro=37813,ao=37814,oo=37815,lo=37816,co=37817,uo=37818,ho=37819,fo=37820,po=37821,mo=36492,go=36494,_o=36495,xo=36283,vo=36284,Pr=36285,Mo=36286,Us=2300,Fs=2301,qr=2302,xl=2303,vl=2400,Ml=2401,Sl=2402,Lh=2500,Ih=0,hu=1,So=2,Dh=3200,yo=0,Nh=1,li="",Ht="srgb",ln="srgb-linear",Lr="linear",ut="srgb",Ci=7680,yl=519,Uh=512,Fh=513,Oh=514,Ho=515,Bh=516,kh=517,Go=518,zh=519,bo=35044,bl="300 es",Cn=2e3,Os=2001;function Vh(s){for(let e=s.length-1;e>=0;--e)if(s[e]>=65535)return!0;return!1}function Hh(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function Bs(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function Gh(){const s=Bs("canvas");return s.style.display="block",s}const El={};function Ir(...s){const e="THREE."+s.shift();console.log(e,...s)}function du(s){const e=s[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=s[1];t&&t.isStackTrace?s[0]+=" "+t.getLocation():s[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return s}function Ie(...s){s=du(s);const e="THREE."+s.shift();{const t=s[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...s)}}function ze(...s){s=du(s);const e="THREE."+s.shift();{const t=s[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...s)}}function Ki(...s){const e=s.join(" ");e in El||(El[e]=!0,Ie(...s))}function Wh(s,e,t){return new Promise(function(n,i){function r(){switch(s.clientWaitSync(e,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:i();break;case s.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}const Xh={[Oa]:Ba,[ka]:Ha,[za]:Ga,[Ji]:Va,[Ba]:Oa,[Ha]:ka,[Ga]:za,[Va]:Ji};class hi{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const i=n[e];if(i!==void 0){const r=i.indexOf(t);r!==-1&&i.splice(r,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let r=0,a=i.length;r<a;r++)i[r].call(this,e);e.target=null}}}const Zt=["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 Tl=1234567;const Ps=Math.PI/180,ts=180/Math.PI;function Mn(){const s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Zt[s&255]+Zt[s>>8&255]+Zt[s>>16&255]+Zt[s>>24&255]+"-"+Zt[e&255]+Zt[e>>8&255]+"-"+Zt[e>>16&15|64]+Zt[e>>24&255]+"-"+Zt[t&63|128]+Zt[t>>8&255]+"-"+Zt[t>>16&255]+Zt[t>>24&255]+Zt[n&255]+Zt[n>>8&255]+Zt[n>>16&255]+Zt[n>>24&255]).toLowerCase()}function $e(s,e,t){return Math.max(e,Math.min(t,s))}function Wo(s,e){return(s%e+e)%e}function Yh(s,e,t,n,i){return n+(s-e)*(i-n)/(t-e)}function qh(s,e,t){return s!==e?(t-s)/(e-s):0}function Ls(s,e,t){return(1-t)*s+t*e}function Kh(s,e,t,n){return Ls(s,e,1-Math.exp(-t*n))}function Zh(s,e=1){return e-Math.abs(Wo(s,e*2)-e)}function $h(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*(3-2*s))}function jh(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*s*(s*(s*6-15)+10))}function Jh(s,e){return s+Math.floor(Math.random()*(e-s+1))}function Qh(s,e){return s+Math.random()*(e-s)}function ed(s){return s*(.5-Math.random())}function td(s){s!==void 0&&(Tl=s);let e=Tl+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function nd(s){return s*Ps}function id(s){return s*ts}function sd(s){return(s&s-1)===0&&s!==0}function rd(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function ad(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function od(s,e,t,n,i){const r=Math.cos,a=Math.sin,o=r(t/2),l=a(t/2),c=r((e+n)/2),u=a((e+n)/2),h=r((e-n)/2),d=a((e-n)/2),f=r((n-e)/2),_=a((n-e)/2);switch(i){case"XYX":s.set(o*u,l*h,l*d,o*c);break;case"YZY":s.set(l*d,o*u,l*h,o*c);break;case"ZXZ":s.set(l*h,l*d,o*u,o*c);break;case"XZX":s.set(o*u,l*_,l*f,o*c);break;case"YXY":s.set(l*f,o*u,l*_,o*c);break;case"ZYZ":s.set(l*_,l*f,o*u,o*c);break;default:Ie("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function xn(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function ht(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const fu={DEG2RAD:Ps,RAD2DEG:ts,generateUUID:Mn,clamp:$e,euclideanModulo:Wo,mapLinear:Yh,inverseLerp:qh,lerp:Ls,damp:Kh,pingpong:Zh,smoothstep:$h,smootherstep:jh,randInt:Jh,randFloat:Qh,randFloatSpread:ed,seededRandom:td,degToRad:nd,radToDeg:id,isPowerOfTwo:sd,ceilPowerOfTwo:rd,floorPowerOfTwo:ad,setQuaternionFromProperEuler:od,normalize:ht,denormalize:xn},al=class al{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=$e(this.x,e.x,t.x),this.y=$e(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=$e(this.x,e,t),this.y=$e(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar($e(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos($e(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*i+e.x,this.y=r*i+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};al.prototype.isVector2=!0;let ke=al;class Sn{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,a,o){let l=n[i+0],c=n[i+1],u=n[i+2],h=n[i+3],d=r[a+0],f=r[a+1],_=r[a+2],v=r[a+3];if(h!==v||l!==d||c!==f||u!==_){let m=l*d+c*f+u*_+h*v;m<0&&(d=-d,f=-f,_=-_,v=-v,m=-m);let p=1-o;if(m<.9995){const b=Math.acos(m),T=Math.sin(b);p=Math.sin(p*b)/T,o=Math.sin(o*b)/T,l=l*p+d*o,c=c*p+f*o,u=u*p+_*o,h=h*p+v*o}else{l=l*p+d*o,c=c*p+f*o,u=u*p+_*o,h=h*p+v*o;const b=1/Math.sqrt(l*l+c*c+u*u+h*h);l*=b,c*=b,u*=b,h*=b}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,i,r,a){const o=n[i],l=n[i+1],c=n[i+2],u=n[i+3],h=r[a],d=r[a+1],f=r[a+2],_=r[a+3];return e[t]=o*_+u*h+l*f-c*d,e[t+1]=l*_+u*d+c*h-o*f,e[t+2]=c*_+u*f+o*d-l*h,e[t+3]=u*_-o*h-l*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,i=e._y,r=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(n/2),u=o(i/2),h=o(r/2),d=l(n/2),f=l(i/2),_=l(r/2);switch(a){case"XYZ":this._x=d*u*h+c*f*_,this._y=c*f*h-d*u*_,this._z=c*u*_+d*f*h,this._w=c*u*h-d*f*_;break;case"YXZ":this._x=d*u*h+c*f*_,this._y=c*f*h-d*u*_,this._z=c*u*_-d*f*h,this._w=c*u*h+d*f*_;break;case"ZXY":this._x=d*u*h-c*f*_,this._y=c*f*h+d*u*_,this._z=c*u*_+d*f*h,this._w=c*u*h-d*f*_;break;case"ZYX":this._x=d*u*h-c*f*_,this._y=c*f*h+d*u*_,this._z=c*u*_-d*f*h,this._w=c*u*h+d*f*_;break;case"YZX":this._x=d*u*h+c*f*_,this._y=c*f*h+d*u*_,this._z=c*u*_-d*f*h,this._w=c*u*h-d*f*_;break;case"XZY":this._x=d*u*h-c*f*_,this._y=c*f*h-d*u*_,this._z=c*u*_+d*f*h,this._w=c*u*h+d*f*_;break;default:Ie("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],r=t[8],a=t[1],o=t[5],l=t[9],c=t[2],u=t[6],h=t[10],d=n+o+h;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(u-l)*f,this._y=(r-c)*f,this._z=(a-i)*f}else if(n>o&&n>h){const f=2*Math.sqrt(1+n-o-h);this._w=(u-l)/f,this._x=.25*f,this._y=(i+a)/f,this._z=(r+c)/f}else if(o>h){const f=2*Math.sqrt(1+o-n-h);this._w=(r-c)/f,this._x=(i+a)/f,this._y=.25*f,this._z=(l+u)/f}else{const f=2*Math.sqrt(1+h-n-o);this._w=(a-i)/f,this._x=(r+c)/f,this._y=(l+u)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs($e(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,r=e._z,a=e._w,o=t._x,l=t._y,c=t._z,u=t._w;return this._x=n*u+a*o+i*c-r*l,this._y=i*u+a*l+r*o-n*c,this._z=r*u+a*c+n*l-i*o,this._w=a*u-n*o-i*l-r*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,i=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,i=-i,r=-r,a=-a,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),u=Math.sin(c);l=Math.sin(l*c)/u,t=Math.sin(t*c)/u,this._x=this._x*l+n*t,this._y=this._y*l+i*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+n*t,this._y=this._y*l+i*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const ol=class ol{constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Al.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Al.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,r=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*i-o*n),u=2*(o*t-r*i),h=2*(r*n-a*t);return this.x=t+l*c+a*h-o*u,this.y=n+l*u+o*c-r*h,this.z=i+l*h+r*u-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=$e(this.x,e.x,t.x),this.y=$e(this.y,e.y,t.y),this.z=$e(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=$e(this.x,e,t),this.y=$e(this.y,e,t),this.z=$e(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar($e(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,r=e.z,a=t.x,o=t.y,l=t.z;return this.x=i*l-r*o,this.y=r*a-n*l,this.z=n*o-i*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Kr.copy(this).projectOnVector(e),this.sub(Kr)}reflect(e){return this.sub(Kr.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos($e(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};ol.prototype.isVector3=!0;let C=ol;const Kr=new C,Al=new Sn,ll=class ll{constructor(e,t,n,i,r,a,o,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,r,a,o,l,c)}set(e,t,n,i,r,a,o,l,c){const u=this.elements;return u[0]=e,u[1]=i,u[2]=o,u[3]=t,u[4]=r,u[5]=l,u[6]=n,u[7]=a,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],u=n[4],h=n[7],d=n[2],f=n[5],_=n[8],v=i[0],m=i[3],p=i[6],b=i[1],T=i[4],S=i[7],w=i[2],E=i[5],R=i[8];return r[0]=a*v+o*b+l*w,r[3]=a*m+o*T+l*E,r[6]=a*p+o*S+l*R,r[1]=c*v+u*b+h*w,r[4]=c*m+u*T+h*E,r[7]=c*p+u*S+h*R,r[2]=d*v+f*b+_*w,r[5]=d*m+f*T+_*E,r[8]=d*p+f*S+_*R,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8];return t*a*u-t*o*c-n*r*u+n*o*l+i*r*c-i*a*l}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],h=u*a-o*c,d=o*l-u*r,f=c*r-a*l,_=t*h+n*d+i*f;if(_===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/_;return e[0]=h*v,e[1]=(i*c-u*n)*v,e[2]=(o*n-i*a)*v,e[3]=d*v,e[4]=(u*t-i*l)*v,e[5]=(i*r-o*t)*v,e[6]=f*v,e[7]=(n*l-c*t)*v,e[8]=(a*t-n*r)*v,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,a,o){const l=Math.cos(r),c=Math.sin(r);return this.set(n*l,n*c,-n*(l*a+c*o)+a+e,-i*c,i*l,-i*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return Ki("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Zr.makeScale(e,t)),this}rotate(e){return Ki("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Zr.makeRotation(-e)),this}translate(e,t){return Ki("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Zr.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};ll.prototype.isMatrix3=!0;let He=ll;const Zr=new He,wl=new He().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Rl=new He().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function ld(){const s={enabled:!0,workingColorSpace:ln,spaces:{},convert:function(i,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===ut&&(i.r=Zn(i.r),i.g=Zn(i.g),i.b=Zn(i.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(i.applyMatrix3(this.spaces[r].toXYZ),i.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===ut&&(i.r=Zi(i.r),i.g=Zi(i.g),i.b=Zi(i.b))),i},workingToColorSpace:function(i,r){return this.convert(i,this.workingColorSpace,r)},colorSpaceToWorking:function(i,r){return this.convert(i,r,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===li?Lr:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,r=this.workingColorSpace){return i.fromArray(this.spaces[r].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,r,a){return i.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,r){return Ki("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),s.workingToColorSpace(i,r)},toWorkingColorSpace:function(i,r){return Ki("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),s.colorSpaceToWorking(i,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return s.define({[ln]:{primaries:e,whitePoint:n,transfer:Lr,toXYZ:wl,fromXYZ:Rl,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Ht},outputColorSpaceConfig:{drawingBufferColorSpace:Ht}},[Ht]:{primaries:e,whitePoint:n,transfer:ut,toXYZ:wl,fromXYZ:Rl,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Ht}}}),s}const Qe=ld();function Zn(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function Zi(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}let Pi;class cd{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Pi===void 0&&(Pi=Bs("canvas")),Pi.width=e.width,Pi.height=e.height;const i=Pi.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),n=Pi}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Bs("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let a=0;a<r.length;a++)r[a]=Zn(r[a]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(Zn(t[n]/255)*255):t[n]=Zn(t[n]);return{data:t,width:e.width,height:e.height}}else return Ie("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let ud=0;class Xo{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:ud++}),this.uuid=Mn(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let a=0,o=i.length;a<o;a++)i[a].isDataTexture?r.push($r(i[a].image)):r.push($r(i[a]))}else r=$r(i);n.url=r}return t||(e.images[this.uuid]=n),n}}function $r(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?cd.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(Ie("Texture: Unable to serialize Texture."),{})}let hd=0;const jr=new C;class Gt extends hi{constructor(e=Gt.DEFAULT_IMAGE,t=Gt.DEFAULT_MAPPING,n=Rn,i=Rn,r=Bt,a=Yn,o=pn,l=on,c=Gt.DEFAULT_ANISOTROPY,u=li){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:hd++}),this.uuid=Mn(),this.name="",this.source=new Xo(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new ke(0,0),this.repeat=new ke(1,1),this.center=new ke(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new He,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(jr).x}get height(){return this.source.getSize(jr).y}get depth(){return this.source.getSize(jr).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const n=e[t];if(n===void 0){Ie(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){Ie(`Texture.setValues(): property '${t}' does not exist.`);continue}i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==iu)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case es:e.x=e.x-Math.floor(e.x);break;case Rn:e.x=e.x<0?0:1;break;case Rr:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case es:e.y=e.y-Math.floor(e.y);break;case Rn:e.y=e.y<0?0:1;break;case Rr:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Gt.DEFAULT_IMAGE=null;Gt.DEFAULT_MAPPING=iu;Gt.DEFAULT_ANISOTROPY=1;const cl=class cl{constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,r;const l=e.elements,c=l[0],u=l[4],h=l[8],d=l[1],f=l[5],_=l[9],v=l[2],m=l[6],p=l[10];if(Math.abs(u-d)<.01&&Math.abs(h-v)<.01&&Math.abs(_-m)<.01){if(Math.abs(u+d)<.1&&Math.abs(h+v)<.1&&Math.abs(_+m)<.1&&Math.abs(c+f+p-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const T=(c+1)/2,S=(f+1)/2,w=(p+1)/2,E=(u+d)/4,R=(h+v)/4,x=(_+m)/4;return T>S&&T>w?T<.01?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(T),i=E/n,r=R/n):S>w?S<.01?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(S),n=E/i,r=x/i):w<.01?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(w),n=R/r,i=x/r),this.set(n,i,r,t),this}let b=Math.sqrt((m-_)*(m-_)+(h-v)*(h-v)+(d-u)*(d-u));return Math.abs(b)<.001&&(b=1),this.x=(m-_)/b,this.y=(h-v)/b,this.z=(d-u)/b,this.w=Math.acos((c+f+p-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=$e(this.x,e.x,t.x),this.y=$e(this.y,e.y,t.y),this.z=$e(this.z,e.z,t.z),this.w=$e(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=$e(this.x,e,t),this.y=$e(this.y,e,t),this.z=$e(this.z,e,t),this.w=$e(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar($e(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};cl.prototype.isVector4=!0;let gt=cl;class dd extends hi{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Bt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new gt(0,0,e,t),this.scissorTest=!1,this.viewport=new gt(0,0,e,t),this.textures=[];const i={width:e,height:t,depth:n.depth},r=new Gt(i),a=n.count;for(let o=0;o<a;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){const t={minFilter:Bt,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const i=Object.assign({},e.textures[t].image);this.textures[t].source=new Xo(i)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Ln extends dd{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class pu extends Gt{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Ot,this.minFilter=Ot,this.wrapR=Rn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class fd extends Gt{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Ot,this.minFilter=Ot,this.wrapR=Rn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Fr=class Fr{constructor(e,t,n,i,r,a,o,l,c,u,h,d,f,_,v,m){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,i,r,a,o,l,c,u,h,d,f,_,v,m)}set(e,t,n,i,r,a,o,l,c,u,h,d,f,_,v,m){const p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=i,p[1]=r,p[5]=a,p[9]=o,p[13]=l,p[2]=c,p[6]=u,p[10]=h,p[14]=d,p[3]=f,p[7]=_,p[11]=v,p[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 Fr().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();const t=this.elements,n=e.elements,i=1/Li.setFromMatrixColumn(e,0).length(),r=1/Li.setFromMatrixColumn(e,1).length(),a=1/Li.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,r=e.z,a=Math.cos(n),o=Math.sin(n),l=Math.cos(i),c=Math.sin(i),u=Math.cos(r),h=Math.sin(r);if(e.order==="XYZ"){const d=a*u,f=a*h,_=o*u,v=o*h;t[0]=l*u,t[4]=-l*h,t[8]=c,t[1]=f+_*c,t[5]=d-v*c,t[9]=-o*l,t[2]=v-d*c,t[6]=_+f*c,t[10]=a*l}else if(e.order==="YXZ"){const d=l*u,f=l*h,_=c*u,v=c*h;t[0]=d+v*o,t[4]=_*o-f,t[8]=a*c,t[1]=a*h,t[5]=a*u,t[9]=-o,t[2]=f*o-_,t[6]=v+d*o,t[10]=a*l}else if(e.order==="ZXY"){const d=l*u,f=l*h,_=c*u,v=c*h;t[0]=d-v*o,t[4]=-a*h,t[8]=_+f*o,t[1]=f+_*o,t[5]=a*u,t[9]=v-d*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const d=a*u,f=a*h,_=o*u,v=o*h;t[0]=l*u,t[4]=_*c-f,t[8]=d*c+v,t[1]=l*h,t[5]=v*c+d,t[9]=f*c-_,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const d=a*l,f=a*c,_=o*l,v=o*c;t[0]=l*u,t[4]=v-d*h,t[8]=_*h+f,t[1]=h,t[5]=a*u,t[9]=-o*u,t[2]=-c*u,t[6]=f*h+_,t[10]=d-v*h}else if(e.order==="XZY"){const d=a*l,f=a*c,_=o*l,v=o*c;t[0]=l*u,t[4]=-h,t[8]=c*u,t[1]=d*h+v,t[5]=a*u,t[9]=f*h-_,t[2]=_*h-f,t[6]=o*u,t[10]=v*h+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(pd,e,md)}lookAt(e,t,n){const i=this.elements;return sn.subVectors(e,t),sn.lengthSq()===0&&(sn.z=1),sn.normalize(),ti.crossVectors(n,sn),ti.lengthSq()===0&&(Math.abs(n.z)===1?sn.x+=1e-4:sn.z+=1e-4,sn.normalize(),ti.crossVectors(n,sn)),ti.normalize(),Ws.crossVectors(sn,ti),i[0]=ti.x,i[4]=Ws.x,i[8]=sn.x,i[1]=ti.y,i[5]=Ws.y,i[9]=sn.y,i[2]=ti.z,i[6]=Ws.z,i[10]=sn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,a=n[0],o=n[4],l=n[8],c=n[12],u=n[1],h=n[5],d=n[9],f=n[13],_=n[2],v=n[6],m=n[10],p=n[14],b=n[3],T=n[7],S=n[11],w=n[15],E=i[0],R=i[4],x=i[8],A=i[12],D=i[1],P=i[5],F=i[9],$=i[13],j=i[2],k=i[6],q=i[10],W=i[14],ee=i[3],K=i[7],le=i[11],pe=i[15];return r[0]=a*E+o*D+l*j+c*ee,r[4]=a*R+o*P+l*k+c*K,r[8]=a*x+o*F+l*q+c*le,r[12]=a*A+o*$+l*W+c*pe,r[1]=u*E+h*D+d*j+f*ee,r[5]=u*R+h*P+d*k+f*K,r[9]=u*x+h*F+d*q+f*le,r[13]=u*A+h*$+d*W+f*pe,r[2]=_*E+v*D+m*j+p*ee,r[6]=_*R+v*P+m*k+p*K,r[10]=_*x+v*F+m*q+p*le,r[14]=_*A+v*$+m*W+p*pe,r[3]=b*E+T*D+S*j+w*ee,r[7]=b*R+T*P+S*k+w*K,r[11]=b*x+T*F+S*q+w*le,r[15]=b*A+T*$+S*W+w*pe,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],a=e[1],o=e[5],l=e[9],c=e[13],u=e[2],h=e[6],d=e[10],f=e[14],_=e[3],v=e[7],m=e[11],p=e[15],b=l*f-c*d,T=o*f-c*h,S=o*d-l*h,w=a*f-c*u,E=a*d-l*u,R=a*h-o*u;return t*(v*b-m*T+p*S)-n*(_*b-m*w+p*E)+i*(_*T-v*w+p*R)-r*(_*S-v*E+m*R)}determinantAffine(){const e=this.elements,t=e[0],n=e[4],i=e[8],r=e[1],a=e[5],o=e[9],l=e[2],c=e[6],u=e[10];return t*(a*u-o*c)-n*(r*u-o*l)+i*(r*c-a*l)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],h=e[9],d=e[10],f=e[11],_=e[12],v=e[13],m=e[14],p=e[15],b=t*o-n*a,T=t*l-i*a,S=t*c-r*a,w=n*l-i*o,E=n*c-r*o,R=i*c-r*l,x=u*v-h*_,A=u*m-d*_,D=u*p-f*_,P=h*m-d*v,F=h*p-f*v,$=d*p-f*m,j=b*$-T*F+S*P+w*D-E*A+R*x;if(j===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const k=1/j;return e[0]=(o*$-l*F+c*P)*k,e[1]=(i*F-n*$-r*P)*k,e[2]=(v*R-m*E+p*w)*k,e[3]=(d*E-h*R-f*w)*k,e[4]=(l*D-a*$-c*A)*k,e[5]=(t*$-i*D+r*A)*k,e[6]=(m*S-_*R-p*T)*k,e[7]=(u*R-d*S+f*T)*k,e[8]=(a*F-o*D+c*x)*k,e[9]=(n*D-t*F-r*x)*k,e[10]=(_*E-v*S+p*b)*k,e[11]=(h*S-u*E-f*b)*k,e[12]=(o*A-a*P-l*x)*k,e[13]=(t*P-n*A+i*x)*k,e[14]=(v*T-_*w-m*b)*k,e[15]=(u*w-h*T+d*b)*k,this}scale(e){const t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),r=1-n,a=e.x,o=e.y,l=e.z,c=r*a,u=r*o;return this.set(c*a+n,c*o-i*l,c*l+i*o,0,c*o+i*l,u*o+n,u*l-i*a,0,c*l-i*o,u*l+i*a,r*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,a){return this.set(1,n,r,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,r=t._x,a=t._y,o=t._z,l=t._w,c=r+r,u=a+a,h=o+o,d=r*c,f=r*u,_=r*h,v=a*u,m=a*h,p=o*h,b=l*c,T=l*u,S=l*h,w=n.x,E=n.y,R=n.z;return i[0]=(1-(v+p))*w,i[1]=(f+S)*w,i[2]=(_-T)*w,i[3]=0,i[4]=(f-S)*E,i[5]=(1-(d+p))*E,i[6]=(m+b)*E,i[7]=0,i[8]=(_+T)*R,i[9]=(m-b)*R,i[10]=(1-(d+v))*R,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];const r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let a=Li.set(i[0],i[1],i[2]).length();const o=Li.set(i[4],i[5],i[6]).length(),l=Li.set(i[8],i[9],i[10]).length();r<0&&(a=-a),mn.copy(this);const c=1/a,u=1/o,h=1/l;return mn.elements[0]*=c,mn.elements[1]*=c,mn.elements[2]*=c,mn.elements[4]*=u,mn.elements[5]*=u,mn.elements[6]*=u,mn.elements[8]*=h,mn.elements[9]*=h,mn.elements[10]*=h,t.setFromRotationMatrix(mn),n.x=a,n.y=o,n.z=l,this}makePerspective(e,t,n,i,r,a,o=Cn,l=!1){const c=this.elements,u=2*r/(t-e),h=2*r/(n-i),d=(t+e)/(t-e),f=(n+i)/(n-i);let _,v;if(l)_=r/(a-r),v=a*r/(a-r);else if(o===Cn)_=-(a+r)/(a-r),v=-2*a*r/(a-r);else if(o===Os)_=-a/(a-r),v=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=u,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=h,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=_,c[14]=v,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,r,a,o=Cn,l=!1){const c=this.elements,u=2/(t-e),h=2/(n-i),d=-(t+e)/(t-e),f=-(n+i)/(n-i);let _,v;if(l)_=1/(a-r),v=a/(a-r);else if(o===Cn)_=-2/(a-r),v=-(a+r)/(a-r);else if(o===Os)_=-1/(a-r),v=-r/(a-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=u,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=h,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=_,c[14]=v,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}};Fr.prototype.isMatrix4=!0;let We=Fr;const Li=new C,mn=new We,pd=new C(0,0,0),md=new C(1,1,1),ti=new C,Ws=new C,sn=new C,Cl=new We,Pl=new Sn;class ui{constructor(e=0,t=0,n=0,i=ui.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,r=i[0],a=i[4],o=i[8],l=i[1],c=i[5],u=i[9],h=i[2],d=i[6],f=i[10];switch(t){case"XYZ":this._y=Math.asin($e(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-$e(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin($e(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-$e(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin($e(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-$e(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-u,f),this._y=0);break;default:Ie("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Cl.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Cl,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Pl.setFromEuler(this),this.setFromQuaternion(Pl,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}ui.DEFAULT_ORDER="XYZ";class Yo{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let gd=0;const Ll=new C,Ii=new Sn,kn=new We,Xs=new C,gs=new C,_d=new C,xd=new Sn,Il=new C(1,0,0),Dl=new C(0,1,0),Nl=new C(0,0,1),Ul={type:"added"},vd={type:"removed"},Di={type:"childadded",child:null},Jr={type:"childremoved",child:null};class At extends hi{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:gd++}),this.uuid=Mn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=At.DEFAULT_UP.clone();const e=new C,t=new ui,n=new Sn,i=new C(1,1,1);function r(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new We},normalMatrix:{value:new He}}),this.matrix=new We,this.matrixWorld=new We,this.matrixAutoUpdate=At.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=At.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Yo,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Ii.setFromAxisAngle(e,t),this.quaternion.multiply(Ii),this}rotateOnWorldAxis(e,t){return Ii.setFromAxisAngle(e,t),this.quaternion.premultiply(Ii),this}rotateX(e){return this.rotateOnAxis(Il,e)}rotateY(e){return this.rotateOnAxis(Dl,e)}rotateZ(e){return this.rotateOnAxis(Nl,e)}translateOnAxis(e,t){return Ll.copy(e).applyQuaternion(this.quaternion),this.position.add(Ll.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Il,e)}translateY(e){return this.translateOnAxis(Dl,e)}translateZ(e){return this.translateOnAxis(Nl,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(kn.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Xs.copy(e):Xs.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),gs.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?kn.lookAt(gs,Xs,this.up):kn.lookAt(Xs,gs,this.up),this.quaternion.setFromRotationMatrix(kn),i&&(kn.extractRotation(i.matrixWorld),Ii.setFromRotationMatrix(kn),this.quaternion.premultiply(Ii.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(ze("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Ul),Di.child=e,this.dispatchEvent(Di),Di.child=null):ze("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(vd),Jr.child=e,this.dispatchEvent(Jr),Jr.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),kn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),kn.multiply(e.parent.matrixWorld)),e.applyMatrix4(kn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Ul),Di.child=e,this.dispatchEvent(Di),Di.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const i=this.children;for(let r=0,a=i.length;r<a;r++)i[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(gs,e,_d),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(gs,xd,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const e=this.pivot;if(e!==null){const t=e.x,n=e.y,i=e.z,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*i,r[13]+=n-r[1]*t-r[5]*n-r[9]*i,r[14]+=i-r[2]*t-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){const i=this.parent;if(e===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),t===!0){const r=this.children;for(let a=0,o=r.length;a<o;a++)r[a].updateWorldMatrix(!1,!0,n)}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),this.static!==!1&&(i.static=this.static),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null&&(i.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(i.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function r(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c<u;c++){const h=l[c];r(e.shapes,h)}else r(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(r(e.materials,this.material[l]));i.material=o}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];i.animations.push(r(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),u=a(e.images),h=a(e.shapes),d=a(e.skeletons),f=a(e.animations),_=a(e.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),u.length>0&&(n.images=u),h.length>0&&(n.shapes=h),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),_.length>0&&(n.nodes=_)}return n.object=i,n;function a(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const i=e.children[n];this.add(i.clone())}return this}}At.DEFAULT_UP=new C(0,1,0);At.DEFAULT_MATRIX_AUTO_UPDATE=!0;At.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Si extends At{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Md={type:"move"};class Qr{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Si,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 Si,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new C,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new C),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Si,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new C,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new C,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let i=null,r=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const v of e.hand.values()){const m=t.getJointPose(v,n),p=this._getHandJoint(c,v);m!==null&&(p.matrix.fromArray(m.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=m.radius),p.visible=m!==null}const u=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],d=u.position.distanceTo(h.position),f=.02,_=.005;c.inputState.pinching&&d>f+_?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=f-_&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,l.eventsEnabled&&l.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null&&(i=r),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Md)))}return o!==null&&(o.visible=i!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Si;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const mu={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},ni={h:0,s:0,l:0},Ys={h:0,s:0,l:0};function ea(s,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?s+(e-s)*6*t:t<1/2?e:t<2/3?s+(e-s)*6*(2/3-t):s}class Ue{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ht){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Qe.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=Qe.workingColorSpace){return this.r=e,this.g=t,this.b=n,Qe.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=Qe.workingColorSpace){if(e=Wo(e,1),t=$e(t,0,1),n=$e(n,0,1),t===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+t):n+t-n*t,a=2*n-r;this.r=ea(a,r,e+1/3),this.g=ea(a,r,e),this.b=ea(a,r,e-1/3)}return Qe.colorSpaceToWorking(this,i),this}setStyle(e,t=Ht){function n(r){r!==void 0&&parseFloat(r)<1&&Ie("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Ie("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=i[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);Ie("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Ht){const n=mu[e.toLowerCase()];return n!==void 0?this.setHex(n,t):Ie("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Zn(e.r),this.g=Zn(e.g),this.b=Zn(e.b),this}copyLinearToSRGB(e){return this.r=Zi(e.r),this.g=Zi(e.g),this.b=Zi(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ht){return Qe.workingToColorSpace($t.copy(this),e),Math.round($e($t.r*255,0,255))*65536+Math.round($e($t.g*255,0,255))*256+Math.round($e($t.b*255,0,255))}getHexString(e=Ht){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Qe.workingColorSpace){Qe.workingToColorSpace($t.copy(this),t);const n=$t.r,i=$t.g,r=$t.b,a=Math.max(n,i,r),o=Math.min(n,i,r);let l,c;const u=(o+a)/2;if(o===a)l=0,c=0;else{const h=a-o;switch(c=u<=.5?h/(a+o):h/(2-a-o),a){case n:l=(i-r)/h+(i<r?6:0);break;case i:l=(r-n)/h+2;break;case r:l=(n-i)/h+4;break}l/=6}return e.h=l,e.s=c,e.l=u,e}getRGB(e,t=Qe.workingColorSpace){return Qe.workingToColorSpace($t.copy(this),t),e.r=$t.r,e.g=$t.g,e.b=$t.b,e}getStyle(e=Ht){Qe.workingToColorSpace($t.copy(this),e);const t=$t.r,n=$t.g,i=$t.b;return e!==Ht?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(ni),this.setHSL(ni.h+e,ni.s+t,ni.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(ni),e.getHSL(Ys);const n=Ls(ni.h,Ys.h,t),i=Ls(ni.s,Ys.s,t),r=Ls(ni.l,Ys.l,t);return this.setHSL(n,i,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*i,this.g=r[1]*t+r[4]*n+r[7]*i,this.b=r[2]*t+r[5]*n+r[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const $t=new Ue;Ue.NAMES=mu;class Sd extends At{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new ui,this.environmentIntensity=1,this.environmentRotation=new ui,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const gn=new C,zn=new C,ta=new C,Vn=new C,Ni=new C,Ui=new C,Fl=new C,na=new C,ia=new C,sa=new C,ra=new gt,aa=new gt,oa=new gt;class vn{constructor(e=new C,t=new C,n=new C){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),gn.subVectors(e,t),i.cross(gn);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){gn.subVectors(i,t),zn.subVectors(n,t),ta.subVectors(e,t);const a=gn.dot(gn),o=gn.dot(zn),l=gn.dot(ta),c=zn.dot(zn),u=zn.dot(ta),h=a*c-o*o;if(h===0)return r.set(0,0,0),null;const d=1/h,f=(c*l-o*u)*d,_=(a*u-o*l)*d;return r.set(1-f-_,_,f)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,Vn)===null?!1:Vn.x>=0&&Vn.y>=0&&Vn.x+Vn.y<=1}static getInterpolation(e,t,n,i,r,a,o,l){return this.getBarycoord(e,t,n,i,Vn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,Vn.x),l.addScaledVector(a,Vn.y),l.addScaledVector(o,Vn.z),l)}static getInterpolatedAttribute(e,t,n,i,r,a){return ra.setScalar(0),aa.setScalar(0),oa.setScalar(0),ra.fromBufferAttribute(e,t),aa.fromBufferAttribute(e,n),oa.fromBufferAttribute(e,i),a.setScalar(0),a.addScaledVector(ra,r.x),a.addScaledVector(aa,r.y),a.addScaledVector(oa,r.z),a}static isFrontFacing(e,t,n,i){return gn.subVectors(n,t),zn.subVectors(e,t),gn.cross(zn).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return gn.subVectors(this.c,this.b),zn.subVectors(this.a,this.b),gn.cross(zn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return vn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return vn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return vn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return vn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return vn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,r=this.c;let a,o;Ni.subVectors(i,n),Ui.subVectors(r,n),na.subVectors(e,n);const l=Ni.dot(na),c=Ui.dot(na);if(l<=0&&c<=0)return t.copy(n);ia.subVectors(e,i);const u=Ni.dot(ia),h=Ui.dot(ia);if(u>=0&&h<=u)return t.copy(i);const d=l*h-u*c;if(d<=0&&l>=0&&u<=0)return a=l/(l-u),t.copy(n).addScaledVector(Ni,a);sa.subVectors(e,r);const f=Ni.dot(sa),_=Ui.dot(sa);if(_>=0&&f<=_)return t.copy(r);const v=f*c-l*_;if(v<=0&&c>=0&&_<=0)return o=c/(c-_),t.copy(n).addScaledVector(Ui,o);const m=u*_-f*h;if(m<=0&&h-u>=0&&f-_>=0)return Fl.subVectors(r,i),o=(h-u)/(h-u+(f-_)),t.copy(i).addScaledVector(Fl,o);const p=1/(m+v+d);return a=v*p,o=d*p,t.copy(n).addScaledVector(Ni,a).addScaledVector(Ui,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Yt{constructor(e=new C(1/0,1/0,1/0),t=new C(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(_n.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(_n.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=_n.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,_n):_n.fromBufferAttribute(r,a),_n.applyMatrix4(e.matrixWorld),this.expandByPoint(_n);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),qs.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),qs.copy(n.boundingBox)),qs.applyMatrix4(e.matrixWorld),this.union(qs)}const i=e.children;for(let r=0,a=i.length;r<a;r++)this.expandByObject(i[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,_n),_n.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(_s),Ks.subVectors(this.max,_s),Fi.subVectors(e.a,_s),Oi.subVectors(e.b,_s),Bi.subVectors(e.c,_s),ii.subVectors(Oi,Fi),si.subVectors(Bi,Oi),di.subVectors(Fi,Bi);let t=[0,-ii.z,ii.y,0,-si.z,si.y,0,-di.z,di.y,ii.z,0,-ii.x,si.z,0,-si.x,di.z,0,-di.x,-ii.y,ii.x,0,-si.y,si.x,0,-di.y,di.x,0];return!la(t,Fi,Oi,Bi,Ks)||(t=[1,0,0,0,1,0,0,0,1],!la(t,Fi,Oi,Bi,Ks))?!1:(Zs.crossVectors(ii,si),t=[Zs.x,Zs.y,Zs.z],la(t,Fi,Oi,Bi,Ks))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,_n).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(_n).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Hn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Hn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Hn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Hn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Hn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Hn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Hn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Hn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Hn),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const Hn=[new C,new C,new C,new C,new C,new C,new C,new C],_n=new C,qs=new Yt,Fi=new C,Oi=new C,Bi=new C,ii=new C,si=new C,di=new C,_s=new C,Ks=new C,Zs=new C,fi=new C;function la(s,e,t,n,i){for(let r=0,a=s.length-3;r<=a;r+=3){fi.fromArray(s,r);const o=i.x*Math.abs(fi.x)+i.y*Math.abs(fi.y)+i.z*Math.abs(fi.z),l=e.dot(fi),c=t.dot(fi),u=n.dot(fi);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}const Dt=new C,$s=new ke;let yd=0;class Nt extends hi{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:yd++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=bo,this.updateRanges=[],this.gpuType=fn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)$s.fromBufferAttribute(this,t),$s.applyMatrix3(e),this.setXY(t,$s.x,$s.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Dt.fromBufferAttribute(this,t),Dt.applyMatrix3(e),this.setXYZ(t,Dt.x,Dt.y,Dt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Dt.fromBufferAttribute(this,t),Dt.applyMatrix4(e),this.setXYZ(t,Dt.x,Dt.y,Dt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Dt.fromBufferAttribute(this,t),Dt.applyNormalMatrix(e),this.setXYZ(t,Dt.x,Dt.y,Dt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Dt.fromBufferAttribute(this,t),Dt.transformDirection(e),this.setXYZ(t,Dt.x,Dt.y,Dt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=xn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=ht(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=xn(t,this.array)),t}setX(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=xn(t,this.array)),t}setY(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=xn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=xn(t,this.array)),t}setW(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array),i=ht(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array),i=ht(i,this.array),r=ht(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==bo&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class gu extends Nt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class _u extends Nt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Lt extends Nt{constructor(e,t,n){super(new Float32Array(e),t,n)}}const bd=new Yt,xs=new C,ca=new C;class Fn{constructor(e=new C,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):bd.setFromPoints(e).getCenter(n);let i=0;for(let r=0,a=e.length;r<a;r++)i=Math.max(i,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;xs.subVectors(e,this.center);const t=xs.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(xs,i/n),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(ca.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(xs.copy(e.center).add(ca)),this.expandByPoint(xs.copy(e.center).sub(ca))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let Ed=0;const hn=new We,ua=new At,ki=new C,rn=new Yt,vs=new Yt,Vt=new C;class Wt extends hi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Ed++}),this.uuid=Mn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Vh(e)?_u:gu)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const r=new He().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return hn.makeRotationFromQuaternion(e),this.applyMatrix4(hn),this}rotateX(e){return hn.makeRotationX(e),this.applyMatrix4(hn),this}rotateY(e){return hn.makeRotationY(e),this.applyMatrix4(hn),this}rotateZ(e){return hn.makeRotationZ(e),this.applyMatrix4(hn),this}translate(e,t,n){return hn.makeTranslation(e,t,n),this.applyMatrix4(hn),this}scale(e,t,n){return hn.makeScale(e,t,n),this.applyMatrix4(hn),this}lookAt(e){return ua.lookAt(e),ua.updateMatrix(),this.applyMatrix4(ua.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ki).negate(),this.translate(ki.x,ki.y,ki.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let i=0,r=e.length;i<r;i++){const a=e[i];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Lt(n,3))}else{const n=Math.min(e.length,t.count);for(let i=0;i<n;i++){const r=e[i];t.setXYZ(i,r.x,r.y,r.z||0)}e.length>t.count&&Ie("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Yt);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ze("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new C(-1/0,-1/0,-1/0),new C(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){const r=t[n];rn.setFromBufferAttribute(r),this.morphTargetsRelative?(Vt.addVectors(this.boundingBox.min,rn.min),this.boundingBox.expandByPoint(Vt),Vt.addVectors(this.boundingBox.max,rn.max),this.boundingBox.expandByPoint(Vt)):(this.boundingBox.expandByPoint(rn.min),this.boundingBox.expandByPoint(rn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&ze('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 Fn);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ze("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new C,1/0);return}if(e){const n=this.boundingSphere.center;if(rn.setFromBufferAttribute(e),t)for(let r=0,a=t.length;r<a;r++){const o=t[r];vs.setFromBufferAttribute(o),this.morphTargetsRelative?(Vt.addVectors(rn.min,vs.min),rn.expandByPoint(Vt),Vt.addVectors(rn.max,vs.max),rn.expandByPoint(Vt)):(rn.expandByPoint(vs.min),rn.expandByPoint(vs.max))}rn.getCenter(n);let i=0;for(let r=0,a=e.count;r<a;r++)Vt.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(Vt));if(t)for(let r=0,a=t.length;r<a;r++){const o=t[r],l=this.morphTargetsRelative;for(let c=0,u=o.count;c<u;c++)Vt.fromBufferAttribute(o,c),l&&(ki.fromBufferAttribute(e,c),Vt.add(ki)),i=Math.max(i,n.distanceToSquared(Vt))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&ze('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){ze("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,i=t.normal,r=t.uv;let a=this.getAttribute("tangent");(a===void 0||a.count!==n.count)&&(a=new Nt(new Float32Array(4*n.count),4),this.setAttribute("tangent",a));const o=[],l=[];for(let x=0;x<n.count;x++)o[x]=new C,l[x]=new C;const c=new C,u=new C,h=new C,d=new ke,f=new ke,_=new ke,v=new C,m=new C;function p(x,A,D){c.fromBufferAttribute(n,x),u.fromBufferAttribute(n,A),h.fromBufferAttribute(n,D),d.fromBufferAttribute(r,x),f.fromBufferAttribute(r,A),_.fromBufferAttribute(r,D),u.sub(c),h.sub(c),f.sub(d),_.sub(d);const P=1/(f.x*_.y-_.x*f.y);isFinite(P)&&(v.copy(u).multiplyScalar(_.y).addScaledVector(h,-f.y).multiplyScalar(P),m.copy(h).multiplyScalar(f.x).addScaledVector(u,-_.x).multiplyScalar(P),o[x].add(v),o[A].add(v),o[D].add(v),l[x].add(m),l[A].add(m),l[D].add(m))}let b=this.groups;b.length===0&&(b=[{start:0,count:e.count}]);for(let x=0,A=b.length;x<A;++x){const D=b[x],P=D.start,F=D.count;for(let $=P,j=P+F;$<j;$+=3)p(e.getX($+0),e.getX($+1),e.getX($+2))}const T=new C,S=new C,w=new C,E=new C;function R(x){w.fromBufferAttribute(i,x),E.copy(w);const A=o[x];T.copy(A),T.sub(w.multiplyScalar(w.dot(A))).normalize(),S.crossVectors(E,A);const P=S.dot(l[x])<0?-1:1;a.setXYZW(x,T.x,T.y,T.z,P)}for(let x=0,A=b.length;x<A;++x){const D=b[x],P=D.start,F=D.count;for(let $=P,j=P+F;$<j;$+=3)R(e.getX($+0)),R(e.getX($+1)),R(e.getX($+2))}this._transformed=!0}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new Nt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);const i=new C,r=new C,a=new C,o=new C,l=new C,c=new C,u=new C,h=new C;if(e)for(let d=0,f=e.count;d<f;d+=3){const _=e.getX(d+0),v=e.getX(d+1),m=e.getX(d+2);i.fromBufferAttribute(t,_),r.fromBufferAttribute(t,v),a.fromBufferAttribute(t,m),u.subVectors(a,r),h.subVectors(i,r),u.cross(h),o.fromBufferAttribute(n,_),l.fromBufferAttribute(n,v),c.fromBufferAttribute(n,m),o.add(u),l.add(u),c.add(u),n.setXYZ(_,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,f=t.count;d<f;d+=3)i.fromBufferAttribute(t,d+0),r.fromBufferAttribute(t,d+1),a.fromBufferAttribute(t,d+2),u.subVectors(a,r),h.subVectors(i,r),u.cross(h),n.setXYZ(d+0,u.x,u.y,u.z),n.setXYZ(d+1,u.x,u.y,u.z),n.setXYZ(d+2,u.x,u.y,u.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Vt.fromBufferAttribute(e,t),Vt.normalize(),e.setXYZ(t,Vt.x,Vt.y,Vt.z)}toNonIndexed(){function e(o,l){const c=o.array,u=o.itemSize,h=o.normalized,d=new c.constructor(l.length*u);let f=0,_=0;for(let v=0,m=l.length;v<m;v++){o.isInterleavedBufferAttribute?f=l[v]*o.data.stride+o.offset:f=l[v]*u;for(let p=0;p<u;p++)d[_++]=c[f++]}return new Nt(d,u,h)}if(this.index===null)return Ie("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Wt,n=this.index.array,i=this.attributes;for(const o in i){const l=i[o],c=e(l,n);t.setAttribute(o,c)}const r=this.morphAttributes;for(const o in r){const l=[],c=r[o];for(let u=0,h=c.length;u<h;u++){const d=c[u],f=e(d,n);l.push(f)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const l in n){const c=n[l];e.data.attributes[l]=c.toJSON(e.data)}const i={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let h=0,d=c.length;h<d;h++){const f=c[h];u.push(f.toJSON(e.data))}u.length>0&&(i[l]=u,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const i=e.attributes;for(const c in i){const u=i[c];this.setAttribute(c,u.clone(t))}const r=e.morphAttributes;for(const c in r){const u=[],h=r[c];for(let d=0,f=h.length;d<f;d++)u.push(h[d].clone(t));this.morphAttributes[c]=u}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,u=a.length;c<u;c++){const h=a[c];this.addGroup(h.start,h.count,h.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Td{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=bo,this.updateRanges=[],this.version=0,this.uuid=Mn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Mn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Mn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const jt=new C;class qo{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)jt.fromBufferAttribute(this,t),jt.applyMatrix4(e),this.setXYZ(t,jt.x,jt.y,jt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)jt.fromBufferAttribute(this,t),jt.applyNormalMatrix(e),this.setXYZ(t,jt.x,jt.y,jt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)jt.fromBufferAttribute(this,t),jt.transformDirection(e),this.setXYZ(t,jt.x,jt.y,jt.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=xn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=ht(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=xn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=xn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=xn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=xn(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array),i=ht(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array),i=ht(i,this.array),r=ht(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(e===void 0){Ir("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return new Nt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new qo(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){Ir("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}let Ad=0;class In extends hi{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Ad++}),this.uuid=Mn(),this.name="",this.type="Material",this.blending=qi,this.side=Dn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Ua,this.blendDst=Fa,this.blendEquation=xi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ue(0,0,0),this.blendAlpha=0,this.depthFunc=Ji,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=yl,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ci,this.stencilZFail=Ci,this.stencilZPass=Ci,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){Ie(`Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){Ie(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector2&&n&&n.isVector2||i&&i.isEuler&&n&&n.isEuler||i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==qi&&(n.blending=this.blending),this.side!==Dn&&(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!==Ua&&(n.blendSrc=this.blendSrc),this.blendDst!==Fa&&(n.blendDst=this.blendDst),this.blendEquation!==xi&&(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!==Ji&&(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!==yl&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ci&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Ci&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Ci&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(r){const a=[];for(const o in r){const l=r[o];delete l.metadata,a.push(l)}return a}if(t){const r=i(e.textures),a=i(e.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new Ue().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let n=e.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new ke().fromArray(n)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new ke().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const i=t.length;n=new Array(i);for(let r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}const Gn=new C,ha=new C,js=new C,ri=new C,da=new C,Js=new C,fa=new C;class rs{constructor(e=new C,t=new C(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Gn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Gn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Gn.copy(this.origin).addScaledVector(this.direction,t),Gn.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){ha.copy(e).add(t).multiplyScalar(.5),js.copy(t).sub(e).normalize(),ri.copy(this.origin).sub(ha);const r=e.distanceTo(t)*.5,a=-this.direction.dot(js),o=ri.dot(this.direction),l=-ri.dot(js),c=ri.lengthSq(),u=Math.abs(1-a*a);let h,d,f,_;if(u>0)if(h=a*l-o,d=a*o-l,_=r*u,h>=0)if(d>=-_)if(d<=_){const v=1/u;h*=v,d*=v,f=h*(h+a*d+2*o)+d*(a*h+d+2*l)+c}else d=r,h=Math.max(0,-(a*d+o)),f=-h*h+d*(d+2*l)+c;else d=-r,h=Math.max(0,-(a*d+o)),f=-h*h+d*(d+2*l)+c;else d<=-_?(h=Math.max(0,-(-a*r+o)),d=h>0?-r:Math.min(Math.max(-r,-l),r),f=-h*h+d*(d+2*l)+c):d<=_?(h=0,d=Math.min(Math.max(-r,-l),r),f=d*(d+2*l)+c):(h=Math.max(0,-(a*r+o)),d=h>0?r:Math.min(Math.max(-r,-l),r),f=-h*h+d*(d+2*l)+c);else d=a>0?-r:r,h=Math.max(0,-(a*d+o)),f=-h*h+d*(d+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(ha).addScaledVector(js,d),f}intersectSphere(e,t){Gn.subVectors(e.center,this.origin);const n=Gn.dot(this.direction),i=Gn.dot(Gn)-n*n,r=e.radius*e.radius;if(i>r)return null;const a=Math.sqrt(r-i),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,a,o,l;const c=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,i=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,i=(e.min.x-d.x)*c),u>=0?(r=(e.min.y-d.y)*u,a=(e.max.y-d.y)*u):(r=(e.max.y-d.y)*u,a=(e.min.y-d.y)*u),n>a||r>i||((r>n||isNaN(n))&&(n=r),(a<i||isNaN(i))&&(i=a),h>=0?(o=(e.min.z-d.z)*h,l=(e.max.z-d.z)*h):(o=(e.max.z-d.z)*h,l=(e.min.z-d.z)*h),n>l||o>i)||((o>n||n!==n)&&(n=o),(l<i||i!==i)&&(i=l),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,Gn)!==null}intersectTriangle(e,t,n,i,r){da.subVectors(t,e),Js.subVectors(n,e),fa.crossVectors(da,Js);let a=this.direction.dot(fa),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;ri.subVectors(this.origin,e);const l=o*this.direction.dot(Js.crossVectors(ri,Js));if(l<0)return null;const c=o*this.direction.dot(da.cross(ri));if(c<0||l+c>a)return null;const u=-o*ri.dot(fa);return u<0?null:this.at(u/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class yi extends In{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ue(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ui,this.combine=Zc,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Ol=new We,pi=new rs,Qs=new Fn,Bl=new C,er=new C,tr=new C,nr=new C,pa=new C,ir=new C,kl=new C,sr=new C;class bt extends At{constructor(e=new Wt,t=new yi){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){const n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(r&&o){ir.set(0,0,0);for(let l=0,c=r.length;l<c;l++){const u=o[l],h=r[l];u!==0&&(pa.fromBufferAttribute(h,e),a?ir.addScaledVector(pa,u):ir.addScaledVector(pa.sub(t),u))}t.add(ir)}return t}raycast(e,t){const n=this.geometry,i=this.material,r=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Qs.copy(n.boundingSphere),Qs.applyMatrix4(r),pi.copy(e.ray).recast(e.near),!(Qs.containsPoint(pi.origin)===!1&&(pi.intersectSphere(Qs,Bl)===null||pi.origin.distanceToSquared(Bl)>(e.far-e.near)**2))&&(Ol.copy(r).invert(),pi.copy(e.ray).applyMatrix4(Ol),!(n.boundingBox!==null&&pi.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,pi)))}_computeIntersections(e,t,n){let i;const r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=r.attributes.uv,u=r.attributes.uv1,h=r.attributes.normal,d=r.groups,f=r.drawRange;if(o!==null)if(Array.isArray(a))for(let _=0,v=d.length;_<v;_++){const m=d[_],p=a[m.materialIndex],b=Math.max(m.start,f.start),T=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let S=b,w=T;S<w;S+=3){const E=o.getX(S),R=o.getX(S+1),x=o.getX(S+2);i=rr(this,p,e,n,c,u,h,E,R,x),i&&(i.faceIndex=Math.floor(S/3),i.face.materialIndex=m.materialIndex,t.push(i))}}else{const _=Math.max(0,f.start),v=Math.min(o.count,f.start+f.count);for(let m=_,p=v;m<p;m+=3){const b=o.getX(m),T=o.getX(m+1),S=o.getX(m+2);i=rr(this,a,e,n,c,u,h,b,T,S),i&&(i.faceIndex=Math.floor(m/3),t.push(i))}}else if(l!==void 0)if(Array.isArray(a))for(let _=0,v=d.length;_<v;_++){const m=d[_],p=a[m.materialIndex],b=Math.max(m.start,f.start),T=Math.min(l.count,Math.min(m.start+m.count,f.start+f.count));for(let S=b,w=T;S<w;S+=3){const E=S,R=S+1,x=S+2;i=rr(this,p,e,n,c,u,h,E,R,x),i&&(i.faceIndex=Math.floor(S/3),i.face.materialIndex=m.materialIndex,t.push(i))}}else{const _=Math.max(0,f.start),v=Math.min(l.count,f.start+f.count);for(let m=_,p=v;m<p;m+=3){const b=m,T=m+1,S=m+2;i=rr(this,a,e,n,c,u,h,b,T,S),i&&(i.faceIndex=Math.floor(m/3),t.push(i))}}}}function wd(s,e,t,n,i,r,a,o){let l;if(e.side===tn?l=n.intersectTriangle(a,r,i,!0,o):l=n.intersectTriangle(i,r,a,e.side===Dn,o),l===null)return null;sr.copy(o),sr.applyMatrix4(s.matrixWorld);const c=t.ray.origin.distanceTo(sr);return c<t.near||c>t.far?null:{distance:c,point:sr.clone(),object:s}}function rr(s,e,t,n,i,r,a,o,l,c){s.getVertexPosition(o,er),s.getVertexPosition(l,tr),s.getVertexPosition(c,nr);const u=wd(s,e,t,n,er,tr,nr,kl);if(u){const h=new C;vn.getBarycoord(kl,er,tr,nr,h),i&&(u.uv=vn.getInterpolatedAttribute(i,o,l,c,h,new ke)),r&&(u.uv1=vn.getInterpolatedAttribute(r,o,l,c,h,new ke)),a&&(u.normal=vn.getInterpolatedAttribute(a,o,l,c,h,new C),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));const d={a:o,b:l,c,normal:new C,materialIndex:0};vn.getNormal(er,tr,nr,d.normal),u.face=d,u.barycoord=h}return u}const Ms=new gt,zl=new gt,Vl=new gt,Rd=new gt,Hl=new We,ar=new C,ma=new Fn,Gl=new We,ga=new rs;class Cd extends bt{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=_l,this.bindMatrix=new We,this.bindMatrixInverse=new We,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Yt),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,ar),this.boundingBox.expandByPoint(ar)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Fn),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,ar),this.boundingSphere.expandByPoint(ar)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ma.copy(this.boundingSphere),ma.applyMatrix4(i),e.ray.intersectsSphere(ma)!==!1&&(Gl.copy(i).invert(),ga.copy(e.ray).applyMatrix4(Gl),!(this.boundingBox!==null&&ga.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,ga)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new gt,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);const r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===_l?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===Ph?this.bindMatrixInverse.copy(this.bindMatrix).invert():Ie("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,i=this.geometry;zl.fromBufferAttribute(i.attributes.skinIndex,e),Vl.fromBufferAttribute(i.attributes.skinWeight,e),t.isVector4?(Ms.copy(t),t.set(0,0,0,0)):(Ms.set(...t,1),t.set(0,0,0)),Ms.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){const a=Vl.getComponent(r);if(a!==0){const o=zl.getComponent(r);Hl.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(Rd.copy(Ms).applyMatrix4(Hl),a)}}return t.isVector4&&(t.w=Ms.w),t.applyMatrix4(this.bindMatrixInverse)}}class xu extends At{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Ko extends Gt{constructor(e=null,t=1,n=1,i,r,a,o,l,c=Ot,u=Ot,h,d){super(null,a,o,l,c,u,i,r,h,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Wl=new We,Pd=new We;class Zo{constructor(e=[],t=[]){this.uuid=Mn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){Ie("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new We)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new We;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,a=e.length;r<a;r++){const o=e[r]?e[r].matrixWorld:Pd;Wl.multiplyMatrices(o,t[r]),Wl.toArray(n,r*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new Zo(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new Ko(t,e,e,pn,fn);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const i=this.bones[t];if(i.name===e)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){const r=e.bones[n];let a=t[r];a===void 0&&(Ie("Skeleton: No bone found with UUID:",r),a=new xu),this.bones.push(a),this.boneInverses.push(new We().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){const a=t[i];e.bones.push(a.uuid);const o=n[i];e.boneInverses.push(o.toArray())}return e}}class Eo extends Nt{constructor(e,t,n,i=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const zi=new We,Xl=new We,or=[],Yl=new Yt,Ld=new We,Ss=new bt,ys=new Fn;class Id extends bt{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Eo(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,Ld)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Yt),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,zi),Yl.copy(e.boundingBox).applyMatrix4(zi),this.boundingBox.union(Yl)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Fn),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,zi),ys.copy(e.boundingSphere).applyMatrix4(zi),this.boundingSphere.union(ys)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){return this.instanceColor===null?t.setRGB(1,1,1):t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,a=e*r+1;for(let o=0;o<n.length;o++)n[o]=i[a+o]}raycast(e,t){const n=this.matrixWorld,i=this.count;if(Ss.geometry=this.geometry,Ss.material=this.material,Ss.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ys.copy(this.boundingSphere),ys.applyMatrix4(n),e.ray.intersectsSphere(ys)!==!1))for(let r=0;r<i;r++){this.getMatrixAt(r,zi),Xl.multiplyMatrices(n,zi),Ss.matrixWorld=Xl,Ss.raycast(e,or);for(let a=0,o=or.length;a<o;a++){const l=or[a];l.instanceId=r,l.object=this,t.push(l)}or.length=0}}setColorAt(e,t){return this.instanceColor===null&&(this.instanceColor=new Eo(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){const n=t.morphTargetInfluences,i=n.length+1;this.morphTexture===null&&(this.morphTexture=new Ko(new Float32Array(i*this.count),i,this.count,Bo,fn));const r=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=i*e;return r[l]=o,r.set(n,l+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const _a=new C,Dd=new C,Nd=new He;class Xn{constructor(e=new C(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=_a.subVectors(n,t).cross(Dd.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){const i=e.delta(_a),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/r;return n===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(i,a)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||Nd.getNormalMatrix(e),i=this.coplanarPoint(_a).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const mi=new Fn,Ud=new ke(.5,.5),lr=new C;class $o{constructor(e=new Xn,t=new Xn,n=new Xn,i=new Xn,r=new Xn,a=new Xn){this.planes=[e,t,n,i,r,a]}set(e,t,n,i,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Cn,n=!1){const i=this.planes,r=e.elements,a=r[0],o=r[1],l=r[2],c=r[3],u=r[4],h=r[5],d=r[6],f=r[7],_=r[8],v=r[9],m=r[10],p=r[11],b=r[12],T=r[13],S=r[14],w=r[15];if(i[0].setComponents(c-a,f-u,p-_,w-b).normalize(),i[1].setComponents(c+a,f+u,p+_,w+b).normalize(),i[2].setComponents(c+o,f+h,p+v,w+T).normalize(),i[3].setComponents(c-o,f-h,p-v,w-T).normalize(),n)i[4].setComponents(l,d,m,S).normalize(),i[5].setComponents(c-l,f-d,p-m,w-S).normalize();else if(i[4].setComponents(c-l,f-d,p-m,w-S).normalize(),t===Cn)i[5].setComponents(c+l,f+d,p+m,w+S).normalize();else if(t===Os)i[5].setComponents(l,d,m,S).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),mi.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),mi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(mi)}intersectsSprite(e){mi.center.set(0,0,0);const t=Ud.distanceTo(e.center);return mi.radius=.7071067811865476+t,mi.applyMatrix4(e.matrixWorld),this.intersectsSphere(mi)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const i=t[n];if(lr.x=i.normal.x>0?e.max.x:e.min.x,lr.y=i.normal.y>0?e.max.y:e.min.y,lr.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(lr)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Br extends In{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ue(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Dr=new C,Nr=new C,ql=new We,bs=new rs,cr=new Fn,xa=new C,Kl=new C;class jo extends At{constructor(e=new Wt,t=new Br){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let i=1,r=t.count;i<r;i++)Dr.fromBufferAttribute(t,i-1),Nr.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=Dr.distanceTo(Nr);e.setAttribute("lineDistance",new Lt(n,1))}else Ie("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),cr.copy(n.boundingSphere),cr.applyMatrix4(i),cr.radius+=r,e.ray.intersectsSphere(cr)===!1)return;ql.copy(i).invert(),bs.copy(e.ray).applyMatrix4(ql);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,u=n.index,d=n.attributes.position;if(u!==null){const f=Math.max(0,a.start),_=Math.min(u.count,a.start+a.count);for(let v=f,m=_-1;v<m;v+=c){const p=u.getX(v),b=u.getX(v+1),T=ur(this,e,bs,l,p,b,v);T&&t.push(T)}if(this.isLineLoop){const v=u.getX(_-1),m=u.getX(f),p=ur(this,e,bs,l,v,m,_-1);p&&t.push(p)}}else{const f=Math.max(0,a.start),_=Math.min(d.count,a.start+a.count);for(let v=f,m=_-1;v<m;v+=c){const p=ur(this,e,bs,l,v,v+1,v);p&&t.push(p)}if(this.isLineLoop){const v=ur(this,e,bs,l,_-1,f,_-1);v&&t.push(v)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function ur(s,e,t,n,i,r,a){const o=s.geometry.attributes.position;if(Dr.fromBufferAttribute(o,i),Nr.fromBufferAttribute(o,r),t.distanceSqToSegment(Dr,Nr,xa,Kl)>n)return;xa.applyMatrix4(s.matrixWorld);const c=e.ray.origin.distanceTo(xa);if(!(c<e.near||c>e.far))return{distance:c,point:Kl.clone().applyMatrix4(s.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:s}}const Zl=new C,$l=new C;class Jo extends jo{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let i=0,r=t.count;i<r;i+=2)Zl.fromBufferAttribute(t,i),$l.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+Zl.distanceTo($l);e.setAttribute("lineDistance",new Lt(n,1))}else Ie("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Fd extends jo{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class vu extends In{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ue(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const jl=new We,To=new rs,hr=new Fn,dr=new C;class Od extends At{constructor(e=new Wt,t=new vu){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),hr.copy(n.boundingSphere),hr.applyMatrix4(i),hr.radius+=r,e.ray.intersectsSphere(hr)===!1)return;jl.copy(i).invert(),To.copy(e.ray).applyMatrix4(jl);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=n.index,h=n.attributes.position;if(c!==null){const d=Math.max(0,a.start),f=Math.min(c.count,a.start+a.count);for(let _=d,v=f;_<v;_++){const m=c.getX(_);dr.fromBufferAttribute(h,m),Jl(dr,m,l,i,e,t,this)}}else{const d=Math.max(0,a.start),f=Math.min(h.count,a.start+a.count);for(let _=d,v=f;_<v;_++)dr.fromBufferAttribute(h,_),Jl(dr,_,l,i,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function Jl(s,e,t,n,i,r,a){const o=To.distanceSqToPoint(s);if(o<t){const l=new C;To.closestPointToPoint(s,l),l.applyMatrix4(n);const c=i.ray.origin.distanceTo(l);if(c<i.near||c>i.far)return;r.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class Mu extends Gt{constructor(e=[],t=bi,n,i,r,a,o,l,c,u){super(e,t,n,i,r,a,o,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class ns extends Gt{constructor(e,t,n=Nn,i,r,a,o=Ot,l=Ot,c,u=jn,h=1){if(u!==jn&&u!==Mi)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:e,height:t,depth:h};super(d,i,r,a,o,l,u,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Xo(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class Bd extends ns{constructor(e,t=Nn,n=bi,i,r,a=Ot,o=Ot,l,c=jn){const u={width:e,height:e,depth:1},h=[u,u,u,u,u,u];super(e,e,t,n,i,r,a,o,l,c),this.image=h,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class Su extends Gt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Vs extends Wt{constructor(e=1,t=1,n=1,i=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:a};const o=this;i=Math.floor(i),r=Math.floor(r),a=Math.floor(a);const l=[],c=[],u=[],h=[];let d=0,f=0;_("z","y","x",-1,-1,n,t,e,a,r,0),_("z","y","x",1,-1,n,t,-e,a,r,1),_("x","z","y",1,1,e,n,t,i,a,2),_("x","z","y",1,-1,e,n,-t,i,a,3),_("x","y","z",1,-1,e,t,n,i,r,4),_("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(l),this.setAttribute("position",new Lt(c,3)),this.setAttribute("normal",new Lt(u,3)),this.setAttribute("uv",new Lt(h,2));function _(v,m,p,b,T,S,w,E,R,x,A){const D=S/R,P=w/x,F=S/2,$=w/2,j=E/2,k=R+1,q=x+1;let W=0,ee=0;const K=new C;for(let le=0;le<q;le++){const pe=le*P-$;for(let Me=0;Me<k;Me++){const Ye=Me*D-F;K[v]=Ye*b,K[m]=pe*T,K[p]=j,c.push(K.x,K.y,K.z),K[v]=0,K[m]=0,K[p]=E>0?1:-1,u.push(K.x,K.y,K.z),h.push(Me/R),h.push(1-le/x),W+=1}}for(let le=0;le<x;le++)for(let pe=0;pe<R;pe++){const Me=d+pe+k*le,Ye=d+pe+k*(le+1),rt=d+(pe+1)+k*(le+1),qe=d+(pe+1)+k*le;l.push(Me,Ye,qe),l.push(Ye,rt,qe),ee+=6}o.addGroup(f,ee,A),f+=ee,d+=W}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Vs(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class Qo extends Wt{constructor(e=1,t=32,n=0,i=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},t=Math.max(3,t);const r=[],a=[],o=[],l=[],c=new C,u=new ke;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let h=0,d=3;h<=t;h++,d+=3){const f=n+h/t*i;c.x=e*Math.cos(f),c.y=e*Math.sin(f),a.push(c.x,c.y,c.z),o.push(0,0,1),u.x=(a[d]/e+1)/2,u.y=(a[d+1]/e+1)/2,l.push(u.x,u.y)}for(let h=1;h<=t;h++)r.push(h,h+1,0);this.setIndex(r),this.setAttribute("position",new Lt(a,3)),this.setAttribute("normal",new Lt(o,3)),this.setAttribute("uv",new Lt(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Qo(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class kr extends Wt{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const r=e/2,a=t/2,o=Math.floor(n),l=Math.floor(i),c=o+1,u=l+1,h=e/o,d=t/l,f=[],_=[],v=[],m=[];for(let p=0;p<u;p++){const b=p*d-a;for(let T=0;T<c;T++){const S=T*h-r;_.push(S,-b,0),v.push(0,0,1),m.push(T/o),m.push(1-p/l)}}for(let p=0;p<l;p++)for(let b=0;b<o;b++){const T=b+c*p,S=b+c*(p+1),w=b+1+c*(p+1),E=b+1+c*p;f.push(T,S,E),f.push(S,w,E)}this.setIndex(f),this.setAttribute("position",new Lt(_,3)),this.setAttribute("normal",new Lt(v,3)),this.setAttribute("uv",new Lt(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new kr(e.width,e.height,e.widthSegments,e.heightSegments)}}class el extends Wt{constructor(e=.5,t=1,n=32,i=1,r=0,a=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:i,thetaStart:r,thetaLength:a},n=Math.max(3,n),i=Math.max(1,i);const o=[],l=[],c=[],u=[];let h=e;const d=(t-e)/i,f=new C,_=new ke;for(let v=0;v<=i;v++){for(let m=0;m<=n;m++){const p=r+m/n*a;f.x=h*Math.cos(p),f.y=h*Math.sin(p),l.push(f.x,f.y,f.z),c.push(0,0,1),_.x=(f.x/t+1)/2,_.y=(f.y/t+1)/2,u.push(_.x,_.y)}h+=d}for(let v=0;v<i;v++){const m=v*(n+1);for(let p=0;p<n;p++){const b=p+m,T=b,S=b+n+1,w=b+n+2,E=b+1;o.push(T,S,E),o.push(S,w,E)}}this.setIndex(o),this.setAttribute("position",new Lt(l,3)),this.setAttribute("normal",new Lt(c,3)),this.setAttribute("uv",new Lt(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new el(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}function is(s){const e={};for(const t in s){e[t]={};for(const n in s[t]){const i=s[t][n];if(Ql(i))i.isRenderTargetTexture?(Ie("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=i.clone();else if(Array.isArray(i))if(Ql(i[0])){const r=[];for(let a=0,o=i.length;a<o;a++)r[a]=i[a].clone();e[t][n]=r}else e[t][n]=i.slice();else e[t][n]=i}}return e}function Jt(s){const e={};for(let t=0;t<s.length;t++){const n=is(s[t]);for(const i in n)e[i]=n[i]}return e}function Ql(s){return s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)}function kd(s){const e=[];for(let t=0;t<s.length;t++)e.push(s[t].clone());return e}function yu(s){const e=s.getRenderTarget();return e===null?s.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Qe.workingColorSpace}const zd={clone:is,merge:Jt};var Vd=`void main() {
1
+ import{a7 as ss,cO as Do,bk as ie,X as Da,g as ku,i as zu}from"./app-BT_37rUb.js";import{b as we,r as Vu}from"./dnd-BCFAPC0L.js";import{S as Hu,u as Gu,j as Wu,R as Xu,L as Yu,i as qu,M as Ku,H as Zu,p as $u}from"./App-DIYNv8nX.js";import{a as Yc,E as qc,m as ms,c as ju}from"./RightSidebar-BljTZjyo.js";import{L as dl}from"./DiffReview-CtlVXUuM.js";import"./react-XDCjal2T.js";import"./terminal-C7X98Amf.js";import"./gestureArbiter-B6OZhQjV.js";import"./triangle-alert-9JebA9Zi.js";import"./referenceLongPress-5KOTIE_2.js";import"./sparkles-BqYxpm2T.js";import"./ChangeWalkthroughPanel-D3P0LWfU.js";import"./DiffViewer-DbAcE-rO.js";const Ju=[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]],Qu=ss("arrow-left-right",Ju);const eh=[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]],Kc=ss("focus",eh);const th=[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]],nh=ss("quote",th);const ih=[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]],sh=ss("scissors",ih);const rh=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],ah=ss("tag",rh);const oh=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],Na=ss("undo-2",oh);const No="185",Yi={ROTATE:0,DOLLY:1,PAN:2},Xi={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},lh=0,fl=1,ch=2,Sr=1,uh=2,ws=3,Dn=0,tn=1,an=2,Kn=0,qi=1,pl=2,ml=3,gl=4,hh=5,xi=100,dh=101,fh=102,ph=103,mh=104,gh=200,_h=201,xh=202,vh=203,Ua=204,Fa=205,Mh=206,Sh=207,yh=208,bh=209,Eh=210,Th=211,Ah=212,wh=213,Rh=214,Oa=0,Ba=1,ka=2,Ji=3,za=4,Va=5,Ha=6,Ga=7,Zc=0,Ch=1,Ph=2,Pn=0,$c=1,jc=2,Jc=3,Qc=4,eu=5,tu=6,nu=7,_l="attached",Lh="detached",iu=300,bi=301,Qi=302,Xr=303,Yr=304,Or=306,es=1e3,Rn=1001,Rr=1002,Ot=1003,su=1004,Rs=1005,Bt=1006,yr=1007,Yn=1008,on=1009,ru=1010,au=1011,Ds=1012,Uo=1013,Nn=1014,fn=1015,$n=1016,Fo=1017,Oo=1018,Ns=1020,ou=35902,lu=35899,cu=1021,uu=1022,pn=1023,jn=1026,Mi=1027,Bo=1028,ko=1029,Ei=1030,zo=1031,Vo=1033,br=33776,Er=33777,Tr=33778,Ar=33779,Wa=35840,Xa=35841,Ya=35842,qa=35843,Ka=36196,Za=37492,$a=37496,ja=37488,Ja=37489,Cr=37490,Qa=37491,eo=37808,to=37809,no=37810,io=37811,so=37812,ro=37813,ao=37814,oo=37815,lo=37816,co=37817,uo=37818,ho=37819,fo=37820,po=37821,mo=36492,go=36494,_o=36495,xo=36283,vo=36284,Pr=36285,Mo=36286,Us=2300,Fs=2301,qr=2302,xl=2303,vl=2400,Ml=2401,Sl=2402,Ih=2500,Dh=0,hu=1,So=2,Nh=3200,yo=0,Uh=1,li="",Ht="srgb",ln="srgb-linear",Lr="linear",ut="srgb",Ci=7680,yl=519,Fh=512,Oh=513,Bh=514,Ho=515,kh=516,zh=517,Go=518,Vh=519,bo=35044,bl="300 es",Cn=2e3,Os=2001;function Hh(s){for(let e=s.length-1;e>=0;--e)if(s[e]>=65535)return!0;return!1}function Gh(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function Bs(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function Wh(){const s=Bs("canvas");return s.style.display="block",s}const El={};function Ir(...s){const e="THREE."+s.shift();console.log(e,...s)}function du(s){const e=s[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=s[1];t&&t.isStackTrace?s[0]+=" "+t.getLocation():s[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return s}function Ie(...s){s=du(s);const e="THREE."+s.shift();{const t=s[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...s)}}function ze(...s){s=du(s);const e="THREE."+s.shift();{const t=s[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...s)}}function Ki(...s){const e=s.join(" ");e in El||(El[e]=!0,Ie(...s))}function Xh(s,e,t){return new Promise(function(n,i){function r(){switch(s.clientWaitSync(e,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:i();break;case s.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}const Yh={[Oa]:Ba,[ka]:Ha,[za]:Ga,[Ji]:Va,[Ba]:Oa,[Ha]:ka,[Ga]:za,[Va]:Ji};class hi{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const i=n[e];if(i!==void 0){const r=i.indexOf(t);r!==-1&&i.splice(r,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let r=0,a=i.length;r<a;r++)i[r].call(this,e);e.target=null}}}const Zt=["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 Tl=1234567;const Ps=Math.PI/180,ts=180/Math.PI;function Mn(){const s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Zt[s&255]+Zt[s>>8&255]+Zt[s>>16&255]+Zt[s>>24&255]+"-"+Zt[e&255]+Zt[e>>8&255]+"-"+Zt[e>>16&15|64]+Zt[e>>24&255]+"-"+Zt[t&63|128]+Zt[t>>8&255]+"-"+Zt[t>>16&255]+Zt[t>>24&255]+Zt[n&255]+Zt[n>>8&255]+Zt[n>>16&255]+Zt[n>>24&255]).toLowerCase()}function $e(s,e,t){return Math.max(e,Math.min(t,s))}function Wo(s,e){return(s%e+e)%e}function qh(s,e,t,n,i){return n+(s-e)*(i-n)/(t-e)}function Kh(s,e,t){return s!==e?(t-s)/(e-s):0}function Ls(s,e,t){return(1-t)*s+t*e}function Zh(s,e,t,n){return Ls(s,e,1-Math.exp(-t*n))}function $h(s,e=1){return e-Math.abs(Wo(s,e*2)-e)}function jh(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*(3-2*s))}function Jh(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*s*(s*(s*6-15)+10))}function Qh(s,e){return s+Math.floor(Math.random()*(e-s+1))}function ed(s,e){return s+Math.random()*(e-s)}function td(s){return s*(.5-Math.random())}function nd(s){s!==void 0&&(Tl=s);let e=Tl+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function id(s){return s*Ps}function sd(s){return s*ts}function rd(s){return(s&s-1)===0&&s!==0}function ad(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function od(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function ld(s,e,t,n,i){const r=Math.cos,a=Math.sin,o=r(t/2),l=a(t/2),c=r((e+n)/2),u=a((e+n)/2),h=r((e-n)/2),d=a((e-n)/2),f=r((n-e)/2),_=a((n-e)/2);switch(i){case"XYX":s.set(o*u,l*h,l*d,o*c);break;case"YZY":s.set(l*d,o*u,l*h,o*c);break;case"ZXZ":s.set(l*h,l*d,o*u,o*c);break;case"XZX":s.set(o*u,l*_,l*f,o*c);break;case"YXY":s.set(l*f,o*u,l*_,o*c);break;case"ZYZ":s.set(l*_,l*f,o*u,o*c);break;default:Ie("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function xn(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function ht(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const fu={DEG2RAD:Ps,RAD2DEG:ts,generateUUID:Mn,clamp:$e,euclideanModulo:Wo,mapLinear:qh,inverseLerp:Kh,lerp:Ls,damp:Zh,pingpong:$h,smoothstep:jh,smootherstep:Jh,randInt:Qh,randFloat:ed,randFloatSpread:td,seededRandom:nd,degToRad:id,radToDeg:sd,isPowerOfTwo:rd,ceilPowerOfTwo:ad,floorPowerOfTwo:od,setQuaternionFromProperEuler:ld,normalize:ht,denormalize:xn},al=class al{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=$e(this.x,e.x,t.x),this.y=$e(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=$e(this.x,e,t),this.y=$e(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar($e(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos($e(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*i+e.x,this.y=r*i+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};al.prototype.isVector2=!0;let ke=al;class Sn{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,a,o){let l=n[i+0],c=n[i+1],u=n[i+2],h=n[i+3],d=r[a+0],f=r[a+1],_=r[a+2],v=r[a+3];if(h!==v||l!==d||c!==f||u!==_){let m=l*d+c*f+u*_+h*v;m<0&&(d=-d,f=-f,_=-_,v=-v,m=-m);let p=1-o;if(m<.9995){const b=Math.acos(m),T=Math.sin(b);p=Math.sin(p*b)/T,o=Math.sin(o*b)/T,l=l*p+d*o,c=c*p+f*o,u=u*p+_*o,h=h*p+v*o}else{l=l*p+d*o,c=c*p+f*o,u=u*p+_*o,h=h*p+v*o;const b=1/Math.sqrt(l*l+c*c+u*u+h*h);l*=b,c*=b,u*=b,h*=b}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,i,r,a){const o=n[i],l=n[i+1],c=n[i+2],u=n[i+3],h=r[a],d=r[a+1],f=r[a+2],_=r[a+3];return e[t]=o*_+u*h+l*f-c*d,e[t+1]=l*_+u*d+c*h-o*f,e[t+2]=c*_+u*f+o*d-l*h,e[t+3]=u*_-o*h-l*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,i=e._y,r=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(n/2),u=o(i/2),h=o(r/2),d=l(n/2),f=l(i/2),_=l(r/2);switch(a){case"XYZ":this._x=d*u*h+c*f*_,this._y=c*f*h-d*u*_,this._z=c*u*_+d*f*h,this._w=c*u*h-d*f*_;break;case"YXZ":this._x=d*u*h+c*f*_,this._y=c*f*h-d*u*_,this._z=c*u*_-d*f*h,this._w=c*u*h+d*f*_;break;case"ZXY":this._x=d*u*h-c*f*_,this._y=c*f*h+d*u*_,this._z=c*u*_+d*f*h,this._w=c*u*h-d*f*_;break;case"ZYX":this._x=d*u*h-c*f*_,this._y=c*f*h+d*u*_,this._z=c*u*_-d*f*h,this._w=c*u*h+d*f*_;break;case"YZX":this._x=d*u*h+c*f*_,this._y=c*f*h+d*u*_,this._z=c*u*_-d*f*h,this._w=c*u*h-d*f*_;break;case"XZY":this._x=d*u*h-c*f*_,this._y=c*f*h-d*u*_,this._z=c*u*_+d*f*h,this._w=c*u*h+d*f*_;break;default:Ie("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],r=t[8],a=t[1],o=t[5],l=t[9],c=t[2],u=t[6],h=t[10],d=n+o+h;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(u-l)*f,this._y=(r-c)*f,this._z=(a-i)*f}else if(n>o&&n>h){const f=2*Math.sqrt(1+n-o-h);this._w=(u-l)/f,this._x=.25*f,this._y=(i+a)/f,this._z=(r+c)/f}else if(o>h){const f=2*Math.sqrt(1+o-n-h);this._w=(r-c)/f,this._x=(i+a)/f,this._y=.25*f,this._z=(l+u)/f}else{const f=2*Math.sqrt(1+h-n-o);this._w=(a-i)/f,this._x=(r+c)/f,this._y=(l+u)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs($e(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,r=e._z,a=e._w,o=t._x,l=t._y,c=t._z,u=t._w;return this._x=n*u+a*o+i*c-r*l,this._y=i*u+a*l+r*o-n*c,this._z=r*u+a*c+n*l-i*o,this._w=a*u-n*o-i*l-r*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,i=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,i=-i,r=-r,a=-a,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),u=Math.sin(c);l=Math.sin(l*c)/u,t=Math.sin(t*c)/u,this._x=this._x*l+n*t,this._y=this._y*l+i*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+n*t,this._y=this._y*l+i*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const ol=class ol{constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Al.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Al.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,r=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*i-o*n),u=2*(o*t-r*i),h=2*(r*n-a*t);return this.x=t+l*c+a*h-o*u,this.y=n+l*u+o*c-r*h,this.z=i+l*h+r*u-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=$e(this.x,e.x,t.x),this.y=$e(this.y,e.y,t.y),this.z=$e(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=$e(this.x,e,t),this.y=$e(this.y,e,t),this.z=$e(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar($e(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,r=e.z,a=t.x,o=t.y,l=t.z;return this.x=i*l-r*o,this.y=r*a-n*l,this.z=n*o-i*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Kr.copy(this).projectOnVector(e),this.sub(Kr)}reflect(e){return this.sub(Kr.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos($e(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};ol.prototype.isVector3=!0;let C=ol;const Kr=new C,Al=new Sn,ll=class ll{constructor(e,t,n,i,r,a,o,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,r,a,o,l,c)}set(e,t,n,i,r,a,o,l,c){const u=this.elements;return u[0]=e,u[1]=i,u[2]=o,u[3]=t,u[4]=r,u[5]=l,u[6]=n,u[7]=a,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],u=n[4],h=n[7],d=n[2],f=n[5],_=n[8],v=i[0],m=i[3],p=i[6],b=i[1],T=i[4],S=i[7],w=i[2],E=i[5],R=i[8];return r[0]=a*v+o*b+l*w,r[3]=a*m+o*T+l*E,r[6]=a*p+o*S+l*R,r[1]=c*v+u*b+h*w,r[4]=c*m+u*T+h*E,r[7]=c*p+u*S+h*R,r[2]=d*v+f*b+_*w,r[5]=d*m+f*T+_*E,r[8]=d*p+f*S+_*R,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8];return t*a*u-t*o*c-n*r*u+n*o*l+i*r*c-i*a*l}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],h=u*a-o*c,d=o*l-u*r,f=c*r-a*l,_=t*h+n*d+i*f;if(_===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/_;return e[0]=h*v,e[1]=(i*c-u*n)*v,e[2]=(o*n-i*a)*v,e[3]=d*v,e[4]=(u*t-i*l)*v,e[5]=(i*r-o*t)*v,e[6]=f*v,e[7]=(n*l-c*t)*v,e[8]=(a*t-n*r)*v,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,a,o){const l=Math.cos(r),c=Math.sin(r);return this.set(n*l,n*c,-n*(l*a+c*o)+a+e,-i*c,i*l,-i*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return Ki("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Zr.makeScale(e,t)),this}rotate(e){return Ki("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Zr.makeRotation(-e)),this}translate(e,t){return Ki("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Zr.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};ll.prototype.isMatrix3=!0;let He=ll;const Zr=new He,wl=new He().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Rl=new He().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function cd(){const s={enabled:!0,workingColorSpace:ln,spaces:{},convert:function(i,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===ut&&(i.r=Zn(i.r),i.g=Zn(i.g),i.b=Zn(i.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(i.applyMatrix3(this.spaces[r].toXYZ),i.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===ut&&(i.r=Zi(i.r),i.g=Zi(i.g),i.b=Zi(i.b))),i},workingToColorSpace:function(i,r){return this.convert(i,this.workingColorSpace,r)},colorSpaceToWorking:function(i,r){return this.convert(i,r,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===li?Lr:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,r=this.workingColorSpace){return i.fromArray(this.spaces[r].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,r,a){return i.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,r){return Ki("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),s.workingToColorSpace(i,r)},toWorkingColorSpace:function(i,r){return Ki("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),s.colorSpaceToWorking(i,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return s.define({[ln]:{primaries:e,whitePoint:n,transfer:Lr,toXYZ:wl,fromXYZ:Rl,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Ht},outputColorSpaceConfig:{drawingBufferColorSpace:Ht}},[Ht]:{primaries:e,whitePoint:n,transfer:ut,toXYZ:wl,fromXYZ:Rl,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Ht}}}),s}const Qe=cd();function Zn(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function Zi(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}let Pi;class ud{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Pi===void 0&&(Pi=Bs("canvas")),Pi.width=e.width,Pi.height=e.height;const i=Pi.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),n=Pi}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Bs("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let a=0;a<r.length;a++)r[a]=Zn(r[a]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(Zn(t[n]/255)*255):t[n]=Zn(t[n]);return{data:t,width:e.width,height:e.height}}else return Ie("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let hd=0;class Xo{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:hd++}),this.uuid=Mn(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let a=0,o=i.length;a<o;a++)i[a].isDataTexture?r.push($r(i[a].image)):r.push($r(i[a]))}else r=$r(i);n.url=r}return t||(e.images[this.uuid]=n),n}}function $r(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?ud.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(Ie("Texture: Unable to serialize Texture."),{})}let dd=0;const jr=new C;class Gt extends hi{constructor(e=Gt.DEFAULT_IMAGE,t=Gt.DEFAULT_MAPPING,n=Rn,i=Rn,r=Bt,a=Yn,o=pn,l=on,c=Gt.DEFAULT_ANISOTROPY,u=li){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:dd++}),this.uuid=Mn(),this.name="",this.source=new Xo(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new ke(0,0),this.repeat=new ke(1,1),this.center=new ke(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new He,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(jr).x}get height(){return this.source.getSize(jr).y}get depth(){return this.source.getSize(jr).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const n=e[t];if(n===void 0){Ie(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){Ie(`Texture.setValues(): property '${t}' does not exist.`);continue}i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==iu)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case es:e.x=e.x-Math.floor(e.x);break;case Rn:e.x=e.x<0?0:1;break;case Rr:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case es:e.y=e.y-Math.floor(e.y);break;case Rn:e.y=e.y<0?0:1;break;case Rr:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Gt.DEFAULT_IMAGE=null;Gt.DEFAULT_MAPPING=iu;Gt.DEFAULT_ANISOTROPY=1;const cl=class cl{constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,r;const l=e.elements,c=l[0],u=l[4],h=l[8],d=l[1],f=l[5],_=l[9],v=l[2],m=l[6],p=l[10];if(Math.abs(u-d)<.01&&Math.abs(h-v)<.01&&Math.abs(_-m)<.01){if(Math.abs(u+d)<.1&&Math.abs(h+v)<.1&&Math.abs(_+m)<.1&&Math.abs(c+f+p-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const T=(c+1)/2,S=(f+1)/2,w=(p+1)/2,E=(u+d)/4,R=(h+v)/4,x=(_+m)/4;return T>S&&T>w?T<.01?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(T),i=E/n,r=R/n):S>w?S<.01?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(S),n=E/i,r=x/i):w<.01?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(w),n=R/r,i=x/r),this.set(n,i,r,t),this}let b=Math.sqrt((m-_)*(m-_)+(h-v)*(h-v)+(d-u)*(d-u));return Math.abs(b)<.001&&(b=1),this.x=(m-_)/b,this.y=(h-v)/b,this.z=(d-u)/b,this.w=Math.acos((c+f+p-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=$e(this.x,e.x,t.x),this.y=$e(this.y,e.y,t.y),this.z=$e(this.z,e.z,t.z),this.w=$e(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=$e(this.x,e,t),this.y=$e(this.y,e,t),this.z=$e(this.z,e,t),this.w=$e(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar($e(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};cl.prototype.isVector4=!0;let gt=cl;class fd extends hi{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Bt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new gt(0,0,e,t),this.scissorTest=!1,this.viewport=new gt(0,0,e,t),this.textures=[];const i={width:e,height:t,depth:n.depth},r=new Gt(i),a=n.count;for(let o=0;o<a;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){const t={minFilter:Bt,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const i=Object.assign({},e.textures[t].image);this.textures[t].source=new Xo(i)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Ln extends fd{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class pu extends Gt{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Ot,this.minFilter=Ot,this.wrapR=Rn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class pd extends Gt{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Ot,this.minFilter=Ot,this.wrapR=Rn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Fr=class Fr{constructor(e,t,n,i,r,a,o,l,c,u,h,d,f,_,v,m){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,i,r,a,o,l,c,u,h,d,f,_,v,m)}set(e,t,n,i,r,a,o,l,c,u,h,d,f,_,v,m){const p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=i,p[1]=r,p[5]=a,p[9]=o,p[13]=l,p[2]=c,p[6]=u,p[10]=h,p[14]=d,p[3]=f,p[7]=_,p[11]=v,p[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 Fr().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();const t=this.elements,n=e.elements,i=1/Li.setFromMatrixColumn(e,0).length(),r=1/Li.setFromMatrixColumn(e,1).length(),a=1/Li.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,r=e.z,a=Math.cos(n),o=Math.sin(n),l=Math.cos(i),c=Math.sin(i),u=Math.cos(r),h=Math.sin(r);if(e.order==="XYZ"){const d=a*u,f=a*h,_=o*u,v=o*h;t[0]=l*u,t[4]=-l*h,t[8]=c,t[1]=f+_*c,t[5]=d-v*c,t[9]=-o*l,t[2]=v-d*c,t[6]=_+f*c,t[10]=a*l}else if(e.order==="YXZ"){const d=l*u,f=l*h,_=c*u,v=c*h;t[0]=d+v*o,t[4]=_*o-f,t[8]=a*c,t[1]=a*h,t[5]=a*u,t[9]=-o,t[2]=f*o-_,t[6]=v+d*o,t[10]=a*l}else if(e.order==="ZXY"){const d=l*u,f=l*h,_=c*u,v=c*h;t[0]=d-v*o,t[4]=-a*h,t[8]=_+f*o,t[1]=f+_*o,t[5]=a*u,t[9]=v-d*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const d=a*u,f=a*h,_=o*u,v=o*h;t[0]=l*u,t[4]=_*c-f,t[8]=d*c+v,t[1]=l*h,t[5]=v*c+d,t[9]=f*c-_,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const d=a*l,f=a*c,_=o*l,v=o*c;t[0]=l*u,t[4]=v-d*h,t[8]=_*h+f,t[1]=h,t[5]=a*u,t[9]=-o*u,t[2]=-c*u,t[6]=f*h+_,t[10]=d-v*h}else if(e.order==="XZY"){const d=a*l,f=a*c,_=o*l,v=o*c;t[0]=l*u,t[4]=-h,t[8]=c*u,t[1]=d*h+v,t[5]=a*u,t[9]=f*h-_,t[2]=_*h-f,t[6]=o*u,t[10]=v*h+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(md,e,gd)}lookAt(e,t,n){const i=this.elements;return sn.subVectors(e,t),sn.lengthSq()===0&&(sn.z=1),sn.normalize(),ti.crossVectors(n,sn),ti.lengthSq()===0&&(Math.abs(n.z)===1?sn.x+=1e-4:sn.z+=1e-4,sn.normalize(),ti.crossVectors(n,sn)),ti.normalize(),Ws.crossVectors(sn,ti),i[0]=ti.x,i[4]=Ws.x,i[8]=sn.x,i[1]=ti.y,i[5]=Ws.y,i[9]=sn.y,i[2]=ti.z,i[6]=Ws.z,i[10]=sn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,a=n[0],o=n[4],l=n[8],c=n[12],u=n[1],h=n[5],d=n[9],f=n[13],_=n[2],v=n[6],m=n[10],p=n[14],b=n[3],T=n[7],S=n[11],w=n[15],E=i[0],R=i[4],x=i[8],A=i[12],D=i[1],P=i[5],F=i[9],$=i[13],j=i[2],k=i[6],q=i[10],W=i[14],ee=i[3],K=i[7],le=i[11],pe=i[15];return r[0]=a*E+o*D+l*j+c*ee,r[4]=a*R+o*P+l*k+c*K,r[8]=a*x+o*F+l*q+c*le,r[12]=a*A+o*$+l*W+c*pe,r[1]=u*E+h*D+d*j+f*ee,r[5]=u*R+h*P+d*k+f*K,r[9]=u*x+h*F+d*q+f*le,r[13]=u*A+h*$+d*W+f*pe,r[2]=_*E+v*D+m*j+p*ee,r[6]=_*R+v*P+m*k+p*K,r[10]=_*x+v*F+m*q+p*le,r[14]=_*A+v*$+m*W+p*pe,r[3]=b*E+T*D+S*j+w*ee,r[7]=b*R+T*P+S*k+w*K,r[11]=b*x+T*F+S*q+w*le,r[15]=b*A+T*$+S*W+w*pe,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],a=e[1],o=e[5],l=e[9],c=e[13],u=e[2],h=e[6],d=e[10],f=e[14],_=e[3],v=e[7],m=e[11],p=e[15],b=l*f-c*d,T=o*f-c*h,S=o*d-l*h,w=a*f-c*u,E=a*d-l*u,R=a*h-o*u;return t*(v*b-m*T+p*S)-n*(_*b-m*w+p*E)+i*(_*T-v*w+p*R)-r*(_*S-v*E+m*R)}determinantAffine(){const e=this.elements,t=e[0],n=e[4],i=e[8],r=e[1],a=e[5],o=e[9],l=e[2],c=e[6],u=e[10];return t*(a*u-o*c)-n*(r*u-o*l)+i*(r*c-a*l)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],h=e[9],d=e[10],f=e[11],_=e[12],v=e[13],m=e[14],p=e[15],b=t*o-n*a,T=t*l-i*a,S=t*c-r*a,w=n*l-i*o,E=n*c-r*o,R=i*c-r*l,x=u*v-h*_,A=u*m-d*_,D=u*p-f*_,P=h*m-d*v,F=h*p-f*v,$=d*p-f*m,j=b*$-T*F+S*P+w*D-E*A+R*x;if(j===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const k=1/j;return e[0]=(o*$-l*F+c*P)*k,e[1]=(i*F-n*$-r*P)*k,e[2]=(v*R-m*E+p*w)*k,e[3]=(d*E-h*R-f*w)*k,e[4]=(l*D-a*$-c*A)*k,e[5]=(t*$-i*D+r*A)*k,e[6]=(m*S-_*R-p*T)*k,e[7]=(u*R-d*S+f*T)*k,e[8]=(a*F-o*D+c*x)*k,e[9]=(n*D-t*F-r*x)*k,e[10]=(_*E-v*S+p*b)*k,e[11]=(h*S-u*E-f*b)*k,e[12]=(o*A-a*P-l*x)*k,e[13]=(t*P-n*A+i*x)*k,e[14]=(v*T-_*w-m*b)*k,e[15]=(u*w-h*T+d*b)*k,this}scale(e){const t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),r=1-n,a=e.x,o=e.y,l=e.z,c=r*a,u=r*o;return this.set(c*a+n,c*o-i*l,c*l+i*o,0,c*o+i*l,u*o+n,u*l-i*a,0,c*l-i*o,u*l+i*a,r*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,a){return this.set(1,n,r,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,r=t._x,a=t._y,o=t._z,l=t._w,c=r+r,u=a+a,h=o+o,d=r*c,f=r*u,_=r*h,v=a*u,m=a*h,p=o*h,b=l*c,T=l*u,S=l*h,w=n.x,E=n.y,R=n.z;return i[0]=(1-(v+p))*w,i[1]=(f+S)*w,i[2]=(_-T)*w,i[3]=0,i[4]=(f-S)*E,i[5]=(1-(d+p))*E,i[6]=(m+b)*E,i[7]=0,i[8]=(_+T)*R,i[9]=(m-b)*R,i[10]=(1-(d+v))*R,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];const r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let a=Li.set(i[0],i[1],i[2]).length();const o=Li.set(i[4],i[5],i[6]).length(),l=Li.set(i[8],i[9],i[10]).length();r<0&&(a=-a),mn.copy(this);const c=1/a,u=1/o,h=1/l;return mn.elements[0]*=c,mn.elements[1]*=c,mn.elements[2]*=c,mn.elements[4]*=u,mn.elements[5]*=u,mn.elements[6]*=u,mn.elements[8]*=h,mn.elements[9]*=h,mn.elements[10]*=h,t.setFromRotationMatrix(mn),n.x=a,n.y=o,n.z=l,this}makePerspective(e,t,n,i,r,a,o=Cn,l=!1){const c=this.elements,u=2*r/(t-e),h=2*r/(n-i),d=(t+e)/(t-e),f=(n+i)/(n-i);let _,v;if(l)_=r/(a-r),v=a*r/(a-r);else if(o===Cn)_=-(a+r)/(a-r),v=-2*a*r/(a-r);else if(o===Os)_=-a/(a-r),v=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=u,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=h,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=_,c[14]=v,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,r,a,o=Cn,l=!1){const c=this.elements,u=2/(t-e),h=2/(n-i),d=-(t+e)/(t-e),f=-(n+i)/(n-i);let _,v;if(l)_=1/(a-r),v=a/(a-r);else if(o===Cn)_=-2/(a-r),v=-(a+r)/(a-r);else if(o===Os)_=-1/(a-r),v=-r/(a-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=u,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=h,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=_,c[14]=v,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}};Fr.prototype.isMatrix4=!0;let We=Fr;const Li=new C,mn=new We,md=new C(0,0,0),gd=new C(1,1,1),ti=new C,Ws=new C,sn=new C,Cl=new We,Pl=new Sn;class ui{constructor(e=0,t=0,n=0,i=ui.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,r=i[0],a=i[4],o=i[8],l=i[1],c=i[5],u=i[9],h=i[2],d=i[6],f=i[10];switch(t){case"XYZ":this._y=Math.asin($e(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-$e(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin($e(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-$e(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin($e(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-$e(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-u,f),this._y=0);break;default:Ie("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Cl.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Cl,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Pl.setFromEuler(this),this.setFromQuaternion(Pl,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}ui.DEFAULT_ORDER="XYZ";class Yo{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let _d=0;const Ll=new C,Ii=new Sn,kn=new We,Xs=new C,gs=new C,xd=new C,vd=new Sn,Il=new C(1,0,0),Dl=new C(0,1,0),Nl=new C(0,0,1),Ul={type:"added"},Md={type:"removed"},Di={type:"childadded",child:null},Jr={type:"childremoved",child:null};class At extends hi{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:_d++}),this.uuid=Mn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=At.DEFAULT_UP.clone();const e=new C,t=new ui,n=new Sn,i=new C(1,1,1);function r(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new We},normalMatrix:{value:new He}}),this.matrix=new We,this.matrixWorld=new We,this.matrixAutoUpdate=At.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=At.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Yo,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Ii.setFromAxisAngle(e,t),this.quaternion.multiply(Ii),this}rotateOnWorldAxis(e,t){return Ii.setFromAxisAngle(e,t),this.quaternion.premultiply(Ii),this}rotateX(e){return this.rotateOnAxis(Il,e)}rotateY(e){return this.rotateOnAxis(Dl,e)}rotateZ(e){return this.rotateOnAxis(Nl,e)}translateOnAxis(e,t){return Ll.copy(e).applyQuaternion(this.quaternion),this.position.add(Ll.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Il,e)}translateY(e){return this.translateOnAxis(Dl,e)}translateZ(e){return this.translateOnAxis(Nl,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(kn.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Xs.copy(e):Xs.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),gs.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?kn.lookAt(gs,Xs,this.up):kn.lookAt(Xs,gs,this.up),this.quaternion.setFromRotationMatrix(kn),i&&(kn.extractRotation(i.matrixWorld),Ii.setFromRotationMatrix(kn),this.quaternion.premultiply(Ii.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(ze("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Ul),Di.child=e,this.dispatchEvent(Di),Di.child=null):ze("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Md),Jr.child=e,this.dispatchEvent(Jr),Jr.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),kn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),kn.multiply(e.parent.matrixWorld)),e.applyMatrix4(kn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Ul),Di.child=e,this.dispatchEvent(Di),Di.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const i=this.children;for(let r=0,a=i.length;r<a;r++)i[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(gs,e,xd),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(gs,vd,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const e=this.pivot;if(e!==null){const t=e.x,n=e.y,i=e.z,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*i,r[13]+=n-r[1]*t-r[5]*n-r[9]*i,r[14]+=i-r[2]*t-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){const i=this.parent;if(e===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),t===!0){const r=this.children;for(let a=0,o=r.length;a<o;a++)r[a].updateWorldMatrix(!1,!0,n)}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),this.static!==!1&&(i.static=this.static),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null&&(i.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(i.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function r(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c<u;c++){const h=l[c];r(e.shapes,h)}else r(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(r(e.materials,this.material[l]));i.material=o}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];i.animations.push(r(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),u=a(e.images),h=a(e.shapes),d=a(e.skeletons),f=a(e.animations),_=a(e.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),u.length>0&&(n.images=u),h.length>0&&(n.shapes=h),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),_.length>0&&(n.nodes=_)}return n.object=i,n;function a(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const i=e.children[n];this.add(i.clone())}return this}}At.DEFAULT_UP=new C(0,1,0);At.DEFAULT_MATRIX_AUTO_UPDATE=!0;At.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Si extends At{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Sd={type:"move"};class Qr{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Si,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 Si,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new C,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new C),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Si,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new C,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new C,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let i=null,r=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const v of e.hand.values()){const m=t.getJointPose(v,n),p=this._getHandJoint(c,v);m!==null&&(p.matrix.fromArray(m.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=m.radius),p.visible=m!==null}const u=c.joints["index-finger-tip"],h=c.joints["thumb-tip"],d=u.position.distanceTo(h.position),f=.02,_=.005;c.inputState.pinching&&d>f+_?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=f-_&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,l.eventsEnabled&&l.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null&&(i=r),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Sd)))}return o!==null&&(o.visible=i!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Si;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const mu={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},ni={h:0,s:0,l:0},Ys={h:0,s:0,l:0};function ea(s,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?s+(e-s)*6*t:t<1/2?e:t<2/3?s+(e-s)*6*(2/3-t):s}class Ue{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ht){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Qe.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=Qe.workingColorSpace){return this.r=e,this.g=t,this.b=n,Qe.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=Qe.workingColorSpace){if(e=Wo(e,1),t=$e(t,0,1),n=$e(n,0,1),t===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+t):n+t-n*t,a=2*n-r;this.r=ea(a,r,e+1/3),this.g=ea(a,r,e),this.b=ea(a,r,e-1/3)}return Qe.colorSpaceToWorking(this,i),this}setStyle(e,t=Ht){function n(r){r!==void 0&&parseFloat(r)<1&&Ie("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Ie("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=i[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);Ie("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Ht){const n=mu[e.toLowerCase()];return n!==void 0?this.setHex(n,t):Ie("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Zn(e.r),this.g=Zn(e.g),this.b=Zn(e.b),this}copyLinearToSRGB(e){return this.r=Zi(e.r),this.g=Zi(e.g),this.b=Zi(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ht){return Qe.workingToColorSpace($t.copy(this),e),Math.round($e($t.r*255,0,255))*65536+Math.round($e($t.g*255,0,255))*256+Math.round($e($t.b*255,0,255))}getHexString(e=Ht){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Qe.workingColorSpace){Qe.workingToColorSpace($t.copy(this),t);const n=$t.r,i=$t.g,r=$t.b,a=Math.max(n,i,r),o=Math.min(n,i,r);let l,c;const u=(o+a)/2;if(o===a)l=0,c=0;else{const h=a-o;switch(c=u<=.5?h/(a+o):h/(2-a-o),a){case n:l=(i-r)/h+(i<r?6:0);break;case i:l=(r-n)/h+2;break;case r:l=(n-i)/h+4;break}l/=6}return e.h=l,e.s=c,e.l=u,e}getRGB(e,t=Qe.workingColorSpace){return Qe.workingToColorSpace($t.copy(this),t),e.r=$t.r,e.g=$t.g,e.b=$t.b,e}getStyle(e=Ht){Qe.workingToColorSpace($t.copy(this),e);const t=$t.r,n=$t.g,i=$t.b;return e!==Ht?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(ni),this.setHSL(ni.h+e,ni.s+t,ni.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(ni),e.getHSL(Ys);const n=Ls(ni.h,Ys.h,t),i=Ls(ni.s,Ys.s,t),r=Ls(ni.l,Ys.l,t);return this.setHSL(n,i,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*i,this.g=r[1]*t+r[4]*n+r[7]*i,this.b=r[2]*t+r[5]*n+r[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const $t=new Ue;Ue.NAMES=mu;class yd extends At{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new ui,this.environmentIntensity=1,this.environmentRotation=new ui,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const gn=new C,zn=new C,ta=new C,Vn=new C,Ni=new C,Ui=new C,Fl=new C,na=new C,ia=new C,sa=new C,ra=new gt,aa=new gt,oa=new gt;class vn{constructor(e=new C,t=new C,n=new C){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),gn.subVectors(e,t),i.cross(gn);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){gn.subVectors(i,t),zn.subVectors(n,t),ta.subVectors(e,t);const a=gn.dot(gn),o=gn.dot(zn),l=gn.dot(ta),c=zn.dot(zn),u=zn.dot(ta),h=a*c-o*o;if(h===0)return r.set(0,0,0),null;const d=1/h,f=(c*l-o*u)*d,_=(a*u-o*l)*d;return r.set(1-f-_,_,f)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,Vn)===null?!1:Vn.x>=0&&Vn.y>=0&&Vn.x+Vn.y<=1}static getInterpolation(e,t,n,i,r,a,o,l){return this.getBarycoord(e,t,n,i,Vn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,Vn.x),l.addScaledVector(a,Vn.y),l.addScaledVector(o,Vn.z),l)}static getInterpolatedAttribute(e,t,n,i,r,a){return ra.setScalar(0),aa.setScalar(0),oa.setScalar(0),ra.fromBufferAttribute(e,t),aa.fromBufferAttribute(e,n),oa.fromBufferAttribute(e,i),a.setScalar(0),a.addScaledVector(ra,r.x),a.addScaledVector(aa,r.y),a.addScaledVector(oa,r.z),a}static isFrontFacing(e,t,n,i){return gn.subVectors(n,t),zn.subVectors(e,t),gn.cross(zn).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return gn.subVectors(this.c,this.b),zn.subVectors(this.a,this.b),gn.cross(zn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return vn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return vn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return vn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return vn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return vn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,r=this.c;let a,o;Ni.subVectors(i,n),Ui.subVectors(r,n),na.subVectors(e,n);const l=Ni.dot(na),c=Ui.dot(na);if(l<=0&&c<=0)return t.copy(n);ia.subVectors(e,i);const u=Ni.dot(ia),h=Ui.dot(ia);if(u>=0&&h<=u)return t.copy(i);const d=l*h-u*c;if(d<=0&&l>=0&&u<=0)return a=l/(l-u),t.copy(n).addScaledVector(Ni,a);sa.subVectors(e,r);const f=Ni.dot(sa),_=Ui.dot(sa);if(_>=0&&f<=_)return t.copy(r);const v=f*c-l*_;if(v<=0&&c>=0&&_<=0)return o=c/(c-_),t.copy(n).addScaledVector(Ui,o);const m=u*_-f*h;if(m<=0&&h-u>=0&&f-_>=0)return Fl.subVectors(r,i),o=(h-u)/(h-u+(f-_)),t.copy(i).addScaledVector(Fl,o);const p=1/(m+v+d);return a=v*p,o=d*p,t.copy(n).addScaledVector(Ni,a).addScaledVector(Ui,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Yt{constructor(e=new C(1/0,1/0,1/0),t=new C(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(_n.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(_n.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=_n.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,_n):_n.fromBufferAttribute(r,a),_n.applyMatrix4(e.matrixWorld),this.expandByPoint(_n);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),qs.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),qs.copy(n.boundingBox)),qs.applyMatrix4(e.matrixWorld),this.union(qs)}const i=e.children;for(let r=0,a=i.length;r<a;r++)this.expandByObject(i[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,_n),_n.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(_s),Ks.subVectors(this.max,_s),Fi.subVectors(e.a,_s),Oi.subVectors(e.b,_s),Bi.subVectors(e.c,_s),ii.subVectors(Oi,Fi),si.subVectors(Bi,Oi),di.subVectors(Fi,Bi);let t=[0,-ii.z,ii.y,0,-si.z,si.y,0,-di.z,di.y,ii.z,0,-ii.x,si.z,0,-si.x,di.z,0,-di.x,-ii.y,ii.x,0,-si.y,si.x,0,-di.y,di.x,0];return!la(t,Fi,Oi,Bi,Ks)||(t=[1,0,0,0,1,0,0,0,1],!la(t,Fi,Oi,Bi,Ks))?!1:(Zs.crossVectors(ii,si),t=[Zs.x,Zs.y,Zs.z],la(t,Fi,Oi,Bi,Ks))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,_n).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(_n).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Hn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Hn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Hn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Hn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Hn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Hn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Hn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Hn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Hn),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const Hn=[new C,new C,new C,new C,new C,new C,new C,new C],_n=new C,qs=new Yt,Fi=new C,Oi=new C,Bi=new C,ii=new C,si=new C,di=new C,_s=new C,Ks=new C,Zs=new C,fi=new C;function la(s,e,t,n,i){for(let r=0,a=s.length-3;r<=a;r+=3){fi.fromArray(s,r);const o=i.x*Math.abs(fi.x)+i.y*Math.abs(fi.y)+i.z*Math.abs(fi.z),l=e.dot(fi),c=t.dot(fi),u=n.dot(fi);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}const Dt=new C,$s=new ke;let bd=0;class Nt extends hi{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:bd++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=bo,this.updateRanges=[],this.gpuType=fn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)$s.fromBufferAttribute(this,t),$s.applyMatrix3(e),this.setXY(t,$s.x,$s.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Dt.fromBufferAttribute(this,t),Dt.applyMatrix3(e),this.setXYZ(t,Dt.x,Dt.y,Dt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Dt.fromBufferAttribute(this,t),Dt.applyMatrix4(e),this.setXYZ(t,Dt.x,Dt.y,Dt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Dt.fromBufferAttribute(this,t),Dt.applyNormalMatrix(e),this.setXYZ(t,Dt.x,Dt.y,Dt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Dt.fromBufferAttribute(this,t),Dt.transformDirection(e),this.setXYZ(t,Dt.x,Dt.y,Dt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=xn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=ht(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=xn(t,this.array)),t}setX(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=xn(t,this.array)),t}setY(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=xn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=xn(t,this.array)),t}setW(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array),i=ht(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array),i=ht(i,this.array),r=ht(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==bo&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class gu extends Nt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class _u extends Nt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Lt extends Nt{constructor(e,t,n){super(new Float32Array(e),t,n)}}const Ed=new Yt,xs=new C,ca=new C;class Fn{constructor(e=new C,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):Ed.setFromPoints(e).getCenter(n);let i=0;for(let r=0,a=e.length;r<a;r++)i=Math.max(i,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;xs.subVectors(e,this.center);const t=xs.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(xs,i/n),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(ca.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(xs.copy(e.center).add(ca)),this.expandByPoint(xs.copy(e.center).sub(ca))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let Td=0;const hn=new We,ua=new At,ki=new C,rn=new Yt,vs=new Yt,Vt=new C;class Wt extends hi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Td++}),this.uuid=Mn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Hh(e)?_u:gu)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const r=new He().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return hn.makeRotationFromQuaternion(e),this.applyMatrix4(hn),this}rotateX(e){return hn.makeRotationX(e),this.applyMatrix4(hn),this}rotateY(e){return hn.makeRotationY(e),this.applyMatrix4(hn),this}rotateZ(e){return hn.makeRotationZ(e),this.applyMatrix4(hn),this}translate(e,t,n){return hn.makeTranslation(e,t,n),this.applyMatrix4(hn),this}scale(e,t,n){return hn.makeScale(e,t,n),this.applyMatrix4(hn),this}lookAt(e){return ua.lookAt(e),ua.updateMatrix(),this.applyMatrix4(ua.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ki).negate(),this.translate(ki.x,ki.y,ki.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let i=0,r=e.length;i<r;i++){const a=e[i];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Lt(n,3))}else{const n=Math.min(e.length,t.count);for(let i=0;i<n;i++){const r=e[i];t.setXYZ(i,r.x,r.y,r.z||0)}e.length>t.count&&Ie("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Yt);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ze("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new C(-1/0,-1/0,-1/0),new C(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){const r=t[n];rn.setFromBufferAttribute(r),this.morphTargetsRelative?(Vt.addVectors(this.boundingBox.min,rn.min),this.boundingBox.expandByPoint(Vt),Vt.addVectors(this.boundingBox.max,rn.max),this.boundingBox.expandByPoint(Vt)):(this.boundingBox.expandByPoint(rn.min),this.boundingBox.expandByPoint(rn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&ze('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 Fn);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ze("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new C,1/0);return}if(e){const n=this.boundingSphere.center;if(rn.setFromBufferAttribute(e),t)for(let r=0,a=t.length;r<a;r++){const o=t[r];vs.setFromBufferAttribute(o),this.morphTargetsRelative?(Vt.addVectors(rn.min,vs.min),rn.expandByPoint(Vt),Vt.addVectors(rn.max,vs.max),rn.expandByPoint(Vt)):(rn.expandByPoint(vs.min),rn.expandByPoint(vs.max))}rn.getCenter(n);let i=0;for(let r=0,a=e.count;r<a;r++)Vt.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(Vt));if(t)for(let r=0,a=t.length;r<a;r++){const o=t[r],l=this.morphTargetsRelative;for(let c=0,u=o.count;c<u;c++)Vt.fromBufferAttribute(o,c),l&&(ki.fromBufferAttribute(e,c),Vt.add(ki)),i=Math.max(i,n.distanceToSquared(Vt))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&ze('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){ze("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,i=t.normal,r=t.uv;let a=this.getAttribute("tangent");(a===void 0||a.count!==n.count)&&(a=new Nt(new Float32Array(4*n.count),4),this.setAttribute("tangent",a));const o=[],l=[];for(let x=0;x<n.count;x++)o[x]=new C,l[x]=new C;const c=new C,u=new C,h=new C,d=new ke,f=new ke,_=new ke,v=new C,m=new C;function p(x,A,D){c.fromBufferAttribute(n,x),u.fromBufferAttribute(n,A),h.fromBufferAttribute(n,D),d.fromBufferAttribute(r,x),f.fromBufferAttribute(r,A),_.fromBufferAttribute(r,D),u.sub(c),h.sub(c),f.sub(d),_.sub(d);const P=1/(f.x*_.y-_.x*f.y);isFinite(P)&&(v.copy(u).multiplyScalar(_.y).addScaledVector(h,-f.y).multiplyScalar(P),m.copy(h).multiplyScalar(f.x).addScaledVector(u,-_.x).multiplyScalar(P),o[x].add(v),o[A].add(v),o[D].add(v),l[x].add(m),l[A].add(m),l[D].add(m))}let b=this.groups;b.length===0&&(b=[{start:0,count:e.count}]);for(let x=0,A=b.length;x<A;++x){const D=b[x],P=D.start,F=D.count;for(let $=P,j=P+F;$<j;$+=3)p(e.getX($+0),e.getX($+1),e.getX($+2))}const T=new C,S=new C,w=new C,E=new C;function R(x){w.fromBufferAttribute(i,x),E.copy(w);const A=o[x];T.copy(A),T.sub(w.multiplyScalar(w.dot(A))).normalize(),S.crossVectors(E,A);const P=S.dot(l[x])<0?-1:1;a.setXYZW(x,T.x,T.y,T.z,P)}for(let x=0,A=b.length;x<A;++x){const D=b[x],P=D.start,F=D.count;for(let $=P,j=P+F;$<j;$+=3)R(e.getX($+0)),R(e.getX($+1)),R(e.getX($+2))}this._transformed=!0}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new Nt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);const i=new C,r=new C,a=new C,o=new C,l=new C,c=new C,u=new C,h=new C;if(e)for(let d=0,f=e.count;d<f;d+=3){const _=e.getX(d+0),v=e.getX(d+1),m=e.getX(d+2);i.fromBufferAttribute(t,_),r.fromBufferAttribute(t,v),a.fromBufferAttribute(t,m),u.subVectors(a,r),h.subVectors(i,r),u.cross(h),o.fromBufferAttribute(n,_),l.fromBufferAttribute(n,v),c.fromBufferAttribute(n,m),o.add(u),l.add(u),c.add(u),n.setXYZ(_,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,f=t.count;d<f;d+=3)i.fromBufferAttribute(t,d+0),r.fromBufferAttribute(t,d+1),a.fromBufferAttribute(t,d+2),u.subVectors(a,r),h.subVectors(i,r),u.cross(h),n.setXYZ(d+0,u.x,u.y,u.z),n.setXYZ(d+1,u.x,u.y,u.z),n.setXYZ(d+2,u.x,u.y,u.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Vt.fromBufferAttribute(e,t),Vt.normalize(),e.setXYZ(t,Vt.x,Vt.y,Vt.z)}toNonIndexed(){function e(o,l){const c=o.array,u=o.itemSize,h=o.normalized,d=new c.constructor(l.length*u);let f=0,_=0;for(let v=0,m=l.length;v<m;v++){o.isInterleavedBufferAttribute?f=l[v]*o.data.stride+o.offset:f=l[v]*u;for(let p=0;p<u;p++)d[_++]=c[f++]}return new Nt(d,u,h)}if(this.index===null)return Ie("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Wt,n=this.index.array,i=this.attributes;for(const o in i){const l=i[o],c=e(l,n);t.setAttribute(o,c)}const r=this.morphAttributes;for(const o in r){const l=[],c=r[o];for(let u=0,h=c.length;u<h;u++){const d=c[u],f=e(d,n);l.push(f)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const l in n){const c=n[l];e.data.attributes[l]=c.toJSON(e.data)}const i={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let h=0,d=c.length;h<d;h++){const f=c[h];u.push(f.toJSON(e.data))}u.length>0&&(i[l]=u,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const i=e.attributes;for(const c in i){const u=i[c];this.setAttribute(c,u.clone(t))}const r=e.morphAttributes;for(const c in r){const u=[],h=r[c];for(let d=0,f=h.length;d<f;d++)u.push(h[d].clone(t));this.morphAttributes[c]=u}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,u=a.length;c<u;c++){const h=a[c];this.addGroup(h.start,h.count,h.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Ad{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=bo,this.updateRanges=[],this.version=0,this.uuid=Mn()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Mn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Mn()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const jt=new C;class qo{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)jt.fromBufferAttribute(this,t),jt.applyMatrix4(e),this.setXYZ(t,jt.x,jt.y,jt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)jt.fromBufferAttribute(this,t),jt.applyNormalMatrix(e),this.setXYZ(t,jt.x,jt.y,jt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)jt.fromBufferAttribute(this,t),jt.transformDirection(e),this.setXYZ(t,jt.x,jt.y,jt.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=xn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=ht(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=xn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=xn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=xn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=xn(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array),i=ht(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array),i=ht(i,this.array),r=ht(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(e===void 0){Ir("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return new Nt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new qo(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){Ir("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}let wd=0;class In extends hi{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:wd++}),this.uuid=Mn(),this.name="",this.type="Material",this.blending=qi,this.side=Dn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Ua,this.blendDst=Fa,this.blendEquation=xi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ue(0,0,0),this.blendAlpha=0,this.depthFunc=Ji,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=yl,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ci,this.stencilZFail=Ci,this.stencilZPass=Ci,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){Ie(`Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){Ie(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector2&&n&&n.isVector2||i&&i.isEuler&&n&&n.isEuler||i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==qi&&(n.blending=this.blending),this.side!==Dn&&(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!==Ua&&(n.blendSrc=this.blendSrc),this.blendDst!==Fa&&(n.blendDst=this.blendDst),this.blendEquation!==xi&&(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!==Ji&&(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!==yl&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ci&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Ci&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Ci&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(r){const a=[];for(const o in r){const l=r[o];delete l.metadata,a.push(l)}return a}if(t){const r=i(e.textures),a=i(e.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new Ue().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let n=e.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new ke().fromArray(n)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new ke().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const i=t.length;n=new Array(i);for(let r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}const Gn=new C,ha=new C,js=new C,ri=new C,da=new C,Js=new C,fa=new C;class rs{constructor(e=new C,t=new C(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Gn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Gn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Gn.copy(this.origin).addScaledVector(this.direction,t),Gn.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){ha.copy(e).add(t).multiplyScalar(.5),js.copy(t).sub(e).normalize(),ri.copy(this.origin).sub(ha);const r=e.distanceTo(t)*.5,a=-this.direction.dot(js),o=ri.dot(this.direction),l=-ri.dot(js),c=ri.lengthSq(),u=Math.abs(1-a*a);let h,d,f,_;if(u>0)if(h=a*l-o,d=a*o-l,_=r*u,h>=0)if(d>=-_)if(d<=_){const v=1/u;h*=v,d*=v,f=h*(h+a*d+2*o)+d*(a*h+d+2*l)+c}else d=r,h=Math.max(0,-(a*d+o)),f=-h*h+d*(d+2*l)+c;else d=-r,h=Math.max(0,-(a*d+o)),f=-h*h+d*(d+2*l)+c;else d<=-_?(h=Math.max(0,-(-a*r+o)),d=h>0?-r:Math.min(Math.max(-r,-l),r),f=-h*h+d*(d+2*l)+c):d<=_?(h=0,d=Math.min(Math.max(-r,-l),r),f=d*(d+2*l)+c):(h=Math.max(0,-(a*r+o)),d=h>0?r:Math.min(Math.max(-r,-l),r),f=-h*h+d*(d+2*l)+c);else d=a>0?-r:r,h=Math.max(0,-(a*d+o)),f=-h*h+d*(d+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(ha).addScaledVector(js,d),f}intersectSphere(e,t){Gn.subVectors(e.center,this.origin);const n=Gn.dot(this.direction),i=Gn.dot(Gn)-n*n,r=e.radius*e.radius;if(i>r)return null;const a=Math.sqrt(r-i),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,a,o,l;const c=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,i=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,i=(e.min.x-d.x)*c),u>=0?(r=(e.min.y-d.y)*u,a=(e.max.y-d.y)*u):(r=(e.max.y-d.y)*u,a=(e.min.y-d.y)*u),n>a||r>i||((r>n||isNaN(n))&&(n=r),(a<i||isNaN(i))&&(i=a),h>=0?(o=(e.min.z-d.z)*h,l=(e.max.z-d.z)*h):(o=(e.max.z-d.z)*h,l=(e.min.z-d.z)*h),n>l||o>i)||((o>n||n!==n)&&(n=o),(l<i||i!==i)&&(i=l),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,Gn)!==null}intersectTriangle(e,t,n,i,r){da.subVectors(t,e),Js.subVectors(n,e),fa.crossVectors(da,Js);let a=this.direction.dot(fa),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;ri.subVectors(this.origin,e);const l=o*this.direction.dot(Js.crossVectors(ri,Js));if(l<0)return null;const c=o*this.direction.dot(da.cross(ri));if(c<0||l+c>a)return null;const u=-o*ri.dot(fa);return u<0?null:this.at(u/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class yi extends In{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ue(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ui,this.combine=Zc,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Ol=new We,pi=new rs,Qs=new Fn,Bl=new C,er=new C,tr=new C,nr=new C,pa=new C,ir=new C,kl=new C,sr=new C;class bt extends At{constructor(e=new Wt,t=new yi){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){const n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(r&&o){ir.set(0,0,0);for(let l=0,c=r.length;l<c;l++){const u=o[l],h=r[l];u!==0&&(pa.fromBufferAttribute(h,e),a?ir.addScaledVector(pa,u):ir.addScaledVector(pa.sub(t),u))}t.add(ir)}return t}raycast(e,t){const n=this.geometry,i=this.material,r=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Qs.copy(n.boundingSphere),Qs.applyMatrix4(r),pi.copy(e.ray).recast(e.near),!(Qs.containsPoint(pi.origin)===!1&&(pi.intersectSphere(Qs,Bl)===null||pi.origin.distanceToSquared(Bl)>(e.far-e.near)**2))&&(Ol.copy(r).invert(),pi.copy(e.ray).applyMatrix4(Ol),!(n.boundingBox!==null&&pi.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,pi)))}_computeIntersections(e,t,n){let i;const r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=r.attributes.uv,u=r.attributes.uv1,h=r.attributes.normal,d=r.groups,f=r.drawRange;if(o!==null)if(Array.isArray(a))for(let _=0,v=d.length;_<v;_++){const m=d[_],p=a[m.materialIndex],b=Math.max(m.start,f.start),T=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let S=b,w=T;S<w;S+=3){const E=o.getX(S),R=o.getX(S+1),x=o.getX(S+2);i=rr(this,p,e,n,c,u,h,E,R,x),i&&(i.faceIndex=Math.floor(S/3),i.face.materialIndex=m.materialIndex,t.push(i))}}else{const _=Math.max(0,f.start),v=Math.min(o.count,f.start+f.count);for(let m=_,p=v;m<p;m+=3){const b=o.getX(m),T=o.getX(m+1),S=o.getX(m+2);i=rr(this,a,e,n,c,u,h,b,T,S),i&&(i.faceIndex=Math.floor(m/3),t.push(i))}}else if(l!==void 0)if(Array.isArray(a))for(let _=0,v=d.length;_<v;_++){const m=d[_],p=a[m.materialIndex],b=Math.max(m.start,f.start),T=Math.min(l.count,Math.min(m.start+m.count,f.start+f.count));for(let S=b,w=T;S<w;S+=3){const E=S,R=S+1,x=S+2;i=rr(this,p,e,n,c,u,h,E,R,x),i&&(i.faceIndex=Math.floor(S/3),i.face.materialIndex=m.materialIndex,t.push(i))}}else{const _=Math.max(0,f.start),v=Math.min(l.count,f.start+f.count);for(let m=_,p=v;m<p;m+=3){const b=m,T=m+1,S=m+2;i=rr(this,a,e,n,c,u,h,b,T,S),i&&(i.faceIndex=Math.floor(m/3),t.push(i))}}}}function Rd(s,e,t,n,i,r,a,o){let l;if(e.side===tn?l=n.intersectTriangle(a,r,i,!0,o):l=n.intersectTriangle(i,r,a,e.side===Dn,o),l===null)return null;sr.copy(o),sr.applyMatrix4(s.matrixWorld);const c=t.ray.origin.distanceTo(sr);return c<t.near||c>t.far?null:{distance:c,point:sr.clone(),object:s}}function rr(s,e,t,n,i,r,a,o,l,c){s.getVertexPosition(o,er),s.getVertexPosition(l,tr),s.getVertexPosition(c,nr);const u=Rd(s,e,t,n,er,tr,nr,kl);if(u){const h=new C;vn.getBarycoord(kl,er,tr,nr,h),i&&(u.uv=vn.getInterpolatedAttribute(i,o,l,c,h,new ke)),r&&(u.uv1=vn.getInterpolatedAttribute(r,o,l,c,h,new ke)),a&&(u.normal=vn.getInterpolatedAttribute(a,o,l,c,h,new C),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));const d={a:o,b:l,c,normal:new C,materialIndex:0};vn.getNormal(er,tr,nr,d.normal),u.face=d,u.barycoord=h}return u}const Ms=new gt,zl=new gt,Vl=new gt,Cd=new gt,Hl=new We,ar=new C,ma=new Fn,Gl=new We,ga=new rs;class Pd extends bt{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=_l,this.bindMatrix=new We,this.bindMatrixInverse=new We,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Yt),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,ar),this.boundingBox.expandByPoint(ar)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Fn),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,ar),this.boundingSphere.expandByPoint(ar)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ma.copy(this.boundingSphere),ma.applyMatrix4(i),e.ray.intersectsSphere(ma)!==!1&&(Gl.copy(i).invert(),ga.copy(e.ray).applyMatrix4(Gl),!(this.boundingBox!==null&&ga.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,ga)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new gt,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);const r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===_l?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===Lh?this.bindMatrixInverse.copy(this.bindMatrix).invert():Ie("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,i=this.geometry;zl.fromBufferAttribute(i.attributes.skinIndex,e),Vl.fromBufferAttribute(i.attributes.skinWeight,e),t.isVector4?(Ms.copy(t),t.set(0,0,0,0)):(Ms.set(...t,1),t.set(0,0,0)),Ms.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){const a=Vl.getComponent(r);if(a!==0){const o=zl.getComponent(r);Hl.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(Cd.copy(Ms).applyMatrix4(Hl),a)}}return t.isVector4&&(t.w=Ms.w),t.applyMatrix4(this.bindMatrixInverse)}}class xu extends At{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Ko extends Gt{constructor(e=null,t=1,n=1,i,r,a,o,l,c=Ot,u=Ot,h,d){super(null,a,o,l,c,u,i,r,h,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Wl=new We,Ld=new We;class Zo{constructor(e=[],t=[]){this.uuid=Mn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){Ie("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new We)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new We;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,a=e.length;r<a;r++){const o=e[r]?e[r].matrixWorld:Ld;Wl.multiplyMatrices(o,t[r]),Wl.toArray(n,r*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new Zo(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new Ko(t,e,e,pn,fn);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const i=this.bones[t];if(i.name===e)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){const r=e.bones[n];let a=t[r];a===void 0&&(Ie("Skeleton: No bone found with UUID:",r),a=new xu),this.bones.push(a),this.boneInverses.push(new We().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){const a=t[i];e.bones.push(a.uuid);const o=n[i];e.boneInverses.push(o.toArray())}return e}}class Eo extends Nt{constructor(e,t,n,i=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const zi=new We,Xl=new We,or=[],Yl=new Yt,Id=new We,Ss=new bt,ys=new Fn;class Dd extends bt{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Eo(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,Id)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Yt),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,zi),Yl.copy(e.boundingBox).applyMatrix4(zi),this.boundingBox.union(Yl)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Fn),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,zi),ys.copy(e.boundingSphere).applyMatrix4(zi),this.boundingSphere.union(ys)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){return this.instanceColor===null?t.setRGB(1,1,1):t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,a=e*r+1;for(let o=0;o<n.length;o++)n[o]=i[a+o]}raycast(e,t){const n=this.matrixWorld,i=this.count;if(Ss.geometry=this.geometry,Ss.material=this.material,Ss.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ys.copy(this.boundingSphere),ys.applyMatrix4(n),e.ray.intersectsSphere(ys)!==!1))for(let r=0;r<i;r++){this.getMatrixAt(r,zi),Xl.multiplyMatrices(n,zi),Ss.matrixWorld=Xl,Ss.raycast(e,or);for(let a=0,o=or.length;a<o;a++){const l=or[a];l.instanceId=r,l.object=this,t.push(l)}or.length=0}}setColorAt(e,t){return this.instanceColor===null&&(this.instanceColor=new Eo(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){const n=t.morphTargetInfluences,i=n.length+1;this.morphTexture===null&&(this.morphTexture=new Ko(new Float32Array(i*this.count),i,this.count,Bo,fn));const r=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=i*e;return r[l]=o,r.set(n,l+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const _a=new C,Nd=new C,Ud=new He;class Xn{constructor(e=new C(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=_a.subVectors(n,t).cross(Nd.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){const i=e.delta(_a),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/r;return n===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(i,a)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||Ud.getNormalMatrix(e),i=this.coplanarPoint(_a).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const mi=new Fn,Fd=new ke(.5,.5),lr=new C;class $o{constructor(e=new Xn,t=new Xn,n=new Xn,i=new Xn,r=new Xn,a=new Xn){this.planes=[e,t,n,i,r,a]}set(e,t,n,i,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Cn,n=!1){const i=this.planes,r=e.elements,a=r[0],o=r[1],l=r[2],c=r[3],u=r[4],h=r[5],d=r[6],f=r[7],_=r[8],v=r[9],m=r[10],p=r[11],b=r[12],T=r[13],S=r[14],w=r[15];if(i[0].setComponents(c-a,f-u,p-_,w-b).normalize(),i[1].setComponents(c+a,f+u,p+_,w+b).normalize(),i[2].setComponents(c+o,f+h,p+v,w+T).normalize(),i[3].setComponents(c-o,f-h,p-v,w-T).normalize(),n)i[4].setComponents(l,d,m,S).normalize(),i[5].setComponents(c-l,f-d,p-m,w-S).normalize();else if(i[4].setComponents(c-l,f-d,p-m,w-S).normalize(),t===Cn)i[5].setComponents(c+l,f+d,p+m,w+S).normalize();else if(t===Os)i[5].setComponents(l,d,m,S).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),mi.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),mi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(mi)}intersectsSprite(e){mi.center.set(0,0,0);const t=Fd.distanceTo(e.center);return mi.radius=.7071067811865476+t,mi.applyMatrix4(e.matrixWorld),this.intersectsSphere(mi)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const i=t[n];if(lr.x=i.normal.x>0?e.max.x:e.min.x,lr.y=i.normal.y>0?e.max.y:e.min.y,lr.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(lr)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Br extends In{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ue(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Dr=new C,Nr=new C,ql=new We,bs=new rs,cr=new Fn,xa=new C,Kl=new C;class jo extends At{constructor(e=new Wt,t=new Br){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let i=1,r=t.count;i<r;i++)Dr.fromBufferAttribute(t,i-1),Nr.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=Dr.distanceTo(Nr);e.setAttribute("lineDistance",new Lt(n,1))}else Ie("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),cr.copy(n.boundingSphere),cr.applyMatrix4(i),cr.radius+=r,e.ray.intersectsSphere(cr)===!1)return;ql.copy(i).invert(),bs.copy(e.ray).applyMatrix4(ql);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,u=n.index,d=n.attributes.position;if(u!==null){const f=Math.max(0,a.start),_=Math.min(u.count,a.start+a.count);for(let v=f,m=_-1;v<m;v+=c){const p=u.getX(v),b=u.getX(v+1),T=ur(this,e,bs,l,p,b,v);T&&t.push(T)}if(this.isLineLoop){const v=u.getX(_-1),m=u.getX(f),p=ur(this,e,bs,l,v,m,_-1);p&&t.push(p)}}else{const f=Math.max(0,a.start),_=Math.min(d.count,a.start+a.count);for(let v=f,m=_-1;v<m;v+=c){const p=ur(this,e,bs,l,v,v+1,v);p&&t.push(p)}if(this.isLineLoop){const v=ur(this,e,bs,l,_-1,f,_-1);v&&t.push(v)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function ur(s,e,t,n,i,r,a){const o=s.geometry.attributes.position;if(Dr.fromBufferAttribute(o,i),Nr.fromBufferAttribute(o,r),t.distanceSqToSegment(Dr,Nr,xa,Kl)>n)return;xa.applyMatrix4(s.matrixWorld);const c=e.ray.origin.distanceTo(xa);if(!(c<e.near||c>e.far))return{distance:c,point:Kl.clone().applyMatrix4(s.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:s}}const Zl=new C,$l=new C;class Jo extends jo{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let i=0,r=t.count;i<r;i+=2)Zl.fromBufferAttribute(t,i),$l.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+Zl.distanceTo($l);e.setAttribute("lineDistance",new Lt(n,1))}else Ie("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Od extends jo{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class vu extends In{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ue(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const jl=new We,To=new rs,hr=new Fn,dr=new C;class Bd extends At{constructor(e=new Wt,t=new vu){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),hr.copy(n.boundingSphere),hr.applyMatrix4(i),hr.radius+=r,e.ray.intersectsSphere(hr)===!1)return;jl.copy(i).invert(),To.copy(e.ray).applyMatrix4(jl);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=n.index,h=n.attributes.position;if(c!==null){const d=Math.max(0,a.start),f=Math.min(c.count,a.start+a.count);for(let _=d,v=f;_<v;_++){const m=c.getX(_);dr.fromBufferAttribute(h,m),Jl(dr,m,l,i,e,t,this)}}else{const d=Math.max(0,a.start),f=Math.min(h.count,a.start+a.count);for(let _=d,v=f;_<v;_++)dr.fromBufferAttribute(h,_),Jl(dr,_,l,i,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function Jl(s,e,t,n,i,r,a){const o=To.distanceSqToPoint(s);if(o<t){const l=new C;To.closestPointToPoint(s,l),l.applyMatrix4(n);const c=i.ray.origin.distanceTo(l);if(c<i.near||c>i.far)return;r.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class Mu extends Gt{constructor(e=[],t=bi,n,i,r,a,o,l,c,u){super(e,t,n,i,r,a,o,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class ns extends Gt{constructor(e,t,n=Nn,i,r,a,o=Ot,l=Ot,c,u=jn,h=1){if(u!==jn&&u!==Mi)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:e,height:t,depth:h};super(d,i,r,a,o,l,u,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Xo(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class kd extends ns{constructor(e,t=Nn,n=bi,i,r,a=Ot,o=Ot,l,c=jn){const u={width:e,height:e,depth:1},h=[u,u,u,u,u,u];super(e,e,t,n,i,r,a,o,l,c),this.image=h,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class Su extends Gt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Vs extends Wt{constructor(e=1,t=1,n=1,i=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:a};const o=this;i=Math.floor(i),r=Math.floor(r),a=Math.floor(a);const l=[],c=[],u=[],h=[];let d=0,f=0;_("z","y","x",-1,-1,n,t,e,a,r,0),_("z","y","x",1,-1,n,t,-e,a,r,1),_("x","z","y",1,1,e,n,t,i,a,2),_("x","z","y",1,-1,e,n,-t,i,a,3),_("x","y","z",1,-1,e,t,n,i,r,4),_("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(l),this.setAttribute("position",new Lt(c,3)),this.setAttribute("normal",new Lt(u,3)),this.setAttribute("uv",new Lt(h,2));function _(v,m,p,b,T,S,w,E,R,x,A){const D=S/R,P=w/x,F=S/2,$=w/2,j=E/2,k=R+1,q=x+1;let W=0,ee=0;const K=new C;for(let le=0;le<q;le++){const pe=le*P-$;for(let Me=0;Me<k;Me++){const Ye=Me*D-F;K[v]=Ye*b,K[m]=pe*T,K[p]=j,c.push(K.x,K.y,K.z),K[v]=0,K[m]=0,K[p]=E>0?1:-1,u.push(K.x,K.y,K.z),h.push(Me/R),h.push(1-le/x),W+=1}}for(let le=0;le<x;le++)for(let pe=0;pe<R;pe++){const Me=d+pe+k*le,Ye=d+pe+k*(le+1),rt=d+(pe+1)+k*(le+1),qe=d+(pe+1)+k*le;l.push(Me,Ye,qe),l.push(Ye,rt,qe),ee+=6}o.addGroup(f,ee,A),f+=ee,d+=W}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Vs(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class Qo extends Wt{constructor(e=1,t=32,n=0,i=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},t=Math.max(3,t);const r=[],a=[],o=[],l=[],c=new C,u=new ke;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let h=0,d=3;h<=t;h++,d+=3){const f=n+h/t*i;c.x=e*Math.cos(f),c.y=e*Math.sin(f),a.push(c.x,c.y,c.z),o.push(0,0,1),u.x=(a[d]/e+1)/2,u.y=(a[d+1]/e+1)/2,l.push(u.x,u.y)}for(let h=1;h<=t;h++)r.push(h,h+1,0);this.setIndex(r),this.setAttribute("position",new Lt(a,3)),this.setAttribute("normal",new Lt(o,3)),this.setAttribute("uv",new Lt(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Qo(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class kr extends Wt{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const r=e/2,a=t/2,o=Math.floor(n),l=Math.floor(i),c=o+1,u=l+1,h=e/o,d=t/l,f=[],_=[],v=[],m=[];for(let p=0;p<u;p++){const b=p*d-a;for(let T=0;T<c;T++){const S=T*h-r;_.push(S,-b,0),v.push(0,0,1),m.push(T/o),m.push(1-p/l)}}for(let p=0;p<l;p++)for(let b=0;b<o;b++){const T=b+c*p,S=b+c*(p+1),w=b+1+c*(p+1),E=b+1+c*p;f.push(T,S,E),f.push(S,w,E)}this.setIndex(f),this.setAttribute("position",new Lt(_,3)),this.setAttribute("normal",new Lt(v,3)),this.setAttribute("uv",new Lt(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new kr(e.width,e.height,e.widthSegments,e.heightSegments)}}class el extends Wt{constructor(e=.5,t=1,n=32,i=1,r=0,a=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:i,thetaStart:r,thetaLength:a},n=Math.max(3,n),i=Math.max(1,i);const o=[],l=[],c=[],u=[];let h=e;const d=(t-e)/i,f=new C,_=new ke;for(let v=0;v<=i;v++){for(let m=0;m<=n;m++){const p=r+m/n*a;f.x=h*Math.cos(p),f.y=h*Math.sin(p),l.push(f.x,f.y,f.z),c.push(0,0,1),_.x=(f.x/t+1)/2,_.y=(f.y/t+1)/2,u.push(_.x,_.y)}h+=d}for(let v=0;v<i;v++){const m=v*(n+1);for(let p=0;p<n;p++){const b=p+m,T=b,S=b+n+1,w=b+n+2,E=b+1;o.push(T,S,E),o.push(S,w,E)}}this.setIndex(o),this.setAttribute("position",new Lt(l,3)),this.setAttribute("normal",new Lt(c,3)),this.setAttribute("uv",new Lt(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new el(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}function is(s){const e={};for(const t in s){e[t]={};for(const n in s[t]){const i=s[t][n];if(Ql(i))i.isRenderTargetTexture?(Ie("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=i.clone();else if(Array.isArray(i))if(Ql(i[0])){const r=[];for(let a=0,o=i.length;a<o;a++)r[a]=i[a].clone();e[t][n]=r}else e[t][n]=i.slice();else e[t][n]=i}}return e}function Jt(s){const e={};for(let t=0;t<s.length;t++){const n=is(s[t]);for(const i in n)e[i]=n[i]}return e}function Ql(s){return s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)}function zd(s){const e=[];for(let t=0;t<s.length;t++)e.push(s[t].clone());return e}function yu(s){const e=s.getRenderTarget();return e===null?s.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Qe.workingColorSpace}const Vd={clone:is,merge:Jt};var Hd=`void main() {
2
2
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
3
- }`,Hd=`void main() {
3
+ }`,Gd=`void main() {
4
4
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
5
- }`;class Un extends In{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Vd,this.fragmentShader=Hd,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=is(e.uniforms),this.uniformsGroups=kd(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const i in this.uniforms){const a=this.uniforms[i].value;a&&a.isTexture?t.uniforms[i]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[i]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[i]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[i]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[i]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[i]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[i]={type:"m4",value:a.toArray()}:t.uniforms[i]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const n in e.uniforms){const i=e.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=t[i.value]||null;break;case"c":this.uniforms[n].value=new Ue().setHex(i.value);break;case"v2":this.uniforms[n].value=new ke().fromArray(i.value);break;case"v3":this.uniforms[n].value=new C().fromArray(i.value);break;case"v4":this.uniforms[n].value=new gt().fromArray(i.value);break;case"m3":this.uniforms[n].value=new He().fromArray(i.value);break;case"m4":this.uniforms[n].value=new We().fromArray(i.value);break;default:this.uniforms[n].value=i.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(const n in e.extensions)this.extensions[n]=e.extensions[n];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class Gd extends Un{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class $i extends In{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Ue(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 Ue(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yo,this.normalScale=new ke(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ui,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class On extends $i{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new ke(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return $e(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Ue(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 Ue(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ue(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class Wd extends In{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Dh,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Xd extends In{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function fr(s,e){return!s||s.constructor===e?s:typeof e.BYTES_PER_ELEMENT=="number"?new e(s):Array.prototype.slice.call(s)}function Yd(s){function e(i,r){return s[i]-s[r]}const t=s.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function ec(s,e,t){const n=s.length,i=new s.constructor(n);for(let r=0,a=0;a!==n;++r){const o=t[r]*e;for(let l=0;l!==e;++l)i[a++]=s[o+l]}return i}function qd(s,e,t,n){let i=1,r=s[0];for(;r!==void 0&&r[n]===void 0;)r=s[i++];if(r===void 0)return;let a=r[n];if(a!==void 0)if(Array.isArray(a))do a=r[n],a!==void 0&&(e.push(r.time),t.push(...a)),r=s[i++];while(r!==void 0);else if(a.toArray!==void 0)do a=r[n],a!==void 0&&(e.push(r.time),a.toArray(t,t.length)),r=s[i++];while(r!==void 0);else do a=r[n],a!==void 0&&(e.push(r.time),t.push(a)),r=s[i++];while(r!==void 0)}class as{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],r=t[n-1];n:{e:{let a;t:{i:if(!(e<i)){for(let o=n+2;;){if(i===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=i,i=t[++n],e<i)break e}a=t.length;break t}if(!(e>=r)){const o=t[1];e<o&&(n=2,r=o);for(let l=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(i=r,r=t[--n-1],e>=r)break e}a=n,n=0;break t}break n}for(;n<a;){const o=n+a>>>1;e<t[o]?a=o:n=o+1}if(i=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let a=0;a!==i;++a)t[a]=n[r+a];return t}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class Kd extends as{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:vl,endingEnd:vl}}intervalChanged_(e,t,n){const i=this.parameterPositions;let r=e-2,a=e+1,o=i[r],l=i[a];if(o===void 0)switch(this.getSettings_().endingStart){case Ml:r=e,o=2*t-n;break;case Sl:r=i.length-2,o=t+i[r]-i[r+1];break;default:r=e,o=n}if(l===void 0)switch(this.getSettings_().endingEnd){case Ml:a=e,l=2*n-t;break;case Sl:a=1,l=n+i[1]-i[0];break;default:a=e-1,l=t}const c=(n-t)*.5,u=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(l-n),this._offsetPrev=r*u,this._offsetNext=a*u}interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,u=this._offsetPrev,h=this._offsetNext,d=this._weightPrev,f=this._weightNext,_=(n-t)/(i-t),v=_*_,m=v*_,p=-d*m+2*d*v-d*_,b=(1+d)*m+(-1.5-2*d)*v+(-.5+d)*_+1,T=(-1-f)*m+(1.5+f)*v+.5*_,S=f*m-f*v;for(let w=0;w!==o;++w)r[w]=p*a[u+w]+b*a[c+w]+T*a[l+w]+S*a[h+w];return r}}class Zd extends as{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,u=(n-t)/(i-t),h=1-u;for(let d=0;d!==o;++d)r[d]=a[c+d]*h+a[l+d]*u;return r}}class $d extends as{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class jd extends as{interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,u=this.inTangents,h=this.outTangents;if(!u||!h){const _=(n-t)/(i-t),v=1-_;for(let m=0;m!==o;++m)r[m]=a[c+m]*v+a[l+m]*_;return r}const d=o*2,f=e-1;for(let _=0;_!==o;++_){const v=a[c+_],m=a[l+_],p=f*d+_*2,b=h[p],T=h[p+1],S=e*d+_*2,w=u[S],E=u[S+1];let R=(n-t)/(i-t),x,A,D,P,F;for(let $=0;$<8;$++){x=R*R,A=x*R,D=1-R,P=D*D,F=P*D;const k=F*t+3*P*R*b+3*D*x*w+A*i-n;if(Math.abs(k)<1e-10)break;const q=3*P*(b-t)+6*D*R*(w-b)+3*x*(i-w);if(Math.abs(q)<1e-10)break;R=R-k/q,R=Math.max(0,Math.min(1,R))}r[_]=F*v+3*P*R*T+3*D*x*E+A*m}return r}}class yn{constructor(e,t,n,i){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=fr(t,this.TimeBufferType),this.values=fr(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:fr(e.times,Array),values:fr(e.values,Array)};const i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new $d(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Zd(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Kd(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){const t=new jd(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents),t}setInterpolation(e){let t;switch(e){case Us:t=this.InterpolantFactoryMethodDiscrete;break;case Fs:t=this.InterpolantFactoryMethodLinear;break;case qr:t=this.InterpolantFactoryMethodSmooth;break;case xl:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return Ie("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Us;case this.InterpolantFactoryMethodLinear:return Fs;case this.InterpolantFactoryMethodSmooth:return qr;case this.InterpolantFactoryMethodBezier:return xl}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){const n=this.times,i=n.length;let r=0,a=i-1;for(;r!==i&&n[r]<e;)++r;for(;a!==-1&&n[a]>t;)--a;if(++a,r!==0||a!==i){r>=a&&(a=Math.max(a,1),r=a-1);const o=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(r*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(ze("KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,r=n.length;r===0&&(ze("KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==r;o++){const l=n[o];if(typeof l=="number"&&isNaN(l)){ze("KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){ze("KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(i!==void 0&&Hh(i))for(let o=0,l=i.length;o!==l;++o){const c=i[o];if(isNaN(c)){ze("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===qr,r=e.length-1;let a=1;for(let o=1;o<r;++o){let l=!1;const c=e[o],u=e[o+1];if(c!==u&&(o!==1||c!==e[0]))if(i)l=!0;else{const h=o*n,d=h-n,f=h+n;for(let _=0;_!==n;++_){const v=t[h+_];if(v!==t[d+_]||v!==t[f+_]){l=!0;break}}}if(l){if(o!==a){e[a]=e[o];const h=o*n,d=a*n;for(let f=0;f!==n;++f)t[d+f]=t[h+f]}++a}}if(r>0){e[a]=e[r];for(let o=r*n,l=a*n,c=0;c!==n;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}yn.prototype.ValueTypeName="";yn.prototype.TimeBufferType=Float32Array;yn.prototype.ValueBufferType=Float32Array;yn.prototype.DefaultInterpolation=Fs;class os extends yn{constructor(e,t,n){super(e,t,n)}}os.prototype.ValueTypeName="bool";os.prototype.ValueBufferType=Array;os.prototype.DefaultInterpolation=Us;os.prototype.InterpolantFactoryMethodLinear=void 0;os.prototype.InterpolantFactoryMethodSmooth=void 0;class bu extends yn{constructor(e,t,n,i){super(e,t,n,i)}}bu.prototype.ValueTypeName="color";class ks extends yn{constructor(e,t,n,i){super(e,t,n,i)}}ks.prototype.ValueTypeName="number";class Jd extends as{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(n-t)/(i-t);let c=e*o;for(let u=c+o;c!==u;c+=4)Sn.slerpFlat(r,0,a,c-o,a,c,l);return r}}class zs extends yn{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new Jd(this.times,this.values,this.getValueSize(),e)}}zs.prototype.ValueTypeName="quaternion";zs.prototype.InterpolantFactoryMethodSmooth=void 0;class ls extends yn{constructor(e,t,n){super(e,t,n)}}ls.prototype.ValueTypeName="string";ls.prototype.ValueBufferType=Array;ls.prototype.DefaultInterpolation=Us;ls.prototype.InterpolantFactoryMethodLinear=void 0;ls.prototype.InterpolantFactoryMethodSmooth=void 0;class Ur extends yn{constructor(e,t,n,i){super(e,t,n,i)}}Ur.prototype.ValueTypeName="vector";class Qd{constructor(e="",t=-1,n=[],i=Lh){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Mn(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let a=0,o=n.length;a!==o;++a)t.push(tf(n[a]).scale(i));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let r=0,a=n.length;r!==a;++r)t.push(yn.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const r=t.length,a=[];for(let o=0;o<r;o++){let l=[],c=[];l.push((o+r-1)%r,o,(o+1)%r),c.push(0,1,0);const u=Yd(l);l=ec(l,1,u),c=ec(c,1,u),!i&&l[0]===0&&(l.push(r),c.push(c[0])),a.push(new ks(".morphTargetInfluences["+t[o].name+"]",l,c).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const i={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,l=e.length;o<l;o++){const c=e[o],u=c.name.match(r);if(u&&u.length>1){const h=u[1];let d=i[h];d||(i[h]=d=[]),d.push(c)}}const a=[];for(const o in i)a.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return a}resetDuration(){const e=this.tracks;let t=0;for(let n=0,i=e.length;n!==i;++n){const r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());const t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function ef(s){switch(s.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return ks;case"vector":case"vector2":case"vector3":case"vector4":return Ur;case"color":return bu;case"quaternion":return zs;case"bool":case"boolean":return os;case"string":return ls}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+s)}function tf(s){if(s.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=ef(s.type);if(s.times===void 0){const t=[],n=[];qd(s.keys,t,n,"value"),s.times=t,s.values=n}return e.parse!==void 0?e.parse(s):new e(s.name,s.times,s.values,s.interpolation)}const qn={enabled:!1,files:{},add:function(s,e){this.enabled!==!1&&(tc(s)||(this.files[s]=e))},get:function(s){if(this.enabled!==!1&&!tc(s))return this.files[s]},remove:function(s){delete this.files[s]},clear:function(){this.files={}}};function tc(s){try{const e=s.slice(s.indexOf(":")+1);return new URL(e).protocol==="blob:"}catch{return!1}}class nf{constructor(e,t,n){const i=this;let r=!1,a=0,o=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(u){o++,r===!1&&i.onStart!==void 0&&i.onStart(u,a,o),r=!0},this.itemEnd=function(u){a++,i.onProgress!==void 0&&i.onProgress(u,a,o),a===o&&(r=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(u){i.onError!==void 0&&i.onError(u)},this.resolveURL=function(u){return u=u.normalize("NFC"),l?l(u):u},this.setURLModifier=function(u){return l=u,this},this.addHandler=function(u,h){return c.push(u,h),this},this.removeHandler=function(u){const h=c.indexOf(u);return h!==-1&&c.splice(h,2),this},this.getHandler=function(u){for(let h=0,d=c.length;h<d;h+=2){const f=c[h],_=c[h+1];if(f.global&&(f.lastIndex=0),f.test(u))return _}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const sf=new nf;class Ti{constructor(e){this.manager=e!==void 0?e:sf,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){const n=this;return new Promise(function(i,r){n.load(e,i,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}Ti.DEFAULT_MATERIAL_NAME="__DEFAULT";const Wn={};class rf extends Error{constructor(e,t){super(e),this.response=t}}class tl extends Ti{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=qn.get(`file:${e}`);if(r!==void 0){this.manager.itemStart(e),setTimeout(()=>{t&&t(r),this.manager.itemEnd(e)},0);return}if(Wn[e]!==void 0){Wn[e].push({onLoad:t,onProgress:n,onError:i});return}Wn[e]=[],Wn[e].push({onLoad:t,onProgress:n,onError:i});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&Ie("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const u=Wn[e],h=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),f=d?parseInt(d):0,_=f!==0;let v=0;const m=new ReadableStream({start(p){b();function b(){h.read().then(({done:T,value:S})=>{if(T)p.close();else{v+=S.byteLength;const w=new ProgressEvent("progress",{lengthComputable:_,loaded:v,total:f});for(let E=0,R=u.length;E<R;E++){const x=u[E];x.onProgress&&x.onProgress(w)}p.enqueue(S),b()}},T=>{p.error(T)})}}});return new Response(m)}else throw new rf(`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(u=>new DOMParser().parseFromString(u,o));case"json":return c.json();default:if(o==="")return c.text();{const h=/charset="?([^;"\s]*)"?/i.exec(o),d=h&&h[1]?h[1].toLowerCase():void 0,f=new TextDecoder(d);return c.arrayBuffer().then(_=>f.decode(_))}}}).then(c=>{qn.add(`file:${e}`,c);const u=Wn[e];delete Wn[e];for(let h=0,d=u.length;h<d;h++){const f=u[h];f.onLoad&&f.onLoad(c)}}).catch(c=>{const u=Wn[e];if(u===void 0)throw this.manager.itemError(e),c;delete Wn[e];for(let h=0,d=u.length;h<d;h++){const f=u[h];f.onError&&f.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const Vi=new WeakMap;class af extends Ti{constructor(e){super(e)}load(e,t,n,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=qn.get(`image:${e}`);if(a!==void 0){if(a.complete===!0)r.manager.itemStart(e),setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0);else{let h=Vi.get(a);h===void 0&&(h=[],Vi.set(a,h)),h.push({onLoad:t,onError:i})}return a}const o=Bs("img");function l(){u(),t&&t(this);const h=Vi.get(this)||[];for(let d=0;d<h.length;d++){const f=h[d];f.onLoad&&f.onLoad(this)}Vi.delete(this),r.manager.itemEnd(e)}function c(h){u(),i&&i(h),qn.remove(`image:${e}`);const d=Vi.get(this)||[];for(let f=0;f<d.length;f++){const _=d[f];_.onError&&_.onError(h)}Vi.delete(this),r.manager.itemError(e),r.manager.itemEnd(e)}function u(){o.removeEventListener("load",l,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),qn.add(`image:${e}`,o),r.manager.itemStart(e),o.src=e,o}}class of extends Ti{constructor(e){super(e)}load(e,t,n,i){const r=new Gt,a=new af(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){r.image=o,r.needsUpdate=!0,t!==void 0&&t(r)},n,i),r}}class zr extends At{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ue(e),this.intensity=t}dispose(){this.dispatchEvent({type:"dispose"})}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}const va=new We,nc=new C,ic=new C;class nl{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ke(512,512),this.mapType=on,this.map=null,this.mapPass=null,this.matrix=new We,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new $o,this._frameExtents=new ke(1,1),this._viewportCount=1,this._viewports=[new gt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;nc.setFromMatrixPosition(e.matrixWorld),t.position.copy(nc),ic.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(ic),t.updateMatrixWorld(),va.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(va,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===Os||t.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(va)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}const pr=new C,mr=new Sn,En=new C;class Eu extends At{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new We,this.projectionMatrix=new We,this.projectionMatrixInverse=new We,this.coordinateSystem=Cn,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(pr,mr,En),En.x===1&&En.y===1&&En.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(pr,mr,En.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(pr,mr,En),En.x===1&&En.y===1&&En.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(pr,mr,En.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const ai=new C,sc=new ke,rc=new ke;class Qt extends Eu{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=ts*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Ps*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return ts*2*Math.atan(Math.tan(Ps*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){ai.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(ai.x,ai.y).multiplyScalar(-e/ai.z),ai.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(ai.x,ai.y).multiplyScalar(-e/ai.z)}getViewSize(e,t){return this.getViewBounds(e,sc,rc),t.subVectors(rc,sc)}setViewOffset(e,t,n,i,r,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Ps*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;r+=a.offsetX*i/l,t-=a.offsetY*n/c,i*=a.width/l,n*=a.height/c}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class lf extends nl{constructor(){super(new Qt(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,n=ts*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=e.distance||t.far;(n!==t.fov||i!==t.aspect||r!==t.far)&&(t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class cf extends zr{constructor(e,t,n=0,i=Math.PI/3,r=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(At.DEFAULT_UP),this.updateMatrix(),this.target=new At,this.distance=n,this.angle=i,this.penumbra=r,this.decay=a,this.map=null,this.shadow=new lf}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture&&(t.object.map=this.map.toJSON(e).uuid),t.object.shadow=this.shadow.toJSON(),t}}class uf extends nl{constructor(){super(new Qt(90,1,.5,500)),this.isPointLightShadow=!0}}class hf extends zr{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new uf}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class Vr extends Eu{constructor(e=-1,t=1,n=1,i=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-e,a=n+e,o=i+t,l=i-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,a=r+c*this.view.width,o-=u*this.view.offsetY,l=o-u*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class df extends nl{constructor(){super(new Vr(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Ao extends zr{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(At.DEFAULT_UP),this.updateMatrix(),this.target=new At,this.shadow=new df}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class ff extends zr{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Is{static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}const Ma=new WeakMap;class pf extends Ti{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&Ie("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&Ie("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=qn.get(`image-bitmap:${e}`);if(a!==void 0){if(r.manager.itemStart(e),a.then){a.then(c=>{Ma.has(a)===!0?(i&&i(Ma.get(a)),r.manager.itemError(e),r.manager.itemEnd(e)):(t&&t(c),r.manager.itemEnd(e))});return}setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0);return}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const l=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(c){qn.add(`image-bitmap:${e}`,c),t&&t(c),r.manager.itemEnd(e)}).catch(function(c){i&&i(c),Ma.set(l,c),qn.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});qn.add(`image-bitmap:${e}`,l),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const Hi=-90,Gi=1;class mf extends At{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Qt(Hi,Gi,e,t);i.layers=this.layers,this.add(i);const r=new Qt(Hi,Gi,e,t);r.layers=this.layers,this.add(r);const a=new Qt(Hi,Gi,e,t);a.layers=this.layers,this.add(a);const o=new Qt(Hi,Gi,e,t);o.layers=this.layers,this.add(o);const l=new Qt(Hi,Gi,e,t);l.layers=this.layers,this.add(l);const c=new Qt(Hi,Gi,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,r,a,o,l]=t;for(const c of t)this.remove(c);if(e===Cn)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Os)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,l,c,u]=this.children,h=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),_=e.xr.enabled;e.xr.enabled=!1;const v=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(n,0,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(n,1,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,2,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,3,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(n,4,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),n.texture.generateMipmaps=v,e.setRenderTarget(n,5,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,u),e.setRenderTarget(h,d,f),e.xr.enabled=_,n.texture.needsPMREMUpdate=!0}}class gf extends Qt{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const il="\\[\\]\\.:\\/",_f=new RegExp("["+il+"]","g"),sl="[^"+il+"]",xf="[^"+il.replace("\\.","")+"]",vf=/((?:WC+[\/:])*)/.source.replace("WC",sl),Mf=/(WCOD+)?/.source.replace("WCOD",xf),Sf=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",sl),yf=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",sl),bf=new RegExp("^"+vf+Mf+Sf+yf+"$"),Ef=["material","materials","bones","map"];class Tf{constructor(e,t,n){const i=n||dt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class dt{constructor(e,t,n){this.path=t,this.parsedPath=n||dt.parseTrackName(t),this.node=dt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new dt.Composite(e,t,n):new dt(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(_f,"")}static parseTrackName(e){const t=bf.exec(e);if(t===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const r=n.nodeName.substring(i+1);Ef.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(r){for(let a=0;a<r.length;a++){const o=r[a];if(o.name===t||o.uuid===t)return o;const l=n(o.children);if(l)return l}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,i=t.propertyName;let r=t.propertyIndex;if(e||(e=dt.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Ie("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){ze("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){ze("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){ze("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let u=0;u<e.length;u++)if(e[u].name===c){c=u;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){ze("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){ze("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){ze("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){ze("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const a=e[i];if(a===void 0){const c=t.nodeName;ze("PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){ze("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){ze("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=r}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}dt.Composite=Tf;dt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};dt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};dt.prototype.GetterByBindingType=[dt.prototype._getValue_direct,dt.prototype._getValue_array,dt.prototype._getValue_arrayElement,dt.prototype._getValue_toArray];dt.prototype.SetterByBindingTypeAndVersioning=[[dt.prototype._setValue_direct,dt.prototype._setValue_direct_setNeedsUpdate,dt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[dt.prototype._setValue_array,dt.prototype._setValue_array_setNeedsUpdate,dt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[dt.prototype._setValue_arrayElement,dt.prototype._setValue_arrayElement_setNeedsUpdate,dt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[dt.prototype._setValue_fromArray,dt.prototype._setValue_fromArray_setNeedsUpdate,dt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const ac=new We;class Af{constructor(e,t,n=0,i=1/0){this.ray=new rs(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new Yo,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,t.projectionMatrix.elements[14]).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):ze("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return ac.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(ac),this}intersectObject(e,t=!0,n=[]){return wo(e,this,n,t),n.sort(oc),n}intersectObjects(e,t=!0,n=[]){for(let i=0,r=e.length;i<r;i++)wo(e[i],this,n,t);return n.sort(oc),n}}function oc(s,e){return s.distance-e.distance}function wo(s,e,t,n){let i=!0;if(s.layers.test(e.layers)&&s.raycast(e,t)===!1&&(i=!1),i===!0&&n===!0){const r=s.children;for(let a=0,o=r.length;a<o;a++)wo(r[a],e,t,!0)}}class lc{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=$e(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos($e(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const ul=class ul{constructor(e,t,n,i){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,i){const r=this.elements;return r[0]=e,r[2]=t,r[1]=n,r[3]=i,this}};ul.prototype.isMatrix2=!0;let cc=ul;class wf extends Jo{constructor(e=10,t=10,n=4473924,i=8947848){n=new Ue(n),i=new Ue(i);const r=t/2,a=e/t,o=e/2,l=[],c=[];for(let d=0,f=0,_=-o;d<=t;d++,_+=a){l.push(-o,0,_,o,0,_),l.push(_,0,-o,_,0,o);const v=d===r?n:i;v.toArray(c,f),f+=3,v.toArray(c,f),f+=3,v.toArray(c,f),f+=3,v.toArray(c,f),f+=3}const u=new Wt;u.setAttribute("position",new Lt(l,3)),u.setAttribute("color",new Lt(c,3));const h=new Br({vertexColors:!0,toneMapped:!1});super(u,h),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const gr=new Yt;class Rf extends Jo{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Float32Array(24),r=new Wt;r.setIndex(new Nt(n,1)),r.setAttribute("position",new Nt(i,3)),super(r,new Br({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(this.object!==void 0&&gr.setFromObject(this.object),gr.isEmpty())return;const e=gr.min,t=gr.max,n=this.geometry.attributes.position,i=n.array;i[0]=t.x,i[1]=t.y,i[2]=t.z,i[3]=e.x,i[4]=t.y,i[5]=t.z,i[6]=e.x,i[7]=e.y,i[8]=t.z,i[9]=t.x,i[10]=e.y,i[11]=t.z,i[12]=t.x,i[13]=t.y,i[14]=e.z,i[15]=e.x,i[16]=t.y,i[17]=e.z,i[18]=e.x,i[19]=e.y,i[20]=e.z,i[21]=t.x,i[22]=e.y,i[23]=e.z,n.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Cf extends hi{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){Ie("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function uc(s,e,t,n){const i=Pf(n);switch(t){case cu:return s*e;case Bo:return s*e/i.components*i.byteLength;case ko:return s*e/i.components*i.byteLength;case Ei:return s*e*2/i.components*i.byteLength;case zo:return s*e*2/i.components*i.byteLength;case uu:return s*e*3/i.components*i.byteLength;case pn:return s*e*4/i.components*i.byteLength;case Vo:return s*e*4/i.components*i.byteLength;case br:case Er:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case Tr:case Ar:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Xa:case qa:return Math.max(s,16)*Math.max(e,8)/4;case Wa:case Ya:return Math.max(s,8)*Math.max(e,8)/2;case Ka:case Za:case ja:case Ja:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case $a:case Cr:case Qa:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case eo:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case to:return Math.floor((s+4)/5)*Math.floor((e+3)/4)*16;case no:return Math.floor((s+4)/5)*Math.floor((e+4)/5)*16;case io:return Math.floor((s+5)/6)*Math.floor((e+4)/5)*16;case so:return Math.floor((s+5)/6)*Math.floor((e+5)/6)*16;case ro:return Math.floor((s+7)/8)*Math.floor((e+4)/5)*16;case ao:return Math.floor((s+7)/8)*Math.floor((e+5)/6)*16;case oo:return Math.floor((s+7)/8)*Math.floor((e+7)/8)*16;case lo:return Math.floor((s+9)/10)*Math.floor((e+4)/5)*16;case co:return Math.floor((s+9)/10)*Math.floor((e+5)/6)*16;case uo:return Math.floor((s+9)/10)*Math.floor((e+7)/8)*16;case ho:return Math.floor((s+9)/10)*Math.floor((e+9)/10)*16;case fo:return Math.floor((s+11)/12)*Math.floor((e+9)/10)*16;case po:return Math.floor((s+11)/12)*Math.floor((e+11)/12)*16;case mo:case go:case _o:return Math.ceil(s/4)*Math.ceil(e/4)*16;case xo:case vo:return Math.ceil(s/4)*Math.ceil(e/4)*8;case Pr:case Mo:return Math.ceil(s/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Pf(s){switch(s){case on:case ru:return{byteLength:1,components:1};case Ds:case au:case $n:return{byteLength:2,components:1};case Fo:case Oo:return{byteLength:2,components:4};case Nn:case Uo:case fn:return{byteLength:4,components:1};case ou:case lu:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${s}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:No}}));typeof window<"u"&&(window.__THREE__?Ie("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=No);function Tu(){let s=null,e=!1,t=null,n=null;function i(r,a){t(r,a),n=s.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&s!==null&&(n=s.requestAnimationFrame(i),e=!0)},stop:function(){s!==null&&s.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){s=r}}}function Lf(s){const e=new WeakMap;function t(o,l){const c=o.array,u=o.usage,h=c.byteLength,d=s.createBuffer();s.bindBuffer(l,d),s.bufferData(l,c,u),o.onUploadCallback();let f;if(c instanceof Float32Array)f=s.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)f=s.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?f=s.HALF_FLOAT:f=s.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=s.SHORT;else if(c instanceof Uint32Array)f=s.UNSIGNED_INT;else if(c instanceof Int32Array)f=s.INT;else if(c instanceof Int8Array)f=s.BYTE;else if(c instanceof Uint8Array)f=s.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:d,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:h}}function n(o,l,c){const u=l.array,h=l.updateRanges;if(s.bindBuffer(c,o),h.length===0)s.bufferSubData(c,0,u);else{h.sort((f,_)=>f.start-_.start);let d=0;for(let f=1;f<h.length;f++){const _=h[d],v=h[f];v.start<=_.start+_.count+1?_.count=Math.max(_.count,v.start+v.count-_.start):(++d,h[d]=v)}h.length=d+1;for(let f=0,_=h.length;f<_;f++){const v=h[f];s.bufferSubData(c,v.start*u.BYTES_PER_ELEMENT,u,v.start,v.count)}l.clearUpdateRanges()}l.onUploadCallback()}function i(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function r(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(s.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const u=e.get(o);(!u||u.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const c=e.get(o);if(c===void 0)e.set(o,t(o,l));else if(c.version<o.version){if(c.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(c.buffer,o,l),c.version=o.version}}return{get:i,remove:r,update:a}}var If=`#ifdef USE_ALPHAHASH
5
+ }`;class Un extends In{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Hd,this.fragmentShader=Gd,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=is(e.uniforms),this.uniformsGroups=zd(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const i in this.uniforms){const a=this.uniforms[i].value;a&&a.isTexture?t.uniforms[i]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[i]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[i]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[i]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[i]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[i]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[i]={type:"m4",value:a.toArray()}:t.uniforms[i]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const n in e.uniforms){const i=e.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=t[i.value]||null;break;case"c":this.uniforms[n].value=new Ue().setHex(i.value);break;case"v2":this.uniforms[n].value=new ke().fromArray(i.value);break;case"v3":this.uniforms[n].value=new C().fromArray(i.value);break;case"v4":this.uniforms[n].value=new gt().fromArray(i.value);break;case"m3":this.uniforms[n].value=new He().fromArray(i.value);break;case"m4":this.uniforms[n].value=new We().fromArray(i.value);break;default:this.uniforms[n].value=i.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(const n in e.extensions)this.extensions[n]=e.extensions[n];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class Wd extends Un{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class $i extends In{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Ue(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 Ue(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yo,this.normalScale=new ke(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ui,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class On extends $i{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new ke(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return $e(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Ue(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 Ue(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ue(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class Xd extends In{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Nh,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Yd extends In{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function fr(s,e){return!s||s.constructor===e?s:typeof e.BYTES_PER_ELEMENT=="number"?new e(s):Array.prototype.slice.call(s)}function qd(s){function e(i,r){return s[i]-s[r]}const t=s.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function ec(s,e,t){const n=s.length,i=new s.constructor(n);for(let r=0,a=0;a!==n;++r){const o=t[r]*e;for(let l=0;l!==e;++l)i[a++]=s[o+l]}return i}function Kd(s,e,t,n){let i=1,r=s[0];for(;r!==void 0&&r[n]===void 0;)r=s[i++];if(r===void 0)return;let a=r[n];if(a!==void 0)if(Array.isArray(a))do a=r[n],a!==void 0&&(e.push(r.time),t.push(...a)),r=s[i++];while(r!==void 0);else if(a.toArray!==void 0)do a=r[n],a!==void 0&&(e.push(r.time),a.toArray(t,t.length)),r=s[i++];while(r!==void 0);else do a=r[n],a!==void 0&&(e.push(r.time),t.push(a)),r=s[i++];while(r!==void 0)}class as{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],r=t[n-1];n:{e:{let a;t:{i:if(!(e<i)){for(let o=n+2;;){if(i===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=i,i=t[++n],e<i)break e}a=t.length;break t}if(!(e>=r)){const o=t[1];e<o&&(n=2,r=o);for(let l=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(i=r,r=t[--n-1],e>=r)break e}a=n,n=0;break t}break n}for(;n<a;){const o=n+a>>>1;e<t[o]?a=o:n=o+1}if(i=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let a=0;a!==i;++a)t[a]=n[r+a];return t}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class Zd extends as{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:vl,endingEnd:vl}}intervalChanged_(e,t,n){const i=this.parameterPositions;let r=e-2,a=e+1,o=i[r],l=i[a];if(o===void 0)switch(this.getSettings_().endingStart){case Ml:r=e,o=2*t-n;break;case Sl:r=i.length-2,o=t+i[r]-i[r+1];break;default:r=e,o=n}if(l===void 0)switch(this.getSettings_().endingEnd){case Ml:a=e,l=2*n-t;break;case Sl:a=1,l=n+i[1]-i[0];break;default:a=e-1,l=t}const c=(n-t)*.5,u=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(l-n),this._offsetPrev=r*u,this._offsetNext=a*u}interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,u=this._offsetPrev,h=this._offsetNext,d=this._weightPrev,f=this._weightNext,_=(n-t)/(i-t),v=_*_,m=v*_,p=-d*m+2*d*v-d*_,b=(1+d)*m+(-1.5-2*d)*v+(-.5+d)*_+1,T=(-1-f)*m+(1.5+f)*v+.5*_,S=f*m-f*v;for(let w=0;w!==o;++w)r[w]=p*a[u+w]+b*a[c+w]+T*a[l+w]+S*a[h+w];return r}}class $d extends as{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,u=(n-t)/(i-t),h=1-u;for(let d=0;d!==o;++d)r[d]=a[c+d]*h+a[l+d]*u;return r}}class jd extends as{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class Jd extends as{interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=e*o,c=l-o,u=this.inTangents,h=this.outTangents;if(!u||!h){const _=(n-t)/(i-t),v=1-_;for(let m=0;m!==o;++m)r[m]=a[c+m]*v+a[l+m]*_;return r}const d=o*2,f=e-1;for(let _=0;_!==o;++_){const v=a[c+_],m=a[l+_],p=f*d+_*2,b=h[p],T=h[p+1],S=e*d+_*2,w=u[S],E=u[S+1];let R=(n-t)/(i-t),x,A,D,P,F;for(let $=0;$<8;$++){x=R*R,A=x*R,D=1-R,P=D*D,F=P*D;const k=F*t+3*P*R*b+3*D*x*w+A*i-n;if(Math.abs(k)<1e-10)break;const q=3*P*(b-t)+6*D*R*(w-b)+3*x*(i-w);if(Math.abs(q)<1e-10)break;R=R-k/q,R=Math.max(0,Math.min(1,R))}r[_]=F*v+3*P*R*T+3*D*x*E+A*m}return r}}class yn{constructor(e,t,n,i){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=fr(t,this.TimeBufferType),this.values=fr(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:fr(e.times,Array),values:fr(e.values,Array)};const i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new jd(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new $d(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Zd(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){const t=new Jd(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents),t}setInterpolation(e){let t;switch(e){case Us:t=this.InterpolantFactoryMethodDiscrete;break;case Fs:t=this.InterpolantFactoryMethodLinear;break;case qr:t=this.InterpolantFactoryMethodSmooth;break;case xl:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return Ie("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Us;case this.InterpolantFactoryMethodLinear:return Fs;case this.InterpolantFactoryMethodSmooth:return qr;case this.InterpolantFactoryMethodBezier:return xl}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){const n=this.times,i=n.length;let r=0,a=i-1;for(;r!==i&&n[r]<e;)++r;for(;a!==-1&&n[a]>t;)--a;if(++a,r!==0||a!==i){r>=a&&(a=Math.max(a,1),r=a-1);const o=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(r*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(ze("KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,r=n.length;r===0&&(ze("KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==r;o++){const l=n[o];if(typeof l=="number"&&isNaN(l)){ze("KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){ze("KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(i!==void 0&&Gh(i))for(let o=0,l=i.length;o!==l;++o){const c=i[o];if(isNaN(c)){ze("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===qr,r=e.length-1;let a=1;for(let o=1;o<r;++o){let l=!1;const c=e[o],u=e[o+1];if(c!==u&&(o!==1||c!==e[0]))if(i)l=!0;else{const h=o*n,d=h-n,f=h+n;for(let _=0;_!==n;++_){const v=t[h+_];if(v!==t[d+_]||v!==t[f+_]){l=!0;break}}}if(l){if(o!==a){e[a]=e[o];const h=o*n,d=a*n;for(let f=0;f!==n;++f)t[d+f]=t[h+f]}++a}}if(r>0){e[a]=e[r];for(let o=r*n,l=a*n,c=0;c!==n;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}yn.prototype.ValueTypeName="";yn.prototype.TimeBufferType=Float32Array;yn.prototype.ValueBufferType=Float32Array;yn.prototype.DefaultInterpolation=Fs;class os extends yn{constructor(e,t,n){super(e,t,n)}}os.prototype.ValueTypeName="bool";os.prototype.ValueBufferType=Array;os.prototype.DefaultInterpolation=Us;os.prototype.InterpolantFactoryMethodLinear=void 0;os.prototype.InterpolantFactoryMethodSmooth=void 0;class bu extends yn{constructor(e,t,n,i){super(e,t,n,i)}}bu.prototype.ValueTypeName="color";class ks extends yn{constructor(e,t,n,i){super(e,t,n,i)}}ks.prototype.ValueTypeName="number";class Qd extends as{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(n-t)/(i-t);let c=e*o;for(let u=c+o;c!==u;c+=4)Sn.slerpFlat(r,0,a,c-o,a,c,l);return r}}class zs extends yn{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new Qd(this.times,this.values,this.getValueSize(),e)}}zs.prototype.ValueTypeName="quaternion";zs.prototype.InterpolantFactoryMethodSmooth=void 0;class ls extends yn{constructor(e,t,n){super(e,t,n)}}ls.prototype.ValueTypeName="string";ls.prototype.ValueBufferType=Array;ls.prototype.DefaultInterpolation=Us;ls.prototype.InterpolantFactoryMethodLinear=void 0;ls.prototype.InterpolantFactoryMethodSmooth=void 0;class Ur extends yn{constructor(e,t,n,i){super(e,t,n,i)}}Ur.prototype.ValueTypeName="vector";class ef{constructor(e="",t=-1,n=[],i=Ih){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Mn(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let a=0,o=n.length;a!==o;++a)t.push(nf(n[a]).scale(i));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let r=0,a=n.length;r!==a;++r)t.push(yn.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const r=t.length,a=[];for(let o=0;o<r;o++){let l=[],c=[];l.push((o+r-1)%r,o,(o+1)%r),c.push(0,1,0);const u=qd(l);l=ec(l,1,u),c=ec(c,1,u),!i&&l[0]===0&&(l.push(r),c.push(c[0])),a.push(new ks(".morphTargetInfluences["+t[o].name+"]",l,c).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const i={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,l=e.length;o<l;o++){const c=e[o],u=c.name.match(r);if(u&&u.length>1){const h=u[1];let d=i[h];d||(i[h]=d=[]),d.push(c)}}const a=[];for(const o in i)a.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return a}resetDuration(){const e=this.tracks;let t=0;for(let n=0,i=e.length;n!==i;++n){const r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());const t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function tf(s){switch(s.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return ks;case"vector":case"vector2":case"vector3":case"vector4":return Ur;case"color":return bu;case"quaternion":return zs;case"bool":case"boolean":return os;case"string":return ls}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+s)}function nf(s){if(s.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=tf(s.type);if(s.times===void 0){const t=[],n=[];Kd(s.keys,t,n,"value"),s.times=t,s.values=n}return e.parse!==void 0?e.parse(s):new e(s.name,s.times,s.values,s.interpolation)}const qn={enabled:!1,files:{},add:function(s,e){this.enabled!==!1&&(tc(s)||(this.files[s]=e))},get:function(s){if(this.enabled!==!1&&!tc(s))return this.files[s]},remove:function(s){delete this.files[s]},clear:function(){this.files={}}};function tc(s){try{const e=s.slice(s.indexOf(":")+1);return new URL(e).protocol==="blob:"}catch{return!1}}class sf{constructor(e,t,n){const i=this;let r=!1,a=0,o=0,l;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(u){o++,r===!1&&i.onStart!==void 0&&i.onStart(u,a,o),r=!0},this.itemEnd=function(u){a++,i.onProgress!==void 0&&i.onProgress(u,a,o),a===o&&(r=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(u){i.onError!==void 0&&i.onError(u)},this.resolveURL=function(u){return u=u.normalize("NFC"),l?l(u):u},this.setURLModifier=function(u){return l=u,this},this.addHandler=function(u,h){return c.push(u,h),this},this.removeHandler=function(u){const h=c.indexOf(u);return h!==-1&&c.splice(h,2),this},this.getHandler=function(u){for(let h=0,d=c.length;h<d;h+=2){const f=c[h],_=c[h+1];if(f.global&&(f.lastIndex=0),f.test(u))return _}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const rf=new sf;class Ti{constructor(e){this.manager=e!==void 0?e:rf,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){const n=this;return new Promise(function(i,r){n.load(e,i,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}Ti.DEFAULT_MATERIAL_NAME="__DEFAULT";const Wn={};class af extends Error{constructor(e,t){super(e),this.response=t}}class tl extends Ti{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=qn.get(`file:${e}`);if(r!==void 0){this.manager.itemStart(e),setTimeout(()=>{t&&t(r),this.manager.itemEnd(e)},0);return}if(Wn[e]!==void 0){Wn[e].push({onLoad:t,onProgress:n,onError:i});return}Wn[e]=[],Wn[e].push({onLoad:t,onProgress:n,onError:i});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&Ie("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const u=Wn[e],h=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),f=d?parseInt(d):0,_=f!==0;let v=0;const m=new ReadableStream({start(p){b();function b(){h.read().then(({done:T,value:S})=>{if(T)p.close();else{v+=S.byteLength;const w=new ProgressEvent("progress",{lengthComputable:_,loaded:v,total:f});for(let E=0,R=u.length;E<R;E++){const x=u[E];x.onProgress&&x.onProgress(w)}p.enqueue(S),b()}},T=>{p.error(T)})}}});return new Response(m)}else throw new af(`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(u=>new DOMParser().parseFromString(u,o));case"json":return c.json();default:if(o==="")return c.text();{const h=/charset="?([^;"\s]*)"?/i.exec(o),d=h&&h[1]?h[1].toLowerCase():void 0,f=new TextDecoder(d);return c.arrayBuffer().then(_=>f.decode(_))}}}).then(c=>{qn.add(`file:${e}`,c);const u=Wn[e];delete Wn[e];for(let h=0,d=u.length;h<d;h++){const f=u[h];f.onLoad&&f.onLoad(c)}}).catch(c=>{const u=Wn[e];if(u===void 0)throw this.manager.itemError(e),c;delete Wn[e];for(let h=0,d=u.length;h<d;h++){const f=u[h];f.onError&&f.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const Vi=new WeakMap;class of extends Ti{constructor(e){super(e)}load(e,t,n,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=qn.get(`image:${e}`);if(a!==void 0){if(a.complete===!0)r.manager.itemStart(e),setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0);else{let h=Vi.get(a);h===void 0&&(h=[],Vi.set(a,h)),h.push({onLoad:t,onError:i})}return a}const o=Bs("img");function l(){u(),t&&t(this);const h=Vi.get(this)||[];for(let d=0;d<h.length;d++){const f=h[d];f.onLoad&&f.onLoad(this)}Vi.delete(this),r.manager.itemEnd(e)}function c(h){u(),i&&i(h),qn.remove(`image:${e}`);const d=Vi.get(this)||[];for(let f=0;f<d.length;f++){const _=d[f];_.onError&&_.onError(h)}Vi.delete(this),r.manager.itemError(e),r.manager.itemEnd(e)}function u(){o.removeEventListener("load",l,!1),o.removeEventListener("error",c,!1)}return o.addEventListener("load",l,!1),o.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),qn.add(`image:${e}`,o),r.manager.itemStart(e),o.src=e,o}}class lf extends Ti{constructor(e){super(e)}load(e,t,n,i){const r=new Gt,a=new of(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){r.image=o,r.needsUpdate=!0,t!==void 0&&t(r)},n,i),r}}class zr extends At{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ue(e),this.intensity=t}dispose(){this.dispatchEvent({type:"dispose"})}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}const va=new We,nc=new C,ic=new C;class nl{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ke(512,512),this.mapType=on,this.map=null,this.mapPass=null,this.matrix=new We,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new $o,this._frameExtents=new ke(1,1),this._viewportCount=1,this._viewports=[new gt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;nc.setFromMatrixPosition(e.matrixWorld),t.position.copy(nc),ic.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(ic),t.updateMatrixWorld(),va.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(va,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===Os||t.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(va)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}const pr=new C,mr=new Sn,En=new C;class Eu extends At{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new We,this.projectionMatrix=new We,this.projectionMatrixInverse=new We,this.coordinateSystem=Cn,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(pr,mr,En),En.x===1&&En.y===1&&En.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(pr,mr,En.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(pr,mr,En),En.x===1&&En.y===1&&En.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(pr,mr,En.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const ai=new C,sc=new ke,rc=new ke;class Qt extends Eu{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=ts*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Ps*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return ts*2*Math.atan(Math.tan(Ps*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){ai.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(ai.x,ai.y).multiplyScalar(-e/ai.z),ai.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(ai.x,ai.y).multiplyScalar(-e/ai.z)}getViewSize(e,t){return this.getViewBounds(e,sc,rc),t.subVectors(rc,sc)}setViewOffset(e,t,n,i,r,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Ps*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;r+=a.offsetX*i/l,t-=a.offsetY*n/c,i*=a.width/l,n*=a.height/c}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class cf extends nl{constructor(){super(new Qt(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,n=ts*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=e.distance||t.far;(n!==t.fov||i!==t.aspect||r!==t.far)&&(t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class uf extends zr{constructor(e,t,n=0,i=Math.PI/3,r=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(At.DEFAULT_UP),this.updateMatrix(),this.target=new At,this.distance=n,this.angle=i,this.penumbra=r,this.decay=a,this.map=null,this.shadow=new cf}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture&&(t.object.map=this.map.toJSON(e).uuid),t.object.shadow=this.shadow.toJSON(),t}}class hf extends nl{constructor(){super(new Qt(90,1,.5,500)),this.isPointLightShadow=!0}}class df extends zr{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new hf}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class Vr extends Eu{constructor(e=-1,t=1,n=1,i=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-e,a=n+e,o=i+t,l=i-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,a=r+c*this.view.width,o-=u*this.view.offsetY,l=o-u*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class ff extends nl{constructor(){super(new Vr(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Ao extends zr{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(At.DEFAULT_UP),this.updateMatrix(),this.target=new At,this.shadow=new ff}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class pf extends zr{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Is{static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}const Ma=new WeakMap;class mf extends Ti{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&Ie("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&Ie("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=qn.get(`image-bitmap:${e}`);if(a!==void 0){if(r.manager.itemStart(e),a.then){a.then(c=>{Ma.has(a)===!0?(i&&i(Ma.get(a)),r.manager.itemError(e),r.manager.itemEnd(e)):(t&&t(c),r.manager.itemEnd(e))});return}setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0);return}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const l=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(c){qn.add(`image-bitmap:${e}`,c),t&&t(c),r.manager.itemEnd(e)}).catch(function(c){i&&i(c),Ma.set(l,c),qn.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});qn.add(`image-bitmap:${e}`,l),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const Hi=-90,Gi=1;class gf extends At{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Qt(Hi,Gi,e,t);i.layers=this.layers,this.add(i);const r=new Qt(Hi,Gi,e,t);r.layers=this.layers,this.add(r);const a=new Qt(Hi,Gi,e,t);a.layers=this.layers,this.add(a);const o=new Qt(Hi,Gi,e,t);o.layers=this.layers,this.add(o);const l=new Qt(Hi,Gi,e,t);l.layers=this.layers,this.add(l);const c=new Qt(Hi,Gi,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,r,a,o,l]=t;for(const c of t)this.remove(c);if(e===Cn)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Os)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,l,c,u]=this.children,h=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),_=e.xr.enabled;e.xr.enabled=!1;const v=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(n,0,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(n,1,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,2,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,3,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(n,4,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),n.texture.generateMipmaps=v,e.setRenderTarget(n,5,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,u),e.setRenderTarget(h,d,f),e.xr.enabled=_,n.texture.needsPMREMUpdate=!0}}class _f extends Qt{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const il="\\[\\]\\.:\\/",xf=new RegExp("["+il+"]","g"),sl="[^"+il+"]",vf="[^"+il.replace("\\.","")+"]",Mf=/((?:WC+[\/:])*)/.source.replace("WC",sl),Sf=/(WCOD+)?/.source.replace("WCOD",vf),yf=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",sl),bf=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",sl),Ef=new RegExp("^"+Mf+Sf+yf+bf+"$"),Tf=["material","materials","bones","map"];class Af{constructor(e,t,n){const i=n||dt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class dt{constructor(e,t,n){this.path=t,this.parsedPath=n||dt.parseTrackName(t),this.node=dt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new dt.Composite(e,t,n):new dt(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(xf,"")}static parseTrackName(e){const t=Ef.exec(e);if(t===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const r=n.nodeName.substring(i+1);Tf.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(r){for(let a=0;a<r.length;a++){const o=r[a];if(o.name===t||o.uuid===t)return o;const l=n(o.children);if(l)return l}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,i=t.propertyName;let r=t.propertyIndex;if(e||(e=dt.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Ie("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){ze("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){ze("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){ze("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let u=0;u<e.length;u++)if(e[u].name===c){c=u;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){ze("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){ze("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){ze("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){ze("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const a=e[i];if(a===void 0){const c=t.nodeName;ze("PropertyBinding: Trying to update property for track: "+c+"."+i+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){ze("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){ze("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}l=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=r}else a.fromArray!==void 0&&a.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(l=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=i;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}dt.Composite=Af;dt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};dt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};dt.prototype.GetterByBindingType=[dt.prototype._getValue_direct,dt.prototype._getValue_array,dt.prototype._getValue_arrayElement,dt.prototype._getValue_toArray];dt.prototype.SetterByBindingTypeAndVersioning=[[dt.prototype._setValue_direct,dt.prototype._setValue_direct_setNeedsUpdate,dt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[dt.prototype._setValue_array,dt.prototype._setValue_array_setNeedsUpdate,dt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[dt.prototype._setValue_arrayElement,dt.prototype._setValue_arrayElement_setNeedsUpdate,dt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[dt.prototype._setValue_fromArray,dt.prototype._setValue_fromArray_setNeedsUpdate,dt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const ac=new We;class wf{constructor(e,t,n=0,i=1/0){this.ray=new rs(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new Yo,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,t.projectionMatrix.elements[14]).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):ze("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return ac.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(ac),this}intersectObject(e,t=!0,n=[]){return wo(e,this,n,t),n.sort(oc),n}intersectObjects(e,t=!0,n=[]){for(let i=0,r=e.length;i<r;i++)wo(e[i],this,n,t);return n.sort(oc),n}}function oc(s,e){return s.distance-e.distance}function wo(s,e,t,n){let i=!0;if(s.layers.test(e.layers)&&s.raycast(e,t)===!1&&(i=!1),i===!0&&n===!0){const r=s.children;for(let a=0,o=r.length;a<o;a++)wo(r[a],e,t,!0)}}class lc{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=$e(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos($e(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const ul=class ul{constructor(e,t,n,i){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,i){const r=this.elements;return r[0]=e,r[2]=t,r[1]=n,r[3]=i,this}};ul.prototype.isMatrix2=!0;let cc=ul;class Rf extends Jo{constructor(e=10,t=10,n=4473924,i=8947848){n=new Ue(n),i=new Ue(i);const r=t/2,a=e/t,o=e/2,l=[],c=[];for(let d=0,f=0,_=-o;d<=t;d++,_+=a){l.push(-o,0,_,o,0,_),l.push(_,0,-o,_,0,o);const v=d===r?n:i;v.toArray(c,f),f+=3,v.toArray(c,f),f+=3,v.toArray(c,f),f+=3,v.toArray(c,f),f+=3}const u=new Wt;u.setAttribute("position",new Lt(l,3)),u.setAttribute("color",new Lt(c,3));const h=new Br({vertexColors:!0,toneMapped:!1});super(u,h),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const gr=new Yt;class Cf extends Jo{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Float32Array(24),r=new Wt;r.setIndex(new Nt(n,1)),r.setAttribute("position",new Nt(i,3)),super(r,new Br({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(this.object!==void 0&&gr.setFromObject(this.object),gr.isEmpty())return;const e=gr.min,t=gr.max,n=this.geometry.attributes.position,i=n.array;i[0]=t.x,i[1]=t.y,i[2]=t.z,i[3]=e.x,i[4]=t.y,i[5]=t.z,i[6]=e.x,i[7]=e.y,i[8]=t.z,i[9]=t.x,i[10]=e.y,i[11]=t.z,i[12]=t.x,i[13]=t.y,i[14]=e.z,i[15]=e.x,i[16]=t.y,i[17]=e.z,i[18]=e.x,i[19]=e.y,i[20]=e.z,i[21]=t.x,i[22]=e.y,i[23]=e.z,n.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Pf extends hi{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){Ie("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function uc(s,e,t,n){const i=Lf(n);switch(t){case cu:return s*e;case Bo:return s*e/i.components*i.byteLength;case ko:return s*e/i.components*i.byteLength;case Ei:return s*e*2/i.components*i.byteLength;case zo:return s*e*2/i.components*i.byteLength;case uu:return s*e*3/i.components*i.byteLength;case pn:return s*e*4/i.components*i.byteLength;case Vo:return s*e*4/i.components*i.byteLength;case br:case Er:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case Tr:case Ar:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Xa:case qa:return Math.max(s,16)*Math.max(e,8)/4;case Wa:case Ya:return Math.max(s,8)*Math.max(e,8)/2;case Ka:case Za:case ja:case Ja:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case $a:case Cr:case Qa:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case eo:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case to:return Math.floor((s+4)/5)*Math.floor((e+3)/4)*16;case no:return Math.floor((s+4)/5)*Math.floor((e+4)/5)*16;case io:return Math.floor((s+5)/6)*Math.floor((e+4)/5)*16;case so:return Math.floor((s+5)/6)*Math.floor((e+5)/6)*16;case ro:return Math.floor((s+7)/8)*Math.floor((e+4)/5)*16;case ao:return Math.floor((s+7)/8)*Math.floor((e+5)/6)*16;case oo:return Math.floor((s+7)/8)*Math.floor((e+7)/8)*16;case lo:return Math.floor((s+9)/10)*Math.floor((e+4)/5)*16;case co:return Math.floor((s+9)/10)*Math.floor((e+5)/6)*16;case uo:return Math.floor((s+9)/10)*Math.floor((e+7)/8)*16;case ho:return Math.floor((s+9)/10)*Math.floor((e+9)/10)*16;case fo:return Math.floor((s+11)/12)*Math.floor((e+9)/10)*16;case po:return Math.floor((s+11)/12)*Math.floor((e+11)/12)*16;case mo:case go:case _o:return Math.ceil(s/4)*Math.ceil(e/4)*16;case xo:case vo:return Math.ceil(s/4)*Math.ceil(e/4)*8;case Pr:case Mo:return Math.ceil(s/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Lf(s){switch(s){case on:case ru:return{byteLength:1,components:1};case Ds:case au:case $n:return{byteLength:2,components:1};case Fo:case Oo:return{byteLength:2,components:4};case Nn:case Uo:case fn:return{byteLength:4,components:1};case ou:case lu:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${s}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:No}}));typeof window<"u"&&(window.__THREE__?Ie("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=No);function Tu(){let s=null,e=!1,t=null,n=null;function i(r,a){t(r,a),n=s.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&s!==null&&(n=s.requestAnimationFrame(i),e=!0)},stop:function(){s!==null&&s.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){s=r}}}function If(s){const e=new WeakMap;function t(o,l){const c=o.array,u=o.usage,h=c.byteLength,d=s.createBuffer();s.bindBuffer(l,d),s.bufferData(l,c,u),o.onUploadCallback();let f;if(c instanceof Float32Array)f=s.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)f=s.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?f=s.HALF_FLOAT:f=s.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=s.SHORT;else if(c instanceof Uint32Array)f=s.UNSIGNED_INT;else if(c instanceof Int32Array)f=s.INT;else if(c instanceof Int8Array)f=s.BYTE;else if(c instanceof Uint8Array)f=s.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:d,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:h}}function n(o,l,c){const u=l.array,h=l.updateRanges;if(s.bindBuffer(c,o),h.length===0)s.bufferSubData(c,0,u);else{h.sort((f,_)=>f.start-_.start);let d=0;for(let f=1;f<h.length;f++){const _=h[d],v=h[f];v.start<=_.start+_.count+1?_.count=Math.max(_.count,v.start+v.count-_.start):(++d,h[d]=v)}h.length=d+1;for(let f=0,_=h.length;f<_;f++){const v=h[f];s.bufferSubData(c,v.start*u.BYTES_PER_ELEMENT,u,v.start,v.count)}l.clearUpdateRanges()}l.onUploadCallback()}function i(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function r(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(s.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const u=e.get(o);(!u||u.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const c=e.get(o);if(c===void 0)e.set(o,t(o,l));else if(c.version<o.version){if(c.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(c.buffer,o,l),c.version=o.version}}return{get:i,remove:r,update:a}}var Df=`#ifdef USE_ALPHAHASH
6
6
  if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
7
- #endif`,Df=`#ifdef USE_ALPHAHASH
7
+ #endif`,Nf=`#ifdef USE_ALPHAHASH
8
8
  const float ALPHA_HASH_SCALE = 0.05;
9
9
  float hash2D( vec2 value ) {
10
10
  return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
@@ -39,20 +39,20 @@ import{a6 as ss,cM as Do,bi as ie,X as Da,g as ku}from"./app-DnjpR35Q.js";import
39
39
  : cases.z;
40
40
  return clamp( threshold , 1.0e-6, 1.0 );
41
41
  }
42
- #endif`,Nf=`#ifdef USE_ALPHAMAP
43
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
44
42
  #endif`,Uf=`#ifdef USE_ALPHAMAP
43
+ diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
44
+ #endif`,Ff=`#ifdef USE_ALPHAMAP
45
45
  uniform sampler2D alphaMap;
46
- #endif`,Ff=`#ifdef USE_ALPHATEST
46
+ #endif`,Of=`#ifdef USE_ALPHATEST
47
47
  #ifdef ALPHA_TO_COVERAGE
48
48
  diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
49
49
  if ( diffuseColor.a == 0.0 ) discard;
50
50
  #else
51
51
  if ( diffuseColor.a < alphaTest ) discard;
52
52
  #endif
53
- #endif`,Of=`#ifdef USE_ALPHATEST
53
+ #endif`,Bf=`#ifdef USE_ALPHATEST
54
54
  uniform float alphaTest;
55
- #endif`,Bf=`#ifdef USE_AOMAP
55
+ #endif`,kf=`#ifdef USE_AOMAP
56
56
  float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
57
57
  reflectedLight.indirectDiffuse *= ambientOcclusion;
58
58
  #if defined( USE_CLEARCOAT )
@@ -65,10 +65,10 @@ import{a6 as ss,cM as Do,bi as ie,X as Da,g as ku}from"./app-DnjpR35Q.js";import
65
65
  float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
66
66
  reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
67
67
  #endif
68
- #endif`,kf=`#ifdef USE_AOMAP
68
+ #endif`,zf=`#ifdef USE_AOMAP
69
69
  uniform sampler2D aoMap;
70
70
  uniform float aoMapIntensity;
71
- #endif`,zf=`#ifdef USE_BATCHING
71
+ #endif`,Vf=`#ifdef USE_BATCHING
72
72
  #if ! defined( GL_ANGLE_multi_draw )
73
73
  #define gl_DrawID _gl_DrawID
74
74
  uniform int _gl_DrawID;
@@ -102,15 +102,15 @@ import{a6 as ss,cM as Do,bi as ie,X as Da,g as ku}from"./app-DnjpR35Q.js";import
102
102
  int y = j / size;
103
103
  return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );
104
104
  }
105
- #endif`,Vf=`#ifdef USE_BATCHING
105
+ #endif`,Hf=`#ifdef USE_BATCHING
106
106
  mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
107
- #endif`,Hf=`vec3 transformed = vec3( position );
107
+ #endif`,Gf=`vec3 transformed = vec3( position );
108
108
  #ifdef USE_ALPHAHASH
109
109
  vPosition = vec3( position );
110
- #endif`,Gf=`vec3 objectNormal = vec3( normal );
110
+ #endif`,Wf=`vec3 objectNormal = vec3( normal );
111
111
  #ifdef USE_TANGENT
112
112
  vec3 objectTangent = vec3( tangent.xyz );
113
- #endif`,Wf=`float G_BlinnPhong_Implicit( ) {
113
+ #endif`,Xf=`float G_BlinnPhong_Implicit( ) {
114
114
  return 0.25;
115
115
  }
116
116
  float D_BlinnPhong( const in float shininess, const in float dotNH ) {
@@ -124,7 +124,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
124
124
  float G = G_BlinnPhong_Implicit( );
125
125
  float D = D_BlinnPhong( shininess, dotNH );
126
126
  return F * ( G * D );
127
- } // validated`,Xf=`#ifdef USE_IRIDESCENCE
127
+ } // validated`,Yf=`#ifdef USE_IRIDESCENCE
128
128
  const mat3 XYZ_TO_REC709 = mat3(
129
129
  3.2404542, -0.9692660, 0.0556434,
130
130
  -1.5371385, 1.8760108, -0.2040259,
@@ -187,7 +187,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
187
187
  }
188
188
  return max( I, vec3( 0.0 ) );
189
189
  }
190
- #endif`,Yf=`#ifdef USE_BUMPMAP
190
+ #endif`,qf=`#ifdef USE_BUMPMAP
191
191
  uniform sampler2D bumpMap;
192
192
  uniform float bumpScale;
193
193
  vec2 dHdxy_fwd() {
@@ -208,7 +208,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
208
208
  vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
209
209
  return normalize( abs( fDet ) * surf_norm - vGrad );
210
210
  }
211
- #endif`,qf=`#if NUM_CLIPPING_PLANES > 0
211
+ #endif`,Kf=`#if NUM_CLIPPING_PLANES > 0
212
212
  vec4 plane;
213
213
  #ifdef ALPHA_TO_COVERAGE
214
214
  float distanceToPlane, distanceGradient;
@@ -254,20 +254,20 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
254
254
  if ( clipped ) discard;
255
255
  #endif
256
256
  #endif
257
- #endif`,Kf=`#if NUM_CLIPPING_PLANES > 0
258
- varying vec3 vClipPosition;
259
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
260
257
  #endif`,Zf=`#if NUM_CLIPPING_PLANES > 0
261
258
  varying vec3 vClipPosition;
259
+ uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
262
260
  #endif`,$f=`#if NUM_CLIPPING_PLANES > 0
261
+ varying vec3 vClipPosition;
262
+ #endif`,jf=`#if NUM_CLIPPING_PLANES > 0
263
263
  vClipPosition = - mvPosition.xyz;
264
- #endif`,jf=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
265
- diffuseColor *= vColor;
266
264
  #endif`,Jf=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
267
- varying vec4 vColor;
268
- #endif`,Qf=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
265
+ diffuseColor *= vColor;
266
+ #endif`,Qf=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
269
267
  varying vec4 vColor;
270
268
  #endif`,ep=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
269
+ varying vec4 vColor;
270
+ #endif`,tp=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
271
271
  vColor = vec4( 1.0 );
272
272
  #endif
273
273
  #ifdef USE_COLOR_ALPHA
@@ -280,7 +280,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
280
280
  #endif
281
281
  #ifdef USE_BATCHING_COLOR
282
282
  vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );
283
- #endif`,tp=`#define PI 3.141592653589793
283
+ #endif`,np=`#define PI 3.141592653589793
284
284
  #define PI2 6.283185307179586
285
285
  #define PI_HALF 1.5707963267948966
286
286
  #define RECIPROCAL_PI 0.3183098861837907
@@ -351,7 +351,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
351
351
  float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
352
352
  float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
353
353
  return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
354
- } // validated`,np=`#ifdef ENVMAP_TYPE_CUBE_UV
354
+ } // validated`,ip=`#ifdef ENVMAP_TYPE_CUBE_UV
355
355
  #define cubeUV_minMipLevel 4.0
356
356
  #define cubeUV_minTileSize 16.0
357
357
  float getFace( vec3 direction ) {
@@ -444,7 +444,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
444
444
  return vec4( mix( color0, color1, mipF ), 1.0 );
445
445
  }
446
446
  }
447
- #endif`,ip=`vec3 transformedNormal = objectNormal;
447
+ #endif`,sp=`vec3 transformedNormal = objectNormal;
448
448
  #ifdef USE_TANGENT
449
449
  vec3 transformedTangent = objectTangent;
450
450
  #endif
@@ -470,21 +470,21 @@ transformedNormal = normalMatrix * transformedNormal;
470
470
  #endif
471
471
  #ifdef USE_TANGENT
472
472
  transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
473
- #endif`,sp=`#ifdef USE_DISPLACEMENTMAP
473
+ #endif`,rp=`#ifdef USE_DISPLACEMENTMAP
474
474
  uniform sampler2D displacementMap;
475
475
  uniform float displacementScale;
476
476
  uniform float displacementBias;
477
- #endif`,rp=`#ifdef USE_DISPLACEMENTMAP
477
+ #endif`,ap=`#ifdef USE_DISPLACEMENTMAP
478
478
  transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
479
- #endif`,ap=`#ifdef USE_EMISSIVEMAP
479
+ #endif`,op=`#ifdef USE_EMISSIVEMAP
480
480
  vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
481
481
  #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
482
482
  emissiveColor = sRGBTransferEOTF( emissiveColor );
483
483
  #endif
484
484
  totalEmissiveRadiance *= emissiveColor.rgb;
485
- #endif`,op=`#ifdef USE_EMISSIVEMAP
485
+ #endif`,lp=`#ifdef USE_EMISSIVEMAP
486
486
  uniform sampler2D emissiveMap;
487
- #endif`,lp="gl_FragColor = linearToOutputTexel( gl_FragColor );",cp=`vec4 LinearTransferOETF( in vec4 value ) {
487
+ #endif`,cp="gl_FragColor = linearToOutputTexel( gl_FragColor );",up=`vec4 LinearTransferOETF( in vec4 value ) {
488
488
  return value;
489
489
  }
490
490
  vec4 sRGBTransferEOTF( in vec4 value ) {
@@ -492,7 +492,7 @@ vec4 sRGBTransferEOTF( in vec4 value ) {
492
492
  }
493
493
  vec4 sRGBTransferOETF( in vec4 value ) {
494
494
  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 );
495
- }`,up=`#ifdef USE_ENVMAP
495
+ }`,hp=`#ifdef USE_ENVMAP
496
496
  #ifdef ENV_WORLDPOS
497
497
  vec3 cameraToFrag;
498
498
  if ( isOrthographic ) {
@@ -519,7 +519,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
519
519
  outgoingLight += envColor.xyz * specularStrength * reflectivity;
520
520
  #endif
521
521
  #endif
522
- #endif`,hp=`#ifdef USE_ENVMAP
522
+ #endif`,dp=`#ifdef USE_ENVMAP
523
523
  uniform float envMapIntensity;
524
524
  uniform mat3 envMapRotation;
525
525
  #ifdef ENVMAP_TYPE_CUBE
@@ -527,7 +527,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
527
527
  #else
528
528
  uniform sampler2D envMap;
529
529
  #endif
530
- #endif`,dp=`#ifdef USE_ENVMAP
530
+ #endif`,fp=`#ifdef USE_ENVMAP
531
531
  uniform float reflectivity;
532
532
  #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
533
533
  #define ENV_WORLDPOS
@@ -538,7 +538,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
538
538
  #else
539
539
  varying vec3 vReflect;
540
540
  #endif
541
- #endif`,fp=`#ifdef USE_ENVMAP
541
+ #endif`,pp=`#ifdef USE_ENVMAP
542
542
  #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
543
543
  #define ENV_WORLDPOS
544
544
  #endif
@@ -549,7 +549,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
549
549
  varying vec3 vReflect;
550
550
  uniform float refractionRatio;
551
551
  #endif
552
- #endif`,pp=`#ifdef USE_ENVMAP
552
+ #endif`,mp=`#ifdef USE_ENVMAP
553
553
  #ifdef ENV_WORLDPOS
554
554
  vWorldPosition = worldPosition.xyz;
555
555
  #else
@@ -566,18 +566,18 @@ vec4 sRGBTransferOETF( in vec4 value ) {
566
566
  vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
567
567
  #endif
568
568
  #endif
569
- #endif`,mp=`#ifdef USE_FOG
570
- vFogDepth = - mvPosition.z;
571
569
  #endif`,gp=`#ifdef USE_FOG
572
- varying float vFogDepth;
570
+ vFogDepth = - mvPosition.z;
573
571
  #endif`,_p=`#ifdef USE_FOG
572
+ varying float vFogDepth;
573
+ #endif`,xp=`#ifdef USE_FOG
574
574
  #ifdef FOG_EXP2
575
575
  float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
576
576
  #else
577
577
  float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
578
578
  #endif
579
579
  gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
580
- #endif`,xp=`#ifdef USE_FOG
580
+ #endif`,vp=`#ifdef USE_FOG
581
581
  uniform vec3 fogColor;
582
582
  varying float vFogDepth;
583
583
  #ifdef FOG_EXP2
@@ -586,7 +586,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
586
586
  uniform float fogNear;
587
587
  uniform float fogFar;
588
588
  #endif
589
- #endif`,vp=`#ifdef USE_GRADIENTMAP
589
+ #endif`,Mp=`#ifdef USE_GRADIENTMAP
590
590
  uniform sampler2D gradientMap;
591
591
  #endif
592
592
  vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
@@ -598,12 +598,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
598
598
  vec2 fw = fwidth( coord ) * 0.5;
599
599
  return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
600
600
  #endif
601
- }`,Mp=`#ifdef USE_LIGHTMAP
601
+ }`,Sp=`#ifdef USE_LIGHTMAP
602
602
  uniform sampler2D lightMap;
603
603
  uniform float lightMapIntensity;
604
- #endif`,Sp=`LambertMaterial material;
604
+ #endif`,yp=`LambertMaterial material;
605
605
  material.diffuseColor = diffuseColor.rgb;
606
- material.specularStrength = specularStrength;`,yp=`varying vec3 vViewPosition;
606
+ material.specularStrength = specularStrength;`,bp=`varying vec3 vViewPosition;
607
607
  struct LambertMaterial {
608
608
  vec3 diffuseColor;
609
609
  float specularStrength;
@@ -617,7 +617,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr
617
617
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
618
618
  }
619
619
  #define RE_Direct RE_Direct_Lambert
620
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,bp=`uniform bool receiveShadow;
620
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Ep=`uniform bool receiveShadow;
621
621
  uniform vec3 ambientLightColor;
622
622
  #if defined( USE_LIGHT_PROBES )
623
623
  uniform vec3 lightProbe[ 9 ];
@@ -734,7 +734,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
734
734
  return irradiance;
735
735
  }
736
736
  #endif
737
- #include <lightprobes_pars_fragment>`,Ep=`#ifdef USE_ENVMAP
737
+ #include <lightprobes_pars_fragment>`,Tp=`#ifdef USE_ENVMAP
738
738
  vec3 getIBLIrradiance( const in vec3 normal ) {
739
739
  #ifdef ENVMAP_TYPE_CUBE_UV
740
740
  vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
@@ -767,8 +767,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
767
767
  #endif
768
768
  }
769
769
  #endif
770
- #endif`,Tp=`ToonMaterial material;
771
- material.diffuseColor = diffuseColor.rgb;`,Ap=`varying vec3 vViewPosition;
770
+ #endif`,Ap=`ToonMaterial material;
771
+ material.diffuseColor = diffuseColor.rgb;`,wp=`varying vec3 vViewPosition;
772
772
  struct ToonMaterial {
773
773
  vec3 diffuseColor;
774
774
  };
@@ -780,11 +780,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo
780
780
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
781
781
  }
782
782
  #define RE_Direct RE_Direct_Toon
783
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,wp=`BlinnPhongMaterial material;
783
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Rp=`BlinnPhongMaterial material;
784
784
  material.diffuseColor = diffuseColor.rgb;
785
785
  material.specularColor = specular;
786
786
  material.specularShininess = shininess;
787
- material.specularStrength = specularStrength;`,Rp=`varying vec3 vViewPosition;
787
+ material.specularStrength = specularStrength;`,Cp=`varying vec3 vViewPosition;
788
788
  struct BlinnPhongMaterial {
789
789
  vec3 diffuseColor;
790
790
  vec3 specularColor;
@@ -801,7 +801,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom
801
801
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
802
802
  }
803
803
  #define RE_Direct RE_Direct_BlinnPhong
804
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Cp=`PhysicalMaterial material;
804
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Pp=`PhysicalMaterial material;
805
805
  material.diffuseColor = diffuseColor.rgb;
806
806
  material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
807
807
  material.metalness = metalnessFactor;
@@ -891,7 +891,7 @@ material.roughness = min( material.roughness, 1.0 );
891
891
  material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
892
892
  material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
893
893
  material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
894
- #endif`,Pp=`uniform sampler2D dfgLUT;
894
+ #endif`,Lp=`uniform sampler2D dfgLUT;
895
895
  struct PhysicalMaterial {
896
896
  vec3 diffuseColor;
897
897
  vec3 diffuseContribution;
@@ -1251,7 +1251,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
1251
1251
  #define RE_IndirectSpecular RE_IndirectSpecular_Physical
1252
1252
  float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
1253
1253
  return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
1254
- }`,Lp=`
1254
+ }`,Ip=`
1255
1255
  vec3 geometryPosition = - vViewPosition;
1256
1256
  vec3 geometryNormal = normal;
1257
1257
  vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
@@ -1373,7 +1373,7 @@ IncidentLight directLight;
1373
1373
  #if defined( RE_IndirectSpecular )
1374
1374
  vec3 radiance = vec3( 0.0 );
1375
1375
  vec3 clearcoatRadiance = vec3( 0.0 );
1376
- #endif`,Ip=`#if defined( RE_IndirectDiffuse )
1376
+ #endif`,Dp=`#if defined( RE_IndirectDiffuse )
1377
1377
  #ifdef USE_LIGHTMAP
1378
1378
  vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
1379
1379
  vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
@@ -1394,7 +1394,7 @@ IncidentLight directLight;
1394
1394
  #ifdef USE_CLEARCOAT
1395
1395
  clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
1396
1396
  #endif
1397
- #endif`,Dp=`#if defined( RE_IndirectDiffuse )
1397
+ #endif`,Np=`#if defined( RE_IndirectDiffuse )
1398
1398
  #if defined( LAMBERT ) || defined( PHONG )
1399
1399
  irradiance += iblIrradiance;
1400
1400
  #endif
@@ -1402,7 +1402,7 @@ IncidentLight directLight;
1402
1402
  #endif
1403
1403
  #if defined( RE_IndirectSpecular )
1404
1404
  RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1405
- #endif`,Np=`#ifdef USE_LIGHT_PROBES_GRID
1405
+ #endif`,Up=`#ifdef USE_LIGHT_PROBES_GRID
1406
1406
  uniform highp sampler3D probesSH;
1407
1407
  uniform vec3 probesMin;
1408
1408
  uniform vec3 probesMax;
@@ -1447,27 +1447,27 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1447
1447
  result += c8 * 0.429043 * ( x * x - y * y );
1448
1448
  return max( result, vec3( 0.0 ) );
1449
1449
  }
1450
- #endif`,Up=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1451
- gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1452
1450
  #endif`,Fp=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1451
+ gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1452
+ #endif`,Op=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1453
1453
  uniform float logDepthBufFC;
1454
1454
  varying float vFragDepth;
1455
1455
  varying float vIsPerspective;
1456
- #endif`,Op=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1456
+ #endif`,Bp=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1457
1457
  varying float vFragDepth;
1458
1458
  varying float vIsPerspective;
1459
- #endif`,Bp=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1459
+ #endif`,kp=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1460
1460
  vFragDepth = 1.0 + gl_Position.w;
1461
1461
  vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
1462
- #endif`,kp=`#ifdef USE_MAP
1462
+ #endif`,zp=`#ifdef USE_MAP
1463
1463
  vec4 sampledDiffuseColor = texture2D( map, vMapUv );
1464
1464
  #ifdef DECODE_VIDEO_TEXTURE
1465
1465
  sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
1466
1466
  #endif
1467
1467
  diffuseColor *= sampledDiffuseColor;
1468
- #endif`,zp=`#ifdef USE_MAP
1468
+ #endif`,Vp=`#ifdef USE_MAP
1469
1469
  uniform sampler2D map;
1470
- #endif`,Vp=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1470
+ #endif`,Hp=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1471
1471
  #if defined( USE_POINTS_UV )
1472
1472
  vec2 uv = vUv;
1473
1473
  #else
@@ -1479,7 +1479,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1479
1479
  #endif
1480
1480
  #ifdef USE_ALPHAMAP
1481
1481
  diffuseColor.a *= texture2D( alphaMap, uv ).g;
1482
- #endif`,Hp=`#if defined( USE_POINTS_UV )
1482
+ #endif`,Gp=`#if defined( USE_POINTS_UV )
1483
1483
  varying vec2 vUv;
1484
1484
  #else
1485
1485
  #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
@@ -1491,19 +1491,19 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1491
1491
  #endif
1492
1492
  #ifdef USE_ALPHAMAP
1493
1493
  uniform sampler2D alphaMap;
1494
- #endif`,Gp=`float metalnessFactor = metalness;
1494
+ #endif`,Wp=`float metalnessFactor = metalness;
1495
1495
  #ifdef USE_METALNESSMAP
1496
1496
  vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
1497
1497
  metalnessFactor *= texelMetalness.b;
1498
- #endif`,Wp=`#ifdef USE_METALNESSMAP
1498
+ #endif`,Xp=`#ifdef USE_METALNESSMAP
1499
1499
  uniform sampler2D metalnessMap;
1500
- #endif`,Xp=`#ifdef USE_INSTANCING_MORPH
1500
+ #endif`,Yp=`#ifdef USE_INSTANCING_MORPH
1501
1501
  float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1502
1502
  float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
1503
1503
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1504
1504
  morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
1505
1505
  }
1506
- #endif`,Yp=`#if defined( USE_MORPHCOLORS )
1506
+ #endif`,qp=`#if defined( USE_MORPHCOLORS )
1507
1507
  vColor *= morphTargetBaseInfluence;
1508
1508
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1509
1509
  #if defined( USE_COLOR_ALPHA )
@@ -1512,12 +1512,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1512
1512
  if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
1513
1513
  #endif
1514
1514
  }
1515
- #endif`,qp=`#ifdef USE_MORPHNORMALS
1515
+ #endif`,Kp=`#ifdef USE_MORPHNORMALS
1516
1516
  objectNormal *= morphTargetBaseInfluence;
1517
1517
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1518
1518
  if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
1519
1519
  }
1520
- #endif`,Kp=`#ifdef USE_MORPHTARGETS
1520
+ #endif`,Zp=`#ifdef USE_MORPHTARGETS
1521
1521
  #ifndef USE_INSTANCING_MORPH
1522
1522
  uniform float morphTargetBaseInfluence;
1523
1523
  uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
@@ -1531,12 +1531,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1531
1531
  ivec3 morphUV = ivec3( x, y, morphTargetIndex );
1532
1532
  return texelFetch( morphTargetsTexture, morphUV, 0 );
1533
1533
  }
1534
- #endif`,Zp=`#ifdef USE_MORPHTARGETS
1534
+ #endif`,$p=`#ifdef USE_MORPHTARGETS
1535
1535
  transformed *= morphTargetBaseInfluence;
1536
1536
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1537
1537
  if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
1538
1538
  }
1539
- #endif`,$p=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1539
+ #endif`,jp=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1540
1540
  #ifdef FLAT_SHADED
1541
1541
  vec3 fdx = dFdx( vViewPosition );
1542
1542
  vec3 fdy = dFdy( vViewPosition );
@@ -1577,7 +1577,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
1577
1577
  tbn2[1] *= faceDirection;
1578
1578
  #endif
1579
1579
  #endif
1580
- vec3 nonPerturbedNormal = normal;`,jp=`#ifdef USE_NORMALMAP_OBJECTSPACE
1580
+ vec3 nonPerturbedNormal = normal;`,Jp=`#ifdef USE_NORMALMAP_OBJECTSPACE
1581
1581
  normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1582
1582
  #ifdef FLIP_SIDED
1583
1583
  normal = - normal;
@@ -1595,19 +1595,19 @@ vec3 nonPerturbedNormal = normal;`,jp=`#ifdef USE_NORMALMAP_OBJECTSPACE
1595
1595
  normal = normalize( tbn * mapN );
1596
1596
  #elif defined( USE_BUMPMAP )
1597
1597
  normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
1598
- #endif`,Jp=`#ifndef FLAT_SHADED
1598
+ #endif`,Qp=`#ifndef FLAT_SHADED
1599
1599
  varying vec3 vNormal;
1600
1600
  #ifdef USE_TANGENT
1601
1601
  varying vec3 vTangent;
1602
1602
  varying vec3 vBitangent;
1603
1603
  #endif
1604
- #endif`,Qp=`#ifndef FLAT_SHADED
1604
+ #endif`,em=`#ifndef FLAT_SHADED
1605
1605
  varying vec3 vNormal;
1606
1606
  #ifdef USE_TANGENT
1607
1607
  varying vec3 vTangent;
1608
1608
  varying vec3 vBitangent;
1609
1609
  #endif
1610
- #endif`,em=`#ifndef FLAT_SHADED
1610
+ #endif`,tm=`#ifndef FLAT_SHADED
1611
1611
  vNormal = normalize( transformedNormal );
1612
1612
  #ifdef USE_TANGENT
1613
1613
  vTangent = normalize( transformedTangent );
@@ -1616,7 +1616,7 @@ vec3 nonPerturbedNormal = normal;`,jp=`#ifdef USE_NORMALMAP_OBJECTSPACE
1616
1616
  vBitangent = - vBitangent;
1617
1617
  #endif
1618
1618
  #endif
1619
- #endif`,tm=`#ifdef USE_NORMALMAP
1619
+ #endif`,nm=`#ifdef USE_NORMALMAP
1620
1620
  uniform sampler2D normalMap;
1621
1621
  uniform vec2 normalScale;
1622
1622
  #endif
@@ -1638,13 +1638,13 @@ vec3 nonPerturbedNormal = normal;`,jp=`#ifdef USE_NORMALMAP_OBJECTSPACE
1638
1638
  float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
1639
1639
  return mat3( T * scale, B * scale, N );
1640
1640
  }
1641
- #endif`,nm=`#ifdef USE_CLEARCOAT
1641
+ #endif`,im=`#ifdef USE_CLEARCOAT
1642
1642
  vec3 clearcoatNormal = nonPerturbedNormal;
1643
- #endif`,im=`#ifdef USE_CLEARCOAT_NORMALMAP
1643
+ #endif`,sm=`#ifdef USE_CLEARCOAT_NORMALMAP
1644
1644
  vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
1645
1645
  clearcoatMapN.xy *= clearcoatNormalScale;
1646
1646
  clearcoatNormal = normalize( tbn2 * clearcoatMapN );
1647
- #endif`,sm=`#ifdef USE_CLEARCOATMAP
1647
+ #endif`,rm=`#ifdef USE_CLEARCOATMAP
1648
1648
  uniform sampler2D clearcoatMap;
1649
1649
  #endif
1650
1650
  #ifdef USE_CLEARCOAT_NORMALMAP
@@ -1653,18 +1653,18 @@ vec3 nonPerturbedNormal = normal;`,jp=`#ifdef USE_NORMALMAP_OBJECTSPACE
1653
1653
  #endif
1654
1654
  #ifdef USE_CLEARCOAT_ROUGHNESSMAP
1655
1655
  uniform sampler2D clearcoatRoughnessMap;
1656
- #endif`,rm=`#ifdef USE_IRIDESCENCEMAP
1656
+ #endif`,am=`#ifdef USE_IRIDESCENCEMAP
1657
1657
  uniform sampler2D iridescenceMap;
1658
1658
  #endif
1659
1659
  #ifdef USE_IRIDESCENCE_THICKNESSMAP
1660
1660
  uniform sampler2D iridescenceThicknessMap;
1661
- #endif`,am=`#ifdef OPAQUE
1661
+ #endif`,om=`#ifdef OPAQUE
1662
1662
  diffuseColor.a = 1.0;
1663
1663
  #endif
1664
1664
  #ifdef USE_TRANSMISSION
1665
1665
  diffuseColor.a *= material.transmissionAlpha;
1666
1666
  #endif
1667
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,om=`vec3 packNormalToRGB( const in vec3 normal ) {
1667
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,lm=`vec3 packNormalToRGB( const in vec3 normal ) {
1668
1668
  return normalize( normal ) * 0.5 + 0.5;
1669
1669
  }
1670
1670
  vec3 unpackRGBToNormal( const in vec3 rgb ) {
@@ -1743,9 +1743,9 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
1743
1743
  #else
1744
1744
  return ( near * far ) / ( ( far - near ) * depth - far );
1745
1745
  #endif
1746
- }`,lm=`#ifdef PREMULTIPLIED_ALPHA
1746
+ }`,cm=`#ifdef PREMULTIPLIED_ALPHA
1747
1747
  gl_FragColor.rgb *= gl_FragColor.a;
1748
- #endif`,cm=`vec4 mvPosition = vec4( transformed, 1.0 );
1748
+ #endif`,um=`vec4 mvPosition = vec4( transformed, 1.0 );
1749
1749
  #ifdef USE_BATCHING
1750
1750
  mvPosition = batchingMatrix * mvPosition;
1751
1751
  #endif
@@ -1753,22 +1753,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
1753
1753
  mvPosition = instanceMatrix * mvPosition;
1754
1754
  #endif
1755
1755
  mvPosition = modelViewMatrix * mvPosition;
1756
- gl_Position = projectionMatrix * mvPosition;`,um=`#ifdef DITHERING
1756
+ gl_Position = projectionMatrix * mvPosition;`,hm=`#ifdef DITHERING
1757
1757
  gl_FragColor.rgb = dithering( gl_FragColor.rgb );
1758
- #endif`,hm=`#ifdef DITHERING
1758
+ #endif`,dm=`#ifdef DITHERING
1759
1759
  vec3 dithering( vec3 color ) {
1760
1760
  float grid_position = rand( gl_FragCoord.xy );
1761
1761
  vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
1762
1762
  dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
1763
1763
  return color + dither_shift_RGB;
1764
1764
  }
1765
- #endif`,dm=`float roughnessFactor = roughness;
1765
+ #endif`,fm=`float roughnessFactor = roughness;
1766
1766
  #ifdef USE_ROUGHNESSMAP
1767
1767
  vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
1768
1768
  roughnessFactor *= texelRoughness.g;
1769
- #endif`,fm=`#ifdef USE_ROUGHNESSMAP
1769
+ #endif`,pm=`#ifdef USE_ROUGHNESSMAP
1770
1770
  uniform sampler2D roughnessMap;
1771
- #endif`,pm=`#if NUM_SPOT_LIGHT_COORDS > 0
1771
+ #endif`,mm=`#if NUM_SPOT_LIGHT_COORDS > 0
1772
1772
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1773
1773
  #endif
1774
1774
  #if NUM_SPOT_LIGHT_MAPS > 0
@@ -1968,7 +1968,7 @@ gl_Position = projectionMatrix * mvPosition;`,um=`#ifdef DITHERING
1968
1968
  }
1969
1969
  #endif
1970
1970
  #endif
1971
- #endif`,mm=`#if NUM_SPOT_LIGHT_COORDS > 0
1971
+ #endif`,gm=`#if NUM_SPOT_LIGHT_COORDS > 0
1972
1972
  uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
1973
1973
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1974
1974
  #endif
@@ -2009,7 +2009,7 @@ gl_Position = projectionMatrix * mvPosition;`,um=`#ifdef DITHERING
2009
2009
  };
2010
2010
  uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
2011
2011
  #endif
2012
- #endif`,gm=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
2012
+ #endif`,_m=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
2013
2013
  #ifdef HAS_NORMAL
2014
2014
  vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );
2015
2015
  #else
@@ -2045,7 +2045,7 @@ gl_Position = projectionMatrix * mvPosition;`,um=`#ifdef DITHERING
2045
2045
  vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
2046
2046
  }
2047
2047
  #pragma unroll_loop_end
2048
- #endif`,_m=`float getShadowMask() {
2048
+ #endif`,xm=`float getShadowMask() {
2049
2049
  float shadow = 1.0;
2050
2050
  #ifdef USE_SHADOWMAP
2051
2051
  #if NUM_DIR_LIGHT_SHADOWS > 0
@@ -2077,12 +2077,12 @@ gl_Position = projectionMatrix * mvPosition;`,um=`#ifdef DITHERING
2077
2077
  #endif
2078
2078
  #endif
2079
2079
  return shadow;
2080
- }`,xm=`#ifdef USE_SKINNING
2080
+ }`,vm=`#ifdef USE_SKINNING
2081
2081
  mat4 boneMatX = getBoneMatrix( skinIndex.x );
2082
2082
  mat4 boneMatY = getBoneMatrix( skinIndex.y );
2083
2083
  mat4 boneMatZ = getBoneMatrix( skinIndex.z );
2084
2084
  mat4 boneMatW = getBoneMatrix( skinIndex.w );
2085
- #endif`,vm=`#ifdef USE_SKINNING
2085
+ #endif`,Mm=`#ifdef USE_SKINNING
2086
2086
  uniform mat4 bindMatrix;
2087
2087
  uniform mat4 bindMatrixInverse;
2088
2088
  uniform highp sampler2D boneTexture;
@@ -2097,7 +2097,7 @@ gl_Position = projectionMatrix * mvPosition;`,um=`#ifdef DITHERING
2097
2097
  vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
2098
2098
  return mat4( v1, v2, v3, v4 );
2099
2099
  }
2100
- #endif`,Mm=`#ifdef USE_SKINNING
2100
+ #endif`,Sm=`#ifdef USE_SKINNING
2101
2101
  vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
2102
2102
  vec4 skinned = vec4( 0.0 );
2103
2103
  skinned += boneMatX * skinVertex * skinWeight.x;
@@ -2105,7 +2105,7 @@ gl_Position = projectionMatrix * mvPosition;`,um=`#ifdef DITHERING
2105
2105
  skinned += boneMatZ * skinVertex * skinWeight.z;
2106
2106
  skinned += boneMatW * skinVertex * skinWeight.w;
2107
2107
  transformed = ( bindMatrixInverse * skinned ).xyz;
2108
- #endif`,Sm=`#ifdef USE_SKINNING
2108
+ #endif`,ym=`#ifdef USE_SKINNING
2109
2109
  mat4 skinMatrix = mat4( 0.0 );
2110
2110
  skinMatrix += skinWeight.x * boneMatX;
2111
2111
  skinMatrix += skinWeight.y * boneMatY;
@@ -2116,17 +2116,17 @@ gl_Position = projectionMatrix * mvPosition;`,um=`#ifdef DITHERING
2116
2116
  #ifdef USE_TANGENT
2117
2117
  objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
2118
2118
  #endif
2119
- #endif`,ym=`float specularStrength;
2119
+ #endif`,bm=`float specularStrength;
2120
2120
  #ifdef USE_SPECULARMAP
2121
2121
  vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
2122
2122
  specularStrength = texelSpecular.r;
2123
2123
  #else
2124
2124
  specularStrength = 1.0;
2125
- #endif`,bm=`#ifdef USE_SPECULARMAP
2125
+ #endif`,Em=`#ifdef USE_SPECULARMAP
2126
2126
  uniform sampler2D specularMap;
2127
- #endif`,Em=`#if defined( TONE_MAPPING )
2127
+ #endif`,Tm=`#if defined( TONE_MAPPING )
2128
2128
  gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2129
- #endif`,Tm=`#ifndef saturate
2129
+ #endif`,Am=`#ifndef saturate
2130
2130
  #define saturate( a ) clamp( a, 0.0, 1.0 )
2131
2131
  #endif
2132
2132
  uniform float toneMappingExposure;
@@ -2223,7 +2223,7 @@ vec3 NeutralToneMapping( vec3 color ) {
2223
2223
  float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
2224
2224
  return mix( color, vec3( newPeak ), g );
2225
2225
  }
2226
- vec3 CustomToneMapping( vec3 color ) { return color; }`,Am=`#ifdef USE_TRANSMISSION
2226
+ vec3 CustomToneMapping( vec3 color ) { return color; }`,wm=`#ifdef USE_TRANSMISSION
2227
2227
  material.transmission = transmission;
2228
2228
  material.transmissionAlpha = 1.0;
2229
2229
  material.thickness = thickness;
@@ -2244,7 +2244,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Am=`#ifdef USE_TRANSMISS
2244
2244
  material.attenuationColor, material.attenuationDistance );
2245
2245
  material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
2246
2246
  totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
2247
- #endif`,wm=`#ifdef USE_TRANSMISSION
2247
+ #endif`,Rm=`#ifdef USE_TRANSMISSION
2248
2248
  uniform float transmission;
2249
2249
  uniform float thickness;
2250
2250
  uniform float attenuationDistance;
@@ -2370,7 +2370,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Am=`#ifdef USE_TRANSMISS
2370
2370
  float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
2371
2371
  return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
2372
2372
  }
2373
- #endif`,Rm=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2373
+ #endif`,Cm=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2374
2374
  varying vec2 vUv;
2375
2375
  #endif
2376
2376
  #ifdef USE_MAP
@@ -2440,7 +2440,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Am=`#ifdef USE_TRANSMISS
2440
2440
  #ifdef USE_THICKNESSMAP
2441
2441
  uniform mat3 thicknessMapTransform;
2442
2442
  varying vec2 vThicknessMapUv;
2443
- #endif`,Cm=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2443
+ #endif`,Pm=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2444
2444
  varying vec2 vUv;
2445
2445
  #endif
2446
2446
  #ifdef USE_MAP
@@ -2534,7 +2534,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Am=`#ifdef USE_TRANSMISS
2534
2534
  #ifdef USE_THICKNESSMAP
2535
2535
  uniform mat3 thicknessMapTransform;
2536
2536
  varying vec2 vThicknessMapUv;
2537
- #endif`,Pm=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2537
+ #endif`,Lm=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2538
2538
  vUv = vec3( uv, 1 ).xy;
2539
2539
  #endif
2540
2540
  #ifdef USE_MAP
@@ -2605,7 +2605,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Am=`#ifdef USE_TRANSMISS
2605
2605
  #endif
2606
2606
  #ifdef USE_THICKNESSMAP
2607
2607
  vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
2608
- #endif`,Lm=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2608
+ #endif`,Im=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2609
2609
  vec4 worldPosition = vec4( transformed, 1.0 );
2610
2610
  #ifdef USE_BATCHING
2611
2611
  worldPosition = batchingMatrix * worldPosition;
@@ -2614,12 +2614,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Am=`#ifdef USE_TRANSMISS
2614
2614
  worldPosition = instanceMatrix * worldPosition;
2615
2615
  #endif
2616
2616
  worldPosition = modelMatrix * worldPosition;
2617
- #endif`;const Im=`varying vec2 vUv;
2617
+ #endif`;const Dm=`varying vec2 vUv;
2618
2618
  uniform mat3 uvTransform;
2619
2619
  void main() {
2620
2620
  vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
2621
2621
  gl_Position = vec4( position.xy, 1.0, 1.0 );
2622
- }`,Dm=`uniform sampler2D t2D;
2622
+ }`,Nm=`uniform sampler2D t2D;
2623
2623
  uniform float backgroundIntensity;
2624
2624
  varying vec2 vUv;
2625
2625
  void main() {
@@ -2631,14 +2631,14 @@ void main() {
2631
2631
  gl_FragColor = texColor;
2632
2632
  #include <tonemapping_fragment>
2633
2633
  #include <colorspace_fragment>
2634
- }`,Nm=`varying vec3 vWorldDirection;
2634
+ }`,Um=`varying vec3 vWorldDirection;
2635
2635
  #include <common>
2636
2636
  void main() {
2637
2637
  vWorldDirection = transformDirection( position, modelMatrix );
2638
2638
  #include <begin_vertex>
2639
2639
  #include <project_vertex>
2640
2640
  gl_Position.z = gl_Position.w;
2641
- }`,Um=`#ifdef ENVMAP_TYPE_CUBE
2641
+ }`,Fm=`#ifdef ENVMAP_TYPE_CUBE
2642
2642
  uniform samplerCube envMap;
2643
2643
  #elif defined( ENVMAP_TYPE_CUBE_UV )
2644
2644
  uniform sampler2D envMap;
@@ -2660,14 +2660,14 @@ void main() {
2660
2660
  gl_FragColor = texColor;
2661
2661
  #include <tonemapping_fragment>
2662
2662
  #include <colorspace_fragment>
2663
- }`,Fm=`varying vec3 vWorldDirection;
2663
+ }`,Om=`varying vec3 vWorldDirection;
2664
2664
  #include <common>
2665
2665
  void main() {
2666
2666
  vWorldDirection = transformDirection( position, modelMatrix );
2667
2667
  #include <begin_vertex>
2668
2668
  #include <project_vertex>
2669
2669
  gl_Position.z = gl_Position.w;
2670
- }`,Om=`uniform samplerCube tCube;
2670
+ }`,Bm=`uniform samplerCube tCube;
2671
2671
  uniform float tFlip;
2672
2672
  uniform float opacity;
2673
2673
  varying vec3 vWorldDirection;
@@ -2677,7 +2677,7 @@ void main() {
2677
2677
  gl_FragColor.a *= opacity;
2678
2678
  #include <tonemapping_fragment>
2679
2679
  #include <colorspace_fragment>
2680
- }`,Bm=`#include <common>
2680
+ }`,km=`#include <common>
2681
2681
  #include <batching_pars_vertex>
2682
2682
  #include <uv_pars_vertex>
2683
2683
  #include <displacementmap_pars_vertex>
@@ -2704,7 +2704,7 @@ void main() {
2704
2704
  #include <logdepthbuf_vertex>
2705
2705
  #include <clipping_planes_vertex>
2706
2706
  vHighPrecisionZW = gl_Position.zw;
2707
- }`,km=`#if DEPTH_PACKING == 3200
2707
+ }`,zm=`#if DEPTH_PACKING == 3200
2708
2708
  uniform float opacity;
2709
2709
  #endif
2710
2710
  #include <common>
@@ -2742,7 +2742,7 @@ void main() {
2742
2742
  #elif DEPTH_PACKING == 3203
2743
2743
  gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
2744
2744
  #endif
2745
- }`,zm=`#define DISTANCE
2745
+ }`,Vm=`#define DISTANCE
2746
2746
  varying vec3 vWorldPosition;
2747
2747
  #include <common>
2748
2748
  #include <batching_pars_vertex>
@@ -2769,7 +2769,7 @@ void main() {
2769
2769
  #include <worldpos_vertex>
2770
2770
  #include <clipping_planes_vertex>
2771
2771
  vWorldPosition = worldPosition.xyz;
2772
- }`,Vm=`#define DISTANCE
2772
+ }`,Hm=`#define DISTANCE
2773
2773
  uniform vec3 referencePosition;
2774
2774
  uniform float nearDistance;
2775
2775
  uniform float farDistance;
@@ -2792,13 +2792,13 @@ void main() {
2792
2792
  dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
2793
2793
  dist = saturate( dist );
2794
2794
  gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
2795
- }`,Hm=`varying vec3 vWorldDirection;
2795
+ }`,Gm=`varying vec3 vWorldDirection;
2796
2796
  #include <common>
2797
2797
  void main() {
2798
2798
  vWorldDirection = transformDirection( position, modelMatrix );
2799
2799
  #include <begin_vertex>
2800
2800
  #include <project_vertex>
2801
- }`,Gm=`uniform sampler2D tEquirect;
2801
+ }`,Wm=`uniform sampler2D tEquirect;
2802
2802
  varying vec3 vWorldDirection;
2803
2803
  #include <common>
2804
2804
  void main() {
@@ -2807,7 +2807,7 @@ void main() {
2807
2807
  gl_FragColor = texture2D( tEquirect, sampleUV );
2808
2808
  #include <tonemapping_fragment>
2809
2809
  #include <colorspace_fragment>
2810
- }`,Wm=`uniform float scale;
2810
+ }`,Xm=`uniform float scale;
2811
2811
  attribute float lineDistance;
2812
2812
  varying float vLineDistance;
2813
2813
  #include <common>
@@ -2829,7 +2829,7 @@ void main() {
2829
2829
  #include <logdepthbuf_vertex>
2830
2830
  #include <clipping_planes_vertex>
2831
2831
  #include <fog_vertex>
2832
- }`,Xm=`uniform vec3 diffuse;
2832
+ }`,Ym=`uniform vec3 diffuse;
2833
2833
  uniform float opacity;
2834
2834
  uniform float dashSize;
2835
2835
  uniform float totalSize;
@@ -2857,7 +2857,7 @@ void main() {
2857
2857
  #include <colorspace_fragment>
2858
2858
  #include <fog_fragment>
2859
2859
  #include <premultiplied_alpha_fragment>
2860
- }`,Ym=`#include <common>
2860
+ }`,qm=`#include <common>
2861
2861
  #include <batching_pars_vertex>
2862
2862
  #include <uv_pars_vertex>
2863
2863
  #include <envmap_pars_vertex>
@@ -2889,7 +2889,7 @@ void main() {
2889
2889
  #include <worldpos_vertex>
2890
2890
  #include <envmap_vertex>
2891
2891
  #include <fog_vertex>
2892
- }`,qm=`uniform vec3 diffuse;
2892
+ }`,Km=`uniform vec3 diffuse;
2893
2893
  uniform float opacity;
2894
2894
  #ifndef FLAT_SHADED
2895
2895
  varying vec3 vNormal;
@@ -2937,7 +2937,7 @@ void main() {
2937
2937
  #include <fog_fragment>
2938
2938
  #include <premultiplied_alpha_fragment>
2939
2939
  #include <dithering_fragment>
2940
- }`,Km=`#define LAMBERT
2940
+ }`,Zm=`#define LAMBERT
2941
2941
  varying vec3 vViewPosition;
2942
2942
  #include <common>
2943
2943
  #include <batching_pars_vertex>
@@ -2976,7 +2976,7 @@ void main() {
2976
2976
  #include <envmap_vertex>
2977
2977
  #include <shadowmap_vertex>
2978
2978
  #include <fog_vertex>
2979
- }`,Zm=`#define LAMBERT
2979
+ }`,$m=`#define LAMBERT
2980
2980
  uniform vec3 diffuse;
2981
2981
  uniform vec3 emissive;
2982
2982
  uniform float opacity;
@@ -3034,7 +3034,7 @@ void main() {
3034
3034
  #include <fog_fragment>
3035
3035
  #include <premultiplied_alpha_fragment>
3036
3036
  #include <dithering_fragment>
3037
- }`,$m=`#define MATCAP
3037
+ }`,jm=`#define MATCAP
3038
3038
  varying vec3 vViewPosition;
3039
3039
  #include <common>
3040
3040
  #include <batching_pars_vertex>
@@ -3068,7 +3068,7 @@ void main() {
3068
3068
  #include <clipping_planes_vertex>
3069
3069
  #include <fog_vertex>
3070
3070
  vViewPosition = - mvPosition.xyz;
3071
- }`,jm=`#define MATCAP
3071
+ }`,Jm=`#define MATCAP
3072
3072
  uniform vec3 diffuse;
3073
3073
  uniform float opacity;
3074
3074
  uniform sampler2D matcap;
@@ -3114,7 +3114,7 @@ void main() {
3114
3114
  #include <fog_fragment>
3115
3115
  #include <premultiplied_alpha_fragment>
3116
3116
  #include <dithering_fragment>
3117
- }`,Jm=`#define NORMAL
3117
+ }`,Qm=`#define NORMAL
3118
3118
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3119
3119
  varying vec3 vViewPosition;
3120
3120
  #endif
@@ -3147,7 +3147,7 @@ void main() {
3147
3147
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3148
3148
  vViewPosition = - mvPosition.xyz;
3149
3149
  #endif
3150
- }`,Qm=`#define NORMAL
3150
+ }`,eg=`#define NORMAL
3151
3151
  uniform float opacity;
3152
3152
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3153
3153
  varying vec3 vViewPosition;
@@ -3168,7 +3168,7 @@ void main() {
3168
3168
  #ifdef OPAQUE
3169
3169
  gl_FragColor.a = 1.0;
3170
3170
  #endif
3171
- }`,eg=`#define PHONG
3171
+ }`,tg=`#define PHONG
3172
3172
  varying vec3 vViewPosition;
3173
3173
  #include <common>
3174
3174
  #include <batching_pars_vertex>
@@ -3207,7 +3207,7 @@ void main() {
3207
3207
  #include <envmap_vertex>
3208
3208
  #include <shadowmap_vertex>
3209
3209
  #include <fog_vertex>
3210
- }`,tg=`#define PHONG
3210
+ }`,ng=`#define PHONG
3211
3211
  uniform vec3 diffuse;
3212
3212
  uniform vec3 emissive;
3213
3213
  uniform vec3 specular;
@@ -3267,7 +3267,7 @@ void main() {
3267
3267
  #include <fog_fragment>
3268
3268
  #include <premultiplied_alpha_fragment>
3269
3269
  #include <dithering_fragment>
3270
- }`,ng=`#define STANDARD
3270
+ }`,ig=`#define STANDARD
3271
3271
  varying vec3 vViewPosition;
3272
3272
  #ifdef USE_TRANSMISSION
3273
3273
  varying vec3 vWorldPosition;
@@ -3310,7 +3310,7 @@ void main() {
3310
3310
  #ifdef USE_TRANSMISSION
3311
3311
  vWorldPosition = worldPosition.xyz;
3312
3312
  #endif
3313
- }`,ig=`#define STANDARD
3313
+ }`,sg=`#define STANDARD
3314
3314
  #ifdef PHYSICAL
3315
3315
  #define IOR
3316
3316
  #define USE_SPECULAR
@@ -3435,7 +3435,7 @@ void main() {
3435
3435
  #include <fog_fragment>
3436
3436
  #include <premultiplied_alpha_fragment>
3437
3437
  #include <dithering_fragment>
3438
- }`,sg=`#define TOON
3438
+ }`,rg=`#define TOON
3439
3439
  varying vec3 vViewPosition;
3440
3440
  #include <common>
3441
3441
  #include <batching_pars_vertex>
@@ -3472,7 +3472,7 @@ void main() {
3472
3472
  #include <worldpos_vertex>
3473
3473
  #include <shadowmap_vertex>
3474
3474
  #include <fog_vertex>
3475
- }`,rg=`#define TOON
3475
+ }`,ag=`#define TOON
3476
3476
  uniform vec3 diffuse;
3477
3477
  uniform vec3 emissive;
3478
3478
  uniform float opacity;
@@ -3524,7 +3524,7 @@ void main() {
3524
3524
  #include <fog_fragment>
3525
3525
  #include <premultiplied_alpha_fragment>
3526
3526
  #include <dithering_fragment>
3527
- }`,ag=`uniform float size;
3527
+ }`,og=`uniform float size;
3528
3528
  uniform float scale;
3529
3529
  #include <common>
3530
3530
  #include <color_pars_vertex>
@@ -3555,7 +3555,7 @@ void main() {
3555
3555
  #include <clipping_planes_vertex>
3556
3556
  #include <worldpos_vertex>
3557
3557
  #include <fog_vertex>
3558
- }`,og=`uniform vec3 diffuse;
3558
+ }`,lg=`uniform vec3 diffuse;
3559
3559
  uniform float opacity;
3560
3560
  #include <common>
3561
3561
  #include <color_pars_fragment>
@@ -3580,7 +3580,7 @@ void main() {
3580
3580
  #include <colorspace_fragment>
3581
3581
  #include <fog_fragment>
3582
3582
  #include <premultiplied_alpha_fragment>
3583
- }`,lg=`#include <common>
3583
+ }`,cg=`#include <common>
3584
3584
  #include <batching_pars_vertex>
3585
3585
  #include <fog_pars_vertex>
3586
3586
  #include <morphtarget_pars_vertex>
@@ -3603,7 +3603,7 @@ void main() {
3603
3603
  #include <worldpos_vertex>
3604
3604
  #include <shadowmap_vertex>
3605
3605
  #include <fog_vertex>
3606
- }`,cg=`uniform vec3 color;
3606
+ }`,ug=`uniform vec3 color;
3607
3607
  uniform float opacity;
3608
3608
  #include <common>
3609
3609
  #include <fog_pars_fragment>
@@ -3619,7 +3619,7 @@ void main() {
3619
3619
  #include <colorspace_fragment>
3620
3620
  #include <fog_fragment>
3621
3621
  #include <premultiplied_alpha_fragment>
3622
- }`,ug=`uniform float rotation;
3622
+ }`,hg=`uniform float rotation;
3623
3623
  uniform vec2 center;
3624
3624
  #include <common>
3625
3625
  #include <uv_pars_vertex>
@@ -3643,7 +3643,7 @@ void main() {
3643
3643
  #include <logdepthbuf_vertex>
3644
3644
  #include <clipping_planes_vertex>
3645
3645
  #include <fog_vertex>
3646
- }`,hg=`uniform vec3 diffuse;
3646
+ }`,dg=`uniform vec3 diffuse;
3647
3647
  uniform float opacity;
3648
3648
  #include <common>
3649
3649
  #include <uv_pars_fragment>
@@ -3668,7 +3668,7 @@ void main() {
3668
3668
  #include <tonemapping_fragment>
3669
3669
  #include <colorspace_fragment>
3670
3670
  #include <fog_fragment>
3671
- }`,Ke={alphahash_fragment:If,alphahash_pars_fragment:Df,alphamap_fragment:Nf,alphamap_pars_fragment:Uf,alphatest_fragment:Ff,alphatest_pars_fragment:Of,aomap_fragment:Bf,aomap_pars_fragment:kf,batching_pars_vertex:zf,batching_vertex:Vf,begin_vertex:Hf,beginnormal_vertex:Gf,bsdfs:Wf,iridescence_fragment:Xf,bumpmap_pars_fragment:Yf,clipping_planes_fragment:qf,clipping_planes_pars_fragment:Kf,clipping_planes_pars_vertex:Zf,clipping_planes_vertex:$f,color_fragment:jf,color_pars_fragment:Jf,color_pars_vertex:Qf,color_vertex:ep,common:tp,cube_uv_reflection_fragment:np,defaultnormal_vertex:ip,displacementmap_pars_vertex:sp,displacementmap_vertex:rp,emissivemap_fragment:ap,emissivemap_pars_fragment:op,colorspace_fragment:lp,colorspace_pars_fragment:cp,envmap_fragment:up,envmap_common_pars_fragment:hp,envmap_pars_fragment:dp,envmap_pars_vertex:fp,envmap_physical_pars_fragment:Ep,envmap_vertex:pp,fog_vertex:mp,fog_pars_vertex:gp,fog_fragment:_p,fog_pars_fragment:xp,gradientmap_pars_fragment:vp,lightmap_pars_fragment:Mp,lights_lambert_fragment:Sp,lights_lambert_pars_fragment:yp,lights_pars_begin:bp,lights_toon_fragment:Tp,lights_toon_pars_fragment:Ap,lights_phong_fragment:wp,lights_phong_pars_fragment:Rp,lights_physical_fragment:Cp,lights_physical_pars_fragment:Pp,lights_fragment_begin:Lp,lights_fragment_maps:Ip,lights_fragment_end:Dp,lightprobes_pars_fragment:Np,logdepthbuf_fragment:Up,logdepthbuf_pars_fragment:Fp,logdepthbuf_pars_vertex:Op,logdepthbuf_vertex:Bp,map_fragment:kp,map_pars_fragment:zp,map_particle_fragment:Vp,map_particle_pars_fragment:Hp,metalnessmap_fragment:Gp,metalnessmap_pars_fragment:Wp,morphinstance_vertex:Xp,morphcolor_vertex:Yp,morphnormal_vertex:qp,morphtarget_pars_vertex:Kp,morphtarget_vertex:Zp,normal_fragment_begin:$p,normal_fragment_maps:jp,normal_pars_fragment:Jp,normal_pars_vertex:Qp,normal_vertex:em,normalmap_pars_fragment:tm,clearcoat_normal_fragment_begin:nm,clearcoat_normal_fragment_maps:im,clearcoat_pars_fragment:sm,iridescence_pars_fragment:rm,opaque_fragment:am,packing:om,premultiplied_alpha_fragment:lm,project_vertex:cm,dithering_fragment:um,dithering_pars_fragment:hm,roughnessmap_fragment:dm,roughnessmap_pars_fragment:fm,shadowmap_pars_fragment:pm,shadowmap_pars_vertex:mm,shadowmap_vertex:gm,shadowmask_pars_fragment:_m,skinbase_vertex:xm,skinning_pars_vertex:vm,skinning_vertex:Mm,skinnormal_vertex:Sm,specularmap_fragment:ym,specularmap_pars_fragment:bm,tonemapping_fragment:Em,tonemapping_pars_fragment:Tm,transmission_fragment:Am,transmission_pars_fragment:wm,uv_pars_fragment:Rm,uv_pars_vertex:Cm,uv_vertex:Pm,worldpos_vertex:Lm,background_vert:Im,background_frag:Dm,backgroundCube_vert:Nm,backgroundCube_frag:Um,cube_vert:Fm,cube_frag:Om,depth_vert:Bm,depth_frag:km,distance_vert:zm,distance_frag:Vm,equirect_vert:Hm,equirect_frag:Gm,linedashed_vert:Wm,linedashed_frag:Xm,meshbasic_vert:Ym,meshbasic_frag:qm,meshlambert_vert:Km,meshlambert_frag:Zm,meshmatcap_vert:$m,meshmatcap_frag:jm,meshnormal_vert:Jm,meshnormal_frag:Qm,meshphong_vert:eg,meshphong_frag:tg,meshphysical_vert:ng,meshphysical_frag:ig,meshtoon_vert:sg,meshtoon_frag:rg,points_vert:ag,points_frag:og,shadow_vert:lg,shadow_frag:cg,sprite_vert:ug,sprite_frag:hg},xe={common:{diffuse:{value:new Ue(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new He},alphaMap:{value:null},alphaMapTransform:{value:new He},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new He}},envmap:{envMap:{value:null},envMapRotation:{value:new He},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new He}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new He}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new He},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new He},normalScale:{value:new ke(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new He},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new He}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new He}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new He}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ue(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new C},probesMax:{value:new C},probesResolution:{value:new C}},points:{diffuse:{value:new Ue(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new He},alphaTest:{value:0},uvTransform:{value:new He}},sprite:{diffuse:{value:new Ue(16777215)},opacity:{value:1},center:{value:new ke(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new He},alphaMap:{value:null},alphaMapTransform:{value:new He},alphaTest:{value:0}}},wn={basic:{uniforms:Jt([xe.common,xe.specularmap,xe.envmap,xe.aomap,xe.lightmap,xe.fog]),vertexShader:Ke.meshbasic_vert,fragmentShader:Ke.meshbasic_frag},lambert:{uniforms:Jt([xe.common,xe.specularmap,xe.envmap,xe.aomap,xe.lightmap,xe.emissivemap,xe.bumpmap,xe.normalmap,xe.displacementmap,xe.fog,xe.lights,{emissive:{value:new Ue(0)},envMapIntensity:{value:1}}]),vertexShader:Ke.meshlambert_vert,fragmentShader:Ke.meshlambert_frag},phong:{uniforms:Jt([xe.common,xe.specularmap,xe.envmap,xe.aomap,xe.lightmap,xe.emissivemap,xe.bumpmap,xe.normalmap,xe.displacementmap,xe.fog,xe.lights,{emissive:{value:new Ue(0)},specular:{value:new Ue(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ke.meshphong_vert,fragmentShader:Ke.meshphong_frag},standard:{uniforms:Jt([xe.common,xe.envmap,xe.aomap,xe.lightmap,xe.emissivemap,xe.bumpmap,xe.normalmap,xe.displacementmap,xe.roughnessmap,xe.metalnessmap,xe.fog,xe.lights,{emissive:{value:new Ue(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ke.meshphysical_vert,fragmentShader:Ke.meshphysical_frag},toon:{uniforms:Jt([xe.common,xe.aomap,xe.lightmap,xe.emissivemap,xe.bumpmap,xe.normalmap,xe.displacementmap,xe.gradientmap,xe.fog,xe.lights,{emissive:{value:new Ue(0)}}]),vertexShader:Ke.meshtoon_vert,fragmentShader:Ke.meshtoon_frag},matcap:{uniforms:Jt([xe.common,xe.bumpmap,xe.normalmap,xe.displacementmap,xe.fog,{matcap:{value:null}}]),vertexShader:Ke.meshmatcap_vert,fragmentShader:Ke.meshmatcap_frag},points:{uniforms:Jt([xe.points,xe.fog]),vertexShader:Ke.points_vert,fragmentShader:Ke.points_frag},dashed:{uniforms:Jt([xe.common,xe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ke.linedashed_vert,fragmentShader:Ke.linedashed_frag},depth:{uniforms:Jt([xe.common,xe.displacementmap]),vertexShader:Ke.depth_vert,fragmentShader:Ke.depth_frag},normal:{uniforms:Jt([xe.common,xe.bumpmap,xe.normalmap,xe.displacementmap,{opacity:{value:1}}]),vertexShader:Ke.meshnormal_vert,fragmentShader:Ke.meshnormal_frag},sprite:{uniforms:Jt([xe.sprite,xe.fog]),vertexShader:Ke.sprite_vert,fragmentShader:Ke.sprite_frag},background:{uniforms:{uvTransform:{value:new He},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ke.background_vert,fragmentShader:Ke.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new He}},vertexShader:Ke.backgroundCube_vert,fragmentShader:Ke.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ke.cube_vert,fragmentShader:Ke.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ke.equirect_vert,fragmentShader:Ke.equirect_frag},distance:{uniforms:Jt([xe.common,xe.displacementmap,{referencePosition:{value:new C},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ke.distance_vert,fragmentShader:Ke.distance_frag},shadow:{uniforms:Jt([xe.lights,xe.fog,{color:{value:new Ue(0)},opacity:{value:1}}]),vertexShader:Ke.shadow_vert,fragmentShader:Ke.shadow_frag}};wn.physical={uniforms:Jt([wn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new He},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new He},clearcoatNormalScale:{value:new ke(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new He},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new He},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new He},sheen:{value:0},sheenColor:{value:new Ue(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new He},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new He},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new He},transmissionSamplerSize:{value:new ke},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new He},attenuationDistance:{value:0},attenuationColor:{value:new Ue(0)},specularColor:{value:new Ue(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new He},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new He},anisotropyVector:{value:new ke},anisotropyMap:{value:null},anisotropyMapTransform:{value:new He}}]),vertexShader:Ke.meshphysical_vert,fragmentShader:Ke.meshphysical_frag};const _r={r:0,b:0,g:0},dg=new We,Au=new He;Au.set(-1,0,0,0,1,0,0,0,1);function fg(s,e,t,n,i,r){const a=new Ue(0);let o=i===!0?0:1,l,c,u=null,h=0,d=null;function f(b){let T=b.isScene===!0?b.background:null;if(T&&T.isTexture){const S=b.backgroundBlurriness>0;T=e.get(T,S)}return T}function _(b){let T=!1;const S=f(b);S===null?m(a,o):S&&S.isColor&&(m(S,1),T=!0);const w=s.xr.getEnvironmentBlendMode();w==="additive"?t.buffers.color.setClear(0,0,0,1,r):w==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(s.autoClear||T)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil))}function v(b,T){const S=f(T);S&&(S.isCubeTexture||S.mapping===Or)?(c===void 0&&(c=new bt(new Vs(1,1,1),new Un({name:"BackgroundCubeMaterial",uniforms:is(wn.backgroundCube.uniforms),vertexShader:wn.backgroundCube.vertexShader,fragmentShader:wn.backgroundCube.fragmentShader,side:tn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(w,E,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(c)),c.material.uniforms.envMap.value=S,c.material.uniforms.backgroundBlurriness.value=T.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(dg.makeRotationFromEuler(T.backgroundRotation)).transpose(),S.isCubeTexture&&S.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(Au),c.material.toneMapped=Qe.getTransfer(S.colorSpace)!==ut,(u!==S||h!==S.version||d!==s.toneMapping)&&(c.material.needsUpdate=!0,u=S,h=S.version,d=s.toneMapping),c.layers.enableAll(),b.unshift(c,c.geometry,c.material,0,0,null)):S&&S.isTexture&&(l===void 0&&(l=new bt(new kr(2,2),new Un({name:"BackgroundMaterial",uniforms:is(wn.background.uniforms),vertexShader:wn.background.vertexShader,fragmentShader:wn.background.fragmentShader,side:Dn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(l)),l.material.uniforms.t2D.value=S,l.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,l.material.toneMapped=Qe.getTransfer(S.colorSpace)!==ut,S.matrixAutoUpdate===!0&&S.updateMatrix(),l.material.uniforms.uvTransform.value.copy(S.matrix),(u!==S||h!==S.version||d!==s.toneMapping)&&(l.material.needsUpdate=!0,u=S,h=S.version,d=s.toneMapping),l.layers.enableAll(),b.unshift(l,l.geometry,l.material,0,0,null))}function m(b,T){b.getRGB(_r,yu(s)),t.buffers.color.setClear(_r.r,_r.g,_r.b,T,r)}function p(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return a},setClearColor:function(b,T=1){a.set(b),o=T,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(b){o=b,m(a,o)},render:_,addToRenderList:v,dispose:p}}function pg(s,e){const t=s.getParameter(s.MAX_VERTEX_ATTRIBS),n={},i=d(null);let r=i,a=!1;function o(P,F,$,j,k){let q=!1;const W=h(P,j,$,F);r!==W&&(r=W,c(r.object)),q=f(P,j,$,k),q&&_(P,j,$,k),k!==null&&e.update(k,s.ELEMENT_ARRAY_BUFFER),(q||a)&&(a=!1,S(P,F,$,j),k!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,e.get(k).buffer))}function l(){return s.createVertexArray()}function c(P){return s.bindVertexArray(P)}function u(P){return s.deleteVertexArray(P)}function h(P,F,$,j){const k=j.wireframe===!0;let q=n[F.id];q===void 0&&(q={},n[F.id]=q);const W=P.isInstancedMesh===!0?P.id:0;let ee=q[W];ee===void 0&&(ee={},q[W]=ee);let K=ee[$.id];K===void 0&&(K={},ee[$.id]=K);let le=K[k];return le===void 0&&(le=d(l()),K[k]=le),le}function d(P){const F=[],$=[],j=[];for(let k=0;k<t;k++)F[k]=0,$[k]=0,j[k]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:F,enabledAttributes:$,attributeDivisors:j,object:P,attributes:{},index:null}}function f(P,F,$,j){const k=r.attributes,q=F.attributes;let W=0;const ee=$.getAttributes();for(const K in ee)if(ee[K].location>=0){const pe=k[K];let Me=q[K];if(Me===void 0&&(K==="instanceMatrix"&&P.instanceMatrix&&(Me=P.instanceMatrix),K==="instanceColor"&&P.instanceColor&&(Me=P.instanceColor)),pe===void 0||pe.attribute!==Me||Me&&pe.data!==Me.data)return!0;W++}return r.attributesNum!==W||r.index!==j}function _(P,F,$,j){const k={},q=F.attributes;let W=0;const ee=$.getAttributes();for(const K in ee)if(ee[K].location>=0){let pe=q[K];pe===void 0&&(K==="instanceMatrix"&&P.instanceMatrix&&(pe=P.instanceMatrix),K==="instanceColor"&&P.instanceColor&&(pe=P.instanceColor));const Me={};Me.attribute=pe,pe&&pe.data&&(Me.data=pe.data),k[K]=Me,W++}r.attributes=k,r.attributesNum=W,r.index=j}function v(){const P=r.newAttributes;for(let F=0,$=P.length;F<$;F++)P[F]=0}function m(P){p(P,0)}function p(P,F){const $=r.newAttributes,j=r.enabledAttributes,k=r.attributeDivisors;$[P]=1,j[P]===0&&(s.enableVertexAttribArray(P),j[P]=1),k[P]!==F&&(s.vertexAttribDivisor(P,F),k[P]=F)}function b(){const P=r.newAttributes,F=r.enabledAttributes;for(let $=0,j=F.length;$<j;$++)F[$]!==P[$]&&(s.disableVertexAttribArray($),F[$]=0)}function T(P,F,$,j,k,q,W){W===!0?s.vertexAttribIPointer(P,F,$,k,q):s.vertexAttribPointer(P,F,$,j,k,q)}function S(P,F,$,j){v();const k=j.attributes,q=$.getAttributes(),W=F.defaultAttributeValues;for(const ee in q){const K=q[ee];if(K.location>=0){let le=k[ee];if(le===void 0&&(ee==="instanceMatrix"&&P.instanceMatrix&&(le=P.instanceMatrix),ee==="instanceColor"&&P.instanceColor&&(le=P.instanceColor)),le!==void 0){const pe=le.normalized,Me=le.itemSize,Ye=e.get(le);if(Ye===void 0)continue;const rt=Ye.buffer,qe=Ye.type,ne=Ye.bytesPerElement,he=qe===s.INT||qe===s.UNSIGNED_INT||le.gpuType===Uo;if(le.isInterleavedBufferAttribute){const ae=le.data,Be=ae.stride,Oe=le.offset;if(ae.isInstancedInterleavedBuffer){for(let De=0;De<K.locationSize;De++)p(K.location+De,ae.meshPerAttribute);P.isInstancedMesh!==!0&&j._maxInstanceCount===void 0&&(j._maxInstanceCount=ae.meshPerAttribute*ae.count)}else for(let De=0;De<K.locationSize;De++)m(K.location+De);s.bindBuffer(s.ARRAY_BUFFER,rt);for(let De=0;De<K.locationSize;De++)T(K.location+De,Me/K.locationSize,qe,pe,Be*ne,(Oe+Me/K.locationSize*De)*ne,he)}else{if(le.isInstancedBufferAttribute){for(let ae=0;ae<K.locationSize;ae++)p(K.location+ae,le.meshPerAttribute);P.isInstancedMesh!==!0&&j._maxInstanceCount===void 0&&(j._maxInstanceCount=le.meshPerAttribute*le.count)}else for(let ae=0;ae<K.locationSize;ae++)m(K.location+ae);s.bindBuffer(s.ARRAY_BUFFER,rt);for(let ae=0;ae<K.locationSize;ae++)T(K.location+ae,Me/K.locationSize,qe,pe,Me*ne,Me/K.locationSize*ae*ne,he)}}else if(W!==void 0){const pe=W[ee];if(pe!==void 0)switch(pe.length){case 2:s.vertexAttrib2fv(K.location,pe);break;case 3:s.vertexAttrib3fv(K.location,pe);break;case 4:s.vertexAttrib4fv(K.location,pe);break;default:s.vertexAttrib1fv(K.location,pe)}}}}b()}function w(){A();for(const P in n){const F=n[P];for(const $ in F){const j=F[$];for(const k in j){const q=j[k];for(const W in q)u(q[W].object),delete q[W];delete j[k]}}delete n[P]}}function E(P){if(n[P.id]===void 0)return;const F=n[P.id];for(const $ in F){const j=F[$];for(const k in j){const q=j[k];for(const W in q)u(q[W].object),delete q[W];delete j[k]}}delete n[P.id]}function R(P){for(const F in n){const $=n[F];for(const j in $){const k=$[j];if(k[P.id]===void 0)continue;const q=k[P.id];for(const W in q)u(q[W].object),delete q[W];delete k[P.id]}}}function x(P){for(const F in n){const $=n[F],j=P.isInstancedMesh===!0?P.id:0,k=$[j];if(k!==void 0){for(const q in k){const W=k[q];for(const ee in W)u(W[ee].object),delete W[ee];delete k[q]}delete $[j],Object.keys($).length===0&&delete n[F]}}}function A(){D(),a=!0,r!==i&&(r=i,c(r.object))}function D(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:o,reset:A,resetDefaultState:D,dispose:w,releaseStatesOfGeometry:E,releaseStatesOfObject:x,releaseStatesOfProgram:R,initAttributes:v,enableAttribute:m,disableUnusedAttributes:b}}function mg(s,e,t){let n;function i(l){n=l}function r(l,c){s.drawArrays(n,l,c),t.update(c,n,1)}function a(l,c,u){u!==0&&(s.drawArraysInstanced(n,l,c,u),t.update(c,n,u))}function o(l,c,u){if(u===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,c,0,u);let d=0;for(let f=0;f<u;f++)d+=c[f];t.update(d,n,1)}this.setMode=i,this.render=r,this.renderInstances=a,this.renderMultiDraw=o}function gg(s,e,t,n){let i;function r(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const R=e.get("EXT_texture_filter_anisotropic");i=s.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function a(R){return!(R!==pn&&n.convert(R)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(R){const x=R===$n&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(R!==on&&n.convert(R)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_TYPE)&&R!==fn&&!x)}function l(R){if(R==="highp"){if(s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.HIGH_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";R="mediump"}return R==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const u=l(c);u!==c&&(Ie("WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);const h=t.logarithmicDepthBuffer===!0,d=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&d===!1&&Ie("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const f=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),_=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=s.getParameter(s.MAX_TEXTURE_SIZE),m=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),p=s.getParameter(s.MAX_VERTEX_ATTRIBS),b=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),T=s.getParameter(s.MAX_VARYING_VECTORS),S=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),w=s.getParameter(s.MAX_SAMPLES),E=s.getParameter(s.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:h,reversedDepthBuffer:d,maxTextures:f,maxVertexTextures:_,maxTextureSize:v,maxCubemapSize:m,maxAttributes:p,maxVertexUniforms:b,maxVaryings:T,maxFragmentUniforms:S,maxSamples:w,samples:E}}function _g(s){const e=this;let t=null,n=0,i=!1,r=!1;const a=new Xn,o=new He,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,d){const f=h.length!==0||d||n!==0||i;return i=d,n=h.length,f},this.beginShadows=function(){r=!0,u(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(h,d){t=u(h,d,0)},this.setState=function(h,d,f){const _=h.clippingPlanes,v=h.clipIntersection,m=h.clipShadows,p=s.get(h);if(!i||_===null||_.length===0||r&&!m)r?u(null):c();else{const b=r?0:n,T=b*4;let S=p.clippingState||null;l.value=S,S=u(_,d,T,f);for(let w=0;w!==T;++w)S[w]=t[w];p.clippingState=S,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=b}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(h,d,f,_){const v=h!==null?h.length:0;let m=null;if(v!==0){if(m=l.value,_!==!0||m===null){const p=f+v*4,b=d.matrixWorldInverse;o.getNormalMatrix(b),(m===null||m.length<p)&&(m=new Float32Array(p));for(let T=0,S=f;T!==v;++T,S+=4)a.copy(h[T]).applyMatrix4(b,o),a.normal.toArray(m,S),m[S+3]=a.constant}l.value=m,l.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,m}}const ci=4,hc=[.125,.215,.35,.446,.526,.582],vi=20,xg=256,Es=new Vr,dc=new Ue;let Sa=null,ya=0,ba=0,Ea=!1;const vg=new C;class fc{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=.1,i=100,r={}){const{size:a=256,position:o=vg}=r;Sa=this._renderer.getRenderTarget(),ya=this._renderer.getActiveCubeFace(),ba=this._renderer.getActiveMipmapLevel(),Ea=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,n,i,l,o),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=gc(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=mc(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Sa,ya,ba),this._renderer.xr.enabled=Ea,e.scissorTest=!1,Wi(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===bi||e.mapping===Qi?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Sa=this._renderer.getRenderTarget(),ya=this._renderer.getActiveCubeFace(),ba=this._renderer.getActiveMipmapLevel(),Ea=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Bt,minFilter:Bt,generateMipmaps:!1,type:$n,format:pn,colorSpace:ln,depthBuffer:!1},i=pc(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=pc(e,t,n);const{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=Mg(r)),this._blurMaterial=yg(r,e,t),this._ggxMaterial=Sg(r,e,t)}return i}_compileMaterial(e){const t=new bt(new Wt,e);this._renderer.compile(t,Es)}_sceneToCubeUV(e,t,n,i,r){const l=new Qt(90,1,t,n),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],h=this._renderer,d=h.autoClear,f=h.toneMapping;h.getClearColor(dc),h.toneMapping=Pn,h.autoClear=!1,h.state.buffers.depth.getReversed()&&(h.setRenderTarget(i),h.clearDepth(),h.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new bt(new Vs,new yi({name:"PMREM.Background",side:tn,depthWrite:!1,depthTest:!1})));const v=this._backgroundBox,m=v.material;let p=!1;const b=e.background;b?b.isColor&&(m.color.copy(b),e.background=null,p=!0):(m.color.copy(dc),p=!0);for(let T=0;T<6;T++){const S=T%3;S===0?(l.up.set(0,c[T],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x+u[T],r.y,r.z)):S===1?(l.up.set(0,0,c[T]),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y+u[T],r.z)):(l.up.set(0,c[T],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y,r.z+u[T]));const w=this._cubeSize;Wi(i,S*w,T>2?w:0,w,w),h.setRenderTarget(i),p&&h.render(v,l),h.render(e,l)}h.toneMapping=f,h.autoClear=d,e.background=b}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===bi||e.mapping===Qi;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=gc()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=mc());const r=i?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const l=this._cubeSize;Wi(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(a,Es)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const i=this._lodMeshes.length;for(let r=1;r<i;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,n){const i=this._renderer,r=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[n];o.material=a;const l=a.uniforms,c=n/(this._lodMeshes.length-1),u=t/(this._lodMeshes.length-1),h=Math.sqrt(c*c-u*u),d=0+c*1.25,f=h*d,{_lodMax:_}=this,v=this._sizeLods[n],m=3*v*(n>_-ci?n-_+ci:0),p=4*(this._cubeSize-v);l.envMap.value=e.texture,l.roughness.value=f,l.mipInt.value=_-t,Wi(r,m,p,3*v,2*v),i.setRenderTarget(r),i.render(o,Es),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=_-n,Wi(e,m,p,3*v,2*v),i.setRenderTarget(e),i.render(o,Es)}_blur(e,t,n,i,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,i,"latitudinal",r),this._halfBlur(a,e,n,n,i,"longitudinal",r)}_halfBlur(e,t,n,i,r,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&ze("blur direction must be either latitudinal or longitudinal!");const u=3,h=this._lodMeshes[i];h.material=c;const d=c.uniforms,f=this._sizeLods[n]-1,_=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*vi-1),v=r/_,m=isFinite(r)?1+Math.floor(u*v):vi;m>vi&&Ie(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${vi}`);const p=[];let b=0;for(let R=0;R<vi;++R){const x=R/v,A=Math.exp(-x*x/2);p.push(A),R===0?b+=A:R<m&&(b+=2*A)}for(let R=0;R<p.length;R++)p[R]=p[R]/b;d.envMap.value=e.texture,d.samples.value=m,d.weights.value=p,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:T}=this;d.dTheta.value=_,d.mipInt.value=T-n;const S=this._sizeLods[i],w=3*S*(i>T-ci?i-T+ci:0),E=4*(this._cubeSize-S);Wi(t,w,E,3*S,2*S),l.setRenderTarget(t),l.render(h,Es)}}function Mg(s){const e=[],t=[],n=[];let i=s;const r=s-ci+1+hc.length;for(let a=0;a<r;a++){const o=Math.pow(2,i);e.push(o);let l=1/o;a>s-ci?l=hc[a-s+ci-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),u=-c,h=1+c,d=[u,u,h,u,h,h,u,u,h,h,u,h],f=6,_=6,v=3,m=2,p=1,b=new Float32Array(v*_*f),T=new Float32Array(m*_*f),S=new Float32Array(p*_*f);for(let E=0;E<f;E++){const R=E%3*2/3-1,x=E>2?0:-1,A=[R,x,0,R+2/3,x,0,R+2/3,x+1,0,R,x,0,R+2/3,x+1,0,R,x+1,0];b.set(A,v*_*E),T.set(d,m*_*E);const D=[E,E,E,E,E,E];S.set(D,p*_*E)}const w=new Wt;w.setAttribute("position",new Nt(b,v)),w.setAttribute("uv",new Nt(T,m)),w.setAttribute("faceIndex",new Nt(S,p)),n.push(new bt(w,null)),i>ci&&i--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function pc(s,e,t){const n=new Ln(s,e,t);return n.texture.mapping=Or,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Wi(s,e,t,n,i){s.viewport.set(e,t,n,i),s.scissor.set(e,t,n,i)}function Sg(s,e,t){return new Un({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:xg,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Hr(),fragmentShader:`
3671
+ }`,Ke={alphahash_fragment:Df,alphahash_pars_fragment:Nf,alphamap_fragment:Uf,alphamap_pars_fragment:Ff,alphatest_fragment:Of,alphatest_pars_fragment:Bf,aomap_fragment:kf,aomap_pars_fragment:zf,batching_pars_vertex:Vf,batching_vertex:Hf,begin_vertex:Gf,beginnormal_vertex:Wf,bsdfs:Xf,iridescence_fragment:Yf,bumpmap_pars_fragment:qf,clipping_planes_fragment:Kf,clipping_planes_pars_fragment:Zf,clipping_planes_pars_vertex:$f,clipping_planes_vertex:jf,color_fragment:Jf,color_pars_fragment:Qf,color_pars_vertex:ep,color_vertex:tp,common:np,cube_uv_reflection_fragment:ip,defaultnormal_vertex:sp,displacementmap_pars_vertex:rp,displacementmap_vertex:ap,emissivemap_fragment:op,emissivemap_pars_fragment:lp,colorspace_fragment:cp,colorspace_pars_fragment:up,envmap_fragment:hp,envmap_common_pars_fragment:dp,envmap_pars_fragment:fp,envmap_pars_vertex:pp,envmap_physical_pars_fragment:Tp,envmap_vertex:mp,fog_vertex:gp,fog_pars_vertex:_p,fog_fragment:xp,fog_pars_fragment:vp,gradientmap_pars_fragment:Mp,lightmap_pars_fragment:Sp,lights_lambert_fragment:yp,lights_lambert_pars_fragment:bp,lights_pars_begin:Ep,lights_toon_fragment:Ap,lights_toon_pars_fragment:wp,lights_phong_fragment:Rp,lights_phong_pars_fragment:Cp,lights_physical_fragment:Pp,lights_physical_pars_fragment:Lp,lights_fragment_begin:Ip,lights_fragment_maps:Dp,lights_fragment_end:Np,lightprobes_pars_fragment:Up,logdepthbuf_fragment:Fp,logdepthbuf_pars_fragment:Op,logdepthbuf_pars_vertex:Bp,logdepthbuf_vertex:kp,map_fragment:zp,map_pars_fragment:Vp,map_particle_fragment:Hp,map_particle_pars_fragment:Gp,metalnessmap_fragment:Wp,metalnessmap_pars_fragment:Xp,morphinstance_vertex:Yp,morphcolor_vertex:qp,morphnormal_vertex:Kp,morphtarget_pars_vertex:Zp,morphtarget_vertex:$p,normal_fragment_begin:jp,normal_fragment_maps:Jp,normal_pars_fragment:Qp,normal_pars_vertex:em,normal_vertex:tm,normalmap_pars_fragment:nm,clearcoat_normal_fragment_begin:im,clearcoat_normal_fragment_maps:sm,clearcoat_pars_fragment:rm,iridescence_pars_fragment:am,opaque_fragment:om,packing:lm,premultiplied_alpha_fragment:cm,project_vertex:um,dithering_fragment:hm,dithering_pars_fragment:dm,roughnessmap_fragment:fm,roughnessmap_pars_fragment:pm,shadowmap_pars_fragment:mm,shadowmap_pars_vertex:gm,shadowmap_vertex:_m,shadowmask_pars_fragment:xm,skinbase_vertex:vm,skinning_pars_vertex:Mm,skinning_vertex:Sm,skinnormal_vertex:ym,specularmap_fragment:bm,specularmap_pars_fragment:Em,tonemapping_fragment:Tm,tonemapping_pars_fragment:Am,transmission_fragment:wm,transmission_pars_fragment:Rm,uv_pars_fragment:Cm,uv_pars_vertex:Pm,uv_vertex:Lm,worldpos_vertex:Im,background_vert:Dm,background_frag:Nm,backgroundCube_vert:Um,backgroundCube_frag:Fm,cube_vert:Om,cube_frag:Bm,depth_vert:km,depth_frag:zm,distance_vert:Vm,distance_frag:Hm,equirect_vert:Gm,equirect_frag:Wm,linedashed_vert:Xm,linedashed_frag:Ym,meshbasic_vert:qm,meshbasic_frag:Km,meshlambert_vert:Zm,meshlambert_frag:$m,meshmatcap_vert:jm,meshmatcap_frag:Jm,meshnormal_vert:Qm,meshnormal_frag:eg,meshphong_vert:tg,meshphong_frag:ng,meshphysical_vert:ig,meshphysical_frag:sg,meshtoon_vert:rg,meshtoon_frag:ag,points_vert:og,points_frag:lg,shadow_vert:cg,shadow_frag:ug,sprite_vert:hg,sprite_frag:dg},xe={common:{diffuse:{value:new Ue(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new He},alphaMap:{value:null},alphaMapTransform:{value:new He},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new He}},envmap:{envMap:{value:null},envMapRotation:{value:new He},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new He}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new He}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new He},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new He},normalScale:{value:new ke(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new He},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new He}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new He}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new He}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ue(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new C},probesMax:{value:new C},probesResolution:{value:new C}},points:{diffuse:{value:new Ue(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new He},alphaTest:{value:0},uvTransform:{value:new He}},sprite:{diffuse:{value:new Ue(16777215)},opacity:{value:1},center:{value:new ke(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new He},alphaMap:{value:null},alphaMapTransform:{value:new He},alphaTest:{value:0}}},wn={basic:{uniforms:Jt([xe.common,xe.specularmap,xe.envmap,xe.aomap,xe.lightmap,xe.fog]),vertexShader:Ke.meshbasic_vert,fragmentShader:Ke.meshbasic_frag},lambert:{uniforms:Jt([xe.common,xe.specularmap,xe.envmap,xe.aomap,xe.lightmap,xe.emissivemap,xe.bumpmap,xe.normalmap,xe.displacementmap,xe.fog,xe.lights,{emissive:{value:new Ue(0)},envMapIntensity:{value:1}}]),vertexShader:Ke.meshlambert_vert,fragmentShader:Ke.meshlambert_frag},phong:{uniforms:Jt([xe.common,xe.specularmap,xe.envmap,xe.aomap,xe.lightmap,xe.emissivemap,xe.bumpmap,xe.normalmap,xe.displacementmap,xe.fog,xe.lights,{emissive:{value:new Ue(0)},specular:{value:new Ue(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ke.meshphong_vert,fragmentShader:Ke.meshphong_frag},standard:{uniforms:Jt([xe.common,xe.envmap,xe.aomap,xe.lightmap,xe.emissivemap,xe.bumpmap,xe.normalmap,xe.displacementmap,xe.roughnessmap,xe.metalnessmap,xe.fog,xe.lights,{emissive:{value:new Ue(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ke.meshphysical_vert,fragmentShader:Ke.meshphysical_frag},toon:{uniforms:Jt([xe.common,xe.aomap,xe.lightmap,xe.emissivemap,xe.bumpmap,xe.normalmap,xe.displacementmap,xe.gradientmap,xe.fog,xe.lights,{emissive:{value:new Ue(0)}}]),vertexShader:Ke.meshtoon_vert,fragmentShader:Ke.meshtoon_frag},matcap:{uniforms:Jt([xe.common,xe.bumpmap,xe.normalmap,xe.displacementmap,xe.fog,{matcap:{value:null}}]),vertexShader:Ke.meshmatcap_vert,fragmentShader:Ke.meshmatcap_frag},points:{uniforms:Jt([xe.points,xe.fog]),vertexShader:Ke.points_vert,fragmentShader:Ke.points_frag},dashed:{uniforms:Jt([xe.common,xe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ke.linedashed_vert,fragmentShader:Ke.linedashed_frag},depth:{uniforms:Jt([xe.common,xe.displacementmap]),vertexShader:Ke.depth_vert,fragmentShader:Ke.depth_frag},normal:{uniforms:Jt([xe.common,xe.bumpmap,xe.normalmap,xe.displacementmap,{opacity:{value:1}}]),vertexShader:Ke.meshnormal_vert,fragmentShader:Ke.meshnormal_frag},sprite:{uniforms:Jt([xe.sprite,xe.fog]),vertexShader:Ke.sprite_vert,fragmentShader:Ke.sprite_frag},background:{uniforms:{uvTransform:{value:new He},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ke.background_vert,fragmentShader:Ke.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new He}},vertexShader:Ke.backgroundCube_vert,fragmentShader:Ke.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ke.cube_vert,fragmentShader:Ke.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ke.equirect_vert,fragmentShader:Ke.equirect_frag},distance:{uniforms:Jt([xe.common,xe.displacementmap,{referencePosition:{value:new C},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ke.distance_vert,fragmentShader:Ke.distance_frag},shadow:{uniforms:Jt([xe.lights,xe.fog,{color:{value:new Ue(0)},opacity:{value:1}}]),vertexShader:Ke.shadow_vert,fragmentShader:Ke.shadow_frag}};wn.physical={uniforms:Jt([wn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new He},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new He},clearcoatNormalScale:{value:new ke(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new He},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new He},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new He},sheen:{value:0},sheenColor:{value:new Ue(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new He},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new He},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new He},transmissionSamplerSize:{value:new ke},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new He},attenuationDistance:{value:0},attenuationColor:{value:new Ue(0)},specularColor:{value:new Ue(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new He},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new He},anisotropyVector:{value:new ke},anisotropyMap:{value:null},anisotropyMapTransform:{value:new He}}]),vertexShader:Ke.meshphysical_vert,fragmentShader:Ke.meshphysical_frag};const _r={r:0,b:0,g:0},fg=new We,Au=new He;Au.set(-1,0,0,0,1,0,0,0,1);function pg(s,e,t,n,i,r){const a=new Ue(0);let o=i===!0?0:1,l,c,u=null,h=0,d=null;function f(b){let T=b.isScene===!0?b.background:null;if(T&&T.isTexture){const S=b.backgroundBlurriness>0;T=e.get(T,S)}return T}function _(b){let T=!1;const S=f(b);S===null?m(a,o):S&&S.isColor&&(m(S,1),T=!0);const w=s.xr.getEnvironmentBlendMode();w==="additive"?t.buffers.color.setClear(0,0,0,1,r):w==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(s.autoClear||T)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil))}function v(b,T){const S=f(T);S&&(S.isCubeTexture||S.mapping===Or)?(c===void 0&&(c=new bt(new Vs(1,1,1),new Un({name:"BackgroundCubeMaterial",uniforms:is(wn.backgroundCube.uniforms),vertexShader:wn.backgroundCube.vertexShader,fragmentShader:wn.backgroundCube.fragmentShader,side:tn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(w,E,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(c)),c.material.uniforms.envMap.value=S,c.material.uniforms.backgroundBlurriness.value=T.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(fg.makeRotationFromEuler(T.backgroundRotation)).transpose(),S.isCubeTexture&&S.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(Au),c.material.toneMapped=Qe.getTransfer(S.colorSpace)!==ut,(u!==S||h!==S.version||d!==s.toneMapping)&&(c.material.needsUpdate=!0,u=S,h=S.version,d=s.toneMapping),c.layers.enableAll(),b.unshift(c,c.geometry,c.material,0,0,null)):S&&S.isTexture&&(l===void 0&&(l=new bt(new kr(2,2),new Un({name:"BackgroundMaterial",uniforms:is(wn.background.uniforms),vertexShader:wn.background.vertexShader,fragmentShader:wn.background.fragmentShader,side:Dn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(l)),l.material.uniforms.t2D.value=S,l.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,l.material.toneMapped=Qe.getTransfer(S.colorSpace)!==ut,S.matrixAutoUpdate===!0&&S.updateMatrix(),l.material.uniforms.uvTransform.value.copy(S.matrix),(u!==S||h!==S.version||d!==s.toneMapping)&&(l.material.needsUpdate=!0,u=S,h=S.version,d=s.toneMapping),l.layers.enableAll(),b.unshift(l,l.geometry,l.material,0,0,null))}function m(b,T){b.getRGB(_r,yu(s)),t.buffers.color.setClear(_r.r,_r.g,_r.b,T,r)}function p(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return a},setClearColor:function(b,T=1){a.set(b),o=T,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(b){o=b,m(a,o)},render:_,addToRenderList:v,dispose:p}}function mg(s,e){const t=s.getParameter(s.MAX_VERTEX_ATTRIBS),n={},i=d(null);let r=i,a=!1;function o(P,F,$,j,k){let q=!1;const W=h(P,j,$,F);r!==W&&(r=W,c(r.object)),q=f(P,j,$,k),q&&_(P,j,$,k),k!==null&&e.update(k,s.ELEMENT_ARRAY_BUFFER),(q||a)&&(a=!1,S(P,F,$,j),k!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,e.get(k).buffer))}function l(){return s.createVertexArray()}function c(P){return s.bindVertexArray(P)}function u(P){return s.deleteVertexArray(P)}function h(P,F,$,j){const k=j.wireframe===!0;let q=n[F.id];q===void 0&&(q={},n[F.id]=q);const W=P.isInstancedMesh===!0?P.id:0;let ee=q[W];ee===void 0&&(ee={},q[W]=ee);let K=ee[$.id];K===void 0&&(K={},ee[$.id]=K);let le=K[k];return le===void 0&&(le=d(l()),K[k]=le),le}function d(P){const F=[],$=[],j=[];for(let k=0;k<t;k++)F[k]=0,$[k]=0,j[k]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:F,enabledAttributes:$,attributeDivisors:j,object:P,attributes:{},index:null}}function f(P,F,$,j){const k=r.attributes,q=F.attributes;let W=0;const ee=$.getAttributes();for(const K in ee)if(ee[K].location>=0){const pe=k[K];let Me=q[K];if(Me===void 0&&(K==="instanceMatrix"&&P.instanceMatrix&&(Me=P.instanceMatrix),K==="instanceColor"&&P.instanceColor&&(Me=P.instanceColor)),pe===void 0||pe.attribute!==Me||Me&&pe.data!==Me.data)return!0;W++}return r.attributesNum!==W||r.index!==j}function _(P,F,$,j){const k={},q=F.attributes;let W=0;const ee=$.getAttributes();for(const K in ee)if(ee[K].location>=0){let pe=q[K];pe===void 0&&(K==="instanceMatrix"&&P.instanceMatrix&&(pe=P.instanceMatrix),K==="instanceColor"&&P.instanceColor&&(pe=P.instanceColor));const Me={};Me.attribute=pe,pe&&pe.data&&(Me.data=pe.data),k[K]=Me,W++}r.attributes=k,r.attributesNum=W,r.index=j}function v(){const P=r.newAttributes;for(let F=0,$=P.length;F<$;F++)P[F]=0}function m(P){p(P,0)}function p(P,F){const $=r.newAttributes,j=r.enabledAttributes,k=r.attributeDivisors;$[P]=1,j[P]===0&&(s.enableVertexAttribArray(P),j[P]=1),k[P]!==F&&(s.vertexAttribDivisor(P,F),k[P]=F)}function b(){const P=r.newAttributes,F=r.enabledAttributes;for(let $=0,j=F.length;$<j;$++)F[$]!==P[$]&&(s.disableVertexAttribArray($),F[$]=0)}function T(P,F,$,j,k,q,W){W===!0?s.vertexAttribIPointer(P,F,$,k,q):s.vertexAttribPointer(P,F,$,j,k,q)}function S(P,F,$,j){v();const k=j.attributes,q=$.getAttributes(),W=F.defaultAttributeValues;for(const ee in q){const K=q[ee];if(K.location>=0){let le=k[ee];if(le===void 0&&(ee==="instanceMatrix"&&P.instanceMatrix&&(le=P.instanceMatrix),ee==="instanceColor"&&P.instanceColor&&(le=P.instanceColor)),le!==void 0){const pe=le.normalized,Me=le.itemSize,Ye=e.get(le);if(Ye===void 0)continue;const rt=Ye.buffer,qe=Ye.type,ne=Ye.bytesPerElement,he=qe===s.INT||qe===s.UNSIGNED_INT||le.gpuType===Uo;if(le.isInterleavedBufferAttribute){const ae=le.data,Be=ae.stride,Oe=le.offset;if(ae.isInstancedInterleavedBuffer){for(let De=0;De<K.locationSize;De++)p(K.location+De,ae.meshPerAttribute);P.isInstancedMesh!==!0&&j._maxInstanceCount===void 0&&(j._maxInstanceCount=ae.meshPerAttribute*ae.count)}else for(let De=0;De<K.locationSize;De++)m(K.location+De);s.bindBuffer(s.ARRAY_BUFFER,rt);for(let De=0;De<K.locationSize;De++)T(K.location+De,Me/K.locationSize,qe,pe,Be*ne,(Oe+Me/K.locationSize*De)*ne,he)}else{if(le.isInstancedBufferAttribute){for(let ae=0;ae<K.locationSize;ae++)p(K.location+ae,le.meshPerAttribute);P.isInstancedMesh!==!0&&j._maxInstanceCount===void 0&&(j._maxInstanceCount=le.meshPerAttribute*le.count)}else for(let ae=0;ae<K.locationSize;ae++)m(K.location+ae);s.bindBuffer(s.ARRAY_BUFFER,rt);for(let ae=0;ae<K.locationSize;ae++)T(K.location+ae,Me/K.locationSize,qe,pe,Me*ne,Me/K.locationSize*ae*ne,he)}}else if(W!==void 0){const pe=W[ee];if(pe!==void 0)switch(pe.length){case 2:s.vertexAttrib2fv(K.location,pe);break;case 3:s.vertexAttrib3fv(K.location,pe);break;case 4:s.vertexAttrib4fv(K.location,pe);break;default:s.vertexAttrib1fv(K.location,pe)}}}}b()}function w(){A();for(const P in n){const F=n[P];for(const $ in F){const j=F[$];for(const k in j){const q=j[k];for(const W in q)u(q[W].object),delete q[W];delete j[k]}}delete n[P]}}function E(P){if(n[P.id]===void 0)return;const F=n[P.id];for(const $ in F){const j=F[$];for(const k in j){const q=j[k];for(const W in q)u(q[W].object),delete q[W];delete j[k]}}delete n[P.id]}function R(P){for(const F in n){const $=n[F];for(const j in $){const k=$[j];if(k[P.id]===void 0)continue;const q=k[P.id];for(const W in q)u(q[W].object),delete q[W];delete k[P.id]}}}function x(P){for(const F in n){const $=n[F],j=P.isInstancedMesh===!0?P.id:0,k=$[j];if(k!==void 0){for(const q in k){const W=k[q];for(const ee in W)u(W[ee].object),delete W[ee];delete k[q]}delete $[j],Object.keys($).length===0&&delete n[F]}}}function A(){D(),a=!0,r!==i&&(r=i,c(r.object))}function D(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:o,reset:A,resetDefaultState:D,dispose:w,releaseStatesOfGeometry:E,releaseStatesOfObject:x,releaseStatesOfProgram:R,initAttributes:v,enableAttribute:m,disableUnusedAttributes:b}}function gg(s,e,t){let n;function i(l){n=l}function r(l,c){s.drawArrays(n,l,c),t.update(c,n,1)}function a(l,c,u){u!==0&&(s.drawArraysInstanced(n,l,c,u),t.update(c,n,u))}function o(l,c,u){if(u===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,c,0,u);let d=0;for(let f=0;f<u;f++)d+=c[f];t.update(d,n,1)}this.setMode=i,this.render=r,this.renderInstances=a,this.renderMultiDraw=o}function _g(s,e,t,n){let i;function r(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const R=e.get("EXT_texture_filter_anisotropic");i=s.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function a(R){return!(R!==pn&&n.convert(R)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(R){const x=R===$n&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(R!==on&&n.convert(R)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_TYPE)&&R!==fn&&!x)}function l(R){if(R==="highp"){if(s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.HIGH_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";R="mediump"}return R==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const u=l(c);u!==c&&(Ie("WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);const h=t.logarithmicDepthBuffer===!0,d=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&d===!1&&Ie("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const f=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),_=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=s.getParameter(s.MAX_TEXTURE_SIZE),m=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),p=s.getParameter(s.MAX_VERTEX_ATTRIBS),b=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),T=s.getParameter(s.MAX_VARYING_VECTORS),S=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),w=s.getParameter(s.MAX_SAMPLES),E=s.getParameter(s.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:h,reversedDepthBuffer:d,maxTextures:f,maxVertexTextures:_,maxTextureSize:v,maxCubemapSize:m,maxAttributes:p,maxVertexUniforms:b,maxVaryings:T,maxFragmentUniforms:S,maxSamples:w,samples:E}}function xg(s){const e=this;let t=null,n=0,i=!1,r=!1;const a=new Xn,o=new He,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,d){const f=h.length!==0||d||n!==0||i;return i=d,n=h.length,f},this.beginShadows=function(){r=!0,u(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(h,d){t=u(h,d,0)},this.setState=function(h,d,f){const _=h.clippingPlanes,v=h.clipIntersection,m=h.clipShadows,p=s.get(h);if(!i||_===null||_.length===0||r&&!m)r?u(null):c();else{const b=r?0:n,T=b*4;let S=p.clippingState||null;l.value=S,S=u(_,d,T,f);for(let w=0;w!==T;++w)S[w]=t[w];p.clippingState=S,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=b}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(h,d,f,_){const v=h!==null?h.length:0;let m=null;if(v!==0){if(m=l.value,_!==!0||m===null){const p=f+v*4,b=d.matrixWorldInverse;o.getNormalMatrix(b),(m===null||m.length<p)&&(m=new Float32Array(p));for(let T=0,S=f;T!==v;++T,S+=4)a.copy(h[T]).applyMatrix4(b,o),a.normal.toArray(m,S),m[S+3]=a.constant}l.value=m,l.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,m}}const ci=4,hc=[.125,.215,.35,.446,.526,.582],vi=20,vg=256,Es=new Vr,dc=new Ue;let Sa=null,ya=0,ba=0,Ea=!1;const Mg=new C;class fc{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=.1,i=100,r={}){const{size:a=256,position:o=Mg}=r;Sa=this._renderer.getRenderTarget(),ya=this._renderer.getActiveCubeFace(),ba=this._renderer.getActiveMipmapLevel(),Ea=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,n,i,l,o),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=gc(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=mc(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Sa,ya,ba),this._renderer.xr.enabled=Ea,e.scissorTest=!1,Wi(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===bi||e.mapping===Qi?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Sa=this._renderer.getRenderTarget(),ya=this._renderer.getActiveCubeFace(),ba=this._renderer.getActiveMipmapLevel(),Ea=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Bt,minFilter:Bt,generateMipmaps:!1,type:$n,format:pn,colorSpace:ln,depthBuffer:!1},i=pc(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=pc(e,t,n);const{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=Sg(r)),this._blurMaterial=bg(r,e,t),this._ggxMaterial=yg(r,e,t)}return i}_compileMaterial(e){const t=new bt(new Wt,e);this._renderer.compile(t,Es)}_sceneToCubeUV(e,t,n,i,r){const l=new Qt(90,1,t,n),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],h=this._renderer,d=h.autoClear,f=h.toneMapping;h.getClearColor(dc),h.toneMapping=Pn,h.autoClear=!1,h.state.buffers.depth.getReversed()&&(h.setRenderTarget(i),h.clearDepth(),h.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new bt(new Vs,new yi({name:"PMREM.Background",side:tn,depthWrite:!1,depthTest:!1})));const v=this._backgroundBox,m=v.material;let p=!1;const b=e.background;b?b.isColor&&(m.color.copy(b),e.background=null,p=!0):(m.color.copy(dc),p=!0);for(let T=0;T<6;T++){const S=T%3;S===0?(l.up.set(0,c[T],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x+u[T],r.y,r.z)):S===1?(l.up.set(0,0,c[T]),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y+u[T],r.z)):(l.up.set(0,c[T],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y,r.z+u[T]));const w=this._cubeSize;Wi(i,S*w,T>2?w:0,w,w),h.setRenderTarget(i),p&&h.render(v,l),h.render(e,l)}h.toneMapping=f,h.autoClear=d,e.background=b}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===bi||e.mapping===Qi;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=gc()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=mc());const r=i?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const l=this._cubeSize;Wi(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(a,Es)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const i=this._lodMeshes.length;for(let r=1;r<i;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,n){const i=this._renderer,r=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[n];o.material=a;const l=a.uniforms,c=n/(this._lodMeshes.length-1),u=t/(this._lodMeshes.length-1),h=Math.sqrt(c*c-u*u),d=0+c*1.25,f=h*d,{_lodMax:_}=this,v=this._sizeLods[n],m=3*v*(n>_-ci?n-_+ci:0),p=4*(this._cubeSize-v);l.envMap.value=e.texture,l.roughness.value=f,l.mipInt.value=_-t,Wi(r,m,p,3*v,2*v),i.setRenderTarget(r),i.render(o,Es),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=_-n,Wi(e,m,p,3*v,2*v),i.setRenderTarget(e),i.render(o,Es)}_blur(e,t,n,i,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,i,"latitudinal",r),this._halfBlur(a,e,n,n,i,"longitudinal",r)}_halfBlur(e,t,n,i,r,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&ze("blur direction must be either latitudinal or longitudinal!");const u=3,h=this._lodMeshes[i];h.material=c;const d=c.uniforms,f=this._sizeLods[n]-1,_=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*vi-1),v=r/_,m=isFinite(r)?1+Math.floor(u*v):vi;m>vi&&Ie(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${vi}`);const p=[];let b=0;for(let R=0;R<vi;++R){const x=R/v,A=Math.exp(-x*x/2);p.push(A),R===0?b+=A:R<m&&(b+=2*A)}for(let R=0;R<p.length;R++)p[R]=p[R]/b;d.envMap.value=e.texture,d.samples.value=m,d.weights.value=p,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:T}=this;d.dTheta.value=_,d.mipInt.value=T-n;const S=this._sizeLods[i],w=3*S*(i>T-ci?i-T+ci:0),E=4*(this._cubeSize-S);Wi(t,w,E,3*S,2*S),l.setRenderTarget(t),l.render(h,Es)}}function Sg(s){const e=[],t=[],n=[];let i=s;const r=s-ci+1+hc.length;for(let a=0;a<r;a++){const o=Math.pow(2,i);e.push(o);let l=1/o;a>s-ci?l=hc[a-s+ci-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),u=-c,h=1+c,d=[u,u,h,u,h,h,u,u,h,h,u,h],f=6,_=6,v=3,m=2,p=1,b=new Float32Array(v*_*f),T=new Float32Array(m*_*f),S=new Float32Array(p*_*f);for(let E=0;E<f;E++){const R=E%3*2/3-1,x=E>2?0:-1,A=[R,x,0,R+2/3,x,0,R+2/3,x+1,0,R,x,0,R+2/3,x+1,0,R,x+1,0];b.set(A,v*_*E),T.set(d,m*_*E);const D=[E,E,E,E,E,E];S.set(D,p*_*E)}const w=new Wt;w.setAttribute("position",new Nt(b,v)),w.setAttribute("uv",new Nt(T,m)),w.setAttribute("faceIndex",new Nt(S,p)),n.push(new bt(w,null)),i>ci&&i--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function pc(s,e,t){const n=new Ln(s,e,t);return n.texture.mapping=Or,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Wi(s,e,t,n,i){s.viewport.set(e,t,n,i),s.scissor.set(e,t,n,i)}function yg(s,e,t){return new Un({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:vg,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Hr(),fragmentShader:`
3672
3672
 
3673
3673
  precision highp float;
3674
3674
  precision highp int;
@@ -3772,7 +3772,7 @@ void main() {
3772
3772
 
3773
3773
  gl_FragColor = vec4(prefilteredColor, 1.0);
3774
3774
  }
3775
- `,blending:Kn,depthTest:!1,depthWrite:!1})}function yg(s,e,t){const n=new Float32Array(vi),i=new C(0,1,0);return new Un({name:"SphericalGaussianBlur",defines:{n:vi,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Hr(),fragmentShader:`
3775
+ `,blending:Kn,depthTest:!1,depthWrite:!1})}function bg(s,e,t){const n=new Float32Array(vi),i=new C(0,1,0);return new Un({name:"SphericalGaussianBlur",defines:{n:vi,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Hr(),fragmentShader:`
3776
3776
 
3777
3777
  precision mediump float;
3778
3778
  precision mediump int;
@@ -3957,7 +3957,7 @@ void main() {
3957
3957
  gl_FragColor = texture2D( tEquirect, sampleUV );
3958
3958
 
3959
3959
  }
3960
- `},i=new Vs(5,5,5),r=new Un({name:"CubemapFromEquirect",uniforms:is(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:tn,blending:Kn});r.uniforms.tEquirect.value=t;const a=new bt(i,r),o=t.minFilter;return t.minFilter===Yn&&(t.minFilter=Bt),new mf(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){const r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,i);e.setRenderTarget(r)}}function bg(s){let e=new WeakMap,t=new WeakMap,n=null;function i(d,f=!1){return d==null?null:f?a(d):r(d)}function r(d){if(d&&d.isTexture){const f=d.mapping;if(f===Xr||f===Yr)if(e.has(d)){const _=e.get(d).texture;return o(_,d.mapping)}else{const _=d.image;if(_&&_.height>0){const v=new wu(_.height);return v.fromEquirectangularTexture(s,d),e.set(d,v),d.addEventListener("dispose",c),o(v.texture,d.mapping)}else return null}}return d}function a(d){if(d&&d.isTexture){const f=d.mapping,_=f===Xr||f===Yr,v=f===bi||f===Qi;if(_||v){let m=t.get(d);const p=m!==void 0?m.texture.pmremVersion:0;if(d.isRenderTargetTexture&&d.pmremVersion!==p)return n===null&&(n=new fc(s)),m=_?n.fromEquirectangular(d,m):n.fromCubemap(d,m),m.texture.pmremVersion=d.pmremVersion,t.set(d,m),m.texture;if(m!==void 0)return m.texture;{const b=d.image;return _&&b&&b.height>0||v&&b&&l(b)?(n===null&&(n=new fc(s)),m=_?n.fromEquirectangular(d):n.fromCubemap(d),m.texture.pmremVersion=d.pmremVersion,t.set(d,m),d.addEventListener("dispose",u),m.texture):null}}}return d}function o(d,f){return f===Xr?d.mapping=bi:f===Yr&&(d.mapping=Qi),d}function l(d){let f=0;const _=6;for(let v=0;v<_;v++)d[v]!==void 0&&f++;return f===_}function c(d){const f=d.target;f.removeEventListener("dispose",c);const _=e.get(f);_!==void 0&&(e.delete(f),_.dispose())}function u(d){const f=d.target;f.removeEventListener("dispose",u);const _=t.get(f);_!==void 0&&(t.delete(f),_.dispose())}function h(){e=new WeakMap,t=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:i,dispose:h}}function Eg(s){const e={};function t(n){if(e[n]!==void 0)return e[n];const i=s.getExtension(n);return e[n]=i,i}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){const i=t(n);return i===null&&Ki("WebGLRenderer: "+n+" extension not supported."),i}}}function Tg(s,e,t,n){const i={},r=new WeakMap;function a(h){const d=h.target;d.index!==null&&e.remove(d.index);for(const _ in d.attributes)e.remove(d.attributes[_]);d.removeEventListener("dispose",a),delete i[d.id];const f=r.get(d);f&&(e.remove(f),r.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function o(h,d){return i[d.id]===!0||(d.addEventListener("dispose",a),i[d.id]=!0,t.memory.geometries++),d}function l(h){const d=h.attributes;for(const f in d)e.update(d[f],s.ARRAY_BUFFER)}function c(h){const d=[],f=h.index,_=h.attributes.position;let v=0;if(_===void 0)return;if(f!==null){const b=f.array;v=f.version;for(let T=0,S=b.length;T<S;T+=3){const w=b[T+0],E=b[T+1],R=b[T+2];d.push(w,E,E,R,R,w)}}else{const b=_.array;v=_.version;for(let T=0,S=b.length/3-1;T<S;T+=3){const w=T+0,E=T+1,R=T+2;d.push(w,E,E,R,R,w)}}const m=new(_.count>=65535?_u:gu)(d,1);m.version=v;const p=r.get(h);p&&e.remove(p),r.set(h,m)}function u(h){const d=r.get(h);if(d){const f=h.index;f!==null&&d.version<f.version&&c(h)}else c(h);return r.get(h)}return{get:o,update:l,getWireframeAttribute:u}}function Ag(s,e,t){let n;function i(h){n=h}let r,a;function o(h){r=h.type,a=h.bytesPerElement}function l(h,d){s.drawElements(n,d,r,h*a),t.update(d,n,1)}function c(h,d,f){f!==0&&(s.drawElementsInstanced(n,d,r,h*a,f),t.update(d,n,f))}function u(h,d,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,d,0,r,h,0,f);let v=0;for(let m=0;m<f;m++)v+=d[m];t.update(v,n,1)}this.setMode=i,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u}function wg(s){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,a,o){switch(t.calls++,a){case s.TRIANGLES:t.triangles+=o*(r/3);break;case s.LINES:t.lines+=o*(r/2);break;case s.LINE_STRIP:t.lines+=o*(r-1);break;case s.LINE_LOOP:t.lines+=o*r;break;case s.POINTS:t.points+=o*r;break;default:ze("WebGLInfo: Unknown draw mode:",a);break}}function i(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:i,update:n}}function Rg(s,e,t){const n=new WeakMap,i=new gt;function r(a,o,l){const c=a.morphTargetInfluences,u=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,h=u!==void 0?u.length:0;let d=n.get(o);if(d===void 0||d.count!==h){let A=function(){R.dispose(),n.delete(o),o.removeEventListener("dispose",A)};d!==void 0&&d.texture.dispose();const f=o.morphAttributes.position!==void 0,_=o.morphAttributes.normal!==void 0,v=o.morphAttributes.color!==void 0,m=o.morphAttributes.position||[],p=o.morphAttributes.normal||[],b=o.morphAttributes.color||[];let T=0;f===!0&&(T=1),_===!0&&(T=2),v===!0&&(T=3);let S=o.attributes.position.count*T,w=1;S>e.maxTextureSize&&(w=Math.ceil(S/e.maxTextureSize),S=e.maxTextureSize);const E=new Float32Array(S*w*4*h),R=new pu(E,S,w,h);R.type=fn,R.needsUpdate=!0;const x=T*4;for(let D=0;D<h;D++){const P=m[D],F=p[D],$=b[D],j=S*w*4*D;for(let k=0;k<P.count;k++){const q=k*x;f===!0&&(i.fromBufferAttribute(P,k),E[j+q+0]=i.x,E[j+q+1]=i.y,E[j+q+2]=i.z,E[j+q+3]=0),_===!0&&(i.fromBufferAttribute(F,k),E[j+q+4]=i.x,E[j+q+5]=i.y,E[j+q+6]=i.z,E[j+q+7]=0),v===!0&&(i.fromBufferAttribute($,k),E[j+q+8]=i.x,E[j+q+9]=i.y,E[j+q+10]=i.z,E[j+q+11]=$.itemSize===4?i.w:1)}}d={count:h,texture:R,size:new ke(S,w)},n.set(o,d),o.addEventListener("dispose",A)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(s,"morphTexture",a.morphTexture,t);else{let f=0;for(let v=0;v<c.length;v++)f+=c[v];const _=o.morphTargetsRelative?1:1-f;l.getUniforms().setValue(s,"morphTargetBaseInfluence",_),l.getUniforms().setValue(s,"morphTargetInfluences",c)}l.getUniforms().setValue(s,"morphTargetsTexture",d.texture,t),l.getUniforms().setValue(s,"morphTargetsTextureSize",d.size)}return{update:r}}function Cg(s,e,t,n,i){let r=new WeakMap;function a(c){const u=i.render.frame,h=c.geometry,d=e.get(c,h);if(r.get(d)!==u&&(e.update(d),r.set(d,u)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),r.get(c)!==u&&(t.update(c.instanceMatrix,s.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,s.ARRAY_BUFFER),r.set(c,u))),c.isSkinnedMesh){const f=c.skeleton;r.get(f)!==u&&(f.update(),r.set(f,u))}return d}function o(){r=new WeakMap}function l(c){const u=c.target;u.removeEventListener("dispose",l),n.releaseStatesOfObject(u),t.remove(u.instanceMatrix),u.instanceColor!==null&&t.remove(u.instanceColor)}return{update:a,dispose:o}}const Pg={[$c]:"LINEAR_TONE_MAPPING",[jc]:"REINHARD_TONE_MAPPING",[Jc]:"CINEON_TONE_MAPPING",[Qc]:"ACES_FILMIC_TONE_MAPPING",[tu]:"AGX_TONE_MAPPING",[nu]:"NEUTRAL_TONE_MAPPING",[eu]:"CUSTOM_TONE_MAPPING"};function Lg(s,e,t,n,i,r){const a=new Ln(e,t,{type:s,depthBuffer:i,stencilBuffer:r,samples:n?4:0,depthTexture:i?new ns(e,t):void 0}),o=new Ln(e,t,{type:$n,depthBuffer:!1,stencilBuffer:!1}),l=new Wt;l.setAttribute("position",new Lt([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new Lt([0,2,0,0,2,0],2));const c=new Gd({uniforms:{tDiffuse:{value:null}},vertexShader:`
3960
+ `},i=new Vs(5,5,5),r=new Un({name:"CubemapFromEquirect",uniforms:is(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:tn,blending:Kn});r.uniforms.tEquirect.value=t;const a=new bt(i,r),o=t.minFilter;return t.minFilter===Yn&&(t.minFilter=Bt),new gf(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){const r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,i);e.setRenderTarget(r)}}function Eg(s){let e=new WeakMap,t=new WeakMap,n=null;function i(d,f=!1){return d==null?null:f?a(d):r(d)}function r(d){if(d&&d.isTexture){const f=d.mapping;if(f===Xr||f===Yr)if(e.has(d)){const _=e.get(d).texture;return o(_,d.mapping)}else{const _=d.image;if(_&&_.height>0){const v=new wu(_.height);return v.fromEquirectangularTexture(s,d),e.set(d,v),d.addEventListener("dispose",c),o(v.texture,d.mapping)}else return null}}return d}function a(d){if(d&&d.isTexture){const f=d.mapping,_=f===Xr||f===Yr,v=f===bi||f===Qi;if(_||v){let m=t.get(d);const p=m!==void 0?m.texture.pmremVersion:0;if(d.isRenderTargetTexture&&d.pmremVersion!==p)return n===null&&(n=new fc(s)),m=_?n.fromEquirectangular(d,m):n.fromCubemap(d,m),m.texture.pmremVersion=d.pmremVersion,t.set(d,m),m.texture;if(m!==void 0)return m.texture;{const b=d.image;return _&&b&&b.height>0||v&&b&&l(b)?(n===null&&(n=new fc(s)),m=_?n.fromEquirectangular(d):n.fromCubemap(d),m.texture.pmremVersion=d.pmremVersion,t.set(d,m),d.addEventListener("dispose",u),m.texture):null}}}return d}function o(d,f){return f===Xr?d.mapping=bi:f===Yr&&(d.mapping=Qi),d}function l(d){let f=0;const _=6;for(let v=0;v<_;v++)d[v]!==void 0&&f++;return f===_}function c(d){const f=d.target;f.removeEventListener("dispose",c);const _=e.get(f);_!==void 0&&(e.delete(f),_.dispose())}function u(d){const f=d.target;f.removeEventListener("dispose",u);const _=t.get(f);_!==void 0&&(t.delete(f),_.dispose())}function h(){e=new WeakMap,t=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:i,dispose:h}}function Tg(s){const e={};function t(n){if(e[n]!==void 0)return e[n];const i=s.getExtension(n);return e[n]=i,i}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){const i=t(n);return i===null&&Ki("WebGLRenderer: "+n+" extension not supported."),i}}}function Ag(s,e,t,n){const i={},r=new WeakMap;function a(h){const d=h.target;d.index!==null&&e.remove(d.index);for(const _ in d.attributes)e.remove(d.attributes[_]);d.removeEventListener("dispose",a),delete i[d.id];const f=r.get(d);f&&(e.remove(f),r.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function o(h,d){return i[d.id]===!0||(d.addEventListener("dispose",a),i[d.id]=!0,t.memory.geometries++),d}function l(h){const d=h.attributes;for(const f in d)e.update(d[f],s.ARRAY_BUFFER)}function c(h){const d=[],f=h.index,_=h.attributes.position;let v=0;if(_===void 0)return;if(f!==null){const b=f.array;v=f.version;for(let T=0,S=b.length;T<S;T+=3){const w=b[T+0],E=b[T+1],R=b[T+2];d.push(w,E,E,R,R,w)}}else{const b=_.array;v=_.version;for(let T=0,S=b.length/3-1;T<S;T+=3){const w=T+0,E=T+1,R=T+2;d.push(w,E,E,R,R,w)}}const m=new(_.count>=65535?_u:gu)(d,1);m.version=v;const p=r.get(h);p&&e.remove(p),r.set(h,m)}function u(h){const d=r.get(h);if(d){const f=h.index;f!==null&&d.version<f.version&&c(h)}else c(h);return r.get(h)}return{get:o,update:l,getWireframeAttribute:u}}function wg(s,e,t){let n;function i(h){n=h}let r,a;function o(h){r=h.type,a=h.bytesPerElement}function l(h,d){s.drawElements(n,d,r,h*a),t.update(d,n,1)}function c(h,d,f){f!==0&&(s.drawElementsInstanced(n,d,r,h*a,f),t.update(d,n,f))}function u(h,d,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,d,0,r,h,0,f);let v=0;for(let m=0;m<f;m++)v+=d[m];t.update(v,n,1)}this.setMode=i,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u}function Rg(s){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,a,o){switch(t.calls++,a){case s.TRIANGLES:t.triangles+=o*(r/3);break;case s.LINES:t.lines+=o*(r/2);break;case s.LINE_STRIP:t.lines+=o*(r-1);break;case s.LINE_LOOP:t.lines+=o*r;break;case s.POINTS:t.points+=o*r;break;default:ze("WebGLInfo: Unknown draw mode:",a);break}}function i(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:i,update:n}}function Cg(s,e,t){const n=new WeakMap,i=new gt;function r(a,o,l){const c=a.morphTargetInfluences,u=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,h=u!==void 0?u.length:0;let d=n.get(o);if(d===void 0||d.count!==h){let A=function(){R.dispose(),n.delete(o),o.removeEventListener("dispose",A)};d!==void 0&&d.texture.dispose();const f=o.morphAttributes.position!==void 0,_=o.morphAttributes.normal!==void 0,v=o.morphAttributes.color!==void 0,m=o.morphAttributes.position||[],p=o.morphAttributes.normal||[],b=o.morphAttributes.color||[];let T=0;f===!0&&(T=1),_===!0&&(T=2),v===!0&&(T=3);let S=o.attributes.position.count*T,w=1;S>e.maxTextureSize&&(w=Math.ceil(S/e.maxTextureSize),S=e.maxTextureSize);const E=new Float32Array(S*w*4*h),R=new pu(E,S,w,h);R.type=fn,R.needsUpdate=!0;const x=T*4;for(let D=0;D<h;D++){const P=m[D],F=p[D],$=b[D],j=S*w*4*D;for(let k=0;k<P.count;k++){const q=k*x;f===!0&&(i.fromBufferAttribute(P,k),E[j+q+0]=i.x,E[j+q+1]=i.y,E[j+q+2]=i.z,E[j+q+3]=0),_===!0&&(i.fromBufferAttribute(F,k),E[j+q+4]=i.x,E[j+q+5]=i.y,E[j+q+6]=i.z,E[j+q+7]=0),v===!0&&(i.fromBufferAttribute($,k),E[j+q+8]=i.x,E[j+q+9]=i.y,E[j+q+10]=i.z,E[j+q+11]=$.itemSize===4?i.w:1)}}d={count:h,texture:R,size:new ke(S,w)},n.set(o,d),o.addEventListener("dispose",A)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(s,"morphTexture",a.morphTexture,t);else{let f=0;for(let v=0;v<c.length;v++)f+=c[v];const _=o.morphTargetsRelative?1:1-f;l.getUniforms().setValue(s,"morphTargetBaseInfluence",_),l.getUniforms().setValue(s,"morphTargetInfluences",c)}l.getUniforms().setValue(s,"morphTargetsTexture",d.texture,t),l.getUniforms().setValue(s,"morphTargetsTextureSize",d.size)}return{update:r}}function Pg(s,e,t,n,i){let r=new WeakMap;function a(c){const u=i.render.frame,h=c.geometry,d=e.get(c,h);if(r.get(d)!==u&&(e.update(d),r.set(d,u)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),r.get(c)!==u&&(t.update(c.instanceMatrix,s.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,s.ARRAY_BUFFER),r.set(c,u))),c.isSkinnedMesh){const f=c.skeleton;r.get(f)!==u&&(f.update(),r.set(f,u))}return d}function o(){r=new WeakMap}function l(c){const u=c.target;u.removeEventListener("dispose",l),n.releaseStatesOfObject(u),t.remove(u.instanceMatrix),u.instanceColor!==null&&t.remove(u.instanceColor)}return{update:a,dispose:o}}const Lg={[$c]:"LINEAR_TONE_MAPPING",[jc]:"REINHARD_TONE_MAPPING",[Jc]:"CINEON_TONE_MAPPING",[Qc]:"ACES_FILMIC_TONE_MAPPING",[tu]:"AGX_TONE_MAPPING",[nu]:"NEUTRAL_TONE_MAPPING",[eu]:"CUSTOM_TONE_MAPPING"};function Ig(s,e,t,n,i,r){const a=new Ln(e,t,{type:s,depthBuffer:i,stencilBuffer:r,samples:n?4:0,depthTexture:i?new ns(e,t):void 0}),o=new Ln(e,t,{type:$n,depthBuffer:!1,stencilBuffer:!1}),l=new Wt;l.setAttribute("position",new Lt([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new Lt([0,2,0,0,2,0],2));const c=new Wd({uniforms:{tDiffuse:{value:null}},vertexShader:`
3961
3961
  precision highp float;
3962
3962
 
3963
3963
  uniform mat4 modelViewMatrix;
@@ -4003,17 +4003,17 @@ void main() {
4003
4003
  #ifdef SRGB_TRANSFER
4004
4004
  gl_FragColor = sRGBTransferOETF( gl_FragColor );
4005
4005
  #endif
4006
- }`,depthTest:!1,depthWrite:!1}),u=new bt(l,c),h=new Vr(-1,1,1,-1,0,1);let d=null,f=null,_=!1,v,m=null,p=[],b=!1;this.setSize=function(T,S){a.setSize(T,S),o.setSize(T,S);for(let w=0;w<p.length;w++){const E=p[w];E.setSize&&E.setSize(T,S)}},this.setEffects=function(T){p=T,b=p.length>0&&p[0].isRenderPass===!0;const S=a.width,w=a.height;for(let E=0;E<p.length;E++){const R=p[E];R.setSize&&R.setSize(S,w)}},this.begin=function(T,S){if(_||T.toneMapping===Pn&&p.length===0)return!1;if(m=S,S!==null){const w=S.width,E=S.height;(a.width!==w||a.height!==E)&&this.setSize(w,E)}return b===!1&&T.setRenderTarget(a),v=T.toneMapping,T.toneMapping=Pn,!0},this.hasRenderPass=function(){return b},this.end=function(T,S){T.toneMapping=v,_=!0;let w=a,E=o;for(let R=0;R<p.length;R++){const x=p[R];if(x.enabled!==!1&&(x.render(T,E,w,S),x.needsSwap!==!1)){const A=w;w=E,E=A}}if(d!==T.outputColorSpace||f!==T.toneMapping){d=T.outputColorSpace,f=T.toneMapping,c.defines={},Qe.getTransfer(d)===ut&&(c.defines.SRGB_TRANSFER="");const R=Pg[f];R&&(c.defines[R]=""),c.needsUpdate=!0}c.uniforms.tDiffuse.value=w.texture,T.setRenderTarget(m),T.render(u,h),m=null,_=!1},this.isCompositing=function(){return _},this.dispose=function(){a.depthTexture&&a.depthTexture.dispose(),a.dispose(),o.dispose(),l.dispose(),c.dispose()}}const Ru=new Gt,Ro=new ns(1,1),Cu=new pu,Pu=new fd,Lu=new Mu,_c=[],xc=[],vc=new Float32Array(16),Mc=new Float32Array(9),Sc=new Float32Array(4);function cs(s,e,t){const n=s[0];if(n<=0||n>0)return s;const i=e*t;let r=_c[i];if(r===void 0&&(r=new Float32Array(i),_c[i]=r),e!==0){n.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,s[a].toArray(r,o)}return r}function kt(s,e){if(s.length!==e.length)return!1;for(let t=0,n=s.length;t<n;t++)if(s[t]!==e[t])return!1;return!0}function zt(s,e){for(let t=0,n=e.length;t<n;t++)s[t]=e[t]}function Gr(s,e){let t=xc[e];t===void 0&&(t=new Int32Array(e),xc[e]=t);for(let n=0;n!==e;++n)t[n]=s.allocateTextureUnit();return t}function Ig(s,e){const t=this.cache;t[0]!==e&&(s.uniform1f(this.addr,e),t[0]=e)}function Dg(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(kt(t,e))return;s.uniform2fv(this.addr,e),zt(t,e)}}function Ng(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(s.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(kt(t,e))return;s.uniform3fv(this.addr,e),zt(t,e)}}function Ug(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(kt(t,e))return;s.uniform4fv(this.addr,e),zt(t,e)}}function Fg(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(kt(t,e))return;s.uniformMatrix2fv(this.addr,!1,e),zt(t,e)}else{if(kt(t,n))return;Sc.set(n),s.uniformMatrix2fv(this.addr,!1,Sc),zt(t,n)}}function Og(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(kt(t,e))return;s.uniformMatrix3fv(this.addr,!1,e),zt(t,e)}else{if(kt(t,n))return;Mc.set(n),s.uniformMatrix3fv(this.addr,!1,Mc),zt(t,n)}}function Bg(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(kt(t,e))return;s.uniformMatrix4fv(this.addr,!1,e),zt(t,e)}else{if(kt(t,n))return;vc.set(n),s.uniformMatrix4fv(this.addr,!1,vc),zt(t,n)}}function kg(s,e){const t=this.cache;t[0]!==e&&(s.uniform1i(this.addr,e),t[0]=e)}function zg(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(kt(t,e))return;s.uniform2iv(this.addr,e),zt(t,e)}}function Vg(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(kt(t,e))return;s.uniform3iv(this.addr,e),zt(t,e)}}function Hg(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(kt(t,e))return;s.uniform4iv(this.addr,e),zt(t,e)}}function Gg(s,e){const t=this.cache;t[0]!==e&&(s.uniform1ui(this.addr,e),t[0]=e)}function Wg(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(kt(t,e))return;s.uniform2uiv(this.addr,e),zt(t,e)}}function Xg(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(kt(t,e))return;s.uniform3uiv(this.addr,e),zt(t,e)}}function Yg(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(kt(t,e))return;s.uniform4uiv(this.addr,e),zt(t,e)}}function qg(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i);let r;this.type===s.SAMPLER_2D_SHADOW?(Ro.compareFunction=t.isReversedDepthBuffer()?Go:Ho,r=Ro):r=Ru,t.setTexture2D(e||r,i)}function Kg(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTexture3D(e||Pu,i)}function Zg(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTextureCube(e||Lu,i)}function $g(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTexture2DArray(e||Cu,i)}function jg(s){switch(s){case 5126:return Ig;case 35664:return Dg;case 35665:return Ng;case 35666:return Ug;case 35674:return Fg;case 35675:return Og;case 35676:return Bg;case 5124:case 35670:return kg;case 35667:case 35671:return zg;case 35668:case 35672:return Vg;case 35669:case 35673:return Hg;case 5125:return Gg;case 36294:return Wg;case 36295:return Xg;case 36296:return Yg;case 35678:case 36198:case 36298:case 36306:case 35682:return qg;case 35679:case 36299:case 36307:return Kg;case 35680:case 36300:case 36308:case 36293:return Zg;case 36289:case 36303:case 36311:case 36292:return $g}}function Jg(s,e){s.uniform1fv(this.addr,e)}function Qg(s,e){const t=cs(e,this.size,2);s.uniform2fv(this.addr,t)}function e_(s,e){const t=cs(e,this.size,3);s.uniform3fv(this.addr,t)}function t_(s,e){const t=cs(e,this.size,4);s.uniform4fv(this.addr,t)}function n_(s,e){const t=cs(e,this.size,4);s.uniformMatrix2fv(this.addr,!1,t)}function i_(s,e){const t=cs(e,this.size,9);s.uniformMatrix3fv(this.addr,!1,t)}function s_(s,e){const t=cs(e,this.size,16);s.uniformMatrix4fv(this.addr,!1,t)}function r_(s,e){s.uniform1iv(this.addr,e)}function a_(s,e){s.uniform2iv(this.addr,e)}function o_(s,e){s.uniform3iv(this.addr,e)}function l_(s,e){s.uniform4iv(this.addr,e)}function c_(s,e){s.uniform1uiv(this.addr,e)}function u_(s,e){s.uniform2uiv(this.addr,e)}function h_(s,e){s.uniform3uiv(this.addr,e)}function d_(s,e){s.uniform4uiv(this.addr,e)}function f_(s,e,t){const n=this.cache,i=e.length,r=Gr(t,i);kt(n,r)||(s.uniform1iv(this.addr,r),zt(n,r));let a;this.type===s.SAMPLER_2D_SHADOW?a=Ro:a=Ru;for(let o=0;o!==i;++o)t.setTexture2D(e[o]||a,r[o])}function p_(s,e,t){const n=this.cache,i=e.length,r=Gr(t,i);kt(n,r)||(s.uniform1iv(this.addr,r),zt(n,r));for(let a=0;a!==i;++a)t.setTexture3D(e[a]||Pu,r[a])}function m_(s,e,t){const n=this.cache,i=e.length,r=Gr(t,i);kt(n,r)||(s.uniform1iv(this.addr,r),zt(n,r));for(let a=0;a!==i;++a)t.setTextureCube(e[a]||Lu,r[a])}function g_(s,e,t){const n=this.cache,i=e.length,r=Gr(t,i);kt(n,r)||(s.uniform1iv(this.addr,r),zt(n,r));for(let a=0;a!==i;++a)t.setTexture2DArray(e[a]||Cu,r[a])}function __(s){switch(s){case 5126:return Jg;case 35664:return Qg;case 35665:return e_;case 35666:return t_;case 35674:return n_;case 35675:return i_;case 35676:return s_;case 5124:case 35670:return r_;case 35667:case 35671:return a_;case 35668:case 35672:return o_;case 35669:case 35673:return l_;case 5125:return c_;case 36294:return u_;case 36295:return h_;case 36296:return d_;case 35678:case 36198:case 36298:case 36306:case 35682:return f_;case 35679:case 36299:case 36307:return p_;case 35680:case 36300:case 36308:case 36293:return m_;case 36289:case 36303:case 36311:case 36292:return g_}}class x_{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=jg(t.type)}}class v_{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=__(t.type)}}class M_{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const i=this.seq;for(let r=0,a=i.length;r!==a;++r){const o=i[r];o.setValue(e,t[o.id],n)}}}const Ta=/(\w+)(\])?(\[|\.)?/g;function yc(s,e){s.seq.push(e),s.map[e.id]=e}function S_(s,e,t){const n=s.name,i=n.length;for(Ta.lastIndex=0;;){const r=Ta.exec(n),a=Ta.lastIndex;let o=r[1];const l=r[2]==="]",c=r[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===i){yc(t,c===void 0?new x_(o,s,e):new v_(o,s,e));break}else{let h=t.map[o];h===void 0&&(h=new M_(o),yc(t,h)),t=h}}}class wr{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let a=0;a<n;++a){const o=e.getActiveUniform(t,a),l=e.getUniformLocation(t,o.name);S_(o,l,this)}const i=[],r=[];for(const a of this.seq)a.type===e.SAMPLER_2D_SHADOW||a.type===e.SAMPLER_CUBE_SHADOW||a.type===e.SAMPLER_2D_ARRAY_SHADOW?i.push(a):r.push(a);i.length>0&&(this.seq=i.concat(r))}setValue(e,t,n,i){const r=this.map[t];r!==void 0&&r.setValue(e,n,i)}setOptional(e,t,n){const i=t[n];i!==void 0&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,a=t.length;r!==a;++r){const o=t[r],l=n[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,i)}}static seqWithValue(e,t){const n=[];for(let i=0,r=e.length;i!==r;++i){const a=e[i];a.id in t&&n.push(a)}return n}}function bc(s,e,t){const n=s.createShader(e);return s.shaderSource(n,t),s.compileShader(n),n}const y_=37297;let b_=0;function E_(s,e){const t=s.split(`
4006
+ }`,depthTest:!1,depthWrite:!1}),u=new bt(l,c),h=new Vr(-1,1,1,-1,0,1);let d=null,f=null,_=!1,v,m=null,p=[],b=!1;this.setSize=function(T,S){a.setSize(T,S),o.setSize(T,S);for(let w=0;w<p.length;w++){const E=p[w];E.setSize&&E.setSize(T,S)}},this.setEffects=function(T){p=T,b=p.length>0&&p[0].isRenderPass===!0;const S=a.width,w=a.height;for(let E=0;E<p.length;E++){const R=p[E];R.setSize&&R.setSize(S,w)}},this.begin=function(T,S){if(_||T.toneMapping===Pn&&p.length===0)return!1;if(m=S,S!==null){const w=S.width,E=S.height;(a.width!==w||a.height!==E)&&this.setSize(w,E)}return b===!1&&T.setRenderTarget(a),v=T.toneMapping,T.toneMapping=Pn,!0},this.hasRenderPass=function(){return b},this.end=function(T,S){T.toneMapping=v,_=!0;let w=a,E=o;for(let R=0;R<p.length;R++){const x=p[R];if(x.enabled!==!1&&(x.render(T,E,w,S),x.needsSwap!==!1)){const A=w;w=E,E=A}}if(d!==T.outputColorSpace||f!==T.toneMapping){d=T.outputColorSpace,f=T.toneMapping,c.defines={},Qe.getTransfer(d)===ut&&(c.defines.SRGB_TRANSFER="");const R=Lg[f];R&&(c.defines[R]=""),c.needsUpdate=!0}c.uniforms.tDiffuse.value=w.texture,T.setRenderTarget(m),T.render(u,h),m=null,_=!1},this.isCompositing=function(){return _},this.dispose=function(){a.depthTexture&&a.depthTexture.dispose(),a.dispose(),o.dispose(),l.dispose(),c.dispose()}}const Ru=new Gt,Ro=new ns(1,1),Cu=new pu,Pu=new pd,Lu=new Mu,_c=[],xc=[],vc=new Float32Array(16),Mc=new Float32Array(9),Sc=new Float32Array(4);function cs(s,e,t){const n=s[0];if(n<=0||n>0)return s;const i=e*t;let r=_c[i];if(r===void 0&&(r=new Float32Array(i),_c[i]=r),e!==0){n.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,s[a].toArray(r,o)}return r}function kt(s,e){if(s.length!==e.length)return!1;for(let t=0,n=s.length;t<n;t++)if(s[t]!==e[t])return!1;return!0}function zt(s,e){for(let t=0,n=e.length;t<n;t++)s[t]=e[t]}function Gr(s,e){let t=xc[e];t===void 0&&(t=new Int32Array(e),xc[e]=t);for(let n=0;n!==e;++n)t[n]=s.allocateTextureUnit();return t}function Dg(s,e){const t=this.cache;t[0]!==e&&(s.uniform1f(this.addr,e),t[0]=e)}function Ng(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(kt(t,e))return;s.uniform2fv(this.addr,e),zt(t,e)}}function Ug(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(s.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(kt(t,e))return;s.uniform3fv(this.addr,e),zt(t,e)}}function Fg(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(kt(t,e))return;s.uniform4fv(this.addr,e),zt(t,e)}}function Og(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(kt(t,e))return;s.uniformMatrix2fv(this.addr,!1,e),zt(t,e)}else{if(kt(t,n))return;Sc.set(n),s.uniformMatrix2fv(this.addr,!1,Sc),zt(t,n)}}function Bg(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(kt(t,e))return;s.uniformMatrix3fv(this.addr,!1,e),zt(t,e)}else{if(kt(t,n))return;Mc.set(n),s.uniformMatrix3fv(this.addr,!1,Mc),zt(t,n)}}function kg(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(kt(t,e))return;s.uniformMatrix4fv(this.addr,!1,e),zt(t,e)}else{if(kt(t,n))return;vc.set(n),s.uniformMatrix4fv(this.addr,!1,vc),zt(t,n)}}function zg(s,e){const t=this.cache;t[0]!==e&&(s.uniform1i(this.addr,e),t[0]=e)}function Vg(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(kt(t,e))return;s.uniform2iv(this.addr,e),zt(t,e)}}function Hg(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(kt(t,e))return;s.uniform3iv(this.addr,e),zt(t,e)}}function Gg(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(kt(t,e))return;s.uniform4iv(this.addr,e),zt(t,e)}}function Wg(s,e){const t=this.cache;t[0]!==e&&(s.uniform1ui(this.addr,e),t[0]=e)}function Xg(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(kt(t,e))return;s.uniform2uiv(this.addr,e),zt(t,e)}}function Yg(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(kt(t,e))return;s.uniform3uiv(this.addr,e),zt(t,e)}}function qg(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(kt(t,e))return;s.uniform4uiv(this.addr,e),zt(t,e)}}function Kg(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i);let r;this.type===s.SAMPLER_2D_SHADOW?(Ro.compareFunction=t.isReversedDepthBuffer()?Go:Ho,r=Ro):r=Ru,t.setTexture2D(e||r,i)}function Zg(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTexture3D(e||Pu,i)}function $g(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTextureCube(e||Lu,i)}function jg(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTexture2DArray(e||Cu,i)}function Jg(s){switch(s){case 5126:return Dg;case 35664:return Ng;case 35665:return Ug;case 35666:return Fg;case 35674:return Og;case 35675:return Bg;case 35676:return kg;case 5124:case 35670:return zg;case 35667:case 35671:return Vg;case 35668:case 35672:return Hg;case 35669:case 35673:return Gg;case 5125:return Wg;case 36294:return Xg;case 36295:return Yg;case 36296:return qg;case 35678:case 36198:case 36298:case 36306:case 35682:return Kg;case 35679:case 36299:case 36307:return Zg;case 35680:case 36300:case 36308:case 36293:return $g;case 36289:case 36303:case 36311:case 36292:return jg}}function Qg(s,e){s.uniform1fv(this.addr,e)}function e_(s,e){const t=cs(e,this.size,2);s.uniform2fv(this.addr,t)}function t_(s,e){const t=cs(e,this.size,3);s.uniform3fv(this.addr,t)}function n_(s,e){const t=cs(e,this.size,4);s.uniform4fv(this.addr,t)}function i_(s,e){const t=cs(e,this.size,4);s.uniformMatrix2fv(this.addr,!1,t)}function s_(s,e){const t=cs(e,this.size,9);s.uniformMatrix3fv(this.addr,!1,t)}function r_(s,e){const t=cs(e,this.size,16);s.uniformMatrix4fv(this.addr,!1,t)}function a_(s,e){s.uniform1iv(this.addr,e)}function o_(s,e){s.uniform2iv(this.addr,e)}function l_(s,e){s.uniform3iv(this.addr,e)}function c_(s,e){s.uniform4iv(this.addr,e)}function u_(s,e){s.uniform1uiv(this.addr,e)}function h_(s,e){s.uniform2uiv(this.addr,e)}function d_(s,e){s.uniform3uiv(this.addr,e)}function f_(s,e){s.uniform4uiv(this.addr,e)}function p_(s,e,t){const n=this.cache,i=e.length,r=Gr(t,i);kt(n,r)||(s.uniform1iv(this.addr,r),zt(n,r));let a;this.type===s.SAMPLER_2D_SHADOW?a=Ro:a=Ru;for(let o=0;o!==i;++o)t.setTexture2D(e[o]||a,r[o])}function m_(s,e,t){const n=this.cache,i=e.length,r=Gr(t,i);kt(n,r)||(s.uniform1iv(this.addr,r),zt(n,r));for(let a=0;a!==i;++a)t.setTexture3D(e[a]||Pu,r[a])}function g_(s,e,t){const n=this.cache,i=e.length,r=Gr(t,i);kt(n,r)||(s.uniform1iv(this.addr,r),zt(n,r));for(let a=0;a!==i;++a)t.setTextureCube(e[a]||Lu,r[a])}function __(s,e,t){const n=this.cache,i=e.length,r=Gr(t,i);kt(n,r)||(s.uniform1iv(this.addr,r),zt(n,r));for(let a=0;a!==i;++a)t.setTexture2DArray(e[a]||Cu,r[a])}function x_(s){switch(s){case 5126:return Qg;case 35664:return e_;case 35665:return t_;case 35666:return n_;case 35674:return i_;case 35675:return s_;case 35676:return r_;case 5124:case 35670:return a_;case 35667:case 35671:return o_;case 35668:case 35672:return l_;case 35669:case 35673:return c_;case 5125:return u_;case 36294:return h_;case 36295:return d_;case 36296:return f_;case 35678:case 36198:case 36298:case 36306:case 35682:return p_;case 35679:case 36299:case 36307:return m_;case 35680:case 36300:case 36308:case 36293:return g_;case 36289:case 36303:case 36311:case 36292:return __}}class v_{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=Jg(t.type)}}class M_{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=x_(t.type)}}class S_{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const i=this.seq;for(let r=0,a=i.length;r!==a;++r){const o=i[r];o.setValue(e,t[o.id],n)}}}const Ta=/(\w+)(\])?(\[|\.)?/g;function yc(s,e){s.seq.push(e),s.map[e.id]=e}function y_(s,e,t){const n=s.name,i=n.length;for(Ta.lastIndex=0;;){const r=Ta.exec(n),a=Ta.lastIndex;let o=r[1];const l=r[2]==="]",c=r[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===i){yc(t,c===void 0?new v_(o,s,e):new M_(o,s,e));break}else{let h=t.map[o];h===void 0&&(h=new S_(o),yc(t,h)),t=h}}}class wr{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let a=0;a<n;++a){const o=e.getActiveUniform(t,a),l=e.getUniformLocation(t,o.name);y_(o,l,this)}const i=[],r=[];for(const a of this.seq)a.type===e.SAMPLER_2D_SHADOW||a.type===e.SAMPLER_CUBE_SHADOW||a.type===e.SAMPLER_2D_ARRAY_SHADOW?i.push(a):r.push(a);i.length>0&&(this.seq=i.concat(r))}setValue(e,t,n,i){const r=this.map[t];r!==void 0&&r.setValue(e,n,i)}setOptional(e,t,n){const i=t[n];i!==void 0&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,a=t.length;r!==a;++r){const o=t[r],l=n[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,i)}}static seqWithValue(e,t){const n=[];for(let i=0,r=e.length;i!==r;++i){const a=e[i];a.id in t&&n.push(a)}return n}}function bc(s,e,t){const n=s.createShader(e);return s.shaderSource(n,t),s.compileShader(n),n}const b_=37297;let E_=0;function T_(s,e){const t=s.split(`
4007
4007
  `),n=[],i=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let a=i;a<r;a++){const o=a+1;n.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return n.join(`
4008
- `)}const Ec=new He;function T_(s){Qe._getMatrix(Ec,Qe.workingColorSpace,s);const e=`mat3( ${Ec.elements.map(t=>t.toFixed(4))} )`;switch(Qe.getTransfer(s)){case Lr:return[e,"LinearTransferOETF"];case ut:return[e,"sRGBTransferOETF"];default:return Ie("WebGLProgram: Unsupported color space: ",s),[e,"LinearTransferOETF"]}}function Tc(s,e,t){const n=s.getShaderParameter(e,s.COMPILE_STATUS),r=(s.getShaderInfoLog(e)||"").trim();if(n&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const o=parseInt(a[1]);return t.toUpperCase()+`
4008
+ `)}const Ec=new He;function A_(s){Qe._getMatrix(Ec,Qe.workingColorSpace,s);const e=`mat3( ${Ec.elements.map(t=>t.toFixed(4))} )`;switch(Qe.getTransfer(s)){case Lr:return[e,"LinearTransferOETF"];case ut:return[e,"sRGBTransferOETF"];default:return Ie("WebGLProgram: Unsupported color space: ",s),[e,"LinearTransferOETF"]}}function Tc(s,e,t){const n=s.getShaderParameter(e,s.COMPILE_STATUS),r=(s.getShaderInfoLog(e)||"").trim();if(n&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const o=parseInt(a[1]);return t.toUpperCase()+`
4009
4009
 
4010
4010
  `+r+`
4011
4011
 
4012
- `+E_(s.getShaderSource(e),o)}else return r}function A_(s,e){const t=T_(e);return[`vec4 ${s}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
4013
- `)}const w_={[$c]:"Linear",[jc]:"Reinhard",[Jc]:"Cineon",[Qc]:"ACESFilmic",[tu]:"AgX",[nu]:"Neutral",[eu]:"Custom"};function R_(s,e){const t=w_[e];return t===void 0?(Ie("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+s+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+s+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const xr=new C;function C_(){Qe.getLuminanceCoefficients(xr);const s=xr.x.toFixed(4),e=xr.y.toFixed(4),t=xr.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${s}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
4014
- `)}function P_(s){return[s.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",s.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Cs).join(`
4015
- `)}function L_(s){const e=[];for(const t in s){const n=s[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
4016
- `)}function I_(s,e){const t={},n=s.getProgramParameter(e,s.ACTIVE_ATTRIBUTES);for(let i=0;i<n;i++){const r=s.getActiveAttrib(e,i),a=r.name;let o=1;r.type===s.FLOAT_MAT2&&(o=2),r.type===s.FLOAT_MAT3&&(o=3),r.type===s.FLOAT_MAT4&&(o=4),t[a]={type:r.type,location:s.getAttribLocation(e,a),locationSize:o}}return t}function Cs(s){return s!==""}function Ac(s,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return s.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function wc(s,e){return s.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const D_=/^[ \t]*#include +<([\w\d./]+)>/gm;function Co(s){return s.replace(D_,U_)}const N_=new Map;function U_(s,e){let t=Ke[e];if(t===void 0){const n=N_.get(e);if(n!==void 0)t=Ke[n],Ie('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return Co(t)}const F_=/#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 Rc(s){return s.replace(F_,O_)}function O_(s,e,t,n){let i="";for(let r=parseInt(e);r<parseInt(t);r++)i+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return i}function Cc(s){let e=`precision ${s.precision} float;
4012
+ `+T_(s.getShaderSource(e),o)}else return r}function w_(s,e){const t=A_(e);return[`vec4 ${s}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
4013
+ `)}const R_={[$c]:"Linear",[jc]:"Reinhard",[Jc]:"Cineon",[Qc]:"ACESFilmic",[tu]:"AgX",[nu]:"Neutral",[eu]:"Custom"};function C_(s,e){const t=R_[e];return t===void 0?(Ie("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+s+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+s+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const xr=new C;function P_(){Qe.getLuminanceCoefficients(xr);const s=xr.x.toFixed(4),e=xr.y.toFixed(4),t=xr.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${s}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
4014
+ `)}function L_(s){return[s.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",s.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Cs).join(`
4015
+ `)}function I_(s){const e=[];for(const t in s){const n=s[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
4016
+ `)}function D_(s,e){const t={},n=s.getProgramParameter(e,s.ACTIVE_ATTRIBUTES);for(let i=0;i<n;i++){const r=s.getActiveAttrib(e,i),a=r.name;let o=1;r.type===s.FLOAT_MAT2&&(o=2),r.type===s.FLOAT_MAT3&&(o=3),r.type===s.FLOAT_MAT4&&(o=4),t[a]={type:r.type,location:s.getAttribLocation(e,a),locationSize:o}}return t}function Cs(s){return s!==""}function Ac(s,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return s.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function wc(s,e){return s.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const N_=/^[ \t]*#include +<([\w\d./]+)>/gm;function Co(s){return s.replace(N_,F_)}const U_=new Map;function F_(s,e){let t=Ke[e];if(t===void 0){const n=U_.get(e);if(n!==void 0)t=Ke[n],Ie('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return Co(t)}const O_=/#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 Rc(s){return s.replace(O_,B_)}function B_(s,e,t,n){let i="";for(let r=parseInt(e);r<parseInt(t);r++)i+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return i}function Cc(s){let e=`precision ${s.precision} float;
4017
4017
  precision ${s.precision} int;
4018
4018
  precision ${s.precision} sampler2D;
4019
4019
  precision ${s.precision} samplerCube;
@@ -4033,14 +4033,14 @@ void main() {
4033
4033
  `;return s.precision==="highp"?e+=`
4034
4034
  #define HIGH_PRECISION`:s.precision==="mediump"?e+=`
4035
4035
  #define MEDIUM_PRECISION`:s.precision==="lowp"&&(e+=`
4036
- #define LOW_PRECISION`),e}const B_={[Sr]:"SHADOWMAP_TYPE_PCF",[ws]:"SHADOWMAP_TYPE_VSM"};function k_(s){return B_[s.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const z_={[bi]:"ENVMAP_TYPE_CUBE",[Qi]:"ENVMAP_TYPE_CUBE",[Or]:"ENVMAP_TYPE_CUBE_UV"};function V_(s){return s.envMap===!1?"ENVMAP_TYPE_CUBE":z_[s.envMapMode]||"ENVMAP_TYPE_CUBE"}const H_={[Qi]:"ENVMAP_MODE_REFRACTION"};function G_(s){return s.envMap===!1?"ENVMAP_MODE_REFLECTION":H_[s.envMapMode]||"ENVMAP_MODE_REFLECTION"}const W_={[Zc]:"ENVMAP_BLENDING_MULTIPLY",[Rh]:"ENVMAP_BLENDING_MIX",[Ch]:"ENVMAP_BLENDING_ADD"};function X_(s){return s.envMap===!1?"ENVMAP_BLENDING_NONE":W_[s.combine]||"ENVMAP_BLENDING_NONE"}function Y_(s){const e=s.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:n,maxMip:t}}function q_(s,e,t,n){const i=s.getContext(),r=t.defines;let a=t.vertexShader,o=t.fragmentShader;const l=k_(t),c=V_(t),u=G_(t),h=X_(t),d=Y_(t),f=P_(t),_=L_(r),v=i.createProgram();let m,p,b=t.glslVersion?"#version "+t.glslVersion+`
4036
+ #define LOW_PRECISION`),e}const k_={[Sr]:"SHADOWMAP_TYPE_PCF",[ws]:"SHADOWMAP_TYPE_VSM"};function z_(s){return k_[s.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const V_={[bi]:"ENVMAP_TYPE_CUBE",[Qi]:"ENVMAP_TYPE_CUBE",[Or]:"ENVMAP_TYPE_CUBE_UV"};function H_(s){return s.envMap===!1?"ENVMAP_TYPE_CUBE":V_[s.envMapMode]||"ENVMAP_TYPE_CUBE"}const G_={[Qi]:"ENVMAP_MODE_REFRACTION"};function W_(s){return s.envMap===!1?"ENVMAP_MODE_REFLECTION":G_[s.envMapMode]||"ENVMAP_MODE_REFLECTION"}const X_={[Zc]:"ENVMAP_BLENDING_MULTIPLY",[Ch]:"ENVMAP_BLENDING_MIX",[Ph]:"ENVMAP_BLENDING_ADD"};function Y_(s){return s.envMap===!1?"ENVMAP_BLENDING_NONE":X_[s.combine]||"ENVMAP_BLENDING_NONE"}function q_(s){const e=s.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:n,maxMip:t}}function K_(s,e,t,n){const i=s.getContext(),r=t.defines;let a=t.vertexShader,o=t.fragmentShader;const l=z_(t),c=H_(t),u=W_(t),h=Y_(t),d=q_(t),f=L_(t),_=I_(r),v=i.createProgram();let m,p,b=t.glslVersion?"#version "+t.glslVersion+`
4037
4037
  `:"";t.isRawShaderMaterial?(m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,_].filter(Cs).join(`
4038
4038
  `),m.length>0&&(m+=`
4039
4039
  `),p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,_].filter(Cs).join(`
4040
4040
  `),p.length>0&&(p+=`
4041
4041
  `)):(m=[Cc(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,_,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
4042
4042
  `].filter(Cs).join(`
4043
- `),p=[Cc(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,_,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+h:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Pn?"#define TONE_MAPPING":"",t.toneMapping!==Pn?Ke.tonemapping_pars_fragment:"",t.toneMapping!==Pn?R_("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Ke.colorspace_pars_fragment,A_("linearToOutputTexel",t.outputColorSpace),C_(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
4043
+ `),p=[Cc(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,_,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+h:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Pn?"#define TONE_MAPPING":"",t.toneMapping!==Pn?Ke.tonemapping_pars_fragment:"",t.toneMapping!==Pn?C_("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Ke.colorspace_pars_fragment,w_("linearToOutputTexel",t.outputColorSpace),P_(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
4044
4044
  `].filter(Cs).join(`
4045
4045
  `)),a=Co(a),a=Ac(a,t),a=wc(a,t),o=Co(o),o=Ac(o,t),o=wc(o,t),a=Rc(a),o=Rc(o),t.isRawShaderMaterial!==!0&&(b=`#version 300 es
4046
4046
  `,m=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(`
@@ -4054,9 +4054,9 @@ Material Type: `+P.type+`
4054
4054
 
4055
4055
  Program Info Log: `+k+`
4056
4056
  `+le+`
4057
- `+pe)}else k!==""?Ie("WebGLProgram: Program Info Log:",k):(q===""||W==="")&&(K=!1);K&&(P.diagnostics={runnable:ee,programLog:k,vertexShader:{log:q,prefix:m},fragmentShader:{log:W,prefix:p}})}i.deleteShader(w),i.deleteShader(E),x=new wr(i,v),A=I_(i,v)}let x;this.getUniforms=function(){return x===void 0&&R(this),x};let A;this.getAttributes=function(){return A===void 0&&R(this),A};let D=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return D===!1&&(D=i.getProgramParameter(v,y_)),D},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=b_++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=w,this.fragmentShader=E,this}let K_=0;class Z_{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){const i=this._getShaderCacheForMaterial(e);return i.has(t)===!1&&(i.add(t),t.usedTimes++),i.has(n)===!1&&(i.add(n),n.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new $_(e),t.set(e,n)),n}}class $_{constructor(e){this.id=K_++,this.code=e,this.usedTimes=0}}function j_(s){return s===Ei||s===Cr||s===Pr}function J_(s,e,t,n,i,r){const a=new Yo,o=new Z_,l=new Set,c=[],u=new Map,h=n.logarithmicDepthBuffer;let d=n.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function _(x){return l.add(x),x===0?"uv":`uv${x}`}function v(x,A,D,P,F,$){const j=P.fog,k=F.geometry,q=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?P.environment:null,W=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap,ee=e.get(x.envMap||q,W),K=ee&&ee.mapping===Or?ee.image.height:null,le=f[x.type];x.precision!==null&&(d=n.getMaxPrecision(x.precision),d!==x.precision&&Ie("WebGLProgram.getParameters:",x.precision,"not supported, using",d,"instead."));const pe=k.morphAttributes.position||k.morphAttributes.normal||k.morphAttributes.color,Me=pe!==void 0?pe.length:0;let Ye=0;k.morphAttributes.position!==void 0&&(Ye=1),k.morphAttributes.normal!==void 0&&(Ye=2),k.morphAttributes.color!==void 0&&(Ye=3);let rt,qe,ne,he;if(le){const Ae=wn[le];rt=Ae.vertexShader,qe=Ae.fragmentShader}else{rt=x.vertexShader,qe=x.fragmentShader;const Ae=o.getVertexShaderStage(x),St=o.getFragmentShaderStage(x);o.update(x,Ae,St),ne=Ae.id,he=St.id}const ae=s.getRenderTarget(),Be=s.state.buffers.depth.getReversed(),Oe=F.isInstancedMesh===!0,De=F.isBatchedMesh===!0,ft=!!x.map,Ge=!!x.matcap,je=!!ee,Le=!!x.aoMap,Ve=!!x.lightMap,nt=!!x.bumpMap&&x.wireframe===!1,at=!!x.normalMap,Et=!!x.displacementMap,lt=!!x.emissiveMap,et=!!x.metalnessMap,vt=!!x.roughnessMap,U=x.anisotropy>0,G=x.clearcoat>0,J=x.dispersion>0,y=x.iridescence>0,g=x.sheen>0,L=x.transmission>0,B=U&&!!x.anisotropyMap,z=G&&!!x.clearcoatMap,Q=G&&!!x.clearcoatNormalMap,re=G&&!!x.clearcoatRoughnessMap,X=y&&!!x.iridescenceMap,Z=y&&!!x.iridescenceThicknessMap,oe=g&&!!x.sheenColorMap,me=g&&!!x.sheenRoughnessMap,ue=!!x.specularMap,ce=!!x.specularColorMap,Ee=!!x.specularIntensityMap,Te=L&&!!x.transmissionMap,Re=L&&!!x.thicknessMap,I=!!x.gradientMap,fe=!!x.alphaMap,te=x.alphaTest>0,de=!!x.alphaHash,ge=!!x.extensions;let se=Pn;x.toneMapped&&(ae===null||ae.isXRRenderTarget===!0)&&(se=s.toneMapping);const be={shaderID:le,shaderType:x.type,shaderName:x.name,vertexShader:rt,fragmentShader:qe,defines:x.defines,customVertexShaderID:ne,customFragmentShaderID:he,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:d,batching:De,batchingColor:De&&F._colorsTexture!==null,instancing:Oe,instancingColor:Oe&&F.instanceColor!==null,instancingMorph:Oe&&F.morphTexture!==null,outputColorSpace:ae===null?s.outputColorSpace:ae.isXRRenderTarget===!0?ae.texture.colorSpace:Qe.workingColorSpace,alphaToCoverage:!!x.alphaToCoverage,map:ft,matcap:Ge,envMap:je,envMapMode:je&&ee.mapping,envMapCubeUVHeight:K,aoMap:Le,lightMap:Ve,bumpMap:nt,normalMap:at,displacementMap:Et,emissiveMap:lt,normalMapObjectSpace:at&&x.normalMapType===Nh,normalMapTangentSpace:at&&x.normalMapType===yo,packedNormalMap:at&&x.normalMapType===yo&&j_(x.normalMap.format),metalnessMap:et,roughnessMap:vt,anisotropy:U,anisotropyMap:B,clearcoat:G,clearcoatMap:z,clearcoatNormalMap:Q,clearcoatRoughnessMap:re,dispersion:J,iridescence:y,iridescenceMap:X,iridescenceThicknessMap:Z,sheen:g,sheenColorMap:oe,sheenRoughnessMap:me,specularMap:ue,specularColorMap:ce,specularIntensityMap:Ee,transmission:L,transmissionMap:Te,thicknessMap:Re,gradientMap:I,opaque:x.transparent===!1&&x.blending===qi&&x.alphaToCoverage===!1,alphaMap:fe,alphaTest:te,alphaHash:de,combine:x.combine,mapUv:ft&&_(x.map.channel),aoMapUv:Le&&_(x.aoMap.channel),lightMapUv:Ve&&_(x.lightMap.channel),bumpMapUv:nt&&_(x.bumpMap.channel),normalMapUv:at&&_(x.normalMap.channel),displacementMapUv:Et&&_(x.displacementMap.channel),emissiveMapUv:lt&&_(x.emissiveMap.channel),metalnessMapUv:et&&_(x.metalnessMap.channel),roughnessMapUv:vt&&_(x.roughnessMap.channel),anisotropyMapUv:B&&_(x.anisotropyMap.channel),clearcoatMapUv:z&&_(x.clearcoatMap.channel),clearcoatNormalMapUv:Q&&_(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:re&&_(x.clearcoatRoughnessMap.channel),iridescenceMapUv:X&&_(x.iridescenceMap.channel),iridescenceThicknessMapUv:Z&&_(x.iridescenceThicknessMap.channel),sheenColorMapUv:oe&&_(x.sheenColorMap.channel),sheenRoughnessMapUv:me&&_(x.sheenRoughnessMap.channel),specularMapUv:ue&&_(x.specularMap.channel),specularColorMapUv:ce&&_(x.specularColorMap.channel),specularIntensityMapUv:Ee&&_(x.specularIntensityMap.channel),transmissionMapUv:Te&&_(x.transmissionMap.channel),thicknessMapUv:Re&&_(x.thicknessMap.channel),alphaMapUv:fe&&_(x.alphaMap.channel),vertexTangents:!!k.attributes.tangent&&(at||U),vertexNormals:!!k.attributes.normal,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!k.attributes.color&&k.attributes.color.itemSize===4,pointsUvs:F.isPoints===!0&&!!k.attributes.uv&&(ft||fe),fog:!!j,useFog:x.fog===!0,fogExp2:!!j&&j.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||k.attributes.normal===void 0&&at===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:h,reversedDepthBuffer:Be,skinning:F.isSkinnedMesh===!0,hasPositionAttribute:k.attributes.position!==void 0,morphTargets:k.morphAttributes.position!==void 0,morphNormals:k.morphAttributes.normal!==void 0,morphColors:k.morphAttributes.color!==void 0,morphTargetsCount:Me,morphTextureStride:Ye,numDirLights:A.directional.length,numPointLights:A.point.length,numSpotLights:A.spot.length,numSpotLightMaps:A.spotLightMap.length,numRectAreaLights:A.rectArea.length,numHemiLights:A.hemi.length,numDirLightShadows:A.directionalShadowMap.length,numPointLightShadows:A.pointShadowMap.length,numSpotLightShadows:A.spotShadowMap.length,numSpotLightShadowsWithMaps:A.numSpotLightShadowsWithMaps,numLightProbes:A.numLightProbes,numLightProbeGrids:$.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:x.dithering,shadowMapEnabled:s.shadowMap.enabled&&D.length>0,shadowMapType:s.shadowMap.type,toneMapping:se,decodeVideoTexture:ft&&x.map.isVideoTexture===!0&&Qe.getTransfer(x.map.colorSpace)===ut,decodeVideoTextureEmissive:lt&&x.emissiveMap.isVideoTexture===!0&&Qe.getTransfer(x.emissiveMap.colorSpace)===ut,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===an,flipSided:x.side===tn,useDepthPacking:x.depthPacking>=0,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionClipCullDistance:ge&&x.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ge&&x.extensions.multiDraw===!0||De)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return be.vertexUv1s=l.has(1),be.vertexUv2s=l.has(2),be.vertexUv3s=l.has(3),l.clear(),be}function m(x){const A=[];if(x.shaderID?A.push(x.shaderID):(A.push(x.customVertexShaderID),A.push(x.customFragmentShaderID)),x.defines!==void 0)for(const D in x.defines)A.push(D),A.push(x.defines[D]);return x.isRawShaderMaterial===!1&&(p(A,x),b(A,x),A.push(s.outputColorSpace)),A.push(x.customProgramCacheKey),A.join()}function p(x,A){x.push(A.precision),x.push(A.outputColorSpace),x.push(A.envMapMode),x.push(A.envMapCubeUVHeight),x.push(A.mapUv),x.push(A.alphaMapUv),x.push(A.lightMapUv),x.push(A.aoMapUv),x.push(A.bumpMapUv),x.push(A.normalMapUv),x.push(A.displacementMapUv),x.push(A.emissiveMapUv),x.push(A.metalnessMapUv),x.push(A.roughnessMapUv),x.push(A.anisotropyMapUv),x.push(A.clearcoatMapUv),x.push(A.clearcoatNormalMapUv),x.push(A.clearcoatRoughnessMapUv),x.push(A.iridescenceMapUv),x.push(A.iridescenceThicknessMapUv),x.push(A.sheenColorMapUv),x.push(A.sheenRoughnessMapUv),x.push(A.specularMapUv),x.push(A.specularColorMapUv),x.push(A.specularIntensityMapUv),x.push(A.transmissionMapUv),x.push(A.thicknessMapUv),x.push(A.combine),x.push(A.fogExp2),x.push(A.sizeAttenuation),x.push(A.morphTargetsCount),x.push(A.morphAttributeCount),x.push(A.numDirLights),x.push(A.numPointLights),x.push(A.numSpotLights),x.push(A.numSpotLightMaps),x.push(A.numHemiLights),x.push(A.numRectAreaLights),x.push(A.numDirLightShadows),x.push(A.numPointLightShadows),x.push(A.numSpotLightShadows),x.push(A.numSpotLightShadowsWithMaps),x.push(A.numLightProbes),x.push(A.shadowMapType),x.push(A.toneMapping),x.push(A.numClippingPlanes),x.push(A.numClipIntersection),x.push(A.depthPacking)}function b(x,A){a.disableAll(),A.instancing&&a.enable(0),A.instancingColor&&a.enable(1),A.instancingMorph&&a.enable(2),A.matcap&&a.enable(3),A.envMap&&a.enable(4),A.normalMapObjectSpace&&a.enable(5),A.normalMapTangentSpace&&a.enable(6),A.clearcoat&&a.enable(7),A.iridescence&&a.enable(8),A.alphaTest&&a.enable(9),A.vertexColors&&a.enable(10),A.vertexAlphas&&a.enable(11),A.vertexUv1s&&a.enable(12),A.vertexUv2s&&a.enable(13),A.vertexUv3s&&a.enable(14),A.vertexTangents&&a.enable(15),A.anisotropy&&a.enable(16),A.alphaHash&&a.enable(17),A.batching&&a.enable(18),A.dispersion&&a.enable(19),A.batchingColor&&a.enable(20),A.gradientMap&&a.enable(21),A.packedNormalMap&&a.enable(22),A.vertexNormals&&a.enable(23),x.push(a.mask),a.disableAll(),A.fog&&a.enable(0),A.useFog&&a.enable(1),A.flatShading&&a.enable(2),A.logarithmicDepthBuffer&&a.enable(3),A.reversedDepthBuffer&&a.enable(4),A.skinning&&a.enable(5),A.morphTargets&&a.enable(6),A.morphNormals&&a.enable(7),A.morphColors&&a.enable(8),A.premultipliedAlpha&&a.enable(9),A.shadowMapEnabled&&a.enable(10),A.doubleSided&&a.enable(11),A.flipSided&&a.enable(12),A.useDepthPacking&&a.enable(13),A.dithering&&a.enable(14),A.transmission&&a.enable(15),A.sheen&&a.enable(16),A.opaque&&a.enable(17),A.pointsUvs&&a.enable(18),A.decodeVideoTexture&&a.enable(19),A.decodeVideoTextureEmissive&&a.enable(20),A.alphaToCoverage&&a.enable(21),A.numLightProbeGrids>0&&a.enable(22),A.hasPositionAttribute&&a.enable(23),x.push(a.mask)}function T(x){const A=f[x.type];let D;if(A){const P=wn[A];D=zd.clone(P.uniforms)}else D=x.uniforms;return D}function S(x,A){let D=u.get(A);return D!==void 0?++D.usedTimes:(D=new q_(s,A,x,i),c.push(D),u.set(A,D)),D}function w(x){if(--x.usedTimes===0){const A=c.indexOf(x);c[A]=c[c.length-1],c.pop(),u.delete(x.cacheKey),x.destroy()}}function E(x){o.remove(x)}function R(){o.dispose()}return{getParameters:v,getProgramCacheKey:m,getUniforms:T,acquireProgram:S,releaseProgram:w,releaseShaderCache:E,programs:c,dispose:R}}function Q_(){let s=new WeakMap;function e(a){return s.has(a)}function t(a){let o=s.get(a);return o===void 0&&(o={},s.set(a,o)),o}function n(a){s.delete(a)}function i(a,o,l){s.get(a)[o]=l}function r(){s=new WeakMap}return{has:e,get:t,remove:n,update:i,dispose:r}}function ex(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.material.id!==e.material.id?s.material.id-e.material.id:s.materialVariant!==e.materialVariant?s.materialVariant-e.materialVariant:s.z!==e.z?s.z-e.z:s.id-e.id}function Pc(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.z!==e.z?e.z-s.z:s.id-e.id}function Lc(){const s=[];let e=0;const t=[],n=[],i=[];function r(){e=0,t.length=0,n.length=0,i.length=0}function a(d){let f=0;return d.isInstancedMesh&&(f+=2),d.isSkinnedMesh&&(f+=1),f}function o(d,f,_,v,m,p){let b=s[e];return b===void 0?(b={id:d.id,object:d,geometry:f,material:_,materialVariant:a(d),groupOrder:v,renderOrder:d.renderOrder,z:m,group:p},s[e]=b):(b.id=d.id,b.object=d,b.geometry=f,b.material=_,b.materialVariant=a(d),b.groupOrder=v,b.renderOrder=d.renderOrder,b.z=m,b.group=p),e++,b}function l(d,f,_,v,m,p){const b=o(d,f,_,v,m,p);_.transmission>0?n.push(b):_.transparent===!0?i.push(b):t.push(b)}function c(d,f,_,v,m,p){const b=o(d,f,_,v,m,p);_.transmission>0?n.unshift(b):_.transparent===!0?i.unshift(b):t.unshift(b)}function u(d,f,_){t.length>1&&t.sort(d||ex),n.length>1&&n.sort(f||Pc),i.length>1&&i.sort(f||Pc),_&&(t.reverse(),n.reverse(),i.reverse())}function h(){for(let d=e,f=s.length;d<f;d++){const _=s[d];if(_.id===null)break;_.id=null,_.object=null,_.geometry=null,_.material=null,_.group=null}}return{opaque:t,transmissive:n,transparent:i,init:r,push:l,unshift:c,finish:h,sort:u}}function tx(){let s=new WeakMap;function e(n,i){const r=s.get(n);let a;return r===void 0?(a=new Lc,s.set(n,[a])):i>=r.length?(a=new Lc,r.push(a)):a=r[i],a}function t(){s=new WeakMap}return{get:e,dispose:t}}function nx(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new C,color:new Ue};break;case"SpotLight":t={position:new C,direction:new C,color:new Ue,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new C,color:new Ue,distance:0,decay:0};break;case"HemisphereLight":t={direction:new C,skyColor:new Ue,groundColor:new Ue};break;case"RectAreaLight":t={color:new Ue,position:new C,halfWidth:new C,halfHeight:new C};break}return s[e.id]=t,t}}}function ix(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ke};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ke};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ke,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[e.id]=t,t}}}let sx=0;function rx(s,e){return(e.castShadow?2:0)-(s.castShadow?2:0)+(e.map?1:0)-(s.map?1:0)}function ax(s){const e=new nx,t=ix(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new C);const i=new C,r=new We,a=new We;function o(c){let u=0,h=0,d=0;for(let A=0;A<9;A++)n.probe[A].set(0,0,0);let f=0,_=0,v=0,m=0,p=0,b=0,T=0,S=0,w=0,E=0,R=0;c.sort(rx);for(let A=0,D=c.length;A<D;A++){const P=c[A],F=P.color,$=P.intensity,j=P.distance;let k=null;if(P.shadow&&P.shadow.map&&(P.shadow.map.texture.format===Ei?k=P.shadow.map.texture:k=P.shadow.map.depthTexture||P.shadow.map.texture),P.isAmbientLight)u+=F.r*$,h+=F.g*$,d+=F.b*$;else if(P.isLightProbe){for(let q=0;q<9;q++)n.probe[q].addScaledVector(P.sh.coefficients[q],$);R++}else if(P.isDirectionalLight){const q=e.get(P);if(q.color.copy(P.color).multiplyScalar(P.intensity),P.castShadow){const W=P.shadow,ee=t.get(P);ee.shadowIntensity=W.intensity,ee.shadowBias=W.bias,ee.shadowNormalBias=W.normalBias,ee.shadowRadius=W.radius,ee.shadowMapSize=W.mapSize,n.directionalShadow[f]=ee,n.directionalShadowMap[f]=k,n.directionalShadowMatrix[f]=P.shadow.matrix,b++}n.directional[f]=q,f++}else if(P.isSpotLight){const q=e.get(P);q.position.setFromMatrixPosition(P.matrixWorld),q.color.copy(F).multiplyScalar($),q.distance=j,q.coneCos=Math.cos(P.angle),q.penumbraCos=Math.cos(P.angle*(1-P.penumbra)),q.decay=P.decay,n.spot[v]=q;const W=P.shadow;if(P.map&&(n.spotLightMap[w]=P.map,w++,W.updateMatrices(P),P.castShadow&&E++),n.spotLightMatrix[v]=W.matrix,P.castShadow){const ee=t.get(P);ee.shadowIntensity=W.intensity,ee.shadowBias=W.bias,ee.shadowNormalBias=W.normalBias,ee.shadowRadius=W.radius,ee.shadowMapSize=W.mapSize,n.spotShadow[v]=ee,n.spotShadowMap[v]=k,S++}v++}else if(P.isRectAreaLight){const q=e.get(P);q.color.copy(F).multiplyScalar($),q.halfWidth.set(P.width*.5,0,0),q.halfHeight.set(0,P.height*.5,0),n.rectArea[m]=q,m++}else if(P.isPointLight){const q=e.get(P);if(q.color.copy(P.color).multiplyScalar(P.intensity),q.distance=P.distance,q.decay=P.decay,P.castShadow){const W=P.shadow,ee=t.get(P);ee.shadowIntensity=W.intensity,ee.shadowBias=W.bias,ee.shadowNormalBias=W.normalBias,ee.shadowRadius=W.radius,ee.shadowMapSize=W.mapSize,ee.shadowCameraNear=W.camera.near,ee.shadowCameraFar=W.camera.far,n.pointShadow[_]=ee,n.pointShadowMap[_]=k,n.pointShadowMatrix[_]=P.shadow.matrix,T++}n.point[_]=q,_++}else if(P.isHemisphereLight){const q=e.get(P);q.skyColor.copy(P.color).multiplyScalar($),q.groundColor.copy(P.groundColor).multiplyScalar($),n.hemi[p]=q,p++}}m>0&&(s.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=xe.LTC_FLOAT_1,n.rectAreaLTC2=xe.LTC_FLOAT_2):(n.rectAreaLTC1=xe.LTC_HALF_1,n.rectAreaLTC2=xe.LTC_HALF_2)),n.ambient[0]=u,n.ambient[1]=h,n.ambient[2]=d;const x=n.hash;(x.directionalLength!==f||x.pointLength!==_||x.spotLength!==v||x.rectAreaLength!==m||x.hemiLength!==p||x.numDirectionalShadows!==b||x.numPointShadows!==T||x.numSpotShadows!==S||x.numSpotMaps!==w||x.numLightProbes!==R)&&(n.directional.length=f,n.spot.length=v,n.rectArea.length=m,n.point.length=_,n.hemi.length=p,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+w-E,n.spotLightMap.length=w,n.numSpotLightShadowsWithMaps=E,n.numLightProbes=R,x.directionalLength=f,x.pointLength=_,x.spotLength=v,x.rectAreaLength=m,x.hemiLength=p,x.numDirectionalShadows=b,x.numPointShadows=T,x.numSpotShadows=S,x.numSpotMaps=w,x.numLightProbes=R,n.version=sx++)}function l(c,u){let h=0,d=0,f=0,_=0,v=0;const m=u.matrixWorldInverse;for(let p=0,b=c.length;p<b;p++){const T=c[p];if(T.isDirectionalLight){const S=n.directional[h];S.direction.setFromMatrixPosition(T.matrixWorld),i.setFromMatrixPosition(T.target.matrixWorld),S.direction.sub(i),S.direction.transformDirection(m),h++}else if(T.isSpotLight){const S=n.spot[f];S.position.setFromMatrixPosition(T.matrixWorld),S.position.applyMatrix4(m),S.direction.setFromMatrixPosition(T.matrixWorld),i.setFromMatrixPosition(T.target.matrixWorld),S.direction.sub(i),S.direction.transformDirection(m),f++}else if(T.isRectAreaLight){const S=n.rectArea[_];S.position.setFromMatrixPosition(T.matrixWorld),S.position.applyMatrix4(m),a.identity(),r.copy(T.matrixWorld),r.premultiply(m),a.extractRotation(r),S.halfWidth.set(T.width*.5,0,0),S.halfHeight.set(0,T.height*.5,0),S.halfWidth.applyMatrix4(a),S.halfHeight.applyMatrix4(a),_++}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 Ic(s){const e=new ax(s),t=[],n=[],i=[];function r(d){h.camera=d,t.length=0,n.length=0,i.length=0}function a(d){t.push(d)}function o(d){n.push(d)}function l(d){i.push(d)}function c(){e.setup(t)}function u(d){e.setupView(t,d)}const h={lightsArray:t,shadowsArray:n,lightProbeGridArray:i,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:h,setupLights:c,setupLightsView:u,pushLight:a,pushShadow:o,pushLightProbeGrid:l}}function ox(s){let e=new WeakMap;function t(i,r=0){const a=e.get(i);let o;return a===void 0?(o=new Ic(s),e.set(i,[o])):r>=a.length?(o=new Ic(s),a.push(o)):o=a[r],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const lx=`void main() {
4057
+ `+pe)}else k!==""?Ie("WebGLProgram: Program Info Log:",k):(q===""||W==="")&&(K=!1);K&&(P.diagnostics={runnable:ee,programLog:k,vertexShader:{log:q,prefix:m},fragmentShader:{log:W,prefix:p}})}i.deleteShader(w),i.deleteShader(E),x=new wr(i,v),A=D_(i,v)}let x;this.getUniforms=function(){return x===void 0&&R(this),x};let A;this.getAttributes=function(){return A===void 0&&R(this),A};let D=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return D===!1&&(D=i.getProgramParameter(v,b_)),D},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=E_++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=w,this.fragmentShader=E,this}let Z_=0;class $_{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){const i=this._getShaderCacheForMaterial(e);return i.has(t)===!1&&(i.add(t),t.usedTimes++),i.has(n)===!1&&(i.add(n),n.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new j_(e),t.set(e,n)),n}}class j_{constructor(e){this.id=Z_++,this.code=e,this.usedTimes=0}}function J_(s){return s===Ei||s===Cr||s===Pr}function Q_(s,e,t,n,i,r){const a=new Yo,o=new $_,l=new Set,c=[],u=new Map,h=n.logarithmicDepthBuffer;let d=n.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function _(x){return l.add(x),x===0?"uv":`uv${x}`}function v(x,A,D,P,F,$){const j=P.fog,k=F.geometry,q=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?P.environment:null,W=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap,ee=e.get(x.envMap||q,W),K=ee&&ee.mapping===Or?ee.image.height:null,le=f[x.type];x.precision!==null&&(d=n.getMaxPrecision(x.precision),d!==x.precision&&Ie("WebGLProgram.getParameters:",x.precision,"not supported, using",d,"instead."));const pe=k.morphAttributes.position||k.morphAttributes.normal||k.morphAttributes.color,Me=pe!==void 0?pe.length:0;let Ye=0;k.morphAttributes.position!==void 0&&(Ye=1),k.morphAttributes.normal!==void 0&&(Ye=2),k.morphAttributes.color!==void 0&&(Ye=3);let rt,qe,ne,he;if(le){const Ae=wn[le];rt=Ae.vertexShader,qe=Ae.fragmentShader}else{rt=x.vertexShader,qe=x.fragmentShader;const Ae=o.getVertexShaderStage(x),St=o.getFragmentShaderStage(x);o.update(x,Ae,St),ne=Ae.id,he=St.id}const ae=s.getRenderTarget(),Be=s.state.buffers.depth.getReversed(),Oe=F.isInstancedMesh===!0,De=F.isBatchedMesh===!0,ft=!!x.map,Ge=!!x.matcap,je=!!ee,Le=!!x.aoMap,Ve=!!x.lightMap,nt=!!x.bumpMap&&x.wireframe===!1,at=!!x.normalMap,Et=!!x.displacementMap,lt=!!x.emissiveMap,et=!!x.metalnessMap,vt=!!x.roughnessMap,U=x.anisotropy>0,G=x.clearcoat>0,J=x.dispersion>0,y=x.iridescence>0,g=x.sheen>0,L=x.transmission>0,B=U&&!!x.anisotropyMap,z=G&&!!x.clearcoatMap,Q=G&&!!x.clearcoatNormalMap,re=G&&!!x.clearcoatRoughnessMap,X=y&&!!x.iridescenceMap,Z=y&&!!x.iridescenceThicknessMap,oe=g&&!!x.sheenColorMap,me=g&&!!x.sheenRoughnessMap,ue=!!x.specularMap,ce=!!x.specularColorMap,Ee=!!x.specularIntensityMap,Te=L&&!!x.transmissionMap,Re=L&&!!x.thicknessMap,I=!!x.gradientMap,fe=!!x.alphaMap,te=x.alphaTest>0,de=!!x.alphaHash,ge=!!x.extensions;let se=Pn;x.toneMapped&&(ae===null||ae.isXRRenderTarget===!0)&&(se=s.toneMapping);const be={shaderID:le,shaderType:x.type,shaderName:x.name,vertexShader:rt,fragmentShader:qe,defines:x.defines,customVertexShaderID:ne,customFragmentShaderID:he,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:d,batching:De,batchingColor:De&&F._colorsTexture!==null,instancing:Oe,instancingColor:Oe&&F.instanceColor!==null,instancingMorph:Oe&&F.morphTexture!==null,outputColorSpace:ae===null?s.outputColorSpace:ae.isXRRenderTarget===!0?ae.texture.colorSpace:Qe.workingColorSpace,alphaToCoverage:!!x.alphaToCoverage,map:ft,matcap:Ge,envMap:je,envMapMode:je&&ee.mapping,envMapCubeUVHeight:K,aoMap:Le,lightMap:Ve,bumpMap:nt,normalMap:at,displacementMap:Et,emissiveMap:lt,normalMapObjectSpace:at&&x.normalMapType===Uh,normalMapTangentSpace:at&&x.normalMapType===yo,packedNormalMap:at&&x.normalMapType===yo&&J_(x.normalMap.format),metalnessMap:et,roughnessMap:vt,anisotropy:U,anisotropyMap:B,clearcoat:G,clearcoatMap:z,clearcoatNormalMap:Q,clearcoatRoughnessMap:re,dispersion:J,iridescence:y,iridescenceMap:X,iridescenceThicknessMap:Z,sheen:g,sheenColorMap:oe,sheenRoughnessMap:me,specularMap:ue,specularColorMap:ce,specularIntensityMap:Ee,transmission:L,transmissionMap:Te,thicknessMap:Re,gradientMap:I,opaque:x.transparent===!1&&x.blending===qi&&x.alphaToCoverage===!1,alphaMap:fe,alphaTest:te,alphaHash:de,combine:x.combine,mapUv:ft&&_(x.map.channel),aoMapUv:Le&&_(x.aoMap.channel),lightMapUv:Ve&&_(x.lightMap.channel),bumpMapUv:nt&&_(x.bumpMap.channel),normalMapUv:at&&_(x.normalMap.channel),displacementMapUv:Et&&_(x.displacementMap.channel),emissiveMapUv:lt&&_(x.emissiveMap.channel),metalnessMapUv:et&&_(x.metalnessMap.channel),roughnessMapUv:vt&&_(x.roughnessMap.channel),anisotropyMapUv:B&&_(x.anisotropyMap.channel),clearcoatMapUv:z&&_(x.clearcoatMap.channel),clearcoatNormalMapUv:Q&&_(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:re&&_(x.clearcoatRoughnessMap.channel),iridescenceMapUv:X&&_(x.iridescenceMap.channel),iridescenceThicknessMapUv:Z&&_(x.iridescenceThicknessMap.channel),sheenColorMapUv:oe&&_(x.sheenColorMap.channel),sheenRoughnessMapUv:me&&_(x.sheenRoughnessMap.channel),specularMapUv:ue&&_(x.specularMap.channel),specularColorMapUv:ce&&_(x.specularColorMap.channel),specularIntensityMapUv:Ee&&_(x.specularIntensityMap.channel),transmissionMapUv:Te&&_(x.transmissionMap.channel),thicknessMapUv:Re&&_(x.thicknessMap.channel),alphaMapUv:fe&&_(x.alphaMap.channel),vertexTangents:!!k.attributes.tangent&&(at||U),vertexNormals:!!k.attributes.normal,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!k.attributes.color&&k.attributes.color.itemSize===4,pointsUvs:F.isPoints===!0&&!!k.attributes.uv&&(ft||fe),fog:!!j,useFog:x.fog===!0,fogExp2:!!j&&j.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||k.attributes.normal===void 0&&at===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:h,reversedDepthBuffer:Be,skinning:F.isSkinnedMesh===!0,hasPositionAttribute:k.attributes.position!==void 0,morphTargets:k.morphAttributes.position!==void 0,morphNormals:k.morphAttributes.normal!==void 0,morphColors:k.morphAttributes.color!==void 0,morphTargetsCount:Me,morphTextureStride:Ye,numDirLights:A.directional.length,numPointLights:A.point.length,numSpotLights:A.spot.length,numSpotLightMaps:A.spotLightMap.length,numRectAreaLights:A.rectArea.length,numHemiLights:A.hemi.length,numDirLightShadows:A.directionalShadowMap.length,numPointLightShadows:A.pointShadowMap.length,numSpotLightShadows:A.spotShadowMap.length,numSpotLightShadowsWithMaps:A.numSpotLightShadowsWithMaps,numLightProbes:A.numLightProbes,numLightProbeGrids:$.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:x.dithering,shadowMapEnabled:s.shadowMap.enabled&&D.length>0,shadowMapType:s.shadowMap.type,toneMapping:se,decodeVideoTexture:ft&&x.map.isVideoTexture===!0&&Qe.getTransfer(x.map.colorSpace)===ut,decodeVideoTextureEmissive:lt&&x.emissiveMap.isVideoTexture===!0&&Qe.getTransfer(x.emissiveMap.colorSpace)===ut,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===an,flipSided:x.side===tn,useDepthPacking:x.depthPacking>=0,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionClipCullDistance:ge&&x.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ge&&x.extensions.multiDraw===!0||De)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return be.vertexUv1s=l.has(1),be.vertexUv2s=l.has(2),be.vertexUv3s=l.has(3),l.clear(),be}function m(x){const A=[];if(x.shaderID?A.push(x.shaderID):(A.push(x.customVertexShaderID),A.push(x.customFragmentShaderID)),x.defines!==void 0)for(const D in x.defines)A.push(D),A.push(x.defines[D]);return x.isRawShaderMaterial===!1&&(p(A,x),b(A,x),A.push(s.outputColorSpace)),A.push(x.customProgramCacheKey),A.join()}function p(x,A){x.push(A.precision),x.push(A.outputColorSpace),x.push(A.envMapMode),x.push(A.envMapCubeUVHeight),x.push(A.mapUv),x.push(A.alphaMapUv),x.push(A.lightMapUv),x.push(A.aoMapUv),x.push(A.bumpMapUv),x.push(A.normalMapUv),x.push(A.displacementMapUv),x.push(A.emissiveMapUv),x.push(A.metalnessMapUv),x.push(A.roughnessMapUv),x.push(A.anisotropyMapUv),x.push(A.clearcoatMapUv),x.push(A.clearcoatNormalMapUv),x.push(A.clearcoatRoughnessMapUv),x.push(A.iridescenceMapUv),x.push(A.iridescenceThicknessMapUv),x.push(A.sheenColorMapUv),x.push(A.sheenRoughnessMapUv),x.push(A.specularMapUv),x.push(A.specularColorMapUv),x.push(A.specularIntensityMapUv),x.push(A.transmissionMapUv),x.push(A.thicknessMapUv),x.push(A.combine),x.push(A.fogExp2),x.push(A.sizeAttenuation),x.push(A.morphTargetsCount),x.push(A.morphAttributeCount),x.push(A.numDirLights),x.push(A.numPointLights),x.push(A.numSpotLights),x.push(A.numSpotLightMaps),x.push(A.numHemiLights),x.push(A.numRectAreaLights),x.push(A.numDirLightShadows),x.push(A.numPointLightShadows),x.push(A.numSpotLightShadows),x.push(A.numSpotLightShadowsWithMaps),x.push(A.numLightProbes),x.push(A.shadowMapType),x.push(A.toneMapping),x.push(A.numClippingPlanes),x.push(A.numClipIntersection),x.push(A.depthPacking)}function b(x,A){a.disableAll(),A.instancing&&a.enable(0),A.instancingColor&&a.enable(1),A.instancingMorph&&a.enable(2),A.matcap&&a.enable(3),A.envMap&&a.enable(4),A.normalMapObjectSpace&&a.enable(5),A.normalMapTangentSpace&&a.enable(6),A.clearcoat&&a.enable(7),A.iridescence&&a.enable(8),A.alphaTest&&a.enable(9),A.vertexColors&&a.enable(10),A.vertexAlphas&&a.enable(11),A.vertexUv1s&&a.enable(12),A.vertexUv2s&&a.enable(13),A.vertexUv3s&&a.enable(14),A.vertexTangents&&a.enable(15),A.anisotropy&&a.enable(16),A.alphaHash&&a.enable(17),A.batching&&a.enable(18),A.dispersion&&a.enable(19),A.batchingColor&&a.enable(20),A.gradientMap&&a.enable(21),A.packedNormalMap&&a.enable(22),A.vertexNormals&&a.enable(23),x.push(a.mask),a.disableAll(),A.fog&&a.enable(0),A.useFog&&a.enable(1),A.flatShading&&a.enable(2),A.logarithmicDepthBuffer&&a.enable(3),A.reversedDepthBuffer&&a.enable(4),A.skinning&&a.enable(5),A.morphTargets&&a.enable(6),A.morphNormals&&a.enable(7),A.morphColors&&a.enable(8),A.premultipliedAlpha&&a.enable(9),A.shadowMapEnabled&&a.enable(10),A.doubleSided&&a.enable(11),A.flipSided&&a.enable(12),A.useDepthPacking&&a.enable(13),A.dithering&&a.enable(14),A.transmission&&a.enable(15),A.sheen&&a.enable(16),A.opaque&&a.enable(17),A.pointsUvs&&a.enable(18),A.decodeVideoTexture&&a.enable(19),A.decodeVideoTextureEmissive&&a.enable(20),A.alphaToCoverage&&a.enable(21),A.numLightProbeGrids>0&&a.enable(22),A.hasPositionAttribute&&a.enable(23),x.push(a.mask)}function T(x){const A=f[x.type];let D;if(A){const P=wn[A];D=Vd.clone(P.uniforms)}else D=x.uniforms;return D}function S(x,A){let D=u.get(A);return D!==void 0?++D.usedTimes:(D=new K_(s,A,x,i),c.push(D),u.set(A,D)),D}function w(x){if(--x.usedTimes===0){const A=c.indexOf(x);c[A]=c[c.length-1],c.pop(),u.delete(x.cacheKey),x.destroy()}}function E(x){o.remove(x)}function R(){o.dispose()}return{getParameters:v,getProgramCacheKey:m,getUniforms:T,acquireProgram:S,releaseProgram:w,releaseShaderCache:E,programs:c,dispose:R}}function ex(){let s=new WeakMap;function e(a){return s.has(a)}function t(a){let o=s.get(a);return o===void 0&&(o={},s.set(a,o)),o}function n(a){s.delete(a)}function i(a,o,l){s.get(a)[o]=l}function r(){s=new WeakMap}return{has:e,get:t,remove:n,update:i,dispose:r}}function tx(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.material.id!==e.material.id?s.material.id-e.material.id:s.materialVariant!==e.materialVariant?s.materialVariant-e.materialVariant:s.z!==e.z?s.z-e.z:s.id-e.id}function Pc(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.z!==e.z?e.z-s.z:s.id-e.id}function Lc(){const s=[];let e=0;const t=[],n=[],i=[];function r(){e=0,t.length=0,n.length=0,i.length=0}function a(d){let f=0;return d.isInstancedMesh&&(f+=2),d.isSkinnedMesh&&(f+=1),f}function o(d,f,_,v,m,p){let b=s[e];return b===void 0?(b={id:d.id,object:d,geometry:f,material:_,materialVariant:a(d),groupOrder:v,renderOrder:d.renderOrder,z:m,group:p},s[e]=b):(b.id=d.id,b.object=d,b.geometry=f,b.material=_,b.materialVariant=a(d),b.groupOrder=v,b.renderOrder=d.renderOrder,b.z=m,b.group=p),e++,b}function l(d,f,_,v,m,p){const b=o(d,f,_,v,m,p);_.transmission>0?n.push(b):_.transparent===!0?i.push(b):t.push(b)}function c(d,f,_,v,m,p){const b=o(d,f,_,v,m,p);_.transmission>0?n.unshift(b):_.transparent===!0?i.unshift(b):t.unshift(b)}function u(d,f,_){t.length>1&&t.sort(d||tx),n.length>1&&n.sort(f||Pc),i.length>1&&i.sort(f||Pc),_&&(t.reverse(),n.reverse(),i.reverse())}function h(){for(let d=e,f=s.length;d<f;d++){const _=s[d];if(_.id===null)break;_.id=null,_.object=null,_.geometry=null,_.material=null,_.group=null}}return{opaque:t,transmissive:n,transparent:i,init:r,push:l,unshift:c,finish:h,sort:u}}function nx(){let s=new WeakMap;function e(n,i){const r=s.get(n);let a;return r===void 0?(a=new Lc,s.set(n,[a])):i>=r.length?(a=new Lc,r.push(a)):a=r[i],a}function t(){s=new WeakMap}return{get:e,dispose:t}}function ix(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new C,color:new Ue};break;case"SpotLight":t={position:new C,direction:new C,color:new Ue,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new C,color:new Ue,distance:0,decay:0};break;case"HemisphereLight":t={direction:new C,skyColor:new Ue,groundColor:new Ue};break;case"RectAreaLight":t={color:new Ue,position:new C,halfWidth:new C,halfHeight:new C};break}return s[e.id]=t,t}}}function sx(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ke};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ke};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ke,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[e.id]=t,t}}}let rx=0;function ax(s,e){return(e.castShadow?2:0)-(s.castShadow?2:0)+(e.map?1:0)-(s.map?1:0)}function ox(s){const e=new ix,t=sx(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new C);const i=new C,r=new We,a=new We;function o(c){let u=0,h=0,d=0;for(let A=0;A<9;A++)n.probe[A].set(0,0,0);let f=0,_=0,v=0,m=0,p=0,b=0,T=0,S=0,w=0,E=0,R=0;c.sort(ax);for(let A=0,D=c.length;A<D;A++){const P=c[A],F=P.color,$=P.intensity,j=P.distance;let k=null;if(P.shadow&&P.shadow.map&&(P.shadow.map.texture.format===Ei?k=P.shadow.map.texture:k=P.shadow.map.depthTexture||P.shadow.map.texture),P.isAmbientLight)u+=F.r*$,h+=F.g*$,d+=F.b*$;else if(P.isLightProbe){for(let q=0;q<9;q++)n.probe[q].addScaledVector(P.sh.coefficients[q],$);R++}else if(P.isDirectionalLight){const q=e.get(P);if(q.color.copy(P.color).multiplyScalar(P.intensity),P.castShadow){const W=P.shadow,ee=t.get(P);ee.shadowIntensity=W.intensity,ee.shadowBias=W.bias,ee.shadowNormalBias=W.normalBias,ee.shadowRadius=W.radius,ee.shadowMapSize=W.mapSize,n.directionalShadow[f]=ee,n.directionalShadowMap[f]=k,n.directionalShadowMatrix[f]=P.shadow.matrix,b++}n.directional[f]=q,f++}else if(P.isSpotLight){const q=e.get(P);q.position.setFromMatrixPosition(P.matrixWorld),q.color.copy(F).multiplyScalar($),q.distance=j,q.coneCos=Math.cos(P.angle),q.penumbraCos=Math.cos(P.angle*(1-P.penumbra)),q.decay=P.decay,n.spot[v]=q;const W=P.shadow;if(P.map&&(n.spotLightMap[w]=P.map,w++,W.updateMatrices(P),P.castShadow&&E++),n.spotLightMatrix[v]=W.matrix,P.castShadow){const ee=t.get(P);ee.shadowIntensity=W.intensity,ee.shadowBias=W.bias,ee.shadowNormalBias=W.normalBias,ee.shadowRadius=W.radius,ee.shadowMapSize=W.mapSize,n.spotShadow[v]=ee,n.spotShadowMap[v]=k,S++}v++}else if(P.isRectAreaLight){const q=e.get(P);q.color.copy(F).multiplyScalar($),q.halfWidth.set(P.width*.5,0,0),q.halfHeight.set(0,P.height*.5,0),n.rectArea[m]=q,m++}else if(P.isPointLight){const q=e.get(P);if(q.color.copy(P.color).multiplyScalar(P.intensity),q.distance=P.distance,q.decay=P.decay,P.castShadow){const W=P.shadow,ee=t.get(P);ee.shadowIntensity=W.intensity,ee.shadowBias=W.bias,ee.shadowNormalBias=W.normalBias,ee.shadowRadius=W.radius,ee.shadowMapSize=W.mapSize,ee.shadowCameraNear=W.camera.near,ee.shadowCameraFar=W.camera.far,n.pointShadow[_]=ee,n.pointShadowMap[_]=k,n.pointShadowMatrix[_]=P.shadow.matrix,T++}n.point[_]=q,_++}else if(P.isHemisphereLight){const q=e.get(P);q.skyColor.copy(P.color).multiplyScalar($),q.groundColor.copy(P.groundColor).multiplyScalar($),n.hemi[p]=q,p++}}m>0&&(s.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=xe.LTC_FLOAT_1,n.rectAreaLTC2=xe.LTC_FLOAT_2):(n.rectAreaLTC1=xe.LTC_HALF_1,n.rectAreaLTC2=xe.LTC_HALF_2)),n.ambient[0]=u,n.ambient[1]=h,n.ambient[2]=d;const x=n.hash;(x.directionalLength!==f||x.pointLength!==_||x.spotLength!==v||x.rectAreaLength!==m||x.hemiLength!==p||x.numDirectionalShadows!==b||x.numPointShadows!==T||x.numSpotShadows!==S||x.numSpotMaps!==w||x.numLightProbes!==R)&&(n.directional.length=f,n.spot.length=v,n.rectArea.length=m,n.point.length=_,n.hemi.length=p,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+w-E,n.spotLightMap.length=w,n.numSpotLightShadowsWithMaps=E,n.numLightProbes=R,x.directionalLength=f,x.pointLength=_,x.spotLength=v,x.rectAreaLength=m,x.hemiLength=p,x.numDirectionalShadows=b,x.numPointShadows=T,x.numSpotShadows=S,x.numSpotMaps=w,x.numLightProbes=R,n.version=rx++)}function l(c,u){let h=0,d=0,f=0,_=0,v=0;const m=u.matrixWorldInverse;for(let p=0,b=c.length;p<b;p++){const T=c[p];if(T.isDirectionalLight){const S=n.directional[h];S.direction.setFromMatrixPosition(T.matrixWorld),i.setFromMatrixPosition(T.target.matrixWorld),S.direction.sub(i),S.direction.transformDirection(m),h++}else if(T.isSpotLight){const S=n.spot[f];S.position.setFromMatrixPosition(T.matrixWorld),S.position.applyMatrix4(m),S.direction.setFromMatrixPosition(T.matrixWorld),i.setFromMatrixPosition(T.target.matrixWorld),S.direction.sub(i),S.direction.transformDirection(m),f++}else if(T.isRectAreaLight){const S=n.rectArea[_];S.position.setFromMatrixPosition(T.matrixWorld),S.position.applyMatrix4(m),a.identity(),r.copy(T.matrixWorld),r.premultiply(m),a.extractRotation(r),S.halfWidth.set(T.width*.5,0,0),S.halfHeight.set(0,T.height*.5,0),S.halfWidth.applyMatrix4(a),S.halfHeight.applyMatrix4(a),_++}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 Ic(s){const e=new ox(s),t=[],n=[],i=[];function r(d){h.camera=d,t.length=0,n.length=0,i.length=0}function a(d){t.push(d)}function o(d){n.push(d)}function l(d){i.push(d)}function c(){e.setup(t)}function u(d){e.setupView(t,d)}const h={lightsArray:t,shadowsArray:n,lightProbeGridArray:i,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:h,setupLights:c,setupLightsView:u,pushLight:a,pushShadow:o,pushLightProbeGrid:l}}function lx(s){let e=new WeakMap;function t(i,r=0){const a=e.get(i);let o;return a===void 0?(o=new Ic(s),e.set(i,[o])):r>=a.length?(o=new Ic(s),a.push(o)):o=a[r],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const cx=`void main() {
4058
4058
  gl_Position = vec4( position, 1.0 );
4059
- }`,cx=`uniform sampler2D shadow_pass;
4059
+ }`,ux=`uniform sampler2D shadow_pass;
4060
4060
  uniform vec2 resolution;
4061
4061
  uniform float radius;
4062
4062
  void main() {
@@ -4081,12 +4081,12 @@ void main() {
4081
4081
  squared_mean = squared_mean / samples;
4082
4082
  float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
4083
4083
  gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
4084
- }`,ux=[new C(1,0,0),new C(-1,0,0),new C(0,1,0),new C(0,-1,0),new C(0,0,1),new C(0,0,-1)],hx=[new C(0,-1,0),new C(0,-1,0),new C(0,0,1),new C(0,0,-1),new C(0,-1,0),new C(0,-1,0)],Dc=new We,Ts=new C,Aa=new C;function dx(s,e,t){let n=new $o;const i=new ke,r=new ke,a=new gt,o=new Wd,l=new Xd,c={},u=t.maxTextureSize,h={[Dn]:tn,[tn]:Dn,[an]:an},d=new Un({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ke},radius:{value:4}},vertexShader:lx,fragmentShader:cx}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const _=new Wt;_.setAttribute("position",new Nt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new bt(_,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Sr;let p=this.type;this.render=function(E,R,x){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||E.length===0)return;this.type===ch&&(Ie("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=Sr);const A=s.getRenderTarget(),D=s.getActiveCubeFace(),P=s.getActiveMipmapLevel(),F=s.state;F.setBlending(Kn),F.buffers.depth.getReversed()===!0?F.buffers.color.setClear(0,0,0,0):F.buffers.color.setClear(1,1,1,1),F.buffers.depth.setTest(!0),F.setScissorTest(!1);const $=p!==this.type;$&&R.traverse(function(j){j.material&&(Array.isArray(j.material)?j.material.forEach(k=>k.needsUpdate=!0):j.material.needsUpdate=!0)});for(let j=0,k=E.length;j<k;j++){const q=E[j],W=q.shadow;if(W===void 0){Ie("WebGLShadowMap:",q,"has no shadow.");continue}if(W.autoUpdate===!1&&W.needsUpdate===!1)continue;i.copy(W.mapSize);const ee=W.getFrameExtents();i.multiply(ee),r.copy(W.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(r.x=Math.floor(u/ee.x),i.x=r.x*ee.x,W.mapSize.x=r.x),i.y>u&&(r.y=Math.floor(u/ee.y),i.y=r.y*ee.y,W.mapSize.y=r.y));const K=s.state.buffers.depth.getReversed();if(W.camera._reversedDepth=K,W.map===null||$===!0){if(W.map!==null&&(W.map.depthTexture!==null&&(W.map.depthTexture.dispose(),W.map.depthTexture=null),W.map.dispose()),this.type===ws){if(q.isPointLight){Ie("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}W.map=new Ln(i.x,i.y,{format:Ei,type:$n,minFilter:Bt,magFilter:Bt,generateMipmaps:!1}),W.map.texture.name=q.name+".shadowMap",W.map.depthTexture=new ns(i.x,i.y,fn),W.map.depthTexture.name=q.name+".shadowMapDepth",W.map.depthTexture.format=jn,W.map.depthTexture.compareFunction=null,W.map.depthTexture.minFilter=Ot,W.map.depthTexture.magFilter=Ot}else q.isPointLight?(W.map=new wu(i.x),W.map.depthTexture=new Bd(i.x,Nn)):(W.map=new Ln(i.x,i.y),W.map.depthTexture=new ns(i.x,i.y,Nn)),W.map.depthTexture.name=q.name+".shadowMap",W.map.depthTexture.format=jn,this.type===Sr?(W.map.depthTexture.compareFunction=K?Go:Ho,W.map.depthTexture.minFilter=Bt,W.map.depthTexture.magFilter=Bt):(W.map.depthTexture.compareFunction=null,W.map.depthTexture.minFilter=Ot,W.map.depthTexture.magFilter=Ot);W.camera.updateProjectionMatrix()}const le=W.map.isWebGLCubeRenderTarget?6:1;for(let pe=0;pe<le;pe++){if(W.map.isWebGLCubeRenderTarget)s.setRenderTarget(W.map,pe),s.clear();else{pe===0&&(s.setRenderTarget(W.map),s.clear());const Me=W.getViewport(pe);a.set(r.x*Me.x,r.y*Me.y,r.x*Me.z,r.y*Me.w),F.viewport(a)}if(q.isPointLight){const Me=W.camera,Ye=W.matrix,rt=q.distance||Me.far;rt!==Me.far&&(Me.far=rt,Me.updateProjectionMatrix()),Ts.setFromMatrixPosition(q.matrixWorld),Me.position.copy(Ts),Aa.copy(Me.position),Aa.add(ux[pe]),Me.up.copy(hx[pe]),Me.lookAt(Aa),Me.updateMatrixWorld(),Ye.makeTranslation(-Ts.x,-Ts.y,-Ts.z),Dc.multiplyMatrices(Me.projectionMatrix,Me.matrixWorldInverse),W._frustum.setFromProjectionMatrix(Dc,Me.coordinateSystem,Me.reversedDepth)}else W.updateMatrices(q);n=W.getFrustum(),S(R,x,W.camera,q,this.type)}W.isPointLightShadow!==!0&&this.type===ws&&b(W,x),W.needsUpdate=!1}p=this.type,m.needsUpdate=!1,s.setRenderTarget(A,D,P)};function b(E,R){const x=e.update(v);d.defines.VSM_SAMPLES!==E.blurSamples&&(d.defines.VSM_SAMPLES=E.blurSamples,f.defines.VSM_SAMPLES=E.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),E.mapPass===null&&(E.mapPass=new Ln(i.x,i.y,{format:Ei,type:$n})),d.uniforms.shadow_pass.value=E.map.depthTexture,d.uniforms.resolution.value=E.mapSize,d.uniforms.radius.value=E.radius,s.setRenderTarget(E.mapPass),s.clear(),s.renderBufferDirect(R,null,x,d,v,null),f.uniforms.shadow_pass.value=E.mapPass.texture,f.uniforms.resolution.value=E.mapSize,f.uniforms.radius.value=E.radius,s.setRenderTarget(E.map),s.clear(),s.renderBufferDirect(R,null,x,f,v,null)}function T(E,R,x,A){let D=null;const P=x.isPointLight===!0?E.customDistanceMaterial:E.customDepthMaterial;if(P!==void 0)D=P;else if(D=x.isPointLight===!0?l:o,s.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0||R.alphaToCoverage===!0){const F=D.uuid,$=R.uuid;let j=c[F];j===void 0&&(j={},c[F]=j);let k=j[$];k===void 0&&(k=D.clone(),j[$]=k,R.addEventListener("dispose",w)),D=k}if(D.visible=R.visible,D.wireframe=R.wireframe,A===ws?D.side=R.shadowSide!==null?R.shadowSide:R.side:D.side=R.shadowSide!==null?R.shadowSide:h[R.side],D.alphaMap=R.alphaMap,D.alphaTest=R.alphaToCoverage===!0?.5:R.alphaTest,D.map=R.map,D.clipShadows=R.clipShadows,D.clippingPlanes=R.clippingPlanes,D.clipIntersection=R.clipIntersection,D.displacementMap=R.displacementMap,D.displacementScale=R.displacementScale,D.displacementBias=R.displacementBias,D.wireframeLinewidth=R.wireframeLinewidth,D.linewidth=R.linewidth,x.isPointLight===!0&&D.isMeshDistanceMaterial===!0){const F=s.properties.get(D);F.light=x}return D}function S(E,R,x,A,D){if(E.visible===!1)return;if(E.layers.test(R.layers)&&(E.isMesh||E.isLine||E.isPoints)&&(E.castShadow||E.receiveShadow&&D===ws)&&(!E.frustumCulled||n.intersectsObject(E))){E.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,E.matrixWorld);const $=e.update(E),j=E.material;if(Array.isArray(j)){const k=$.groups;for(let q=0,W=k.length;q<W;q++){const ee=k[q],K=j[ee.materialIndex];if(K&&K.visible){const le=T(E,K,A,D);E.onBeforeShadow(s,E,R,x,$,le,ee),s.renderBufferDirect(x,null,$,le,E,ee),E.onAfterShadow(s,E,R,x,$,le,ee)}}}else if(j.visible){const k=T(E,j,A,D);E.onBeforeShadow(s,E,R,x,$,k,null),s.renderBufferDirect(x,null,$,k,E,null),E.onAfterShadow(s,E,R,x,$,k,null)}}const F=E.children;for(let $=0,j=F.length;$<j;$++)S(F[$],R,x,A,D)}function w(E){E.target.removeEventListener("dispose",w);for(const x in c){const A=c[x],D=E.target.uuid;D in A&&(A[D].dispose(),delete A[D])}}}function fx(s,e){function t(){let I=!1;const fe=new gt;let te=null;const de=new gt(0,0,0,0);return{setMask:function(ge){te!==ge&&!I&&(s.colorMask(ge,ge,ge,ge),te=ge)},setLocked:function(ge){I=ge},setClear:function(ge,se,be,Ae,St){St===!0&&(ge*=Ae,se*=Ae,be*=Ae),fe.set(ge,se,be,Ae),de.equals(fe)===!1&&(s.clearColor(ge,se,be,Ae),de.copy(fe))},reset:function(){I=!1,te=null,de.set(-1,0,0,0)}}}function n(){let I=!1,fe=!1,te=null,de=null,ge=null;return{setReversed:function(se){if(fe!==se){const be=e.get("EXT_clip_control");se?be.clipControlEXT(be.LOWER_LEFT_EXT,be.ZERO_TO_ONE_EXT):be.clipControlEXT(be.LOWER_LEFT_EXT,be.NEGATIVE_ONE_TO_ONE_EXT),fe=se;const Ae=ge;ge=null,this.setClear(Ae)}},getReversed:function(){return fe},setTest:function(se){se?ae(s.DEPTH_TEST):Be(s.DEPTH_TEST)},setMask:function(se){te!==se&&!I&&(s.depthMask(se),te=se)},setFunc:function(se){if(fe&&(se=Xh[se]),de!==se){switch(se){case Oa:s.depthFunc(s.NEVER);break;case Ba:s.depthFunc(s.ALWAYS);break;case ka:s.depthFunc(s.LESS);break;case Ji:s.depthFunc(s.LEQUAL);break;case za:s.depthFunc(s.EQUAL);break;case Va:s.depthFunc(s.GEQUAL);break;case Ha:s.depthFunc(s.GREATER);break;case Ga:s.depthFunc(s.NOTEQUAL);break;default:s.depthFunc(s.LEQUAL)}de=se}},setLocked:function(se){I=se},setClear:function(se){ge!==se&&(ge=se,fe&&(se=1-se),s.clearDepth(se))},reset:function(){I=!1,te=null,de=null,ge=null,fe=!1}}}function i(){let I=!1,fe=null,te=null,de=null,ge=null,se=null,be=null,Ae=null,St=null;return{setTest:function(ct){I||(ct?ae(s.STENCIL_TEST):Be(s.STENCIL_TEST))},setMask:function(ct){fe!==ct&&!I&&(s.stencilMask(ct),fe=ct)},setFunc:function(ct,cn,qt){(te!==ct||de!==cn||ge!==qt)&&(s.stencilFunc(ct,cn,qt),te=ct,de=cn,ge=qt)},setOp:function(ct,cn,qt){(se!==ct||be!==cn||Ae!==qt)&&(s.stencilOp(ct,cn,qt),se=ct,be=cn,Ae=qt)},setLocked:function(ct){I=ct},setClear:function(ct){St!==ct&&(s.clearStencil(ct),St=ct)},reset:function(){I=!1,fe=null,te=null,de=null,ge=null,se=null,be=null,Ae=null,St=null}}}const r=new t,a=new n,o=new i,l=new WeakMap,c=new WeakMap;let u={},h={},d={},f=new WeakMap,_=[],v=null,m=!1,p=null,b=null,T=null,S=null,w=null,E=null,R=null,x=new Ue(0,0,0),A=0,D=!1,P=null,F=null,$=null,j=null,k=null;const q=s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let W=!1,ee=0;const K=s.getParameter(s.VERSION);K.indexOf("WebGL")!==-1?(ee=parseFloat(/^WebGL (\d)/.exec(K)[1]),W=ee>=1):K.indexOf("OpenGL ES")!==-1&&(ee=parseFloat(/^OpenGL ES (\d)/.exec(K)[1]),W=ee>=2);let le=null,pe={};const Me=s.getParameter(s.SCISSOR_BOX),Ye=s.getParameter(s.VIEWPORT),rt=new gt().fromArray(Me),qe=new gt().fromArray(Ye);function ne(I,fe,te,de){const ge=new Uint8Array(4),se=s.createTexture();s.bindTexture(I,se),s.texParameteri(I,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(I,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let be=0;be<te;be++)I===s.TEXTURE_3D||I===s.TEXTURE_2D_ARRAY?s.texImage3D(fe,0,s.RGBA,1,1,de,0,s.RGBA,s.UNSIGNED_BYTE,ge):s.texImage2D(fe+be,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,ge);return se}const he={};he[s.TEXTURE_2D]=ne(s.TEXTURE_2D,s.TEXTURE_2D,1),he[s.TEXTURE_CUBE_MAP]=ne(s.TEXTURE_CUBE_MAP,s.TEXTURE_CUBE_MAP_POSITIVE_X,6),he[s.TEXTURE_2D_ARRAY]=ne(s.TEXTURE_2D_ARRAY,s.TEXTURE_2D_ARRAY,1,1),he[s.TEXTURE_3D]=ne(s.TEXTURE_3D,s.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),ae(s.DEPTH_TEST),a.setFunc(Ji),nt(!1),at(fl),ae(s.CULL_FACE),Le(Kn);function ae(I){u[I]!==!0&&(s.enable(I),u[I]=!0)}function Be(I){u[I]!==!1&&(s.disable(I),u[I]=!1)}function Oe(I,fe){return d[I]!==fe?(s.bindFramebuffer(I,fe),d[I]=fe,I===s.DRAW_FRAMEBUFFER&&(d[s.FRAMEBUFFER]=fe),I===s.FRAMEBUFFER&&(d[s.DRAW_FRAMEBUFFER]=fe),!0):!1}function De(I,fe){let te=_,de=!1;if(I){te=f.get(fe),te===void 0&&(te=[],f.set(fe,te));const ge=I.textures;if(te.length!==ge.length||te[0]!==s.COLOR_ATTACHMENT0){for(let se=0,be=ge.length;se<be;se++)te[se]=s.COLOR_ATTACHMENT0+se;te.length=ge.length,de=!0}}else te[0]!==s.BACK&&(te[0]=s.BACK,de=!0);de&&s.drawBuffers(te)}function ft(I){return v!==I?(s.useProgram(I),v=I,!0):!1}const Ge={[xi]:s.FUNC_ADD,[hh]:s.FUNC_SUBTRACT,[dh]:s.FUNC_REVERSE_SUBTRACT};Ge[fh]=s.MIN,Ge[ph]=s.MAX;const je={[mh]:s.ZERO,[gh]:s.ONE,[_h]:s.SRC_COLOR,[Ua]:s.SRC_ALPHA,[bh]:s.SRC_ALPHA_SATURATE,[Sh]:s.DST_COLOR,[vh]:s.DST_ALPHA,[xh]:s.ONE_MINUS_SRC_COLOR,[Fa]:s.ONE_MINUS_SRC_ALPHA,[yh]:s.ONE_MINUS_DST_COLOR,[Mh]:s.ONE_MINUS_DST_ALPHA,[Eh]:s.CONSTANT_COLOR,[Th]:s.ONE_MINUS_CONSTANT_COLOR,[Ah]:s.CONSTANT_ALPHA,[wh]:s.ONE_MINUS_CONSTANT_ALPHA};function Le(I,fe,te,de,ge,se,be,Ae,St,ct){if(I===Kn){m===!0&&(Be(s.BLEND),m=!1);return}if(m===!1&&(ae(s.BLEND),m=!0),I!==uh){if(I!==p||ct!==D){if((b!==xi||w!==xi)&&(s.blendEquation(s.FUNC_ADD),b=xi,w=xi),ct)switch(I){case qi:s.blendFuncSeparate(s.ONE,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case pl:s.blendFunc(s.ONE,s.ONE);break;case ml:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case gl:s.blendFuncSeparate(s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ZERO,s.ONE);break;default:ze("WebGLState: Invalid blending: ",I);break}else switch(I){case qi:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case pl:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE,s.ONE,s.ONE);break;case ml:ze("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case gl:ze("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:ze("WebGLState: Invalid blending: ",I);break}T=null,S=null,E=null,R=null,x.set(0,0,0),A=0,p=I,D=ct}return}ge=ge||fe,se=se||te,be=be||de,(fe!==b||ge!==w)&&(s.blendEquationSeparate(Ge[fe],Ge[ge]),b=fe,w=ge),(te!==T||de!==S||se!==E||be!==R)&&(s.blendFuncSeparate(je[te],je[de],je[se],je[be]),T=te,S=de,E=se,R=be),(Ae.equals(x)===!1||St!==A)&&(s.blendColor(Ae.r,Ae.g,Ae.b,St),x.copy(Ae),A=St),p=I,D=!1}function Ve(I,fe){I.side===an?Be(s.CULL_FACE):ae(s.CULL_FACE);let te=I.side===tn;fe&&(te=!te),nt(te),I.blending===qi&&I.transparent===!1?Le(Kn):Le(I.blending,I.blendEquation,I.blendSrc,I.blendDst,I.blendEquationAlpha,I.blendSrcAlpha,I.blendDstAlpha,I.blendColor,I.blendAlpha,I.premultipliedAlpha),a.setFunc(I.depthFunc),a.setTest(I.depthTest),a.setMask(I.depthWrite),r.setMask(I.colorWrite);const de=I.stencilWrite;o.setTest(de),de&&(o.setMask(I.stencilWriteMask),o.setFunc(I.stencilFunc,I.stencilRef,I.stencilFuncMask),o.setOp(I.stencilFail,I.stencilZFail,I.stencilZPass)),lt(I.polygonOffset,I.polygonOffsetFactor,I.polygonOffsetUnits),I.alphaToCoverage===!0?ae(s.SAMPLE_ALPHA_TO_COVERAGE):Be(s.SAMPLE_ALPHA_TO_COVERAGE)}function nt(I){P!==I&&(I?s.frontFace(s.CW):s.frontFace(s.CCW),P=I)}function at(I){I!==oh?(ae(s.CULL_FACE),I!==F&&(I===fl?s.cullFace(s.BACK):I===lh?s.cullFace(s.FRONT):s.cullFace(s.FRONT_AND_BACK))):Be(s.CULL_FACE),F=I}function Et(I){I!==$&&(W&&s.lineWidth(I),$=I)}function lt(I,fe,te){I?(ae(s.POLYGON_OFFSET_FILL),(j!==fe||k!==te)&&(j=fe,k=te,a.getReversed()&&(fe=-fe),s.polygonOffset(fe,te))):Be(s.POLYGON_OFFSET_FILL)}function et(I){I?ae(s.SCISSOR_TEST):Be(s.SCISSOR_TEST)}function vt(I){I===void 0&&(I=s.TEXTURE0+q-1),le!==I&&(s.activeTexture(I),le=I)}function U(I,fe,te){te===void 0&&(le===null?te=s.TEXTURE0+q-1:te=le);let de=pe[te];de===void 0&&(de={type:void 0,texture:void 0},pe[te]=de),(de.type!==I||de.texture!==fe)&&(le!==te&&(s.activeTexture(te),le=te),s.bindTexture(I,fe||he[I]),de.type=I,de.texture=fe)}function G(){const I=pe[le];I!==void 0&&I.type!==void 0&&(s.bindTexture(I.type,null),I.type=void 0,I.texture=void 0)}function J(){try{s.compressedTexImage2D(...arguments)}catch(I){ze("WebGLState:",I)}}function y(){try{s.compressedTexImage3D(...arguments)}catch(I){ze("WebGLState:",I)}}function g(){try{s.texSubImage2D(...arguments)}catch(I){ze("WebGLState:",I)}}function L(){try{s.texSubImage3D(...arguments)}catch(I){ze("WebGLState:",I)}}function B(){try{s.compressedTexSubImage2D(...arguments)}catch(I){ze("WebGLState:",I)}}function z(){try{s.compressedTexSubImage3D(...arguments)}catch(I){ze("WebGLState:",I)}}function Q(){try{s.texStorage2D(...arguments)}catch(I){ze("WebGLState:",I)}}function re(){try{s.texStorage3D(...arguments)}catch(I){ze("WebGLState:",I)}}function X(){try{s.texImage2D(...arguments)}catch(I){ze("WebGLState:",I)}}function Z(){try{s.texImage3D(...arguments)}catch(I){ze("WebGLState:",I)}}function oe(I){return h[I]!==void 0?h[I]:s.getParameter(I)}function me(I,fe){h[I]!==fe&&(s.pixelStorei(I,fe),h[I]=fe)}function ue(I){rt.equals(I)===!1&&(s.scissor(I.x,I.y,I.z,I.w),rt.copy(I))}function ce(I){qe.equals(I)===!1&&(s.viewport(I.x,I.y,I.z,I.w),qe.copy(I))}function Ee(I,fe){let te=c.get(fe);te===void 0&&(te=new WeakMap,c.set(fe,te));let de=te.get(I);de===void 0&&(de=s.getUniformBlockIndex(fe,I.name),te.set(I,de))}function Te(I,fe){const de=c.get(fe).get(I);l.get(fe)!==de&&(s.uniformBlockBinding(fe,de,I.__bindingPointIndex),l.set(fe,de))}function Re(){s.disable(s.BLEND),s.disable(s.CULL_FACE),s.disable(s.DEPTH_TEST),s.disable(s.POLYGON_OFFSET_FILL),s.disable(s.SCISSOR_TEST),s.disable(s.STENCIL_TEST),s.disable(s.SAMPLE_ALPHA_TO_COVERAGE),s.blendEquation(s.FUNC_ADD),s.blendFunc(s.ONE,s.ZERO),s.blendFuncSeparate(s.ONE,s.ZERO,s.ONE,s.ZERO),s.blendColor(0,0,0,0),s.colorMask(!0,!0,!0,!0),s.clearColor(0,0,0,0),s.depthMask(!0),s.depthFunc(s.LESS),a.setReversed(!1),s.clearDepth(1),s.stencilMask(4294967295),s.stencilFunc(s.ALWAYS,0,4294967295),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),s.clearStencil(0),s.cullFace(s.BACK),s.frontFace(s.CCW),s.polygonOffset(0,0),s.activeTexture(s.TEXTURE0),s.bindFramebuffer(s.FRAMEBUFFER,null),s.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),s.bindFramebuffer(s.READ_FRAMEBUFFER,null),s.useProgram(null),s.lineWidth(1),s.scissor(0,0,s.canvas.width,s.canvas.height),s.viewport(0,0,s.canvas.width,s.canvas.height),s.pixelStorei(s.PACK_ALIGNMENT,4),s.pixelStorei(s.UNPACK_ALIGNMENT,4),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,!1),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,s.BROWSER_DEFAULT_WEBGL),s.pixelStorei(s.PACK_ROW_LENGTH,0),s.pixelStorei(s.PACK_SKIP_PIXELS,0),s.pixelStorei(s.PACK_SKIP_ROWS,0),s.pixelStorei(s.UNPACK_ROW_LENGTH,0),s.pixelStorei(s.UNPACK_IMAGE_HEIGHT,0),s.pixelStorei(s.UNPACK_SKIP_PIXELS,0),s.pixelStorei(s.UNPACK_SKIP_ROWS,0),s.pixelStorei(s.UNPACK_SKIP_IMAGES,0),u={},h={},le=null,pe={},d={},f=new WeakMap,_=[],v=null,m=!1,p=null,b=null,T=null,S=null,w=null,E=null,R=null,x=new Ue(0,0,0),A=0,D=!1,P=null,F=null,$=null,j=null,k=null,rt.set(0,0,s.canvas.width,s.canvas.height),qe.set(0,0,s.canvas.width,s.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:ae,disable:Be,bindFramebuffer:Oe,drawBuffers:De,useProgram:ft,setBlending:Le,setMaterial:Ve,setFlipSided:nt,setCullFace:at,setLineWidth:Et,setPolygonOffset:lt,setScissorTest:et,activeTexture:vt,bindTexture:U,unbindTexture:G,compressedTexImage2D:J,compressedTexImage3D:y,texImage2D:X,texImage3D:Z,pixelStorei:me,getParameter:oe,updateUBOMapping:Ee,uniformBlockBinding:Te,texStorage2D:Q,texStorage3D:re,texSubImage2D:g,texSubImage3D:L,compressedTexSubImage2D:B,compressedTexSubImage3D:z,scissor:ue,viewport:ce,reset:Re}}function px(s,e,t,n,i,r,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new ke,u=new WeakMap,h=new Set;let d;const f=new WeakMap;let _=!1;try{_=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(y,g){return _?new OffscreenCanvas(y,g):Bs("canvas")}function m(y,g,L){let B=1;const z=J(y);if((z.width>L||z.height>L)&&(B=L/Math.max(z.width,z.height)),B<1)if(typeof HTMLImageElement<"u"&&y instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&y instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&y instanceof ImageBitmap||typeof VideoFrame<"u"&&y instanceof VideoFrame){const Q=Math.floor(B*z.width),re=Math.floor(B*z.height);d===void 0&&(d=v(Q,re));const X=g?v(Q,re):d;return X.width=Q,X.height=re,X.getContext("2d").drawImage(y,0,0,Q,re),Ie("WebGLRenderer: Texture has been resized from ("+z.width+"x"+z.height+") to ("+Q+"x"+re+")."),X}else return"data"in y&&Ie("WebGLRenderer: Image in DataTexture is too big ("+z.width+"x"+z.height+")."),y;return y}function p(y){return y.generateMipmaps}function b(y){s.generateMipmap(y)}function T(y){return y.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:y.isWebGL3DRenderTarget?s.TEXTURE_3D:y.isWebGLArrayRenderTarget||y.isCompressedArrayTexture?s.TEXTURE_2D_ARRAY:s.TEXTURE_2D}function S(y,g,L,B,z,Q=!1){if(y!==null){if(s[y]!==void 0)return s[y];Ie("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+y+"'")}let re;B&&(re=e.get("EXT_texture_norm16"),re||Ie("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let X=g;if(g===s.RED&&(L===s.FLOAT&&(X=s.R32F),L===s.HALF_FLOAT&&(X=s.R16F),L===s.UNSIGNED_BYTE&&(X=s.R8),L===s.UNSIGNED_SHORT&&re&&(X=re.R16_EXT),L===s.SHORT&&re&&(X=re.R16_SNORM_EXT)),g===s.RED_INTEGER&&(L===s.UNSIGNED_BYTE&&(X=s.R8UI),L===s.UNSIGNED_SHORT&&(X=s.R16UI),L===s.UNSIGNED_INT&&(X=s.R32UI),L===s.BYTE&&(X=s.R8I),L===s.SHORT&&(X=s.R16I),L===s.INT&&(X=s.R32I)),g===s.RG&&(L===s.FLOAT&&(X=s.RG32F),L===s.HALF_FLOAT&&(X=s.RG16F),L===s.UNSIGNED_BYTE&&(X=s.RG8),L===s.UNSIGNED_SHORT&&re&&(X=re.RG16_EXT),L===s.SHORT&&re&&(X=re.RG16_SNORM_EXT)),g===s.RG_INTEGER&&(L===s.UNSIGNED_BYTE&&(X=s.RG8UI),L===s.UNSIGNED_SHORT&&(X=s.RG16UI),L===s.UNSIGNED_INT&&(X=s.RG32UI),L===s.BYTE&&(X=s.RG8I),L===s.SHORT&&(X=s.RG16I),L===s.INT&&(X=s.RG32I)),g===s.RGB_INTEGER&&(L===s.UNSIGNED_BYTE&&(X=s.RGB8UI),L===s.UNSIGNED_SHORT&&(X=s.RGB16UI),L===s.UNSIGNED_INT&&(X=s.RGB32UI),L===s.BYTE&&(X=s.RGB8I),L===s.SHORT&&(X=s.RGB16I),L===s.INT&&(X=s.RGB32I)),g===s.RGBA_INTEGER&&(L===s.UNSIGNED_BYTE&&(X=s.RGBA8UI),L===s.UNSIGNED_SHORT&&(X=s.RGBA16UI),L===s.UNSIGNED_INT&&(X=s.RGBA32UI),L===s.BYTE&&(X=s.RGBA8I),L===s.SHORT&&(X=s.RGBA16I),L===s.INT&&(X=s.RGBA32I)),g===s.RGB&&(L===s.UNSIGNED_SHORT&&re&&(X=re.RGB16_EXT),L===s.SHORT&&re&&(X=re.RGB16_SNORM_EXT),L===s.UNSIGNED_INT_5_9_9_9_REV&&(X=s.RGB9_E5),L===s.UNSIGNED_INT_10F_11F_11F_REV&&(X=s.R11F_G11F_B10F)),g===s.RGBA){const Z=Q?Lr:Qe.getTransfer(z);L===s.FLOAT&&(X=s.RGBA32F),L===s.HALF_FLOAT&&(X=s.RGBA16F),L===s.UNSIGNED_BYTE&&(X=Z===ut?s.SRGB8_ALPHA8:s.RGBA8),L===s.UNSIGNED_SHORT&&re&&(X=re.RGBA16_EXT),L===s.SHORT&&re&&(X=re.RGBA16_SNORM_EXT),L===s.UNSIGNED_SHORT_4_4_4_4&&(X=s.RGBA4),L===s.UNSIGNED_SHORT_5_5_5_1&&(X=s.RGB5_A1)}return(X===s.R16F||X===s.R32F||X===s.RG16F||X===s.RG32F||X===s.RGBA16F||X===s.RGBA32F)&&e.get("EXT_color_buffer_float"),X}function w(y,g){let L;return y?g===null||g===Nn||g===Ns?L=s.DEPTH24_STENCIL8:g===fn?L=s.DEPTH32F_STENCIL8:g===Ds&&(L=s.DEPTH24_STENCIL8,Ie("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):g===null||g===Nn||g===Ns?L=s.DEPTH_COMPONENT24:g===fn?L=s.DEPTH_COMPONENT32F:g===Ds&&(L=s.DEPTH_COMPONENT16),L}function E(y,g){return p(y)===!0||y.isFramebufferTexture&&y.minFilter!==Ot&&y.minFilter!==Bt?Math.log2(Math.max(g.width,g.height))+1:y.mipmaps!==void 0&&y.mipmaps.length>0?y.mipmaps.length:y.isCompressedTexture&&Array.isArray(y.image)?g.mipmaps.length:1}function R(y){const g=y.target;g.removeEventListener("dispose",R),A(g),g.isVideoTexture&&u.delete(g),g.isHTMLTexture&&h.delete(g)}function x(y){const g=y.target;g.removeEventListener("dispose",x),P(g)}function A(y){const g=n.get(y);if(g.__webglInit===void 0)return;const L=y.source,B=f.get(L);if(B){const z=B[g.__cacheKey];z.usedTimes--,z.usedTimes===0&&D(y),Object.keys(B).length===0&&f.delete(L)}n.remove(y)}function D(y){const g=n.get(y);s.deleteTexture(g.__webglTexture);const L=y.source,B=f.get(L);delete B[g.__cacheKey],a.memory.textures--}function P(y){const g=n.get(y);if(y.depthTexture&&(y.depthTexture.dispose(),n.remove(y.depthTexture)),y.isWebGLCubeRenderTarget)for(let B=0;B<6;B++){if(Array.isArray(g.__webglFramebuffer[B]))for(let z=0;z<g.__webglFramebuffer[B].length;z++)s.deleteFramebuffer(g.__webglFramebuffer[B][z]);else s.deleteFramebuffer(g.__webglFramebuffer[B]);g.__webglDepthbuffer&&s.deleteRenderbuffer(g.__webglDepthbuffer[B])}else{if(Array.isArray(g.__webglFramebuffer))for(let B=0;B<g.__webglFramebuffer.length;B++)s.deleteFramebuffer(g.__webglFramebuffer[B]);else s.deleteFramebuffer(g.__webglFramebuffer);if(g.__webglDepthbuffer&&s.deleteRenderbuffer(g.__webglDepthbuffer),g.__webglMultisampledFramebuffer&&s.deleteFramebuffer(g.__webglMultisampledFramebuffer),g.__webglColorRenderbuffer)for(let B=0;B<g.__webglColorRenderbuffer.length;B++)g.__webglColorRenderbuffer[B]&&s.deleteRenderbuffer(g.__webglColorRenderbuffer[B]);g.__webglDepthRenderbuffer&&s.deleteRenderbuffer(g.__webglDepthRenderbuffer)}const L=y.textures;for(let B=0,z=L.length;B<z;B++){const Q=n.get(L[B]);Q.__webglTexture&&(s.deleteTexture(Q.__webglTexture),a.memory.textures--),n.remove(L[B])}n.remove(y)}let F=0;function $(){F=0}function j(){return F}function k(y){F=y}function q(){const y=F;return y>=i.maxTextures&&Ie("WebGLTextures: Trying to use "+y+" texture units while this GPU supports only "+i.maxTextures),F+=1,y}function W(y){const g=[];return g.push(y.wrapS),g.push(y.wrapT),g.push(y.wrapR||0),g.push(y.magFilter),g.push(y.minFilter),g.push(y.anisotropy),g.push(y.internalFormat),g.push(y.format),g.push(y.type),g.push(y.generateMipmaps),g.push(y.premultiplyAlpha),g.push(y.flipY),g.push(y.unpackAlignment),g.push(y.colorSpace),g.join()}function ee(y,g){const L=n.get(y);if(y.isVideoTexture&&U(y),y.isRenderTargetTexture===!1&&y.isExternalTexture!==!0&&y.version>0&&L.__version!==y.version){const B=y.image;if(B===null)Ie("WebGLRenderer: Texture marked for update but no image data found.");else if(B.complete===!1)Ie("WebGLRenderer: Texture marked for update but image is incomplete");else{Be(L,y,g);return}}else y.isExternalTexture&&(L.__webglTexture=y.sourceTexture?y.sourceTexture:null);t.bindTexture(s.TEXTURE_2D,L.__webglTexture,s.TEXTURE0+g)}function K(y,g){const L=n.get(y);if(y.isRenderTargetTexture===!1&&y.version>0&&L.__version!==y.version){Be(L,y,g);return}else y.isExternalTexture&&(L.__webglTexture=y.sourceTexture?y.sourceTexture:null);t.bindTexture(s.TEXTURE_2D_ARRAY,L.__webglTexture,s.TEXTURE0+g)}function le(y,g){const L=n.get(y);if(y.isRenderTargetTexture===!1&&y.version>0&&L.__version!==y.version){Be(L,y,g);return}t.bindTexture(s.TEXTURE_3D,L.__webglTexture,s.TEXTURE0+g)}function pe(y,g){const L=n.get(y);if(y.isCubeDepthTexture!==!0&&y.version>0&&L.__version!==y.version){Oe(L,y,g);return}t.bindTexture(s.TEXTURE_CUBE_MAP,L.__webglTexture,s.TEXTURE0+g)}const Me={[es]:s.REPEAT,[Rn]:s.CLAMP_TO_EDGE,[Rr]:s.MIRRORED_REPEAT},Ye={[Ot]:s.NEAREST,[su]:s.NEAREST_MIPMAP_NEAREST,[Rs]:s.NEAREST_MIPMAP_LINEAR,[Bt]:s.LINEAR,[yr]:s.LINEAR_MIPMAP_NEAREST,[Yn]:s.LINEAR_MIPMAP_LINEAR},rt={[Uh]:s.NEVER,[zh]:s.ALWAYS,[Fh]:s.LESS,[Ho]:s.LEQUAL,[Oh]:s.EQUAL,[Go]:s.GEQUAL,[Bh]:s.GREATER,[kh]:s.NOTEQUAL};function qe(y,g){if(g.type===fn&&e.has("OES_texture_float_linear")===!1&&(g.magFilter===Bt||g.magFilter===yr||g.magFilter===Rs||g.magFilter===Yn||g.minFilter===Bt||g.minFilter===yr||g.minFilter===Rs||g.minFilter===Yn)&&Ie("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),s.texParameteri(y,s.TEXTURE_WRAP_S,Me[g.wrapS]),s.texParameteri(y,s.TEXTURE_WRAP_T,Me[g.wrapT]),(y===s.TEXTURE_3D||y===s.TEXTURE_2D_ARRAY)&&s.texParameteri(y,s.TEXTURE_WRAP_R,Me[g.wrapR]),s.texParameteri(y,s.TEXTURE_MAG_FILTER,Ye[g.magFilter]),s.texParameteri(y,s.TEXTURE_MIN_FILTER,Ye[g.minFilter]),g.compareFunction&&(s.texParameteri(y,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(y,s.TEXTURE_COMPARE_FUNC,rt[g.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(g.magFilter===Ot||g.minFilter!==Rs&&g.minFilter!==Yn||g.type===fn&&e.has("OES_texture_float_linear")===!1)return;if(g.anisotropy>1||n.get(g).__currentAnisotropy){const L=e.get("EXT_texture_filter_anisotropic");s.texParameterf(y,L.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(g.anisotropy,i.getMaxAnisotropy())),n.get(g).__currentAnisotropy=g.anisotropy}}}function ne(y,g){let L=!1;y.__webglInit===void 0&&(y.__webglInit=!0,g.addEventListener("dispose",R));const B=g.source;let z=f.get(B);z===void 0&&(z={},f.set(B,z));const Q=W(g);if(Q!==y.__cacheKey){z[Q]===void 0&&(z[Q]={texture:s.createTexture(),usedTimes:0},a.memory.textures++,L=!0),z[Q].usedTimes++;const re=z[y.__cacheKey];re!==void 0&&(z[y.__cacheKey].usedTimes--,re.usedTimes===0&&D(g)),y.__cacheKey=Q,y.__webglTexture=z[Q].texture}return L}function he(y,g,L){return Math.floor(Math.floor(y/L)/g)}function ae(y,g,L,B){const Q=y.updateRanges;if(Q.length===0)t.texSubImage2D(s.TEXTURE_2D,0,0,0,g.width,g.height,L,B,g.data);else{Q.sort((me,ue)=>me.start-ue.start);let re=0;for(let me=1;me<Q.length;me++){const ue=Q[re],ce=Q[me],Ee=ue.start+ue.count,Te=he(ce.start,g.width,4),Re=he(ue.start,g.width,4);ce.start<=Ee+1&&Te===Re&&he(ce.start+ce.count-1,g.width,4)===Te?ue.count=Math.max(ue.count,ce.start+ce.count-ue.start):(++re,Q[re]=ce)}Q.length=re+1;const X=t.getParameter(s.UNPACK_ROW_LENGTH),Z=t.getParameter(s.UNPACK_SKIP_PIXELS),oe=t.getParameter(s.UNPACK_SKIP_ROWS);t.pixelStorei(s.UNPACK_ROW_LENGTH,g.width);for(let me=0,ue=Q.length;me<ue;me++){const ce=Q[me],Ee=Math.floor(ce.start/4),Te=Math.ceil(ce.count/4),Re=Ee%g.width,I=Math.floor(Ee/g.width),fe=Te,te=1;t.pixelStorei(s.UNPACK_SKIP_PIXELS,Re),t.pixelStorei(s.UNPACK_SKIP_ROWS,I),t.texSubImage2D(s.TEXTURE_2D,0,Re,I,fe,te,L,B,g.data)}y.clearUpdateRanges(),t.pixelStorei(s.UNPACK_ROW_LENGTH,X),t.pixelStorei(s.UNPACK_SKIP_PIXELS,Z),t.pixelStorei(s.UNPACK_SKIP_ROWS,oe)}}function Be(y,g,L){let B=s.TEXTURE_2D;(g.isDataArrayTexture||g.isCompressedArrayTexture)&&(B=s.TEXTURE_2D_ARRAY),g.isData3DTexture&&(B=s.TEXTURE_3D);const z=ne(y,g),Q=g.source;t.bindTexture(B,y.__webglTexture,s.TEXTURE0+L);const re=n.get(Q);if(Q.version!==re.__version||z===!0){if(t.activeTexture(s.TEXTURE0+L),(typeof ImageBitmap<"u"&&g.image instanceof ImageBitmap)===!1){const te=Qe.getPrimaries(Qe.workingColorSpace),de=g.colorSpace===li?null:Qe.getPrimaries(g.colorSpace),ge=g.colorSpace===li||te===de?s.NONE:s.BROWSER_DEFAULT_WEBGL;t.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,g.flipY),t.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,g.premultiplyAlpha),t.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,ge)}t.pixelStorei(s.UNPACK_ALIGNMENT,g.unpackAlignment);let Z=m(g.image,!1,i.maxTextureSize);Z=G(g,Z);const oe=r.convert(g.format,g.colorSpace),me=r.convert(g.type);let ue=S(g.internalFormat,oe,me,g.normalized,g.colorSpace,g.isVideoTexture);qe(B,g);let ce;const Ee=g.mipmaps,Te=g.isVideoTexture!==!0,Re=re.__version===void 0||z===!0,I=Q.dataReady,fe=E(g,Z);if(g.isDepthTexture)ue=w(g.format===Mi,g.type),Re&&(Te?t.texStorage2D(s.TEXTURE_2D,1,ue,Z.width,Z.height):t.texImage2D(s.TEXTURE_2D,0,ue,Z.width,Z.height,0,oe,me,null));else if(g.isDataTexture)if(Ee.length>0){Te&&Re&&t.texStorage2D(s.TEXTURE_2D,fe,ue,Ee[0].width,Ee[0].height);for(let te=0,de=Ee.length;te<de;te++)ce=Ee[te],Te?I&&t.texSubImage2D(s.TEXTURE_2D,te,0,0,ce.width,ce.height,oe,me,ce.data):t.texImage2D(s.TEXTURE_2D,te,ue,ce.width,ce.height,0,oe,me,ce.data);g.generateMipmaps=!1}else Te?(Re&&t.texStorage2D(s.TEXTURE_2D,fe,ue,Z.width,Z.height),I&&ae(g,Z,oe,me)):t.texImage2D(s.TEXTURE_2D,0,ue,Z.width,Z.height,0,oe,me,Z.data);else if(g.isCompressedTexture)if(g.isCompressedArrayTexture){Te&&Re&&t.texStorage3D(s.TEXTURE_2D_ARRAY,fe,ue,Ee[0].width,Ee[0].height,Z.depth);for(let te=0,de=Ee.length;te<de;te++)if(ce=Ee[te],g.format!==pn)if(oe!==null)if(Te){if(I)if(g.layerUpdates.size>0){const ge=uc(ce.width,ce.height,g.format,g.type);for(const se of g.layerUpdates){const be=ce.data.subarray(se*ge/ce.data.BYTES_PER_ELEMENT,(se+1)*ge/ce.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,te,0,0,se,ce.width,ce.height,1,oe,be)}g.clearLayerUpdates()}else t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,te,0,0,0,ce.width,ce.height,Z.depth,oe,ce.data)}else t.compressedTexImage3D(s.TEXTURE_2D_ARRAY,te,ue,ce.width,ce.height,Z.depth,0,ce.data,0,0);else Ie("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Te?I&&t.texSubImage3D(s.TEXTURE_2D_ARRAY,te,0,0,0,ce.width,ce.height,Z.depth,oe,me,ce.data):t.texImage3D(s.TEXTURE_2D_ARRAY,te,ue,ce.width,ce.height,Z.depth,0,oe,me,ce.data)}else{Te&&Re&&t.texStorage2D(s.TEXTURE_2D,fe,ue,Ee[0].width,Ee[0].height);for(let te=0,de=Ee.length;te<de;te++)ce=Ee[te],g.format!==pn?oe!==null?Te?I&&t.compressedTexSubImage2D(s.TEXTURE_2D,te,0,0,ce.width,ce.height,oe,ce.data):t.compressedTexImage2D(s.TEXTURE_2D,te,ue,ce.width,ce.height,0,ce.data):Ie("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Te?I&&t.texSubImage2D(s.TEXTURE_2D,te,0,0,ce.width,ce.height,oe,me,ce.data):t.texImage2D(s.TEXTURE_2D,te,ue,ce.width,ce.height,0,oe,me,ce.data)}else if(g.isDataArrayTexture)if(Te){if(Re&&t.texStorage3D(s.TEXTURE_2D_ARRAY,fe,ue,Z.width,Z.height,Z.depth),I)if(g.layerUpdates.size>0){const te=uc(Z.width,Z.height,g.format,g.type);for(const de of g.layerUpdates){const ge=Z.data.subarray(de*te/Z.data.BYTES_PER_ELEMENT,(de+1)*te/Z.data.BYTES_PER_ELEMENT);t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,de,Z.width,Z.height,1,oe,me,ge)}g.clearLayerUpdates()}else t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,Z.width,Z.height,Z.depth,oe,me,Z.data)}else t.texImage3D(s.TEXTURE_2D_ARRAY,0,ue,Z.width,Z.height,Z.depth,0,oe,me,Z.data);else if(g.isData3DTexture)Te?(Re&&t.texStorage3D(s.TEXTURE_3D,fe,ue,Z.width,Z.height,Z.depth),I&&t.texSubImage3D(s.TEXTURE_3D,0,0,0,0,Z.width,Z.height,Z.depth,oe,me,Z.data)):t.texImage3D(s.TEXTURE_3D,0,ue,Z.width,Z.height,Z.depth,0,oe,me,Z.data);else if(g.isFramebufferTexture){if(Re)if(Te)t.texStorage2D(s.TEXTURE_2D,fe,ue,Z.width,Z.height);else{let te=Z.width,de=Z.height;for(let ge=0;ge<fe;ge++)t.texImage2D(s.TEXTURE_2D,ge,ue,te,de,0,oe,me,null),te>>=1,de>>=1}}else if(g.isHTMLTexture){if("texElementImage2D"in s){const te=s.canvas;if(te.hasAttribute("layoutsubtree")||te.setAttribute("layoutsubtree","true"),Z.parentNode!==te){te.appendChild(Z),h.add(g),te.onpaint=de=>{const ge=de.changedElements;for(const se of h)ge.includes(se.image)&&(se.needsUpdate=!0)},te.requestPaint();return}if(s.texElementImage2D.length===3)s.texElementImage2D(s.TEXTURE_2D,s.RGBA8,Z);else{const ge=s.RGBA,se=s.RGBA,be=s.UNSIGNED_BYTE;s.texElementImage2D(s.TEXTURE_2D,0,ge,se,be,Z)}s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE)}}else if(Ee.length>0){if(Te&&Re){const te=J(Ee[0]);t.texStorage2D(s.TEXTURE_2D,fe,ue,te.width,te.height)}for(let te=0,de=Ee.length;te<de;te++)ce=Ee[te],Te?I&&t.texSubImage2D(s.TEXTURE_2D,te,0,0,oe,me,ce):t.texImage2D(s.TEXTURE_2D,te,ue,oe,me,ce);g.generateMipmaps=!1}else if(Te){if(Re){const te=J(Z);t.texStorage2D(s.TEXTURE_2D,fe,ue,te.width,te.height)}I&&t.texSubImage2D(s.TEXTURE_2D,0,0,0,oe,me,Z)}else t.texImage2D(s.TEXTURE_2D,0,ue,oe,me,Z);p(g)&&b(B),re.__version=Q.version,g.onUpdate&&g.onUpdate(g)}y.__version=g.version}function Oe(y,g,L){if(g.image.length!==6)return;const B=ne(y,g),z=g.source;t.bindTexture(s.TEXTURE_CUBE_MAP,y.__webglTexture,s.TEXTURE0+L);const Q=n.get(z);if(z.version!==Q.__version||B===!0){t.activeTexture(s.TEXTURE0+L);const re=Qe.getPrimaries(Qe.workingColorSpace),X=g.colorSpace===li?null:Qe.getPrimaries(g.colorSpace),Z=g.colorSpace===li||re===X?s.NONE:s.BROWSER_DEFAULT_WEBGL;t.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,g.flipY),t.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,g.premultiplyAlpha),t.pixelStorei(s.UNPACK_ALIGNMENT,g.unpackAlignment),t.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,Z);const oe=g.isCompressedTexture||g.image[0].isCompressedTexture,me=g.image[0]&&g.image[0].isDataTexture,ue=[];for(let se=0;se<6;se++)!oe&&!me?ue[se]=m(g.image[se],!0,i.maxCubemapSize):ue[se]=me?g.image[se].image:g.image[se],ue[se]=G(g,ue[se]);const ce=ue[0],Ee=r.convert(g.format,g.colorSpace),Te=r.convert(g.type),Re=S(g.internalFormat,Ee,Te,g.normalized,g.colorSpace),I=g.isVideoTexture!==!0,fe=Q.__version===void 0||B===!0,te=z.dataReady;let de=E(g,ce);qe(s.TEXTURE_CUBE_MAP,g);let ge;if(oe){I&&fe&&t.texStorage2D(s.TEXTURE_CUBE_MAP,de,Re,ce.width,ce.height);for(let se=0;se<6;se++){ge=ue[se].mipmaps;for(let be=0;be<ge.length;be++){const Ae=ge[be];g.format!==pn?Ee!==null?I?te&&t.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+se,be,0,0,Ae.width,Ae.height,Ee,Ae.data):t.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+se,be,Re,Ae.width,Ae.height,0,Ae.data):Ie("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):I?te&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+se,be,0,0,Ae.width,Ae.height,Ee,Te,Ae.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+se,be,Re,Ae.width,Ae.height,0,Ee,Te,Ae.data)}}}else{if(ge=g.mipmaps,I&&fe){ge.length>0&&de++;const se=J(ue[0]);t.texStorage2D(s.TEXTURE_CUBE_MAP,de,Re,se.width,se.height)}for(let se=0;se<6;se++)if(me){I?te&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+se,0,0,0,ue[se].width,ue[se].height,Ee,Te,ue[se].data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+se,0,Re,ue[se].width,ue[se].height,0,Ee,Te,ue[se].data);for(let be=0;be<ge.length;be++){const St=ge[be].image[se].image;I?te&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+se,be+1,0,0,St.width,St.height,Ee,Te,St.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+se,be+1,Re,St.width,St.height,0,Ee,Te,St.data)}}else{I?te&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+se,0,0,0,Ee,Te,ue[se]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+se,0,Re,Ee,Te,ue[se]);for(let be=0;be<ge.length;be++){const Ae=ge[be];I?te&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+se,be+1,0,0,Ee,Te,Ae.image[se]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+se,be+1,Re,Ee,Te,Ae.image[se])}}}p(g)&&b(s.TEXTURE_CUBE_MAP),Q.__version=z.version,g.onUpdate&&g.onUpdate(g)}y.__version=g.version}function De(y,g,L,B,z,Q){const re=r.convert(L.format,L.colorSpace),X=r.convert(L.type),Z=S(L.internalFormat,re,X,L.normalized,L.colorSpace),oe=n.get(g),me=n.get(L);if(me.__renderTarget=g,!oe.__hasExternalTextures){const ue=Math.max(1,g.width>>Q),ce=Math.max(1,g.height>>Q);z===s.TEXTURE_3D||z===s.TEXTURE_2D_ARRAY?t.texImage3D(z,Q,Z,ue,ce,g.depth,0,re,X,null):t.texImage2D(z,Q,Z,ue,ce,0,re,X,null)}t.bindFramebuffer(s.FRAMEBUFFER,y),vt(g)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,B,z,me.__webglTexture,0,et(g)):(z===s.TEXTURE_2D||z>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&z<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,B,z,me.__webglTexture,Q),t.bindFramebuffer(s.FRAMEBUFFER,null)}function ft(y,g,L){if(s.bindRenderbuffer(s.RENDERBUFFER,y),g.depthBuffer){const B=g.depthTexture,z=B&&B.isDepthTexture?B.type:null,Q=w(g.stencilBuffer,z),re=g.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;vt(g)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,et(g),Q,g.width,g.height):L?s.renderbufferStorageMultisample(s.RENDERBUFFER,et(g),Q,g.width,g.height):s.renderbufferStorage(s.RENDERBUFFER,Q,g.width,g.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,re,s.RENDERBUFFER,y)}else{const B=g.textures;for(let z=0;z<B.length;z++){const Q=B[z],re=r.convert(Q.format,Q.colorSpace),X=r.convert(Q.type),Z=S(Q.internalFormat,re,X,Q.normalized,Q.colorSpace);vt(g)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,et(g),Z,g.width,g.height):L?s.renderbufferStorageMultisample(s.RENDERBUFFER,et(g),Z,g.width,g.height):s.renderbufferStorage(s.RENDERBUFFER,Z,g.width,g.height)}}s.bindRenderbuffer(s.RENDERBUFFER,null)}function Ge(y,g,L){const B=g.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(s.FRAMEBUFFER,y),!(g.depthTexture&&g.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const z=n.get(g.depthTexture);if(z.__renderTarget=g,(!z.__webglTexture||g.depthTexture.image.width!==g.width||g.depthTexture.image.height!==g.height)&&(g.depthTexture.image.width=g.width,g.depthTexture.image.height=g.height,g.depthTexture.needsUpdate=!0),B){if(z.__webglInit===void 0&&(z.__webglInit=!0,g.depthTexture.addEventListener("dispose",R)),z.__webglTexture===void 0){z.__webglTexture=s.createTexture(),t.bindTexture(s.TEXTURE_CUBE_MAP,z.__webglTexture),qe(s.TEXTURE_CUBE_MAP,g.depthTexture);const oe=r.convert(g.depthTexture.format),me=r.convert(g.depthTexture.type);let ue;g.depthTexture.format===jn?ue=s.DEPTH_COMPONENT24:g.depthTexture.format===Mi&&(ue=s.DEPTH24_STENCIL8);for(let ce=0;ce<6;ce++)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,ue,g.width,g.height,0,oe,me,null)}}else ee(g.depthTexture,0);const Q=z.__webglTexture,re=et(g),X=B?s.TEXTURE_CUBE_MAP_POSITIVE_X+L:s.TEXTURE_2D,Z=g.depthTexture.format===Mi?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;if(g.depthTexture.format===jn)vt(g)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,Z,X,Q,0,re):s.framebufferTexture2D(s.FRAMEBUFFER,Z,X,Q,0);else if(g.depthTexture.format===Mi)vt(g)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,Z,X,Q,0,re):s.framebufferTexture2D(s.FRAMEBUFFER,Z,X,Q,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function je(y){const g=n.get(y),L=y.isWebGLCubeRenderTarget===!0;if(g.__boundDepthTexture!==y.depthTexture){const B=y.depthTexture;if(g.__depthDisposeCallback&&g.__depthDisposeCallback(),B){const z=()=>{delete g.__boundDepthTexture,delete g.__depthDisposeCallback,B.removeEventListener("dispose",z)};B.addEventListener("dispose",z),g.__depthDisposeCallback=z}g.__boundDepthTexture=B}if(y.depthTexture&&!g.__autoAllocateDepthBuffer)if(L)for(let B=0;B<6;B++)Ge(g.__webglFramebuffer[B],y,B);else{const B=y.texture.mipmaps;B&&B.length>0?Ge(g.__webglFramebuffer[0],y,0):Ge(g.__webglFramebuffer,y,0)}else if(L){g.__webglDepthbuffer=[];for(let B=0;B<6;B++)if(t.bindFramebuffer(s.FRAMEBUFFER,g.__webglFramebuffer[B]),g.__webglDepthbuffer[B]===void 0)g.__webglDepthbuffer[B]=s.createRenderbuffer(),ft(g.__webglDepthbuffer[B],y,!1);else{const z=y.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,Q=g.__webglDepthbuffer[B];s.bindRenderbuffer(s.RENDERBUFFER,Q),s.framebufferRenderbuffer(s.FRAMEBUFFER,z,s.RENDERBUFFER,Q)}}else{const B=y.texture.mipmaps;if(B&&B.length>0?t.bindFramebuffer(s.FRAMEBUFFER,g.__webglFramebuffer[0]):t.bindFramebuffer(s.FRAMEBUFFER,g.__webglFramebuffer),g.__webglDepthbuffer===void 0)g.__webglDepthbuffer=s.createRenderbuffer(),ft(g.__webglDepthbuffer,y,!1);else{const z=y.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,Q=g.__webglDepthbuffer;s.bindRenderbuffer(s.RENDERBUFFER,Q),s.framebufferRenderbuffer(s.FRAMEBUFFER,z,s.RENDERBUFFER,Q)}}t.bindFramebuffer(s.FRAMEBUFFER,null)}function Le(y,g,L){const B=n.get(y);g!==void 0&&De(B.__webglFramebuffer,y,y.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),L!==void 0&&je(y)}function Ve(y){const g=y.texture,L=n.get(y),B=n.get(g);y.addEventListener("dispose",x);const z=y.textures,Q=y.isWebGLCubeRenderTarget===!0,re=z.length>1;if(re||(B.__webglTexture===void 0&&(B.__webglTexture=s.createTexture()),B.__version=g.version,a.memory.textures++),Q){L.__webglFramebuffer=[];for(let X=0;X<6;X++)if(g.mipmaps&&g.mipmaps.length>0){L.__webglFramebuffer[X]=[];for(let Z=0;Z<g.mipmaps.length;Z++)L.__webglFramebuffer[X][Z]=s.createFramebuffer()}else L.__webglFramebuffer[X]=s.createFramebuffer()}else{if(g.mipmaps&&g.mipmaps.length>0){L.__webglFramebuffer=[];for(let X=0;X<g.mipmaps.length;X++)L.__webglFramebuffer[X]=s.createFramebuffer()}else L.__webglFramebuffer=s.createFramebuffer();if(re)for(let X=0,Z=z.length;X<Z;X++){const oe=n.get(z[X]);oe.__webglTexture===void 0&&(oe.__webglTexture=s.createTexture(),a.memory.textures++)}if(y.samples>0&&vt(y)===!1){L.__webglMultisampledFramebuffer=s.createFramebuffer(),L.__webglColorRenderbuffer=[],t.bindFramebuffer(s.FRAMEBUFFER,L.__webglMultisampledFramebuffer);for(let X=0;X<z.length;X++){const Z=z[X];L.__webglColorRenderbuffer[X]=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,L.__webglColorRenderbuffer[X]);const oe=r.convert(Z.format,Z.colorSpace),me=r.convert(Z.type),ue=S(Z.internalFormat,oe,me,Z.normalized,Z.colorSpace,y.isXRRenderTarget===!0),ce=et(y);s.renderbufferStorageMultisample(s.RENDERBUFFER,ce,ue,y.width,y.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+X,s.RENDERBUFFER,L.__webglColorRenderbuffer[X])}s.bindRenderbuffer(s.RENDERBUFFER,null),y.depthBuffer&&(L.__webglDepthRenderbuffer=s.createRenderbuffer(),ft(L.__webglDepthRenderbuffer,y,!0)),t.bindFramebuffer(s.FRAMEBUFFER,null)}}if(Q){t.bindTexture(s.TEXTURE_CUBE_MAP,B.__webglTexture),qe(s.TEXTURE_CUBE_MAP,g);for(let X=0;X<6;X++)if(g.mipmaps&&g.mipmaps.length>0)for(let Z=0;Z<g.mipmaps.length;Z++)De(L.__webglFramebuffer[X][Z],y,g,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+X,Z);else De(L.__webglFramebuffer[X],y,g,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+X,0);p(g)&&b(s.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(re){for(let X=0,Z=z.length;X<Z;X++){const oe=z[X],me=n.get(oe);let ue=s.TEXTURE_2D;(y.isWebGL3DRenderTarget||y.isWebGLArrayRenderTarget)&&(ue=y.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture(ue,me.__webglTexture),qe(ue,oe),De(L.__webglFramebuffer,y,oe,s.COLOR_ATTACHMENT0+X,ue,0),p(oe)&&b(ue)}t.unbindTexture()}else{let X=s.TEXTURE_2D;if((y.isWebGL3DRenderTarget||y.isWebGLArrayRenderTarget)&&(X=y.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture(X,B.__webglTexture),qe(X,g),g.mipmaps&&g.mipmaps.length>0)for(let Z=0;Z<g.mipmaps.length;Z++)De(L.__webglFramebuffer[Z],y,g,s.COLOR_ATTACHMENT0,X,Z);else De(L.__webglFramebuffer,y,g,s.COLOR_ATTACHMENT0,X,0);p(g)&&b(X),t.unbindTexture()}y.depthBuffer&&je(y)}function nt(y){const g=y.textures;for(let L=0,B=g.length;L<B;L++){const z=g[L];if(p(z)){const Q=T(y),re=n.get(z).__webglTexture;t.bindTexture(Q,re),b(Q),t.unbindTexture()}}}const at=[],Et=[];function lt(y){if(y.samples>0){if(vt(y)===!1){const g=y.textures,L=y.width,B=y.height;let z=s.COLOR_BUFFER_BIT;const Q=y.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,re=n.get(y),X=g.length>1;if(X)for(let oe=0;oe<g.length;oe++)t.bindFramebuffer(s.FRAMEBUFFER,re.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+oe,s.RENDERBUFFER,null),t.bindFramebuffer(s.FRAMEBUFFER,re.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+oe,s.TEXTURE_2D,null,0);t.bindFramebuffer(s.READ_FRAMEBUFFER,re.__webglMultisampledFramebuffer);const Z=y.texture.mipmaps;Z&&Z.length>0?t.bindFramebuffer(s.DRAW_FRAMEBUFFER,re.__webglFramebuffer[0]):t.bindFramebuffer(s.DRAW_FRAMEBUFFER,re.__webglFramebuffer);for(let oe=0;oe<g.length;oe++){if(y.resolveDepthBuffer&&(y.depthBuffer&&(z|=s.DEPTH_BUFFER_BIT),y.stencilBuffer&&y.resolveStencilBuffer&&(z|=s.STENCIL_BUFFER_BIT)),X){s.framebufferRenderbuffer(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,re.__webglColorRenderbuffer[oe]);const me=n.get(g[oe]).__webglTexture;s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,me,0)}s.blitFramebuffer(0,0,L,B,0,0,L,B,z,s.NEAREST),l===!0&&(at.length=0,Et.length=0,at.push(s.COLOR_ATTACHMENT0+oe),y.depthBuffer&&y.resolveDepthBuffer===!1&&(at.push(Q),Et.push(Q),s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,Et)),s.invalidateFramebuffer(s.READ_FRAMEBUFFER,at))}if(t.bindFramebuffer(s.READ_FRAMEBUFFER,null),t.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),X)for(let oe=0;oe<g.length;oe++){t.bindFramebuffer(s.FRAMEBUFFER,re.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+oe,s.RENDERBUFFER,re.__webglColorRenderbuffer[oe]);const me=n.get(g[oe]).__webglTexture;t.bindFramebuffer(s.FRAMEBUFFER,re.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+oe,s.TEXTURE_2D,me,0)}t.bindFramebuffer(s.DRAW_FRAMEBUFFER,re.__webglMultisampledFramebuffer)}else if(y.depthBuffer&&y.resolveDepthBuffer===!1&&l){const g=y.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,[g])}}}function et(y){return Math.min(i.maxSamples,y.samples)}function vt(y){const g=n.get(y);return y.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&g.__useRenderToTexture!==!1}function U(y){const g=a.render.frame;u.get(y)!==g&&(u.set(y,g),y.update())}function G(y,g){const L=y.colorSpace,B=y.format,z=y.type;return y.isCompressedTexture===!0||y.isVideoTexture===!0||L!==ln&&L!==li&&(Qe.getTransfer(L)===ut?(B!==pn||z!==on)&&Ie("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):ze("WebGLTextures: Unsupported texture color space:",L)),g}function J(y){return typeof HTMLImageElement<"u"&&y instanceof HTMLImageElement?(c.width=y.naturalWidth||y.width,c.height=y.naturalHeight||y.height):typeof VideoFrame<"u"&&y instanceof VideoFrame?(c.width=y.displayWidth,c.height=y.displayHeight):(c.width=y.width,c.height=y.height),c}this.allocateTextureUnit=q,this.resetTextureUnits=$,this.getTextureUnits=j,this.setTextureUnits=k,this.setTexture2D=ee,this.setTexture2DArray=K,this.setTexture3D=le,this.setTextureCube=pe,this.rebindTextures=Le,this.setupRenderTarget=Ve,this.updateRenderTargetMipmap=nt,this.updateMultisampleRenderTarget=lt,this.setupDepthRenderbuffer=je,this.setupFrameBufferTexture=De,this.useMultisampledRTT=vt,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function mx(s,e){function t(n,i=li){let r;const a=Qe.getTransfer(i);if(n===on)return s.UNSIGNED_BYTE;if(n===Fo)return s.UNSIGNED_SHORT_4_4_4_4;if(n===Oo)return s.UNSIGNED_SHORT_5_5_5_1;if(n===ou)return s.UNSIGNED_INT_5_9_9_9_REV;if(n===lu)return s.UNSIGNED_INT_10F_11F_11F_REV;if(n===ru)return s.BYTE;if(n===au)return s.SHORT;if(n===Ds)return s.UNSIGNED_SHORT;if(n===Uo)return s.INT;if(n===Nn)return s.UNSIGNED_INT;if(n===fn)return s.FLOAT;if(n===$n)return s.HALF_FLOAT;if(n===cu)return s.ALPHA;if(n===uu)return s.RGB;if(n===pn)return s.RGBA;if(n===jn)return s.DEPTH_COMPONENT;if(n===Mi)return s.DEPTH_STENCIL;if(n===Bo)return s.RED;if(n===ko)return s.RED_INTEGER;if(n===Ei)return s.RG;if(n===zo)return s.RG_INTEGER;if(n===Vo)return s.RGBA_INTEGER;if(n===br||n===Er||n===Tr||n===Ar)if(a===ut)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===br)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Er)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Tr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Ar)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===br)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Er)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Tr)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Ar)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Wa||n===Xa||n===Ya||n===qa)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===Wa)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Xa)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Ya)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===qa)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Ka||n===Za||n===$a||n===ja||n===Ja||n===Cr||n===Qa)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Ka||n===Za)return a===ut?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===$a)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===ja)return r.COMPRESSED_R11_EAC;if(n===Ja)return r.COMPRESSED_SIGNED_R11_EAC;if(n===Cr)return r.COMPRESSED_RG11_EAC;if(n===Qa)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===eo||n===to||n===no||n===io||n===so||n===ro||n===ao||n===oo||n===lo||n===co||n===uo||n===ho||n===fo||n===po)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===eo)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===to)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===no)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===io)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===so)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===ro)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===ao)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===oo)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===lo)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===co)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===uo)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===ho)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===fo)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===po)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===mo||n===go||n===_o)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===mo)return a===ut?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===go)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===_o)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===xo||n===vo||n===Pr||n===Mo)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===xo)return r.COMPRESSED_RED_RGTC1_EXT;if(n===vo)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Pr)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Mo)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Ns?s.UNSIGNED_INT_24_8:s[n]!==void 0?s[n]:null}return{convert:t}}const gx=`
4084
+ }`,hx=[new C(1,0,0),new C(-1,0,0),new C(0,1,0),new C(0,-1,0),new C(0,0,1),new C(0,0,-1)],dx=[new C(0,-1,0),new C(0,-1,0),new C(0,0,1),new C(0,0,-1),new C(0,-1,0),new C(0,-1,0)],Dc=new We,Ts=new C,Aa=new C;function fx(s,e,t){let n=new $o;const i=new ke,r=new ke,a=new gt,o=new Xd,l=new Yd,c={},u=t.maxTextureSize,h={[Dn]:tn,[tn]:Dn,[an]:an},d=new Un({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ke},radius:{value:4}},vertexShader:cx,fragmentShader:ux}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const _=new Wt;_.setAttribute("position",new Nt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new bt(_,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Sr;let p=this.type;this.render=function(E,R,x){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||E.length===0)return;this.type===uh&&(Ie("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=Sr);const A=s.getRenderTarget(),D=s.getActiveCubeFace(),P=s.getActiveMipmapLevel(),F=s.state;F.setBlending(Kn),F.buffers.depth.getReversed()===!0?F.buffers.color.setClear(0,0,0,0):F.buffers.color.setClear(1,1,1,1),F.buffers.depth.setTest(!0),F.setScissorTest(!1);const $=p!==this.type;$&&R.traverse(function(j){j.material&&(Array.isArray(j.material)?j.material.forEach(k=>k.needsUpdate=!0):j.material.needsUpdate=!0)});for(let j=0,k=E.length;j<k;j++){const q=E[j],W=q.shadow;if(W===void 0){Ie("WebGLShadowMap:",q,"has no shadow.");continue}if(W.autoUpdate===!1&&W.needsUpdate===!1)continue;i.copy(W.mapSize);const ee=W.getFrameExtents();i.multiply(ee),r.copy(W.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(r.x=Math.floor(u/ee.x),i.x=r.x*ee.x,W.mapSize.x=r.x),i.y>u&&(r.y=Math.floor(u/ee.y),i.y=r.y*ee.y,W.mapSize.y=r.y));const K=s.state.buffers.depth.getReversed();if(W.camera._reversedDepth=K,W.map===null||$===!0){if(W.map!==null&&(W.map.depthTexture!==null&&(W.map.depthTexture.dispose(),W.map.depthTexture=null),W.map.dispose()),this.type===ws){if(q.isPointLight){Ie("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}W.map=new Ln(i.x,i.y,{format:Ei,type:$n,minFilter:Bt,magFilter:Bt,generateMipmaps:!1}),W.map.texture.name=q.name+".shadowMap",W.map.depthTexture=new ns(i.x,i.y,fn),W.map.depthTexture.name=q.name+".shadowMapDepth",W.map.depthTexture.format=jn,W.map.depthTexture.compareFunction=null,W.map.depthTexture.minFilter=Ot,W.map.depthTexture.magFilter=Ot}else q.isPointLight?(W.map=new wu(i.x),W.map.depthTexture=new kd(i.x,Nn)):(W.map=new Ln(i.x,i.y),W.map.depthTexture=new ns(i.x,i.y,Nn)),W.map.depthTexture.name=q.name+".shadowMap",W.map.depthTexture.format=jn,this.type===Sr?(W.map.depthTexture.compareFunction=K?Go:Ho,W.map.depthTexture.minFilter=Bt,W.map.depthTexture.magFilter=Bt):(W.map.depthTexture.compareFunction=null,W.map.depthTexture.minFilter=Ot,W.map.depthTexture.magFilter=Ot);W.camera.updateProjectionMatrix()}const le=W.map.isWebGLCubeRenderTarget?6:1;for(let pe=0;pe<le;pe++){if(W.map.isWebGLCubeRenderTarget)s.setRenderTarget(W.map,pe),s.clear();else{pe===0&&(s.setRenderTarget(W.map),s.clear());const Me=W.getViewport(pe);a.set(r.x*Me.x,r.y*Me.y,r.x*Me.z,r.y*Me.w),F.viewport(a)}if(q.isPointLight){const Me=W.camera,Ye=W.matrix,rt=q.distance||Me.far;rt!==Me.far&&(Me.far=rt,Me.updateProjectionMatrix()),Ts.setFromMatrixPosition(q.matrixWorld),Me.position.copy(Ts),Aa.copy(Me.position),Aa.add(hx[pe]),Me.up.copy(dx[pe]),Me.lookAt(Aa),Me.updateMatrixWorld(),Ye.makeTranslation(-Ts.x,-Ts.y,-Ts.z),Dc.multiplyMatrices(Me.projectionMatrix,Me.matrixWorldInverse),W._frustum.setFromProjectionMatrix(Dc,Me.coordinateSystem,Me.reversedDepth)}else W.updateMatrices(q);n=W.getFrustum(),S(R,x,W.camera,q,this.type)}W.isPointLightShadow!==!0&&this.type===ws&&b(W,x),W.needsUpdate=!1}p=this.type,m.needsUpdate=!1,s.setRenderTarget(A,D,P)};function b(E,R){const x=e.update(v);d.defines.VSM_SAMPLES!==E.blurSamples&&(d.defines.VSM_SAMPLES=E.blurSamples,f.defines.VSM_SAMPLES=E.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),E.mapPass===null&&(E.mapPass=new Ln(i.x,i.y,{format:Ei,type:$n})),d.uniforms.shadow_pass.value=E.map.depthTexture,d.uniforms.resolution.value=E.mapSize,d.uniforms.radius.value=E.radius,s.setRenderTarget(E.mapPass),s.clear(),s.renderBufferDirect(R,null,x,d,v,null),f.uniforms.shadow_pass.value=E.mapPass.texture,f.uniforms.resolution.value=E.mapSize,f.uniforms.radius.value=E.radius,s.setRenderTarget(E.map),s.clear(),s.renderBufferDirect(R,null,x,f,v,null)}function T(E,R,x,A){let D=null;const P=x.isPointLight===!0?E.customDistanceMaterial:E.customDepthMaterial;if(P!==void 0)D=P;else if(D=x.isPointLight===!0?l:o,s.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0||R.alphaToCoverage===!0){const F=D.uuid,$=R.uuid;let j=c[F];j===void 0&&(j={},c[F]=j);let k=j[$];k===void 0&&(k=D.clone(),j[$]=k,R.addEventListener("dispose",w)),D=k}if(D.visible=R.visible,D.wireframe=R.wireframe,A===ws?D.side=R.shadowSide!==null?R.shadowSide:R.side:D.side=R.shadowSide!==null?R.shadowSide:h[R.side],D.alphaMap=R.alphaMap,D.alphaTest=R.alphaToCoverage===!0?.5:R.alphaTest,D.map=R.map,D.clipShadows=R.clipShadows,D.clippingPlanes=R.clippingPlanes,D.clipIntersection=R.clipIntersection,D.displacementMap=R.displacementMap,D.displacementScale=R.displacementScale,D.displacementBias=R.displacementBias,D.wireframeLinewidth=R.wireframeLinewidth,D.linewidth=R.linewidth,x.isPointLight===!0&&D.isMeshDistanceMaterial===!0){const F=s.properties.get(D);F.light=x}return D}function S(E,R,x,A,D){if(E.visible===!1)return;if(E.layers.test(R.layers)&&(E.isMesh||E.isLine||E.isPoints)&&(E.castShadow||E.receiveShadow&&D===ws)&&(!E.frustumCulled||n.intersectsObject(E))){E.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,E.matrixWorld);const $=e.update(E),j=E.material;if(Array.isArray(j)){const k=$.groups;for(let q=0,W=k.length;q<W;q++){const ee=k[q],K=j[ee.materialIndex];if(K&&K.visible){const le=T(E,K,A,D);E.onBeforeShadow(s,E,R,x,$,le,ee),s.renderBufferDirect(x,null,$,le,E,ee),E.onAfterShadow(s,E,R,x,$,le,ee)}}}else if(j.visible){const k=T(E,j,A,D);E.onBeforeShadow(s,E,R,x,$,k,null),s.renderBufferDirect(x,null,$,k,E,null),E.onAfterShadow(s,E,R,x,$,k,null)}}const F=E.children;for(let $=0,j=F.length;$<j;$++)S(F[$],R,x,A,D)}function w(E){E.target.removeEventListener("dispose",w);for(const x in c){const A=c[x],D=E.target.uuid;D in A&&(A[D].dispose(),delete A[D])}}}function px(s,e){function t(){let I=!1;const fe=new gt;let te=null;const de=new gt(0,0,0,0);return{setMask:function(ge){te!==ge&&!I&&(s.colorMask(ge,ge,ge,ge),te=ge)},setLocked:function(ge){I=ge},setClear:function(ge,se,be,Ae,St){St===!0&&(ge*=Ae,se*=Ae,be*=Ae),fe.set(ge,se,be,Ae),de.equals(fe)===!1&&(s.clearColor(ge,se,be,Ae),de.copy(fe))},reset:function(){I=!1,te=null,de.set(-1,0,0,0)}}}function n(){let I=!1,fe=!1,te=null,de=null,ge=null;return{setReversed:function(se){if(fe!==se){const be=e.get("EXT_clip_control");se?be.clipControlEXT(be.LOWER_LEFT_EXT,be.ZERO_TO_ONE_EXT):be.clipControlEXT(be.LOWER_LEFT_EXT,be.NEGATIVE_ONE_TO_ONE_EXT),fe=se;const Ae=ge;ge=null,this.setClear(Ae)}},getReversed:function(){return fe},setTest:function(se){se?ae(s.DEPTH_TEST):Be(s.DEPTH_TEST)},setMask:function(se){te!==se&&!I&&(s.depthMask(se),te=se)},setFunc:function(se){if(fe&&(se=Yh[se]),de!==se){switch(se){case Oa:s.depthFunc(s.NEVER);break;case Ba:s.depthFunc(s.ALWAYS);break;case ka:s.depthFunc(s.LESS);break;case Ji:s.depthFunc(s.LEQUAL);break;case za:s.depthFunc(s.EQUAL);break;case Va:s.depthFunc(s.GEQUAL);break;case Ha:s.depthFunc(s.GREATER);break;case Ga:s.depthFunc(s.NOTEQUAL);break;default:s.depthFunc(s.LEQUAL)}de=se}},setLocked:function(se){I=se},setClear:function(se){ge!==se&&(ge=se,fe&&(se=1-se),s.clearDepth(se))},reset:function(){I=!1,te=null,de=null,ge=null,fe=!1}}}function i(){let I=!1,fe=null,te=null,de=null,ge=null,se=null,be=null,Ae=null,St=null;return{setTest:function(ct){I||(ct?ae(s.STENCIL_TEST):Be(s.STENCIL_TEST))},setMask:function(ct){fe!==ct&&!I&&(s.stencilMask(ct),fe=ct)},setFunc:function(ct,cn,qt){(te!==ct||de!==cn||ge!==qt)&&(s.stencilFunc(ct,cn,qt),te=ct,de=cn,ge=qt)},setOp:function(ct,cn,qt){(se!==ct||be!==cn||Ae!==qt)&&(s.stencilOp(ct,cn,qt),se=ct,be=cn,Ae=qt)},setLocked:function(ct){I=ct},setClear:function(ct){St!==ct&&(s.clearStencil(ct),St=ct)},reset:function(){I=!1,fe=null,te=null,de=null,ge=null,se=null,be=null,Ae=null,St=null}}}const r=new t,a=new n,o=new i,l=new WeakMap,c=new WeakMap;let u={},h={},d={},f=new WeakMap,_=[],v=null,m=!1,p=null,b=null,T=null,S=null,w=null,E=null,R=null,x=new Ue(0,0,0),A=0,D=!1,P=null,F=null,$=null,j=null,k=null;const q=s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let W=!1,ee=0;const K=s.getParameter(s.VERSION);K.indexOf("WebGL")!==-1?(ee=parseFloat(/^WebGL (\d)/.exec(K)[1]),W=ee>=1):K.indexOf("OpenGL ES")!==-1&&(ee=parseFloat(/^OpenGL ES (\d)/.exec(K)[1]),W=ee>=2);let le=null,pe={};const Me=s.getParameter(s.SCISSOR_BOX),Ye=s.getParameter(s.VIEWPORT),rt=new gt().fromArray(Me),qe=new gt().fromArray(Ye);function ne(I,fe,te,de){const ge=new Uint8Array(4),se=s.createTexture();s.bindTexture(I,se),s.texParameteri(I,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(I,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let be=0;be<te;be++)I===s.TEXTURE_3D||I===s.TEXTURE_2D_ARRAY?s.texImage3D(fe,0,s.RGBA,1,1,de,0,s.RGBA,s.UNSIGNED_BYTE,ge):s.texImage2D(fe+be,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,ge);return se}const he={};he[s.TEXTURE_2D]=ne(s.TEXTURE_2D,s.TEXTURE_2D,1),he[s.TEXTURE_CUBE_MAP]=ne(s.TEXTURE_CUBE_MAP,s.TEXTURE_CUBE_MAP_POSITIVE_X,6),he[s.TEXTURE_2D_ARRAY]=ne(s.TEXTURE_2D_ARRAY,s.TEXTURE_2D_ARRAY,1,1),he[s.TEXTURE_3D]=ne(s.TEXTURE_3D,s.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),ae(s.DEPTH_TEST),a.setFunc(Ji),nt(!1),at(fl),ae(s.CULL_FACE),Le(Kn);function ae(I){u[I]!==!0&&(s.enable(I),u[I]=!0)}function Be(I){u[I]!==!1&&(s.disable(I),u[I]=!1)}function Oe(I,fe){return d[I]!==fe?(s.bindFramebuffer(I,fe),d[I]=fe,I===s.DRAW_FRAMEBUFFER&&(d[s.FRAMEBUFFER]=fe),I===s.FRAMEBUFFER&&(d[s.DRAW_FRAMEBUFFER]=fe),!0):!1}function De(I,fe){let te=_,de=!1;if(I){te=f.get(fe),te===void 0&&(te=[],f.set(fe,te));const ge=I.textures;if(te.length!==ge.length||te[0]!==s.COLOR_ATTACHMENT0){for(let se=0,be=ge.length;se<be;se++)te[se]=s.COLOR_ATTACHMENT0+se;te.length=ge.length,de=!0}}else te[0]!==s.BACK&&(te[0]=s.BACK,de=!0);de&&s.drawBuffers(te)}function ft(I){return v!==I?(s.useProgram(I),v=I,!0):!1}const Ge={[xi]:s.FUNC_ADD,[dh]:s.FUNC_SUBTRACT,[fh]:s.FUNC_REVERSE_SUBTRACT};Ge[ph]=s.MIN,Ge[mh]=s.MAX;const je={[gh]:s.ZERO,[_h]:s.ONE,[xh]:s.SRC_COLOR,[Ua]:s.SRC_ALPHA,[Eh]:s.SRC_ALPHA_SATURATE,[yh]:s.DST_COLOR,[Mh]:s.DST_ALPHA,[vh]:s.ONE_MINUS_SRC_COLOR,[Fa]:s.ONE_MINUS_SRC_ALPHA,[bh]:s.ONE_MINUS_DST_COLOR,[Sh]:s.ONE_MINUS_DST_ALPHA,[Th]:s.CONSTANT_COLOR,[Ah]:s.ONE_MINUS_CONSTANT_COLOR,[wh]:s.CONSTANT_ALPHA,[Rh]:s.ONE_MINUS_CONSTANT_ALPHA};function Le(I,fe,te,de,ge,se,be,Ae,St,ct){if(I===Kn){m===!0&&(Be(s.BLEND),m=!1);return}if(m===!1&&(ae(s.BLEND),m=!0),I!==hh){if(I!==p||ct!==D){if((b!==xi||w!==xi)&&(s.blendEquation(s.FUNC_ADD),b=xi,w=xi),ct)switch(I){case qi:s.blendFuncSeparate(s.ONE,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case pl:s.blendFunc(s.ONE,s.ONE);break;case ml:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case gl:s.blendFuncSeparate(s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ZERO,s.ONE);break;default:ze("WebGLState: Invalid blending: ",I);break}else switch(I){case qi:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case pl:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE,s.ONE,s.ONE);break;case ml:ze("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case gl:ze("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:ze("WebGLState: Invalid blending: ",I);break}T=null,S=null,E=null,R=null,x.set(0,0,0),A=0,p=I,D=ct}return}ge=ge||fe,se=se||te,be=be||de,(fe!==b||ge!==w)&&(s.blendEquationSeparate(Ge[fe],Ge[ge]),b=fe,w=ge),(te!==T||de!==S||se!==E||be!==R)&&(s.blendFuncSeparate(je[te],je[de],je[se],je[be]),T=te,S=de,E=se,R=be),(Ae.equals(x)===!1||St!==A)&&(s.blendColor(Ae.r,Ae.g,Ae.b,St),x.copy(Ae),A=St),p=I,D=!1}function Ve(I,fe){I.side===an?Be(s.CULL_FACE):ae(s.CULL_FACE);let te=I.side===tn;fe&&(te=!te),nt(te),I.blending===qi&&I.transparent===!1?Le(Kn):Le(I.blending,I.blendEquation,I.blendSrc,I.blendDst,I.blendEquationAlpha,I.blendSrcAlpha,I.blendDstAlpha,I.blendColor,I.blendAlpha,I.premultipliedAlpha),a.setFunc(I.depthFunc),a.setTest(I.depthTest),a.setMask(I.depthWrite),r.setMask(I.colorWrite);const de=I.stencilWrite;o.setTest(de),de&&(o.setMask(I.stencilWriteMask),o.setFunc(I.stencilFunc,I.stencilRef,I.stencilFuncMask),o.setOp(I.stencilFail,I.stencilZFail,I.stencilZPass)),lt(I.polygonOffset,I.polygonOffsetFactor,I.polygonOffsetUnits),I.alphaToCoverage===!0?ae(s.SAMPLE_ALPHA_TO_COVERAGE):Be(s.SAMPLE_ALPHA_TO_COVERAGE)}function nt(I){P!==I&&(I?s.frontFace(s.CW):s.frontFace(s.CCW),P=I)}function at(I){I!==lh?(ae(s.CULL_FACE),I!==F&&(I===fl?s.cullFace(s.BACK):I===ch?s.cullFace(s.FRONT):s.cullFace(s.FRONT_AND_BACK))):Be(s.CULL_FACE),F=I}function Et(I){I!==$&&(W&&s.lineWidth(I),$=I)}function lt(I,fe,te){I?(ae(s.POLYGON_OFFSET_FILL),(j!==fe||k!==te)&&(j=fe,k=te,a.getReversed()&&(fe=-fe),s.polygonOffset(fe,te))):Be(s.POLYGON_OFFSET_FILL)}function et(I){I?ae(s.SCISSOR_TEST):Be(s.SCISSOR_TEST)}function vt(I){I===void 0&&(I=s.TEXTURE0+q-1),le!==I&&(s.activeTexture(I),le=I)}function U(I,fe,te){te===void 0&&(le===null?te=s.TEXTURE0+q-1:te=le);let de=pe[te];de===void 0&&(de={type:void 0,texture:void 0},pe[te]=de),(de.type!==I||de.texture!==fe)&&(le!==te&&(s.activeTexture(te),le=te),s.bindTexture(I,fe||he[I]),de.type=I,de.texture=fe)}function G(){const I=pe[le];I!==void 0&&I.type!==void 0&&(s.bindTexture(I.type,null),I.type=void 0,I.texture=void 0)}function J(){try{s.compressedTexImage2D(...arguments)}catch(I){ze("WebGLState:",I)}}function y(){try{s.compressedTexImage3D(...arguments)}catch(I){ze("WebGLState:",I)}}function g(){try{s.texSubImage2D(...arguments)}catch(I){ze("WebGLState:",I)}}function L(){try{s.texSubImage3D(...arguments)}catch(I){ze("WebGLState:",I)}}function B(){try{s.compressedTexSubImage2D(...arguments)}catch(I){ze("WebGLState:",I)}}function z(){try{s.compressedTexSubImage3D(...arguments)}catch(I){ze("WebGLState:",I)}}function Q(){try{s.texStorage2D(...arguments)}catch(I){ze("WebGLState:",I)}}function re(){try{s.texStorage3D(...arguments)}catch(I){ze("WebGLState:",I)}}function X(){try{s.texImage2D(...arguments)}catch(I){ze("WebGLState:",I)}}function Z(){try{s.texImage3D(...arguments)}catch(I){ze("WebGLState:",I)}}function oe(I){return h[I]!==void 0?h[I]:s.getParameter(I)}function me(I,fe){h[I]!==fe&&(s.pixelStorei(I,fe),h[I]=fe)}function ue(I){rt.equals(I)===!1&&(s.scissor(I.x,I.y,I.z,I.w),rt.copy(I))}function ce(I){qe.equals(I)===!1&&(s.viewport(I.x,I.y,I.z,I.w),qe.copy(I))}function Ee(I,fe){let te=c.get(fe);te===void 0&&(te=new WeakMap,c.set(fe,te));let de=te.get(I);de===void 0&&(de=s.getUniformBlockIndex(fe,I.name),te.set(I,de))}function Te(I,fe){const de=c.get(fe).get(I);l.get(fe)!==de&&(s.uniformBlockBinding(fe,de,I.__bindingPointIndex),l.set(fe,de))}function Re(){s.disable(s.BLEND),s.disable(s.CULL_FACE),s.disable(s.DEPTH_TEST),s.disable(s.POLYGON_OFFSET_FILL),s.disable(s.SCISSOR_TEST),s.disable(s.STENCIL_TEST),s.disable(s.SAMPLE_ALPHA_TO_COVERAGE),s.blendEquation(s.FUNC_ADD),s.blendFunc(s.ONE,s.ZERO),s.blendFuncSeparate(s.ONE,s.ZERO,s.ONE,s.ZERO),s.blendColor(0,0,0,0),s.colorMask(!0,!0,!0,!0),s.clearColor(0,0,0,0),s.depthMask(!0),s.depthFunc(s.LESS),a.setReversed(!1),s.clearDepth(1),s.stencilMask(4294967295),s.stencilFunc(s.ALWAYS,0,4294967295),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),s.clearStencil(0),s.cullFace(s.BACK),s.frontFace(s.CCW),s.polygonOffset(0,0),s.activeTexture(s.TEXTURE0),s.bindFramebuffer(s.FRAMEBUFFER,null),s.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),s.bindFramebuffer(s.READ_FRAMEBUFFER,null),s.useProgram(null),s.lineWidth(1),s.scissor(0,0,s.canvas.width,s.canvas.height),s.viewport(0,0,s.canvas.width,s.canvas.height),s.pixelStorei(s.PACK_ALIGNMENT,4),s.pixelStorei(s.UNPACK_ALIGNMENT,4),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,!1),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,s.BROWSER_DEFAULT_WEBGL),s.pixelStorei(s.PACK_ROW_LENGTH,0),s.pixelStorei(s.PACK_SKIP_PIXELS,0),s.pixelStorei(s.PACK_SKIP_ROWS,0),s.pixelStorei(s.UNPACK_ROW_LENGTH,0),s.pixelStorei(s.UNPACK_IMAGE_HEIGHT,0),s.pixelStorei(s.UNPACK_SKIP_PIXELS,0),s.pixelStorei(s.UNPACK_SKIP_ROWS,0),s.pixelStorei(s.UNPACK_SKIP_IMAGES,0),u={},h={},le=null,pe={},d={},f=new WeakMap,_=[],v=null,m=!1,p=null,b=null,T=null,S=null,w=null,E=null,R=null,x=new Ue(0,0,0),A=0,D=!1,P=null,F=null,$=null,j=null,k=null,rt.set(0,0,s.canvas.width,s.canvas.height),qe.set(0,0,s.canvas.width,s.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:ae,disable:Be,bindFramebuffer:Oe,drawBuffers:De,useProgram:ft,setBlending:Le,setMaterial:Ve,setFlipSided:nt,setCullFace:at,setLineWidth:Et,setPolygonOffset:lt,setScissorTest:et,activeTexture:vt,bindTexture:U,unbindTexture:G,compressedTexImage2D:J,compressedTexImage3D:y,texImage2D:X,texImage3D:Z,pixelStorei:me,getParameter:oe,updateUBOMapping:Ee,uniformBlockBinding:Te,texStorage2D:Q,texStorage3D:re,texSubImage2D:g,texSubImage3D:L,compressedTexSubImage2D:B,compressedTexSubImage3D:z,scissor:ue,viewport:ce,reset:Re}}function mx(s,e,t,n,i,r,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new ke,u=new WeakMap,h=new Set;let d;const f=new WeakMap;let _=!1;try{_=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(y,g){return _?new OffscreenCanvas(y,g):Bs("canvas")}function m(y,g,L){let B=1;const z=J(y);if((z.width>L||z.height>L)&&(B=L/Math.max(z.width,z.height)),B<1)if(typeof HTMLImageElement<"u"&&y instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&y instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&y instanceof ImageBitmap||typeof VideoFrame<"u"&&y instanceof VideoFrame){const Q=Math.floor(B*z.width),re=Math.floor(B*z.height);d===void 0&&(d=v(Q,re));const X=g?v(Q,re):d;return X.width=Q,X.height=re,X.getContext("2d").drawImage(y,0,0,Q,re),Ie("WebGLRenderer: Texture has been resized from ("+z.width+"x"+z.height+") to ("+Q+"x"+re+")."),X}else return"data"in y&&Ie("WebGLRenderer: Image in DataTexture is too big ("+z.width+"x"+z.height+")."),y;return y}function p(y){return y.generateMipmaps}function b(y){s.generateMipmap(y)}function T(y){return y.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:y.isWebGL3DRenderTarget?s.TEXTURE_3D:y.isWebGLArrayRenderTarget||y.isCompressedArrayTexture?s.TEXTURE_2D_ARRAY:s.TEXTURE_2D}function S(y,g,L,B,z,Q=!1){if(y!==null){if(s[y]!==void 0)return s[y];Ie("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+y+"'")}let re;B&&(re=e.get("EXT_texture_norm16"),re||Ie("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let X=g;if(g===s.RED&&(L===s.FLOAT&&(X=s.R32F),L===s.HALF_FLOAT&&(X=s.R16F),L===s.UNSIGNED_BYTE&&(X=s.R8),L===s.UNSIGNED_SHORT&&re&&(X=re.R16_EXT),L===s.SHORT&&re&&(X=re.R16_SNORM_EXT)),g===s.RED_INTEGER&&(L===s.UNSIGNED_BYTE&&(X=s.R8UI),L===s.UNSIGNED_SHORT&&(X=s.R16UI),L===s.UNSIGNED_INT&&(X=s.R32UI),L===s.BYTE&&(X=s.R8I),L===s.SHORT&&(X=s.R16I),L===s.INT&&(X=s.R32I)),g===s.RG&&(L===s.FLOAT&&(X=s.RG32F),L===s.HALF_FLOAT&&(X=s.RG16F),L===s.UNSIGNED_BYTE&&(X=s.RG8),L===s.UNSIGNED_SHORT&&re&&(X=re.RG16_EXT),L===s.SHORT&&re&&(X=re.RG16_SNORM_EXT)),g===s.RG_INTEGER&&(L===s.UNSIGNED_BYTE&&(X=s.RG8UI),L===s.UNSIGNED_SHORT&&(X=s.RG16UI),L===s.UNSIGNED_INT&&(X=s.RG32UI),L===s.BYTE&&(X=s.RG8I),L===s.SHORT&&(X=s.RG16I),L===s.INT&&(X=s.RG32I)),g===s.RGB_INTEGER&&(L===s.UNSIGNED_BYTE&&(X=s.RGB8UI),L===s.UNSIGNED_SHORT&&(X=s.RGB16UI),L===s.UNSIGNED_INT&&(X=s.RGB32UI),L===s.BYTE&&(X=s.RGB8I),L===s.SHORT&&(X=s.RGB16I),L===s.INT&&(X=s.RGB32I)),g===s.RGBA_INTEGER&&(L===s.UNSIGNED_BYTE&&(X=s.RGBA8UI),L===s.UNSIGNED_SHORT&&(X=s.RGBA16UI),L===s.UNSIGNED_INT&&(X=s.RGBA32UI),L===s.BYTE&&(X=s.RGBA8I),L===s.SHORT&&(X=s.RGBA16I),L===s.INT&&(X=s.RGBA32I)),g===s.RGB&&(L===s.UNSIGNED_SHORT&&re&&(X=re.RGB16_EXT),L===s.SHORT&&re&&(X=re.RGB16_SNORM_EXT),L===s.UNSIGNED_INT_5_9_9_9_REV&&(X=s.RGB9_E5),L===s.UNSIGNED_INT_10F_11F_11F_REV&&(X=s.R11F_G11F_B10F)),g===s.RGBA){const Z=Q?Lr:Qe.getTransfer(z);L===s.FLOAT&&(X=s.RGBA32F),L===s.HALF_FLOAT&&(X=s.RGBA16F),L===s.UNSIGNED_BYTE&&(X=Z===ut?s.SRGB8_ALPHA8:s.RGBA8),L===s.UNSIGNED_SHORT&&re&&(X=re.RGBA16_EXT),L===s.SHORT&&re&&(X=re.RGBA16_SNORM_EXT),L===s.UNSIGNED_SHORT_4_4_4_4&&(X=s.RGBA4),L===s.UNSIGNED_SHORT_5_5_5_1&&(X=s.RGB5_A1)}return(X===s.R16F||X===s.R32F||X===s.RG16F||X===s.RG32F||X===s.RGBA16F||X===s.RGBA32F)&&e.get("EXT_color_buffer_float"),X}function w(y,g){let L;return y?g===null||g===Nn||g===Ns?L=s.DEPTH24_STENCIL8:g===fn?L=s.DEPTH32F_STENCIL8:g===Ds&&(L=s.DEPTH24_STENCIL8,Ie("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):g===null||g===Nn||g===Ns?L=s.DEPTH_COMPONENT24:g===fn?L=s.DEPTH_COMPONENT32F:g===Ds&&(L=s.DEPTH_COMPONENT16),L}function E(y,g){return p(y)===!0||y.isFramebufferTexture&&y.minFilter!==Ot&&y.minFilter!==Bt?Math.log2(Math.max(g.width,g.height))+1:y.mipmaps!==void 0&&y.mipmaps.length>0?y.mipmaps.length:y.isCompressedTexture&&Array.isArray(y.image)?g.mipmaps.length:1}function R(y){const g=y.target;g.removeEventListener("dispose",R),A(g),g.isVideoTexture&&u.delete(g),g.isHTMLTexture&&h.delete(g)}function x(y){const g=y.target;g.removeEventListener("dispose",x),P(g)}function A(y){const g=n.get(y);if(g.__webglInit===void 0)return;const L=y.source,B=f.get(L);if(B){const z=B[g.__cacheKey];z.usedTimes--,z.usedTimes===0&&D(y),Object.keys(B).length===0&&f.delete(L)}n.remove(y)}function D(y){const g=n.get(y);s.deleteTexture(g.__webglTexture);const L=y.source,B=f.get(L);delete B[g.__cacheKey],a.memory.textures--}function P(y){const g=n.get(y);if(y.depthTexture&&(y.depthTexture.dispose(),n.remove(y.depthTexture)),y.isWebGLCubeRenderTarget)for(let B=0;B<6;B++){if(Array.isArray(g.__webglFramebuffer[B]))for(let z=0;z<g.__webglFramebuffer[B].length;z++)s.deleteFramebuffer(g.__webglFramebuffer[B][z]);else s.deleteFramebuffer(g.__webglFramebuffer[B]);g.__webglDepthbuffer&&s.deleteRenderbuffer(g.__webglDepthbuffer[B])}else{if(Array.isArray(g.__webglFramebuffer))for(let B=0;B<g.__webglFramebuffer.length;B++)s.deleteFramebuffer(g.__webglFramebuffer[B]);else s.deleteFramebuffer(g.__webglFramebuffer);if(g.__webglDepthbuffer&&s.deleteRenderbuffer(g.__webglDepthbuffer),g.__webglMultisampledFramebuffer&&s.deleteFramebuffer(g.__webglMultisampledFramebuffer),g.__webglColorRenderbuffer)for(let B=0;B<g.__webglColorRenderbuffer.length;B++)g.__webglColorRenderbuffer[B]&&s.deleteRenderbuffer(g.__webglColorRenderbuffer[B]);g.__webglDepthRenderbuffer&&s.deleteRenderbuffer(g.__webglDepthRenderbuffer)}const L=y.textures;for(let B=0,z=L.length;B<z;B++){const Q=n.get(L[B]);Q.__webglTexture&&(s.deleteTexture(Q.__webglTexture),a.memory.textures--),n.remove(L[B])}n.remove(y)}let F=0;function $(){F=0}function j(){return F}function k(y){F=y}function q(){const y=F;return y>=i.maxTextures&&Ie("WebGLTextures: Trying to use "+y+" texture units while this GPU supports only "+i.maxTextures),F+=1,y}function W(y){const g=[];return g.push(y.wrapS),g.push(y.wrapT),g.push(y.wrapR||0),g.push(y.magFilter),g.push(y.minFilter),g.push(y.anisotropy),g.push(y.internalFormat),g.push(y.format),g.push(y.type),g.push(y.generateMipmaps),g.push(y.premultiplyAlpha),g.push(y.flipY),g.push(y.unpackAlignment),g.push(y.colorSpace),g.join()}function ee(y,g){const L=n.get(y);if(y.isVideoTexture&&U(y),y.isRenderTargetTexture===!1&&y.isExternalTexture!==!0&&y.version>0&&L.__version!==y.version){const B=y.image;if(B===null)Ie("WebGLRenderer: Texture marked for update but no image data found.");else if(B.complete===!1)Ie("WebGLRenderer: Texture marked for update but image is incomplete");else{Be(L,y,g);return}}else y.isExternalTexture&&(L.__webglTexture=y.sourceTexture?y.sourceTexture:null);t.bindTexture(s.TEXTURE_2D,L.__webglTexture,s.TEXTURE0+g)}function K(y,g){const L=n.get(y);if(y.isRenderTargetTexture===!1&&y.version>0&&L.__version!==y.version){Be(L,y,g);return}else y.isExternalTexture&&(L.__webglTexture=y.sourceTexture?y.sourceTexture:null);t.bindTexture(s.TEXTURE_2D_ARRAY,L.__webglTexture,s.TEXTURE0+g)}function le(y,g){const L=n.get(y);if(y.isRenderTargetTexture===!1&&y.version>0&&L.__version!==y.version){Be(L,y,g);return}t.bindTexture(s.TEXTURE_3D,L.__webglTexture,s.TEXTURE0+g)}function pe(y,g){const L=n.get(y);if(y.isCubeDepthTexture!==!0&&y.version>0&&L.__version!==y.version){Oe(L,y,g);return}t.bindTexture(s.TEXTURE_CUBE_MAP,L.__webglTexture,s.TEXTURE0+g)}const Me={[es]:s.REPEAT,[Rn]:s.CLAMP_TO_EDGE,[Rr]:s.MIRRORED_REPEAT},Ye={[Ot]:s.NEAREST,[su]:s.NEAREST_MIPMAP_NEAREST,[Rs]:s.NEAREST_MIPMAP_LINEAR,[Bt]:s.LINEAR,[yr]:s.LINEAR_MIPMAP_NEAREST,[Yn]:s.LINEAR_MIPMAP_LINEAR},rt={[Fh]:s.NEVER,[Vh]:s.ALWAYS,[Oh]:s.LESS,[Ho]:s.LEQUAL,[Bh]:s.EQUAL,[Go]:s.GEQUAL,[kh]:s.GREATER,[zh]:s.NOTEQUAL};function qe(y,g){if(g.type===fn&&e.has("OES_texture_float_linear")===!1&&(g.magFilter===Bt||g.magFilter===yr||g.magFilter===Rs||g.magFilter===Yn||g.minFilter===Bt||g.minFilter===yr||g.minFilter===Rs||g.minFilter===Yn)&&Ie("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),s.texParameteri(y,s.TEXTURE_WRAP_S,Me[g.wrapS]),s.texParameteri(y,s.TEXTURE_WRAP_T,Me[g.wrapT]),(y===s.TEXTURE_3D||y===s.TEXTURE_2D_ARRAY)&&s.texParameteri(y,s.TEXTURE_WRAP_R,Me[g.wrapR]),s.texParameteri(y,s.TEXTURE_MAG_FILTER,Ye[g.magFilter]),s.texParameteri(y,s.TEXTURE_MIN_FILTER,Ye[g.minFilter]),g.compareFunction&&(s.texParameteri(y,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(y,s.TEXTURE_COMPARE_FUNC,rt[g.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(g.magFilter===Ot||g.minFilter!==Rs&&g.minFilter!==Yn||g.type===fn&&e.has("OES_texture_float_linear")===!1)return;if(g.anisotropy>1||n.get(g).__currentAnisotropy){const L=e.get("EXT_texture_filter_anisotropic");s.texParameterf(y,L.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(g.anisotropy,i.getMaxAnisotropy())),n.get(g).__currentAnisotropy=g.anisotropy}}}function ne(y,g){let L=!1;y.__webglInit===void 0&&(y.__webglInit=!0,g.addEventListener("dispose",R));const B=g.source;let z=f.get(B);z===void 0&&(z={},f.set(B,z));const Q=W(g);if(Q!==y.__cacheKey){z[Q]===void 0&&(z[Q]={texture:s.createTexture(),usedTimes:0},a.memory.textures++,L=!0),z[Q].usedTimes++;const re=z[y.__cacheKey];re!==void 0&&(z[y.__cacheKey].usedTimes--,re.usedTimes===0&&D(g)),y.__cacheKey=Q,y.__webglTexture=z[Q].texture}return L}function he(y,g,L){return Math.floor(Math.floor(y/L)/g)}function ae(y,g,L,B){const Q=y.updateRanges;if(Q.length===0)t.texSubImage2D(s.TEXTURE_2D,0,0,0,g.width,g.height,L,B,g.data);else{Q.sort((me,ue)=>me.start-ue.start);let re=0;for(let me=1;me<Q.length;me++){const ue=Q[re],ce=Q[me],Ee=ue.start+ue.count,Te=he(ce.start,g.width,4),Re=he(ue.start,g.width,4);ce.start<=Ee+1&&Te===Re&&he(ce.start+ce.count-1,g.width,4)===Te?ue.count=Math.max(ue.count,ce.start+ce.count-ue.start):(++re,Q[re]=ce)}Q.length=re+1;const X=t.getParameter(s.UNPACK_ROW_LENGTH),Z=t.getParameter(s.UNPACK_SKIP_PIXELS),oe=t.getParameter(s.UNPACK_SKIP_ROWS);t.pixelStorei(s.UNPACK_ROW_LENGTH,g.width);for(let me=0,ue=Q.length;me<ue;me++){const ce=Q[me],Ee=Math.floor(ce.start/4),Te=Math.ceil(ce.count/4),Re=Ee%g.width,I=Math.floor(Ee/g.width),fe=Te,te=1;t.pixelStorei(s.UNPACK_SKIP_PIXELS,Re),t.pixelStorei(s.UNPACK_SKIP_ROWS,I),t.texSubImage2D(s.TEXTURE_2D,0,Re,I,fe,te,L,B,g.data)}y.clearUpdateRanges(),t.pixelStorei(s.UNPACK_ROW_LENGTH,X),t.pixelStorei(s.UNPACK_SKIP_PIXELS,Z),t.pixelStorei(s.UNPACK_SKIP_ROWS,oe)}}function Be(y,g,L){let B=s.TEXTURE_2D;(g.isDataArrayTexture||g.isCompressedArrayTexture)&&(B=s.TEXTURE_2D_ARRAY),g.isData3DTexture&&(B=s.TEXTURE_3D);const z=ne(y,g),Q=g.source;t.bindTexture(B,y.__webglTexture,s.TEXTURE0+L);const re=n.get(Q);if(Q.version!==re.__version||z===!0){if(t.activeTexture(s.TEXTURE0+L),(typeof ImageBitmap<"u"&&g.image instanceof ImageBitmap)===!1){const te=Qe.getPrimaries(Qe.workingColorSpace),de=g.colorSpace===li?null:Qe.getPrimaries(g.colorSpace),ge=g.colorSpace===li||te===de?s.NONE:s.BROWSER_DEFAULT_WEBGL;t.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,g.flipY),t.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,g.premultiplyAlpha),t.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,ge)}t.pixelStorei(s.UNPACK_ALIGNMENT,g.unpackAlignment);let Z=m(g.image,!1,i.maxTextureSize);Z=G(g,Z);const oe=r.convert(g.format,g.colorSpace),me=r.convert(g.type);let ue=S(g.internalFormat,oe,me,g.normalized,g.colorSpace,g.isVideoTexture);qe(B,g);let ce;const Ee=g.mipmaps,Te=g.isVideoTexture!==!0,Re=re.__version===void 0||z===!0,I=Q.dataReady,fe=E(g,Z);if(g.isDepthTexture)ue=w(g.format===Mi,g.type),Re&&(Te?t.texStorage2D(s.TEXTURE_2D,1,ue,Z.width,Z.height):t.texImage2D(s.TEXTURE_2D,0,ue,Z.width,Z.height,0,oe,me,null));else if(g.isDataTexture)if(Ee.length>0){Te&&Re&&t.texStorage2D(s.TEXTURE_2D,fe,ue,Ee[0].width,Ee[0].height);for(let te=0,de=Ee.length;te<de;te++)ce=Ee[te],Te?I&&t.texSubImage2D(s.TEXTURE_2D,te,0,0,ce.width,ce.height,oe,me,ce.data):t.texImage2D(s.TEXTURE_2D,te,ue,ce.width,ce.height,0,oe,me,ce.data);g.generateMipmaps=!1}else Te?(Re&&t.texStorage2D(s.TEXTURE_2D,fe,ue,Z.width,Z.height),I&&ae(g,Z,oe,me)):t.texImage2D(s.TEXTURE_2D,0,ue,Z.width,Z.height,0,oe,me,Z.data);else if(g.isCompressedTexture)if(g.isCompressedArrayTexture){Te&&Re&&t.texStorage3D(s.TEXTURE_2D_ARRAY,fe,ue,Ee[0].width,Ee[0].height,Z.depth);for(let te=0,de=Ee.length;te<de;te++)if(ce=Ee[te],g.format!==pn)if(oe!==null)if(Te){if(I)if(g.layerUpdates.size>0){const ge=uc(ce.width,ce.height,g.format,g.type);for(const se of g.layerUpdates){const be=ce.data.subarray(se*ge/ce.data.BYTES_PER_ELEMENT,(se+1)*ge/ce.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,te,0,0,se,ce.width,ce.height,1,oe,be)}g.clearLayerUpdates()}else t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,te,0,0,0,ce.width,ce.height,Z.depth,oe,ce.data)}else t.compressedTexImage3D(s.TEXTURE_2D_ARRAY,te,ue,ce.width,ce.height,Z.depth,0,ce.data,0,0);else Ie("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Te?I&&t.texSubImage3D(s.TEXTURE_2D_ARRAY,te,0,0,0,ce.width,ce.height,Z.depth,oe,me,ce.data):t.texImage3D(s.TEXTURE_2D_ARRAY,te,ue,ce.width,ce.height,Z.depth,0,oe,me,ce.data)}else{Te&&Re&&t.texStorage2D(s.TEXTURE_2D,fe,ue,Ee[0].width,Ee[0].height);for(let te=0,de=Ee.length;te<de;te++)ce=Ee[te],g.format!==pn?oe!==null?Te?I&&t.compressedTexSubImage2D(s.TEXTURE_2D,te,0,0,ce.width,ce.height,oe,ce.data):t.compressedTexImage2D(s.TEXTURE_2D,te,ue,ce.width,ce.height,0,ce.data):Ie("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Te?I&&t.texSubImage2D(s.TEXTURE_2D,te,0,0,ce.width,ce.height,oe,me,ce.data):t.texImage2D(s.TEXTURE_2D,te,ue,ce.width,ce.height,0,oe,me,ce.data)}else if(g.isDataArrayTexture)if(Te){if(Re&&t.texStorage3D(s.TEXTURE_2D_ARRAY,fe,ue,Z.width,Z.height,Z.depth),I)if(g.layerUpdates.size>0){const te=uc(Z.width,Z.height,g.format,g.type);for(const de of g.layerUpdates){const ge=Z.data.subarray(de*te/Z.data.BYTES_PER_ELEMENT,(de+1)*te/Z.data.BYTES_PER_ELEMENT);t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,de,Z.width,Z.height,1,oe,me,ge)}g.clearLayerUpdates()}else t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,Z.width,Z.height,Z.depth,oe,me,Z.data)}else t.texImage3D(s.TEXTURE_2D_ARRAY,0,ue,Z.width,Z.height,Z.depth,0,oe,me,Z.data);else if(g.isData3DTexture)Te?(Re&&t.texStorage3D(s.TEXTURE_3D,fe,ue,Z.width,Z.height,Z.depth),I&&t.texSubImage3D(s.TEXTURE_3D,0,0,0,0,Z.width,Z.height,Z.depth,oe,me,Z.data)):t.texImage3D(s.TEXTURE_3D,0,ue,Z.width,Z.height,Z.depth,0,oe,me,Z.data);else if(g.isFramebufferTexture){if(Re)if(Te)t.texStorage2D(s.TEXTURE_2D,fe,ue,Z.width,Z.height);else{let te=Z.width,de=Z.height;for(let ge=0;ge<fe;ge++)t.texImage2D(s.TEXTURE_2D,ge,ue,te,de,0,oe,me,null),te>>=1,de>>=1}}else if(g.isHTMLTexture){if("texElementImage2D"in s){const te=s.canvas;if(te.hasAttribute("layoutsubtree")||te.setAttribute("layoutsubtree","true"),Z.parentNode!==te){te.appendChild(Z),h.add(g),te.onpaint=de=>{const ge=de.changedElements;for(const se of h)ge.includes(se.image)&&(se.needsUpdate=!0)},te.requestPaint();return}if(s.texElementImage2D.length===3)s.texElementImage2D(s.TEXTURE_2D,s.RGBA8,Z);else{const ge=s.RGBA,se=s.RGBA,be=s.UNSIGNED_BYTE;s.texElementImage2D(s.TEXTURE_2D,0,ge,se,be,Z)}s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE)}}else if(Ee.length>0){if(Te&&Re){const te=J(Ee[0]);t.texStorage2D(s.TEXTURE_2D,fe,ue,te.width,te.height)}for(let te=0,de=Ee.length;te<de;te++)ce=Ee[te],Te?I&&t.texSubImage2D(s.TEXTURE_2D,te,0,0,oe,me,ce):t.texImage2D(s.TEXTURE_2D,te,ue,oe,me,ce);g.generateMipmaps=!1}else if(Te){if(Re){const te=J(Z);t.texStorage2D(s.TEXTURE_2D,fe,ue,te.width,te.height)}I&&t.texSubImage2D(s.TEXTURE_2D,0,0,0,oe,me,Z)}else t.texImage2D(s.TEXTURE_2D,0,ue,oe,me,Z);p(g)&&b(B),re.__version=Q.version,g.onUpdate&&g.onUpdate(g)}y.__version=g.version}function Oe(y,g,L){if(g.image.length!==6)return;const B=ne(y,g),z=g.source;t.bindTexture(s.TEXTURE_CUBE_MAP,y.__webglTexture,s.TEXTURE0+L);const Q=n.get(z);if(z.version!==Q.__version||B===!0){t.activeTexture(s.TEXTURE0+L);const re=Qe.getPrimaries(Qe.workingColorSpace),X=g.colorSpace===li?null:Qe.getPrimaries(g.colorSpace),Z=g.colorSpace===li||re===X?s.NONE:s.BROWSER_DEFAULT_WEBGL;t.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,g.flipY),t.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,g.premultiplyAlpha),t.pixelStorei(s.UNPACK_ALIGNMENT,g.unpackAlignment),t.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,Z);const oe=g.isCompressedTexture||g.image[0].isCompressedTexture,me=g.image[0]&&g.image[0].isDataTexture,ue=[];for(let se=0;se<6;se++)!oe&&!me?ue[se]=m(g.image[se],!0,i.maxCubemapSize):ue[se]=me?g.image[se].image:g.image[se],ue[se]=G(g,ue[se]);const ce=ue[0],Ee=r.convert(g.format,g.colorSpace),Te=r.convert(g.type),Re=S(g.internalFormat,Ee,Te,g.normalized,g.colorSpace),I=g.isVideoTexture!==!0,fe=Q.__version===void 0||B===!0,te=z.dataReady;let de=E(g,ce);qe(s.TEXTURE_CUBE_MAP,g);let ge;if(oe){I&&fe&&t.texStorage2D(s.TEXTURE_CUBE_MAP,de,Re,ce.width,ce.height);for(let se=0;se<6;se++){ge=ue[se].mipmaps;for(let be=0;be<ge.length;be++){const Ae=ge[be];g.format!==pn?Ee!==null?I?te&&t.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+se,be,0,0,Ae.width,Ae.height,Ee,Ae.data):t.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+se,be,Re,Ae.width,Ae.height,0,Ae.data):Ie("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):I?te&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+se,be,0,0,Ae.width,Ae.height,Ee,Te,Ae.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+se,be,Re,Ae.width,Ae.height,0,Ee,Te,Ae.data)}}}else{if(ge=g.mipmaps,I&&fe){ge.length>0&&de++;const se=J(ue[0]);t.texStorage2D(s.TEXTURE_CUBE_MAP,de,Re,se.width,se.height)}for(let se=0;se<6;se++)if(me){I?te&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+se,0,0,0,ue[se].width,ue[se].height,Ee,Te,ue[se].data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+se,0,Re,ue[se].width,ue[se].height,0,Ee,Te,ue[se].data);for(let be=0;be<ge.length;be++){const St=ge[be].image[se].image;I?te&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+se,be+1,0,0,St.width,St.height,Ee,Te,St.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+se,be+1,Re,St.width,St.height,0,Ee,Te,St.data)}}else{I?te&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+se,0,0,0,Ee,Te,ue[se]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+se,0,Re,Ee,Te,ue[se]);for(let be=0;be<ge.length;be++){const Ae=ge[be];I?te&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+se,be+1,0,0,Ee,Te,Ae.image[se]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+se,be+1,Re,Ee,Te,Ae.image[se])}}}p(g)&&b(s.TEXTURE_CUBE_MAP),Q.__version=z.version,g.onUpdate&&g.onUpdate(g)}y.__version=g.version}function De(y,g,L,B,z,Q){const re=r.convert(L.format,L.colorSpace),X=r.convert(L.type),Z=S(L.internalFormat,re,X,L.normalized,L.colorSpace),oe=n.get(g),me=n.get(L);if(me.__renderTarget=g,!oe.__hasExternalTextures){const ue=Math.max(1,g.width>>Q),ce=Math.max(1,g.height>>Q);z===s.TEXTURE_3D||z===s.TEXTURE_2D_ARRAY?t.texImage3D(z,Q,Z,ue,ce,g.depth,0,re,X,null):t.texImage2D(z,Q,Z,ue,ce,0,re,X,null)}t.bindFramebuffer(s.FRAMEBUFFER,y),vt(g)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,B,z,me.__webglTexture,0,et(g)):(z===s.TEXTURE_2D||z>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&z<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,B,z,me.__webglTexture,Q),t.bindFramebuffer(s.FRAMEBUFFER,null)}function ft(y,g,L){if(s.bindRenderbuffer(s.RENDERBUFFER,y),g.depthBuffer){const B=g.depthTexture,z=B&&B.isDepthTexture?B.type:null,Q=w(g.stencilBuffer,z),re=g.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;vt(g)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,et(g),Q,g.width,g.height):L?s.renderbufferStorageMultisample(s.RENDERBUFFER,et(g),Q,g.width,g.height):s.renderbufferStorage(s.RENDERBUFFER,Q,g.width,g.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,re,s.RENDERBUFFER,y)}else{const B=g.textures;for(let z=0;z<B.length;z++){const Q=B[z],re=r.convert(Q.format,Q.colorSpace),X=r.convert(Q.type),Z=S(Q.internalFormat,re,X,Q.normalized,Q.colorSpace);vt(g)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,et(g),Z,g.width,g.height):L?s.renderbufferStorageMultisample(s.RENDERBUFFER,et(g),Z,g.width,g.height):s.renderbufferStorage(s.RENDERBUFFER,Z,g.width,g.height)}}s.bindRenderbuffer(s.RENDERBUFFER,null)}function Ge(y,g,L){const B=g.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(s.FRAMEBUFFER,y),!(g.depthTexture&&g.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const z=n.get(g.depthTexture);if(z.__renderTarget=g,(!z.__webglTexture||g.depthTexture.image.width!==g.width||g.depthTexture.image.height!==g.height)&&(g.depthTexture.image.width=g.width,g.depthTexture.image.height=g.height,g.depthTexture.needsUpdate=!0),B){if(z.__webglInit===void 0&&(z.__webglInit=!0,g.depthTexture.addEventListener("dispose",R)),z.__webglTexture===void 0){z.__webglTexture=s.createTexture(),t.bindTexture(s.TEXTURE_CUBE_MAP,z.__webglTexture),qe(s.TEXTURE_CUBE_MAP,g.depthTexture);const oe=r.convert(g.depthTexture.format),me=r.convert(g.depthTexture.type);let ue;g.depthTexture.format===jn?ue=s.DEPTH_COMPONENT24:g.depthTexture.format===Mi&&(ue=s.DEPTH24_STENCIL8);for(let ce=0;ce<6;ce++)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,ue,g.width,g.height,0,oe,me,null)}}else ee(g.depthTexture,0);const Q=z.__webglTexture,re=et(g),X=B?s.TEXTURE_CUBE_MAP_POSITIVE_X+L:s.TEXTURE_2D,Z=g.depthTexture.format===Mi?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;if(g.depthTexture.format===jn)vt(g)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,Z,X,Q,0,re):s.framebufferTexture2D(s.FRAMEBUFFER,Z,X,Q,0);else if(g.depthTexture.format===Mi)vt(g)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,Z,X,Q,0,re):s.framebufferTexture2D(s.FRAMEBUFFER,Z,X,Q,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function je(y){const g=n.get(y),L=y.isWebGLCubeRenderTarget===!0;if(g.__boundDepthTexture!==y.depthTexture){const B=y.depthTexture;if(g.__depthDisposeCallback&&g.__depthDisposeCallback(),B){const z=()=>{delete g.__boundDepthTexture,delete g.__depthDisposeCallback,B.removeEventListener("dispose",z)};B.addEventListener("dispose",z),g.__depthDisposeCallback=z}g.__boundDepthTexture=B}if(y.depthTexture&&!g.__autoAllocateDepthBuffer)if(L)for(let B=0;B<6;B++)Ge(g.__webglFramebuffer[B],y,B);else{const B=y.texture.mipmaps;B&&B.length>0?Ge(g.__webglFramebuffer[0],y,0):Ge(g.__webglFramebuffer,y,0)}else if(L){g.__webglDepthbuffer=[];for(let B=0;B<6;B++)if(t.bindFramebuffer(s.FRAMEBUFFER,g.__webglFramebuffer[B]),g.__webglDepthbuffer[B]===void 0)g.__webglDepthbuffer[B]=s.createRenderbuffer(),ft(g.__webglDepthbuffer[B],y,!1);else{const z=y.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,Q=g.__webglDepthbuffer[B];s.bindRenderbuffer(s.RENDERBUFFER,Q),s.framebufferRenderbuffer(s.FRAMEBUFFER,z,s.RENDERBUFFER,Q)}}else{const B=y.texture.mipmaps;if(B&&B.length>0?t.bindFramebuffer(s.FRAMEBUFFER,g.__webglFramebuffer[0]):t.bindFramebuffer(s.FRAMEBUFFER,g.__webglFramebuffer),g.__webglDepthbuffer===void 0)g.__webglDepthbuffer=s.createRenderbuffer(),ft(g.__webglDepthbuffer,y,!1);else{const z=y.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,Q=g.__webglDepthbuffer;s.bindRenderbuffer(s.RENDERBUFFER,Q),s.framebufferRenderbuffer(s.FRAMEBUFFER,z,s.RENDERBUFFER,Q)}}t.bindFramebuffer(s.FRAMEBUFFER,null)}function Le(y,g,L){const B=n.get(y);g!==void 0&&De(B.__webglFramebuffer,y,y.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),L!==void 0&&je(y)}function Ve(y){const g=y.texture,L=n.get(y),B=n.get(g);y.addEventListener("dispose",x);const z=y.textures,Q=y.isWebGLCubeRenderTarget===!0,re=z.length>1;if(re||(B.__webglTexture===void 0&&(B.__webglTexture=s.createTexture()),B.__version=g.version,a.memory.textures++),Q){L.__webglFramebuffer=[];for(let X=0;X<6;X++)if(g.mipmaps&&g.mipmaps.length>0){L.__webglFramebuffer[X]=[];for(let Z=0;Z<g.mipmaps.length;Z++)L.__webglFramebuffer[X][Z]=s.createFramebuffer()}else L.__webglFramebuffer[X]=s.createFramebuffer()}else{if(g.mipmaps&&g.mipmaps.length>0){L.__webglFramebuffer=[];for(let X=0;X<g.mipmaps.length;X++)L.__webglFramebuffer[X]=s.createFramebuffer()}else L.__webglFramebuffer=s.createFramebuffer();if(re)for(let X=0,Z=z.length;X<Z;X++){const oe=n.get(z[X]);oe.__webglTexture===void 0&&(oe.__webglTexture=s.createTexture(),a.memory.textures++)}if(y.samples>0&&vt(y)===!1){L.__webglMultisampledFramebuffer=s.createFramebuffer(),L.__webglColorRenderbuffer=[],t.bindFramebuffer(s.FRAMEBUFFER,L.__webglMultisampledFramebuffer);for(let X=0;X<z.length;X++){const Z=z[X];L.__webglColorRenderbuffer[X]=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,L.__webglColorRenderbuffer[X]);const oe=r.convert(Z.format,Z.colorSpace),me=r.convert(Z.type),ue=S(Z.internalFormat,oe,me,Z.normalized,Z.colorSpace,y.isXRRenderTarget===!0),ce=et(y);s.renderbufferStorageMultisample(s.RENDERBUFFER,ce,ue,y.width,y.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+X,s.RENDERBUFFER,L.__webglColorRenderbuffer[X])}s.bindRenderbuffer(s.RENDERBUFFER,null),y.depthBuffer&&(L.__webglDepthRenderbuffer=s.createRenderbuffer(),ft(L.__webglDepthRenderbuffer,y,!0)),t.bindFramebuffer(s.FRAMEBUFFER,null)}}if(Q){t.bindTexture(s.TEXTURE_CUBE_MAP,B.__webglTexture),qe(s.TEXTURE_CUBE_MAP,g);for(let X=0;X<6;X++)if(g.mipmaps&&g.mipmaps.length>0)for(let Z=0;Z<g.mipmaps.length;Z++)De(L.__webglFramebuffer[X][Z],y,g,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+X,Z);else De(L.__webglFramebuffer[X],y,g,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+X,0);p(g)&&b(s.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(re){for(let X=0,Z=z.length;X<Z;X++){const oe=z[X],me=n.get(oe);let ue=s.TEXTURE_2D;(y.isWebGL3DRenderTarget||y.isWebGLArrayRenderTarget)&&(ue=y.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture(ue,me.__webglTexture),qe(ue,oe),De(L.__webglFramebuffer,y,oe,s.COLOR_ATTACHMENT0+X,ue,0),p(oe)&&b(ue)}t.unbindTexture()}else{let X=s.TEXTURE_2D;if((y.isWebGL3DRenderTarget||y.isWebGLArrayRenderTarget)&&(X=y.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture(X,B.__webglTexture),qe(X,g),g.mipmaps&&g.mipmaps.length>0)for(let Z=0;Z<g.mipmaps.length;Z++)De(L.__webglFramebuffer[Z],y,g,s.COLOR_ATTACHMENT0,X,Z);else De(L.__webglFramebuffer,y,g,s.COLOR_ATTACHMENT0,X,0);p(g)&&b(X),t.unbindTexture()}y.depthBuffer&&je(y)}function nt(y){const g=y.textures;for(let L=0,B=g.length;L<B;L++){const z=g[L];if(p(z)){const Q=T(y),re=n.get(z).__webglTexture;t.bindTexture(Q,re),b(Q),t.unbindTexture()}}}const at=[],Et=[];function lt(y){if(y.samples>0){if(vt(y)===!1){const g=y.textures,L=y.width,B=y.height;let z=s.COLOR_BUFFER_BIT;const Q=y.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,re=n.get(y),X=g.length>1;if(X)for(let oe=0;oe<g.length;oe++)t.bindFramebuffer(s.FRAMEBUFFER,re.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+oe,s.RENDERBUFFER,null),t.bindFramebuffer(s.FRAMEBUFFER,re.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+oe,s.TEXTURE_2D,null,0);t.bindFramebuffer(s.READ_FRAMEBUFFER,re.__webglMultisampledFramebuffer);const Z=y.texture.mipmaps;Z&&Z.length>0?t.bindFramebuffer(s.DRAW_FRAMEBUFFER,re.__webglFramebuffer[0]):t.bindFramebuffer(s.DRAW_FRAMEBUFFER,re.__webglFramebuffer);for(let oe=0;oe<g.length;oe++){if(y.resolveDepthBuffer&&(y.depthBuffer&&(z|=s.DEPTH_BUFFER_BIT),y.stencilBuffer&&y.resolveStencilBuffer&&(z|=s.STENCIL_BUFFER_BIT)),X){s.framebufferRenderbuffer(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,re.__webglColorRenderbuffer[oe]);const me=n.get(g[oe]).__webglTexture;s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,me,0)}s.blitFramebuffer(0,0,L,B,0,0,L,B,z,s.NEAREST),l===!0&&(at.length=0,Et.length=0,at.push(s.COLOR_ATTACHMENT0+oe),y.depthBuffer&&y.resolveDepthBuffer===!1&&(at.push(Q),Et.push(Q),s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,Et)),s.invalidateFramebuffer(s.READ_FRAMEBUFFER,at))}if(t.bindFramebuffer(s.READ_FRAMEBUFFER,null),t.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),X)for(let oe=0;oe<g.length;oe++){t.bindFramebuffer(s.FRAMEBUFFER,re.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+oe,s.RENDERBUFFER,re.__webglColorRenderbuffer[oe]);const me=n.get(g[oe]).__webglTexture;t.bindFramebuffer(s.FRAMEBUFFER,re.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+oe,s.TEXTURE_2D,me,0)}t.bindFramebuffer(s.DRAW_FRAMEBUFFER,re.__webglMultisampledFramebuffer)}else if(y.depthBuffer&&y.resolveDepthBuffer===!1&&l){const g=y.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,[g])}}}function et(y){return Math.min(i.maxSamples,y.samples)}function vt(y){const g=n.get(y);return y.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&g.__useRenderToTexture!==!1}function U(y){const g=a.render.frame;u.get(y)!==g&&(u.set(y,g),y.update())}function G(y,g){const L=y.colorSpace,B=y.format,z=y.type;return y.isCompressedTexture===!0||y.isVideoTexture===!0||L!==ln&&L!==li&&(Qe.getTransfer(L)===ut?(B!==pn||z!==on)&&Ie("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):ze("WebGLTextures: Unsupported texture color space:",L)),g}function J(y){return typeof HTMLImageElement<"u"&&y instanceof HTMLImageElement?(c.width=y.naturalWidth||y.width,c.height=y.naturalHeight||y.height):typeof VideoFrame<"u"&&y instanceof VideoFrame?(c.width=y.displayWidth,c.height=y.displayHeight):(c.width=y.width,c.height=y.height),c}this.allocateTextureUnit=q,this.resetTextureUnits=$,this.getTextureUnits=j,this.setTextureUnits=k,this.setTexture2D=ee,this.setTexture2DArray=K,this.setTexture3D=le,this.setTextureCube=pe,this.rebindTextures=Le,this.setupRenderTarget=Ve,this.updateRenderTargetMipmap=nt,this.updateMultisampleRenderTarget=lt,this.setupDepthRenderbuffer=je,this.setupFrameBufferTexture=De,this.useMultisampledRTT=vt,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function gx(s,e){function t(n,i=li){let r;const a=Qe.getTransfer(i);if(n===on)return s.UNSIGNED_BYTE;if(n===Fo)return s.UNSIGNED_SHORT_4_4_4_4;if(n===Oo)return s.UNSIGNED_SHORT_5_5_5_1;if(n===ou)return s.UNSIGNED_INT_5_9_9_9_REV;if(n===lu)return s.UNSIGNED_INT_10F_11F_11F_REV;if(n===ru)return s.BYTE;if(n===au)return s.SHORT;if(n===Ds)return s.UNSIGNED_SHORT;if(n===Uo)return s.INT;if(n===Nn)return s.UNSIGNED_INT;if(n===fn)return s.FLOAT;if(n===$n)return s.HALF_FLOAT;if(n===cu)return s.ALPHA;if(n===uu)return s.RGB;if(n===pn)return s.RGBA;if(n===jn)return s.DEPTH_COMPONENT;if(n===Mi)return s.DEPTH_STENCIL;if(n===Bo)return s.RED;if(n===ko)return s.RED_INTEGER;if(n===Ei)return s.RG;if(n===zo)return s.RG_INTEGER;if(n===Vo)return s.RGBA_INTEGER;if(n===br||n===Er||n===Tr||n===Ar)if(a===ut)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===br)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Er)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Tr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Ar)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===br)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Er)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Tr)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Ar)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Wa||n===Xa||n===Ya||n===qa)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===Wa)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Xa)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Ya)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===qa)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Ka||n===Za||n===$a||n===ja||n===Ja||n===Cr||n===Qa)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Ka||n===Za)return a===ut?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===$a)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===ja)return r.COMPRESSED_R11_EAC;if(n===Ja)return r.COMPRESSED_SIGNED_R11_EAC;if(n===Cr)return r.COMPRESSED_RG11_EAC;if(n===Qa)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===eo||n===to||n===no||n===io||n===so||n===ro||n===ao||n===oo||n===lo||n===co||n===uo||n===ho||n===fo||n===po)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===eo)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===to)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===no)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===io)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===so)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===ro)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===ao)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===oo)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===lo)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===co)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===uo)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===ho)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===fo)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===po)return a===ut?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===mo||n===go||n===_o)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===mo)return a===ut?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===go)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===_o)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===xo||n===vo||n===Pr||n===Mo)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===xo)return r.COMPRESSED_RED_RGTC1_EXT;if(n===vo)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Pr)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Mo)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Ns?s.UNSIGNED_INT_24_8:s[n]!==void 0?s[n]:null}return{convert:t}}const _x=`
4085
4085
  void main() {
4086
4086
 
4087
4087
  gl_Position = vec4( position, 1.0 );
4088
4088
 
4089
- }`,_x=`
4089
+ }`,xx=`
4090
4090
  uniform sampler2DArray depthColor;
4091
4091
  uniform float depthWidth;
4092
4092
  uniform float depthHeight;
@@ -4105,8 +4105,8 @@ void main() {
4105
4105
 
4106
4106
  }
4107
4107
 
4108
- }`;class xx{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new Su(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new Un({vertexShader:gx,fragmentShader:_x,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new bt(new kr(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class vx extends hi{constructor(e,t){super();const n=this;let i=null,r=1,a=null,o="local-floor",l=1,c=null,u=null,h=null,d=null,f=null,_=null;const v=typeof XRWebGLBinding<"u",m=new xx,p={},b=t.getContextAttributes();let T=null,S=null;const w=[],E=[],R=new ke;let x=null;const A=new Qt;A.viewport=new gt;const D=new Qt;D.viewport=new gt;const P=[A,D],F=new gf;let $=null,j=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ne){let he=w[ne];return he===void 0&&(he=new Qr,w[ne]=he),he.getTargetRaySpace()},this.getControllerGrip=function(ne){let he=w[ne];return he===void 0&&(he=new Qr,w[ne]=he),he.getGripSpace()},this.getHand=function(ne){let he=w[ne];return he===void 0&&(he=new Qr,w[ne]=he),he.getHandSpace()};function k(ne){const he=E.indexOf(ne.inputSource);if(he===-1)return;const ae=w[he];ae!==void 0&&(ae.update(ne.inputSource,ne.frame,c||a),ae.dispatchEvent({type:ne.type,data:ne.inputSource}))}function q(){i.removeEventListener("select",k),i.removeEventListener("selectstart",k),i.removeEventListener("selectend",k),i.removeEventListener("squeeze",k),i.removeEventListener("squeezestart",k),i.removeEventListener("squeezeend",k),i.removeEventListener("end",q),i.removeEventListener("inputsourceschange",W);for(let ne=0;ne<w.length;ne++){const he=E[ne];he!==null&&(E[ne]=null,w[ne].disconnect(he))}$=null,j=null,m.reset();for(const ne in p)delete p[ne];e.setRenderTarget(T),f=null,d=null,h=null,i=null,S=null,qe.stop(),n.isPresenting=!1,e.setPixelRatio(x),e.setSize(R.width,R.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ne){r=ne,n.isPresenting===!0&&Ie("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ne){o=ne,n.isPresenting===!0&&Ie("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(ne){c=ne},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return h===null&&v&&(h=new XRWebGLBinding(i,t)),h},this.getFrame=function(){return _},this.getSession=function(){return i},this.setSession=async function(ne){if(i=ne,i!==null){if(T=e.getRenderTarget(),i.addEventListener("select",k),i.addEventListener("selectstart",k),i.addEventListener("selectend",k),i.addEventListener("squeeze",k),i.addEventListener("squeezestart",k),i.addEventListener("squeezeend",k),i.addEventListener("end",q),i.addEventListener("inputsourceschange",W),b.xrCompatible!==!0&&await t.makeXRCompatible(),x=e.getPixelRatio(),e.getSize(R),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let ae=null,Be=null,Oe=null;b.depth&&(Oe=b.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ae=b.stencil?Mi:jn,Be=b.stencil?Ns:Nn);const De={colorFormat:t.RGBA8,depthFormat:Oe,scaleFactor:r};h=this.getBinding(),d=h.createProjectionLayer(De),i.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),S=new Ln(d.textureWidth,d.textureHeight,{format:pn,type:on,depthTexture:new ns(d.textureWidth,d.textureHeight,Be,void 0,void 0,void 0,void 0,void 0,void 0,ae),stencilBuffer:b.stencil,colorSpace:e.outputColorSpace,samples:b.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const ae={antialias:b.antialias,alpha:!0,depth:b.depth,stencil:b.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(i,t,ae),i.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),S=new Ln(f.framebufferWidth,f.framebufferHeight,{format:pn,type:on,colorSpace:e.outputColorSpace,stencilBuffer:b.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}S.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await i.requestReferenceSpace(o),qe.setContext(i),qe.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function W(ne){for(let he=0;he<ne.removed.length;he++){const ae=ne.removed[he],Be=E.indexOf(ae);Be>=0&&(E[Be]=null,w[Be].disconnect(ae))}for(let he=0;he<ne.added.length;he++){const ae=ne.added[he];let Be=E.indexOf(ae);if(Be===-1){for(let De=0;De<w.length;De++)if(De>=E.length){E.push(ae),Be=De;break}else if(E[De]===null){E[De]=ae,Be=De;break}if(Be===-1)break}const Oe=w[Be];Oe&&Oe.connect(ae)}}const ee=new C,K=new C;function le(ne,he,ae){ee.setFromMatrixPosition(he.matrixWorld),K.setFromMatrixPosition(ae.matrixWorld);const Be=ee.distanceTo(K),Oe=he.projectionMatrix.elements,De=ae.projectionMatrix.elements,ft=Oe[14]/(Oe[10]-1),Ge=Oe[14]/(Oe[10]+1),je=(Oe[9]+1)/Oe[5],Le=(Oe[9]-1)/Oe[5],Ve=(Oe[8]-1)/Oe[0],nt=(De[8]+1)/De[0],at=ft*Ve,Et=ft*nt,lt=Be/(-Ve+nt),et=lt*-Ve;if(he.matrixWorld.decompose(ne.position,ne.quaternion,ne.scale),ne.translateX(et),ne.translateZ(lt),ne.matrixWorld.compose(ne.position,ne.quaternion,ne.scale),ne.matrixWorldInverse.copy(ne.matrixWorld).invert(),Oe[10]===-1)ne.projectionMatrix.copy(he.projectionMatrix),ne.projectionMatrixInverse.copy(he.projectionMatrixInverse);else{const vt=ft+lt,U=Ge+lt,G=at-et,J=Et+(Be-et),y=je*Ge/U*vt,g=Le*Ge/U*vt;ne.projectionMatrix.makePerspective(G,J,y,g,vt,U),ne.projectionMatrixInverse.copy(ne.projectionMatrix).invert()}}function pe(ne,he){he===null?ne.matrixWorld.copy(ne.matrix):ne.matrixWorld.multiplyMatrices(he.matrixWorld,ne.matrix),ne.matrixWorldInverse.copy(ne.matrixWorld).invert()}this.updateCamera=function(ne){if(i===null)return;let he=ne.near,ae=ne.far;m.texture!==null&&(m.depthNear>0&&(he=m.depthNear),m.depthFar>0&&(ae=m.depthFar)),F.near=D.near=A.near=he,F.far=D.far=A.far=ae,($!==F.near||j!==F.far)&&(i.updateRenderState({depthNear:F.near,depthFar:F.far}),$=F.near,j=F.far),F.layers.mask=ne.layers.mask|6,A.layers.mask=F.layers.mask&-5,D.layers.mask=F.layers.mask&-3;const Be=ne.parent,Oe=F.cameras;pe(F,Be);for(let De=0;De<Oe.length;De++)pe(Oe[De],Be);Oe.length===2?le(F,A,D):F.projectionMatrix.copy(A.projectionMatrix),Me(ne,F,Be)};function Me(ne,he,ae){ae===null?ne.matrix.copy(he.matrixWorld):(ne.matrix.copy(ae.matrixWorld),ne.matrix.invert(),ne.matrix.multiply(he.matrixWorld)),ne.matrix.decompose(ne.position,ne.quaternion,ne.scale),ne.updateMatrixWorld(!0),ne.projectionMatrix.copy(he.projectionMatrix),ne.projectionMatrixInverse.copy(he.projectionMatrixInverse),ne.isPerspectiveCamera&&(ne.fov=ts*2*Math.atan(1/ne.projectionMatrix.elements[5]),ne.zoom=1)}this.getCamera=function(){return F},this.getFoveation=function(){if(!(d===null&&f===null))return l},this.setFoveation=function(ne){l=ne,d!==null&&(d.fixedFoveation=ne),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=ne)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(F)},this.getCameraTexture=function(ne){return p[ne]};let Ye=null;function rt(ne,he){if(u=he.getViewerPose(c||a),_=he,u!==null){const ae=u.views;f!==null&&(e.setRenderTargetFramebuffer(S,f.framebuffer),e.setRenderTarget(S));let Be=!1;ae.length!==F.cameras.length&&(F.cameras.length=0,Be=!0);for(let Ge=0;Ge<ae.length;Ge++){const je=ae[Ge];let Le=null;if(f!==null)Le=f.getViewport(je);else{const nt=h.getViewSubImage(d,je);Le=nt.viewport,Ge===0&&(e.setRenderTargetTextures(S,nt.colorTexture,nt.depthStencilTexture),e.setRenderTarget(S))}let Ve=P[Ge];Ve===void 0&&(Ve=new Qt,Ve.layers.enable(Ge),Ve.viewport=new gt,P[Ge]=Ve),Ve.matrix.fromArray(je.transform.matrix),Ve.matrix.decompose(Ve.position,Ve.quaternion,Ve.scale),Ve.projectionMatrix.fromArray(je.projectionMatrix),Ve.projectionMatrixInverse.copy(Ve.projectionMatrix).invert(),Ve.viewport.set(Le.x,Le.y,Le.width,Le.height),Ge===0&&(F.matrix.copy(Ve.matrix),F.matrix.decompose(F.position,F.quaternion,F.scale)),Be===!0&&F.cameras.push(Ve)}const Oe=i.enabledFeatures;if(Oe&&Oe.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&v){h=n.getBinding();const Ge=h.getDepthInformation(ae[0]);Ge&&Ge.isValid&&Ge.texture&&m.init(Ge,i.renderState)}if(Oe&&Oe.includes("camera-access")&&v){e.state.unbindTexture(),h=n.getBinding();for(let Ge=0;Ge<ae.length;Ge++){const je=ae[Ge].camera;if(je){let Le=p[je];Le||(Le=new Su,p[je]=Le);const Ve=h.getCameraImage(je);Le.sourceTexture=Ve}}}}for(let ae=0;ae<w.length;ae++){const Be=E[ae],Oe=w[ae];Be!==null&&Oe!==void 0&&Oe.update(Be,he,c||a)}Ye&&Ye(ne,he),he.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:he}),_=null}const qe=new Tu;qe.setAnimationLoop(rt),this.setAnimationLoop=function(ne){Ye=ne},this.dispose=function(){}}}const Mx=new We,Iu=new He;Iu.set(-1,0,0,0,1,0,0,0,1);function Sx(s,e){function t(m,p){m.matrixAutoUpdate===!0&&m.updateMatrix(),p.value.copy(m.matrix)}function n(m,p){p.color.getRGB(m.fogColor.value,yu(s)),p.isFog?(m.fogNear.value=p.near,m.fogFar.value=p.far):p.isFogExp2&&(m.fogDensity.value=p.density)}function i(m,p,b,T,S){p.isNodeMaterial?p.uniformsNeedUpdate=!1:p.isMeshBasicMaterial?r(m,p):p.isMeshLambertMaterial?(r(m,p),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)):p.isMeshToonMaterial?(r(m,p),h(m,p)):p.isMeshPhongMaterial?(r(m,p),u(m,p),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)):p.isMeshStandardMaterial?(r(m,p),d(m,p),p.isMeshPhysicalMaterial&&f(m,p,S)):p.isMeshMatcapMaterial?(r(m,p),_(m,p)):p.isMeshDepthMaterial?r(m,p):p.isMeshDistanceMaterial?(r(m,p),v(m,p)):p.isMeshNormalMaterial?r(m,p):p.isLineBasicMaterial?(a(m,p),p.isLineDashedMaterial&&o(m,p)):p.isPointsMaterial?l(m,p,b,T):p.isSpriteMaterial?c(m,p):p.isShadowMaterial?(m.color.value.copy(p.color),m.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function r(m,p){m.opacity.value=p.opacity,p.color&&m.diffuse.value.copy(p.color),p.emissive&&m.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(m.map.value=p.map,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.bumpMap&&(m.bumpMap.value=p.bumpMap,t(p.bumpMap,m.bumpMapTransform),m.bumpScale.value=p.bumpScale,p.side===tn&&(m.bumpScale.value*=-1)),p.normalMap&&(m.normalMap.value=p.normalMap,t(p.normalMap,m.normalMapTransform),m.normalScale.value.copy(p.normalScale),p.side===tn&&m.normalScale.value.negate()),p.displacementMap&&(m.displacementMap.value=p.displacementMap,t(p.displacementMap,m.displacementMapTransform),m.displacementScale.value=p.displacementScale,m.displacementBias.value=p.displacementBias),p.emissiveMap&&(m.emissiveMap.value=p.emissiveMap,t(p.emissiveMap,m.emissiveMapTransform)),p.specularMap&&(m.specularMap.value=p.specularMap,t(p.specularMap,m.specularMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest);const b=e.get(p),T=b.envMap,S=b.envMapRotation;T&&(m.envMap.value=T,m.envMapRotation.value.setFromMatrix4(Mx.makeRotationFromEuler(S)).transpose(),T.isCubeTexture&&T.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(Iu),m.reflectivity.value=p.reflectivity,m.ior.value=p.ior,m.refractionRatio.value=p.refractionRatio),p.lightMap&&(m.lightMap.value=p.lightMap,m.lightMapIntensity.value=p.lightMapIntensity,t(p.lightMap,m.lightMapTransform)),p.aoMap&&(m.aoMap.value=p.aoMap,m.aoMapIntensity.value=p.aoMapIntensity,t(p.aoMap,m.aoMapTransform))}function a(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform))}function o(m,p){m.dashSize.value=p.dashSize,m.totalSize.value=p.dashSize+p.gapSize,m.scale.value=p.scale}function l(m,p,b,T){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.size.value=p.size*b,m.scale.value=T*.5,p.map&&(m.map.value=p.map,t(p.map,m.uvTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function c(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.rotation.value=p.rotation,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function u(m,p){m.specular.value.copy(p.specular),m.shininess.value=Math.max(p.shininess,1e-4)}function h(m,p){p.gradientMap&&(m.gradientMap.value=p.gradientMap)}function d(m,p){m.metalness.value=p.metalness,p.metalnessMap&&(m.metalnessMap.value=p.metalnessMap,t(p.metalnessMap,m.metalnessMapTransform)),m.roughness.value=p.roughness,p.roughnessMap&&(m.roughnessMap.value=p.roughnessMap,t(p.roughnessMap,m.roughnessMapTransform)),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)}function f(m,p,b){m.ior.value=p.ior,p.sheen>0&&(m.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),m.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(m.sheenColorMap.value=p.sheenColorMap,t(p.sheenColorMap,m.sheenColorMapTransform)),p.sheenRoughnessMap&&(m.sheenRoughnessMap.value=p.sheenRoughnessMap,t(p.sheenRoughnessMap,m.sheenRoughnessMapTransform))),p.clearcoat>0&&(m.clearcoat.value=p.clearcoat,m.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(m.clearcoatMap.value=p.clearcoatMap,t(p.clearcoatMap,m.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,t(p.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(m.clearcoatNormalMap.value=p.clearcoatNormalMap,t(p.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===tn&&m.clearcoatNormalScale.value.negate())),p.dispersion>0&&(m.dispersion.value=p.dispersion),p.iridescence>0&&(m.iridescence.value=p.iridescence,m.iridescenceIOR.value=p.iridescenceIOR,m.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(m.iridescenceMap.value=p.iridescenceMap,t(p.iridescenceMap,m.iridescenceMapTransform)),p.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=p.iridescenceThicknessMap,t(p.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),p.transmission>0&&(m.transmission.value=p.transmission,m.transmissionSamplerMap.value=b.texture,m.transmissionSamplerSize.value.set(b.width,b.height),p.transmissionMap&&(m.transmissionMap.value=p.transmissionMap,t(p.transmissionMap,m.transmissionMapTransform)),m.thickness.value=p.thickness,p.thicknessMap&&(m.thicknessMap.value=p.thicknessMap,t(p.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=p.attenuationDistance,m.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(m.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(m.anisotropyMap.value=p.anisotropyMap,t(p.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=p.specularIntensity,m.specularColor.value.copy(p.specularColor),p.specularColorMap&&(m.specularColorMap.value=p.specularColorMap,t(p.specularColorMap,m.specularColorMapTransform)),p.specularIntensityMap&&(m.specularIntensityMap.value=p.specularIntensityMap,t(p.specularIntensityMap,m.specularIntensityMapTransform))}function _(m,p){p.matcap&&(m.matcap.value=p.matcap)}function v(m,p){const b=e.get(p).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:i}}function yx(s,e,t,n){let i={},r={},a=[];const o=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function l(S,w){const E=w.program;n.uniformBlockBinding(S,E)}function c(S,w){let E=i[S.id];E===void 0&&(m(S),E=u(S),i[S.id]=E,S.addEventListener("dispose",b));const R=w.program;n.updateUBOMapping(S,R);const x=e.render.frame;r[S.id]!==x&&(d(S),r[S.id]=x)}function u(S){const w=h();S.__bindingPointIndex=w;const E=s.createBuffer(),R=S.__size,x=S.usage;return s.bindBuffer(s.UNIFORM_BUFFER,E),s.bufferData(s.UNIFORM_BUFFER,R,x),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,w,E),E}function h(){for(let S=0;S<o;S++)if(a.indexOf(S)===-1)return a.push(S),S;return ze("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(S){const w=i[S.id],E=S.uniforms,R=S.__cache;s.bindBuffer(s.UNIFORM_BUFFER,w);for(let x=0,A=E.length;x<A;x++){const D=E[x];if(Array.isArray(D))for(let P=0,F=D.length;P<F;P++)f(D[P],x,P,R);else f(D,x,0,R)}s.bindBuffer(s.UNIFORM_BUFFER,null)}function f(S,w,E,R){if(v(S,w,E,R)===!0){const x=S.__offset,A=S.value;if(Array.isArray(A)){let D=0;for(let P=0;P<A.length;P++){const F=A[P],$=p(F);_(F,S.__data,D),typeof F!="number"&&typeof F!="boolean"&&!F.isMatrix3&&!ArrayBuffer.isView(F)&&(D+=$.storage/Float32Array.BYTES_PER_ELEMENT)}}else _(A,S.__data,0);s.bufferSubData(s.UNIFORM_BUFFER,x,S.__data)}}function _(S,w,E){typeof S=="number"||typeof S=="boolean"?w[0]=S:S.isMatrix3?(w[0]=S.elements[0],w[1]=S.elements[1],w[2]=S.elements[2],w[3]=0,w[4]=S.elements[3],w[5]=S.elements[4],w[6]=S.elements[5],w[7]=0,w[8]=S.elements[6],w[9]=S.elements[7],w[10]=S.elements[8],w[11]=0):ArrayBuffer.isView(S)?w.set(new S.constructor(S.buffer,S.byteOffset,w.length)):S.toArray(w,E)}function v(S,w,E,R){const x=S.value,A=w+"_"+E;if(R[A]===void 0)return typeof x=="number"||typeof x=="boolean"?R[A]=x:ArrayBuffer.isView(x)?R[A]=x.slice():R[A]=x.clone(),!0;{const D=R[A];if(typeof x=="number"||typeof x=="boolean"){if(D!==x)return R[A]=x,!0}else{if(ArrayBuffer.isView(x))return!0;if(D.equals(x)===!1)return D.copy(x),!0}}return!1}function m(S){const w=S.uniforms;let E=0;const R=16;for(let A=0,D=w.length;A<D;A++){const P=Array.isArray(w[A])?w[A]:[w[A]];for(let F=0,$=P.length;F<$;F++){const j=P[F],k=Array.isArray(j.value)?j.value:[j.value];for(let q=0,W=k.length;q<W;q++){const ee=k[q],K=p(ee),le=E%R,pe=le%K.boundary,Me=le+pe;E+=pe,Me!==0&&R-Me<K.storage&&(E+=R-Me),j.__data=new Float32Array(K.storage/Float32Array.BYTES_PER_ELEMENT),j.__offset=E,E+=K.storage}}}const x=E%R;return x>0&&(E+=R-x),S.__size=E,S.__cache={},this}function p(S){const w={boundary:0,storage:0};return typeof S=="number"||typeof S=="boolean"?(w.boundary=4,w.storage=4):S.isVector2?(w.boundary=8,w.storage=8):S.isVector3||S.isColor?(w.boundary=16,w.storage=12):S.isVector4?(w.boundary=16,w.storage=16):S.isMatrix3?(w.boundary=48,w.storage=48):S.isMatrix4?(w.boundary=64,w.storage=64):S.isTexture?Ie("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(S)?(w.boundary=16,w.storage=S.byteLength):Ie("WebGLRenderer: Unsupported uniform value type.",S),w}function b(S){const w=S.target;w.removeEventListener("dispose",b);const E=a.indexOf(w.__bindingPointIndex);a.splice(E,1),s.deleteBuffer(i[w.id]),delete i[w.id],delete r[w.id]}function T(){for(const S in i)s.deleteBuffer(i[S]);a=[],i={},r={}}return{bind:l,update:c,dispose:T}}const bx=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let Tn=null;function Ex(){return Tn===null&&(Tn=new Ko(bx,16,16,Ei,$n),Tn.name="DFG_LUT",Tn.minFilter=Bt,Tn.magFilter=Bt,Tn.wrapS=Rn,Tn.wrapT=Rn,Tn.generateMipmaps=!1,Tn.needsUpdate=!0),Tn}class Tx{constructor(e={}){const{canvas:t=Gh(),context:n=null,depth:i=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1,reversedDepthBuffer:d=!1,outputBufferType:f=on}=e;this.isWebGLRenderer=!0;let _;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");_=n.getContextAttributes().alpha}else _=a;const v=f,m=new Set([Vo,zo,ko]),p=new Set([on,Nn,Ds,Ns,Fo,Oo]),b=new Uint32Array(4),T=new Int32Array(4),S=new C;let w=null,E=null;const R=[],x=[];let A=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Pn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const D=this;let P=!1,F=null,$=null,j=null,k=null;this._outputColorSpace=Ht;let q=0,W=0,ee=null,K=-1,le=null;const pe=new gt,Me=new gt;let Ye=null;const rt=new Ue(0);let qe=0,ne=t.width,he=t.height,ae=1,Be=null,Oe=null;const De=new gt(0,0,ne,he),ft=new gt(0,0,ne,he);let Ge=!1;const je=new $o;let Le=!1,Ve=!1;const nt=new We,at=new C,Et=new gt,lt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let et=!1;function vt(){return ee===null?ae:1}let U=n;function G(M,O){return t.getContext(M,O)}try{const M={alpha:!0,depth:i,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${No}`),t.addEventListener("webglcontextlost",St,!1),t.addEventListener("webglcontextrestored",ct,!1),t.addEventListener("webglcontextcreationerror",cn,!1),U===null){const O="webgl2";if(U=G(O,M),U===null)throw G(O)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(M){throw ze("WebGLRenderer: "+M.message),M}let J,y,g,L,B,z,Q,re,X,Z,oe,me,ue,ce,Ee,Te,Re,I,fe,te,de,ge,se;function be(){J=new Eg(U),J.init(),de=new mx(U,J),y=new gg(U,J,e,de),g=new fx(U,J),y.reversedDepthBuffer&&d&&g.buffers.depth.setReversed(!0),$=U.createFramebuffer(),j=U.createFramebuffer(),k=U.createFramebuffer(),L=new wg(U),B=new Q_,z=new px(U,J,g,B,y,de,L),Q=new bg(D),re=new Lf(U),ge=new pg(U,re),X=new Tg(U,re,L,ge),Z=new Cg(U,X,re,ge,L),I=new Rg(U,y,z),Ee=new _g(B),oe=new J_(D,Q,J,y,ge,Ee),me=new Sx(D,B),ue=new tx,ce=new ox(J),Re=new fg(D,Q,g,Z,_,l),Te=new dx(D,Z,y),se=new yx(U,L,y,g),fe=new mg(U,J,L),te=new Ag(U,J,L),L.programs=oe.programs,D.capabilities=y,D.extensions=J,D.properties=B,D.renderLists=ue,D.shadowMap=Te,D.state=g,D.info=L}be(),v!==on&&(A=new Lg(v,t.width,t.height,o,i,r));const Ae=new vx(D,U);this.xr=Ae,this.getContext=function(){return U},this.getContextAttributes=function(){return U.getContextAttributes()},this.forceContextLoss=function(){const M=J.get("WEBGL_lose_context");M&&M.loseContext()},this.forceContextRestore=function(){const M=J.get("WEBGL_lose_context");M&&M.restoreContext()},this.getPixelRatio=function(){return ae},this.setPixelRatio=function(M){M!==void 0&&(ae=M,this.setSize(ne,he,!1))},this.getSize=function(M){return M.set(ne,he)},this.setSize=function(M,O,Y=!0){if(Ae.isPresenting){Ie("WebGLRenderer: Can't change size while VR device is presenting.");return}ne=M,he=O,t.width=Math.floor(M*ae),t.height=Math.floor(O*ae),Y===!0&&(t.style.width=M+"px",t.style.height=O+"px"),A!==null&&A.setSize(t.width,t.height),this.setViewport(0,0,M,O)},this.getDrawingBufferSize=function(M){return M.set(ne*ae,he*ae).floor()},this.setDrawingBufferSize=function(M,O,Y){ne=M,he=O,ae=Y,t.width=Math.floor(M*Y),t.height=Math.floor(O*Y),this.setViewport(0,0,M,O)},this.setEffects=function(M){if(v===on){ze("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(M){for(let O=0;O<M.length;O++)if(M[O].isOutputPass===!0){Ie("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}A.setEffects(M||[])},this.getCurrentViewport=function(M){return M.copy(pe)},this.getViewport=function(M){return M.copy(De)},this.setViewport=function(M,O,Y,V){M.isVector4?De.set(M.x,M.y,M.z,M.w):De.set(M,O,Y,V),g.viewport(pe.copy(De).multiplyScalar(ae).round())},this.getScissor=function(M){return M.copy(ft)},this.setScissor=function(M,O,Y,V){M.isVector4?ft.set(M.x,M.y,M.z,M.w):ft.set(M,O,Y,V),g.scissor(Me.copy(ft).multiplyScalar(ae).round())},this.getScissorTest=function(){return Ge},this.setScissorTest=function(M){g.setScissorTest(Ge=M)},this.setOpaqueSort=function(M){Be=M},this.setTransparentSort=function(M){Oe=M},this.getClearColor=function(M){return M.copy(Re.getClearColor())},this.setClearColor=function(){Re.setClearColor(...arguments)},this.getClearAlpha=function(){return Re.getClearAlpha()},this.setClearAlpha=function(){Re.setClearAlpha(...arguments)},this.clear=function(M=!0,O=!0,Y=!0){let V=0;if(M){let H=!1;if(ee!==null){const _e=ee.texture.format;H=m.has(_e)}if(H){const _e=ee.texture.type,Se=p.has(_e),ve=Re.getClearColor(),Pe=Re.getClearAlpha(),Ne=ve.r,Xe=ve.g,Ze=ve.b;Se?(b[0]=Ne,b[1]=Xe,b[2]=Ze,b[3]=Pe,U.clearBufferuiv(U.COLOR,0,b)):(T[0]=Ne,T[1]=Xe,T[2]=Ze,T[3]=Pe,U.clearBufferiv(U.COLOR,0,T))}else V|=U.COLOR_BUFFER_BIT}O&&(V|=U.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),Y&&(V|=U.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),V!==0&&U.clear(V)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(M){M.setRenderer(this),F=M},this.dispose=function(){t.removeEventListener("webglcontextlost",St,!1),t.removeEventListener("webglcontextrestored",ct,!1),t.removeEventListener("webglcontextcreationerror",cn,!1),Re.dispose(),ue.dispose(),ce.dispose(),B.dispose(),Q.dispose(),Z.dispose(),ge.dispose(),se.dispose(),oe.dispose(),Ae.dispose(),Ae.removeEventListener("sessionstart",Gs),Ae.removeEventListener("sessionend",fs),Bn.stop()};function St(M){M.preventDefault(),Ir("WebGLRenderer: Context Lost."),P=!0}function ct(){Ir("WebGLRenderer: Context Restored."),P=!1;const M=L.autoReset,O=Te.enabled,Y=Te.autoUpdate,V=Te.needsUpdate,H=Te.type;be(),L.autoReset=M,Te.enabled=O,Te.autoUpdate=Y,Te.needsUpdate=V,Te.type=H}function cn(M){ze("WebGLRenderer: A WebGL context could not be created. Reason: ",M.statusMessage)}function qt(M){const O=M.target;O.removeEventListener("dispose",qt),Hs(O)}function Hs(M){Wr(M),B.remove(M)}function Wr(M){const O=B.get(M).programs;O!==void 0&&(O.forEach(function(Y){oe.releaseProgram(Y)}),M.isShaderMaterial&&oe.releaseShaderCache(M))}this.renderBufferDirect=function(M,O,Y,V,H,_e){O===null&&(O=lt);const Se=H.isMesh&&H.matrixWorld.determinantAffine()<0,ve=Ut(M,O,Y,V,H);g.setMaterial(V,Se);let Pe=Y.index,Ne=1;if(V.wireframe===!0){if(Pe=X.getWireframeAttribute(Y),Pe===void 0)return;Ne=2}const Xe=Y.drawRange,Ze=Y.attributes.position;let Fe=Xe.start*Ne,pt=(Xe.start+Xe.count)*Ne;_e!==null&&(Fe=Math.max(Fe,_e.start*Ne),pt=Math.min(pt,(_e.start+_e.count)*Ne)),Pe!==null?(Fe=Math.max(Fe,0),pt=Math.min(pt,Pe.count)):Ze!=null&&(Fe=Math.max(Fe,0),pt=Math.min(pt,Ze.count));const Ct=pt-Fe;if(Ct<0||Ct===1/0)return;ge.setup(H,V,ve,Y,Pe);let wt,_t=fe;if(Pe!==null&&(wt=re.get(Pe),_t=te,_t.setIndex(wt)),H.isMesh)V.wireframe===!0?(g.setLineWidth(V.wireframeLinewidth*vt()),_t.setMode(U.LINES)):_t.setMode(U.TRIANGLES);else if(H.isLine){let Kt=V.linewidth;Kt===void 0&&(Kt=1),g.setLineWidth(Kt*vt()),H.isLineSegments?_t.setMode(U.LINES):H.isLineLoop?_t.setMode(U.LINE_LOOP):_t.setMode(U.LINE_STRIP)}else H.isPoints?_t.setMode(U.POINTS):H.isSprite&&_t.setMode(U.TRIANGLES);if(H.isBatchedMesh)if(J.get("WEBGL_multi_draw"))_t.renderMultiDraw(H._multiDrawStarts,H._multiDrawCounts,H._multiDrawCount);else{const Kt=H._multiDrawStarts,ye=H._multiDrawCounts,nn=H._multiDrawCount,st=Pe?re.get(Pe).bytesPerElement:1,un=B.get(V).currentProgram.getUniforms();for(let bn=0;bn<nn;bn++)un.setValue(U,"_gl_DrawID",bn),_t.render(Kt[bn]/st,ye[bn])}else if(H.isInstancedMesh)_t.renderInstances(Fe,Ct,H.count);else if(Y.isInstancedBufferGeometry){const Kt=Y._maxInstanceCount!==void 0?Y._maxInstanceCount:1/0,ye=Math.min(Y.instanceCount,Kt);_t.renderInstances(Fe,Ct,ye)}else _t.render(Fe,Ct)};function us(M,O,Y){M.transparent===!0&&M.side===an&&M.forceSinglePass===!1?(M.side=tn,M.needsUpdate=!0,tt(M,O,Y),M.side=Dn,M.needsUpdate=!0,tt(M,O,Y),M.side=an):tt(M,O,Y)}this.compile=function(M,O,Y=null){Y===null&&(Y=M),E=ce.get(Y),E.init(O),x.push(E),Y.traverseVisible(function(H){H.isLight&&H.layers.test(O.layers)&&(E.pushLight(H),H.castShadow&&E.pushShadow(H))}),M!==Y&&M.traverseVisible(function(H){H.isLight&&H.layers.test(O.layers)&&(E.pushLight(H),H.castShadow&&E.pushShadow(H))}),E.setupLights();const V=new Set;return M.traverse(function(H){if(!(H.isMesh||H.isPoints||H.isLine||H.isSprite))return;const _e=H.material;if(_e)if(Array.isArray(_e))for(let Se=0;Se<_e.length;Se++){const ve=_e[Se];us(ve,Y,H),V.add(ve)}else us(_e,Y,H),V.add(_e)}),E=x.pop(),V},this.compileAsync=function(M,O,Y=null){const V=this.compile(M,O,Y);return new Promise(H=>{function _e(){if(V.forEach(function(Se){B.get(Se).currentProgram.isReady()&&V.delete(Se)}),V.size===0){H(M);return}setTimeout(_e,10)}J.get("KHR_parallel_shader_compile")!==null?_e():setTimeout(_e,10)})};let hs=null;function ds(M){hs&&hs(M)}function Gs(){Bn.stop()}function fs(){Bn.start()}const Bn=new Tu;Bn.setAnimationLoop(ds),typeof self<"u"&&Bn.setContext(self),this.setAnimationLoop=function(M){hs=M,Ae.setAnimationLoop(M),M===null?Bn.stop():Bn.start()},Ae.addEventListener("sessionstart",Gs),Ae.addEventListener("sessionend",fs),this.render=function(M,O){if(O!==void 0&&O.isCamera!==!0){ze("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(P===!0)return;F!==null&&F.renderStart(M,O);const Y=Ae.enabled===!0&&Ae.isPresenting===!0,V=A!==null&&(ee===null||Y)&&A.begin(D,ee);if(M.matrixWorldAutoUpdate===!0&&M.updateMatrixWorld(),O.parent===null&&O.matrixWorldAutoUpdate===!0&&O.updateMatrixWorld(),Ae.enabled===!0&&Ae.isPresenting===!0&&(A===null||A.isCompositing()===!1)&&(Ae.cameraAutoUpdate===!0&&Ae.updateCamera(O),O=Ae.getCamera()),M.isScene===!0&&M.onBeforeRender(D,M,O,ee),E=ce.get(M,x.length),E.init(O),E.state.textureUnits=z.getTextureUnits(),x.push(E),nt.multiplyMatrices(O.projectionMatrix,O.matrixWorldInverse),je.setFromProjectionMatrix(nt,Cn,O.reversedDepth),Ve=this.localClippingEnabled,Le=Ee.init(this.clippingPlanes,Ve),w=ue.get(M,R.length),w.init(),R.push(w),Ae.enabled===!0&&Ae.isPresenting===!0){const Se=D.xr.getDepthSensingMesh();Se!==null&&Ai(Se,O,-1/0,D.sortObjects)}Ai(M,O,0,D.sortObjects),w.finish(),D.sortObjects===!0&&w.sort(Be,Oe,O.reversedDepth),et=Ae.enabled===!1||Ae.isPresenting===!1||Ae.hasDepthSensing()===!1,et&&Re.addToRenderList(w,M),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Le===!0&&Ee.beginShadows();const H=E.state.shadowsArray;if(Te.render(H,M,O),Le===!0&&Ee.endShadows(),(V&&A.hasRenderPass())===!1){const Se=w.opaque,ve=w.transmissive;if(E.setupLights(),O.isArrayCamera){const Pe=O.cameras;if(ve.length>0)for(let Ne=0,Xe=Pe.length;Ne<Xe;Ne++){const Ze=Pe[Ne];N(Se,ve,M,Ze)}et&&Re.render(M);for(let Ne=0,Xe=Pe.length;Ne<Xe;Ne++){const Ze=Pe[Ne];ps(w,M,Ze,Ze.viewport)}}else ve.length>0&&N(Se,ve,M,O),et&&Re.render(M),ps(w,M,O)}ee!==null&&W===0&&(z.updateMultisampleRenderTarget(ee),z.updateRenderTargetMipmap(ee)),V&&A.end(D),M.isScene===!0&&M.onAfterRender(D,M,O),ge.resetDefaultState(),K=-1,le=null,x.pop(),x.length>0?(E=x[x.length-1],z.setTextureUnits(E.state.textureUnits),Le===!0&&Ee.setGlobalState(D.clippingPlanes,E.state.camera)):E=null,R.pop(),R.length>0?w=R[R.length-1]:w=null,F!==null&&F.renderEnd()};function Ai(M,O,Y,V){if(M.visible===!1)return;if(M.layers.test(O.layers)){if(M.isGroup)Y=M.renderOrder;else if(M.isLOD)M.autoUpdate===!0&&M.update(O);else if(M.isLightProbeGrid)E.pushLightProbeGrid(M);else if(M.isLight)E.pushLight(M),M.castShadow&&E.pushShadow(M);else if(M.isSprite){if(!M.frustumCulled||je.intersectsSprite(M)){V&&Et.setFromMatrixPosition(M.matrixWorld).applyMatrix4(nt);const Se=Z.update(M),ve=M.material;ve.visible&&w.push(M,Se,ve,Y,Et.z,null)}}else if((M.isMesh||M.isLine||M.isPoints)&&(!M.frustumCulled||je.intersectsObject(M))){const Se=Z.update(M),ve=M.material;if(V&&(M.boundingSphere!==void 0?(M.boundingSphere===null&&M.computeBoundingSphere(),Et.copy(M.boundingSphere.center)):(Se.boundingSphere===null&&Se.computeBoundingSphere(),Et.copy(Se.boundingSphere.center)),Et.applyMatrix4(M.matrixWorld).applyMatrix4(nt)),Array.isArray(ve)){const Pe=Se.groups;for(let Ne=0,Xe=Pe.length;Ne<Xe;Ne++){const Ze=Pe[Ne],Fe=ve[Ze.materialIndex];Fe&&Fe.visible&&w.push(M,Se,Fe,Y,Et.z,Ze)}}else ve.visible&&w.push(M,Se,ve,Y,Et.z,null)}}const _e=M.children;for(let Se=0,ve=_e.length;Se<ve;Se++)Ai(_e[Se],O,Y,V)}function ps(M,O,Y,V){const{opaque:H,transmissive:_e,transparent:Se}=M;E.setupLightsView(Y),Le===!0&&Ee.setGlobalState(D.clippingPlanes,Y),V&&g.viewport(pe.copy(V)),H.length>0&&Ce(H,O,Y),_e.length>0&&Ce(_e,O,Y),Se.length>0&&Ce(Se,O,Y),g.buffers.depth.setTest(!0),g.buffers.depth.setMask(!0),g.buffers.color.setMask(!0),g.setPolygonOffset(!1)}function N(M,O,Y,V){if((Y.isScene===!0?Y.overrideMaterial:null)!==null)return;if(E.state.transmissionRenderTarget[V.id]===void 0){const Fe=J.has("EXT_color_buffer_half_float")||J.has("EXT_color_buffer_float");E.state.transmissionRenderTarget[V.id]=new Ln(1,1,{generateMipmaps:!0,type:Fe?$n:on,minFilter:Yn,samples:Math.max(4,y.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Qe.workingColorSpace})}const _e=E.state.transmissionRenderTarget[V.id],Se=V.viewport||pe;_e.setSize(Se.z*D.transmissionResolutionScale,Se.w*D.transmissionResolutionScale);const ve=D.getRenderTarget(),Pe=D.getActiveCubeFace(),Ne=D.getActiveMipmapLevel();D.setRenderTarget(_e),D.getClearColor(rt),qe=D.getClearAlpha(),qe<1&&D.setClearColor(16777215,.5),D.clear(),et&&Re.render(Y);const Xe=D.toneMapping;D.toneMapping=Pn;const Ze=V.viewport;if(V.viewport!==void 0&&(V.viewport=void 0),E.setupLightsView(V),Le===!0&&Ee.setGlobalState(D.clippingPlanes,V),Ce(M,Y,V),z.updateMultisampleRenderTarget(_e),z.updateRenderTargetMipmap(_e),J.has("WEBGL_multisampled_render_to_texture")===!1){let Fe=!1;for(let pt=0,Ct=O.length;pt<Ct;pt++){const wt=O[pt],{object:_t,geometry:Kt,material:ye,group:nn}=wt;if(ye.side===an&&_t.layers.test(V.layers)){const st=ye.side;ye.side=tn,ye.needsUpdate=!0,it(_t,Y,V,Kt,ye,nn),ye.side=st,ye.needsUpdate=!0,Fe=!0}}Fe===!0&&(z.updateMultisampleRenderTarget(_e),z.updateRenderTargetMipmap(_e))}D.setRenderTarget(ve,Pe,Ne),D.setClearColor(rt,qe),Ze!==void 0&&(V.viewport=Ze),D.toneMapping=Xe}function Ce(M,O,Y){const V=O.isScene===!0?O.overrideMaterial:null;for(let H=0,_e=M.length;H<_e;H++){const Se=M[H],{object:ve,geometry:Pe,group:Ne}=Se;let Xe=Se.material;Xe.allowOverride===!0&&V!==null&&(Xe=V),ve.layers.test(Y.layers)&&it(ve,O,Y,Pe,Xe,Ne)}}function it(M,O,Y,V,H,_e){M.onBeforeRender(D,O,Y,V,H,_e),M.modelViewMatrix.multiplyMatrices(Y.matrixWorldInverse,M.matrixWorld),M.normalMatrix.getNormalMatrix(M.modelViewMatrix),H.onBeforeRender(D,O,Y,V,M,_e),H.transparent===!0&&H.side===an&&H.forceSinglePass===!1?(H.side=tn,H.needsUpdate=!0,D.renderBufferDirect(Y,O,V,H,M,_e),H.side=Dn,H.needsUpdate=!0,D.renderBufferDirect(Y,O,V,H,M,_e),H.side=an):D.renderBufferDirect(Y,O,V,H,M,_e),M.onAfterRender(D,O,Y,V,H,_e)}function tt(M,O,Y){O.isScene!==!0&&(O=lt);const V=B.get(M),H=E.state.lights,_e=E.state.shadowsArray,Se=H.state.version,ve=oe.getParameters(M,H.state,_e,O,Y,E.state.lightProbeGridArray),Pe=oe.getProgramCacheKey(ve);let Ne=V.programs;V.environment=M.isMeshStandardMaterial||M.isMeshLambertMaterial||M.isMeshPhongMaterial?O.environment:null,V.fog=O.fog;const Xe=M.isMeshStandardMaterial||M.isMeshLambertMaterial&&!M.envMap||M.isMeshPhongMaterial&&!M.envMap;V.envMap=Q.get(M.envMap||V.environment,Xe),V.envMapRotation=V.environment!==null&&M.envMap===null?O.environmentRotation:M.envMapRotation,Ne===void 0&&(M.addEventListener("dispose",qt),Ne=new Map,V.programs=Ne);let Ze=Ne.get(Pe);if(Ze!==void 0){if(V.currentProgram===Ze&&V.lightsStateVersion===Se)return Tt(M,ve),Ze}else ve.uniforms=oe.getUniforms(M),F!==null&&M.isNodeMaterial&&F.build(M,Y,ve),M.onBeforeCompile(ve,D),Ze=oe.acquireProgram(ve,Pe),Ne.set(Pe,Ze),V.uniforms=ve.uniforms;const Fe=V.uniforms;return(!M.isShaderMaterial&&!M.isRawShaderMaterial||M.clipping===!0)&&(Fe.clippingPlanes=Ee.uniform),Tt(M,ve),V.needsLights=Rt(M),V.lightsStateVersion=Se,V.needsLights&&(Fe.ambientLightColor.value=H.state.ambient,Fe.lightProbe.value=H.state.probe,Fe.directionalLights.value=H.state.directional,Fe.directionalLightShadows.value=H.state.directionalShadow,Fe.spotLights.value=H.state.spot,Fe.spotLightShadows.value=H.state.spotShadow,Fe.rectAreaLights.value=H.state.rectArea,Fe.ltc_1.value=H.state.rectAreaLTC1,Fe.ltc_2.value=H.state.rectAreaLTC2,Fe.pointLights.value=H.state.point,Fe.pointLightShadows.value=H.state.pointShadow,Fe.hemisphereLights.value=H.state.hemi,Fe.directionalShadowMatrix.value=H.state.directionalShadowMatrix,Fe.spotLightMatrix.value=H.state.spotLightMatrix,Fe.spotLightMap.value=H.state.spotLightMap,Fe.pointShadowMatrix.value=H.state.pointShadowMatrix),V.lightProbeGrid=E.state.lightProbeGridArray.length>0,V.currentProgram=Ze,V.uniformsList=null,Ze}function Xt(M){if(M.uniformsList===null){const O=M.currentProgram.getUniforms();M.uniformsList=wr.seqWithValue(O.seq,M.uniforms)}return M.uniformsList}function Tt(M,O){const Y=B.get(M);Y.outputColorSpace=O.outputColorSpace,Y.batching=O.batching,Y.batchingColor=O.batchingColor,Y.instancing=O.instancing,Y.instancingColor=O.instancingColor,Y.instancingMorph=O.instancingMorph,Y.skinning=O.skinning,Y.morphTargets=O.morphTargets,Y.morphNormals=O.morphNormals,Y.morphColors=O.morphColors,Y.morphTargetsCount=O.morphTargetsCount,Y.numClippingPlanes=O.numClippingPlanes,Y.numIntersection=O.numClipIntersection,Y.vertexAlphas=O.vertexAlphas,Y.vertexTangents=O.vertexTangents,Y.toneMapping=O.toneMapping}function yt(M,O){if(M.length===0)return null;if(M.length===1)return M[0].texture!==null?M[0]:null;S.setFromMatrixPosition(O.matrixWorld);for(let Y=0,V=M.length;Y<V;Y++){const H=M[Y];if(H.texture!==null&&H.boundingBox.containsPoint(S))return H}return null}function Ut(M,O,Y,V,H){O.isScene!==!0&&(O=lt),z.resetTextureUnits();const _e=O.fog,Se=V.isMeshStandardMaterial||V.isMeshLambertMaterial||V.isMeshPhongMaterial?O.environment:null,ve=ee===null?D.outputColorSpace:ee.isXRRenderTarget===!0?ee.texture.colorSpace:Qe.workingColorSpace,Pe=V.isMeshStandardMaterial||V.isMeshLambertMaterial&&!V.envMap||V.isMeshPhongMaterial&&!V.envMap,Ne=Q.get(V.envMap||Se,Pe),Xe=V.vertexColors===!0&&!!Y.attributes.color&&Y.attributes.color.itemSize===4,Ze=!!Y.attributes.tangent&&(!!V.normalMap||V.anisotropy>0),Fe=!!Y.morphAttributes.position,pt=!!Y.morphAttributes.normal,Ct=!!Y.morphAttributes.color;let wt=Pn;V.toneMapped&&(ee===null||ee.isXRRenderTarget===!0)&&(wt=D.toneMapping);const _t=Y.morphAttributes.position||Y.morphAttributes.normal||Y.morphAttributes.color,Kt=_t!==void 0?_t.length:0,ye=B.get(V),nn=E.state.lights;if(Le===!0&&(Ve===!0||M!==le)){const Mt=M===le&&V.id===K;Ee.setState(V,M,Mt)}let st=!1;V.version===ye.__version?(ye.needsLights&&ye.lightsStateVersion!==nn.state.version||ye.outputColorSpace!==ve||H.isBatchedMesh&&ye.batching===!1||!H.isBatchedMesh&&ye.batching===!0||H.isBatchedMesh&&ye.batchingColor===!0&&H.colorTexture===null||H.isBatchedMesh&&ye.batchingColor===!1&&H.colorTexture!==null||H.isInstancedMesh&&ye.instancing===!1||!H.isInstancedMesh&&ye.instancing===!0||H.isSkinnedMesh&&ye.skinning===!1||!H.isSkinnedMesh&&ye.skinning===!0||H.isInstancedMesh&&ye.instancingColor===!0&&H.instanceColor===null||H.isInstancedMesh&&ye.instancingColor===!1&&H.instanceColor!==null||H.isInstancedMesh&&ye.instancingMorph===!0&&H.morphTexture===null||H.isInstancedMesh&&ye.instancingMorph===!1&&H.morphTexture!==null||ye.envMap!==Ne||V.fog===!0&&ye.fog!==_e||ye.numClippingPlanes!==void 0&&(ye.numClippingPlanes!==Ee.numPlanes||ye.numIntersection!==Ee.numIntersection)||ye.vertexAlphas!==Xe||ye.vertexTangents!==Ze||ye.morphTargets!==Fe||ye.morphNormals!==pt||ye.morphColors!==Ct||ye.toneMapping!==wt||ye.morphTargetsCount!==Kt||!!ye.lightProbeGrid!=E.state.lightProbeGridArray.length>0)&&(st=!0):(st=!0,ye.__version=V.version);let un=ye.currentProgram;st===!0&&(un=tt(V,O,H),F&&V.isNodeMaterial&&F.onUpdateProgram(V,un,ye));let bn=!1,Jn=!1,wi=!1;const xt=un.getUniforms(),Pt=ye.uniforms;if(g.useProgram(un.program)&&(bn=!0,Jn=!0,wi=!0),V.id!==K&&(K=V.id,Jn=!0),ye.needsLights){const Mt=yt(E.state.lightProbeGridArray,H);ye.lightProbeGrid!==Mt&&(ye.lightProbeGrid=Mt,Jn=!0)}if(bn||le!==M){g.buffers.depth.getReversed()&&M.reversedDepth!==!0&&(M._reversedDepth=!0,M.updateProjectionMatrix()),xt.setValue(U,"projectionMatrix",M.projectionMatrix),xt.setValue(U,"viewMatrix",M.matrixWorldInverse);const ei=xt.map.cameraPosition;ei!==void 0&&ei.setValue(U,at.setFromMatrixPosition(M.matrixWorld)),y.logarithmicDepthBuffer&&xt.setValue(U,"logDepthBufFC",2/(Math.log(M.far+1)/Math.LN2)),(V.isMeshPhongMaterial||V.isMeshToonMaterial||V.isMeshLambertMaterial||V.isMeshBasicMaterial||V.isMeshStandardMaterial||V.isShaderMaterial)&&xt.setValue(U,"isOrthographic",M.isOrthographicCamera===!0),le!==M&&(le=M,Jn=!0,wi=!0)}if(ye.needsLights&&(nn.state.directionalShadowMap.length>0&&xt.setValue(U,"directionalShadowMap",nn.state.directionalShadowMap,z),nn.state.spotShadowMap.length>0&&xt.setValue(U,"spotShadowMap",nn.state.spotShadowMap,z),nn.state.pointShadowMap.length>0&&xt.setValue(U,"pointShadowMap",nn.state.pointShadowMap,z)),H.isSkinnedMesh){xt.setOptional(U,H,"bindMatrix"),xt.setOptional(U,H,"bindMatrixInverse");const Mt=H.skeleton;Mt&&(Mt.boneTexture===null&&Mt.computeBoneTexture(),xt.setValue(U,"boneTexture",Mt.boneTexture,z))}H.isBatchedMesh&&(xt.setOptional(U,H,"batchingTexture"),xt.setValue(U,"batchingTexture",H._matricesTexture,z),xt.setOptional(U,H,"batchingIdTexture"),xt.setValue(U,"batchingIdTexture",H._indirectTexture,z),xt.setOptional(U,H,"batchingColorTexture"),H._colorsTexture!==null&&xt.setValue(U,"batchingColorTexture",H._colorsTexture,z));const Qn=Y.morphAttributes;if((Qn.position!==void 0||Qn.normal!==void 0||Qn.color!==void 0)&&I.update(H,Y,un),(Jn||ye.receiveShadow!==H.receiveShadow)&&(ye.receiveShadow=H.receiveShadow,xt.setValue(U,"receiveShadow",H.receiveShadow)),(V.isMeshStandardMaterial||V.isMeshLambertMaterial||V.isMeshPhongMaterial)&&V.envMap===null&&O.environment!==null&&(Pt.envMapIntensity.value=O.environmentIntensity),Pt.dfgLUT!==void 0&&(Pt.dfgLUT.value=Ex()),Jn){if(xt.setValue(U,"toneMappingExposure",D.toneMappingExposure),ye.needsLights&&ot(Pt,wi),_e&&V.fog===!0&&me.refreshFogUniforms(Pt,_e),me.refreshMaterialUniforms(Pt,V,ae,he,E.state.transmissionRenderTarget[M.id]),ye.needsLights&&ye.lightProbeGrid){const Mt=ye.lightProbeGrid;Pt.probesSH.value=Mt.texture,Pt.probesMin.value.copy(Mt.boundingBox.min),Pt.probesMax.value.copy(Mt.boundingBox.max),Pt.probesResolution.value.copy(Mt.resolution)}wr.upload(U,Xt(ye),Pt,z)}if(V.isShaderMaterial&&V.uniformsNeedUpdate===!0&&(wr.upload(U,Xt(ye),Pt,z),V.uniformsNeedUpdate=!1),V.isSpriteMaterial&&xt.setValue(U,"center",H.center),xt.setValue(U,"modelViewMatrix",H.modelViewMatrix),xt.setValue(U,"normalMatrix",H.normalMatrix),xt.setValue(U,"modelMatrix",H.matrixWorld),V.uniformsGroups!==void 0){const Mt=V.uniformsGroups;for(let ei=0,Ri=Mt.length;ei<Ri;ei++){const hl=Mt[ei];se.update(hl,un),se.bind(hl,un)}}return un}function ot(M,O){M.ambientLightColor.needsUpdate=O,M.lightProbe.needsUpdate=O,M.directionalLights.needsUpdate=O,M.directionalLightShadows.needsUpdate=O,M.pointLights.needsUpdate=O,M.pointLightShadows.needsUpdate=O,M.spotLights.needsUpdate=O,M.spotLightShadows.needsUpdate=O,M.rectAreaLights.needsUpdate=O,M.hemisphereLights.needsUpdate=O}function Rt(M){return M.isMeshLambertMaterial||M.isMeshToonMaterial||M.isMeshPhongMaterial||M.isMeshStandardMaterial||M.isShadowMaterial||M.isShaderMaterial&&M.lights===!0}this.getActiveCubeFace=function(){return q},this.getActiveMipmapLevel=function(){return W},this.getRenderTarget=function(){return ee},this.setRenderTargetTextures=function(M,O,Y){const V=B.get(M);V.__autoAllocateDepthBuffer=M.resolveDepthBuffer===!1,V.__autoAllocateDepthBuffer===!1&&(V.__useRenderToTexture=!1),B.get(M.texture).__webglTexture=O,B.get(M.depthTexture).__webglTexture=V.__autoAllocateDepthBuffer?void 0:Y,V.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(M,O){const Y=B.get(M);Y.__webglFramebuffer=O,Y.__useDefaultFramebuffer=O===void 0},this.setRenderTarget=function(M,O=0,Y=0){ee=M,q=O,W=Y;let V=null,H=!1,_e=!1;if(M){const ve=B.get(M);if(ve.__useDefaultFramebuffer!==void 0){g.bindFramebuffer(U.FRAMEBUFFER,ve.__webglFramebuffer),pe.copy(M.viewport),Me.copy(M.scissor),Ye=M.scissorTest,g.viewport(pe),g.scissor(Me),g.setScissorTest(Ye),K=-1;return}else if(ve.__webglFramebuffer===void 0)z.setupRenderTarget(M);else if(ve.__hasExternalTextures)z.rebindTextures(M,B.get(M.texture).__webglTexture,B.get(M.depthTexture).__webglTexture);else if(M.depthBuffer){const Xe=M.depthTexture;if(ve.__boundDepthTexture!==Xe){if(Xe!==null&&B.has(Xe)&&(M.width!==Xe.image.width||M.height!==Xe.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");z.setupDepthRenderbuffer(M)}}const Pe=M.texture;(Pe.isData3DTexture||Pe.isDataArrayTexture||Pe.isCompressedArrayTexture)&&(_e=!0);const Ne=B.get(M).__webglFramebuffer;M.isWebGLCubeRenderTarget?(Array.isArray(Ne[O])?V=Ne[O][Y]:V=Ne[O],H=!0):M.samples>0&&z.useMultisampledRTT(M)===!1?V=B.get(M).__webglMultisampledFramebuffer:Array.isArray(Ne)?V=Ne[Y]:V=Ne,pe.copy(M.viewport),Me.copy(M.scissor),Ye=M.scissorTest}else pe.copy(De).multiplyScalar(ae).floor(),Me.copy(ft).multiplyScalar(ae).floor(),Ye=Ge;if(Y!==0&&(V=$),g.bindFramebuffer(U.FRAMEBUFFER,V)&&g.drawBuffers(M,V),g.viewport(pe),g.scissor(Me),g.setScissorTest(Ye),H){const ve=B.get(M.texture);U.framebufferTexture2D(U.FRAMEBUFFER,U.COLOR_ATTACHMENT0,U.TEXTURE_CUBE_MAP_POSITIVE_X+O,ve.__webglTexture,Y)}else if(_e){const ve=O;for(let Pe=0;Pe<M.textures.length;Pe++){const Ne=B.get(M.textures[Pe]);U.framebufferTextureLayer(U.FRAMEBUFFER,U.COLOR_ATTACHMENT0+Pe,Ne.__webglTexture,Y,ve)}}else if(M!==null&&Y!==0){const ve=B.get(M.texture);U.framebufferTexture2D(U.FRAMEBUFFER,U.COLOR_ATTACHMENT0,U.TEXTURE_2D,ve.__webglTexture,Y)}K=-1},this.readRenderTargetPixels=function(M,O,Y,V,H,_e,Se,ve=0){if(!(M&&M.isWebGLRenderTarget)){ze("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Pe=B.get(M).__webglFramebuffer;if(M.isWebGLCubeRenderTarget&&Se!==void 0&&(Pe=Pe[Se]),Pe){g.bindFramebuffer(U.FRAMEBUFFER,Pe);try{const Ne=M.textures[ve],Xe=Ne.format,Ze=Ne.type;if(M.textures.length>1&&U.readBuffer(U.COLOR_ATTACHMENT0+ve),!y.textureFormatReadable(Xe)){ze("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!y.textureTypeReadable(Ze)){ze("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}O>=0&&O<=M.width-V&&Y>=0&&Y<=M.height-H&&U.readPixels(O,Y,V,H,de.convert(Xe),de.convert(Ze),_e)}finally{const Ne=ee!==null?B.get(ee).__webglFramebuffer:null;g.bindFramebuffer(U.FRAMEBUFFER,Ne)}}},this.readRenderTargetPixelsAsync=async function(M,O,Y,V,H,_e,Se,ve=0){if(!(M&&M.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Pe=B.get(M).__webglFramebuffer;if(M.isWebGLCubeRenderTarget&&Se!==void 0&&(Pe=Pe[Se]),Pe)if(O>=0&&O<=M.width-V&&Y>=0&&Y<=M.height-H){g.bindFramebuffer(U.FRAMEBUFFER,Pe);const Ne=M.textures[ve],Xe=Ne.format,Ze=Ne.type;if(M.textures.length>1&&U.readBuffer(U.COLOR_ATTACHMENT0+ve),!y.textureFormatReadable(Xe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!y.textureTypeReadable(Ze))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Fe=U.createBuffer();U.bindBuffer(U.PIXEL_PACK_BUFFER,Fe),U.bufferData(U.PIXEL_PACK_BUFFER,_e.byteLength,U.STREAM_READ),U.readPixels(O,Y,V,H,de.convert(Xe),de.convert(Ze),0);const pt=ee!==null?B.get(ee).__webglFramebuffer:null;g.bindFramebuffer(U.FRAMEBUFFER,pt);const Ct=U.fenceSync(U.SYNC_GPU_COMMANDS_COMPLETE,0);return U.flush(),await Wh(U,Ct,4),U.bindBuffer(U.PIXEL_PACK_BUFFER,Fe),U.getBufferSubData(U.PIXEL_PACK_BUFFER,0,_e),U.deleteBuffer(Fe),U.deleteSync(Ct),_e}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(M,O=null,Y=0){const V=Math.pow(2,-Y),H=Math.floor(M.image.width*V),_e=Math.floor(M.image.height*V),Se=O!==null?O.x:0,ve=O!==null?O.y:0;z.setTexture2D(M,0),U.copyTexSubImage2D(U.TEXTURE_2D,Y,0,0,Se,ve,H,_e),g.unbindTexture()},this.copyTextureToTexture=function(M,O,Y=null,V=null,H=0,_e=0){let Se,ve,Pe,Ne,Xe,Ze,Fe,pt,Ct;const wt=M.isCompressedTexture?M.mipmaps[_e]:M.image;if(Y!==null)Se=Y.max.x-Y.min.x,ve=Y.max.y-Y.min.y,Pe=Y.isBox3?Y.max.z-Y.min.z:1,Ne=Y.min.x,Xe=Y.min.y,Ze=Y.isBox3?Y.min.z:0;else{const Pt=Math.pow(2,-H);Se=Math.floor(wt.width*Pt),ve=Math.floor(wt.height*Pt),M.isDataArrayTexture?Pe=wt.depth:M.isData3DTexture?Pe=Math.floor(wt.depth*Pt):Pe=1,Ne=0,Xe=0,Ze=0}V!==null?(Fe=V.x,pt=V.y,Ct=V.z):(Fe=0,pt=0,Ct=0);const _t=de.convert(O.format),Kt=de.convert(O.type);let ye;O.isData3DTexture?(z.setTexture3D(O,0),ye=U.TEXTURE_3D):O.isDataArrayTexture||O.isCompressedArrayTexture?(z.setTexture2DArray(O,0),ye=U.TEXTURE_2D_ARRAY):(z.setTexture2D(O,0),ye=U.TEXTURE_2D),g.activeTexture(U.TEXTURE0),g.pixelStorei(U.UNPACK_FLIP_Y_WEBGL,O.flipY),g.pixelStorei(U.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),g.pixelStorei(U.UNPACK_ALIGNMENT,O.unpackAlignment);const nn=g.getParameter(U.UNPACK_ROW_LENGTH),st=g.getParameter(U.UNPACK_IMAGE_HEIGHT),un=g.getParameter(U.UNPACK_SKIP_PIXELS),bn=g.getParameter(U.UNPACK_SKIP_ROWS),Jn=g.getParameter(U.UNPACK_SKIP_IMAGES);g.pixelStorei(U.UNPACK_ROW_LENGTH,wt.width),g.pixelStorei(U.UNPACK_IMAGE_HEIGHT,wt.height),g.pixelStorei(U.UNPACK_SKIP_PIXELS,Ne),g.pixelStorei(U.UNPACK_SKIP_ROWS,Xe),g.pixelStorei(U.UNPACK_SKIP_IMAGES,Ze);const wi=M.isDataArrayTexture||M.isData3DTexture,xt=O.isDataArrayTexture||O.isData3DTexture;if(M.isDepthTexture){const Pt=B.get(M),Qn=B.get(O),Mt=B.get(Pt.__renderTarget),ei=B.get(Qn.__renderTarget);g.bindFramebuffer(U.READ_FRAMEBUFFER,Mt.__webglFramebuffer),g.bindFramebuffer(U.DRAW_FRAMEBUFFER,ei.__webglFramebuffer);for(let Ri=0;Ri<Pe;Ri++)wi&&(U.framebufferTextureLayer(U.READ_FRAMEBUFFER,U.COLOR_ATTACHMENT0,B.get(M).__webglTexture,H,Ze+Ri),U.framebufferTextureLayer(U.DRAW_FRAMEBUFFER,U.COLOR_ATTACHMENT0,B.get(O).__webglTexture,_e,Ct+Ri)),U.blitFramebuffer(Ne,Xe,Se,ve,Fe,pt,Se,ve,U.DEPTH_BUFFER_BIT,U.NEAREST);g.bindFramebuffer(U.READ_FRAMEBUFFER,null),g.bindFramebuffer(U.DRAW_FRAMEBUFFER,null)}else if(H!==0||M.isRenderTargetTexture||B.has(M)){const Pt=B.get(M),Qn=B.get(O);g.bindFramebuffer(U.READ_FRAMEBUFFER,j),g.bindFramebuffer(U.DRAW_FRAMEBUFFER,k);for(let Mt=0;Mt<Pe;Mt++)wi?U.framebufferTextureLayer(U.READ_FRAMEBUFFER,U.COLOR_ATTACHMENT0,Pt.__webglTexture,H,Ze+Mt):U.framebufferTexture2D(U.READ_FRAMEBUFFER,U.COLOR_ATTACHMENT0,U.TEXTURE_2D,Pt.__webglTexture,H),xt?U.framebufferTextureLayer(U.DRAW_FRAMEBUFFER,U.COLOR_ATTACHMENT0,Qn.__webglTexture,_e,Ct+Mt):U.framebufferTexture2D(U.DRAW_FRAMEBUFFER,U.COLOR_ATTACHMENT0,U.TEXTURE_2D,Qn.__webglTexture,_e),H!==0?U.blitFramebuffer(Ne,Xe,Se,ve,Fe,pt,Se,ve,U.COLOR_BUFFER_BIT,U.NEAREST):xt?U.copyTexSubImage3D(ye,_e,Fe,pt,Ct+Mt,Ne,Xe,Se,ve):U.copyTexSubImage2D(ye,_e,Fe,pt,Ne,Xe,Se,ve);g.bindFramebuffer(U.READ_FRAMEBUFFER,null),g.bindFramebuffer(U.DRAW_FRAMEBUFFER,null)}else xt?M.isDataTexture||M.isData3DTexture?U.texSubImage3D(ye,_e,Fe,pt,Ct,Se,ve,Pe,_t,Kt,wt.data):O.isCompressedArrayTexture?U.compressedTexSubImage3D(ye,_e,Fe,pt,Ct,Se,ve,Pe,_t,wt.data):U.texSubImage3D(ye,_e,Fe,pt,Ct,Se,ve,Pe,_t,Kt,wt):M.isDataTexture?U.texSubImage2D(U.TEXTURE_2D,_e,Fe,pt,Se,ve,_t,Kt,wt.data):M.isCompressedTexture?U.compressedTexSubImage2D(U.TEXTURE_2D,_e,Fe,pt,wt.width,wt.height,_t,wt.data):U.texSubImage2D(U.TEXTURE_2D,_e,Fe,pt,Se,ve,_t,Kt,wt);g.pixelStorei(U.UNPACK_ROW_LENGTH,nn),g.pixelStorei(U.UNPACK_IMAGE_HEIGHT,st),g.pixelStorei(U.UNPACK_SKIP_PIXELS,un),g.pixelStorei(U.UNPACK_SKIP_ROWS,bn),g.pixelStorei(U.UNPACK_SKIP_IMAGES,Jn),_e===0&&O.generateMipmaps&&U.generateMipmap(ye),g.unbindTexture()},this.initRenderTarget=function(M){B.get(M).__webglFramebuffer===void 0&&z.setupRenderTarget(M)},this.initTexture=function(M){M.isCubeTexture?z.setTextureCube(M,0):M.isData3DTexture?z.setTexture3D(M,0):M.isDataArrayTexture||M.isCompressedArrayTexture?z.setTexture2DArray(M,0):z.setTexture2D(M,0),g.unbindTexture()},this.resetState=function(){q=0,W=0,ee=null,g.reset(),ge.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Cn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=Qe._getDrawingBufferColorSpace(e),t.unpackColorSpace=Qe._getUnpackColorSpace()}}function Du(s){const e=n=>{let i=!1;return n.traverse(r=>{r instanceof bt&&(i=!0)}),i};let t=s;for(;!(t instanceof bt);){const n=(t.children??[]).filter(e);if(n.length!==1)return n;if(n[0].userData?.termdockSinglePart)return[n[0]];t=n[0]}return[t]}function Ax(s,e){const t=e.getCenter(new C),n=new C,i=new C,r=new C,a=new C,o=new C,l=new C,c=new C;let u=0,h=0;s.traverse(_=>{if(!(_ instanceof bt))return;const v=_.geometry.getAttribute("position");if(!v)return;const m=_.geometry.index,p=m?.count??v.count;for(let b=0;b+2<p;b+=3){r.fromBufferAttribute(v,m?m.getX(b):b).applyMatrix4(_.matrixWorld).sub(t),a.fromBufferAttribute(v,m?m.getX(b+1):b+1).applyMatrix4(_.matrixWorld).sub(t),o.fromBufferAttribute(v,m?m.getX(b+2):b+2).applyMatrix4(_.matrixWorld).sub(t);const T=r.dot(l.crossVectors(a,o));u+=T,n.addScaledVector(r,T/4).addScaledVector(a,T/4).addScaledVector(o,T/4),l.subVectors(a,r).cross(c.subVectors(o,r)),i.add(l),h+=l.length()}});const d=e.getSize(new C);if(Math.abs(u)<=d.x*d.y*d.z*1e-9||i.length()>h*1e-5)return t;const f=n.divideScalar(u).add(t);return e.containsPoint(f)?f:t}function wx(s){s.updateMatrixWorld(!0);const e=Du(s).map(l=>{const c=new Yt().setFromObject(l);return{node:l,position:l.position.clone(),matrix:l.matrix.clone(),autoUpdate:l.matrixAutoUpdate,box:c,center:Ax(l,c),offset:new C}}),n=new Yt().setFromObject(s).getSize(new C),i=Math.max(n.x,n.y,n.z,1e-6)*.002,r=Math.max(n.x,n.y,n.z,1e-6)*.12,a=new Map;for(const l of["x","y","z"]){const c=[],u=[...e].sort((v,m)=>v.box.min[l]-m.box.min[l]||m.box.max[l]-v.box.max[l])[0],h=[...e].sort((v,m)=>v===m?0:v===u?-1:m===u?1:v.center[l]-m.center[l]||m.box.max[l]-v.box.max[l]);for(const v of h){const m=c.find(p=>Math.abs(p.min-v.box.min[l])<=i&&Math.abs(p.max-v.box.max[l])<=i);m?m.parts.push(v):c.push({min:v.box.min[l],max:v.box.max[l],parts:[v]})}const d=new Map;let f=0,_=0;for(const[v,m]of c.entries()){const p=Math.min(...m.parts.map(T=>T.box.min[l])),b=Math.max(...m.parts.map(T=>T.box.max[l]));v>0&&(f+=Math.max(r,_-p+r));for(const T of m.parts)d.set(T,f);_=b}a.set(l,d)}const o=l=>{if(typeof l=="string"){const c=e.filter(u=>u.node.uuid===l||u.node.name===l||u.node.userData.termdockPartName===l);return c.length===1?c[0]:void 0}for(let c=l;c;c=c.parent??void 0){const u=e.find(h=>h.node===c);if(u)return u}};return{count:e.length,part:l=>o(l)?.node,offset:l=>o(l)?.offset.clone()??new C,set(l){const c=l&&Number.isFinite(l.amount)?Math.max(0,Math.min(1,l.amount)):0,u=l?.axis??"y";for(const h of e)if(h.offset.set(0,0,0),h.offset[u]=(a.get(u)?.get(h)??0)*c,h.node.position.copy(h.position),h.node.matrix.copy(h.matrix),c>0){const d=h.node.parent?.matrixWorld.clone().invert()??new We,f=h.offset.clone().applyMatrix4(d).sub(new C().applyMatrix4(d));h.node.position.add(f),h.autoUpdate?h.node.updateMatrix():h.node.matrix.premultiply(new We().makeTranslation(f.x,f.y,f.z))}return s.updateMatrixWorld(!0),new Yt().setFromObject(s)}}}function Rx(s,e){return[s&&s.amount>0?`Exploded ${s.axis.toUpperCase()} ${Math.round(s.amount*100)}%; assembled coordinates`:"",e?`Section ${e.axis.toUpperCase()} ${Math.round(e.value01*100)}%${e.flip?" flipped":""}`:""].filter(Boolean).join(" / ")}function Nc(s,e){if(e.type==="reset")return{hidden:[],history:[]};if(e.type==="undo")return s.history.length?{hidden:s.history[s.history.length-1],history:s.history.slice(0,-1)}:s;const t=e.type==="toggle"?s.hidden.includes(e.id)?s.hidden.filter(n=>n!==e.id):[...s.hidden,e.id]:[...new Set(e.hidden)];return t.length===s.hidden.length&&t.every(n=>s.hidden.includes(n))?s:{hidden:t,history:[...s.history.slice(-19),s.hidden]}}function _i(s){for(let e=s;e;e=e.parent)if(!e.visible)return!1;return!0}function Cx(s){const e=Du(s).map((n,i)=>({node:n,id:`part-${i}`,visible:n.visible})),t=new Map(e.map(n=>[n.node,n]));return{parts:e.map(({id:n,node:i,visible:r})=>({id:n,name:i.userData.termdockPartName||i.name,initiallyVisible:r})),node:n=>e.find(i=>i.id===n)?.node,id(n){for(let i=n;i;i=i.parent){const r=t.get(i);if(r)return r.id}},setHidden(n){const i=new Set(n);for(const r of e)r.node.visible=r.visible&&!i.has(r.id)},isPartVisible(n){if(!n)return!0;const i=e.filter(({node:r})=>r.uuid===n||r.name===n||r.userData.termdockPartName===n);return i.length===0||i.some(({node:r})=>_i(r))}}}function Px({parts:s,hidden:e,selected:t,wide:n,canUndo:i,onSelect:r,onToggle:a,onIsolate:o,onShowAll:l,onUndo:c,onClose:u}){const{t:h}=Do(),[d,f]=we.useState(""),[_,v]=we.useState(!1),m=we.useRef(null);we.useEffect(()=>{const b=m.current,T=b?.querySelector(`[data-part-id="${t}"]`);!b||!T||(T.offsetTop<b.scrollTop?b.scrollTop=T.offsetTop:T.offsetTop+T.offsetHeight>b.scrollTop+b.clientHeight&&(b.scrollTop=T.offsetTop+T.offsetHeight-b.clientHeight))},[t]);const p=s.filter(b=>b.name.toLocaleLowerCase().includes(d.trim().toLocaleLowerCase())&&(!_||e.includes(b.id)));return ie.jsxs("section",{"aria-label":h("rightSidebar.model3dParts"),className:`swiper-no-swiping relative z-20 flex min-h-0 shrink-0 flex-col bg-surface ${n?"h-full w-72 border-l border-border/30":"h-[42%] border-t border-border/30"}`,onPointerDown:b=>b.stopPropagation(),onTouchStart:b=>b.stopPropagation(),children:[ie.jsxs("div",{className:"flex shrink-0 items-center gap-2 px-3 pt-1",children:[ie.jsxs("h3",{className:"min-w-0 flex-1 text-sm font-medium text-foreground",children:[h("rightSidebar.model3dParts")," ",ie.jsxs("span",{className:"text-xs text-muted-foreground",children:[s.length-e.length,"/",s.length]})]}),ie.jsx("button",{type:"button",onClick:u,"aria-label":h("rightSidebar.model3dCloseParts"),className:"inline-flex h-10 w-10 items-center justify-center rounded-lg text-muted-foreground hover:bg-surface-2",children:ie.jsx(Da,{size:18})})]}),ie.jsxs("div",{className:"flex shrink-0 items-center gap-2 px-3 pb-2",children:[ie.jsxs("div",{className:"flex h-9 min-w-0 flex-1 items-center gap-2 rounded-lg bg-surface-2 px-2 text-muted-foreground",children:[ie.jsx(Vu,{size:14,className:"shrink-0"}),ie.jsx("input",{value:d,onChange:b=>f(b.target.value),placeholder:h("rightSidebar.model3dSearchParts"),"aria-label":h("rightSidebar.model3dSearchParts"),onKeyDown:b=>{b.key==="Enter"&&b.currentTarget.blur()},className:"min-w-0 flex-1 bg-transparent text-sm text-foreground outline-none"}),d&&ie.jsx("button",{type:"button","aria-label":h("rightSidebar.model3dClearPartSearch"),onClick:()=>f(""),className:"inline-flex h-9 w-7 shrink-0 items-center justify-center",children:ie.jsx(Da,{size:14})})]}),ie.jsx("button",{type:"button","aria-pressed":_,onClick:()=>v(b=>!b),className:`h-9 shrink-0 rounded-lg px-2 text-xs ${_?"bg-accent/15 text-accent":"bg-surface-2 text-muted-foreground"}`,children:h("rightSidebar.model3dHiddenParts",{count:e.length})})]}),ie.jsxs("div",{ref:m,className:"relative min-h-0 flex-1 overflow-y-auto overscroll-contain px-2",role:"list","aria-label":h("rightSidebar.model3dParts"),children:[p.map(b=>{const T=e.includes(b.id);return ie.jsxs("div",{"data-part-id":b.id,role:"listitem",className:`flex min-h-11 items-center rounded-lg ${t===b.id?"bg-accent/10":"hover:bg-surface-2"}`,children:[ie.jsx("button",{type:"button",onClick:()=>r(b.id),"aria-pressed":t===b.id,title:b.name,className:`min-h-11 min-w-0 flex-1 px-2 py-2 text-left text-sm leading-snug ${T?"text-muted-foreground":"text-foreground"}`,children:ie.jsx("span",{className:"line-clamp-2 break-words",children:b.name})}),ie.jsx("button",{type:"button",onClick:()=>a(b.id),"aria-label":h(T?"rightSidebar.model3dShowNamedPart":"rightSidebar.model3dHideNamedPart",{name:b.name}),title:h(T?"rightSidebar.model3dShowNamedPart":"rightSidebar.model3dHideNamedPart",{name:b.name}),className:`inline-flex h-11 w-11 shrink-0 items-center justify-center rounded-lg hover:bg-surface-elevated ${T?"text-muted-foreground":"text-foreground"}`,children:T?ie.jsx(Yc,{size:18}):ie.jsx(qc,{size:18})}),ie.jsx("button",{type:"button",onClick:()=>o(b.id),"aria-label":h("rightSidebar.model3dIsolateNamedPart",{name:b.name}),title:h("rightSidebar.model3dIsolateNamedPart",{name:b.name}),className:"inline-flex h-11 w-11 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-surface-elevated hover:text-foreground",children:ie.jsx(Kc,{size:17})})]},b.id)}),p.length===0&&ie.jsx("p",{className:"px-2 py-5 text-center text-sm text-muted-foreground",children:h("rightSidebar.model3dNoParts")})]}),ie.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-t border-border/20 px-3 py-1 pb-[max(0.25rem,env(safe-area-inset-bottom,0px))]",children:[ie.jsxs("button",{type:"button",onClick:c,disabled:!i,className:"inline-flex h-10 items-center gap-1 rounded-lg px-2 text-sm text-foreground disabled:opacity-40",children:[ie.jsx(Na,{size:15}),h("rightSidebar.model3dUndoVisibility")]}),ie.jsx("button",{type:"button",onClick:l,disabled:e.length===0,className:"ml-auto h-10 rounded-lg px-2 text-sm text-foreground disabled:opacity-40",children:h("rightSidebar.model3dShowAllParts",{count:e.length})})]})]})}function Lx({dark:s,onToggleBackground:e,onRefresh:t,onView:n}){const{t:i}=Do(),[r,a]=we.useState(!1),o=we.useRef(null),l=we.useRef(null),c=we.useRef(null);we.useEffect(()=>{if(!r)return;c.current?.focus();const h=d=>{o.current?.contains(d.target)||a(!1)};return document.addEventListener("pointerdown",h),()=>document.removeEventListener("pointerdown",h)},[r]);const u=()=>{a(!1),l.current?.focus()};return ie.jsxs("div",{ref:o,"data-model-viewer-menu":r?"open":"closed",className:"relative z-20 shrink-0",onKeyDown:h=>{h.key==="Escape"&&r&&(h.preventDefault(),h.stopPropagation(),u())},children:[ie.jsx("button",{ref:l,type:"button","aria-label":i("rightSidebar.model3dMore"),"aria-expanded":r,onClick:()=>a(h=>!h),className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground hover:bg-surface-elevated",children:ie.jsx(ku,{size:17})}),r&&ie.jsxs("div",{className:"absolute right-0 top-full z-30 mt-2 w-48 rounded-xl border border-border/30 bg-surface p-1 shadow-lg",children:[ie.jsxs("button",{ref:c,type:"button",onClick:()=>{e(),u()},className:"flex min-h-11 w-full items-center gap-2 rounded-lg px-3 text-left text-sm text-foreground hover:bg-surface-2",children:[s?ie.jsx(Hu,{size:16}):ie.jsx(Gu,{size:16}),i(s?"rightSidebar.model3dBgToLight":"rightSidebar.model3dBgToDark")]}),n&&["fit","front","top","right"].map(h=>ie.jsx("button",{type:"button",onClick:()=>{u(),n(h)},className:"flex min-h-11 w-full items-center rounded-lg px-3 text-left text-sm text-foreground hover:bg-surface-2",children:i(h==="fit"?"rightSidebar.model3dFit":h==="front"?"rightSidebar.model3dFront":h==="top"?"rightSidebar.model3dTop":"rightSidebar.model3dRight")},h)),t&&ie.jsxs("button",{type:"button",onClick:()=>{u(),t()},className:"flex min-h-11 w-full items-center gap-2 rounded-lg px-3 text-left text-sm text-foreground hover:bg-surface-2",children:[ie.jsx(Wu,{size:16}),i("rightSidebar.model3dRefresh")]})]})]})}const Uc={type:"change"},rl={type:"start"},Nu={type:"end"},vr=new rs,Fc=new Xn,Ix=Math.cos(70*fu.DEG2RAD),Ft=new C,en=2*Math.PI,mt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},wa=1e-6;class Dx extends Cf{constructor(e,t=null){super(e,t),this.state=mt.NONE,this.target=new C,this.cursor=new C,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Yi.ROTATE,MIDDLE:Yi.DOLLY,RIGHT:Yi.PAN},this.touches={ONE:Xi.ROTATE,TWO:Xi.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new C,this._lastQuaternion=new Sn,this._lastTargetPosition=new C,this._quat=new Sn().setFromUnitVectors(e.up,new C(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new lc,this._sphericalDelta=new lc,this._scale=1,this._panOffset=new C,this._rotateStart=new ke,this._rotateEnd=new ke,this._rotateDelta=new ke,this._panStart=new ke,this._panEnd=new ke,this._panDelta=new ke,this._dollyStart=new ke,this._dollyEnd=new ke,this._dollyDelta=new ke,this._dollyDirection=new C,this._mouse=new ke,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Ux.bind(this),this._onPointerDown=Nx.bind(this),this._onPointerUp=Fx.bind(this),this._onContextMenu=Gx.bind(this),this._onMouseWheel=kx.bind(this),this._onKeyDown=zx.bind(this),this._onTouchStart=Vx.bind(this),this._onTouchMove=Hx.bind(this),this._onMouseDown=Ox.bind(this),this._onMouseMove=Bx.bind(this),this._interceptControlDown=Wx.bind(this),this._interceptControlUp=Xx.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(e){this._cursorStyle=e,e==="grab"?this.domElement.style.cursor="grab":this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction=""}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Uc),this.update(),this.state=mt.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){const t=this.object.position;Ft.copy(t).sub(this.target),Ft.applyQuaternion(this._quat),this._spherical.setFromVector3(Ft),this.autoRotate&&this.state===mt.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(n)&&isFinite(i)&&(n<-Math.PI?n+=en:n>Math.PI&&(n-=en),i<-Math.PI?i+=en:i>Math.PI&&(i-=en),n<=i?this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=a!=this._spherical.radius}if(Ft.setFromSpherical(this._spherical),Ft.applyQuaternion(this._quatInverse),t.copy(this.target).add(Ft),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=Ft.length();a=this._clampDistance(o*this._scale);const l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){const o=new C(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;const c=new C(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=Ft.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(vr.origin.copy(this.object.position),vr.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(vr.direction))<Ix?this.object.lookAt(this.target):(Fc.setFromNormalAndCoplanarPoint(this.object.up,this.target),vr.intersectPlane(Fc,this.target))))}else if(this.object.isOrthographicCamera){const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>wa||8*(1-this._lastQuaternion.dot(this.object.quaternion))>wa||this._lastTargetPosition.distanceToSquared(this.target)>wa?(this.dispatchEvent(Uc),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?en/60*this.autoRotateSpeed*e:en/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Ft.setFromMatrixColumn(t,0),Ft.multiplyScalar(-e),this._panOffset.add(Ft)}_panUp(e,t){this.screenSpacePanning===!0?Ft.setFromMatrixColumn(t,1):(Ft.setFromMatrixColumn(t,0),Ft.crossVectors(this.object.up,Ft)),Ft.multiplyScalar(e),this._panOffset.add(Ft)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;Ft.copy(i).sub(this.target);let r=Ft.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),i=e-n.left,r=t-n.top,a=n.width,o=n.height;this._mouse.x=i/a*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(en*this._rotateDelta.x/t.clientHeight),this._rotateUp(en*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(en*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-en*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(en*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-en*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panStart.set(n,i)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),i=.5*(e.pageX+n.x),r=.5*(e.pageY+n.y);this._rotateEnd.set(i,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(en*this._rotateDelta.x/t.clientHeight),this._rotateUp(en*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new ke,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function Nx(s){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(s.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(s)&&(this._addPointer(s),s.pointerType==="touch"?this._onTouchStart(s):this._onMouseDown(s),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function Ux(s){this.enabled!==!1&&(s.pointerType==="touch"?this._onTouchMove(s):this._onMouseMove(s))}function Fx(s){switch(this._removePointer(s),this._pointers.length){case 0:this.domElement.releasePointerCapture(s.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Nu),this.state=mt.NONE,this._cursorStyle==="grab"&&(this.domElement.style.cursor="grab");break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function Ox(s){let e;switch(s.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case Yi.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(s),this.state=mt.DOLLY;break;case Yi.ROTATE:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=mt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=mt.ROTATE}break;case Yi.PAN:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=mt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=mt.PAN}break;default:this.state=mt.NONE}this.state!==mt.NONE&&this.dispatchEvent(rl)}function Bx(s){switch(this.state){case mt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(s);break;case mt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(s);break;case mt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(s);break}}function kx(s){this.enabled===!1||this.enableZoom===!1||this.state!==mt.NONE||(s.preventDefault(),this.dispatchEvent(rl),this._handleMouseWheel(this._customWheelEvent(s)),this.dispatchEvent(Nu))}function zx(s){this.enabled!==!1&&this._handleKeyDown(s)}function Vx(s){switch(this._trackPointer(s),this._pointers.length){case 1:switch(this.touches.ONE){case Xi.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(s),this.state=mt.TOUCH_ROTATE;break;case Xi.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(s),this.state=mt.TOUCH_PAN;break;default:this.state=mt.NONE}break;case 2:switch(this.touches.TWO){case Xi.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(s),this.state=mt.TOUCH_DOLLY_PAN;break;case Xi.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(s),this.state=mt.TOUCH_DOLLY_ROTATE;break;default:this.state=mt.NONE}break;default:this.state=mt.NONE}this.state!==mt.NONE&&this.dispatchEvent(rl)}function Hx(s){switch(this._trackPointer(s),this.state){case mt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(s),this.update();break;case mt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(s),this.update();break;case mt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(s),this.update();break;case mt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(s),this.update();break;default:this.state=mt.NONE}}function Gx(s){this.enabled!==!1&&s.preventDefault()}function Wx(s){s.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Xx(s){s.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Oc(s,e){if(e===Ih)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),s;if(e===So||e===hu){let t=s.getIndex();if(t===null){const a=[],o=s.getAttribute("position");if(o!==void 0){for(let l=0;l<o.count;l++)a.push(l);s.setIndex(a),t=s.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),s}const n=t.count-2,i=[];if(e===So)for(let a=1;a<=n;a++)i.push(t.getX(0)),i.push(t.getX(a)),i.push(t.getX(a+1));else for(let a=0;a<n;a++)a%2===0?(i.push(t.getX(a)),i.push(t.getX(a+1)),i.push(t.getX(a+2))):(i.push(t.getX(a+2)),i.push(t.getX(a+1)),i.push(t.getX(a)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=s.clone();return r.setIndex(i),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),s}function Yx(s){const e=new Map,t=new Map,n=s.clone();return Uu(s,n,function(i,r){e.set(r,i),t.set(i,r)}),n.traverse(function(i){if(!i.isSkinnedMesh)return;const r=i,a=e.get(i),o=a.skeleton.bones;r.skeleton=a.skeleton.clone(),r.bindMatrix.copy(a.bindMatrix),r.skeleton.bones=o.map(function(l){return t.get(l)}),r.bind(r.skeleton,r.bindMatrix)}),n}function Uu(s,e,t){t(s,e);for(let n=0;n<s.children.length;n++)Uu(s.children[n],e.children[n],t)}class qx extends Ti{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Jx(t)}),this.register(function(t){return new Qx(t)}),this.register(function(t){return new l0(t)}),this.register(function(t){return new c0(t)}),this.register(function(t){return new u0(t)}),this.register(function(t){return new t0(t)}),this.register(function(t){return new n0(t)}),this.register(function(t){return new i0(t)}),this.register(function(t){return new s0(t)}),this.register(function(t){return new jx(t)}),this.register(function(t){return new r0(t)}),this.register(function(t){return new e0(t)}),this.register(function(t){return new o0(t)}),this.register(function(t){return new a0(t)}),this.register(function(t){return new Zx(t)}),this.register(function(t){return new Bc(t,Je.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Bc(t,Je.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new h0(t)})}load(e,t,n,i){const r=this;let a;if(this.resourcePath!=="")a=this.resourcePath;else if(this.path!==""){const c=Is.extractUrlBase(e);a=Is.resolveURL(c,this.path)}else a=Is.extractUrlBase(e);this.manager.itemStart(e);const o=function(c){i?i(c):console.error(c),r.manager.itemError(e),r.manager.itemEnd(e)},l=new tl(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(c){try{r.parse(c,a,function(u){t(u),r.manager.itemEnd(e)},o)}catch(u){o(u)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){let r;const a={},o={},l=new TextDecoder;if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===Fu){try{a[Je.KHR_BINARY_GLTF]=new d0(e)}catch(h){i&&i(h);return}r=JSON.parse(a[Je.KHR_BINARY_GLTF].content)}else r=JSON.parse(l.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new T0(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u<this.pluginCallbacks.length;u++){const h=this.pluginCallbacks[u](c);h.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),o[h.name]=h,a[h.name]=!0}if(r.extensionsUsed)for(let u=0;u<r.extensionsUsed.length;++u){const h=r.extensionsUsed[u],d=r.extensionsRequired||[];switch(h){case Je.KHR_MATERIALS_UNLIT:a[h]=new $x;break;case Je.KHR_DRACO_MESH_COMPRESSION:a[h]=new f0(r,this.dracoLoader);break;case Je.KHR_TEXTURE_TRANSFORM:a[h]=new p0;break;case Je.KHR_MESH_QUANTIZATION:a[h]=new m0;break;default:d.indexOf(h)>=0&&o[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}c.setExtensions(a),c.setPlugins(o),c.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}}function Kx(){let s={};return{get:function(e){return s[e]},add:function(e,t){s[e]=t},remove:function(e){delete s[e]},removeAll:function(){s={}}}}function It(s,e,t){const n=s.json.materials[e];return n.extensions&&n.extensions[t]?n.extensions[t]:null}const Je={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Zx{constructor(e){this.parser=e,this.name=Je.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const r=t.json,l=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let c;const u=new Ue(16777215);l.color!==void 0&&u.setRGB(l.color[0],l.color[1],l.color[2],ln);const h=l.range!==void 0?l.range:0;switch(l.type){case"directional":c=new Ao(u),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new hf(u),c.distance=h;break;case"spot":c=new cf(u),c.distance=h,l.spot=l.spot||{},l.spot.innerConeAngle=l.spot.innerConeAngle!==void 0?l.spot.innerConeAngle:0,l.spot.outerConeAngle=l.spot.outerConeAngle!==void 0?l.spot.outerConeAngle:Math.PI/4,c.angle=l.spot.outerConeAngle,c.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return c.position.set(0,0,0),An(c,l),l.intensity!==void 0&&(c.intensity=l.intensity),c.name=t.createUniqueName(l.name||"light_"+e),i=Promise.resolve(c),t.cache.add(n,i),i}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,r=n.json.nodes[e],o=(r.extensions&&r.extensions[this.name]||{}).light;return o===void 0?null:this._loadLight(o).then(function(l){return n._getNodeRef(t.cache,o,l)})}}class $x{constructor(){this.name=Je.KHR_MATERIALS_UNLIT}getMaterialType(){return yi}extendParams(e,t,n){const i=[];e.color=new Ue(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const a=r.baseColorFactor;e.color.setRGB(a[0],a[1],a[2],ln),e.opacity=a[3]}r.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",r.baseColorTexture,Ht))}return Promise.all(i)}}class jx{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=It(this.parser,e,this.name);return n===null||n.emissiveStrength!==void 0&&(t.emissiveIntensity=n.emissiveStrength),Promise.resolve()}}class Jx{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return It(this.parser,e,this.name)!==null?On:null}extendMaterialParams(e,t){const n=It(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];if(n.clearcoatFactor!==void 0&&(t.clearcoat=n.clearcoatFactor),n.clearcoatTexture!==void 0&&i.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture)),n.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=n.clearcoatRoughnessFactor),n.clearcoatRoughnessTexture!==void 0&&i.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture)),n.clearcoatNormalTexture!==void 0&&(i.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0)){const r=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new ke(r,r)}return Promise.all(i)}}class Qx{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_DISPERSION}getMaterialType(e){return It(this.parser,e,this.name)!==null?On:null}extendMaterialParams(e,t){const n=It(this.parser,e,this.name);return n===null||(t.dispersion=n.dispersion!==void 0?n.dispersion:0),Promise.resolve()}}class e0{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return It(this.parser,e,this.name)!==null?On:null}extendMaterialParams(e,t){const n=It(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];return n.iridescenceFactor!==void 0&&(t.iridescence=n.iridescenceFactor),n.iridescenceTexture!==void 0&&i.push(this.parser.assignTexture(t,"iridescenceMap",n.iridescenceTexture)),n.iridescenceIor!==void 0&&(t.iridescenceIOR=n.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),n.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum),n.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum),n.iridescenceThicknessTexture!==void 0&&i.push(this.parser.assignTexture(t,"iridescenceThicknessMap",n.iridescenceThicknessTexture)),Promise.all(i)}}class t0{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_SHEEN}getMaterialType(e){return It(this.parser,e,this.name)!==null?On:null}extendMaterialParams(e,t){const n=It(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];if(t.sheenColor=new Ue(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){const r=n.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],ln)}return n.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&i.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,Ht)),n.sheenRoughnessTexture!==void 0&&i.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture)),Promise.all(i)}}class n0{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return It(this.parser,e,this.name)!==null?On:null}extendMaterialParams(e,t){const n=It(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];return n.transmissionFactor!==void 0&&(t.transmission=n.transmissionFactor),n.transmissionTexture!==void 0&&i.push(this.parser.assignTexture(t,"transmissionMap",n.transmissionTexture)),Promise.all(i)}}class i0{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_VOLUME}getMaterialType(e){return It(this.parser,e,this.name)!==null?On:null}extendMaterialParams(e,t){const n=It(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0&&i.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture)),t.attenuationDistance=n.attenuationDistance||1/0;const r=n.attenuationColor||[1,1,1];return t.attenuationColor=new Ue().setRGB(r[0],r[1],r[2],ln),Promise.all(i)}}class s0{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_IOR}getMaterialType(e){return It(this.parser,e,this.name)!==null?On:null}extendMaterialParams(e,t){const n=It(this.parser,e,this.name);return n===null||(t.ior=n.ior!==void 0?n.ior:1.5,t.ior===0&&(t.ior=1e3)),Promise.resolve()}}class r0{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_SPECULAR}getMaterialType(e){return It(this.parser,e,this.name)!==null?On:null}extendMaterialParams(e,t){const n=It(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0&&i.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));const r=n.specularColorFactor||[1,1,1];return t.specularColor=new Ue().setRGB(r[0],r[1],r[2],ln),n.specularColorTexture!==void 0&&i.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,Ht)),Promise.all(i)}}class a0{constructor(e){this.parser=e,this.name=Je.EXT_MATERIALS_BUMP}getMaterialType(e){return It(this.parser,e,this.name)!==null?On:null}extendMaterialParams(e,t){const n=It(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];return t.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0&&i.push(this.parser.assignTexture(t,"bumpMap",n.bumpTexture)),Promise.all(i)}}class o0{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return It(this.parser,e,this.name)!==null?On:null}extendMaterialParams(e,t){const n=It(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];return n.anisotropyStrength!==void 0&&(t.anisotropy=n.anisotropyStrength),n.anisotropyRotation!==void 0&&(t.anisotropyRotation=n.anisotropyRotation),n.anisotropyTexture!==void 0&&i.push(this.parser.assignTexture(t,"anisotropyMap",n.anisotropyTexture)),Promise.all(i)}}class l0{constructor(e){this.parser=e,this.name=Je.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const r=i.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,a)}}class c0{constructor(e){this.parser=e,this.name=Je.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const a=r.extensions[t],o=i.images[a.source];let l=n.textureLoader;if(o.uri){const c=n.options.manager.getHandler(o.uri);c!==null&&(l=c)}return n.loadTextureImage(e,a.source,l)}}class u0{constructor(e){this.parser=e,this.name=Je.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const a=r.extensions[t],o=i.images[a.source];let l=n.textureLoader;if(o.uri){const c=n.options.manager.getHandler(o.uri);c!==null&&(l=c)}return n.loadTextureImage(e,a.source,l)}}class Bc{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),a=this.parser.options.meshoptDecoder;if(!a||!a.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(o){const l=i.byteOffset||0,c=i.byteLength||0,u=i.count,h=i.byteStride,d=new Uint8Array(o,l,c);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(u,h,d,i.mode,i.filter).then(function(f){return f.buffer}):a.ready.then(function(){const f=new ArrayBuffer(u*h);return a.decodeGltfBuffer(new Uint8Array(f),u,h,d,i.mode,i.filter),f})})}else return null}}class h0{constructor(e){this.name=Je.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const i=t.meshes[n.mesh];for(const c of i.primitives)if(c.mode!==dn.TRIANGLES&&c.mode!==dn.TRIANGLE_STRIP&&c.mode!==dn.TRIANGLE_FAN&&c.mode!==void 0)return null;const a=n.extensions[this.name].attributes,o=[],l={};for(const c in a)o.push(this.parser.getDependency("accessor",a[c]).then(u=>(l[c]=u,l[c])));return o.length<1?null:(o.push(this.parser.createNodeMesh(e)),Promise.all(o).then(c=>{const u=c.pop(),h=u.isGroup?u.children:[u],d=c[0].count,f=[];for(const _ of h){const v=new We,m=new C,p=new Sn,b=new C(1,1,1),T=new Id(_.geometry,_.material,d);for(let S=0;S<d;S++)l.TRANSLATION&&m.fromBufferAttribute(l.TRANSLATION,S),l.ROTATION&&p.fromBufferAttribute(l.ROTATION,S),l.SCALE&&b.fromBufferAttribute(l.SCALE,S),T.setMatrixAt(S,v.compose(m,p,b));for(const S in l)if(S==="_COLOR_0"){const w=l[S];T.instanceColor=new Eo(w.array,w.itemSize,w.normalized)}else S!=="TRANSLATION"&&S!=="ROTATION"&&S!=="SCALE"&&_.geometry.setAttribute(S,l[S]);At.prototype.copy.call(T,_),this.parser.assignFinalMaterial(T),f.push(T)}return u.isGroup?(u.clear(),u.add(...f),u):f[0]}))}}const Fu="glTF",As=12,kc={JSON:1313821514,BIN:5130562};class d0{constructor(e){this.name=Je.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,As),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Fu)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-As,r=new DataView(e,As);let a=0;for(;a<i;){const o=r.getUint32(a,!0);a+=4;const l=r.getUint32(a,!0);if(a+=4,l===kc.JSON){const c=new Uint8Array(e,As+a,o);this.content=n.decode(c)}else if(l===kc.BIN){const c=As+a;this.body=e.slice(c,c+o)}a+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class f0{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Je.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},l={},c={};for(const u in a){const h=Po[u]||u.toLowerCase();o[h]=a[u]}for(const u in e.attributes){const h=Po[u]||u.toLowerCase();if(a[u]!==void 0){const d=n.accessors[e.attributes[u]],f=ji[d.componentType];c[h]=f.name,l[h]=d.normalized===!0}}return t.getDependency("bufferView",r).then(function(u){return new Promise(function(h,d){i.decodeDracoFile(u,function(f){for(const _ in f.attributes){const v=f.attributes[_],m=l[_];m!==void 0&&(v.normalized=m)}h(f)},o,c,ln,d)})})}}class p0{constructor(){this.name=Je.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class m0{constructor(){this.name=Je.KHR_MESH_QUANTIZATION}}class Ou extends as{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let a=0;a!==i;a++)t[a]=n[r+a];return t}interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=o*2,c=o*3,u=i-t,h=(n-t)/u,d=h*h,f=d*h,_=e*c,v=_-c,m=-2*f+3*d,p=f-d,b=1-m,T=p-d+h;for(let S=0;S!==o;S++){const w=a[v+S+o],E=a[v+S+l]*u,R=a[_+S+o],x=a[_+S]*u;r[S]=b*w+T*E+m*R+p*x}return r}}const g0=new Sn;class _0 extends Ou{interpolate_(e,t,n,i){const r=super.interpolate_(e,t,n,i);return g0.fromArray(r).normalize().toArray(r),r}}const dn={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},ji={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},zc={9728:Ot,9729:Bt,9984:su,9985:yr,9986:Rs,9987:Yn},Vc={33071:Rn,33648:Rr,10497:es},Ra={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Po={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},oi={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},x0={CUBICSPLINE:void 0,LINEAR:Fs,STEP:Us},Ca={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function v0(s){return s.DefaultMaterial===void 0&&(s.DefaultMaterial=new $i({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Dn})),s.DefaultMaterial}function gi(s,e,t){for(const n in t.extensions)s[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function An(s,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(s.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function M0(s,e,t){let n=!1,i=!1,r=!1;for(let c=0,u=e.length;c<u;c++){const h=e[c];if(h.POSITION!==void 0&&(n=!0),h.NORMAL!==void 0&&(i=!0),h.COLOR_0!==void 0&&(r=!0),n&&i&&r)break}if(!n&&!i&&!r)return Promise.resolve(s);const a=[],o=[],l=[];for(let c=0,u=e.length;c<u;c++){const h=e[c];if(n){const d=h.POSITION!==void 0?t.getDependency("accessor",h.POSITION):s.attributes.position;a.push(d)}if(i){const d=h.NORMAL!==void 0?t.getDependency("accessor",h.NORMAL):s.attributes.normal;o.push(d)}if(r){const d=h.COLOR_0!==void 0?t.getDependency("accessor",h.COLOR_0):s.attributes.color;l.push(d)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l)]).then(function(c){const u=c[0],h=c[1],d=c[2];return n&&(s.morphAttributes.position=u),i&&(s.morphAttributes.normal=h),r&&(s.morphAttributes.color=d),s.morphTargetsRelative=!0,s})}function S0(s,e){if(s.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)s.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(s.morphTargetInfluences.length===t.length){s.morphTargetDictionary={};for(let n=0,i=t.length;n<i;n++)s.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function y0(s){let e;const t=s.extensions&&s.extensions[Je.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Pa(t.attributes):e=s.indices+":"+Pa(s.attributes)+":"+s.mode,s.targets!==void 0)for(let n=0,i=s.targets.length;n<i;n++)e+=":"+Pa(s.targets[n]);return e}function Pa(s){let e="";const t=Object.keys(s).sort();for(let n=0,i=t.length;n<i;n++)e+=t[n]+":"+s[t[n]]+";";return e}function Lo(s){switch(s){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function b0(s){return s.search(/\.jpe?g($|\?)/i)>0||s.search(/^data\:image\/jpeg/)===0?"image/jpeg":s.search(/\.webp($|\?)/i)>0||s.search(/^data\:image\/webp/)===0?"image/webp":s.search(/\.ktx2($|\?)/i)>0||s.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const E0=new We;class T0{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Kx,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,r=!1,a=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){const o=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(o)===!0;const l=o.match(/Version\/(\d+)/);i=n&&l?parseInt(l[1],10):-1,r=o.indexOf("Firefox")>-1,a=r?o.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&i<17||r&&a<98?this.textureLoader=new of(this.options.manager):this.textureLoader=new pf(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new tl(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(a){return a._markDefs&&a._markDefs()}),Promise.all(this._invokeAll(function(a){return a.beforeRoot&&a.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(a){const o={scene:a[0][i.scene||0],scenes:a[0],animations:a[1],cameras:a[2],asset:i.asset,parser:n,userData:{}};return gi(r,o,i),An(o,i),Promise.all(n._invokeAll(function(l){return l.afterRoot&&l.afterRoot(o)})).then(function(){for(const l of o.scenes)l.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=t.length;i<r;i++){const a=t[i].joints;for(let o=0,l=a.length;o<l;o++)e[a[o]].isBone=!0}for(let i=0,r=e.length;i<r;i++){const a=e[i];a.mesh!==void 0&&(this._addNodeRef(this.meshCache,a.mesh),a.skin!==void 0&&(n[a.mesh].isSkinnedMesh=!0)),a.camera!==void 0&&this._addNodeRef(this.cameraCache,a.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const i=n.clone(),r=(a,o)=>{const l=this.associations.get(a);l!=null&&this.associations.set(o,l);for(const[c,u]of a.children.entries())r(u,o.children[c])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const r=e(t[i]);r&&n.push(r)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!i)throw new Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(r,a){return n.getDependency(e,a)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Je.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(r,a){n.load(Is.resolveURL(t.uri,i.path),r,void 0,function(){a(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const i=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+i)})}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){const a=Ra[i.type],o=ji[i.componentType],l=i.normalized===!0,c=new o(i.count*a);return Promise.resolve(new Nt(c,a,l))}const r=[];return i.bufferView!==void 0?r.push(this.getDependency("bufferView",i.bufferView)):r.push(null),i.sparse!==void 0&&(r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(r).then(function(a){const o=a[0],l=Ra[i.type],c=ji[i.componentType],u=c.BYTES_PER_ELEMENT,h=u*l,d=i.byteOffset||0,f=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,_=i.normalized===!0;let v,m;if(f&&f!==h){const p=Math.floor(d/f),b="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+p+":"+i.count;let T=t.cache.get(b);T||(v=new c(o,p*f,i.count*f/u),T=new Td(v,f/u),t.cache.add(b,T)),m=new qo(T,l,d%f/u,_)}else o===null?v=new c(i.count*l):v=new c(o,d,i.count*l),m=new Nt(v,l,_);if(i.sparse!==void 0){const p=Ra.SCALAR,b=ji[i.sparse.indices.componentType],T=i.sparse.indices.byteOffset||0,S=i.sparse.values.byteOffset||0,w=new b(a[1],T,i.sparse.count*p),E=new c(a[2],S,i.sparse.count*l);o!==null&&(m=new Nt(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let R=0,x=w.length;R<x;R++){const A=w[R];if(m.setX(A,E[R*l]),l>=2&&m.setY(A,E[R*l+1]),l>=3&&m.setZ(A,E[R*l+2]),l>=4&&m.setW(A,E[R*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=_}return m})}loadTexture(e){const t=this.json,n=this.options,r=t.textures[e].source,a=t.images[r];let o=this.textureLoader;if(a.uri){const l=n.manager.getHandler(a.uri);l!==null&&(o=l)}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,n){const i=this,r=this.json,a=r.textures[e],o=r.images[t],l=(o.uri||o.bufferView)+":"+a.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,n).then(function(u){u.flipY=!1,u.name=a.name||o.name||"",u.name===""&&typeof o.uri=="string"&&o.uri.startsWith("data:image/")===!1&&(u.name=o.uri);const d=(r.samplers||{})[a.sampler]||{};return u.magFilter=zc[d.magFilter]||Bt,u.minFilter=zc[d.minFilter]||Yn,u.wrapS=Vc[d.wrapS]||es,u.wrapT=Vc[d.wrapT]||es,u.generateMipmaps=!u.isCompressedTexture&&u.minFilter!==Ot&&u.minFilter!==Bt,i.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const n=this,i=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(h=>h.clone());const a=i.images[e],o=self.URL||self.webkitURL;let l=a.uri||"",c=!1;if(a.bufferView!==void 0)l=n.getDependency("bufferView",a.bufferView).then(function(h){c=!0;const d=new Blob([h],{type:a.mimeType});return l=o.createObjectURL(d),l});else if(a.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const u=Promise.resolve(l).then(function(h){return new Promise(function(d,f){let _=d;t.isImageBitmapLoader===!0&&(_=function(v){const m=new Gt(v);m.needsUpdate=!0,d(m)}),t.load(Is.resolveURL(h,r.path),_,void 0,f)})}).then(function(h){return c===!0&&o.revokeObjectURL(l),An(h,a),h.userData.mimeType=a.mimeType||b0(a.uri),h}).catch(function(h){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),h});return this.sourceCache[e]=u,u}assignTexture(e,t,n,i){const r=this;return this.getDependency("texture",n.index).then(function(a){if(!a)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(a=a.clone(),a.channel=n.texCoord),r.extensions[Je.KHR_TEXTURE_TRANSFORM]){const o=n.extensions!==void 0?n.extensions[Je.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const l=r.associations.get(a);a=r.extensions[Je.KHR_TEXTURE_TRANSFORM].extendTexture(a,o),r.associations.set(a,l)}}return i!==void 0&&(a.colorSpace=i),e[t]=a,a})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){const o="PointsMaterial:"+n.uuid;let l=this.cache.get(o);l||(l=new vu,In.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,l.sizeAttenuation=!1,this.cache.add(o,l)),n=l}else if(e.isLine){const o="LineBasicMaterial:"+n.uuid;let l=this.cache.get(o);l||(l=new Br,In.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(o,l)),n=l}if(i||r||a){let o="ClonedMaterial:"+n.uuid+":";i&&(o+="derivative-tangents:"),r&&(o+="vertex-colors:"),a&&(o+="flat-shading:");let l=this.cache.get(o);l||(l=n.clone(),r&&(l.vertexColors=!0),a&&(l.flatShading=!0),i&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(o,l),this.associations.set(l,this.associations.get(n))),n=l}e.material=n}getMaterialType(){return $i}loadMaterial(e){const t=this,n=this.json,i=this.extensions,r=n.materials[e];let a;const o={},l=r.extensions||{},c=[];if(l[Je.KHR_MATERIALS_UNLIT]){const h=i[Je.KHR_MATERIALS_UNLIT];a=h.getMaterialType(),c.push(h.extendParams(o,r,t))}else{const h=r.pbrMetallicRoughness||{};if(o.color=new Ue(1,1,1),o.opacity=1,Array.isArray(h.baseColorFactor)){const d=h.baseColorFactor;o.color.setRGB(d[0],d[1],d[2],ln),o.opacity=d[3]}h.baseColorTexture!==void 0&&c.push(t.assignTexture(o,"map",h.baseColorTexture,Ht)),o.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,o.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(o,"metalnessMap",h.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",h.metallicRoughnessTexture))),a=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,o)})))}r.doubleSided===!0&&(o.side=an);const u=r.alphaMode||Ca.OPAQUE;if(u===Ca.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,u===Ca.MASK&&(o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&a!==yi&&(c.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new ke(1,1),r.normalTexture.scale!==void 0)){const h=r.normalTexture.scale;o.normalScale.set(h,h)}if(r.occlusionTexture!==void 0&&a!==yi&&(c.push(t.assignTexture(o,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&a!==yi){const h=r.emissiveFactor;o.emissive=new Ue().setRGB(h[0],h[1],h[2],ln)}return r.emissiveTexture!==void 0&&a!==yi&&c.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,Ht)),Promise.all(c).then(function(){const h=new a(o);return r.name&&(h.name=r.name),An(h,r),t.associations.set(h,{materials:e}),r.extensions&&gi(i,h,r),h})}createUniqueName(e){const t=dt.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function r(o){return n[Je.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(l){return Hc(l,o,t)})}const a=[];for(let o=0,l=e.length;o<l;o++){const c=e[o],u=y0(c),h=i[u];if(h)a.push(h.promise);else{let d;c.extensions&&c.extensions[Je.KHR_DRACO_MESH_COMPRESSION]?d=r(c):d=Hc(new Wt,c,t),i[u]={primitive:c,promise:d},a.push(d)}}return Promise.all(a)}loadMesh(e){const t=this,n=this.json,i=this.extensions,r=n.meshes[e],a=r.primitives,o=[];for(let l=0,c=a.length;l<c;l++){const u=a[l].material===void 0?v0(this.cache):this.getDependency("material",a[l].material);o.push(u)}return o.push(t.loadGeometries(a)),Promise.all(o).then(function(l){const c=l.slice(0,l.length-1),u=l[l.length-1],h=[];for(let f=0,_=u.length;f<_;f++){const v=u[f],m=a[f];let p;const b=c[f];if(m.mode===dn.TRIANGLES||m.mode===dn.TRIANGLE_STRIP||m.mode===dn.TRIANGLE_FAN||m.mode===void 0)p=r.isSkinnedMesh===!0?new Cd(v,b):new bt(v,b),p.isSkinnedMesh===!0&&p.normalizeSkinWeights(),m.mode===dn.TRIANGLE_STRIP?p.geometry=Oc(p.geometry,hu):m.mode===dn.TRIANGLE_FAN&&(p.geometry=Oc(p.geometry,So));else if(m.mode===dn.LINES)p=new Jo(v,b);else if(m.mode===dn.LINE_STRIP)p=new jo(v,b);else if(m.mode===dn.LINE_LOOP)p=new Fd(v,b);else if(m.mode===dn.POINTS)p=new Od(v,b);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(p.geometry.morphAttributes).length>0&&S0(p,r),p.name=t.createUniqueName(r.name||"mesh_"+e),An(p,r),m.extensions&&gi(i,p,m),t.assignFinalMaterial(p),h.push(p)}for(let f=0,_=h.length;f<_;f++)t.associations.set(h[f],{meshes:e,primitives:f});if(h.length===1)return r.extensions&&gi(i,h[0],r),h[0];const d=new Si;r.extensions&&gi(i,d,r),t.associations.set(d,{meshes:e});for(let f=0,_=h.length;f<_;f++)d.add(h[f]);return d})}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new Qt(fu.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new Vr(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),An(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let i=0,r=t.joints.length;i<r;i++)n.push(this._loadNodeShallow(t.joints[i]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(i){const r=i.pop(),a=i,o=[],l=[];for(let c=0,u=a.length;c<u;c++){const h=a[c];if(h){o.push(h);const d=new We;r!==null&&d.fromArray(r.array,c*16),l.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new Zo(o,l)})}loadAnimation(e){const t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,a=[],o=[],l=[],c=[],u=[];for(let h=0,d=i.channels.length;h<d;h++){const f=i.channels[h],_=i.samplers[f.sampler],v=f.target,m=v.node,p=i.parameters!==void 0?i.parameters[_.input]:_.input,b=i.parameters!==void 0?i.parameters[_.output]:_.output;v.node!==void 0&&(a.push(this.getDependency("node",m)),o.push(this.getDependency("accessor",p)),l.push(this.getDependency("accessor",b)),c.push(_),u.push(v))}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l),Promise.all(c),Promise.all(u)]).then(function(h){const d=h[0],f=h[1],_=h[2],v=h[3],m=h[4],p=[];for(let T=0,S=d.length;T<S;T++){const w=d[T],E=f[T],R=_[T],x=v[T],A=m[T];if(w===void 0)continue;w.updateMatrix&&w.updateMatrix();const D=n._createAnimationTracks(w,E,R,x,A);if(D)for(let P=0;P<D.length;P++)p.push(D[P])}const b=new Qd(r,void 0,p);return An(b,i),b})}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return i.mesh===void 0?null:n.getDependency("mesh",i.mesh).then(function(r){const a=n._getNodeRef(n.meshCache,i.mesh,r);return i.weights!==void 0&&a.traverse(function(o){if(o.isMesh)for(let l=0,c=i.weights.length;l<c;l++)o.morphTargetInfluences[l]=i.weights[l]}),a})}loadNode(e){const t=this.json,n=this,i=t.nodes[e],r=n._loadNodeShallow(e),a=[],o=i.children||[];for(let c=0,u=o.length;c<u;c++)a.push(n.getDependency("node",o[c]));const l=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(a),l]).then(function(c){const u=c[0],h=c[1],d=c[2];d!==null&&u.traverse(function(f){f.isSkinnedMesh&&f.bind(d,E0)});for(let f=0,_=h.length;f<_;f++)u.add(h[f]);if(u.userData.pivot!==void 0&&h.length>0){const f=u.userData.pivot,_=h[0];u.pivot=new C().fromArray(f),u.position.x-=f[0],u.position.y-=f[1],u.position.z-=f[2],_.position.set(0,0,0),delete u.userData.pivot}return u})}_loadNodeShallow(e){const t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=t.nodes[e],a=r.name?i.createUniqueName(r.name):"",o=[],l=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return l&&o.push(l),r.camera!==void 0&&o.push(i.getDependency("camera",r.camera).then(function(c){return i._getNodeRef(i.cameraCache,r.camera,c)})),i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){o.push(c)}),this.nodeCache[e]=Promise.all(o).then(function(c){let u;if(r.isBone===!0?u=new xu:c.length>1?u=new Si:c.length===1?u=c[0]:u=new At,u!==c[0])for(let h=0,d=c.length;h<d;h++)u.add(c[h]);if(r.name&&(u.userData.name=r.name,u.name=a),An(u,r),r.extensions&&gi(n,u,r),r.matrix!==void 0){const h=new We;h.fromArray(r.matrix),u.applyMatrix4(h)}else r.translation!==void 0&&u.position.fromArray(r.translation),r.rotation!==void 0&&u.quaternion.fromArray(r.rotation),r.scale!==void 0&&u.scale.fromArray(r.scale);if(!i.associations.has(u))i.associations.set(u,{});else if(r.mesh!==void 0&&i.meshCache.refs[r.mesh]>1){const h=i.associations.get(u);i.associations.set(u,{...h})}return i.associations.get(u).nodes=e,u}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],i=this,r=new Si;n.name&&(r.name=i.createUniqueName(n.name)),An(r,n),n.extensions&&gi(t,r,n);const a=n.nodes||[],o=[];for(let l=0,c=a.length;l<c;l++)o.push(i.getDependency("node",a[l]));return Promise.all(o).then(function(l){for(let u=0,h=l.length;u<h;u++){const d=l[u];d.parent!==null?r.add(Yx(d)):r.add(d)}const c=u=>{const h=new Map;for(const[d,f]of i.associations)(d instanceof In||d instanceof Gt)&&h.set(d,f);return u.traverse(d=>{const f=i.associations.get(d);f!=null&&h.set(d,f)}),h};return i.associations=c(r),r})}_createAnimationTracks(e,t,n,i,r){const a=[],o=e.name?e.name:e.uuid,l=[];function c(f){f.morphTargetInfluences&&l.push(f.name?f.name:f.uuid)}oi[r.path]===oi.weights?(c(e),e.isGroup&&e.children.forEach(c)):l.push(o);let u;switch(oi[r.path]){case oi.weights:u=ks;break;case oi.rotation:u=zs;break;case oi.translation:case oi.scale:u=Ur;break;default:n.itemSize===1?u=ks:u=Ur;break}const h=i.interpolation!==void 0?x0[i.interpolation]:Fs,d=this._getArrayFromAccessor(n);for(let f=0,_=l.length;f<_;f++){const v=new u(l[f]+"."+oi[r.path],t.array,d,h);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(v),a.push(v)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=Lo(t.constructor),i=new Float32Array(t.length);for(let r=0,a=t.length;r<a;r++)i[r]=t[r]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const i=this instanceof zs?_0:Ou;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function A0(s,e,t){const n=e.attributes,i=new Yt;if(n.POSITION!==void 0){const o=t.json.accessors[n.POSITION],l=o.min,c=o.max;if(l!==void 0&&c!==void 0){if(i.set(new C(l[0],l[1],l[2]),new C(c[0],c[1],c[2])),o.normalized){const u=Lo(ji[o.componentType]);i.min.multiplyScalar(u),i.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=e.targets;if(r!==void 0){const o=new C,l=new C;for(let c=0,u=r.length;c<u;c++){const h=r[c];if(h.POSITION!==void 0){const d=t.json.accessors[h.POSITION],f=d.min,_=d.max;if(f!==void 0&&_!==void 0){if(l.setX(Math.max(Math.abs(f[0]),Math.abs(_[0]))),l.setY(Math.max(Math.abs(f[1]),Math.abs(_[1]))),l.setZ(Math.max(Math.abs(f[2]),Math.abs(_[2]))),d.normalized){const v=Lo(ji[d.componentType]);l.multiplyScalar(v)}o.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(o)}s.boundingBox=i;const a=new Fn;i.getCenter(a.center),a.radius=i.min.distanceTo(i.max)/2,s.boundingSphere=a}function Hc(s,e,t){const n=e.attributes,i=[];function r(a,o){return t.getDependency("accessor",a).then(function(l){s.setAttribute(o,l)})}for(const a in n){const o=Po[a]||a.toLowerCase();o in s.attributes||i.push(r(n[a],o))}if(e.indices!==void 0&&!s.index){const a=t.getDependency("accessor",e.indices).then(function(o){s.setIndex(o)});i.push(a)}return Qe.workingColorSpace!==ln&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Qe.workingColorSpace}" not supported.`),An(s,e),A0(s,e,t),Promise.all(i).then(function(){return e.targets!==void 0?M0(s,e.targets,t):s})}class w0 extends Ti{constructor(e){super(e)}load(e,t,n,i){const r=this,a=new tl(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(r.parse(o))}catch(l){i?i(l):console.error(l),r.manager.itemError(e)}},n,i)}parse(e){function t(c){const u=new DataView(c),h=32/8*3+32/8*3*3+16/8,d=u.getUint32(80,!0);if(80+32/8+d*h===u.byteLength)return!0;const _=[115,111,108,105,100];for(let v=0;v<5;v++)if(n(_,u,v))return!1;return!0}function n(c,u,h){for(let d=0,f=c.length;d<f;d++)if(c[d]!==u.getUint8(h+d))return!1;return!0}function i(c){const u=new DataView(c),h=u.getUint32(80,!0);let d,f,_,v=!1,m,p,b,T,S;for(let P=0;P<70;P++)u.getUint32(P,!1)==1129270351&&u.getUint8(P+4)==82&&u.getUint8(P+5)==61&&(v=!0,m=new Float32Array(h*3*3),p=u.getUint8(P+6)/255,b=u.getUint8(P+7)/255,T=u.getUint8(P+8)/255,S=u.getUint8(P+9)/255);const w=84,E=50,R=new Wt,x=new Float32Array(h*3*3),A=new Float32Array(h*3*3),D=new Ue;for(let P=0;P<h;P++){const F=w+P*E,$=u.getFloat32(F,!0),j=u.getFloat32(F+4,!0),k=u.getFloat32(F+8,!0);if(v){const q=u.getUint16(F+48,!0);(q&32768)===0?(d=(q&31)/31,f=(q>>5&31)/31,_=(q>>10&31)/31):(d=p,f=b,_=T)}for(let q=1;q<=3;q++){const W=F+q*12,ee=P*3*3+(q-1)*3;x[ee]=u.getFloat32(W,!0),x[ee+1]=u.getFloat32(W+4,!0),x[ee+2]=u.getFloat32(W+8,!0),A[ee]=$,A[ee+1]=j,A[ee+2]=k,v&&(D.setRGB(d,f,_,Ht),m[ee]=D.r,m[ee+1]=D.g,m[ee+2]=D.b)}}return R.setAttribute("position",new Nt(x,3)),R.setAttribute("normal",new Nt(A,3)),v&&(R.setAttribute("color",new Nt(m,3)),R.hasColors=!0,R.alpha=S),R}function r(c){const u=new Wt,h=/solid([\s\S]*?)endsolid/g,d=/facet([\s\S]*?)endfacet/g,f=/solid\s(.+)/;let _=0;const v=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,m=new RegExp("vertex"+v+v+v,"g"),p=new RegExp("normal"+v+v+v,"g"),b=[],T=[],S=[],w=new C;let E,R=0,x=0,A=0;for(;(E=h.exec(c))!==null;){x=A;const D=E[0],P=(E=f.exec(D))!==null?E[1]:"";for(S.push(P);(E=d.exec(D))!==null;){let j=0,k=0;const q=E[0];for(;(E=p.exec(q))!==null;)w.x=parseFloat(E[1]),w.y=parseFloat(E[2]),w.z=parseFloat(E[3]),k++;for(;(E=m.exec(q))!==null;)b.push(parseFloat(E[1]),parseFloat(E[2]),parseFloat(E[3])),T.push(w.x,w.y,w.z),j++,A++;k!==1&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+_),j!==3&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+_),_++}const F=x,$=A-x;u.userData.groupNames=S,u.addGroup(F,$,R),R++}return u.setAttribute("position",new Lt(b,3)),u.setAttribute("normal",new Lt(T,3)),u}function a(c){return typeof c!="string"?new TextDecoder().decode(c):c}function o(c){if(typeof c=="string"){const u=new Uint8Array(c.length);for(let h=0;h<c.length;h++)u[h]=c.charCodeAt(h)&255;return u.buffer||u}else return c}const l=o(e);return t(l)?i(l):r(a(e))}}function La(s){const e=s.toLowerCase();return e===".stl"?"stl":e===".glb"||e===".gltf"?"gltf":null}function Ia(s){return s>=100?s.toFixed(0):s.toFixed(1)}function R0(s,e){const t=`${Ia(s.x)} × ${Ia(s.y)} × ${Ia(s.z)}`;return e?`${t} ${e}`:t}function C0(s){let e=s,t="";for(;e;){if(e.name&&!t&&(t=e.name),e.name&&e.type==="Group")return e.name;e=e.parent}return t}function P0(s){if(s.ctrlKey||s.metaKey)return"pinch-zoom";if(s.deltaMode!==0)return"wheel-zoom";const e=Math.abs(s.wheelDeltaY??0);return e>=120&&e%120===0?"wheel-zoom":Math.abs(s.deltaX)>.01||e>0&&e%120!==0||!Number.isInteger(s.deltaY)||Math.abs(s.deltaY)<50?"trackpad-pan":"wheel-zoom"}const L0=.52,Gc=18,Io=1.38,I0=.62,D0=.55,N0=.72;function U0(s){return s?{rotate:I0,pan:D0,zoom:N0}:{rotate:1,pan:1,zoom:Io}}function Wc(s){return Number.isFinite(s)?Gc*Math.tanh(s*L0/Gc):0}function F0(s){const e=new Set;return s.traverse(t=>{if(!(t instanceof bt))return;let n=t,i=!1;for(;n;){if(n.name.toLowerCase().includes("_silkscreen")){i=!0;break}n=n.parent}if(i){t.renderOrder=Math.max(t.renderOrder,20);for(const r of Array.isArray(t.material)?t.material:[t.material])r.transparent=!1,r.opacity=1,r.depthTest=!0,r.depthWrite=!0,r.polygonOffset=!0,r.polygonOffsetFactor=-2,r.polygonOffsetUnits=-2,r.needsUpdate=!0,e.add(r)}}),e.size}function O0(s){const e=new Set;return s.traverse(t=>{if(!(t instanceof bt))return;let n=t,i=!1;for(;n;){if(/_pcb$/i.test(n.name)){i=!0;break}n=n.parent}if(i)for(const r of Array.isArray(t.material)?t.material:[t.material])r.transparent=!1,r.opacity=1,r.depthTest=!0,r.depthWrite=!0,r.needsUpdate=!0,e.add(r)}),e.size}function B0(s){const e=new Map;s.traverse(n=>{if(n instanceof bt)for(const i of Array.isArray(n.material)?n.material:[n.material])e.has(i)||!i.transparent||i.opacity<.8||e.set(i,{transparent:i.transparent,opacity:i.opacity,depthWrite:i.depthWrite,forceSinglePass:i.forceSinglePass})});let t=!1;return{count:e.size,setEnabled(n){if(n!==t){t=n;for(const[i,r]of e)t?(i.transparent=!1,i.opacity=1,i.depthWrite=!0,i.forceSinglePass=!0):(i.transparent=r.transparent,i.opacity=r.opacity,i.depthWrite=r.depthWrite,i.forceSinglePass=r.forceSinglePass),i.needsUpdate=!0}}}}const Mr={light:{bg:"#F4F4F2",part:"#9AA0A6",gridLine:"#CCCCCC",grid:"#DDDDDD"},dark:{bg:"#232527",part:"#8B929A",gridLine:"#4A4E54",grid:"#3A3E44"}};function Bu(){return typeof document<"u"&&document.documentElement.dataset.theme==="light"?"light":"dark"}const k0=[{termZh:"倒角",descZh:"把棱角削成斜面(如直角边变 45° 斜边)。防割手、防崩角、方便装配。",termEn:"Chamfer",descEn:"Bevels a sharp edge into a flat slope (e.g. 45°). Prevents cuts/chips and eases assembly."},{termZh:"圆角 / 内圆角",descZh:"把棱角磨圆。内角圆角能减少应力集中、不容易裂;外圆角防刮手。",termEn:"Fillet / inner radius",descEn:"Rounds a corner. Inner fillets reduce stress concentration; outer fillets prevent sharp edges."},{termZh:"加厚",descZh:"增加壁厚,让零件更结实。",termEn:"Thicken",descEn:"Increases wall thickness for strength."},{termZh:"减料",descZh:"去掉一部分材料(减重或让位)。",termEn:"Remove material",descEn:"Removes material (lighter or to make room)."},{termZh:"钻孔",descZh:"打一个圆孔,通常配螺丝/螺栓。",termEn:"Drill / hole",descEn:"Adds a round hole, usually for screws/bolts."},{termZh:"沉孔",descZh:"孔口挖一圈浅台阶,让螺丝头/螺母沉进表面不凸出。",termEn:"Counterbore",descEn:"Recesses the hole mouth so screw heads/nuts sit flush."},{termZh:"加强筋",descZh:"表面加一条凸起的筋,用最少材料增加抗弯强度。",termEn:"Rib",descEn:"A raised strip that adds bending strength with little material."},{termZh:"燕尾槽",descZh:"横截面是梯形的槽,另一零件的梯形尾部滑进去后被卡住、不会脱出。",termEn:"Dovetail slot",descEn:"A trapezoidal slot that locks a matching tail in place."},{termZh:"卡槽",descZh:"用来卡住或滑入另一个零件的槽。",termEn:"Slot",descEn:"A groove that holds or guides another part."},{termZh:"燕尾根部",descZh:"燕尾和板身连接的地方,受力集中、容易断。",termEn:"Tab root",descEn:"Where the dovetail meets the plate — stress concentrates here."},{termZh:"压面",descZh:"朝墙压住床垫的那个面。",termEn:"Press face",descEn:"The face pressing the mattress toward the wall."},{termZh:"胶贴面",descZh:"贴双面胶(VHB)粘到柜子上的面。",termEn:"Glue face",descEn:"The face that sticks to the cabinet with VHB tape."},{termZh:"支撑 / 加固",descZh:"在薄弱处加斜撑或筋,增强强度。",termEn:"Support / reinforce",descEn:"Adds a brace or rib to strengthen a weak spot."},{termZh:"间隙 / 公差",descZh:"两个配合件之间留的缝隙,滑动配合通常单边 0.15~0.3mm。",termEn:"Clearance / tolerance",descEn:"The gap between mating parts (sliding fit ~0.15-0.3mm per side)."}];function z0({locale:s,onClose:e}){const t=s==="zh";return ie.jsxs("div",{className:"space-y-2 p-1",children:[k0.map((n,i)=>ie.jsxs("div",{className:"rounded-md bg-surface/60 px-2 py-1.5",children:[ie.jsx("div",{className:"text-xs font-medium text-foreground",children:t?n.termZh:n.termEn}),ie.jsx("div",{className:"mt-0.5 text-[11px] leading-relaxed text-muted-foreground",children:t?n.descZh:n.descEn})]},i)),ie.jsx("button",{type:"button",className:"mt-1 w-full rounded-md bg-surface-elevated px-2 py-1 text-xs font-medium text-foreground hover:bg-surface",onClick:e,children:t?"返回特征列表":"Back to features"})]})}async function V0(s,e){if(e==="stl")return{kind:"stl",geometry:new w0().parse(s)};const t=await new Promise((n,i)=>{new qx().parse(s,"",n,i)});return t.scene.traverse(n=>{const i=t.parser?.associations.get(n);i?.meshes!==void 0&&(n.userData.termdockSinglePart=!0);const r=i?.nodes!==void 0?t.parser.json.nodes?.[i.nodes]?.name:void 0;r&&(n.userData.termdockPartName=r)}),{kind:"gltf",object:t.scene}}function H0(s,e,t=1,n){const i=Bu(),r=new Sd;r.background=new Ue(Mr[i].bg);const a=new Qt(45,s.clientWidth/Math.max(1,s.clientHeight),.1,1e4),o=new Tx({antialias:!0});o.setPixelRatio(window.devicePixelRatio),o.setSize(s.clientWidth,s.clientHeight),o.localClippingEnabled=!0,s.appendChild(o.domElement),r.add(new ff("white",.55*Math.PI));const l=new Ao("white",.8*Math.PI);l.position.set(1,2,3),r.add(l);const c=new Ao("white",.35*Math.PI);c.position.set(-2,-1,-2),r.add(c);let u,h=null,d;const f=new C;if(e.kind==="stl"){const G=e.geometry;G.computeBoundingBox();const J=G.boundingBox;u=J.getSize(new C);const y=J.getCenter(new C);f.copy(y),G.translate(-y.x,-y.y,-y.z),h=new $i({color:new Ue(Mr[i].part),metalness:.1,roughness:.75});const g=new bt(G,h);g.rotation.x=-Math.PI/2,r.add(g),d=g}else{const G=e.object;F0(G),O0(G),G.scale.setScalar(t),G.updateMatrixWorld(!0);const J=new Yt().setFromObject(G);u=J.getSize(new C);const y=J.getCenter(new C);f.copy(y),G.position.sub(y),r.add(G),d=G}const _=e.kind==="stl",v=_?null:wx(d),m=Cx(d);let p=null,b;const T=()=>{p&&(r.remove(p),p.geometry.dispose(),p.material.dispose(),p=null)},S=G=>_?new C(G.x-f.x,G.z-f.z,f.y-G.y):new C(G.x,G.z,-G.y).sub(f),w=G=>_?[G.x+f.x,f.y-G.z,G.y+f.z]:[G.x+f.x,-(G.z+f.z),G.y+f.y],E=(G,J,y,g)=>{const L=y.clone().sub(J),B=g.clone().sub(J),z=G.clone().sub(J),Q=L.dot(L),re=B.dot(B),X=L.dot(B),Z=z.dot(L),oe=z.dot(B),me=Q*re-X*X;if(me!==0){const ce=(re*Z-X*oe)/me,Ee=(Q*oe-X*Z)/me;if(ce>=0&&Ee>=0&&ce+Ee<=1)return G.distanceTo(J.clone().add(L.multiplyScalar(ce)).add(B.multiplyScalar(Ee)))}let ue=1/0;for(const[ce,Ee]of[[J,y],[y,g],[g,J]]){const Te=Ee.clone().sub(ce),Re=Te.dot(Te),I=Re===0?0:Math.min(1,Math.max(0,G.clone().sub(ce).dot(Te)/Re));ue=Math.min(ue,G.distanceTo(ce.clone().add(Te.multiplyScalar(I))))}return ue},R=G=>{const J=S(G);let y=1/0;const g=new C,L=new C,B=new C;return d.updateMatrixWorld(!0),d.traverse(z=>{if(!(z instanceof bt)||y<1e-6)return;const Q=z.geometry,re=Q.getAttribute("position");if(!re)return;const X=Q.getIndex(),Z=X?X.count/3:re.count/3,oe=v?.offset(z);for(let me=0;me<Z;me++){const ue=X?X.getX(me*3):me*3,ce=X?X.getX(me*3+1):me*3+1,Ee=X?X.getX(me*3+2):me*3+2;if(g.fromArray(re.array,ue*3).applyMatrix4(z.matrixWorld),L.fromArray(re.array,ce*3).applyMatrix4(z.matrixWorld),B.fromArray(re.array,Ee*3).applyMatrix4(z.matrixWorld),oe&&(g.sub(oe),L.sub(oe),B.sub(oe)),y=Math.min(y,E(J,g,L,B)),y<1e-6)break}}),y},A=new Yt().setFromObject(d).getSize(new C),D=e.kind==="stl"?{x:new C(1,0,0),y:new C(0,0,-1),z:new C(0,1,0)}:{x:new C(1,0,0),y:new C(0,1,0),z:new C(0,0,1)},P=new Xn(new C(0,-1,0),0);let F=!1;const $=[];d.traverse(G=>{if(G instanceof bt)for(const J of Array.isArray(G.material)?G.material:[G.material])$.push(J)});const j=B0(d),k=Math.max(u.length()/2,1e-6),q=ms(k,a.fov,a.aspect);a.position.set(q*.7,q*.6,q*.7),a.near=q/100,a.far=q*100,a.updateProjectionMatrix();let W=null;const ee=G=>{W&&(r.remove(W),W.geometry.dispose(),W.material.dispose());const J=Mr[G];W=new wf(k*4,20,new Ue(J.gridLine),new Ue(J.grid)),W.position.y=-k*1.001,r.add(W)};ee(i);const K=new Dx(a,o.domElement);K.enableDamping=!0,K.dampingFactor=.08,K.screenSpacePanning=!0,K.zoomToCursor=!0,K.zoomSpeed=Io,K.minDistance=Math.max(k*.025,a.near*2),K.maxDistance=q*30;let le=null;const pe=()=>{le=null},Me=(G,J)=>{const y=K.enableDamping;K.enableDamping=!1,K.update(),K.enableDamping=y;const g={target:G,position:J};window.matchMedia?.("(prefers-reduced-motion: reduce)").matches?(K.target.copy(G),a.position.copy(J),K.update(),le=null):le={start:performance.now(),from:{target:K.target.clone(),position:a.position.clone()},to:g}},Ye=()=>{d.updateWorldMatrix(!0,!0);const G=new Yt;return d.traverse(J=>{!(J instanceof bt)||!_i(J)||(J.geometry.boundingBox||J.geometry.computeBoundingBox(),J.geometry.boundingBox&&G.union(J.geometry.boundingBox.clone().applyMatrix4(J.matrixWorld)))}),G},rt=G=>{const J=Ye();if(J.isEmpty())return;const y=J.getCenter(new C),g=ms(Math.max(J.getSize(new C).length()/2,k*.025),a.fov,a.aspect),L=G==="fit"?a.position.clone().sub(K.target).normalize():G==="front"?new C(0,0,1):G==="right"?new C(1,0,0):G==="top"?new C(0,1,1e-4).normalize():new C(.7,.6,.7).normalize();Me(y,y.clone().addScaledVector(L,g))};o.domElement.addEventListener("wheel",pe,{capture:!0});const qe=new Set,ne=G=>{const J=U0(G);K.rotateSpeed=J.rotate,K.panSpeed=J.pan,K.zoomSpeed=J.zoom},he=G=>{pe(),G.pointerType==="touch"&&(qe.add(G.pointerId),ne(!0))},ae=G=>{qe.delete(G.pointerId)&&qe.size===0&&ne(!1)};o.domElement.addEventListener("pointerdown",he,{capture:!0}),o.domElement.addEventListener("pointerup",ae,{capture:!0}),o.domElement.addEventListener("pointercancel",ae,{capture:!0});const Be=(G,J)=>{const y=Math.max(1,o.domElement.clientHeight||s.clientHeight),L=2*Math.max(a.position.distanceTo(K.target),1e-6)*Math.tan(a.fov*Math.PI/180/2)/y,B=a.getWorldDirection(new C),z=new C().crossVectors(B,a.up).normalize(),Q=new C().crossVectors(z,B).normalize(),re=z.multiplyScalar(Wc(G)*L).add(Q.multiplyScalar(-Wc(J)*L));a.position.add(re),K.target.add(re)},Oe=G=>{P0(G)==="trackpad-pan"&&(G.preventDefault(),G.stopImmediatePropagation(),Be(G.deltaX,G.deltaY))};o.domElement.addEventListener("wheel",Oe,{capture:!0,passive:!1});let De=1;const ft=G=>{const J=G;De=J.scale&&J.scale>0?J.scale:1,J.preventDefault(),J.stopPropagation()},Ge=G=>{const J=G,y=J.scale&&J.scale>0?J.scale:De,g=y/Math.max(De,1e-6),L=Math.min(2,Math.max(.5,Math.pow(g,Io)));De=y;const B=a.position.clone().sub(K.target),z=Math.min(K.maxDistance,Math.max(K.minDistance,B.length()/L));Number.isFinite(z)&&z>0&&(a.position.copy(K.target).add(B.setLength(z)),K.update()),J.preventDefault(),J.stopPropagation()},je=G=>{De=1,G.preventDefault(),G.stopPropagation()};o.domElement.addEventListener("gesturestart",ft,{passive:!1}),o.domElement.addEventListener("gesturechange",Ge,{passive:!1}),o.domElement.addEventListener("gestureend",je,{passive:!1});const Le=new Af,Ve=new ResizeObserver(()=>{const G=s.clientWidth,J=Math.max(1,s.clientHeight);if(G===0)return;const y=ms(k,a.fov,a.aspect);a.aspect=G/J;const g=ms(k,a.fov,a.aspect);a.position.sub(K.target).multiplyScalar(g/y).add(K.target),a.updateProjectionMatrix(),o.setSize(G,J)});Ve.observe(s);let nt=null,at=!0,Et=null,lt=[],et=1;const vt=()=>{const G=s.clientHeight/2,J=Math.tan(a.fov*Math.PI/180/2);for(const y of lt){const g=Math.max(a.position.distanceTo(y.point),1e-6),z=36/(G/(g*J))/(k*.12);for(const Q of y.meshes)Q.scale.set(z,z,z)}},U=()=>{if(!at){nt=null;return}if(le){const G=Math.min(1,(performance.now()-le.start)/240),J=G*G*(3-2*G);a.position.lerpVectors(le.from.position,le.to.position,J),K.target.lerpVectors(le.from.target,le.to.target,J),G===1&&(le=null)}K.update(),p&&b&&(p.visible=_i(b),p.visible&&p.update()),o.render(r,a),vt(),Et?.(),nt=requestAnimationFrame(U)};return U(),{partCount:v?.count??1,parts:m.parts,setView:rt,zoomAt:(G,J,y,g)=>{Le.setFromCamera(new ke(G/y*2-1,1-J/g*2),a);const L=Le.intersectObject(d,!0).find(Q=>_i(Q.object)&&(!F||P.distanceToPoint(Q.point)>=0));if(!L){rt("fit");return}const B=a.position.clone().sub(L.point).normalize(),z=Math.max(K.minDistance,a.position.distanceTo(L.point)*.45);Me(L.point.clone(),L.point.clone().addScaledVector(B,z))},cameraPose:()=>({position:a.position.clone(),target:K.target.clone()}),restoreCameraPose:({position:G,target:J})=>{pe(),a.position.copy(G),K.target.copy(J),K.update()},focusPart:G=>{pe();const J=G?m.node(G):d;if(!J)return;const y=new Yt().setFromObject(J);if(y.isEmpty())return;const g=y.getCenter(new C),L=ms(Math.max(y.getSize(new C).length()/2,1e-6),a.fov,a.aspect),B=a.position.clone().sub(K.target).normalize();K.target.copy(g),a.position.copy(g).addScaledVector(B,L),K.update()},setSelectedPart:G=>{if(T(),b=G?m.node(G):void 0,!b)return;const J=getComputedStyle(document.documentElement).getPropertyValue("--accent").trim()||"white";p=new Rf(b,new Ue(J)),p.visible=_i(b),r.add(p)},setHiddenParts:m.setHidden,setExplosion:G=>{if(pe(),!v||v.count<2)return;const J=v.set(G),y=J.getCenter(new C),g=Math.max(1,J.getSize(new C).length()/u.length()),L=a.position.clone().sub(K.target).multiplyScalar(g/et);K.target.copy(y),a.position.copy(y).add(L),et=g,K.update()},capture:G=>{try{return o.render(r,a),$u(o.domElement,void 0,G)}catch{return Promise.resolve(null)}},dims:R0(u,n??(e.kind==="stl"?"mm":void 0)),setActive:G=>{at!==G&&(at=G,!at&&nt!==null?(cancelAnimationFrame(nt),nt=null):at&&nt===null&&U())},setAppearance:G=>{const J=Mr[G];r.background=new Ue(J.bg),h&&(h.color=new Ue(J.part)),ee(G)},setClip:G=>{if(F=!!G,!G){j.setEnabled(!1);for(const L of $)L.clippingPlanes=null;h&&(h.side=Dn);return}j.setEnabled(!0);const J=D[G.axis],y=(Math.abs(J.x)*A.x+Math.abs(J.y)*A.y+Math.abs(J.z)*A.z)/2,g=(G.value01*2-1)*y;P.normal.copy(J).negate(),P.constant=g,G.flip&&(P.normal.negate(),P.constant=-g);for(const L of $)L.clippingPlanes=[P];h&&(h.side=an)},projectToScreen:(G,J)=>{if(!m.isPartVisible(J))return null;const y=S(G);J&&y.add(v?.offset(J)??new C);const g=y.clone().project(a);if(g.z<-1||g.z>1)return null;let L=!0;const B=y.clone().sub(a.position),z=B.length();if(z>1e-6){Le.set(a.position,B.normalize());const X=Le.intersectObject(d,!0).filter(Z=>_i(Z.object)&&(!F||P.distanceToPoint(Z.point)>=0));X.length>0&&X[0].distance<z-1.5&&(L=!1)}const Q=s.clientWidth,re=Math.max(1,s.clientHeight);return{x:(g.x*.5+.5)*Q,y:(-g.y*.5+.5)*re,visible:L}},surfaceDistance:G=>R(G),pick:(G,J,y,g)=>{const L=new ke(G/y*2-1,-(J/g*2-1));Le.setFromCamera(L,a);const B=Le.intersectObject(d,!0).find(me=>_i(me.object)&&(!F||P.distanceToPoint(me.point)>=0));if(!B)return null;const z=B.point.clone().sub(v?.offset(B.object)??new C),Q=w(z),re=B.face?.normal.clone().applyMatrix3(new He().getNormalMatrix(B.object.matrixWorld)).normalize(),X=re?[re.x,-re.z,re.y]:null,Z=v?.part(B.object);return{part:Z?.userData.termdockPartName||Z?.name||C0(B.object),node:Z?.uuid,visibilityId:m.id(B.object),point:Q,normal:X}},setSelection:G=>{for(const Q of lt)for(const re of Q.meshes)r.remove(re),re.geometry.dispose(),re.material.dispose();lt=[];const J=G?.filter(Q=>m.isPartVisible(Q.node??Q.part));if(!J?.length)return;const y=new Qo(k*.1,32),g=new $i({color:new Ue("#D0A215"),side:an,transparent:!0,opacity:.32,depthWrite:!1}),L=new el(k*.09,k*.12,32),B=new $i({color:new Ue("#D0A215"),side:an,transparent:!0,opacity:.9,depthWrite:!1}),z=new C(0,0,1);for(const Q of J){const re=S({x:Q.point[0],y:Q.point[1],z:Q.point[2]});re.add(v?.offset(Q.node??Q.part)??new C);const X=Q.normal?new C(Q.normal[0],Q.normal[2],-Q.normal[1]).normalize():null,Z=[];for(const[oe,me]of[[y,g],[L,B]]){const ue=new bt(oe,me);X?(ue.quaternion.setFromUnitVectors(z,X),ue.position.copy(re).add(X.clone().multiplyScalar(.15))):ue.position.copy(re),r.add(ue),Z.push(ue)}lt.push({point:re,meshes:Z})}vt()},setAfterRender:G=>{Et=G},dispose:()=>{T(),at=!1,nt!==null&&cancelAnimationFrame(nt),nt=null;for(const G of lt)for(const J of G.meshes)r.remove(J),J.geometry.dispose(),J.material.dispose();lt=[],Ve.disconnect(),o.domElement.removeEventListener("pointerdown",he,{capture:!0}),o.domElement.removeEventListener("pointerup",ae,{capture:!0}),o.domElement.removeEventListener("pointercancel",ae,{capture:!0}),o.domElement.removeEventListener("wheel",pe,{capture:!0}),o.domElement.removeEventListener("wheel",Oe,{capture:!0}),o.domElement.removeEventListener("gesturestart",ft),o.domElement.removeEventListener("gesturechange",Ge),o.domElement.removeEventListener("gestureend",je),K.dispose(),W&&(r.remove(W),W.geometry.dispose(),W.material.dispose(),W=null),r.traverse(G=>{if(G instanceof bt){G.geometry.dispose();const J=G.material;for(const y of Array.isArray(J)?J:[J])y.dispose()}}),o.dispose(),o.domElement.remove()}}}const Xc="termdock.model3d.bg";function nv({blobUrl:s,ext:e,fileName:t,filePath:n,features:i,onInsertFeature:r,onRefresh:a,unitScale:o=1,dimensionUnit:l,coordinateSystemLabel:c,annotationPrefix:u="",normalizePickedPartName:h,active:d=!0}){const{t:f,locale:_}=Do(),v=we.useRef(null),m=we.useRef(null),[p,b]=we.useState({kind:"loading"}),[T,S]=we.useState(!1),w=typeof document<"u"&&document.fullscreenEnabled,[E,R]=we.useState(!1),x=T||E,A=()=>{w?document.fullscreenElement?document.exitFullscreen():v.current?.requestFullscreen():R(N=>!N)},[D,P]=we.useState(()=>{if(typeof window>"u")return null;const N=window.localStorage.getItem(Xc);return N==="light"||N==="dark"?N:null}),F=we.useRef(null),$=we.useRef(D);$.current=D;const[j,k]=we.useState(!1),[q,W]=we.useState("z"),[ee,K]=we.useState(.5),[le,pe]=we.useState(!1),Me=we.useRef(null);Me.current=j?{axis:q,value01:ee,flip:le}:null;const[Ye,rt]=we.useState(!1),[qe,ne]=we.useState(.65),[he,ae]=we.useState("y"),Be=we.useRef(null);Be.current=Ye?{axis:he,amount:qe}:null;const[Oe,De]=we.useReducer(Nc,{hidden:[],history:[]}),ft=we.useRef(Oe);ft.current=Oe;const Ge=we.useRef([]),je=N=>{const Ce=ft.current,it=Nc(Ce,N);if(ft.current=it,N.type==="reset")Ge.current=[];else if(N.type==="undo"){const tt=Ge.current.pop();tt&&F.current?.restoreCameraPose(tt)}else it!==Ce&&(Ge.current=[...Ge.current.slice(-19),F.current?.cameraPose()]);De(N)},Le=Oe.hidden,[Ve,nt]=we.useState(!1),[at,Et]=we.useState(!1),[lt,et]=we.useState(null),vt=we.useRef(null),U=p.kind==="ready"?p.parts.filter(N=>N.initiallyVisible).map((N,Ce)=>({...N,name:h?.(N.name)||N.name||f("rightSidebar.model3dUnnamedPart",{index:Ce+1})})):[],G=U.find(N=>N.id===lt),J=()=>{nt(!1),vt.current?.focus()},y=we.useRef(Le);y.current=Le;const g=()=>[Rx(Be.current,Me.current),y.current.length>0?`Hidden parts: ${y.current.length}`:""].filter(Boolean).join(" / "),[L,B]=we.useState(!1),[z,Q]=we.useState([]),[re,X]=we.useState(null),[Z,oe]=we.useState(!1),[me,ue]=we.useState(()=>typeof window<"u"&&window.innerWidth>=768),ce=we.useRef(null),Ee=we.useRef(z);Ee.current=z;const Te=i?.filter(N=>z.includes(N.id))??[],[Re,I]=we.useState(null),fe=we.useRef(Re);fe.current=Re;const te=we.useRef(null),de=we.useRef(null),ge=we.useRef(new Set),se=we.useRef(!1),be=we.useRef(null),Ae=N=>{et(N),I(null),B(!1),Q([])},St=N=>{je({type:"toggle",id:N}),Le.includes(N)&&Le.length===U.length-1&&F.current?.focusPart(),Re?.visibilityId===N&&I(null)},ct=N=>{je({type:"set",hidden:U.filter(Ce=>Ce.id!==N).map(Ce=>Ce.id)}),et(N),Re?.visibilityId!==N&&I(null),F.current?.focusPart(N)},cn=()=>{je({type:"set",hidden:[]}),Le.length===U.length-1&&F.current?.focusPart()},qt=!!(G||Re||Te.length);we.useEffect(()=>{const N=v.current;if(!N)return;const Ce=()=>Et(N.clientWidth>=720);Ce();const it=new ResizeObserver(Ce);return it.observe(N),()=>it.disconnect()},[E]);const Hs=N=>{const Ce=N.part.replace(/_\d+$/,""),it=i?.find(tt=>tt.node&&(tt.node===N.part||tt.node===Ce));return it?it.part:i&&i.length>0&&(!N.part||N.part==="part")?i[0].part:Ce||t.replace(/\.(stl|glb|gltf)$/i,"")},Wr=()=>{const N=fe.current;if(!N)return;const Ce=La(e)==="gltf",it=c??(Ce?"GLB Y-up":"STL Z-up"),tt=M=>Ce?[M[0],M[2],-M[1]]:M,Xt=tt(N.point).map(M=>M.toFixed(1)).join(","),Tt=N.normal?` · 法线 (${tt(N.normal).map(M=>M.toFixed(2)).join(",")})`:"",yt=Hs(N),Ut=l??(Ce?"文件单位":"mm"),ot=`${u?`${u}: `:""}${n??t}
4108
+ }`;class vx{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new Su(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new Un({vertexShader:_x,fragmentShader:xx,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new bt(new kr(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Mx extends hi{constructor(e,t){super();const n=this;let i=null,r=1,a=null,o="local-floor",l=1,c=null,u=null,h=null,d=null,f=null,_=null;const v=typeof XRWebGLBinding<"u",m=new vx,p={},b=t.getContextAttributes();let T=null,S=null;const w=[],E=[],R=new ke;let x=null;const A=new Qt;A.viewport=new gt;const D=new Qt;D.viewport=new gt;const P=[A,D],F=new _f;let $=null,j=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ne){let he=w[ne];return he===void 0&&(he=new Qr,w[ne]=he),he.getTargetRaySpace()},this.getControllerGrip=function(ne){let he=w[ne];return he===void 0&&(he=new Qr,w[ne]=he),he.getGripSpace()},this.getHand=function(ne){let he=w[ne];return he===void 0&&(he=new Qr,w[ne]=he),he.getHandSpace()};function k(ne){const he=E.indexOf(ne.inputSource);if(he===-1)return;const ae=w[he];ae!==void 0&&(ae.update(ne.inputSource,ne.frame,c||a),ae.dispatchEvent({type:ne.type,data:ne.inputSource}))}function q(){i.removeEventListener("select",k),i.removeEventListener("selectstart",k),i.removeEventListener("selectend",k),i.removeEventListener("squeeze",k),i.removeEventListener("squeezestart",k),i.removeEventListener("squeezeend",k),i.removeEventListener("end",q),i.removeEventListener("inputsourceschange",W);for(let ne=0;ne<w.length;ne++){const he=E[ne];he!==null&&(E[ne]=null,w[ne].disconnect(he))}$=null,j=null,m.reset();for(const ne in p)delete p[ne];e.setRenderTarget(T),f=null,d=null,h=null,i=null,S=null,qe.stop(),n.isPresenting=!1,e.setPixelRatio(x),e.setSize(R.width,R.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ne){r=ne,n.isPresenting===!0&&Ie("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ne){o=ne,n.isPresenting===!0&&Ie("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(ne){c=ne},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return h===null&&v&&(h=new XRWebGLBinding(i,t)),h},this.getFrame=function(){return _},this.getSession=function(){return i},this.setSession=async function(ne){if(i=ne,i!==null){if(T=e.getRenderTarget(),i.addEventListener("select",k),i.addEventListener("selectstart",k),i.addEventListener("selectend",k),i.addEventListener("squeeze",k),i.addEventListener("squeezestart",k),i.addEventListener("squeezeend",k),i.addEventListener("end",q),i.addEventListener("inputsourceschange",W),b.xrCompatible!==!0&&await t.makeXRCompatible(),x=e.getPixelRatio(),e.getSize(R),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let ae=null,Be=null,Oe=null;b.depth&&(Oe=b.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ae=b.stencil?Mi:jn,Be=b.stencil?Ns:Nn);const De={colorFormat:t.RGBA8,depthFormat:Oe,scaleFactor:r};h=this.getBinding(),d=h.createProjectionLayer(De),i.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),S=new Ln(d.textureWidth,d.textureHeight,{format:pn,type:on,depthTexture:new ns(d.textureWidth,d.textureHeight,Be,void 0,void 0,void 0,void 0,void 0,void 0,ae),stencilBuffer:b.stencil,colorSpace:e.outputColorSpace,samples:b.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const ae={antialias:b.antialias,alpha:!0,depth:b.depth,stencil:b.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(i,t,ae),i.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),S=new Ln(f.framebufferWidth,f.framebufferHeight,{format:pn,type:on,colorSpace:e.outputColorSpace,stencilBuffer:b.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}S.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await i.requestReferenceSpace(o),qe.setContext(i),qe.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function W(ne){for(let he=0;he<ne.removed.length;he++){const ae=ne.removed[he],Be=E.indexOf(ae);Be>=0&&(E[Be]=null,w[Be].disconnect(ae))}for(let he=0;he<ne.added.length;he++){const ae=ne.added[he];let Be=E.indexOf(ae);if(Be===-1){for(let De=0;De<w.length;De++)if(De>=E.length){E.push(ae),Be=De;break}else if(E[De]===null){E[De]=ae,Be=De;break}if(Be===-1)break}const Oe=w[Be];Oe&&Oe.connect(ae)}}const ee=new C,K=new C;function le(ne,he,ae){ee.setFromMatrixPosition(he.matrixWorld),K.setFromMatrixPosition(ae.matrixWorld);const Be=ee.distanceTo(K),Oe=he.projectionMatrix.elements,De=ae.projectionMatrix.elements,ft=Oe[14]/(Oe[10]-1),Ge=Oe[14]/(Oe[10]+1),je=(Oe[9]+1)/Oe[5],Le=(Oe[9]-1)/Oe[5],Ve=(Oe[8]-1)/Oe[0],nt=(De[8]+1)/De[0],at=ft*Ve,Et=ft*nt,lt=Be/(-Ve+nt),et=lt*-Ve;if(he.matrixWorld.decompose(ne.position,ne.quaternion,ne.scale),ne.translateX(et),ne.translateZ(lt),ne.matrixWorld.compose(ne.position,ne.quaternion,ne.scale),ne.matrixWorldInverse.copy(ne.matrixWorld).invert(),Oe[10]===-1)ne.projectionMatrix.copy(he.projectionMatrix),ne.projectionMatrixInverse.copy(he.projectionMatrixInverse);else{const vt=ft+lt,U=Ge+lt,G=at-et,J=Et+(Be-et),y=je*Ge/U*vt,g=Le*Ge/U*vt;ne.projectionMatrix.makePerspective(G,J,y,g,vt,U),ne.projectionMatrixInverse.copy(ne.projectionMatrix).invert()}}function pe(ne,he){he===null?ne.matrixWorld.copy(ne.matrix):ne.matrixWorld.multiplyMatrices(he.matrixWorld,ne.matrix),ne.matrixWorldInverse.copy(ne.matrixWorld).invert()}this.updateCamera=function(ne){if(i===null)return;let he=ne.near,ae=ne.far;m.texture!==null&&(m.depthNear>0&&(he=m.depthNear),m.depthFar>0&&(ae=m.depthFar)),F.near=D.near=A.near=he,F.far=D.far=A.far=ae,($!==F.near||j!==F.far)&&(i.updateRenderState({depthNear:F.near,depthFar:F.far}),$=F.near,j=F.far),F.layers.mask=ne.layers.mask|6,A.layers.mask=F.layers.mask&-5,D.layers.mask=F.layers.mask&-3;const Be=ne.parent,Oe=F.cameras;pe(F,Be);for(let De=0;De<Oe.length;De++)pe(Oe[De],Be);Oe.length===2?le(F,A,D):F.projectionMatrix.copy(A.projectionMatrix),Me(ne,F,Be)};function Me(ne,he,ae){ae===null?ne.matrix.copy(he.matrixWorld):(ne.matrix.copy(ae.matrixWorld),ne.matrix.invert(),ne.matrix.multiply(he.matrixWorld)),ne.matrix.decompose(ne.position,ne.quaternion,ne.scale),ne.updateMatrixWorld(!0),ne.projectionMatrix.copy(he.projectionMatrix),ne.projectionMatrixInverse.copy(he.projectionMatrixInverse),ne.isPerspectiveCamera&&(ne.fov=ts*2*Math.atan(1/ne.projectionMatrix.elements[5]),ne.zoom=1)}this.getCamera=function(){return F},this.getFoveation=function(){if(!(d===null&&f===null))return l},this.setFoveation=function(ne){l=ne,d!==null&&(d.fixedFoveation=ne),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=ne)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(F)},this.getCameraTexture=function(ne){return p[ne]};let Ye=null;function rt(ne,he){if(u=he.getViewerPose(c||a),_=he,u!==null){const ae=u.views;f!==null&&(e.setRenderTargetFramebuffer(S,f.framebuffer),e.setRenderTarget(S));let Be=!1;ae.length!==F.cameras.length&&(F.cameras.length=0,Be=!0);for(let Ge=0;Ge<ae.length;Ge++){const je=ae[Ge];let Le=null;if(f!==null)Le=f.getViewport(je);else{const nt=h.getViewSubImage(d,je);Le=nt.viewport,Ge===0&&(e.setRenderTargetTextures(S,nt.colorTexture,nt.depthStencilTexture),e.setRenderTarget(S))}let Ve=P[Ge];Ve===void 0&&(Ve=new Qt,Ve.layers.enable(Ge),Ve.viewport=new gt,P[Ge]=Ve),Ve.matrix.fromArray(je.transform.matrix),Ve.matrix.decompose(Ve.position,Ve.quaternion,Ve.scale),Ve.projectionMatrix.fromArray(je.projectionMatrix),Ve.projectionMatrixInverse.copy(Ve.projectionMatrix).invert(),Ve.viewport.set(Le.x,Le.y,Le.width,Le.height),Ge===0&&(F.matrix.copy(Ve.matrix),F.matrix.decompose(F.position,F.quaternion,F.scale)),Be===!0&&F.cameras.push(Ve)}const Oe=i.enabledFeatures;if(Oe&&Oe.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&v){h=n.getBinding();const Ge=h.getDepthInformation(ae[0]);Ge&&Ge.isValid&&Ge.texture&&m.init(Ge,i.renderState)}if(Oe&&Oe.includes("camera-access")&&v){e.state.unbindTexture(),h=n.getBinding();for(let Ge=0;Ge<ae.length;Ge++){const je=ae[Ge].camera;if(je){let Le=p[je];Le||(Le=new Su,p[je]=Le);const Ve=h.getCameraImage(je);Le.sourceTexture=Ve}}}}for(let ae=0;ae<w.length;ae++){const Be=E[ae],Oe=w[ae];Be!==null&&Oe!==void 0&&Oe.update(Be,he,c||a)}Ye&&Ye(ne,he),he.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:he}),_=null}const qe=new Tu;qe.setAnimationLoop(rt),this.setAnimationLoop=function(ne){Ye=ne},this.dispose=function(){}}}const Sx=new We,Iu=new He;Iu.set(-1,0,0,0,1,0,0,0,1);function yx(s,e){function t(m,p){m.matrixAutoUpdate===!0&&m.updateMatrix(),p.value.copy(m.matrix)}function n(m,p){p.color.getRGB(m.fogColor.value,yu(s)),p.isFog?(m.fogNear.value=p.near,m.fogFar.value=p.far):p.isFogExp2&&(m.fogDensity.value=p.density)}function i(m,p,b,T,S){p.isNodeMaterial?p.uniformsNeedUpdate=!1:p.isMeshBasicMaterial?r(m,p):p.isMeshLambertMaterial?(r(m,p),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)):p.isMeshToonMaterial?(r(m,p),h(m,p)):p.isMeshPhongMaterial?(r(m,p),u(m,p),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)):p.isMeshStandardMaterial?(r(m,p),d(m,p),p.isMeshPhysicalMaterial&&f(m,p,S)):p.isMeshMatcapMaterial?(r(m,p),_(m,p)):p.isMeshDepthMaterial?r(m,p):p.isMeshDistanceMaterial?(r(m,p),v(m,p)):p.isMeshNormalMaterial?r(m,p):p.isLineBasicMaterial?(a(m,p),p.isLineDashedMaterial&&o(m,p)):p.isPointsMaterial?l(m,p,b,T):p.isSpriteMaterial?c(m,p):p.isShadowMaterial?(m.color.value.copy(p.color),m.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function r(m,p){m.opacity.value=p.opacity,p.color&&m.diffuse.value.copy(p.color),p.emissive&&m.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(m.map.value=p.map,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.bumpMap&&(m.bumpMap.value=p.bumpMap,t(p.bumpMap,m.bumpMapTransform),m.bumpScale.value=p.bumpScale,p.side===tn&&(m.bumpScale.value*=-1)),p.normalMap&&(m.normalMap.value=p.normalMap,t(p.normalMap,m.normalMapTransform),m.normalScale.value.copy(p.normalScale),p.side===tn&&m.normalScale.value.negate()),p.displacementMap&&(m.displacementMap.value=p.displacementMap,t(p.displacementMap,m.displacementMapTransform),m.displacementScale.value=p.displacementScale,m.displacementBias.value=p.displacementBias),p.emissiveMap&&(m.emissiveMap.value=p.emissiveMap,t(p.emissiveMap,m.emissiveMapTransform)),p.specularMap&&(m.specularMap.value=p.specularMap,t(p.specularMap,m.specularMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest);const b=e.get(p),T=b.envMap,S=b.envMapRotation;T&&(m.envMap.value=T,m.envMapRotation.value.setFromMatrix4(Sx.makeRotationFromEuler(S)).transpose(),T.isCubeTexture&&T.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(Iu),m.reflectivity.value=p.reflectivity,m.ior.value=p.ior,m.refractionRatio.value=p.refractionRatio),p.lightMap&&(m.lightMap.value=p.lightMap,m.lightMapIntensity.value=p.lightMapIntensity,t(p.lightMap,m.lightMapTransform)),p.aoMap&&(m.aoMap.value=p.aoMap,m.aoMapIntensity.value=p.aoMapIntensity,t(p.aoMap,m.aoMapTransform))}function a(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform))}function o(m,p){m.dashSize.value=p.dashSize,m.totalSize.value=p.dashSize+p.gapSize,m.scale.value=p.scale}function l(m,p,b,T){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.size.value=p.size*b,m.scale.value=T*.5,p.map&&(m.map.value=p.map,t(p.map,m.uvTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function c(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.rotation.value=p.rotation,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function u(m,p){m.specular.value.copy(p.specular),m.shininess.value=Math.max(p.shininess,1e-4)}function h(m,p){p.gradientMap&&(m.gradientMap.value=p.gradientMap)}function d(m,p){m.metalness.value=p.metalness,p.metalnessMap&&(m.metalnessMap.value=p.metalnessMap,t(p.metalnessMap,m.metalnessMapTransform)),m.roughness.value=p.roughness,p.roughnessMap&&(m.roughnessMap.value=p.roughnessMap,t(p.roughnessMap,m.roughnessMapTransform)),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)}function f(m,p,b){m.ior.value=p.ior,p.sheen>0&&(m.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),m.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(m.sheenColorMap.value=p.sheenColorMap,t(p.sheenColorMap,m.sheenColorMapTransform)),p.sheenRoughnessMap&&(m.sheenRoughnessMap.value=p.sheenRoughnessMap,t(p.sheenRoughnessMap,m.sheenRoughnessMapTransform))),p.clearcoat>0&&(m.clearcoat.value=p.clearcoat,m.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(m.clearcoatMap.value=p.clearcoatMap,t(p.clearcoatMap,m.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,t(p.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(m.clearcoatNormalMap.value=p.clearcoatNormalMap,t(p.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===tn&&m.clearcoatNormalScale.value.negate())),p.dispersion>0&&(m.dispersion.value=p.dispersion),p.iridescence>0&&(m.iridescence.value=p.iridescence,m.iridescenceIOR.value=p.iridescenceIOR,m.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(m.iridescenceMap.value=p.iridescenceMap,t(p.iridescenceMap,m.iridescenceMapTransform)),p.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=p.iridescenceThicknessMap,t(p.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),p.transmission>0&&(m.transmission.value=p.transmission,m.transmissionSamplerMap.value=b.texture,m.transmissionSamplerSize.value.set(b.width,b.height),p.transmissionMap&&(m.transmissionMap.value=p.transmissionMap,t(p.transmissionMap,m.transmissionMapTransform)),m.thickness.value=p.thickness,p.thicknessMap&&(m.thicknessMap.value=p.thicknessMap,t(p.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=p.attenuationDistance,m.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(m.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(m.anisotropyMap.value=p.anisotropyMap,t(p.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=p.specularIntensity,m.specularColor.value.copy(p.specularColor),p.specularColorMap&&(m.specularColorMap.value=p.specularColorMap,t(p.specularColorMap,m.specularColorMapTransform)),p.specularIntensityMap&&(m.specularIntensityMap.value=p.specularIntensityMap,t(p.specularIntensityMap,m.specularIntensityMapTransform))}function _(m,p){p.matcap&&(m.matcap.value=p.matcap)}function v(m,p){const b=e.get(p).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:i}}function bx(s,e,t,n){let i={},r={},a=[];const o=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function l(S,w){const E=w.program;n.uniformBlockBinding(S,E)}function c(S,w){let E=i[S.id];E===void 0&&(m(S),E=u(S),i[S.id]=E,S.addEventListener("dispose",b));const R=w.program;n.updateUBOMapping(S,R);const x=e.render.frame;r[S.id]!==x&&(d(S),r[S.id]=x)}function u(S){const w=h();S.__bindingPointIndex=w;const E=s.createBuffer(),R=S.__size,x=S.usage;return s.bindBuffer(s.UNIFORM_BUFFER,E),s.bufferData(s.UNIFORM_BUFFER,R,x),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,w,E),E}function h(){for(let S=0;S<o;S++)if(a.indexOf(S)===-1)return a.push(S),S;return ze("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(S){const w=i[S.id],E=S.uniforms,R=S.__cache;s.bindBuffer(s.UNIFORM_BUFFER,w);for(let x=0,A=E.length;x<A;x++){const D=E[x];if(Array.isArray(D))for(let P=0,F=D.length;P<F;P++)f(D[P],x,P,R);else f(D,x,0,R)}s.bindBuffer(s.UNIFORM_BUFFER,null)}function f(S,w,E,R){if(v(S,w,E,R)===!0){const x=S.__offset,A=S.value;if(Array.isArray(A)){let D=0;for(let P=0;P<A.length;P++){const F=A[P],$=p(F);_(F,S.__data,D),typeof F!="number"&&typeof F!="boolean"&&!F.isMatrix3&&!ArrayBuffer.isView(F)&&(D+=$.storage/Float32Array.BYTES_PER_ELEMENT)}}else _(A,S.__data,0);s.bufferSubData(s.UNIFORM_BUFFER,x,S.__data)}}function _(S,w,E){typeof S=="number"||typeof S=="boolean"?w[0]=S:S.isMatrix3?(w[0]=S.elements[0],w[1]=S.elements[1],w[2]=S.elements[2],w[3]=0,w[4]=S.elements[3],w[5]=S.elements[4],w[6]=S.elements[5],w[7]=0,w[8]=S.elements[6],w[9]=S.elements[7],w[10]=S.elements[8],w[11]=0):ArrayBuffer.isView(S)?w.set(new S.constructor(S.buffer,S.byteOffset,w.length)):S.toArray(w,E)}function v(S,w,E,R){const x=S.value,A=w+"_"+E;if(R[A]===void 0)return typeof x=="number"||typeof x=="boolean"?R[A]=x:ArrayBuffer.isView(x)?R[A]=x.slice():R[A]=x.clone(),!0;{const D=R[A];if(typeof x=="number"||typeof x=="boolean"){if(D!==x)return R[A]=x,!0}else{if(ArrayBuffer.isView(x))return!0;if(D.equals(x)===!1)return D.copy(x),!0}}return!1}function m(S){const w=S.uniforms;let E=0;const R=16;for(let A=0,D=w.length;A<D;A++){const P=Array.isArray(w[A])?w[A]:[w[A]];for(let F=0,$=P.length;F<$;F++){const j=P[F],k=Array.isArray(j.value)?j.value:[j.value];for(let q=0,W=k.length;q<W;q++){const ee=k[q],K=p(ee),le=E%R,pe=le%K.boundary,Me=le+pe;E+=pe,Me!==0&&R-Me<K.storage&&(E+=R-Me),j.__data=new Float32Array(K.storage/Float32Array.BYTES_PER_ELEMENT),j.__offset=E,E+=K.storage}}}const x=E%R;return x>0&&(E+=R-x),S.__size=E,S.__cache={},this}function p(S){const w={boundary:0,storage:0};return typeof S=="number"||typeof S=="boolean"?(w.boundary=4,w.storage=4):S.isVector2?(w.boundary=8,w.storage=8):S.isVector3||S.isColor?(w.boundary=16,w.storage=12):S.isVector4?(w.boundary=16,w.storage=16):S.isMatrix3?(w.boundary=48,w.storage=48):S.isMatrix4?(w.boundary=64,w.storage=64):S.isTexture?Ie("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(S)?(w.boundary=16,w.storage=S.byteLength):Ie("WebGLRenderer: Unsupported uniform value type.",S),w}function b(S){const w=S.target;w.removeEventListener("dispose",b);const E=a.indexOf(w.__bindingPointIndex);a.splice(E,1),s.deleteBuffer(i[w.id]),delete i[w.id],delete r[w.id]}function T(){for(const S in i)s.deleteBuffer(i[S]);a=[],i={},r={}}return{bind:l,update:c,dispose:T}}const Ex=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let Tn=null;function Tx(){return Tn===null&&(Tn=new Ko(Ex,16,16,Ei,$n),Tn.name="DFG_LUT",Tn.minFilter=Bt,Tn.magFilter=Bt,Tn.wrapS=Rn,Tn.wrapT=Rn,Tn.generateMipmaps=!1,Tn.needsUpdate=!0),Tn}class Ax{constructor(e={}){const{canvas:t=Wh(),context:n=null,depth:i=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1,reversedDepthBuffer:d=!1,outputBufferType:f=on}=e;this.isWebGLRenderer=!0;let _;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");_=n.getContextAttributes().alpha}else _=a;const v=f,m=new Set([Vo,zo,ko]),p=new Set([on,Nn,Ds,Ns,Fo,Oo]),b=new Uint32Array(4),T=new Int32Array(4),S=new C;let w=null,E=null;const R=[],x=[];let A=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Pn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const D=this;let P=!1,F=null,$=null,j=null,k=null;this._outputColorSpace=Ht;let q=0,W=0,ee=null,K=-1,le=null;const pe=new gt,Me=new gt;let Ye=null;const rt=new Ue(0);let qe=0,ne=t.width,he=t.height,ae=1,Be=null,Oe=null;const De=new gt(0,0,ne,he),ft=new gt(0,0,ne,he);let Ge=!1;const je=new $o;let Le=!1,Ve=!1;const nt=new We,at=new C,Et=new gt,lt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let et=!1;function vt(){return ee===null?ae:1}let U=n;function G(M,O){return t.getContext(M,O)}try{const M={alpha:!0,depth:i,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${No}`),t.addEventListener("webglcontextlost",St,!1),t.addEventListener("webglcontextrestored",ct,!1),t.addEventListener("webglcontextcreationerror",cn,!1),U===null){const O="webgl2";if(U=G(O,M),U===null)throw G(O)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(M){throw ze("WebGLRenderer: "+M.message),M}let J,y,g,L,B,z,Q,re,X,Z,oe,me,ue,ce,Ee,Te,Re,I,fe,te,de,ge,se;function be(){J=new Tg(U),J.init(),de=new gx(U,J),y=new _g(U,J,e,de),g=new px(U,J),y.reversedDepthBuffer&&d&&g.buffers.depth.setReversed(!0),$=U.createFramebuffer(),j=U.createFramebuffer(),k=U.createFramebuffer(),L=new Rg(U),B=new ex,z=new mx(U,J,g,B,y,de,L),Q=new Eg(D),re=new If(U),ge=new mg(U,re),X=new Ag(U,re,L,ge),Z=new Pg(U,X,re,ge,L),I=new Cg(U,y,z),Ee=new xg(B),oe=new Q_(D,Q,J,y,ge,Ee),me=new yx(D,B),ue=new nx,ce=new lx(J),Re=new pg(D,Q,g,Z,_,l),Te=new fx(D,Z,y),se=new bx(U,L,y,g),fe=new gg(U,J,L),te=new wg(U,J,L),L.programs=oe.programs,D.capabilities=y,D.extensions=J,D.properties=B,D.renderLists=ue,D.shadowMap=Te,D.state=g,D.info=L}be(),v!==on&&(A=new Ig(v,t.width,t.height,o,i,r));const Ae=new Mx(D,U);this.xr=Ae,this.getContext=function(){return U},this.getContextAttributes=function(){return U.getContextAttributes()},this.forceContextLoss=function(){const M=J.get("WEBGL_lose_context");M&&M.loseContext()},this.forceContextRestore=function(){const M=J.get("WEBGL_lose_context");M&&M.restoreContext()},this.getPixelRatio=function(){return ae},this.setPixelRatio=function(M){M!==void 0&&(ae=M,this.setSize(ne,he,!1))},this.getSize=function(M){return M.set(ne,he)},this.setSize=function(M,O,Y=!0){if(Ae.isPresenting){Ie("WebGLRenderer: Can't change size while VR device is presenting.");return}ne=M,he=O,t.width=Math.floor(M*ae),t.height=Math.floor(O*ae),Y===!0&&(t.style.width=M+"px",t.style.height=O+"px"),A!==null&&A.setSize(t.width,t.height),this.setViewport(0,0,M,O)},this.getDrawingBufferSize=function(M){return M.set(ne*ae,he*ae).floor()},this.setDrawingBufferSize=function(M,O,Y){ne=M,he=O,ae=Y,t.width=Math.floor(M*Y),t.height=Math.floor(O*Y),this.setViewport(0,0,M,O)},this.setEffects=function(M){if(v===on){ze("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(M){for(let O=0;O<M.length;O++)if(M[O].isOutputPass===!0){Ie("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}A.setEffects(M||[])},this.getCurrentViewport=function(M){return M.copy(pe)},this.getViewport=function(M){return M.copy(De)},this.setViewport=function(M,O,Y,V){M.isVector4?De.set(M.x,M.y,M.z,M.w):De.set(M,O,Y,V),g.viewport(pe.copy(De).multiplyScalar(ae).round())},this.getScissor=function(M){return M.copy(ft)},this.setScissor=function(M,O,Y,V){M.isVector4?ft.set(M.x,M.y,M.z,M.w):ft.set(M,O,Y,V),g.scissor(Me.copy(ft).multiplyScalar(ae).round())},this.getScissorTest=function(){return Ge},this.setScissorTest=function(M){g.setScissorTest(Ge=M)},this.setOpaqueSort=function(M){Be=M},this.setTransparentSort=function(M){Oe=M},this.getClearColor=function(M){return M.copy(Re.getClearColor())},this.setClearColor=function(){Re.setClearColor(...arguments)},this.getClearAlpha=function(){return Re.getClearAlpha()},this.setClearAlpha=function(){Re.setClearAlpha(...arguments)},this.clear=function(M=!0,O=!0,Y=!0){let V=0;if(M){let H=!1;if(ee!==null){const _e=ee.texture.format;H=m.has(_e)}if(H){const _e=ee.texture.type,Se=p.has(_e),ve=Re.getClearColor(),Pe=Re.getClearAlpha(),Ne=ve.r,Xe=ve.g,Ze=ve.b;Se?(b[0]=Ne,b[1]=Xe,b[2]=Ze,b[3]=Pe,U.clearBufferuiv(U.COLOR,0,b)):(T[0]=Ne,T[1]=Xe,T[2]=Ze,T[3]=Pe,U.clearBufferiv(U.COLOR,0,T))}else V|=U.COLOR_BUFFER_BIT}O&&(V|=U.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),Y&&(V|=U.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),V!==0&&U.clear(V)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(M){M.setRenderer(this),F=M},this.dispose=function(){t.removeEventListener("webglcontextlost",St,!1),t.removeEventListener("webglcontextrestored",ct,!1),t.removeEventListener("webglcontextcreationerror",cn,!1),Re.dispose(),ue.dispose(),ce.dispose(),B.dispose(),Q.dispose(),Z.dispose(),ge.dispose(),se.dispose(),oe.dispose(),Ae.dispose(),Ae.removeEventListener("sessionstart",Gs),Ae.removeEventListener("sessionend",fs),Bn.stop()};function St(M){M.preventDefault(),Ir("WebGLRenderer: Context Lost."),P=!0}function ct(){Ir("WebGLRenderer: Context Restored."),P=!1;const M=L.autoReset,O=Te.enabled,Y=Te.autoUpdate,V=Te.needsUpdate,H=Te.type;be(),L.autoReset=M,Te.enabled=O,Te.autoUpdate=Y,Te.needsUpdate=V,Te.type=H}function cn(M){ze("WebGLRenderer: A WebGL context could not be created. Reason: ",M.statusMessage)}function qt(M){const O=M.target;O.removeEventListener("dispose",qt),Hs(O)}function Hs(M){Wr(M),B.remove(M)}function Wr(M){const O=B.get(M).programs;O!==void 0&&(O.forEach(function(Y){oe.releaseProgram(Y)}),M.isShaderMaterial&&oe.releaseShaderCache(M))}this.renderBufferDirect=function(M,O,Y,V,H,_e){O===null&&(O=lt);const Se=H.isMesh&&H.matrixWorld.determinantAffine()<0,ve=Ut(M,O,Y,V,H);g.setMaterial(V,Se);let Pe=Y.index,Ne=1;if(V.wireframe===!0){if(Pe=X.getWireframeAttribute(Y),Pe===void 0)return;Ne=2}const Xe=Y.drawRange,Ze=Y.attributes.position;let Fe=Xe.start*Ne,pt=(Xe.start+Xe.count)*Ne;_e!==null&&(Fe=Math.max(Fe,_e.start*Ne),pt=Math.min(pt,(_e.start+_e.count)*Ne)),Pe!==null?(Fe=Math.max(Fe,0),pt=Math.min(pt,Pe.count)):Ze!=null&&(Fe=Math.max(Fe,0),pt=Math.min(pt,Ze.count));const Ct=pt-Fe;if(Ct<0||Ct===1/0)return;ge.setup(H,V,ve,Y,Pe);let wt,_t=fe;if(Pe!==null&&(wt=re.get(Pe),_t=te,_t.setIndex(wt)),H.isMesh)V.wireframe===!0?(g.setLineWidth(V.wireframeLinewidth*vt()),_t.setMode(U.LINES)):_t.setMode(U.TRIANGLES);else if(H.isLine){let Kt=V.linewidth;Kt===void 0&&(Kt=1),g.setLineWidth(Kt*vt()),H.isLineSegments?_t.setMode(U.LINES):H.isLineLoop?_t.setMode(U.LINE_LOOP):_t.setMode(U.LINE_STRIP)}else H.isPoints?_t.setMode(U.POINTS):H.isSprite&&_t.setMode(U.TRIANGLES);if(H.isBatchedMesh)if(J.get("WEBGL_multi_draw"))_t.renderMultiDraw(H._multiDrawStarts,H._multiDrawCounts,H._multiDrawCount);else{const Kt=H._multiDrawStarts,ye=H._multiDrawCounts,nn=H._multiDrawCount,st=Pe?re.get(Pe).bytesPerElement:1,un=B.get(V).currentProgram.getUniforms();for(let bn=0;bn<nn;bn++)un.setValue(U,"_gl_DrawID",bn),_t.render(Kt[bn]/st,ye[bn])}else if(H.isInstancedMesh)_t.renderInstances(Fe,Ct,H.count);else if(Y.isInstancedBufferGeometry){const Kt=Y._maxInstanceCount!==void 0?Y._maxInstanceCount:1/0,ye=Math.min(Y.instanceCount,Kt);_t.renderInstances(Fe,Ct,ye)}else _t.render(Fe,Ct)};function us(M,O,Y){M.transparent===!0&&M.side===an&&M.forceSinglePass===!1?(M.side=tn,M.needsUpdate=!0,tt(M,O,Y),M.side=Dn,M.needsUpdate=!0,tt(M,O,Y),M.side=an):tt(M,O,Y)}this.compile=function(M,O,Y=null){Y===null&&(Y=M),E=ce.get(Y),E.init(O),x.push(E),Y.traverseVisible(function(H){H.isLight&&H.layers.test(O.layers)&&(E.pushLight(H),H.castShadow&&E.pushShadow(H))}),M!==Y&&M.traverseVisible(function(H){H.isLight&&H.layers.test(O.layers)&&(E.pushLight(H),H.castShadow&&E.pushShadow(H))}),E.setupLights();const V=new Set;return M.traverse(function(H){if(!(H.isMesh||H.isPoints||H.isLine||H.isSprite))return;const _e=H.material;if(_e)if(Array.isArray(_e))for(let Se=0;Se<_e.length;Se++){const ve=_e[Se];us(ve,Y,H),V.add(ve)}else us(_e,Y,H),V.add(_e)}),E=x.pop(),V},this.compileAsync=function(M,O,Y=null){const V=this.compile(M,O,Y);return new Promise(H=>{function _e(){if(V.forEach(function(Se){B.get(Se).currentProgram.isReady()&&V.delete(Se)}),V.size===0){H(M);return}setTimeout(_e,10)}J.get("KHR_parallel_shader_compile")!==null?_e():setTimeout(_e,10)})};let hs=null;function ds(M){hs&&hs(M)}function Gs(){Bn.stop()}function fs(){Bn.start()}const Bn=new Tu;Bn.setAnimationLoop(ds),typeof self<"u"&&Bn.setContext(self),this.setAnimationLoop=function(M){hs=M,Ae.setAnimationLoop(M),M===null?Bn.stop():Bn.start()},Ae.addEventListener("sessionstart",Gs),Ae.addEventListener("sessionend",fs),this.render=function(M,O){if(O!==void 0&&O.isCamera!==!0){ze("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(P===!0)return;F!==null&&F.renderStart(M,O);const Y=Ae.enabled===!0&&Ae.isPresenting===!0,V=A!==null&&(ee===null||Y)&&A.begin(D,ee);if(M.matrixWorldAutoUpdate===!0&&M.updateMatrixWorld(),O.parent===null&&O.matrixWorldAutoUpdate===!0&&O.updateMatrixWorld(),Ae.enabled===!0&&Ae.isPresenting===!0&&(A===null||A.isCompositing()===!1)&&(Ae.cameraAutoUpdate===!0&&Ae.updateCamera(O),O=Ae.getCamera()),M.isScene===!0&&M.onBeforeRender(D,M,O,ee),E=ce.get(M,x.length),E.init(O),E.state.textureUnits=z.getTextureUnits(),x.push(E),nt.multiplyMatrices(O.projectionMatrix,O.matrixWorldInverse),je.setFromProjectionMatrix(nt,Cn,O.reversedDepth),Ve=this.localClippingEnabled,Le=Ee.init(this.clippingPlanes,Ve),w=ue.get(M,R.length),w.init(),R.push(w),Ae.enabled===!0&&Ae.isPresenting===!0){const Se=D.xr.getDepthSensingMesh();Se!==null&&Ai(Se,O,-1/0,D.sortObjects)}Ai(M,O,0,D.sortObjects),w.finish(),D.sortObjects===!0&&w.sort(Be,Oe,O.reversedDepth),et=Ae.enabled===!1||Ae.isPresenting===!1||Ae.hasDepthSensing()===!1,et&&Re.addToRenderList(w,M),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Le===!0&&Ee.beginShadows();const H=E.state.shadowsArray;if(Te.render(H,M,O),Le===!0&&Ee.endShadows(),(V&&A.hasRenderPass())===!1){const Se=w.opaque,ve=w.transmissive;if(E.setupLights(),O.isArrayCamera){const Pe=O.cameras;if(ve.length>0)for(let Ne=0,Xe=Pe.length;Ne<Xe;Ne++){const Ze=Pe[Ne];N(Se,ve,M,Ze)}et&&Re.render(M);for(let Ne=0,Xe=Pe.length;Ne<Xe;Ne++){const Ze=Pe[Ne];ps(w,M,Ze,Ze.viewport)}}else ve.length>0&&N(Se,ve,M,O),et&&Re.render(M),ps(w,M,O)}ee!==null&&W===0&&(z.updateMultisampleRenderTarget(ee),z.updateRenderTargetMipmap(ee)),V&&A.end(D),M.isScene===!0&&M.onAfterRender(D,M,O),ge.resetDefaultState(),K=-1,le=null,x.pop(),x.length>0?(E=x[x.length-1],z.setTextureUnits(E.state.textureUnits),Le===!0&&Ee.setGlobalState(D.clippingPlanes,E.state.camera)):E=null,R.pop(),R.length>0?w=R[R.length-1]:w=null,F!==null&&F.renderEnd()};function Ai(M,O,Y,V){if(M.visible===!1)return;if(M.layers.test(O.layers)){if(M.isGroup)Y=M.renderOrder;else if(M.isLOD)M.autoUpdate===!0&&M.update(O);else if(M.isLightProbeGrid)E.pushLightProbeGrid(M);else if(M.isLight)E.pushLight(M),M.castShadow&&E.pushShadow(M);else if(M.isSprite){if(!M.frustumCulled||je.intersectsSprite(M)){V&&Et.setFromMatrixPosition(M.matrixWorld).applyMatrix4(nt);const Se=Z.update(M),ve=M.material;ve.visible&&w.push(M,Se,ve,Y,Et.z,null)}}else if((M.isMesh||M.isLine||M.isPoints)&&(!M.frustumCulled||je.intersectsObject(M))){const Se=Z.update(M),ve=M.material;if(V&&(M.boundingSphere!==void 0?(M.boundingSphere===null&&M.computeBoundingSphere(),Et.copy(M.boundingSphere.center)):(Se.boundingSphere===null&&Se.computeBoundingSphere(),Et.copy(Se.boundingSphere.center)),Et.applyMatrix4(M.matrixWorld).applyMatrix4(nt)),Array.isArray(ve)){const Pe=Se.groups;for(let Ne=0,Xe=Pe.length;Ne<Xe;Ne++){const Ze=Pe[Ne],Fe=ve[Ze.materialIndex];Fe&&Fe.visible&&w.push(M,Se,Fe,Y,Et.z,Ze)}}else ve.visible&&w.push(M,Se,ve,Y,Et.z,null)}}const _e=M.children;for(let Se=0,ve=_e.length;Se<ve;Se++)Ai(_e[Se],O,Y,V)}function ps(M,O,Y,V){const{opaque:H,transmissive:_e,transparent:Se}=M;E.setupLightsView(Y),Le===!0&&Ee.setGlobalState(D.clippingPlanes,Y),V&&g.viewport(pe.copy(V)),H.length>0&&Ce(H,O,Y),_e.length>0&&Ce(_e,O,Y),Se.length>0&&Ce(Se,O,Y),g.buffers.depth.setTest(!0),g.buffers.depth.setMask(!0),g.buffers.color.setMask(!0),g.setPolygonOffset(!1)}function N(M,O,Y,V){if((Y.isScene===!0?Y.overrideMaterial:null)!==null)return;if(E.state.transmissionRenderTarget[V.id]===void 0){const Fe=J.has("EXT_color_buffer_half_float")||J.has("EXT_color_buffer_float");E.state.transmissionRenderTarget[V.id]=new Ln(1,1,{generateMipmaps:!0,type:Fe?$n:on,minFilter:Yn,samples:Math.max(4,y.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Qe.workingColorSpace})}const _e=E.state.transmissionRenderTarget[V.id],Se=V.viewport||pe;_e.setSize(Se.z*D.transmissionResolutionScale,Se.w*D.transmissionResolutionScale);const ve=D.getRenderTarget(),Pe=D.getActiveCubeFace(),Ne=D.getActiveMipmapLevel();D.setRenderTarget(_e),D.getClearColor(rt),qe=D.getClearAlpha(),qe<1&&D.setClearColor(16777215,.5),D.clear(),et&&Re.render(Y);const Xe=D.toneMapping;D.toneMapping=Pn;const Ze=V.viewport;if(V.viewport!==void 0&&(V.viewport=void 0),E.setupLightsView(V),Le===!0&&Ee.setGlobalState(D.clippingPlanes,V),Ce(M,Y,V),z.updateMultisampleRenderTarget(_e),z.updateRenderTargetMipmap(_e),J.has("WEBGL_multisampled_render_to_texture")===!1){let Fe=!1;for(let pt=0,Ct=O.length;pt<Ct;pt++){const wt=O[pt],{object:_t,geometry:Kt,material:ye,group:nn}=wt;if(ye.side===an&&_t.layers.test(V.layers)){const st=ye.side;ye.side=tn,ye.needsUpdate=!0,it(_t,Y,V,Kt,ye,nn),ye.side=st,ye.needsUpdate=!0,Fe=!0}}Fe===!0&&(z.updateMultisampleRenderTarget(_e),z.updateRenderTargetMipmap(_e))}D.setRenderTarget(ve,Pe,Ne),D.setClearColor(rt,qe),Ze!==void 0&&(V.viewport=Ze),D.toneMapping=Xe}function Ce(M,O,Y){const V=O.isScene===!0?O.overrideMaterial:null;for(let H=0,_e=M.length;H<_e;H++){const Se=M[H],{object:ve,geometry:Pe,group:Ne}=Se;let Xe=Se.material;Xe.allowOverride===!0&&V!==null&&(Xe=V),ve.layers.test(Y.layers)&&it(ve,O,Y,Pe,Xe,Ne)}}function it(M,O,Y,V,H,_e){M.onBeforeRender(D,O,Y,V,H,_e),M.modelViewMatrix.multiplyMatrices(Y.matrixWorldInverse,M.matrixWorld),M.normalMatrix.getNormalMatrix(M.modelViewMatrix),H.onBeforeRender(D,O,Y,V,M,_e),H.transparent===!0&&H.side===an&&H.forceSinglePass===!1?(H.side=tn,H.needsUpdate=!0,D.renderBufferDirect(Y,O,V,H,M,_e),H.side=Dn,H.needsUpdate=!0,D.renderBufferDirect(Y,O,V,H,M,_e),H.side=an):D.renderBufferDirect(Y,O,V,H,M,_e),M.onAfterRender(D,O,Y,V,H,_e)}function tt(M,O,Y){O.isScene!==!0&&(O=lt);const V=B.get(M),H=E.state.lights,_e=E.state.shadowsArray,Se=H.state.version,ve=oe.getParameters(M,H.state,_e,O,Y,E.state.lightProbeGridArray),Pe=oe.getProgramCacheKey(ve);let Ne=V.programs;V.environment=M.isMeshStandardMaterial||M.isMeshLambertMaterial||M.isMeshPhongMaterial?O.environment:null,V.fog=O.fog;const Xe=M.isMeshStandardMaterial||M.isMeshLambertMaterial&&!M.envMap||M.isMeshPhongMaterial&&!M.envMap;V.envMap=Q.get(M.envMap||V.environment,Xe),V.envMapRotation=V.environment!==null&&M.envMap===null?O.environmentRotation:M.envMapRotation,Ne===void 0&&(M.addEventListener("dispose",qt),Ne=new Map,V.programs=Ne);let Ze=Ne.get(Pe);if(Ze!==void 0){if(V.currentProgram===Ze&&V.lightsStateVersion===Se)return Tt(M,ve),Ze}else ve.uniforms=oe.getUniforms(M),F!==null&&M.isNodeMaterial&&F.build(M,Y,ve),M.onBeforeCompile(ve,D),Ze=oe.acquireProgram(ve,Pe),Ne.set(Pe,Ze),V.uniforms=ve.uniforms;const Fe=V.uniforms;return(!M.isShaderMaterial&&!M.isRawShaderMaterial||M.clipping===!0)&&(Fe.clippingPlanes=Ee.uniform),Tt(M,ve),V.needsLights=Rt(M),V.lightsStateVersion=Se,V.needsLights&&(Fe.ambientLightColor.value=H.state.ambient,Fe.lightProbe.value=H.state.probe,Fe.directionalLights.value=H.state.directional,Fe.directionalLightShadows.value=H.state.directionalShadow,Fe.spotLights.value=H.state.spot,Fe.spotLightShadows.value=H.state.spotShadow,Fe.rectAreaLights.value=H.state.rectArea,Fe.ltc_1.value=H.state.rectAreaLTC1,Fe.ltc_2.value=H.state.rectAreaLTC2,Fe.pointLights.value=H.state.point,Fe.pointLightShadows.value=H.state.pointShadow,Fe.hemisphereLights.value=H.state.hemi,Fe.directionalShadowMatrix.value=H.state.directionalShadowMatrix,Fe.spotLightMatrix.value=H.state.spotLightMatrix,Fe.spotLightMap.value=H.state.spotLightMap,Fe.pointShadowMatrix.value=H.state.pointShadowMatrix),V.lightProbeGrid=E.state.lightProbeGridArray.length>0,V.currentProgram=Ze,V.uniformsList=null,Ze}function Xt(M){if(M.uniformsList===null){const O=M.currentProgram.getUniforms();M.uniformsList=wr.seqWithValue(O.seq,M.uniforms)}return M.uniformsList}function Tt(M,O){const Y=B.get(M);Y.outputColorSpace=O.outputColorSpace,Y.batching=O.batching,Y.batchingColor=O.batchingColor,Y.instancing=O.instancing,Y.instancingColor=O.instancingColor,Y.instancingMorph=O.instancingMorph,Y.skinning=O.skinning,Y.morphTargets=O.morphTargets,Y.morphNormals=O.morphNormals,Y.morphColors=O.morphColors,Y.morphTargetsCount=O.morphTargetsCount,Y.numClippingPlanes=O.numClippingPlanes,Y.numIntersection=O.numClipIntersection,Y.vertexAlphas=O.vertexAlphas,Y.vertexTangents=O.vertexTangents,Y.toneMapping=O.toneMapping}function yt(M,O){if(M.length===0)return null;if(M.length===1)return M[0].texture!==null?M[0]:null;S.setFromMatrixPosition(O.matrixWorld);for(let Y=0,V=M.length;Y<V;Y++){const H=M[Y];if(H.texture!==null&&H.boundingBox.containsPoint(S))return H}return null}function Ut(M,O,Y,V,H){O.isScene!==!0&&(O=lt),z.resetTextureUnits();const _e=O.fog,Se=V.isMeshStandardMaterial||V.isMeshLambertMaterial||V.isMeshPhongMaterial?O.environment:null,ve=ee===null?D.outputColorSpace:ee.isXRRenderTarget===!0?ee.texture.colorSpace:Qe.workingColorSpace,Pe=V.isMeshStandardMaterial||V.isMeshLambertMaterial&&!V.envMap||V.isMeshPhongMaterial&&!V.envMap,Ne=Q.get(V.envMap||Se,Pe),Xe=V.vertexColors===!0&&!!Y.attributes.color&&Y.attributes.color.itemSize===4,Ze=!!Y.attributes.tangent&&(!!V.normalMap||V.anisotropy>0),Fe=!!Y.morphAttributes.position,pt=!!Y.morphAttributes.normal,Ct=!!Y.morphAttributes.color;let wt=Pn;V.toneMapped&&(ee===null||ee.isXRRenderTarget===!0)&&(wt=D.toneMapping);const _t=Y.morphAttributes.position||Y.morphAttributes.normal||Y.morphAttributes.color,Kt=_t!==void 0?_t.length:0,ye=B.get(V),nn=E.state.lights;if(Le===!0&&(Ve===!0||M!==le)){const Mt=M===le&&V.id===K;Ee.setState(V,M,Mt)}let st=!1;V.version===ye.__version?(ye.needsLights&&ye.lightsStateVersion!==nn.state.version||ye.outputColorSpace!==ve||H.isBatchedMesh&&ye.batching===!1||!H.isBatchedMesh&&ye.batching===!0||H.isBatchedMesh&&ye.batchingColor===!0&&H.colorTexture===null||H.isBatchedMesh&&ye.batchingColor===!1&&H.colorTexture!==null||H.isInstancedMesh&&ye.instancing===!1||!H.isInstancedMesh&&ye.instancing===!0||H.isSkinnedMesh&&ye.skinning===!1||!H.isSkinnedMesh&&ye.skinning===!0||H.isInstancedMesh&&ye.instancingColor===!0&&H.instanceColor===null||H.isInstancedMesh&&ye.instancingColor===!1&&H.instanceColor!==null||H.isInstancedMesh&&ye.instancingMorph===!0&&H.morphTexture===null||H.isInstancedMesh&&ye.instancingMorph===!1&&H.morphTexture!==null||ye.envMap!==Ne||V.fog===!0&&ye.fog!==_e||ye.numClippingPlanes!==void 0&&(ye.numClippingPlanes!==Ee.numPlanes||ye.numIntersection!==Ee.numIntersection)||ye.vertexAlphas!==Xe||ye.vertexTangents!==Ze||ye.morphTargets!==Fe||ye.morphNormals!==pt||ye.morphColors!==Ct||ye.toneMapping!==wt||ye.morphTargetsCount!==Kt||!!ye.lightProbeGrid!=E.state.lightProbeGridArray.length>0)&&(st=!0):(st=!0,ye.__version=V.version);let un=ye.currentProgram;st===!0&&(un=tt(V,O,H),F&&V.isNodeMaterial&&F.onUpdateProgram(V,un,ye));let bn=!1,Jn=!1,wi=!1;const xt=un.getUniforms(),Pt=ye.uniforms;if(g.useProgram(un.program)&&(bn=!0,Jn=!0,wi=!0),V.id!==K&&(K=V.id,Jn=!0),ye.needsLights){const Mt=yt(E.state.lightProbeGridArray,H);ye.lightProbeGrid!==Mt&&(ye.lightProbeGrid=Mt,Jn=!0)}if(bn||le!==M){g.buffers.depth.getReversed()&&M.reversedDepth!==!0&&(M._reversedDepth=!0,M.updateProjectionMatrix()),xt.setValue(U,"projectionMatrix",M.projectionMatrix),xt.setValue(U,"viewMatrix",M.matrixWorldInverse);const ei=xt.map.cameraPosition;ei!==void 0&&ei.setValue(U,at.setFromMatrixPosition(M.matrixWorld)),y.logarithmicDepthBuffer&&xt.setValue(U,"logDepthBufFC",2/(Math.log(M.far+1)/Math.LN2)),(V.isMeshPhongMaterial||V.isMeshToonMaterial||V.isMeshLambertMaterial||V.isMeshBasicMaterial||V.isMeshStandardMaterial||V.isShaderMaterial)&&xt.setValue(U,"isOrthographic",M.isOrthographicCamera===!0),le!==M&&(le=M,Jn=!0,wi=!0)}if(ye.needsLights&&(nn.state.directionalShadowMap.length>0&&xt.setValue(U,"directionalShadowMap",nn.state.directionalShadowMap,z),nn.state.spotShadowMap.length>0&&xt.setValue(U,"spotShadowMap",nn.state.spotShadowMap,z),nn.state.pointShadowMap.length>0&&xt.setValue(U,"pointShadowMap",nn.state.pointShadowMap,z)),H.isSkinnedMesh){xt.setOptional(U,H,"bindMatrix"),xt.setOptional(U,H,"bindMatrixInverse");const Mt=H.skeleton;Mt&&(Mt.boneTexture===null&&Mt.computeBoneTexture(),xt.setValue(U,"boneTexture",Mt.boneTexture,z))}H.isBatchedMesh&&(xt.setOptional(U,H,"batchingTexture"),xt.setValue(U,"batchingTexture",H._matricesTexture,z),xt.setOptional(U,H,"batchingIdTexture"),xt.setValue(U,"batchingIdTexture",H._indirectTexture,z),xt.setOptional(U,H,"batchingColorTexture"),H._colorsTexture!==null&&xt.setValue(U,"batchingColorTexture",H._colorsTexture,z));const Qn=Y.morphAttributes;if((Qn.position!==void 0||Qn.normal!==void 0||Qn.color!==void 0)&&I.update(H,Y,un),(Jn||ye.receiveShadow!==H.receiveShadow)&&(ye.receiveShadow=H.receiveShadow,xt.setValue(U,"receiveShadow",H.receiveShadow)),(V.isMeshStandardMaterial||V.isMeshLambertMaterial||V.isMeshPhongMaterial)&&V.envMap===null&&O.environment!==null&&(Pt.envMapIntensity.value=O.environmentIntensity),Pt.dfgLUT!==void 0&&(Pt.dfgLUT.value=Tx()),Jn){if(xt.setValue(U,"toneMappingExposure",D.toneMappingExposure),ye.needsLights&&ot(Pt,wi),_e&&V.fog===!0&&me.refreshFogUniforms(Pt,_e),me.refreshMaterialUniforms(Pt,V,ae,he,E.state.transmissionRenderTarget[M.id]),ye.needsLights&&ye.lightProbeGrid){const Mt=ye.lightProbeGrid;Pt.probesSH.value=Mt.texture,Pt.probesMin.value.copy(Mt.boundingBox.min),Pt.probesMax.value.copy(Mt.boundingBox.max),Pt.probesResolution.value.copy(Mt.resolution)}wr.upload(U,Xt(ye),Pt,z)}if(V.isShaderMaterial&&V.uniformsNeedUpdate===!0&&(wr.upload(U,Xt(ye),Pt,z),V.uniformsNeedUpdate=!1),V.isSpriteMaterial&&xt.setValue(U,"center",H.center),xt.setValue(U,"modelViewMatrix",H.modelViewMatrix),xt.setValue(U,"normalMatrix",H.normalMatrix),xt.setValue(U,"modelMatrix",H.matrixWorld),V.uniformsGroups!==void 0){const Mt=V.uniformsGroups;for(let ei=0,Ri=Mt.length;ei<Ri;ei++){const hl=Mt[ei];se.update(hl,un),se.bind(hl,un)}}return un}function ot(M,O){M.ambientLightColor.needsUpdate=O,M.lightProbe.needsUpdate=O,M.directionalLights.needsUpdate=O,M.directionalLightShadows.needsUpdate=O,M.pointLights.needsUpdate=O,M.pointLightShadows.needsUpdate=O,M.spotLights.needsUpdate=O,M.spotLightShadows.needsUpdate=O,M.rectAreaLights.needsUpdate=O,M.hemisphereLights.needsUpdate=O}function Rt(M){return M.isMeshLambertMaterial||M.isMeshToonMaterial||M.isMeshPhongMaterial||M.isMeshStandardMaterial||M.isShadowMaterial||M.isShaderMaterial&&M.lights===!0}this.getActiveCubeFace=function(){return q},this.getActiveMipmapLevel=function(){return W},this.getRenderTarget=function(){return ee},this.setRenderTargetTextures=function(M,O,Y){const V=B.get(M);V.__autoAllocateDepthBuffer=M.resolveDepthBuffer===!1,V.__autoAllocateDepthBuffer===!1&&(V.__useRenderToTexture=!1),B.get(M.texture).__webglTexture=O,B.get(M.depthTexture).__webglTexture=V.__autoAllocateDepthBuffer?void 0:Y,V.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(M,O){const Y=B.get(M);Y.__webglFramebuffer=O,Y.__useDefaultFramebuffer=O===void 0},this.setRenderTarget=function(M,O=0,Y=0){ee=M,q=O,W=Y;let V=null,H=!1,_e=!1;if(M){const ve=B.get(M);if(ve.__useDefaultFramebuffer!==void 0){g.bindFramebuffer(U.FRAMEBUFFER,ve.__webglFramebuffer),pe.copy(M.viewport),Me.copy(M.scissor),Ye=M.scissorTest,g.viewport(pe),g.scissor(Me),g.setScissorTest(Ye),K=-1;return}else if(ve.__webglFramebuffer===void 0)z.setupRenderTarget(M);else if(ve.__hasExternalTextures)z.rebindTextures(M,B.get(M.texture).__webglTexture,B.get(M.depthTexture).__webglTexture);else if(M.depthBuffer){const Xe=M.depthTexture;if(ve.__boundDepthTexture!==Xe){if(Xe!==null&&B.has(Xe)&&(M.width!==Xe.image.width||M.height!==Xe.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");z.setupDepthRenderbuffer(M)}}const Pe=M.texture;(Pe.isData3DTexture||Pe.isDataArrayTexture||Pe.isCompressedArrayTexture)&&(_e=!0);const Ne=B.get(M).__webglFramebuffer;M.isWebGLCubeRenderTarget?(Array.isArray(Ne[O])?V=Ne[O][Y]:V=Ne[O],H=!0):M.samples>0&&z.useMultisampledRTT(M)===!1?V=B.get(M).__webglMultisampledFramebuffer:Array.isArray(Ne)?V=Ne[Y]:V=Ne,pe.copy(M.viewport),Me.copy(M.scissor),Ye=M.scissorTest}else pe.copy(De).multiplyScalar(ae).floor(),Me.copy(ft).multiplyScalar(ae).floor(),Ye=Ge;if(Y!==0&&(V=$),g.bindFramebuffer(U.FRAMEBUFFER,V)&&g.drawBuffers(M,V),g.viewport(pe),g.scissor(Me),g.setScissorTest(Ye),H){const ve=B.get(M.texture);U.framebufferTexture2D(U.FRAMEBUFFER,U.COLOR_ATTACHMENT0,U.TEXTURE_CUBE_MAP_POSITIVE_X+O,ve.__webglTexture,Y)}else if(_e){const ve=O;for(let Pe=0;Pe<M.textures.length;Pe++){const Ne=B.get(M.textures[Pe]);U.framebufferTextureLayer(U.FRAMEBUFFER,U.COLOR_ATTACHMENT0+Pe,Ne.__webglTexture,Y,ve)}}else if(M!==null&&Y!==0){const ve=B.get(M.texture);U.framebufferTexture2D(U.FRAMEBUFFER,U.COLOR_ATTACHMENT0,U.TEXTURE_2D,ve.__webglTexture,Y)}K=-1},this.readRenderTargetPixels=function(M,O,Y,V,H,_e,Se,ve=0){if(!(M&&M.isWebGLRenderTarget)){ze("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Pe=B.get(M).__webglFramebuffer;if(M.isWebGLCubeRenderTarget&&Se!==void 0&&(Pe=Pe[Se]),Pe){g.bindFramebuffer(U.FRAMEBUFFER,Pe);try{const Ne=M.textures[ve],Xe=Ne.format,Ze=Ne.type;if(M.textures.length>1&&U.readBuffer(U.COLOR_ATTACHMENT0+ve),!y.textureFormatReadable(Xe)){ze("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!y.textureTypeReadable(Ze)){ze("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}O>=0&&O<=M.width-V&&Y>=0&&Y<=M.height-H&&U.readPixels(O,Y,V,H,de.convert(Xe),de.convert(Ze),_e)}finally{const Ne=ee!==null?B.get(ee).__webglFramebuffer:null;g.bindFramebuffer(U.FRAMEBUFFER,Ne)}}},this.readRenderTargetPixelsAsync=async function(M,O,Y,V,H,_e,Se,ve=0){if(!(M&&M.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Pe=B.get(M).__webglFramebuffer;if(M.isWebGLCubeRenderTarget&&Se!==void 0&&(Pe=Pe[Se]),Pe)if(O>=0&&O<=M.width-V&&Y>=0&&Y<=M.height-H){g.bindFramebuffer(U.FRAMEBUFFER,Pe);const Ne=M.textures[ve],Xe=Ne.format,Ze=Ne.type;if(M.textures.length>1&&U.readBuffer(U.COLOR_ATTACHMENT0+ve),!y.textureFormatReadable(Xe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!y.textureTypeReadable(Ze))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Fe=U.createBuffer();U.bindBuffer(U.PIXEL_PACK_BUFFER,Fe),U.bufferData(U.PIXEL_PACK_BUFFER,_e.byteLength,U.STREAM_READ),U.readPixels(O,Y,V,H,de.convert(Xe),de.convert(Ze),0);const pt=ee!==null?B.get(ee).__webglFramebuffer:null;g.bindFramebuffer(U.FRAMEBUFFER,pt);const Ct=U.fenceSync(U.SYNC_GPU_COMMANDS_COMPLETE,0);return U.flush(),await Xh(U,Ct,4),U.bindBuffer(U.PIXEL_PACK_BUFFER,Fe),U.getBufferSubData(U.PIXEL_PACK_BUFFER,0,_e),U.deleteBuffer(Fe),U.deleteSync(Ct),_e}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(M,O=null,Y=0){const V=Math.pow(2,-Y),H=Math.floor(M.image.width*V),_e=Math.floor(M.image.height*V),Se=O!==null?O.x:0,ve=O!==null?O.y:0;z.setTexture2D(M,0),U.copyTexSubImage2D(U.TEXTURE_2D,Y,0,0,Se,ve,H,_e),g.unbindTexture()},this.copyTextureToTexture=function(M,O,Y=null,V=null,H=0,_e=0){let Se,ve,Pe,Ne,Xe,Ze,Fe,pt,Ct;const wt=M.isCompressedTexture?M.mipmaps[_e]:M.image;if(Y!==null)Se=Y.max.x-Y.min.x,ve=Y.max.y-Y.min.y,Pe=Y.isBox3?Y.max.z-Y.min.z:1,Ne=Y.min.x,Xe=Y.min.y,Ze=Y.isBox3?Y.min.z:0;else{const Pt=Math.pow(2,-H);Se=Math.floor(wt.width*Pt),ve=Math.floor(wt.height*Pt),M.isDataArrayTexture?Pe=wt.depth:M.isData3DTexture?Pe=Math.floor(wt.depth*Pt):Pe=1,Ne=0,Xe=0,Ze=0}V!==null?(Fe=V.x,pt=V.y,Ct=V.z):(Fe=0,pt=0,Ct=0);const _t=de.convert(O.format),Kt=de.convert(O.type);let ye;O.isData3DTexture?(z.setTexture3D(O,0),ye=U.TEXTURE_3D):O.isDataArrayTexture||O.isCompressedArrayTexture?(z.setTexture2DArray(O,0),ye=U.TEXTURE_2D_ARRAY):(z.setTexture2D(O,0),ye=U.TEXTURE_2D),g.activeTexture(U.TEXTURE0),g.pixelStorei(U.UNPACK_FLIP_Y_WEBGL,O.flipY),g.pixelStorei(U.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),g.pixelStorei(U.UNPACK_ALIGNMENT,O.unpackAlignment);const nn=g.getParameter(U.UNPACK_ROW_LENGTH),st=g.getParameter(U.UNPACK_IMAGE_HEIGHT),un=g.getParameter(U.UNPACK_SKIP_PIXELS),bn=g.getParameter(U.UNPACK_SKIP_ROWS),Jn=g.getParameter(U.UNPACK_SKIP_IMAGES);g.pixelStorei(U.UNPACK_ROW_LENGTH,wt.width),g.pixelStorei(U.UNPACK_IMAGE_HEIGHT,wt.height),g.pixelStorei(U.UNPACK_SKIP_PIXELS,Ne),g.pixelStorei(U.UNPACK_SKIP_ROWS,Xe),g.pixelStorei(U.UNPACK_SKIP_IMAGES,Ze);const wi=M.isDataArrayTexture||M.isData3DTexture,xt=O.isDataArrayTexture||O.isData3DTexture;if(M.isDepthTexture){const Pt=B.get(M),Qn=B.get(O),Mt=B.get(Pt.__renderTarget),ei=B.get(Qn.__renderTarget);g.bindFramebuffer(U.READ_FRAMEBUFFER,Mt.__webglFramebuffer),g.bindFramebuffer(U.DRAW_FRAMEBUFFER,ei.__webglFramebuffer);for(let Ri=0;Ri<Pe;Ri++)wi&&(U.framebufferTextureLayer(U.READ_FRAMEBUFFER,U.COLOR_ATTACHMENT0,B.get(M).__webglTexture,H,Ze+Ri),U.framebufferTextureLayer(U.DRAW_FRAMEBUFFER,U.COLOR_ATTACHMENT0,B.get(O).__webglTexture,_e,Ct+Ri)),U.blitFramebuffer(Ne,Xe,Se,ve,Fe,pt,Se,ve,U.DEPTH_BUFFER_BIT,U.NEAREST);g.bindFramebuffer(U.READ_FRAMEBUFFER,null),g.bindFramebuffer(U.DRAW_FRAMEBUFFER,null)}else if(H!==0||M.isRenderTargetTexture||B.has(M)){const Pt=B.get(M),Qn=B.get(O);g.bindFramebuffer(U.READ_FRAMEBUFFER,j),g.bindFramebuffer(U.DRAW_FRAMEBUFFER,k);for(let Mt=0;Mt<Pe;Mt++)wi?U.framebufferTextureLayer(U.READ_FRAMEBUFFER,U.COLOR_ATTACHMENT0,Pt.__webglTexture,H,Ze+Mt):U.framebufferTexture2D(U.READ_FRAMEBUFFER,U.COLOR_ATTACHMENT0,U.TEXTURE_2D,Pt.__webglTexture,H),xt?U.framebufferTextureLayer(U.DRAW_FRAMEBUFFER,U.COLOR_ATTACHMENT0,Qn.__webglTexture,_e,Ct+Mt):U.framebufferTexture2D(U.DRAW_FRAMEBUFFER,U.COLOR_ATTACHMENT0,U.TEXTURE_2D,Qn.__webglTexture,_e),H!==0?U.blitFramebuffer(Ne,Xe,Se,ve,Fe,pt,Se,ve,U.COLOR_BUFFER_BIT,U.NEAREST):xt?U.copyTexSubImage3D(ye,_e,Fe,pt,Ct+Mt,Ne,Xe,Se,ve):U.copyTexSubImage2D(ye,_e,Fe,pt,Ne,Xe,Se,ve);g.bindFramebuffer(U.READ_FRAMEBUFFER,null),g.bindFramebuffer(U.DRAW_FRAMEBUFFER,null)}else xt?M.isDataTexture||M.isData3DTexture?U.texSubImage3D(ye,_e,Fe,pt,Ct,Se,ve,Pe,_t,Kt,wt.data):O.isCompressedArrayTexture?U.compressedTexSubImage3D(ye,_e,Fe,pt,Ct,Se,ve,Pe,_t,wt.data):U.texSubImage3D(ye,_e,Fe,pt,Ct,Se,ve,Pe,_t,Kt,wt):M.isDataTexture?U.texSubImage2D(U.TEXTURE_2D,_e,Fe,pt,Se,ve,_t,Kt,wt.data):M.isCompressedTexture?U.compressedTexSubImage2D(U.TEXTURE_2D,_e,Fe,pt,wt.width,wt.height,_t,wt.data):U.texSubImage2D(U.TEXTURE_2D,_e,Fe,pt,Se,ve,_t,Kt,wt);g.pixelStorei(U.UNPACK_ROW_LENGTH,nn),g.pixelStorei(U.UNPACK_IMAGE_HEIGHT,st),g.pixelStorei(U.UNPACK_SKIP_PIXELS,un),g.pixelStorei(U.UNPACK_SKIP_ROWS,bn),g.pixelStorei(U.UNPACK_SKIP_IMAGES,Jn),_e===0&&O.generateMipmaps&&U.generateMipmap(ye),g.unbindTexture()},this.initRenderTarget=function(M){B.get(M).__webglFramebuffer===void 0&&z.setupRenderTarget(M)},this.initTexture=function(M){M.isCubeTexture?z.setTextureCube(M,0):M.isData3DTexture?z.setTexture3D(M,0):M.isDataArrayTexture||M.isCompressedArrayTexture?z.setTexture2DArray(M,0):z.setTexture2D(M,0),g.unbindTexture()},this.resetState=function(){q=0,W=0,ee=null,g.reset(),ge.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Cn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=Qe._getDrawingBufferColorSpace(e),t.unpackColorSpace=Qe._getUnpackColorSpace()}}function Du(s){const e=n=>{let i=!1;return n.traverse(r=>{r instanceof bt&&(i=!0)}),i};let t=s;for(;!(t instanceof bt);){const n=(t.children??[]).filter(e);if(n.length!==1)return n;if(n[0].userData?.termdockSinglePart)return[n[0]];t=n[0]}return[t]}function wx(s,e){const t=e.getCenter(new C),n=new C,i=new C,r=new C,a=new C,o=new C,l=new C,c=new C;let u=0,h=0;s.traverse(_=>{if(!(_ instanceof bt))return;const v=_.geometry.getAttribute("position");if(!v)return;const m=_.geometry.index,p=m?.count??v.count;for(let b=0;b+2<p;b+=3){r.fromBufferAttribute(v,m?m.getX(b):b).applyMatrix4(_.matrixWorld).sub(t),a.fromBufferAttribute(v,m?m.getX(b+1):b+1).applyMatrix4(_.matrixWorld).sub(t),o.fromBufferAttribute(v,m?m.getX(b+2):b+2).applyMatrix4(_.matrixWorld).sub(t);const T=r.dot(l.crossVectors(a,o));u+=T,n.addScaledVector(r,T/4).addScaledVector(a,T/4).addScaledVector(o,T/4),l.subVectors(a,r).cross(c.subVectors(o,r)),i.add(l),h+=l.length()}});const d=e.getSize(new C);if(Math.abs(u)<=d.x*d.y*d.z*1e-9||i.length()>h*1e-5)return t;const f=n.divideScalar(u).add(t);return e.containsPoint(f)?f:t}function Rx(s){s.updateMatrixWorld(!0);const e=Du(s).map(l=>{const c=new Yt().setFromObject(l);return{node:l,position:l.position.clone(),matrix:l.matrix.clone(),autoUpdate:l.matrixAutoUpdate,box:c,center:wx(l,c),offset:new C}}),n=new Yt().setFromObject(s).getSize(new C),i=Math.max(n.x,n.y,n.z,1e-6)*.002,r=Math.max(n.x,n.y,n.z,1e-6)*.12,a=new Map;for(const l of["x","y","z"]){const c=[],u=[...e].sort((v,m)=>v.box.min[l]-m.box.min[l]||m.box.max[l]-v.box.max[l])[0],h=[...e].sort((v,m)=>v===m?0:v===u?-1:m===u?1:v.center[l]-m.center[l]||m.box.max[l]-v.box.max[l]);for(const v of h){const m=c.find(p=>Math.abs(p.min-v.box.min[l])<=i&&Math.abs(p.max-v.box.max[l])<=i);m?m.parts.push(v):c.push({min:v.box.min[l],max:v.box.max[l],parts:[v]})}const d=new Map;let f=0,_=0;for(const[v,m]of c.entries()){const p=Math.min(...m.parts.map(T=>T.box.min[l])),b=Math.max(...m.parts.map(T=>T.box.max[l]));v>0&&(f+=Math.max(r,_-p+r));for(const T of m.parts)d.set(T,f);_=b}a.set(l,d)}const o=l=>{if(typeof l=="string"){const c=e.filter(u=>u.node.uuid===l||u.node.name===l||u.node.userData.termdockPartName===l);return c.length===1?c[0]:void 0}for(let c=l;c;c=c.parent??void 0){const u=e.find(h=>h.node===c);if(u)return u}};return{count:e.length,part:l=>o(l)?.node,offset:l=>o(l)?.offset.clone()??new C,set(l){const c=l&&Number.isFinite(l.amount)?Math.max(0,Math.min(1,l.amount)):0,u=l?.axis??"y";for(const h of e)if(h.offset.set(0,0,0),h.offset[u]=(a.get(u)?.get(h)??0)*c,h.node.position.copy(h.position),h.node.matrix.copy(h.matrix),c>0){const d=h.node.parent?.matrixWorld.clone().invert()??new We,f=h.offset.clone().applyMatrix4(d).sub(new C().applyMatrix4(d));h.node.position.add(f),h.autoUpdate?h.node.updateMatrix():h.node.matrix.premultiply(new We().makeTranslation(f.x,f.y,f.z))}return s.updateMatrixWorld(!0),new Yt().setFromObject(s)}}}function Cx(s,e){return[s&&s.amount>0?`Exploded ${s.axis.toUpperCase()} ${Math.round(s.amount*100)}%; assembled coordinates`:"",e?`Section ${e.axis.toUpperCase()} ${Math.round(e.value01*100)}%${e.flip?" flipped":""}`:""].filter(Boolean).join(" / ")}function Nc(s,e){if(e.type==="reset")return{hidden:[],history:[]};if(e.type==="undo")return s.history.length?{hidden:s.history[s.history.length-1],history:s.history.slice(0,-1)}:s;const t=e.type==="toggle"?s.hidden.includes(e.id)?s.hidden.filter(n=>n!==e.id):[...s.hidden,e.id]:[...new Set(e.hidden)];return t.length===s.hidden.length&&t.every(n=>s.hidden.includes(n))?s:{hidden:t,history:[...s.history.slice(-19),s.hidden]}}function _i(s){for(let e=s;e;e=e.parent)if(!e.visible)return!1;return!0}function Px(s){const e=Du(s).map((n,i)=>({node:n,id:`part-${i}`,visible:n.visible})),t=new Map(e.map(n=>[n.node,n]));return{parts:e.map(({id:n,node:i,visible:r})=>({id:n,name:i.userData.termdockPartName||i.name,initiallyVisible:r})),node:n=>e.find(i=>i.id===n)?.node,id(n){for(let i=n;i;i=i.parent){const r=t.get(i);if(r)return r.id}},setHidden(n){const i=new Set(n);for(const r of e)r.node.visible=r.visible&&!i.has(r.id)},isPartVisible(n){if(!n)return!0;const i=e.filter(({node:r})=>r.uuid===n||r.name===n||r.userData.termdockPartName===n);return i.length===0||i.some(({node:r})=>_i(r))}}}function Lx({parts:s,hidden:e,selected:t,wide:n,canUndo:i,onSelect:r,onToggle:a,onIsolate:o,onShowAll:l,onUndo:c,onClose:u}){const{t:h}=Do(),[d,f]=we.useState(""),[_,v]=we.useState(!1),m=we.useRef(null);we.useEffect(()=>{const b=m.current,T=b?.querySelector(`[data-part-id="${t}"]`);!b||!T||(T.offsetTop<b.scrollTop?b.scrollTop=T.offsetTop:T.offsetTop+T.offsetHeight>b.scrollTop+b.clientHeight&&(b.scrollTop=T.offsetTop+T.offsetHeight-b.clientHeight))},[t]);const p=s.filter(b=>b.name.toLocaleLowerCase().includes(d.trim().toLocaleLowerCase())&&(!_||e.includes(b.id)));return ie.jsxs("section",{"aria-label":h("rightSidebar.model3dParts"),className:`swiper-no-swiping relative z-20 flex min-h-0 shrink-0 flex-col bg-surface ${n?"h-full w-72 border-l border-border/30":"h-[42%] border-t border-border/30"}`,onPointerDown:b=>b.stopPropagation(),onTouchStart:b=>b.stopPropagation(),children:[ie.jsxs("div",{className:"flex shrink-0 items-center gap-2 px-3 pt-1",children:[ie.jsxs("h3",{className:"min-w-0 flex-1 text-sm font-medium text-foreground",children:[h("rightSidebar.model3dParts")," ",ie.jsxs("span",{className:"text-xs text-muted-foreground",children:[s.length-e.length,"/",s.length]})]}),ie.jsx("button",{type:"button",onClick:u,"aria-label":h("rightSidebar.model3dCloseParts"),className:"inline-flex h-10 w-10 items-center justify-center rounded-lg text-muted-foreground hover:bg-surface-2",children:ie.jsx(Da,{size:18})})]}),ie.jsxs("div",{className:"flex shrink-0 items-center gap-2 px-3 pb-2",children:[ie.jsxs("div",{className:"flex h-9 min-w-0 flex-1 items-center gap-2 rounded-lg bg-surface-2 px-2 text-muted-foreground",children:[ie.jsx(Hu,{size:14,className:"shrink-0"}),ie.jsx("input",{value:d,onChange:b=>f(b.target.value),placeholder:h("rightSidebar.model3dSearchParts"),"aria-label":h("rightSidebar.model3dSearchParts"),onKeyDown:b=>{b.key==="Enter"&&b.currentTarget.blur()},className:"min-w-0 flex-1 bg-transparent text-sm text-foreground outline-none"}),d&&ie.jsx("button",{type:"button","aria-label":h("rightSidebar.model3dClearPartSearch"),onClick:()=>f(""),className:"inline-flex h-9 w-7 shrink-0 items-center justify-center",children:ie.jsx(Da,{size:14})})]}),ie.jsx("button",{type:"button","aria-pressed":_,onClick:()=>v(b=>!b),className:`h-9 shrink-0 rounded-lg px-2 text-xs ${_?"bg-accent/15 text-accent":"bg-surface-2 text-muted-foreground"}`,children:h("rightSidebar.model3dHiddenParts",{count:e.length})})]}),ie.jsxs("div",{ref:m,className:"relative min-h-0 flex-1 overflow-y-auto overscroll-contain px-2",role:"list","aria-label":h("rightSidebar.model3dParts"),children:[p.map(b=>{const T=e.includes(b.id);return ie.jsxs("div",{"data-part-id":b.id,role:"listitem",className:`flex min-h-11 items-center rounded-lg ${t===b.id?"bg-accent/10":"hover:bg-surface-2"}`,children:[ie.jsx("button",{type:"button",onClick:()=>r(b.id),"aria-pressed":t===b.id,title:b.name,className:`min-h-11 min-w-0 flex-1 px-2 py-2 text-left text-sm leading-snug ${T?"text-muted-foreground":"text-foreground"}`,children:ie.jsx("span",{className:"line-clamp-2 break-words",children:b.name})}),ie.jsx("button",{type:"button",onClick:()=>a(b.id),"aria-label":h(T?"rightSidebar.model3dShowNamedPart":"rightSidebar.model3dHideNamedPart",{name:b.name}),title:h(T?"rightSidebar.model3dShowNamedPart":"rightSidebar.model3dHideNamedPart",{name:b.name}),className:`inline-flex h-11 w-11 shrink-0 items-center justify-center rounded-lg hover:bg-surface-elevated ${T?"text-muted-foreground":"text-foreground"}`,children:T?ie.jsx(Yc,{size:18}):ie.jsx(qc,{size:18})}),ie.jsx("button",{type:"button",onClick:()=>o(b.id),"aria-label":h("rightSidebar.model3dIsolateNamedPart",{name:b.name}),title:h("rightSidebar.model3dIsolateNamedPart",{name:b.name}),className:"inline-flex h-11 w-11 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-surface-elevated hover:text-foreground",children:ie.jsx(Kc,{size:17})})]},b.id)}),p.length===0&&ie.jsx("p",{className:"px-2 py-5 text-center text-sm text-muted-foreground",children:h("rightSidebar.model3dNoParts")})]}),ie.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-t border-border/20 px-3 py-1 pb-[max(0.25rem,env(safe-area-inset-bottom,0px))]",children:[ie.jsxs("button",{type:"button",onClick:c,disabled:!i,className:"inline-flex h-10 items-center gap-1 rounded-lg px-2 text-sm text-foreground disabled:opacity-40",children:[ie.jsx(Na,{size:15}),h("rightSidebar.model3dUndoVisibility")]}),ie.jsx("button",{type:"button",onClick:l,disabled:e.length===0,className:"ml-auto h-10 rounded-lg px-2 text-sm text-foreground disabled:opacity-40",children:h("rightSidebar.model3dShowAllParts",{count:e.length})})]})]})}function Ix({dark:s,onToggleBackground:e,onRefresh:t,onView:n}){const{t:i}=Do(),[r,a]=we.useState(!1),o=we.useRef(null),l=we.useRef(null),c=we.useRef(null);we.useEffect(()=>{if(!r)return;c.current?.focus();const h=d=>{o.current?.contains(d.target)||a(!1)};return document.addEventListener("pointerdown",h),()=>document.removeEventListener("pointerdown",h)},[r]);const u=()=>{a(!1),l.current?.focus()};return ie.jsxs("div",{ref:o,"data-model-viewer-menu":r?"open":"closed",className:"relative z-20 shrink-0",onKeyDown:h=>{h.key==="Escape"&&r&&(h.preventDefault(),h.stopPropagation(),u())},children:[ie.jsx("button",{ref:l,type:"button","aria-label":i("rightSidebar.model3dMore"),"aria-expanded":r,onClick:()=>a(h=>!h),className:"inline-flex h-9 w-9 items-center justify-center rounded-full bg-surface-2 text-muted-foreground hover:bg-surface-elevated",children:ie.jsx(ku,{size:17})}),r&&ie.jsxs("div",{className:"absolute right-0 top-full z-30 mt-2 w-48 rounded-xl border border-border/30 bg-surface p-1 shadow-lg",children:[ie.jsxs("button",{ref:c,type:"button",onClick:()=>{e(),u()},className:"flex min-h-11 w-full items-center gap-2 rounded-lg px-3 text-left text-sm text-foreground hover:bg-surface-2",children:[s?ie.jsx(Gu,{size:16}):ie.jsx(Wu,{size:16}),i(s?"rightSidebar.model3dBgToLight":"rightSidebar.model3dBgToDark")]}),n&&["fit","front","top","right"].map(h=>ie.jsx("button",{type:"button",onClick:()=>{u(),n(h)},className:"flex min-h-11 w-full items-center rounded-lg px-3 text-left text-sm text-foreground hover:bg-surface-2",children:i(h==="fit"?"rightSidebar.model3dFit":h==="front"?"rightSidebar.model3dFront":h==="top"?"rightSidebar.model3dTop":"rightSidebar.model3dRight")},h)),t&&ie.jsxs("button",{type:"button",onClick:()=>{u(),t()},className:"flex min-h-11 w-full items-center gap-2 rounded-lg px-3 text-left text-sm text-foreground hover:bg-surface-2",children:[ie.jsx(Xu,{size:16}),i("rightSidebar.model3dRefresh")]})]})]})}const Uc={type:"change"},rl={type:"start"},Nu={type:"end"},vr=new rs,Fc=new Xn,Dx=Math.cos(70*fu.DEG2RAD),Ft=new C,en=2*Math.PI,mt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},wa=1e-6;class Nx extends Pf{constructor(e,t=null){super(e,t),this.state=mt.NONE,this.target=new C,this.cursor=new C,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Yi.ROTATE,MIDDLE:Yi.DOLLY,RIGHT:Yi.PAN},this.touches={ONE:Xi.ROTATE,TWO:Xi.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new C,this._lastQuaternion=new Sn,this._lastTargetPosition=new C,this._quat=new Sn().setFromUnitVectors(e.up,new C(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new lc,this._sphericalDelta=new lc,this._scale=1,this._panOffset=new C,this._rotateStart=new ke,this._rotateEnd=new ke,this._rotateDelta=new ke,this._panStart=new ke,this._panEnd=new ke,this._panDelta=new ke,this._dollyStart=new ke,this._dollyEnd=new ke,this._dollyDelta=new ke,this._dollyDirection=new C,this._mouse=new ke,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Fx.bind(this),this._onPointerDown=Ux.bind(this),this._onPointerUp=Ox.bind(this),this._onContextMenu=Wx.bind(this),this._onMouseWheel=zx.bind(this),this._onKeyDown=Vx.bind(this),this._onTouchStart=Hx.bind(this),this._onTouchMove=Gx.bind(this),this._onMouseDown=Bx.bind(this),this._onMouseMove=kx.bind(this),this._interceptControlDown=Xx.bind(this),this._interceptControlUp=Yx.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(e){this._cursorStyle=e,e==="grab"?this.domElement.style.cursor="grab":this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction=""}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Uc),this.update(),this.state=mt.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){const t=this.object.position;Ft.copy(t).sub(this.target),Ft.applyQuaternion(this._quat),this._spherical.setFromVector3(Ft),this.autoRotate&&this.state===mt.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(n)&&isFinite(i)&&(n<-Math.PI?n+=en:n>Math.PI&&(n-=en),i<-Math.PI?i+=en:i>Math.PI&&(i-=en),n<=i?this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=a!=this._spherical.radius}if(Ft.setFromSpherical(this._spherical),Ft.applyQuaternion(this._quatInverse),t.copy(this.target).add(Ft),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=Ft.length();a=this._clampDistance(o*this._scale);const l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){const o=new C(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;const c=new C(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=Ft.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(vr.origin.copy(this.object.position),vr.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(vr.direction))<Dx?this.object.lookAt(this.target):(Fc.setFromNormalAndCoplanarPoint(this.object.up,this.target),vr.intersectPlane(Fc,this.target))))}else if(this.object.isOrthographicCamera){const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>wa||8*(1-this._lastQuaternion.dot(this.object.quaternion))>wa||this._lastTargetPosition.distanceToSquared(this.target)>wa?(this.dispatchEvent(Uc),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?en/60*this.autoRotateSpeed*e:en/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Ft.setFromMatrixColumn(t,0),Ft.multiplyScalar(-e),this._panOffset.add(Ft)}_panUp(e,t){this.screenSpacePanning===!0?Ft.setFromMatrixColumn(t,1):(Ft.setFromMatrixColumn(t,0),Ft.crossVectors(this.object.up,Ft)),Ft.multiplyScalar(e),this._panOffset.add(Ft)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;Ft.copy(i).sub(this.target);let r=Ft.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),i=e-n.left,r=t-n.top,a=n.width,o=n.height;this._mouse.x=i/a*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(en*this._rotateDelta.x/t.clientHeight),this._rotateUp(en*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(en*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-en*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(en*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-en*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panStart.set(n,i)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),i=.5*(e.pageX+n.x),r=.5*(e.pageY+n.y);this._rotateEnd.set(i,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(en*this._rotateDelta.x/t.clientHeight),this._rotateUp(en*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new ke,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function Ux(s){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(s.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(s)&&(this._addPointer(s),s.pointerType==="touch"?this._onTouchStart(s):this._onMouseDown(s),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function Fx(s){this.enabled!==!1&&(s.pointerType==="touch"?this._onTouchMove(s):this._onMouseMove(s))}function Ox(s){switch(this._removePointer(s),this._pointers.length){case 0:this.domElement.releasePointerCapture(s.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Nu),this.state=mt.NONE,this._cursorStyle==="grab"&&(this.domElement.style.cursor="grab");break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function Bx(s){let e;switch(s.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case Yi.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(s),this.state=mt.DOLLY;break;case Yi.ROTATE:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=mt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=mt.ROTATE}break;case Yi.PAN:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=mt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=mt.PAN}break;default:this.state=mt.NONE}this.state!==mt.NONE&&this.dispatchEvent(rl)}function kx(s){switch(this.state){case mt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(s);break;case mt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(s);break;case mt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(s);break}}function zx(s){this.enabled===!1||this.enableZoom===!1||this.state!==mt.NONE||(s.preventDefault(),this.dispatchEvent(rl),this._handleMouseWheel(this._customWheelEvent(s)),this.dispatchEvent(Nu))}function Vx(s){this.enabled!==!1&&this._handleKeyDown(s)}function Hx(s){switch(this._trackPointer(s),this._pointers.length){case 1:switch(this.touches.ONE){case Xi.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(s),this.state=mt.TOUCH_ROTATE;break;case Xi.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(s),this.state=mt.TOUCH_PAN;break;default:this.state=mt.NONE}break;case 2:switch(this.touches.TWO){case Xi.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(s),this.state=mt.TOUCH_DOLLY_PAN;break;case Xi.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(s),this.state=mt.TOUCH_DOLLY_ROTATE;break;default:this.state=mt.NONE}break;default:this.state=mt.NONE}this.state!==mt.NONE&&this.dispatchEvent(rl)}function Gx(s){switch(this._trackPointer(s),this.state){case mt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(s),this.update();break;case mt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(s),this.update();break;case mt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(s),this.update();break;case mt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(s),this.update();break;default:this.state=mt.NONE}}function Wx(s){this.enabled!==!1&&s.preventDefault()}function Xx(s){s.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Yx(s){s.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Oc(s,e){if(e===Dh)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),s;if(e===So||e===hu){let t=s.getIndex();if(t===null){const a=[],o=s.getAttribute("position");if(o!==void 0){for(let l=0;l<o.count;l++)a.push(l);s.setIndex(a),t=s.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),s}const n=t.count-2,i=[];if(e===So)for(let a=1;a<=n;a++)i.push(t.getX(0)),i.push(t.getX(a)),i.push(t.getX(a+1));else for(let a=0;a<n;a++)a%2===0?(i.push(t.getX(a)),i.push(t.getX(a+1)),i.push(t.getX(a+2))):(i.push(t.getX(a+2)),i.push(t.getX(a+1)),i.push(t.getX(a)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=s.clone();return r.setIndex(i),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),s}function qx(s){const e=new Map,t=new Map,n=s.clone();return Uu(s,n,function(i,r){e.set(r,i),t.set(i,r)}),n.traverse(function(i){if(!i.isSkinnedMesh)return;const r=i,a=e.get(i),o=a.skeleton.bones;r.skeleton=a.skeleton.clone(),r.bindMatrix.copy(a.bindMatrix),r.skeleton.bones=o.map(function(l){return t.get(l)}),r.bind(r.skeleton,r.bindMatrix)}),n}function Uu(s,e,t){t(s,e);for(let n=0;n<s.children.length;n++)Uu(s.children[n],e.children[n],t)}class Kx extends Ti{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Qx(t)}),this.register(function(t){return new e0(t)}),this.register(function(t){return new c0(t)}),this.register(function(t){return new u0(t)}),this.register(function(t){return new h0(t)}),this.register(function(t){return new n0(t)}),this.register(function(t){return new i0(t)}),this.register(function(t){return new s0(t)}),this.register(function(t){return new r0(t)}),this.register(function(t){return new Jx(t)}),this.register(function(t){return new a0(t)}),this.register(function(t){return new t0(t)}),this.register(function(t){return new l0(t)}),this.register(function(t){return new o0(t)}),this.register(function(t){return new $x(t)}),this.register(function(t){return new Bc(t,Je.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Bc(t,Je.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new d0(t)})}load(e,t,n,i){const r=this;let a;if(this.resourcePath!=="")a=this.resourcePath;else if(this.path!==""){const c=Is.extractUrlBase(e);a=Is.resolveURL(c,this.path)}else a=Is.extractUrlBase(e);this.manager.itemStart(e);const o=function(c){i?i(c):console.error(c),r.manager.itemError(e),r.manager.itemEnd(e)},l=new tl(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(c){try{r.parse(c,a,function(u){t(u),r.manager.itemEnd(e)},o)}catch(u){o(u)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){let r;const a={},o={},l=new TextDecoder;if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===Fu){try{a[Je.KHR_BINARY_GLTF]=new f0(e)}catch(h){i&&i(h);return}r=JSON.parse(a[Je.KHR_BINARY_GLTF].content)}else r=JSON.parse(l.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new A0(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u<this.pluginCallbacks.length;u++){const h=this.pluginCallbacks[u](c);h.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),o[h.name]=h,a[h.name]=!0}if(r.extensionsUsed)for(let u=0;u<r.extensionsUsed.length;++u){const h=r.extensionsUsed[u],d=r.extensionsRequired||[];switch(h){case Je.KHR_MATERIALS_UNLIT:a[h]=new jx;break;case Je.KHR_DRACO_MESH_COMPRESSION:a[h]=new p0(r,this.dracoLoader);break;case Je.KHR_TEXTURE_TRANSFORM:a[h]=new m0;break;case Je.KHR_MESH_QUANTIZATION:a[h]=new g0;break;default:d.indexOf(h)>=0&&o[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}c.setExtensions(a),c.setPlugins(o),c.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}}function Zx(){let s={};return{get:function(e){return s[e]},add:function(e,t){s[e]=t},remove:function(e){delete s[e]},removeAll:function(){s={}}}}function It(s,e,t){const n=s.json.materials[e];return n.extensions&&n.extensions[t]?n.extensions[t]:null}const Je={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class $x{constructor(e){this.parser=e,this.name=Je.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const r=t.json,l=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let c;const u=new Ue(16777215);l.color!==void 0&&u.setRGB(l.color[0],l.color[1],l.color[2],ln);const h=l.range!==void 0?l.range:0;switch(l.type){case"directional":c=new Ao(u),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new df(u),c.distance=h;break;case"spot":c=new uf(u),c.distance=h,l.spot=l.spot||{},l.spot.innerConeAngle=l.spot.innerConeAngle!==void 0?l.spot.innerConeAngle:0,l.spot.outerConeAngle=l.spot.outerConeAngle!==void 0?l.spot.outerConeAngle:Math.PI/4,c.angle=l.spot.outerConeAngle,c.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return c.position.set(0,0,0),An(c,l),l.intensity!==void 0&&(c.intensity=l.intensity),c.name=t.createUniqueName(l.name||"light_"+e),i=Promise.resolve(c),t.cache.add(n,i),i}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,r=n.json.nodes[e],o=(r.extensions&&r.extensions[this.name]||{}).light;return o===void 0?null:this._loadLight(o).then(function(l){return n._getNodeRef(t.cache,o,l)})}}class jx{constructor(){this.name=Je.KHR_MATERIALS_UNLIT}getMaterialType(){return yi}extendParams(e,t,n){const i=[];e.color=new Ue(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const a=r.baseColorFactor;e.color.setRGB(a[0],a[1],a[2],ln),e.opacity=a[3]}r.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",r.baseColorTexture,Ht))}return Promise.all(i)}}class Jx{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=It(this.parser,e,this.name);return n===null||n.emissiveStrength!==void 0&&(t.emissiveIntensity=n.emissiveStrength),Promise.resolve()}}class Qx{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return It(this.parser,e,this.name)!==null?On:null}extendMaterialParams(e,t){const n=It(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];if(n.clearcoatFactor!==void 0&&(t.clearcoat=n.clearcoatFactor),n.clearcoatTexture!==void 0&&i.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture)),n.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=n.clearcoatRoughnessFactor),n.clearcoatRoughnessTexture!==void 0&&i.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture)),n.clearcoatNormalTexture!==void 0&&(i.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0)){const r=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new ke(r,r)}return Promise.all(i)}}class e0{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_DISPERSION}getMaterialType(e){return It(this.parser,e,this.name)!==null?On:null}extendMaterialParams(e,t){const n=It(this.parser,e,this.name);return n===null||(t.dispersion=n.dispersion!==void 0?n.dispersion:0),Promise.resolve()}}class t0{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return It(this.parser,e,this.name)!==null?On:null}extendMaterialParams(e,t){const n=It(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];return n.iridescenceFactor!==void 0&&(t.iridescence=n.iridescenceFactor),n.iridescenceTexture!==void 0&&i.push(this.parser.assignTexture(t,"iridescenceMap",n.iridescenceTexture)),n.iridescenceIor!==void 0&&(t.iridescenceIOR=n.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),n.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum),n.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum),n.iridescenceThicknessTexture!==void 0&&i.push(this.parser.assignTexture(t,"iridescenceThicknessMap",n.iridescenceThicknessTexture)),Promise.all(i)}}class n0{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_SHEEN}getMaterialType(e){return It(this.parser,e,this.name)!==null?On:null}extendMaterialParams(e,t){const n=It(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];if(t.sheenColor=new Ue(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){const r=n.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],ln)}return n.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&i.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,Ht)),n.sheenRoughnessTexture!==void 0&&i.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture)),Promise.all(i)}}class i0{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return It(this.parser,e,this.name)!==null?On:null}extendMaterialParams(e,t){const n=It(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];return n.transmissionFactor!==void 0&&(t.transmission=n.transmissionFactor),n.transmissionTexture!==void 0&&i.push(this.parser.assignTexture(t,"transmissionMap",n.transmissionTexture)),Promise.all(i)}}class s0{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_VOLUME}getMaterialType(e){return It(this.parser,e,this.name)!==null?On:null}extendMaterialParams(e,t){const n=It(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0&&i.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture)),t.attenuationDistance=n.attenuationDistance||1/0;const r=n.attenuationColor||[1,1,1];return t.attenuationColor=new Ue().setRGB(r[0],r[1],r[2],ln),Promise.all(i)}}class r0{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_IOR}getMaterialType(e){return It(this.parser,e,this.name)!==null?On:null}extendMaterialParams(e,t){const n=It(this.parser,e,this.name);return n===null||(t.ior=n.ior!==void 0?n.ior:1.5,t.ior===0&&(t.ior=1e3)),Promise.resolve()}}class a0{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_SPECULAR}getMaterialType(e){return It(this.parser,e,this.name)!==null?On:null}extendMaterialParams(e,t){const n=It(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0&&i.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));const r=n.specularColorFactor||[1,1,1];return t.specularColor=new Ue().setRGB(r[0],r[1],r[2],ln),n.specularColorTexture!==void 0&&i.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,Ht)),Promise.all(i)}}class o0{constructor(e){this.parser=e,this.name=Je.EXT_MATERIALS_BUMP}getMaterialType(e){return It(this.parser,e,this.name)!==null?On:null}extendMaterialParams(e,t){const n=It(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];return t.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0&&i.push(this.parser.assignTexture(t,"bumpMap",n.bumpTexture)),Promise.all(i)}}class l0{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return It(this.parser,e,this.name)!==null?On:null}extendMaterialParams(e,t){const n=It(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];return n.anisotropyStrength!==void 0&&(t.anisotropy=n.anisotropyStrength),n.anisotropyRotation!==void 0&&(t.anisotropyRotation=n.anisotropyRotation),n.anisotropyTexture!==void 0&&i.push(this.parser.assignTexture(t,"anisotropyMap",n.anisotropyTexture)),Promise.all(i)}}class c0{constructor(e){this.parser=e,this.name=Je.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const r=i.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,a)}}class u0{constructor(e){this.parser=e,this.name=Je.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const a=r.extensions[t],o=i.images[a.source];let l=n.textureLoader;if(o.uri){const c=n.options.manager.getHandler(o.uri);c!==null&&(l=c)}return n.loadTextureImage(e,a.source,l)}}class h0{constructor(e){this.parser=e,this.name=Je.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const a=r.extensions[t],o=i.images[a.source];let l=n.textureLoader;if(o.uri){const c=n.options.manager.getHandler(o.uri);c!==null&&(l=c)}return n.loadTextureImage(e,a.source,l)}}class Bc{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),a=this.parser.options.meshoptDecoder;if(!a||!a.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(o){const l=i.byteOffset||0,c=i.byteLength||0,u=i.count,h=i.byteStride,d=new Uint8Array(o,l,c);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(u,h,d,i.mode,i.filter).then(function(f){return f.buffer}):a.ready.then(function(){const f=new ArrayBuffer(u*h);return a.decodeGltfBuffer(new Uint8Array(f),u,h,d,i.mode,i.filter),f})})}else return null}}class d0{constructor(e){this.name=Je.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const i=t.meshes[n.mesh];for(const c of i.primitives)if(c.mode!==dn.TRIANGLES&&c.mode!==dn.TRIANGLE_STRIP&&c.mode!==dn.TRIANGLE_FAN&&c.mode!==void 0)return null;const a=n.extensions[this.name].attributes,o=[],l={};for(const c in a)o.push(this.parser.getDependency("accessor",a[c]).then(u=>(l[c]=u,l[c])));return o.length<1?null:(o.push(this.parser.createNodeMesh(e)),Promise.all(o).then(c=>{const u=c.pop(),h=u.isGroup?u.children:[u],d=c[0].count,f=[];for(const _ of h){const v=new We,m=new C,p=new Sn,b=new C(1,1,1),T=new Dd(_.geometry,_.material,d);for(let S=0;S<d;S++)l.TRANSLATION&&m.fromBufferAttribute(l.TRANSLATION,S),l.ROTATION&&p.fromBufferAttribute(l.ROTATION,S),l.SCALE&&b.fromBufferAttribute(l.SCALE,S),T.setMatrixAt(S,v.compose(m,p,b));for(const S in l)if(S==="_COLOR_0"){const w=l[S];T.instanceColor=new Eo(w.array,w.itemSize,w.normalized)}else S!=="TRANSLATION"&&S!=="ROTATION"&&S!=="SCALE"&&_.geometry.setAttribute(S,l[S]);At.prototype.copy.call(T,_),this.parser.assignFinalMaterial(T),f.push(T)}return u.isGroup?(u.clear(),u.add(...f),u):f[0]}))}}const Fu="glTF",As=12,kc={JSON:1313821514,BIN:5130562};class f0{constructor(e){this.name=Je.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,As),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Fu)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-As,r=new DataView(e,As);let a=0;for(;a<i;){const o=r.getUint32(a,!0);a+=4;const l=r.getUint32(a,!0);if(a+=4,l===kc.JSON){const c=new Uint8Array(e,As+a,o);this.content=n.decode(c)}else if(l===kc.BIN){const c=As+a;this.body=e.slice(c,c+o)}a+=o}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class p0{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Je.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},l={},c={};for(const u in a){const h=Po[u]||u.toLowerCase();o[h]=a[u]}for(const u in e.attributes){const h=Po[u]||u.toLowerCase();if(a[u]!==void 0){const d=n.accessors[e.attributes[u]],f=ji[d.componentType];c[h]=f.name,l[h]=d.normalized===!0}}return t.getDependency("bufferView",r).then(function(u){return new Promise(function(h,d){i.decodeDracoFile(u,function(f){for(const _ in f.attributes){const v=f.attributes[_],m=l[_];m!==void 0&&(v.normalized=m)}h(f)},o,c,ln,d)})})}}class m0{constructor(){this.name=Je.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class g0{constructor(){this.name=Je.KHR_MESH_QUANTIZATION}}class Ou extends as{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let a=0;a!==i;a++)t[a]=n[r+a];return t}interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=o*2,c=o*3,u=i-t,h=(n-t)/u,d=h*h,f=d*h,_=e*c,v=_-c,m=-2*f+3*d,p=f-d,b=1-m,T=p-d+h;for(let S=0;S!==o;S++){const w=a[v+S+o],E=a[v+S+l]*u,R=a[_+S+o],x=a[_+S]*u;r[S]=b*w+T*E+m*R+p*x}return r}}const _0=new Sn;class x0 extends Ou{interpolate_(e,t,n,i){const r=super.interpolate_(e,t,n,i);return _0.fromArray(r).normalize().toArray(r),r}}const dn={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},ji={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},zc={9728:Ot,9729:Bt,9984:su,9985:yr,9986:Rs,9987:Yn},Vc={33071:Rn,33648:Rr,10497:es},Ra={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Po={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},oi={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},v0={CUBICSPLINE:void 0,LINEAR:Fs,STEP:Us},Ca={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function M0(s){return s.DefaultMaterial===void 0&&(s.DefaultMaterial=new $i({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Dn})),s.DefaultMaterial}function gi(s,e,t){for(const n in t.extensions)s[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function An(s,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(s.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function S0(s,e,t){let n=!1,i=!1,r=!1;for(let c=0,u=e.length;c<u;c++){const h=e[c];if(h.POSITION!==void 0&&(n=!0),h.NORMAL!==void 0&&(i=!0),h.COLOR_0!==void 0&&(r=!0),n&&i&&r)break}if(!n&&!i&&!r)return Promise.resolve(s);const a=[],o=[],l=[];for(let c=0,u=e.length;c<u;c++){const h=e[c];if(n){const d=h.POSITION!==void 0?t.getDependency("accessor",h.POSITION):s.attributes.position;a.push(d)}if(i){const d=h.NORMAL!==void 0?t.getDependency("accessor",h.NORMAL):s.attributes.normal;o.push(d)}if(r){const d=h.COLOR_0!==void 0?t.getDependency("accessor",h.COLOR_0):s.attributes.color;l.push(d)}}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l)]).then(function(c){const u=c[0],h=c[1],d=c[2];return n&&(s.morphAttributes.position=u),i&&(s.morphAttributes.normal=h),r&&(s.morphAttributes.color=d),s.morphTargetsRelative=!0,s})}function y0(s,e){if(s.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)s.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(s.morphTargetInfluences.length===t.length){s.morphTargetDictionary={};for(let n=0,i=t.length;n<i;n++)s.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function b0(s){let e;const t=s.extensions&&s.extensions[Je.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Pa(t.attributes):e=s.indices+":"+Pa(s.attributes)+":"+s.mode,s.targets!==void 0)for(let n=0,i=s.targets.length;n<i;n++)e+=":"+Pa(s.targets[n]);return e}function Pa(s){let e="";const t=Object.keys(s).sort();for(let n=0,i=t.length;n<i;n++)e+=t[n]+":"+s[t[n]]+";";return e}function Lo(s){switch(s){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function E0(s){return s.search(/\.jpe?g($|\?)/i)>0||s.search(/^data\:image\/jpeg/)===0?"image/jpeg":s.search(/\.webp($|\?)/i)>0||s.search(/^data\:image\/webp/)===0?"image/webp":s.search(/\.ktx2($|\?)/i)>0||s.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const T0=new We;class A0{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Zx,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,r=!1,a=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){const o=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(o)===!0;const l=o.match(/Version\/(\d+)/);i=n&&l?parseInt(l[1],10):-1,r=o.indexOf("Firefox")>-1,a=r?o.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&i<17||r&&a<98?this.textureLoader=new lf(this.options.manager):this.textureLoader=new mf(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new tl(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(a){return a._markDefs&&a._markDefs()}),Promise.all(this._invokeAll(function(a){return a.beforeRoot&&a.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(a){const o={scene:a[0][i.scene||0],scenes:a[0],animations:a[1],cameras:a[2],asset:i.asset,parser:n,userData:{}};return gi(r,o,i),An(o,i),Promise.all(n._invokeAll(function(l){return l.afterRoot&&l.afterRoot(o)})).then(function(){for(const l of o.scenes)l.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=t.length;i<r;i++){const a=t[i].joints;for(let o=0,l=a.length;o<l;o++)e[a[o]].isBone=!0}for(let i=0,r=e.length;i<r;i++){const a=e[i];a.mesh!==void 0&&(this._addNodeRef(this.meshCache,a.mesh),a.skin!==void 0&&(n[a.mesh].isSkinnedMesh=!0)),a.camera!==void 0&&this._addNodeRef(this.cameraCache,a.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const i=n.clone(),r=(a,o)=>{const l=this.associations.get(a);l!=null&&this.associations.set(o,l);for(const[c,u]of a.children.entries())r(u,o.children[c])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const r=e(t[i]);r&&n.push(r)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!i)throw new Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(r,a){return n.getDependency(e,a)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Je.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(r,a){n.load(Is.resolveURL(t.uri,i.path),r,void 0,function(){a(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const i=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+i)})}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){const a=Ra[i.type],o=ji[i.componentType],l=i.normalized===!0,c=new o(i.count*a);return Promise.resolve(new Nt(c,a,l))}const r=[];return i.bufferView!==void 0?r.push(this.getDependency("bufferView",i.bufferView)):r.push(null),i.sparse!==void 0&&(r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(r).then(function(a){const o=a[0],l=Ra[i.type],c=ji[i.componentType],u=c.BYTES_PER_ELEMENT,h=u*l,d=i.byteOffset||0,f=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,_=i.normalized===!0;let v,m;if(f&&f!==h){const p=Math.floor(d/f),b="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+p+":"+i.count;let T=t.cache.get(b);T||(v=new c(o,p*f,i.count*f/u),T=new Ad(v,f/u),t.cache.add(b,T)),m=new qo(T,l,d%f/u,_)}else o===null?v=new c(i.count*l):v=new c(o,d,i.count*l),m=new Nt(v,l,_);if(i.sparse!==void 0){const p=Ra.SCALAR,b=ji[i.sparse.indices.componentType],T=i.sparse.indices.byteOffset||0,S=i.sparse.values.byteOffset||0,w=new b(a[1],T,i.sparse.count*p),E=new c(a[2],S,i.sparse.count*l);o!==null&&(m=new Nt(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let R=0,x=w.length;R<x;R++){const A=w[R];if(m.setX(A,E[R*l]),l>=2&&m.setY(A,E[R*l+1]),l>=3&&m.setZ(A,E[R*l+2]),l>=4&&m.setW(A,E[R*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=_}return m})}loadTexture(e){const t=this.json,n=this.options,r=t.textures[e].source,a=t.images[r];let o=this.textureLoader;if(a.uri){const l=n.manager.getHandler(a.uri);l!==null&&(o=l)}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,n){const i=this,r=this.json,a=r.textures[e],o=r.images[t],l=(o.uri||o.bufferView)+":"+a.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,n).then(function(u){u.flipY=!1,u.name=a.name||o.name||"",u.name===""&&typeof o.uri=="string"&&o.uri.startsWith("data:image/")===!1&&(u.name=o.uri);const d=(r.samplers||{})[a.sampler]||{};return u.magFilter=zc[d.magFilter]||Bt,u.minFilter=zc[d.minFilter]||Yn,u.wrapS=Vc[d.wrapS]||es,u.wrapT=Vc[d.wrapT]||es,u.generateMipmaps=!u.isCompressedTexture&&u.minFilter!==Ot&&u.minFilter!==Bt,i.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const n=this,i=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(h=>h.clone());const a=i.images[e],o=self.URL||self.webkitURL;let l=a.uri||"",c=!1;if(a.bufferView!==void 0)l=n.getDependency("bufferView",a.bufferView).then(function(h){c=!0;const d=new Blob([h],{type:a.mimeType});return l=o.createObjectURL(d),l});else if(a.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const u=Promise.resolve(l).then(function(h){return new Promise(function(d,f){let _=d;t.isImageBitmapLoader===!0&&(_=function(v){const m=new Gt(v);m.needsUpdate=!0,d(m)}),t.load(Is.resolveURL(h,r.path),_,void 0,f)})}).then(function(h){return c===!0&&o.revokeObjectURL(l),An(h,a),h.userData.mimeType=a.mimeType||E0(a.uri),h}).catch(function(h){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),h});return this.sourceCache[e]=u,u}assignTexture(e,t,n,i){const r=this;return this.getDependency("texture",n.index).then(function(a){if(!a)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(a=a.clone(),a.channel=n.texCoord),r.extensions[Je.KHR_TEXTURE_TRANSFORM]){const o=n.extensions!==void 0?n.extensions[Je.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const l=r.associations.get(a);a=r.extensions[Je.KHR_TEXTURE_TRANSFORM].extendTexture(a,o),r.associations.set(a,l)}}return i!==void 0&&(a.colorSpace=i),e[t]=a,a})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){const o="PointsMaterial:"+n.uuid;let l=this.cache.get(o);l||(l=new vu,In.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,l.sizeAttenuation=!1,this.cache.add(o,l)),n=l}else if(e.isLine){const o="LineBasicMaterial:"+n.uuid;let l=this.cache.get(o);l||(l=new Br,In.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(o,l)),n=l}if(i||r||a){let o="ClonedMaterial:"+n.uuid+":";i&&(o+="derivative-tangents:"),r&&(o+="vertex-colors:"),a&&(o+="flat-shading:");let l=this.cache.get(o);l||(l=n.clone(),r&&(l.vertexColors=!0),a&&(l.flatShading=!0),i&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(o,l),this.associations.set(l,this.associations.get(n))),n=l}e.material=n}getMaterialType(){return $i}loadMaterial(e){const t=this,n=this.json,i=this.extensions,r=n.materials[e];let a;const o={},l=r.extensions||{},c=[];if(l[Je.KHR_MATERIALS_UNLIT]){const h=i[Je.KHR_MATERIALS_UNLIT];a=h.getMaterialType(),c.push(h.extendParams(o,r,t))}else{const h=r.pbrMetallicRoughness||{};if(o.color=new Ue(1,1,1),o.opacity=1,Array.isArray(h.baseColorFactor)){const d=h.baseColorFactor;o.color.setRGB(d[0],d[1],d[2],ln),o.opacity=d[3]}h.baseColorTexture!==void 0&&c.push(t.assignTexture(o,"map",h.baseColorTexture,Ht)),o.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,o.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(o,"metalnessMap",h.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",h.metallicRoughnessTexture))),a=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,o)})))}r.doubleSided===!0&&(o.side=an);const u=r.alphaMode||Ca.OPAQUE;if(u===Ca.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,u===Ca.MASK&&(o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&a!==yi&&(c.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new ke(1,1),r.normalTexture.scale!==void 0)){const h=r.normalTexture.scale;o.normalScale.set(h,h)}if(r.occlusionTexture!==void 0&&a!==yi&&(c.push(t.assignTexture(o,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&a!==yi){const h=r.emissiveFactor;o.emissive=new Ue().setRGB(h[0],h[1],h[2],ln)}return r.emissiveTexture!==void 0&&a!==yi&&c.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,Ht)),Promise.all(c).then(function(){const h=new a(o);return r.name&&(h.name=r.name),An(h,r),t.associations.set(h,{materials:e}),r.extensions&&gi(i,h,r),h})}createUniqueName(e){const t=dt.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function r(o){return n[Je.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(l){return Hc(l,o,t)})}const a=[];for(let o=0,l=e.length;o<l;o++){const c=e[o],u=b0(c),h=i[u];if(h)a.push(h.promise);else{let d;c.extensions&&c.extensions[Je.KHR_DRACO_MESH_COMPRESSION]?d=r(c):d=Hc(new Wt,c,t),i[u]={primitive:c,promise:d},a.push(d)}}return Promise.all(a)}loadMesh(e){const t=this,n=this.json,i=this.extensions,r=n.meshes[e],a=r.primitives,o=[];for(let l=0,c=a.length;l<c;l++){const u=a[l].material===void 0?M0(this.cache):this.getDependency("material",a[l].material);o.push(u)}return o.push(t.loadGeometries(a)),Promise.all(o).then(function(l){const c=l.slice(0,l.length-1),u=l[l.length-1],h=[];for(let f=0,_=u.length;f<_;f++){const v=u[f],m=a[f];let p;const b=c[f];if(m.mode===dn.TRIANGLES||m.mode===dn.TRIANGLE_STRIP||m.mode===dn.TRIANGLE_FAN||m.mode===void 0)p=r.isSkinnedMesh===!0?new Pd(v,b):new bt(v,b),p.isSkinnedMesh===!0&&p.normalizeSkinWeights(),m.mode===dn.TRIANGLE_STRIP?p.geometry=Oc(p.geometry,hu):m.mode===dn.TRIANGLE_FAN&&(p.geometry=Oc(p.geometry,So));else if(m.mode===dn.LINES)p=new Jo(v,b);else if(m.mode===dn.LINE_STRIP)p=new jo(v,b);else if(m.mode===dn.LINE_LOOP)p=new Od(v,b);else if(m.mode===dn.POINTS)p=new Bd(v,b);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(p.geometry.morphAttributes).length>0&&y0(p,r),p.name=t.createUniqueName(r.name||"mesh_"+e),An(p,r),m.extensions&&gi(i,p,m),t.assignFinalMaterial(p),h.push(p)}for(let f=0,_=h.length;f<_;f++)t.associations.set(h[f],{meshes:e,primitives:f});if(h.length===1)return r.extensions&&gi(i,h[0],r),h[0];const d=new Si;r.extensions&&gi(i,d,r),t.associations.set(d,{meshes:e});for(let f=0,_=h.length;f<_;f++)d.add(h[f]);return d})}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new Qt(fu.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new Vr(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),An(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let i=0,r=t.joints.length;i<r;i++)n.push(this._loadNodeShallow(t.joints[i]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(i){const r=i.pop(),a=i,o=[],l=[];for(let c=0,u=a.length;c<u;c++){const h=a[c];if(h){o.push(h);const d=new We;r!==null&&d.fromArray(r.array,c*16),l.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new Zo(o,l)})}loadAnimation(e){const t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,a=[],o=[],l=[],c=[],u=[];for(let h=0,d=i.channels.length;h<d;h++){const f=i.channels[h],_=i.samplers[f.sampler],v=f.target,m=v.node,p=i.parameters!==void 0?i.parameters[_.input]:_.input,b=i.parameters!==void 0?i.parameters[_.output]:_.output;v.node!==void 0&&(a.push(this.getDependency("node",m)),o.push(this.getDependency("accessor",p)),l.push(this.getDependency("accessor",b)),c.push(_),u.push(v))}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(l),Promise.all(c),Promise.all(u)]).then(function(h){const d=h[0],f=h[1],_=h[2],v=h[3],m=h[4],p=[];for(let T=0,S=d.length;T<S;T++){const w=d[T],E=f[T],R=_[T],x=v[T],A=m[T];if(w===void 0)continue;w.updateMatrix&&w.updateMatrix();const D=n._createAnimationTracks(w,E,R,x,A);if(D)for(let P=0;P<D.length;P++)p.push(D[P])}const b=new ef(r,void 0,p);return An(b,i),b})}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return i.mesh===void 0?null:n.getDependency("mesh",i.mesh).then(function(r){const a=n._getNodeRef(n.meshCache,i.mesh,r);return i.weights!==void 0&&a.traverse(function(o){if(o.isMesh)for(let l=0,c=i.weights.length;l<c;l++)o.morphTargetInfluences[l]=i.weights[l]}),a})}loadNode(e){const t=this.json,n=this,i=t.nodes[e],r=n._loadNodeShallow(e),a=[],o=i.children||[];for(let c=0,u=o.length;c<u;c++)a.push(n.getDependency("node",o[c]));const l=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(a),l]).then(function(c){const u=c[0],h=c[1],d=c[2];d!==null&&u.traverse(function(f){f.isSkinnedMesh&&f.bind(d,T0)});for(let f=0,_=h.length;f<_;f++)u.add(h[f]);if(u.userData.pivot!==void 0&&h.length>0){const f=u.userData.pivot,_=h[0];u.pivot=new C().fromArray(f),u.position.x-=f[0],u.position.y-=f[1],u.position.z-=f[2],_.position.set(0,0,0),delete u.userData.pivot}return u})}_loadNodeShallow(e){const t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=t.nodes[e],a=r.name?i.createUniqueName(r.name):"",o=[],l=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return l&&o.push(l),r.camera!==void 0&&o.push(i.getDependency("camera",r.camera).then(function(c){return i._getNodeRef(i.cameraCache,r.camera,c)})),i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){o.push(c)}),this.nodeCache[e]=Promise.all(o).then(function(c){let u;if(r.isBone===!0?u=new xu:c.length>1?u=new Si:c.length===1?u=c[0]:u=new At,u!==c[0])for(let h=0,d=c.length;h<d;h++)u.add(c[h]);if(r.name&&(u.userData.name=r.name,u.name=a),An(u,r),r.extensions&&gi(n,u,r),r.matrix!==void 0){const h=new We;h.fromArray(r.matrix),u.applyMatrix4(h)}else r.translation!==void 0&&u.position.fromArray(r.translation),r.rotation!==void 0&&u.quaternion.fromArray(r.rotation),r.scale!==void 0&&u.scale.fromArray(r.scale);if(!i.associations.has(u))i.associations.set(u,{});else if(r.mesh!==void 0&&i.meshCache.refs[r.mesh]>1){const h=i.associations.get(u);i.associations.set(u,{...h})}return i.associations.get(u).nodes=e,u}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],i=this,r=new Si;n.name&&(r.name=i.createUniqueName(n.name)),An(r,n),n.extensions&&gi(t,r,n);const a=n.nodes||[],o=[];for(let l=0,c=a.length;l<c;l++)o.push(i.getDependency("node",a[l]));return Promise.all(o).then(function(l){for(let u=0,h=l.length;u<h;u++){const d=l[u];d.parent!==null?r.add(qx(d)):r.add(d)}const c=u=>{const h=new Map;for(const[d,f]of i.associations)(d instanceof In||d instanceof Gt)&&h.set(d,f);return u.traverse(d=>{const f=i.associations.get(d);f!=null&&h.set(d,f)}),h};return i.associations=c(r),r})}_createAnimationTracks(e,t,n,i,r){const a=[],o=e.name?e.name:e.uuid,l=[];function c(f){f.morphTargetInfluences&&l.push(f.name?f.name:f.uuid)}oi[r.path]===oi.weights?(c(e),e.isGroup&&e.children.forEach(c)):l.push(o);let u;switch(oi[r.path]){case oi.weights:u=ks;break;case oi.rotation:u=zs;break;case oi.translation:case oi.scale:u=Ur;break;default:n.itemSize===1?u=ks:u=Ur;break}const h=i.interpolation!==void 0?v0[i.interpolation]:Fs,d=this._getArrayFromAccessor(n);for(let f=0,_=l.length;f<_;f++){const v=new u(l[f]+"."+oi[r.path],t.array,d,h);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(v),a.push(v)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=Lo(t.constructor),i=new Float32Array(t.length);for(let r=0,a=t.length;r<a;r++)i[r]=t[r]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const i=this instanceof zs?x0:Ou;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function w0(s,e,t){const n=e.attributes,i=new Yt;if(n.POSITION!==void 0){const o=t.json.accessors[n.POSITION],l=o.min,c=o.max;if(l!==void 0&&c!==void 0){if(i.set(new C(l[0],l[1],l[2]),new C(c[0],c[1],c[2])),o.normalized){const u=Lo(ji[o.componentType]);i.min.multiplyScalar(u),i.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=e.targets;if(r!==void 0){const o=new C,l=new C;for(let c=0,u=r.length;c<u;c++){const h=r[c];if(h.POSITION!==void 0){const d=t.json.accessors[h.POSITION],f=d.min,_=d.max;if(f!==void 0&&_!==void 0){if(l.setX(Math.max(Math.abs(f[0]),Math.abs(_[0]))),l.setY(Math.max(Math.abs(f[1]),Math.abs(_[1]))),l.setZ(Math.max(Math.abs(f[2]),Math.abs(_[2]))),d.normalized){const v=Lo(ji[d.componentType]);l.multiplyScalar(v)}o.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(o)}s.boundingBox=i;const a=new Fn;i.getCenter(a.center),a.radius=i.min.distanceTo(i.max)/2,s.boundingSphere=a}function Hc(s,e,t){const n=e.attributes,i=[];function r(a,o){return t.getDependency("accessor",a).then(function(l){s.setAttribute(o,l)})}for(const a in n){const o=Po[a]||a.toLowerCase();o in s.attributes||i.push(r(n[a],o))}if(e.indices!==void 0&&!s.index){const a=t.getDependency("accessor",e.indices).then(function(o){s.setIndex(o)});i.push(a)}return Qe.workingColorSpace!==ln&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Qe.workingColorSpace}" not supported.`),An(s,e),w0(s,e,t),Promise.all(i).then(function(){return e.targets!==void 0?S0(s,e.targets,t):s})}class R0 extends Ti{constructor(e){super(e)}load(e,t,n,i){const r=this,a=new tl(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(r.parse(o))}catch(l){i?i(l):console.error(l),r.manager.itemError(e)}},n,i)}parse(e){function t(c){const u=new DataView(c),h=32/8*3+32/8*3*3+16/8,d=u.getUint32(80,!0);if(80+32/8+d*h===u.byteLength)return!0;const _=[115,111,108,105,100];for(let v=0;v<5;v++)if(n(_,u,v))return!1;return!0}function n(c,u,h){for(let d=0,f=c.length;d<f;d++)if(c[d]!==u.getUint8(h+d))return!1;return!0}function i(c){const u=new DataView(c),h=u.getUint32(80,!0);let d,f,_,v=!1,m,p,b,T,S;for(let P=0;P<70;P++)u.getUint32(P,!1)==1129270351&&u.getUint8(P+4)==82&&u.getUint8(P+5)==61&&(v=!0,m=new Float32Array(h*3*3),p=u.getUint8(P+6)/255,b=u.getUint8(P+7)/255,T=u.getUint8(P+8)/255,S=u.getUint8(P+9)/255);const w=84,E=50,R=new Wt,x=new Float32Array(h*3*3),A=new Float32Array(h*3*3),D=new Ue;for(let P=0;P<h;P++){const F=w+P*E,$=u.getFloat32(F,!0),j=u.getFloat32(F+4,!0),k=u.getFloat32(F+8,!0);if(v){const q=u.getUint16(F+48,!0);(q&32768)===0?(d=(q&31)/31,f=(q>>5&31)/31,_=(q>>10&31)/31):(d=p,f=b,_=T)}for(let q=1;q<=3;q++){const W=F+q*12,ee=P*3*3+(q-1)*3;x[ee]=u.getFloat32(W,!0),x[ee+1]=u.getFloat32(W+4,!0),x[ee+2]=u.getFloat32(W+8,!0),A[ee]=$,A[ee+1]=j,A[ee+2]=k,v&&(D.setRGB(d,f,_,Ht),m[ee]=D.r,m[ee+1]=D.g,m[ee+2]=D.b)}}return R.setAttribute("position",new Nt(x,3)),R.setAttribute("normal",new Nt(A,3)),v&&(R.setAttribute("color",new Nt(m,3)),R.hasColors=!0,R.alpha=S),R}function r(c){const u=new Wt,h=/solid([\s\S]*?)endsolid/g,d=/facet([\s\S]*?)endfacet/g,f=/solid\s(.+)/;let _=0;const v=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,m=new RegExp("vertex"+v+v+v,"g"),p=new RegExp("normal"+v+v+v,"g"),b=[],T=[],S=[],w=new C;let E,R=0,x=0,A=0;for(;(E=h.exec(c))!==null;){x=A;const D=E[0],P=(E=f.exec(D))!==null?E[1]:"";for(S.push(P);(E=d.exec(D))!==null;){let j=0,k=0;const q=E[0];for(;(E=p.exec(q))!==null;)w.x=parseFloat(E[1]),w.y=parseFloat(E[2]),w.z=parseFloat(E[3]),k++;for(;(E=m.exec(q))!==null;)b.push(parseFloat(E[1]),parseFloat(E[2]),parseFloat(E[3])),T.push(w.x,w.y,w.z),j++,A++;k!==1&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+_),j!==3&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+_),_++}const F=x,$=A-x;u.userData.groupNames=S,u.addGroup(F,$,R),R++}return u.setAttribute("position",new Lt(b,3)),u.setAttribute("normal",new Lt(T,3)),u}function a(c){return typeof c!="string"?new TextDecoder().decode(c):c}function o(c){if(typeof c=="string"){const u=new Uint8Array(c.length);for(let h=0;h<c.length;h++)u[h]=c.charCodeAt(h)&255;return u.buffer||u}else return c}const l=o(e);return t(l)?i(l):r(a(e))}}function La(s){const e=s.toLowerCase();return e===".stl"?"stl":e===".glb"||e===".gltf"?"gltf":null}function Ia(s){return s>=100?s.toFixed(0):s.toFixed(1)}function C0(s,e){const t=`${Ia(s.x)} × ${Ia(s.y)} × ${Ia(s.z)}`;return e?`${t} ${e}`:t}function P0(s){let e=s,t="";for(;e;){if(e.name&&!t&&(t=e.name),e.name&&e.type==="Group")return e.name;e=e.parent}return t}function L0(s){if(s.ctrlKey||s.metaKey)return"pinch-zoom";if(s.deltaMode!==0)return"wheel-zoom";const e=Math.abs(s.wheelDeltaY??0);return e>=120&&e%120===0?"wheel-zoom":Math.abs(s.deltaX)>.01||e>0&&e%120!==0||!Number.isInteger(s.deltaY)||Math.abs(s.deltaY)<50?"trackpad-pan":"wheel-zoom"}const I0=.52,Gc=18,Io=1.38,D0=.62,N0=.55,U0=.72;function F0(s){return s?{rotate:D0,pan:N0,zoom:U0}:{rotate:1,pan:1,zoom:Io}}function Wc(s){return Number.isFinite(s)?Gc*Math.tanh(s*I0/Gc):0}function O0(s){const e=new Set;return s.traverse(t=>{if(!(t instanceof bt))return;let n=t,i=!1;for(;n;){if(n.name.toLowerCase().includes("_silkscreen")){i=!0;break}n=n.parent}if(i){t.renderOrder=Math.max(t.renderOrder,20);for(const r of Array.isArray(t.material)?t.material:[t.material])r.transparent=!1,r.opacity=1,r.depthTest=!0,r.depthWrite=!0,r.polygonOffset=!0,r.polygonOffsetFactor=-2,r.polygonOffsetUnits=-2,r.needsUpdate=!0,e.add(r)}}),e.size}function B0(s){const e=new Set;return s.traverse(t=>{if(!(t instanceof bt))return;let n=t,i=!1;for(;n;){if(/_pcb$/i.test(n.name)){i=!0;break}n=n.parent}if(i)for(const r of Array.isArray(t.material)?t.material:[t.material])r.transparent=!1,r.opacity=1,r.depthTest=!0,r.depthWrite=!0,r.needsUpdate=!0,e.add(r)}),e.size}function k0(s){const e=new Map;s.traverse(n=>{if(n instanceof bt)for(const i of Array.isArray(n.material)?n.material:[n.material])e.has(i)||!i.transparent||i.opacity<.8||e.set(i,{transparent:i.transparent,opacity:i.opacity,depthWrite:i.depthWrite,forceSinglePass:i.forceSinglePass})});let t=!1;return{count:e.size,setEnabled(n){if(n!==t){t=n;for(const[i,r]of e)t?(i.transparent=!1,i.opacity=1,i.depthWrite=!0,i.forceSinglePass=!0):(i.transparent=r.transparent,i.opacity=r.opacity,i.depthWrite=r.depthWrite,i.forceSinglePass=r.forceSinglePass),i.needsUpdate=!0}}}}const Mr={light:{bg:"#F4F4F2",part:"#9AA0A6",gridLine:"#CCCCCC",grid:"#DDDDDD"},dark:{bg:"#232527",part:"#8B929A",gridLine:"#4A4E54",grid:"#3A3E44"}};function Bu(){return typeof document<"u"&&document.documentElement.dataset.theme==="light"?"light":"dark"}const z0=[{termZh:"倒角",descZh:"把棱角削成斜面(如直角边变 45° 斜边)。防割手、防崩角、方便装配。",termEn:"Chamfer",descEn:"Bevels a sharp edge into a flat slope (e.g. 45°). Prevents cuts/chips and eases assembly."},{termZh:"圆角 / 内圆角",descZh:"把棱角磨圆。内角圆角能减少应力集中、不容易裂;外圆角防刮手。",termEn:"Fillet / inner radius",descEn:"Rounds a corner. Inner fillets reduce stress concentration; outer fillets prevent sharp edges."},{termZh:"加厚",descZh:"增加壁厚,让零件更结实。",termEn:"Thicken",descEn:"Increases wall thickness for strength."},{termZh:"减料",descZh:"去掉一部分材料(减重或让位)。",termEn:"Remove material",descEn:"Removes material (lighter or to make room)."},{termZh:"钻孔",descZh:"打一个圆孔,通常配螺丝/螺栓。",termEn:"Drill / hole",descEn:"Adds a round hole, usually for screws/bolts."},{termZh:"沉孔",descZh:"孔口挖一圈浅台阶,让螺丝头/螺母沉进表面不凸出。",termEn:"Counterbore",descEn:"Recesses the hole mouth so screw heads/nuts sit flush."},{termZh:"加强筋",descZh:"表面加一条凸起的筋,用最少材料增加抗弯强度。",termEn:"Rib",descEn:"A raised strip that adds bending strength with little material."},{termZh:"燕尾槽",descZh:"横截面是梯形的槽,另一零件的梯形尾部滑进去后被卡住、不会脱出。",termEn:"Dovetail slot",descEn:"A trapezoidal slot that locks a matching tail in place."},{termZh:"卡槽",descZh:"用来卡住或滑入另一个零件的槽。",termEn:"Slot",descEn:"A groove that holds or guides another part."},{termZh:"燕尾根部",descZh:"燕尾和板身连接的地方,受力集中、容易断。",termEn:"Tab root",descEn:"Where the dovetail meets the plate — stress concentrates here."},{termZh:"压面",descZh:"朝墙压住床垫的那个面。",termEn:"Press face",descEn:"The face pressing the mattress toward the wall."},{termZh:"胶贴面",descZh:"贴双面胶(VHB)粘到柜子上的面。",termEn:"Glue face",descEn:"The face that sticks to the cabinet with VHB tape."},{termZh:"支撑 / 加固",descZh:"在薄弱处加斜撑或筋,增强强度。",termEn:"Support / reinforce",descEn:"Adds a brace or rib to strengthen a weak spot."},{termZh:"间隙 / 公差",descZh:"两个配合件之间留的缝隙,滑动配合通常单边 0.15~0.3mm。",termEn:"Clearance / tolerance",descEn:"The gap between mating parts (sliding fit ~0.15-0.3mm per side)."}];function V0({locale:s,onClose:e}){const t=s==="zh";return ie.jsxs("div",{className:"space-y-2 p-1",children:[z0.map((n,i)=>ie.jsxs("div",{className:"rounded-md bg-surface/60 px-2 py-1.5",children:[ie.jsx("div",{className:"text-xs font-medium text-foreground",children:t?n.termZh:n.termEn}),ie.jsx("div",{className:"mt-0.5 text-[11px] leading-relaxed text-muted-foreground",children:t?n.descZh:n.descEn})]},i)),ie.jsx("button",{type:"button",className:"mt-1 w-full rounded-md bg-surface-elevated px-2 py-1 text-xs font-medium text-foreground hover:bg-surface",onClick:e,children:t?"返回特征列表":"Back to features"})]})}async function H0(s,e){if(e==="stl")return{kind:"stl",geometry:new R0().parse(s)};const t=await new Promise((n,i)=>{new Kx().parse(s,"",n,i)});return t.scene.traverse(n=>{const i=t.parser?.associations.get(n);i?.meshes!==void 0&&(n.userData.termdockSinglePart=!0);const r=i?.nodes!==void 0?t.parser.json.nodes?.[i.nodes]?.name:void 0;r&&(n.userData.termdockPartName=r)}),{kind:"gltf",object:t.scene}}function G0(s,e,t=1,n){const i=Bu(),r=new yd;r.background=new Ue(Mr[i].bg);const a=new Qt(45,s.clientWidth/Math.max(1,s.clientHeight),.1,1e4),o=new Ax({antialias:!0});o.setPixelRatio(window.devicePixelRatio),o.setSize(s.clientWidth,s.clientHeight),o.localClippingEnabled=!0,s.appendChild(o.domElement),r.add(new pf("white",.55*Math.PI));const l=new Ao("white",.8*Math.PI);l.position.set(1,2,3),r.add(l);const c=new Ao("white",.35*Math.PI);c.position.set(-2,-1,-2),r.add(c);let u,h=null,d;const f=new C;if(e.kind==="stl"){const G=e.geometry;G.computeBoundingBox();const J=G.boundingBox;u=J.getSize(new C);const y=J.getCenter(new C);f.copy(y),G.translate(-y.x,-y.y,-y.z),h=new $i({color:new Ue(Mr[i].part),metalness:.1,roughness:.75});const g=new bt(G,h);g.rotation.x=-Math.PI/2,r.add(g),d=g}else{const G=e.object;O0(G),B0(G),G.scale.setScalar(t),G.updateMatrixWorld(!0);const J=new Yt().setFromObject(G);u=J.getSize(new C);const y=J.getCenter(new C);f.copy(y),G.position.sub(y),r.add(G),d=G}const _=e.kind==="stl",v=_?null:Rx(d),m=Px(d);let p=null,b;const T=()=>{p&&(r.remove(p),p.geometry.dispose(),p.material.dispose(),p=null)},S=G=>_?new C(G.x-f.x,G.z-f.z,f.y-G.y):new C(G.x,G.z,-G.y).sub(f),w=G=>_?[G.x+f.x,f.y-G.z,G.y+f.z]:[G.x+f.x,-(G.z+f.z),G.y+f.y],E=(G,J,y,g)=>{const L=y.clone().sub(J),B=g.clone().sub(J),z=G.clone().sub(J),Q=L.dot(L),re=B.dot(B),X=L.dot(B),Z=z.dot(L),oe=z.dot(B),me=Q*re-X*X;if(me!==0){const ce=(re*Z-X*oe)/me,Ee=(Q*oe-X*Z)/me;if(ce>=0&&Ee>=0&&ce+Ee<=1)return G.distanceTo(J.clone().add(L.multiplyScalar(ce)).add(B.multiplyScalar(Ee)))}let ue=1/0;for(const[ce,Ee]of[[J,y],[y,g],[g,J]]){const Te=Ee.clone().sub(ce),Re=Te.dot(Te),I=Re===0?0:Math.min(1,Math.max(0,G.clone().sub(ce).dot(Te)/Re));ue=Math.min(ue,G.distanceTo(ce.clone().add(Te.multiplyScalar(I))))}return ue},R=G=>{const J=S(G);let y=1/0;const g=new C,L=new C,B=new C;return d.updateMatrixWorld(!0),d.traverse(z=>{if(!(z instanceof bt)||y<1e-6)return;const Q=z.geometry,re=Q.getAttribute("position");if(!re)return;const X=Q.getIndex(),Z=X?X.count/3:re.count/3,oe=v?.offset(z);for(let me=0;me<Z;me++){const ue=X?X.getX(me*3):me*3,ce=X?X.getX(me*3+1):me*3+1,Ee=X?X.getX(me*3+2):me*3+2;if(g.fromArray(re.array,ue*3).applyMatrix4(z.matrixWorld),L.fromArray(re.array,ce*3).applyMatrix4(z.matrixWorld),B.fromArray(re.array,Ee*3).applyMatrix4(z.matrixWorld),oe&&(g.sub(oe),L.sub(oe),B.sub(oe)),y=Math.min(y,E(J,g,L,B)),y<1e-6)break}}),y},A=new Yt().setFromObject(d).getSize(new C),D=e.kind==="stl"?{x:new C(1,0,0),y:new C(0,0,-1),z:new C(0,1,0)}:{x:new C(1,0,0),y:new C(0,1,0),z:new C(0,0,1)},P=new Xn(new C(0,-1,0),0);let F=!1;const $=[];d.traverse(G=>{if(G instanceof bt)for(const J of Array.isArray(G.material)?G.material:[G.material])$.push(J)});const j=k0(d),k=Math.max(u.length()/2,1e-6),q=ms(k,a.fov,a.aspect);a.position.set(q*.7,q*.6,q*.7),a.near=q/100,a.far=q*100,a.updateProjectionMatrix();let W=null;const ee=G=>{W&&(r.remove(W),W.geometry.dispose(),W.material.dispose());const J=Mr[G];W=new Rf(k*4,20,new Ue(J.gridLine),new Ue(J.grid)),W.position.y=-k*1.001,r.add(W)};ee(i);const K=new Nx(a,o.domElement);K.enableDamping=!0,K.dampingFactor=.08,K.screenSpacePanning=!0,K.zoomToCursor=!0,K.zoomSpeed=Io,K.minDistance=Math.max(k*.025,a.near*2),K.maxDistance=q*30;let le=null;const pe=()=>{le=null},Me=(G,J)=>{const y=K.enableDamping;K.enableDamping=!1,K.update(),K.enableDamping=y;const g={target:G,position:J};window.matchMedia?.("(prefers-reduced-motion: reduce)").matches?(K.target.copy(G),a.position.copy(J),K.update(),le=null):le={start:performance.now(),from:{target:K.target.clone(),position:a.position.clone()},to:g}},Ye=()=>{d.updateWorldMatrix(!0,!0);const G=new Yt;return d.traverse(J=>{!(J instanceof bt)||!_i(J)||(J.geometry.boundingBox||J.geometry.computeBoundingBox(),J.geometry.boundingBox&&G.union(J.geometry.boundingBox.clone().applyMatrix4(J.matrixWorld)))}),G},rt=G=>{const J=Ye();if(J.isEmpty())return;const y=J.getCenter(new C),g=ms(Math.max(J.getSize(new C).length()/2,k*.025),a.fov,a.aspect),L=G==="fit"?a.position.clone().sub(K.target).normalize():G==="front"?new C(0,0,1):G==="right"?new C(1,0,0):G==="top"?new C(0,1,1e-4).normalize():new C(.7,.6,.7).normalize();Me(y,y.clone().addScaledVector(L,g))};o.domElement.addEventListener("wheel",pe,{capture:!0});const qe=new Set,ne=G=>{const J=F0(G);K.rotateSpeed=J.rotate,K.panSpeed=J.pan,K.zoomSpeed=J.zoom},he=G=>{pe(),G.pointerType==="touch"&&(qe.add(G.pointerId),ne(!0))},ae=G=>{qe.delete(G.pointerId)&&qe.size===0&&ne(!1)};o.domElement.addEventListener("pointerdown",he,{capture:!0}),o.domElement.addEventListener("pointerup",ae,{capture:!0}),o.domElement.addEventListener("pointercancel",ae,{capture:!0});const Be=(G,J)=>{const y=Math.max(1,o.domElement.clientHeight||s.clientHeight),L=2*Math.max(a.position.distanceTo(K.target),1e-6)*Math.tan(a.fov*Math.PI/180/2)/y,B=a.getWorldDirection(new C),z=new C().crossVectors(B,a.up).normalize(),Q=new C().crossVectors(z,B).normalize(),re=z.multiplyScalar(Wc(G)*L).add(Q.multiplyScalar(-Wc(J)*L));a.position.add(re),K.target.add(re)},Oe=G=>{L0(G)==="trackpad-pan"&&(G.preventDefault(),G.stopImmediatePropagation(),Be(G.deltaX,G.deltaY))};o.domElement.addEventListener("wheel",Oe,{capture:!0,passive:!1});let De=1;const ft=G=>{const J=G;De=J.scale&&J.scale>0?J.scale:1,J.preventDefault(),J.stopPropagation()},Ge=G=>{const J=G,y=J.scale&&J.scale>0?J.scale:De,g=y/Math.max(De,1e-6),L=Math.min(2,Math.max(.5,Math.pow(g,Io)));De=y;const B=a.position.clone().sub(K.target),z=Math.min(K.maxDistance,Math.max(K.minDistance,B.length()/L));Number.isFinite(z)&&z>0&&(a.position.copy(K.target).add(B.setLength(z)),K.update()),J.preventDefault(),J.stopPropagation()},je=G=>{De=1,G.preventDefault(),G.stopPropagation()};o.domElement.addEventListener("gesturestart",ft,{passive:!1}),o.domElement.addEventListener("gesturechange",Ge,{passive:!1}),o.domElement.addEventListener("gestureend",je,{passive:!1});const Le=new wf,Ve=new ResizeObserver(()=>{const G=s.clientWidth,J=Math.max(1,s.clientHeight);if(G===0)return;const y=ms(k,a.fov,a.aspect);a.aspect=G/J;const g=ms(k,a.fov,a.aspect);a.position.sub(K.target).multiplyScalar(g/y).add(K.target),a.updateProjectionMatrix(),o.setSize(G,J)});Ve.observe(s);let nt=null,at=!0,Et=null,lt=[],et=1;const vt=()=>{const G=s.clientHeight/2,J=Math.tan(a.fov*Math.PI/180/2);for(const y of lt){const g=Math.max(a.position.distanceTo(y.point),1e-6),z=36/(G/(g*J))/(k*.12);for(const Q of y.meshes)Q.scale.set(z,z,z)}},U=()=>{if(!at){nt=null;return}if(le){const G=Math.min(1,(performance.now()-le.start)/240),J=G*G*(3-2*G);a.position.lerpVectors(le.from.position,le.to.position,J),K.target.lerpVectors(le.from.target,le.to.target,J),G===1&&(le=null)}K.update(),p&&b&&(p.visible=_i(b),p.visible&&p.update()),o.render(r,a),vt(),Et?.(),nt=requestAnimationFrame(U)};return U(),{partCount:v?.count??1,parts:m.parts,setView:rt,zoomAt:(G,J,y,g)=>{Le.setFromCamera(new ke(G/y*2-1,1-J/g*2),a);const L=Le.intersectObject(d,!0).find(Q=>_i(Q.object)&&(!F||P.distanceToPoint(Q.point)>=0));if(!L){rt("fit");return}const B=a.position.clone().sub(L.point).normalize(),z=Math.max(K.minDistance,a.position.distanceTo(L.point)*.45);Me(L.point.clone(),L.point.clone().addScaledVector(B,z))},cameraPose:()=>({position:a.position.clone(),target:K.target.clone()}),restoreCameraPose:({position:G,target:J})=>{pe(),a.position.copy(G),K.target.copy(J),K.update()},focusPart:G=>{pe();const J=G?m.node(G):d;if(!J)return;const y=new Yt().setFromObject(J);if(y.isEmpty())return;const g=y.getCenter(new C),L=ms(Math.max(y.getSize(new C).length()/2,1e-6),a.fov,a.aspect),B=a.position.clone().sub(K.target).normalize();K.target.copy(g),a.position.copy(g).addScaledVector(B,L),K.update()},setSelectedPart:G=>{if(T(),b=G?m.node(G):void 0,!b)return;const J=getComputedStyle(document.documentElement).getPropertyValue("--accent").trim()||"white";p=new Cf(b,new Ue(J)),p.visible=_i(b),r.add(p)},setHiddenParts:m.setHidden,setExplosion:G=>{if(pe(),!v||v.count<2)return;const J=v.set(G),y=J.getCenter(new C),g=Math.max(1,J.getSize(new C).length()/u.length()),L=a.position.clone().sub(K.target).multiplyScalar(g/et);K.target.copy(y),a.position.copy(y).add(L),et=g,K.update()},capture:G=>{try{return o.render(r,a),ju(o.domElement,void 0,G)}catch{return Promise.resolve(null)}},dims:C0(u,n??(e.kind==="stl"?"mm":void 0)),setActive:G=>{at!==G&&(at=G,!at&&nt!==null?(cancelAnimationFrame(nt),nt=null):at&&nt===null&&U())},setAppearance:G=>{const J=Mr[G];r.background=new Ue(J.bg),h&&(h.color=new Ue(J.part)),ee(G)},setClip:G=>{if(F=!!G,!G){j.setEnabled(!1);for(const L of $)L.clippingPlanes=null;h&&(h.side=Dn);return}j.setEnabled(!0);const J=D[G.axis],y=(Math.abs(J.x)*A.x+Math.abs(J.y)*A.y+Math.abs(J.z)*A.z)/2,g=(G.value01*2-1)*y;P.normal.copy(J).negate(),P.constant=g,G.flip&&(P.normal.negate(),P.constant=-g);for(const L of $)L.clippingPlanes=[P];h&&(h.side=an)},projectToScreen:(G,J)=>{if(!m.isPartVisible(J))return null;const y=S(G);J&&y.add(v?.offset(J)??new C);const g=y.clone().project(a);if(g.z<-1||g.z>1)return null;let L=!0;const B=y.clone().sub(a.position),z=B.length();if(z>1e-6){Le.set(a.position,B.normalize());const X=Le.intersectObject(d,!0).filter(Z=>_i(Z.object)&&(!F||P.distanceToPoint(Z.point)>=0));X.length>0&&X[0].distance<z-1.5&&(L=!1)}const Q=s.clientWidth,re=Math.max(1,s.clientHeight);return{x:(g.x*.5+.5)*Q,y:(-g.y*.5+.5)*re,visible:L}},surfaceDistance:G=>R(G),pick:(G,J,y,g)=>{const L=new ke(G/y*2-1,-(J/g*2-1));Le.setFromCamera(L,a);const B=Le.intersectObject(d,!0).find(me=>_i(me.object)&&(!F||P.distanceToPoint(me.point)>=0));if(!B)return null;const z=B.point.clone().sub(v?.offset(B.object)??new C),Q=w(z),re=B.face?.normal.clone().applyMatrix3(new He().getNormalMatrix(B.object.matrixWorld)).normalize(),X=re?[re.x,-re.z,re.y]:null,Z=v?.part(B.object);return{part:Z?.userData.termdockPartName||Z?.name||P0(B.object),node:Z?.uuid,visibilityId:m.id(B.object),point:Q,normal:X}},setSelection:G=>{for(const Q of lt)for(const re of Q.meshes)r.remove(re),re.geometry.dispose(),re.material.dispose();lt=[];const J=G?.filter(Q=>m.isPartVisible(Q.node??Q.part));if(!J?.length)return;const y=new Qo(k*.1,32),g=new $i({color:new Ue("#D0A215"),side:an,transparent:!0,opacity:.32,depthWrite:!1}),L=new el(k*.09,k*.12,32),B=new $i({color:new Ue("#D0A215"),side:an,transparent:!0,opacity:.9,depthWrite:!1}),z=new C(0,0,1);for(const Q of J){const re=S({x:Q.point[0],y:Q.point[1],z:Q.point[2]});re.add(v?.offset(Q.node??Q.part)??new C);const X=Q.normal?new C(Q.normal[0],Q.normal[2],-Q.normal[1]).normalize():null,Z=[];for(const[oe,me]of[[y,g],[L,B]]){const ue=new bt(oe,me);X?(ue.quaternion.setFromUnitVectors(z,X),ue.position.copy(re).add(X.clone().multiplyScalar(.15))):ue.position.copy(re),r.add(ue),Z.push(ue)}lt.push({point:re,meshes:Z})}vt()},setAfterRender:G=>{Et=G},dispose:()=>{T(),at=!1,nt!==null&&cancelAnimationFrame(nt),nt=null;for(const G of lt)for(const J of G.meshes)r.remove(J),J.geometry.dispose(),J.material.dispose();lt=[],Ve.disconnect(),o.domElement.removeEventListener("pointerdown",he,{capture:!0}),o.domElement.removeEventListener("pointerup",ae,{capture:!0}),o.domElement.removeEventListener("pointercancel",ae,{capture:!0}),o.domElement.removeEventListener("wheel",pe,{capture:!0}),o.domElement.removeEventListener("wheel",Oe,{capture:!0}),o.domElement.removeEventListener("gesturestart",ft),o.domElement.removeEventListener("gesturechange",Ge),o.domElement.removeEventListener("gestureend",je),K.dispose(),W&&(r.remove(W),W.geometry.dispose(),W.material.dispose(),W=null),r.traverse(G=>{if(G instanceof bt){G.geometry.dispose();const J=G.material;for(const y of Array.isArray(J)?J:[J])y.dispose()}}),o.dispose(),o.domElement.remove()}}}const Xc="termdock.model3d.bg";function iv({blobUrl:s,ext:e,fileName:t,filePath:n,features:i,onInsertFeature:r,onRefresh:a,unitScale:o=1,dimensionUnit:l,coordinateSystemLabel:c,annotationPrefix:u="",normalizePickedPartName:h,active:d=!0}){const{t:f,locale:_}=Do(),v=we.useRef(null),m=we.useRef(null),[p,b]=we.useState({kind:"loading"}),[T,S]=we.useState(!1),w=typeof document<"u"&&document.fullscreenEnabled,[E,R]=we.useState(!1),x=T||E,A=()=>{w?document.fullscreenElement?document.exitFullscreen():v.current?.requestFullscreen():R(N=>!N)},[D,P]=we.useState(()=>{if(typeof window>"u")return null;const N=window.localStorage.getItem(Xc);return N==="light"||N==="dark"?N:null}),F=we.useRef(null),$=we.useRef(D);$.current=D;const[j,k]=we.useState(!1),[q,W]=we.useState("z"),[ee,K]=we.useState(.5),[le,pe]=we.useState(!1),Me=we.useRef(null);Me.current=j?{axis:q,value01:ee,flip:le}:null;const[Ye,rt]=we.useState(!1),[qe,ne]=we.useState(.65),[he,ae]=we.useState("y"),Be=we.useRef(null);Be.current=Ye?{axis:he,amount:qe}:null;const[Oe,De]=we.useReducer(Nc,{hidden:[],history:[]}),ft=we.useRef(Oe);ft.current=Oe;const Ge=we.useRef([]),je=N=>{const Ce=ft.current,it=Nc(Ce,N);if(ft.current=it,N.type==="reset")Ge.current=[];else if(N.type==="undo"){const tt=Ge.current.pop();tt&&F.current?.restoreCameraPose(tt)}else it!==Ce&&(Ge.current=[...Ge.current.slice(-19),F.current?.cameraPose()]);De(N)},Le=Oe.hidden,[Ve,nt]=we.useState(!1),[at,Et]=we.useState(!1),[lt,et]=we.useState(null),vt=we.useRef(null),U=p.kind==="ready"?p.parts.filter(N=>N.initiallyVisible).map((N,Ce)=>({...N,name:h?.(N.name)||N.name||f("rightSidebar.model3dUnnamedPart",{index:Ce+1})})):[],G=U.find(N=>N.id===lt),J=()=>{nt(!1),vt.current?.focus()},y=we.useRef(Le);y.current=Le;const g=()=>[Cx(Be.current,Me.current),y.current.length>0?`Hidden parts: ${y.current.length}`:""].filter(Boolean).join(" / "),[L,B]=we.useState(!1),[z,Q]=we.useState([]),[re,X]=we.useState(null),[Z,oe]=we.useState(!1),[me,ue]=we.useState(()=>typeof window<"u"&&window.innerWidth>=768),ce=we.useRef(null),Ee=we.useRef(z);Ee.current=z;const Te=i?.filter(N=>z.includes(N.id))??[],[Re,I]=we.useState(null),fe=we.useRef(Re);fe.current=Re;const te=we.useRef(null),de=we.useRef(null),ge=we.useRef(new Set),se=we.useRef(!1),be=we.useRef(null),Ae=N=>{et(N),I(null),B(!1),Q([])},St=N=>{je({type:"toggle",id:N}),Le.includes(N)&&Le.length===U.length-1&&F.current?.focusPart(),Re?.visibilityId===N&&I(null)},ct=N=>{je({type:"set",hidden:U.filter(Ce=>Ce.id!==N).map(Ce=>Ce.id)}),et(N),Re?.visibilityId!==N&&I(null),F.current?.focusPart(N)},cn=()=>{je({type:"set",hidden:[]}),Le.length===U.length-1&&F.current?.focusPart()},qt=!!(G||Re||Te.length);we.useEffect(()=>{const N=v.current;if(!N)return;const Ce=()=>Et(N.clientWidth>=720);Ce();const it=new ResizeObserver(Ce);return it.observe(N),()=>it.disconnect()},[E]);const Hs=N=>{const Ce=N.part.replace(/_\d+$/,""),it=i?.find(tt=>tt.node&&(tt.node===N.part||tt.node===Ce));return it?it.part:i&&i.length>0&&(!N.part||N.part==="part")?i[0].part:Ce||t.replace(/\.(stl|glb|gltf)$/i,"")},Wr=()=>{const N=fe.current;if(!N)return;const Ce=La(e)==="gltf",it=c??(Ce?"GLB Y-up":"STL Z-up"),tt=M=>Ce?[M[0],M[2],-M[1]]:M,Xt=tt(N.point).map(M=>M.toFixed(1)).join(","),Tt=N.normal?` · 法线 (${tt(N.normal).map(M=>M.toFixed(2)).join(",")})`:"",yt=Hs(N),Ut=l??(Ce?"文件单位":"mm"),ot=`${u?`${u}: `:""}${n??t}
4109
4109
  ${yt} · 点 (${Xt}) [${it}, ${Ut}]${Tt}`,Rt=g();r?.([ot,Rt].filter(Boolean).join(`
4110
4110
  `),`pick:${N.part}:${Xt}`,{snapshot:F.current?.capture(Rt)}),I(null)};we.useEffect(()=>{F.current?.setExplosion(Be.current)},[Ye,qe,he]),we.useEffect(()=>{F.current?.setHiddenParts(Le)},[Le]),we.useEffect(()=>{F.current?.setSelectedPart(lt)},[lt,p]),we.useEffect(()=>{const N=[];if(i)for(const Ce of i)z.includes(Ce.id)&&N.push({part:Ce.node??Ce.part,point:Ce.center,normal:Ce.normal??null});Re&&N.push({part:Re.part,node:Re.node,point:Re.point,normal:Re.normal}),F.current?.setSelection(N.length>0?N:null)},[i,z,Re,Ye,qe,he,p,Le]);const us=N=>{Q(Ce=>Ce.includes(N)?Ce.filter(it=>it!==N):Ce.length>=2?[Ce[1],N]:[...Ce,N])};we.useEffect(()=>{if(p.kind!=="ready"||!F.current)return;const N=F.current,Ce=()=>{const it=ce.current;if(!N)return;if(it&&i){let Tt=0;const yt=[],Ut=Ee.current;for(const ot of i)try{const Rt=it.querySelector(`[data-feature-id="${ot.id}"]`);if(!Rt)continue;const M=new C(ot.center[0],ot.center[1],ot.center[2]);ot.normal&&(M.x+=ot.normal[0]*2,M.y+=ot.normal[1]*2,M.z+=ot.normal[2]*2);const O=N.projectToScreen(M,ot.node??ot.part);Rt.style.display=O?"":"none",O&&(Rt.style.transform=`translate(${O.x}px, ${O.y}px) translate(-50%, -50%)`,Rt.style.opacity=O.visible||Ut.includes(ot.id)?"1":"0.22",Ut.includes(ot.id)&&yt.push({id:ot.id,x:O.x,y:O.y}),Tt+=1)}catch(Rt){console.error("[ModelPreview] 特征标签定位失败",Rt)}if(X(ot=>ot&&ot.total===i.length&&ot.positioned===Tt?ot:{total:i.length,positioned:Tt}),yt.length===2){const ot=yt[0],Rt=yt[1],M=Rt.x-ot.x,O=Rt.y-ot.y,Y=Math.hypot(M,O);if(Y>1e-6&&Y<24){const V=M/Y,H=O/Y,_e=it.querySelector(`[data-feature-id="${ot.id}"]`),Se=it.querySelector(`[data-feature-id="${Rt.id}"]`);_e&&(_e.style.transform=`translate(${ot.x-V*8}px, ${ot.y-H*8}px) translate(-50%, -50%)`),Se&&(Se.style.transform=`translate(${Rt.x+V*18}px, ${Rt.y+H*18}px) translate(-50%, -50%)`)}}}const tt=fe.current,Xt=te.current;if(tt&&Xt){const Tt=N.projectToScreen(new C(tt.point[0],tt.point[1],tt.point[2]),tt.node??tt.part);Tt?(Xt.style.display="",Xt.style.transform=`translate(${Tt.x}px, ${Tt.y}px) translate(-50%, -50%)`):Xt.style.display="none"}};return Ce(),N.setAfterRender(Ce),()=>{N.setAfterRender(null)}},[i,L,p.kind]),we.useEffect(()=>{Q([]),oe(!1),I(null)},[s,L]);const hs=()=>{if(Te.length===0)return;const N=La(e)==="gltf",Ce=c??(N?"GLB Y-up":"STL Z-up"),it=yt=>N?[yt[0],yt[2],-yt[1]]:yt,tt=Te.map((yt,Ut)=>{const ot=it(yt.center).map(Y=>Y.toFixed(1)).join(","),Rt=F.current?.surfaceDistance({x:yt.center[0],y:yt.center[1],z:yt.center[2]})??0,M=Number.isFinite(Rt)&&Rt>.05?` / 命中距离 ${Rt.toFixed(1)}mm`:"";return`${Te.length>1?`面${"AB"[Ut]}: `:""}${yt.part}·${yt.name} (中心 ${ot}) [${Ce}]${M}`}),Xt=`${u?`${u}: `:""}${n??t}
4111
4111
  ${tt.join(" ; ")}`,Tt=g();r?.([Xt,Tt].filter(Boolean).join(`
4112
- `),`features:${Te.map(yt=>yt.id).join("+")}`,{snapshot:F.current?.capture(Tt)}),Q([])},ds=we.useRef(f);ds.current=f;const Gs=Bu(),fs=D??Gs,Bn=()=>{const N=fs==="dark"?"light":"dark";P(N);try{window.localStorage.setItem(Xc,N)}catch{}};we.useEffect(()=>{const N=()=>{S(document.fullscreenElement===v.current)};return document.addEventListener("fullscreenchange",N),()=>document.removeEventListener("fullscreenchange",N)},[]),we.useEffect(()=>{const N=La(e);if(!N){b({kind:"error",message:ds.current("rightSidebar.model3dLoadFailed")});return}let Ce=!1,it=null;return b({kind:"loading"}),(async()=>{const tt=await fetch(s);if(!tt.ok)throw new Error(`Failed to fetch model blob (${tt.status})`);const Xt=await tt.arrayBuffer(),Tt=await V0(Xt,N),yt=m.current;if(Ce||!yt)return;const Ut=H0(yt,Tt,o,l);it=Ut.dispose,F.current=Ut,Ut.setActive(d),$.current&&Ut.setAppearance($.current),Ut.setClip(Me.current),Ut.setExplosion(Be.current),Ut.setHiddenParts(y.current),Ce||b({kind:"ready",dims:Ut.dims,partCount:Ut.partCount,parts:Ut.parts})})().catch(tt=>{Ce||b({kind:"error",message:tt instanceof Error?tt.message:ds.current("rightSidebar.model3dLoadFailed")})}),()=>{Ce=!0,it?.(),F.current=null}},[s,e,E,o,l]),we.useEffect(()=>{be.current=null,rt(!1),k(!1),je({type:"reset"}),I(null),et(null)},[s,e]),we.useEffect(()=>{F.current?.setActive(d)},[d]),we.useEffect(()=>{D&&F.current?.setAppearance(D)},[D]),we.useEffect(()=>{F.current?.setClip(j?{axis:q,value01:ee,flip:le}:null)},[j,q,ee,le]);const Ai=!Ve&&qt?x?"bottom-[calc(4rem+env(safe-area-inset-bottom,0px))]":"bottom-16":!Ve&&(Le.length>0||Oe.history.length>0)?x?"bottom-[calc(3.5rem+env(safe-area-inset-bottom,0px))]":"bottom-14":x?"bottom-[calc(0.75rem+env(safe-area-inset-bottom,0px))]":"bottom-3",ps=ie.jsxs("div",{ref:v,"data-sidebar-gesture-ignore":!0,onPointerDown:N=>N.stopPropagation(),onTouchStart:N=>N.stopPropagation(),onKeyDownCapture:N=>{if(N.key==="Escape"&&!(N.target instanceof Element&&N.target.closest('[data-model-viewer-menu="open"]'))){if(Ve)J();else if(qt)et(null),I(null),Q([]);else return;N.preventDefault(),N.stopPropagation()}},className:E?`fixed inset-0 z-modal-panel flex overflow-hidden bg-surface ${at?"flex-row":"flex-col"}`:`relative flex h-full min-h-0 flex-1 overflow-hidden bg-surface ${at?"flex-row":"flex-col"}`,children:[ie.jsxs("div",{className:"relative min-h-0 min-w-0 flex-1",children:[p.kind==="ready"&&!Ve&&!G&&ie.jsxs("div",{className:`pointer-events-none absolute right-3 z-10 select-none text-xs leading-relaxed text-muted-foreground max-sm:rounded-lg max-sm:bg-surface/75 max-sm:px-2.5 max-sm:py-1.5 max-sm:text-[15px] ${x?"left-[calc(0.75rem+env(safe-area-inset-left,0px))] top-[calc(3.75rem+env(safe-area-inset-top,0px))]":"left-3 top-14"}`,children:[ie.jsx("div",{className:"text-sm font-semibold text-foreground max-sm:text-base",children:t}),ie.jsx("div",{children:f("rightSidebar.model3dDimensions",{dims:p.dims})}),Ye&&!Ve&&ie.jsx("div",{children:f("rightSidebar.model3dExplodedNotice")}),L&&re&&ie.jsx("div",{className:"text-foreground/70",children:f("rightSidebar.model3dFeatureStatus",{total:re.total,positioned:re.positioned})}),!Ve&&!qt&&ie.jsx("div",{children:f("rightSidebar.model3dInspectHint")})]}),p.kind!=="error"&&ie.jsxs("div",{className:`absolute left-3 z-20 flex justify-end gap-0.5 [&>button]:h-9 [&>button]:w-9 [&>button]:shrink-0 ${x?"right-[calc(0.75rem+env(safe-area-inset-right,0px))] top-[calc(0.625rem+env(safe-area-inset-top,0px))]":"right-3 top-2.5"}`,children:[p.kind==="ready"&&p.partCount>1&&ie.jsx("button",{ref:vt,type:"button",title:f("rightSidebar.model3dParts"),"aria-label":f("rightSidebar.model3dParts"),"aria-expanded":Ve,style:{width:"auto"},className:`inline-flex h-7 w-7 items-center justify-center rounded-full transition active:scale-95 ${Ve?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,onClick:()=>{nt(N=>!N),B(!1),Q([])},children:ie.jsxs("span",{className:"inline-flex items-center gap-1 px-2",children:[ie.jsx(dl,{size:16}),f("rightSidebar.model3dParts"),Le.length>0&&ie.jsx("span",{className:"text-xs tabular-nums text-accent",children:Le.length})]})}),p.kind==="ready"&&p.partCount>1&&ie.jsx("button",{type:"button",title:f("rightSidebar.model3dExplode"),"aria-label":f("rightSidebar.model3dExplode"),"aria-pressed":Ye,className:`inline-flex items-center justify-center rounded-full ${Ye?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground"}`,onClick:()=>{rt(N=>!N),k(!1)},children:ie.jsx(Xu,{size:16})}),i&&i.length>0&&ie.jsx("button",{type:"button",title:f("rightSidebar.model3dFeatureToggle"),"aria-label":f("rightSidebar.model3dFeatureToggle"),"aria-pressed":L,className:`inline-flex h-7 w-7 items-center justify-center rounded-full transition active:scale-95 ${L?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,onClick:()=>{B(N=>{const Ce=!N;return Ce&&(et(null),I(null)),Ce})},children:ie.jsx(rh,{size:14})}),ie.jsx("button",{type:"button",title:f("rightSidebar.model3dClipToggle"),"aria-label":f("rightSidebar.model3dClipToggle"),"aria-pressed":j,className:`inline-flex h-7 w-7 items-center justify-center rounded-full transition active:scale-95 ${j?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,onClick:()=>{k(N=>!N),rt(!1)},children:ie.jsx(ih,{size:14})}),ie.jsx("button",{type:"button",title:f(x?"rightSidebar.model3dFullscreenExit":"rightSidebar.model3dFullscreenEnter"),"aria-label":f(x?"rightSidebar.model3dFullscreenExit":"rightSidebar.model3dFullscreenEnter"),className:"inline-flex h-7 w-7 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",onClick:A,children:x?ie.jsx(Yu,{size:14}):ie.jsx(qu,{size:14})}),ie.jsx("button",{type:"button",title:f("rightSidebar.model3dHome"),"aria-label":f("rightSidebar.model3dHome"),className:"inline-flex items-center justify-center rounded-full bg-surface-2 text-muted-foreground hover:bg-surface-elevated",onClick:()=>F.current?.setView("home"),children:ie.jsx(Ku,{size:16})}),ie.jsx(Lx,{onView:N=>F.current?.setView(N),dark:fs==="dark",onToggleBackground:Bn,onRefresh:a})]}),p.kind==="ready"&&Ye&&p.partCount>1&&ie.jsxs("div",{className:`swiper-no-swiping absolute left-3 right-3 z-20 flex flex-wrap items-center justify-center gap-2 rounded-lg bg-surface-2 px-2 py-1 ${Ai}`,onPointerDown:N=>N.stopPropagation(),onTouchStart:N=>N.stopPropagation(),children:[ie.jsx("select",{"aria-label":f("rightSidebar.model3dExplodeAxis"),value:he,onChange:N=>ae(N.target.value),className:"h-9 rounded-md bg-surface-elevated px-2 text-sm text-foreground",children:["x","y","z"].map(N=>ie.jsx("option",{value:N,children:N.toUpperCase()},N))}),ie.jsx("input",{type:"range",min:0,max:100,value:Math.round(qe*100),onChange:N=>ne(Number(N.target.value)/100),"aria-label":f("rightSidebar.model3dExplodeAmount"),className:"h-9 min-w-0 flex-1"}),ie.jsxs("output",{className:"w-9 text-right text-xs tabular-nums text-muted-foreground",children:[Math.round(qe*100),"%"]}),ie.jsx("button",{type:"button","aria-label":f("rightSidebar.model3dAssemble"),title:f("rightSidebar.model3dAssemble"),className:"inline-flex h-9 w-9 items-center justify-center rounded-md bg-surface-elevated text-foreground",onClick:()=>rt(!1),children:ie.jsx(Zu,{size:16})})]}),p.kind==="ready"&&j&&ie.jsxs("div",{className:`swiper-no-swiping absolute left-3 right-3 z-20 flex items-center justify-center gap-2 rounded-xl bg-surface-2 px-3 py-2 ${Ai}`,onPointerDown:N=>N.stopPropagation(),onTouchStart:N=>N.stopPropagation(),children:[["x","y","z"].map(N=>ie.jsx("button",{type:"button","aria-pressed":q===N,className:`h-6 w-6 rounded-md text-xs font-medium transition active:scale-95 ${q===N?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,onClick:()=>W(N),children:N.toUpperCase()},N)),ie.jsx("input",{type:"range",min:0,max:1e3,value:Math.round(ee*1e3),onChange:N=>K(Number(N.target.value)/1e3),className:"h-9 min-w-0 flex-1","aria-label":f("rightSidebar.model3dClipPosition")}),ie.jsx("button",{type:"button",title:f("rightSidebar.model3dClipFlip"),"aria-label":f("rightSidebar.model3dClipFlip"),"aria-pressed":le,className:`inline-flex h-6 w-6 items-center justify-center rounded-md transition active:scale-95 ${le?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,onClick:()=>pe(N=>!N),children:ie.jsx(Ju,{size:13})})]}),p.kind==="ready"&&i&&L&&ie.jsx("div",{ref:ce,className:"pointer-events-none absolute inset-0 z-10 overflow-hidden",children:i.map(N=>ie.jsxs("button",{type:"button","data-feature-id":N.id,title:`${N.part}·${N.name}`,className:`pointer-events-auto absolute left-0 top-0 model3d-feature-label flex items-center gap-1 rounded-full px-1 py-0.5 transition-[opacity] ${z.includes(N.id)?"border border-foreground bg-surface-elevated":"border border-transparent hover:border-border/60"}`,onClick:()=>us(N.id),children:[ie.jsx("span",{className:"block h-2.5 w-2.5 flex-none rounded-full border border-black/50",style:{background:N.part==="底座"?"#E8833A":N.part==="压件"?"#3F9E6D":"#4385BE"}}),z.includes(N.id)&&ie.jsxs("span",{className:"max-w-[140px] truncate text-[11px] leading-4 text-foreground",children:["面","AB"[z.indexOf(N.id)],": ",N.part,"·",N.name]})]},N.id))}),p.kind==="ready"&&i&&L&&ie.jsxs("div",{className:"swiper-no-swiping absolute bottom-28 right-2 top-40 z-20 h-fit max-h-[calc(100%-17rem)] w-44 overflow-auto rounded-xl bg-surface-2/95",onPointerDown:N=>N.stopPropagation(),onTouchStart:N=>N.stopPropagation(),children:[ie.jsxs("button",{type:"button","aria-expanded":me,className:"flex w-full items-center justify-between gap-2 px-2.5 py-1.5 text-xs font-medium text-foreground",onClick:()=>ue(N=>!N),children:[ie.jsxs("span",{className:"truncate",children:[f("rightSidebar.model3dFeatureToggle")," (",i.length,")"]}),ie.jsxs("span",{className:"flex items-center gap-1",children:[ie.jsx("span",{role:"button",tabIndex:0,title:f("rightSidebar.model3dGlossaryToggle"),"aria-label":f("rightSidebar.model3dGlossaryToggle"),className:"inline-flex h-5 w-5 items-center justify-center rounded-full text-muted-foreground hover:bg-surface-elevated hover:text-foreground",onClick:N=>{N.stopPropagation(),oe(Ce=>!Ce)},onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.stopPropagation(),oe(Ce=>!Ce))},children:"?"}),ie.jsx("span",{className:"flex-none text-muted-foreground",children:me?"▾":"▸"})]})]}),me&&ie.jsx("div",{className:"max-h-[calc(100%-2.25rem)] overflow-auto border-t border-border/20 p-1.5",children:Z?ie.jsx(z0,{locale:_,onClose:()=>oe(!1)}):i.map(N=>ie.jsxs("button",{type:"button","aria-pressed":z.includes(N.id),className:`flex w-full items-center gap-1.5 rounded-md px-1.5 py-1 text-left text-xs transition ${z.includes(N.id)?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,onClick:()=>us(N.id),children:[ie.jsx("span",{className:"h-2 w-2 flex-none rounded-full",style:{background:N.part==="底座"?"#E8833A":N.part==="压件"?"#3F9E6D":"#4385BE"}}),ie.jsxs("span",{className:"truncate",children:[N.part,"·",N.name]})]},N.id))})]}),p.kind==="ready"&&!L&&Re&&ie.jsx("div",{ref:te,className:"pointer-events-none absolute left-0 top-0 z-10 h-3 w-3 rounded-full border-2 border-accent bg-surface"}),p.kind==="ready"&&!Ve&&qt&&ie.jsxs("div",{className:`swiper-no-swiping absolute left-3 right-3 z-20 flex items-center rounded-lg border border-border/30 bg-surface pl-3 pr-1 shadow ${x?"bottom-[calc(0.75rem+env(safe-area-inset-bottom,0px))]":"bottom-3"}`,onPointerDown:N=>N.stopPropagation(),onTouchStart:N=>N.stopPropagation(),children:[ie.jsx("div",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",title:G?.name,children:G?.name??(Re?Hs(Re):Te.map(N=>N.name).join(" · "))}),G&&U.length>1&&ie.jsxs(ie.Fragment,{children:[ie.jsx("button",{type:"button",className:"inline-flex h-11 w-11 shrink-0 items-center justify-center rounded-lg text-foreground hover:bg-surface-2",title:f(Le.includes(G.id)?"rightSidebar.model3dShowPart":"rightSidebar.model3dHidePart"),"aria-label":f(Le.includes(G.id)?"rightSidebar.model3dShowPart":"rightSidebar.model3dHidePart"),onClick:()=>{St(G.id),et(null),I(null),Q([])},children:Le.includes(G.id)?ie.jsx(qc,{size:18}):ie.jsx(Yc,{size:18})}),ie.jsx("button",{type:"button",onClick:()=>ct(G.id),disabled:!Le.includes(G.id)&&Le.length===U.length-1,title:f("rightSidebar.model3dIsolatePart"),"aria-label":f("rightSidebar.model3dIsolatePart"),className:"inline-flex h-11 w-11 shrink-0 items-center justify-center rounded-lg text-foreground hover:bg-surface-2 disabled:opacity-40",children:ie.jsx(Kc,{size:18})})]}),r&&(Re||Te.length>0)&&ie.jsx("button",{type:"button",className:"inline-flex h-11 w-11 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-surface-2",title:f("rightSidebar.model3dFeatureInsert"),"aria-label":f("rightSidebar.model3dFeatureInsert"),onClick:Te.length>0?hs:Wr,children:ie.jsx(th,{size:18})}),Oe.history.length>0&&ie.jsx("button",{type:"button",onClick:()=>je({type:"undo"}),"aria-label":f("rightSidebar.model3dUndoVisibility"),title:f("rightSidebar.model3dUndoVisibility"),className:"inline-flex h-11 w-11 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-surface-2",children:ie.jsx(Na,{size:16})}),ie.jsx("button",{type:"button","aria-label":f("rightSidebar.model3dClearSelection"),onClick:()=>{et(null),I(null),Q([])},className:"inline-flex h-11 w-11 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-surface-2",children:ie.jsx(Da,{size:16})})]}),p.kind==="ready"&&!Ve&&!qt&&(Le.length>0||Oe.history.length>0)&&ie.jsxs("div",{className:`swiper-no-swiping absolute left-3 right-3 z-20 flex items-center justify-between gap-2 rounded-xl bg-surface px-2 ${x?"bottom-[calc(0.75rem+env(safe-area-inset-bottom,0px))]":"bottom-3"}`,onPointerDown:N=>N.stopPropagation(),onTouchStart:N=>N.stopPropagation(),children:[ie.jsxs("button",{type:"button",className:"inline-flex h-9 items-center gap-1 px-1 text-xs text-foreground",onClick:()=>nt(!0),children:[ie.jsx(dl,{size:15}),Le.length?f("rightSidebar.model3dHiddenParts",{count:Le.length}):f("rightSidebar.model3dAllPartsVisible")]}),ie.jsxs("button",{type:"button",disabled:!Oe.history.length,className:"inline-flex h-9 items-center gap-1 px-1 text-xs text-foreground disabled:opacity-40",onClick:()=>je({type:"undo"}),children:[ie.jsx(Na,{size:14}),f("rightSidebar.model3dUndoVisibility")]})]}),ie.jsx("div",{ref:m,className:"swiper-no-swiping absolute inset-0",style:{touchAction:"none"},tabIndex:0,"aria-label":f("rightSidebar.model3dCanvas"),onPointerMove:N=>{const Ce=de.current;Ce&&Math.hypot(N.clientX-Ce.x,N.clientY-Ce.y)>8&&(de.current=null)},onPointerDown:N=>{N.stopPropagation(),N.currentTarget.focus({preventScroll:!0}),ge.current.size===0&&(se.current=!1),ge.current.add(N.pointerId),ge.current.size>1&&(se.current=!0,be.current=null),de.current=se.current?null:{x:N.clientX,y:N.clientY}},onPointerUp:N=>{const Ce=de.current;if(de.current=null,ge.current.delete(N.pointerId),!Ce||se.current){be.current=null;return}if(Math.hypot(N.clientX-Ce.x,N.clientY-Ce.y)>8||N.button!==0)return;const it=N.currentTarget.getBoundingClientRect(),tt=be.current,Xt=performance.now();if(tt&&Xt-tt.time<320&&tt.pointerType===N.pointerType&&Math.hypot(N.clientX-tt.x,N.clientY-tt.y)<24){be.current=null,F.current?.zoomAt(N.clientX-it.left,N.clientY-it.top,it.width||1,it.height||1),I(null),Q([]),et(null);return}if(be.current={x:N.clientX,y:N.clientY,time:Xt,pointerType:N.pointerType},L)Q([]),I(null),et(null);else{const Tt=F.current?.pick(N.clientX-it.left,N.clientY-it.top,it.width||1,it.height||1);et(Tt?.visibilityId??null),I(Tt?{...Tt,part:h?.(Tt.part)??Tt.part}:null)}},onPointerCancel:N=>{ge.current.delete(N.pointerId),se.current=!0,be.current=null,de.current=null},onTouchStart:N=>N.stopPropagation(),onWheel:N=>N.stopPropagation()}),p.kind==="loading"&&ie.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sm text-muted-foreground",children:f("rightSidebar.model3dLoading")}),p.kind==="error"&&ie.jsx("div",{className:"absolute inset-0 overflow-auto",children:ie.jsx("div",{className:"mx-3 mt-3 rounded-xl border border-border/15 bg-surface-2 px-4 py-6 text-center text-sm text-muted-foreground",children:p.message})})]}),p.kind==="ready"&&Ve&&ie.jsx(Px,{parts:U,hidden:Le,selected:lt,wide:at,canUndo:Oe.history.length>0,onSelect:Ae,onToggle:St,onIsolate:ct,onShowAll:cn,onUndo:()=>je({type:"undo"}),onClose:J},s)]});return E?zu.createPortal(ps,document.body):ps}export{P0 as classifyModelWheelGesture,B0 as createSectionMaterialStabilizer,nv as default,Ia as formatModelDimension,R0 as formatModelDimensions,U0 as modelControlSensitivity,La as resolveModel3dLoaderKind,C0 as resolvePickedPartName,Wc as scaleModelTrackpadPanDelta,F0 as stabilizePcbSilkscreenMaterials,O0 as stabilizePcbSubstrateMaterials};
4112
+ `),`features:${Te.map(yt=>yt.id).join("+")}`,{snapshot:F.current?.capture(Tt)}),Q([])},ds=we.useRef(f);ds.current=f;const Gs=Bu(),fs=D??Gs,Bn=()=>{const N=fs==="dark"?"light":"dark";P(N);try{window.localStorage.setItem(Xc,N)}catch{}};we.useEffect(()=>{const N=()=>{S(document.fullscreenElement===v.current)};return document.addEventListener("fullscreenchange",N),()=>document.removeEventListener("fullscreenchange",N)},[]),we.useEffect(()=>{const N=La(e);if(!N){b({kind:"error",message:ds.current("rightSidebar.model3dLoadFailed")});return}let Ce=!1,it=null;return b({kind:"loading"}),(async()=>{const tt=await fetch(s);if(!tt.ok)throw new Error(`Failed to fetch model blob (${tt.status})`);const Xt=await tt.arrayBuffer(),Tt=await H0(Xt,N),yt=m.current;if(Ce||!yt)return;const Ut=G0(yt,Tt,o,l);it=Ut.dispose,F.current=Ut,Ut.setActive(d),$.current&&Ut.setAppearance($.current),Ut.setClip(Me.current),Ut.setExplosion(Be.current),Ut.setHiddenParts(y.current),Ce||b({kind:"ready",dims:Ut.dims,partCount:Ut.partCount,parts:Ut.parts})})().catch(tt=>{Ce||b({kind:"error",message:tt instanceof Error?tt.message:ds.current("rightSidebar.model3dLoadFailed")})}),()=>{Ce=!0,it?.(),F.current=null}},[s,e,E,o,l]),we.useEffect(()=>{be.current=null,rt(!1),k(!1),je({type:"reset"}),I(null),et(null)},[s,e]),we.useEffect(()=>{F.current?.setActive(d)},[d]),we.useEffect(()=>{D&&F.current?.setAppearance(D)},[D]),we.useEffect(()=>{F.current?.setClip(j?{axis:q,value01:ee,flip:le}:null)},[j,q,ee,le]);const Ai=!Ve&&qt?x?"bottom-[calc(4rem+env(safe-area-inset-bottom,0px))]":"bottom-16":!Ve&&(Le.length>0||Oe.history.length>0)?x?"bottom-[calc(3.5rem+env(safe-area-inset-bottom,0px))]":"bottom-14":x?"bottom-[calc(0.75rem+env(safe-area-inset-bottom,0px))]":"bottom-3",ps=ie.jsxs("div",{ref:v,"data-sidebar-gesture-ignore":!0,onPointerDown:N=>N.stopPropagation(),onTouchStart:N=>N.stopPropagation(),onKeyDownCapture:N=>{if(N.key==="Escape"&&!(N.target instanceof Element&&N.target.closest('[data-model-viewer-menu="open"]'))){if(Ve)J();else if(qt)et(null),I(null),Q([]);else return;N.preventDefault(),N.stopPropagation()}},className:E?`fixed inset-0 z-modal-panel flex overflow-hidden bg-surface ${at?"flex-row":"flex-col"}`:`relative flex h-full min-h-0 flex-1 overflow-hidden bg-surface ${at?"flex-row":"flex-col"}`,children:[ie.jsxs("div",{className:"relative min-h-0 min-w-0 flex-1",children:[p.kind==="ready"&&!Ve&&!G&&ie.jsxs("div",{className:`pointer-events-none absolute right-3 z-10 select-none text-xs leading-relaxed text-muted-foreground max-sm:rounded-lg max-sm:bg-surface/75 max-sm:px-2.5 max-sm:py-1.5 max-sm:text-[15px] ${x?"left-[calc(0.75rem+env(safe-area-inset-left,0px))] top-[calc(3.75rem+env(safe-area-inset-top,0px))]":"left-3 top-14"}`,children:[ie.jsx("div",{className:"text-sm font-semibold text-foreground max-sm:text-base",children:t}),ie.jsx("div",{children:f("rightSidebar.model3dDimensions",{dims:p.dims})}),Ye&&!Ve&&ie.jsx("div",{children:f("rightSidebar.model3dExplodedNotice")}),L&&re&&ie.jsx("div",{className:"text-foreground/70",children:f("rightSidebar.model3dFeatureStatus",{total:re.total,positioned:re.positioned})}),!Ve&&!qt&&ie.jsx("div",{children:f("rightSidebar.model3dInspectHint")})]}),p.kind!=="error"&&ie.jsxs("div",{className:`absolute left-3 z-20 flex justify-end gap-0.5 [&>button]:h-9 [&>button]:w-9 [&>button]:shrink-0 ${x?"right-[calc(0.75rem+env(safe-area-inset-right,0px))] top-[calc(0.625rem+env(safe-area-inset-top,0px))]":"right-3 top-2.5"}`,children:[p.kind==="ready"&&p.partCount>1&&ie.jsx("button",{ref:vt,type:"button",title:f("rightSidebar.model3dParts"),"aria-label":f("rightSidebar.model3dParts"),"aria-expanded":Ve,style:{width:"auto"},className:`inline-flex h-7 w-7 items-center justify-center rounded-full transition active:scale-95 ${Ve?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,onClick:()=>{nt(N=>!N),B(!1),Q([])},children:ie.jsxs("span",{className:"inline-flex items-center gap-1 px-2",children:[ie.jsx(dl,{size:16}),f("rightSidebar.model3dParts"),Le.length>0&&ie.jsx("span",{className:"text-xs tabular-nums text-accent",children:Le.length})]})}),p.kind==="ready"&&p.partCount>1&&ie.jsx("button",{type:"button",title:f("rightSidebar.model3dExplode"),"aria-label":f("rightSidebar.model3dExplode"),"aria-pressed":Ye,className:`inline-flex items-center justify-center rounded-full ${Ye?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground"}`,onClick:()=>{rt(N=>!N),k(!1)},children:ie.jsx(Yu,{size:16})}),i&&i.length>0&&ie.jsx("button",{type:"button",title:f("rightSidebar.model3dFeatureToggle"),"aria-label":f("rightSidebar.model3dFeatureToggle"),"aria-pressed":L,className:`inline-flex h-7 w-7 items-center justify-center rounded-full transition active:scale-95 ${L?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,onClick:()=>{B(N=>{const Ce=!N;return Ce&&(et(null),I(null)),Ce})},children:ie.jsx(ah,{size:14})}),ie.jsx("button",{type:"button",title:f("rightSidebar.model3dClipToggle"),"aria-label":f("rightSidebar.model3dClipToggle"),"aria-pressed":j,className:`inline-flex h-7 w-7 items-center justify-center rounded-full transition active:scale-95 ${j?"bg-surface-elevated text-foreground":"bg-surface-2 text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,onClick:()=>{k(N=>!N),rt(!1)},children:ie.jsx(sh,{size:14})}),ie.jsx("button",{type:"button",title:f(x?"rightSidebar.model3dFullscreenExit":"rightSidebar.model3dFullscreenEnter"),"aria-label":f(x?"rightSidebar.model3dFullscreenExit":"rightSidebar.model3dFullscreenEnter"),className:"inline-flex h-7 w-7 items-center justify-center rounded-full bg-surface-2 text-muted-foreground transition hover:bg-surface-elevated hover:text-foreground active:scale-95",onClick:A,children:x?ie.jsx(qu,{size:14}):ie.jsx(Ku,{size:14})}),ie.jsx("button",{type:"button",title:f("rightSidebar.model3dHome"),"aria-label":f("rightSidebar.model3dHome"),className:"inline-flex items-center justify-center rounded-full bg-surface-2 text-muted-foreground hover:bg-surface-elevated",onClick:()=>F.current?.setView("home"),children:ie.jsx(Zu,{size:16})}),ie.jsx(Ix,{onView:N=>F.current?.setView(N),dark:fs==="dark",onToggleBackground:Bn,onRefresh:a})]}),p.kind==="ready"&&Ye&&p.partCount>1&&ie.jsxs("div",{className:`swiper-no-swiping absolute left-3 right-3 z-20 flex flex-wrap items-center justify-center gap-2 rounded-lg bg-surface-2 px-2 py-1 ${Ai}`,onPointerDown:N=>N.stopPropagation(),onTouchStart:N=>N.stopPropagation(),children:[ie.jsx("select",{"aria-label":f("rightSidebar.model3dExplodeAxis"),value:he,onChange:N=>ae(N.target.value),className:"h-9 rounded-md bg-surface-elevated px-2 text-sm text-foreground",children:["x","y","z"].map(N=>ie.jsx("option",{value:N,children:N.toUpperCase()},N))}),ie.jsx("input",{type:"range",min:0,max:100,value:Math.round(qe*100),onChange:N=>ne(Number(N.target.value)/100),"aria-label":f("rightSidebar.model3dExplodeAmount"),className:"h-9 min-w-0 flex-1"}),ie.jsxs("output",{className:"w-9 text-right text-xs tabular-nums text-muted-foreground",children:[Math.round(qe*100),"%"]}),ie.jsx("button",{type:"button","aria-label":f("rightSidebar.model3dAssemble"),title:f("rightSidebar.model3dAssemble"),className:"inline-flex h-9 w-9 items-center justify-center rounded-md bg-surface-elevated text-foreground",onClick:()=>rt(!1),children:ie.jsx($u,{size:16})})]}),p.kind==="ready"&&j&&ie.jsxs("div",{className:`swiper-no-swiping absolute left-3 right-3 z-20 flex items-center justify-center gap-2 rounded-xl bg-surface-2 px-3 py-2 ${Ai}`,onPointerDown:N=>N.stopPropagation(),onTouchStart:N=>N.stopPropagation(),children:[["x","y","z"].map(N=>ie.jsx("button",{type:"button","aria-pressed":q===N,className:`h-6 w-6 rounded-md text-xs font-medium transition active:scale-95 ${q===N?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,onClick:()=>W(N),children:N.toUpperCase()},N)),ie.jsx("input",{type:"range",min:0,max:1e3,value:Math.round(ee*1e3),onChange:N=>K(Number(N.target.value)/1e3),className:"h-9 min-w-0 flex-1","aria-label":f("rightSidebar.model3dClipPosition")}),ie.jsx("button",{type:"button",title:f("rightSidebar.model3dClipFlip"),"aria-label":f("rightSidebar.model3dClipFlip"),"aria-pressed":le,className:`inline-flex h-6 w-6 items-center justify-center rounded-md transition active:scale-95 ${le?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,onClick:()=>pe(N=>!N),children:ie.jsx(Qu,{size:13})})]}),p.kind==="ready"&&i&&L&&ie.jsx("div",{ref:ce,className:"pointer-events-none absolute inset-0 z-10 overflow-hidden",children:i.map(N=>ie.jsxs("button",{type:"button","data-feature-id":N.id,title:`${N.part}·${N.name}`,className:`pointer-events-auto absolute left-0 top-0 model3d-feature-label flex items-center gap-1 rounded-full px-1 py-0.5 transition-[opacity] ${z.includes(N.id)?"border border-foreground bg-surface-elevated":"border border-transparent hover:border-border/60"}`,onClick:()=>us(N.id),children:[ie.jsx("span",{className:"block h-2.5 w-2.5 flex-none rounded-full border border-black/50",style:{background:N.part==="底座"?"#E8833A":N.part==="压件"?"#3F9E6D":"#4385BE"}}),z.includes(N.id)&&ie.jsxs("span",{className:"max-w-[140px] truncate text-[11px] leading-4 text-foreground",children:["面","AB"[z.indexOf(N.id)],": ",N.part,"·",N.name]})]},N.id))}),p.kind==="ready"&&i&&L&&ie.jsxs("div",{className:"swiper-no-swiping absolute bottom-28 right-2 top-40 z-20 h-fit max-h-[calc(100%-17rem)] w-44 overflow-auto rounded-xl bg-surface-2/95",onPointerDown:N=>N.stopPropagation(),onTouchStart:N=>N.stopPropagation(),children:[ie.jsxs("button",{type:"button","aria-expanded":me,className:"flex w-full items-center justify-between gap-2 px-2.5 py-1.5 text-xs font-medium text-foreground",onClick:()=>ue(N=>!N),children:[ie.jsxs("span",{className:"truncate",children:[f("rightSidebar.model3dFeatureToggle")," (",i.length,")"]}),ie.jsxs("span",{className:"flex items-center gap-1",children:[ie.jsx("span",{role:"button",tabIndex:0,title:f("rightSidebar.model3dGlossaryToggle"),"aria-label":f("rightSidebar.model3dGlossaryToggle"),className:"inline-flex h-5 w-5 items-center justify-center rounded-full text-muted-foreground hover:bg-surface-elevated hover:text-foreground",onClick:N=>{N.stopPropagation(),oe(Ce=>!Ce)},onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.stopPropagation(),oe(Ce=>!Ce))},children:"?"}),ie.jsx("span",{className:"flex-none text-muted-foreground",children:me?"▾":"▸"})]})]}),me&&ie.jsx("div",{className:"max-h-[calc(100%-2.25rem)] overflow-auto border-t border-border/20 p-1.5",children:Z?ie.jsx(V0,{locale:_,onClose:()=>oe(!1)}):i.map(N=>ie.jsxs("button",{type:"button","aria-pressed":z.includes(N.id),className:`flex w-full items-center gap-1.5 rounded-md px-1.5 py-1 text-left text-xs transition ${z.includes(N.id)?"bg-surface-elevated text-foreground":"text-muted-foreground hover:bg-surface-elevated hover:text-foreground"}`,onClick:()=>us(N.id),children:[ie.jsx("span",{className:"h-2 w-2 flex-none rounded-full",style:{background:N.part==="底座"?"#E8833A":N.part==="压件"?"#3F9E6D":"#4385BE"}}),ie.jsxs("span",{className:"truncate",children:[N.part,"·",N.name]})]},N.id))})]}),p.kind==="ready"&&!L&&Re&&ie.jsx("div",{ref:te,className:"pointer-events-none absolute left-0 top-0 z-10 h-3 w-3 rounded-full border-2 border-accent bg-surface"}),p.kind==="ready"&&!Ve&&qt&&ie.jsxs("div",{className:`swiper-no-swiping absolute left-3 right-3 z-20 flex items-center rounded-lg border border-border/30 bg-surface pl-3 pr-1 shadow ${x?"bottom-[calc(0.75rem+env(safe-area-inset-bottom,0px))]":"bottom-3"}`,onPointerDown:N=>N.stopPropagation(),onTouchStart:N=>N.stopPropagation(),children:[ie.jsx("div",{className:"min-w-0 flex-1 truncate text-xs font-medium text-foreground",title:G?.name,children:G?.name??(Re?Hs(Re):Te.map(N=>N.name).join(" · "))}),G&&U.length>1&&ie.jsxs(ie.Fragment,{children:[ie.jsx("button",{type:"button",className:"inline-flex h-11 w-11 shrink-0 items-center justify-center rounded-lg text-foreground hover:bg-surface-2",title:f(Le.includes(G.id)?"rightSidebar.model3dShowPart":"rightSidebar.model3dHidePart"),"aria-label":f(Le.includes(G.id)?"rightSidebar.model3dShowPart":"rightSidebar.model3dHidePart"),onClick:()=>{St(G.id),et(null),I(null),Q([])},children:Le.includes(G.id)?ie.jsx(qc,{size:18}):ie.jsx(Yc,{size:18})}),ie.jsx("button",{type:"button",onClick:()=>ct(G.id),disabled:!Le.includes(G.id)&&Le.length===U.length-1,title:f("rightSidebar.model3dIsolatePart"),"aria-label":f("rightSidebar.model3dIsolatePart"),className:"inline-flex h-11 w-11 shrink-0 items-center justify-center rounded-lg text-foreground hover:bg-surface-2 disabled:opacity-40",children:ie.jsx(Kc,{size:18})})]}),r&&(Re||Te.length>0)&&ie.jsx("button",{type:"button",className:"inline-flex h-11 w-11 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-surface-2",title:f("rightSidebar.model3dFeatureInsert"),"aria-label":f("rightSidebar.model3dFeatureInsert"),onClick:Te.length>0?hs:Wr,children:ie.jsx(nh,{size:18})}),Oe.history.length>0&&ie.jsx("button",{type:"button",onClick:()=>je({type:"undo"}),"aria-label":f("rightSidebar.model3dUndoVisibility"),title:f("rightSidebar.model3dUndoVisibility"),className:"inline-flex h-11 w-11 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-surface-2",children:ie.jsx(Na,{size:16})}),ie.jsx("button",{type:"button","aria-label":f("rightSidebar.model3dClearSelection"),onClick:()=>{et(null),I(null),Q([])},className:"inline-flex h-11 w-11 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-surface-2",children:ie.jsx(Da,{size:16})})]}),p.kind==="ready"&&!Ve&&!qt&&(Le.length>0||Oe.history.length>0)&&ie.jsxs("div",{className:`swiper-no-swiping absolute left-3 right-3 z-20 flex items-center justify-between gap-2 rounded-xl bg-surface px-2 ${x?"bottom-[calc(0.75rem+env(safe-area-inset-bottom,0px))]":"bottom-3"}`,onPointerDown:N=>N.stopPropagation(),onTouchStart:N=>N.stopPropagation(),children:[ie.jsxs("button",{type:"button",className:"inline-flex h-9 items-center gap-1 px-1 text-xs text-foreground",onClick:()=>nt(!0),children:[ie.jsx(dl,{size:15}),Le.length?f("rightSidebar.model3dHiddenParts",{count:Le.length}):f("rightSidebar.model3dAllPartsVisible")]}),ie.jsxs("button",{type:"button",disabled:!Oe.history.length,className:"inline-flex h-9 items-center gap-1 px-1 text-xs text-foreground disabled:opacity-40",onClick:()=>je({type:"undo"}),children:[ie.jsx(Na,{size:14}),f("rightSidebar.model3dUndoVisibility")]})]}),ie.jsx("div",{ref:m,className:"swiper-no-swiping absolute inset-0",style:{touchAction:"none"},tabIndex:0,"aria-label":f("rightSidebar.model3dCanvas"),onPointerMove:N=>{const Ce=de.current;Ce&&Math.hypot(N.clientX-Ce.x,N.clientY-Ce.y)>8&&(de.current=null)},onPointerDown:N=>{N.stopPropagation(),N.currentTarget.focus({preventScroll:!0}),ge.current.size===0&&(se.current=!1),ge.current.add(N.pointerId),ge.current.size>1&&(se.current=!0,be.current=null),de.current=se.current?null:{x:N.clientX,y:N.clientY}},onPointerUp:N=>{const Ce=de.current;if(de.current=null,ge.current.delete(N.pointerId),!Ce||se.current){be.current=null;return}if(Math.hypot(N.clientX-Ce.x,N.clientY-Ce.y)>8||N.button!==0)return;const it=N.currentTarget.getBoundingClientRect(),tt=be.current,Xt=performance.now();if(tt&&Xt-tt.time<320&&tt.pointerType===N.pointerType&&Math.hypot(N.clientX-tt.x,N.clientY-tt.y)<24){be.current=null,F.current?.zoomAt(N.clientX-it.left,N.clientY-it.top,it.width||1,it.height||1),I(null),Q([]),et(null);return}if(be.current={x:N.clientX,y:N.clientY,time:Xt,pointerType:N.pointerType},L)Q([]),I(null),et(null);else{const Tt=F.current?.pick(N.clientX-it.left,N.clientY-it.top,it.width||1,it.height||1);et(Tt?.visibilityId??null),I(Tt?{...Tt,part:h?.(Tt.part)??Tt.part}:null)}},onPointerCancel:N=>{ge.current.delete(N.pointerId),se.current=!0,be.current=null,de.current=null},onTouchStart:N=>N.stopPropagation(),onWheel:N=>N.stopPropagation()}),p.kind==="loading"&&ie.jsx(zu,{label:f("rightSidebar.model3dLoading"),className:"absolute inset-0"}),p.kind==="error"&&ie.jsx("div",{className:"absolute inset-0 overflow-auto",children:ie.jsx("div",{className:"mx-3 mt-3 rounded-xl border border-border/15 bg-surface-2 px-4 py-6 text-center text-sm text-muted-foreground",children:p.message})})]}),p.kind==="ready"&&Ve&&ie.jsx(Lx,{parts:U,hidden:Le,selected:lt,wide:at,canUndo:Oe.history.length>0,onSelect:Ae,onToggle:St,onIsolate:ct,onShowAll:cn,onUndo:()=>je({type:"undo"}),onClose:J},s)]});return E?Vu.createPortal(ps,document.body):ps}export{L0 as classifyModelWheelGesture,k0 as createSectionMaterialStabilizer,iv as default,Ia as formatModelDimension,C0 as formatModelDimensions,F0 as modelControlSensitivity,La as resolveModel3dLoaderKind,P0 as resolvePickedPartName,Wc as scaleModelTrackpadPanDelta,O0 as stabilizePcbSilkscreenMaterials,B0 as stabilizePcbSubstrateMaterials};