@splinetool/runtime 2.0.4 → 2.0.5

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 (273) hide show
  1. package/build/{runtime-chunk-CIBY4YG3.js → runtime-chunk-243VQV5T.js} +1 -1
  2. package/build/{runtime-chunk-CIBY4YG3.js.br → runtime-chunk-243VQV5T.js.br} +0 -0
  3. package/build/runtime-chunk-243VQV5T.js.gz +0 -0
  4. package/build/{runtime-chunk-ESZD4IRS.js → runtime-chunk-2657LZHS.js} +1 -1
  5. package/build/runtime-chunk-2657LZHS.js.br +0 -0
  6. package/build/runtime-chunk-2657LZHS.js.gz +0 -0
  7. package/build/{runtime-chunk-SL64ZYCB.js → runtime-chunk-6WHNEYAL.js} +1 -1
  8. package/build/runtime-chunk-6WHNEYAL.js.br +0 -0
  9. package/build/runtime-chunk-6WHNEYAL.js.gz +0 -0
  10. package/build/{runtime-chunk-RF63UVAU.js → runtime-chunk-CDZQF4NV.js} +1 -1
  11. package/build/runtime-chunk-CDZQF4NV.js.br +0 -0
  12. package/build/runtime-chunk-CDZQF4NV.js.gz +0 -0
  13. package/build/{runtime-chunk-3J5YHSQW.js → runtime-chunk-DNWPGXEC.js} +1 -1
  14. package/build/runtime-chunk-DNWPGXEC.js.br +0 -0
  15. package/build/runtime-chunk-DNWPGXEC.js.gz +0 -0
  16. package/build/{runtime-chunk-LT4UVXE2.js → runtime-chunk-DSGSWXCQ.js} +1 -1
  17. package/build/runtime-chunk-DSGSWXCQ.js.br +0 -0
  18. package/build/runtime-chunk-DSGSWXCQ.js.gz +0 -0
  19. package/build/{runtime-chunk-I5QFGBIU.js → runtime-chunk-DZOSSY2K.js} +1 -1
  20. package/build/runtime-chunk-DZOSSY2K.js.br +0 -0
  21. package/build/runtime-chunk-DZOSSY2K.js.gz +0 -0
  22. package/build/{runtime-chunk-TPKGBIJU.js → runtime-chunk-EGI7ABC6.js} +1 -1
  23. package/build/runtime-chunk-EGI7ABC6.js.br +0 -0
  24. package/build/runtime-chunk-EGI7ABC6.js.gz +0 -0
  25. package/build/{runtime-chunk-WMWQXAOH.js → runtime-chunk-F7OUYIT6.js} +1 -1
  26. package/build/runtime-chunk-F7OUYIT6.js.br +0 -0
  27. package/build/runtime-chunk-F7OUYIT6.js.gz +0 -0
  28. package/build/{runtime-chunk-DSJY3WL2.js → runtime-chunk-IGBRWWDI.js} +1 -1
  29. package/build/runtime-chunk-IGBRWWDI.js.br +0 -0
  30. package/build/runtime-chunk-IGBRWWDI.js.gz +0 -0
  31. package/build/{runtime-chunk-NTW4X3NC.js → runtime-chunk-IK4H7UNI.js} +1 -1
  32. package/build/runtime-chunk-IK4H7UNI.js.br +0 -0
  33. package/build/runtime-chunk-IK4H7UNI.js.gz +0 -0
  34. package/build/{runtime-chunk-ZMXEX5NX.js → runtime-chunk-J4FFQBNR.js} +1 -1
  35. package/build/runtime-chunk-J4FFQBNR.js.br +0 -0
  36. package/build/runtime-chunk-J4FFQBNR.js.gz +0 -0
  37. package/build/{runtime-chunk-YFAATRJU.js → runtime-chunk-LALFWESO.js} +1 -1
  38. package/build/runtime-chunk-LALFWESO.js.br +0 -0
  39. package/build/runtime-chunk-LALFWESO.js.gz +0 -0
  40. package/build/{runtime-chunk-W4ZCHGLQ.js → runtime-chunk-NIDXMSZY.js} +1 -1
  41. package/build/runtime-chunk-NIDXMSZY.js.br +0 -0
  42. package/build/runtime-chunk-NIDXMSZY.js.gz +0 -0
  43. package/build/runtime-chunk-OTAMLWBD.js +1 -0
  44. package/build/runtime-chunk-OTAMLWBD.js.br +0 -0
  45. package/build/runtime-chunk-OTAMLWBD.js.gz +0 -0
  46. package/build/{runtime-chunk-GPACKOH2.js → runtime-chunk-P2QJHRIH.js} +1 -1
  47. package/build/runtime-chunk-P2QJHRIH.js.br +0 -0
  48. package/build/runtime-chunk-P2QJHRIH.js.gz +0 -0
  49. package/build/{runtime-chunk-OOC7YSI5.js → runtime-chunk-PLJ25O2X.js} +1 -1
  50. package/build/runtime-chunk-PLJ25O2X.js.br +0 -0
  51. package/build/runtime-chunk-PLJ25O2X.js.gz +0 -0
  52. package/build/runtime-chunk-PRQYD4EW.js +1 -0
  53. package/build/runtime-chunk-PRQYD4EW.js.br +0 -0
  54. package/build/runtime-chunk-PRQYD4EW.js.gz +0 -0
  55. package/build/{runtime-chunk-R7NC6CZZ.js → runtime-chunk-QPB2TL3G.js} +1 -1
  56. package/build/runtime-chunk-QPB2TL3G.js.br +0 -0
  57. package/build/runtime-chunk-QPB2TL3G.js.gz +0 -0
  58. package/build/{runtime-chunk-36FZTFCC.js → runtime-chunk-RSPDUS6G.js} +1 -1
  59. package/build/runtime-chunk-RSPDUS6G.js.br +0 -0
  60. package/build/runtime-chunk-RSPDUS6G.js.gz +0 -0
  61. package/build/{runtime-chunk-JNSHQPHC.js → runtime-chunk-RWL6KR5S.js} +1 -1
  62. package/build/runtime-chunk-RWL6KR5S.js.br +0 -0
  63. package/build/runtime-chunk-RWL6KR5S.js.gz +0 -0
  64. package/build/{runtime-chunk-V5NUL7BL.js → runtime-chunk-SXDO5LXF.js} +1 -1
  65. package/build/runtime-chunk-SXDO5LXF.js.br +0 -0
  66. package/build/runtime-chunk-SXDO5LXF.js.gz +0 -0
  67. package/build/{runtime-chunk-ZJPGZKPX.js → runtime-chunk-U6S2BBR7.js} +1 -1
  68. package/build/runtime-chunk-U6S2BBR7.js.br +0 -0
  69. package/build/runtime-chunk-U6S2BBR7.js.gz +0 -0
  70. package/build/{runtime-chunk-V7XDOE2W.js → runtime-chunk-V3U2TPGQ.js} +1 -1
  71. package/build/runtime-chunk-V3U2TPGQ.js.br +0 -0
  72. package/build/runtime-chunk-V3U2TPGQ.js.gz +0 -0
  73. package/build/{runtime-chunk-4I22JDL6.js → runtime-chunk-Y365A3K5.js} +1 -1
  74. package/build/runtime-chunk-Y365A3K5.js.br +0 -0
  75. package/build/runtime-chunk-Y365A3K5.js.gz +0 -0
  76. package/build/{runtime-chunk-WHKBOV2O.js → runtime-chunk-YWT6AWL4.js} +1 -1
  77. package/build/runtime-chunk-YWT6AWL4.js.br +0 -0
  78. package/build/runtime-chunk-YWT6AWL4.js.gz +0 -0
  79. package/build/{runtime-classicRuntime-UOZ6RID5.js → runtime-classicRuntime-BD2WFYXF.js} +1 -1
  80. package/build/runtime-classicRuntime-BD2WFYXF.js.br +0 -0
  81. package/build/runtime-classicRuntime-BD2WFYXF.js.gz +0 -0
  82. package/build/{runtime-cloners-DALMNZYL.js → runtime-cloners-ST66KGZH.js} +1 -1
  83. package/build/runtime-cloners-ST66KGZH.js.br +1 -0
  84. package/build/runtime-cloners-ST66KGZH.js.gz +0 -0
  85. package/build/{runtime-components-IGNRKI6T.js → runtime-components-RLXFVT5A.js} +1 -1
  86. package/build/runtime-components-RLXFVT5A.js.br +0 -0
  87. package/build/runtime-components-RLXFVT5A.js.gz +0 -0
  88. package/build/{runtime-createDestroy-JLB7IIQL.js → runtime-createDestroy-4PG4ZWLI.js} +1 -1
  89. package/build/runtime-createDestroy-4PG4ZWLI.js.br +0 -0
  90. package/build/runtime-createDestroy-4PG4ZWLI.js.gz +0 -0
  91. package/build/{runtime-dragDrop-ERDSNA3S.js → runtime-dragDrop-CTXPZ6OW.js} +1 -1
  92. package/build/runtime-dragDrop-CTXPZ6OW.js.br +0 -0
  93. package/build/runtime-dragDrop-CTXPZ6OW.js.gz +0 -0
  94. package/build/{runtime-gameControls-XKOQVZZC.js → runtime-gameControls-LUALVLF5.js} +1 -1
  95. package/build/runtime-gameControls-LUALVLF5.js.br +0 -0
  96. package/build/runtime-gameControls-LUALVLF5.js.gz +0 -0
  97. package/build/{runtime-hair-EOZHA2BH.js → runtime-hair-JNRT3G3X.js} +1 -1
  98. package/build/runtime-hair-JNRT3G3X.js.br +1 -0
  99. package/build/runtime-hair-JNRT3G3X.js.gz +0 -0
  100. package/build/{runtime-mergeStaticGeometries-4Y3LE3VX.js → runtime-mergeStaticGeometries-QDKIDV27.js} +1 -1
  101. package/build/runtime-mergeStaticGeometries-QDKIDV27.js.br +0 -0
  102. package/build/runtime-mergeStaticGeometries-QDKIDV27.js.gz +0 -0
  103. package/build/{runtime-miscActions-KIRLTM7C.js → runtime-miscActions-FCQTXDEH.js} +1 -1
  104. package/build/runtime-miscActions-FCQTXDEH.js.br +0 -0
  105. package/build/runtime-miscActions-FCQTXDEH.js.gz +0 -0
  106. package/build/{runtime-mouseHover-WULIJFG2.js → runtime-mouseHover-GP5TEPLG.js} +1 -1
  107. package/build/runtime-mouseHover-GP5TEPLG.js.br +0 -0
  108. package/build/runtime-mouseHover-GP5TEPLG.js.gz +0 -0
  109. package/build/{runtime-particles-NNV35DLD.js → runtime-particles-VMYZZSAL.js} +1 -1
  110. package/build/runtime-particles-VMYZZSAL.js.br +0 -0
  111. package/build/runtime-particles-VMYZZSAL.js.gz +0 -0
  112. package/build/{runtime-paths-RRXZ3PXM.js → runtime-paths-TGU7JOOY.js} +1 -1
  113. package/build/runtime-paths-TGU7JOOY.js.br +0 -0
  114. package/build/runtime-paths-TGU7JOOY.js.gz +0 -0
  115. package/build/{runtime-resize-V6LZSOZB.js → runtime-resize-O3Y2XS2Q.js} +1 -1
  116. package/build/runtime-resize-O3Y2XS2Q.js.br +0 -0
  117. package/build/runtime-resize-O3Y2XS2Q.js.gz +0 -0
  118. package/build/{runtime-sceneTransition-CP5TI3VP.js → runtime-sceneTransition-4DDTFDJN.js} +1 -1
  119. package/build/runtime-sceneTransition-4DDTFDJN.js.br +0 -0
  120. package/build/runtime-sceneTransition-4DDTFDJN.js.gz +0 -0
  121. package/build/{runtime-scroll-Q7VGS5NM.js → runtime-scroll-ET44H7JC.js} +1 -1
  122. package/build/runtime-scroll-ET44H7JC.js.br +0 -0
  123. package/build/runtime-scroll-ET44H7JC.js.gz +0 -0
  124. package/build/runtime-shapeBlends-3FCSH6PN.js +1 -0
  125. package/build/runtime-shapeBlends-3FCSH6PN.js.br +2 -0
  126. package/build/runtime-shapeBlends-3FCSH6PN.js.gz +0 -0
  127. package/build/{runtime-text-N6XLUSM2.js → runtime-text-UQIUL5X6.js} +1 -1
  128. package/build/runtime-text-UQIUL5X6.js.br +0 -0
  129. package/build/runtime-text-UQIUL5X6.js.gz +0 -0
  130. package/build/{runtime-textInputs-IW2E6BNU.js → runtime-textInputs-E72WPYQU.js} +1 -1
  131. package/build/runtime-textInputs-E72WPYQU.js.br +0 -0
  132. package/build/runtime-textInputs-E72WPYQU.js.gz +0 -0
  133. package/build/{runtime-timeline-JA2JZIS7.js → runtime-timeline-2VAMFUOE.js} +1 -1
  134. package/build/runtime-timeline-2VAMFUOE.js.br +0 -0
  135. package/build/runtime-timeline-2VAMFUOE.js.gz +0 -0
  136. package/build/{runtime-tracking-M57J2PGK.js → runtime-tracking-E72XXGER.js} +1 -1
  137. package/build/runtime-tracking-E72XXGER.js.br +0 -0
  138. package/build/runtime-tracking-E72XXGER.js.gz +0 -0
  139. package/build/{runtime-transitions-PELRDE7B.js → runtime-transitions-JOHZRI2L.js} +1 -1
  140. package/build/runtime-transitions-JOHZRI2L.js.br +0 -0
  141. package/build/runtime-transitions-JOHZRI2L.js.gz +0 -0
  142. package/build/{runtime-ui2d-IOB5Y76W.js → runtime-ui2d-PJKKRE32.js} +1 -1
  143. package/build/runtime-ui2d-PJKKRE32.js.br +0 -0
  144. package/build/runtime-ui2d-PJKKRE32.js.gz +0 -0
  145. package/build/{runtime-vectorShapes-ISY7MWHY.js → runtime-vectorShapes-FKC6EQWI.js} +1 -1
  146. package/build/runtime-vectorShapes-FKC6EQWI.js.br +0 -0
  147. package/build/runtime-vectorShapes-FKC6EQWI.js.gz +0 -0
  148. package/build/runtime-webgpu-TBHSGHNI.js +1 -0
  149. package/build/runtime-webgpu-TBHSGHNI.js.br +0 -0
  150. package/build/runtime-webgpu-TBHSGHNI.js.gz +0 -0
  151. package/build/runtime.cjs +288 -288
  152. package/build/runtime.js +1 -1
  153. package/build/runtime.js.br +0 -0
  154. package/build/runtime.js.gz +0 -0
  155. package/build/runtime.standalone.js +1 -1
  156. package/build/runtime.standalone.js.br +0 -0
  157. package/build/runtime.standalone.js.gz +0 -0
  158. package/build/runtime.standalone.webgl.js +1 -1
  159. package/build/runtime.standalone.webgl.js.br +0 -0
  160. package/build/runtime.standalone.webgl.js.gz +0 -0
  161. package/build/runtime.standalone.webgpu.js +1 -1
  162. package/build/runtime.standalone.webgpu.js.br +0 -0
  163. package/build/runtime.standalone.webgpu.js.gz +0 -0
  164. package/build/runtime.standalone.webgpu.micro.js +1 -1
  165. package/build/runtime.standalone.webgpu.micro.js.br +0 -0
  166. package/build/runtime.standalone.webgpu.micro.js.gz +0 -0
  167. package/build/runtime.standalone.webgpu.min.js +1 -1
  168. package/build/runtime.standalone.webgpu.min.js.br +0 -0
  169. package/build/runtime.standalone.webgpu.min.js.gz +0 -0
  170. package/package.json +1 -1
  171. package/build/runtime-chunk-36FZTFCC.js.br +0 -0
  172. package/build/runtime-chunk-36FZTFCC.js.gz +0 -0
  173. package/build/runtime-chunk-3J5YHSQW.js.br +0 -0
  174. package/build/runtime-chunk-3J5YHSQW.js.gz +0 -0
  175. package/build/runtime-chunk-4I22JDL6.js.br +0 -0
  176. package/build/runtime-chunk-4I22JDL6.js.gz +0 -0
  177. package/build/runtime-chunk-6UUF5VIS.js +0 -1
  178. package/build/runtime-chunk-6UUF5VIS.js.br +0 -0
  179. package/build/runtime-chunk-6UUF5VIS.js.gz +0 -0
  180. package/build/runtime-chunk-CIBY4YG3.js.gz +0 -0
  181. package/build/runtime-chunk-DKGQ6OYZ.js +0 -1
  182. package/build/runtime-chunk-DKGQ6OYZ.js.br +0 -0
  183. package/build/runtime-chunk-DKGQ6OYZ.js.gz +0 -0
  184. package/build/runtime-chunk-DSJY3WL2.js.br +0 -0
  185. package/build/runtime-chunk-DSJY3WL2.js.gz +0 -0
  186. package/build/runtime-chunk-ESZD4IRS.js.br +0 -0
  187. package/build/runtime-chunk-ESZD4IRS.js.gz +0 -0
  188. package/build/runtime-chunk-GPACKOH2.js.br +0 -0
  189. package/build/runtime-chunk-GPACKOH2.js.gz +0 -0
  190. package/build/runtime-chunk-I5QFGBIU.js.br +0 -0
  191. package/build/runtime-chunk-I5QFGBIU.js.gz +0 -0
  192. package/build/runtime-chunk-JNSHQPHC.js.br +0 -0
  193. package/build/runtime-chunk-JNSHQPHC.js.gz +0 -0
  194. package/build/runtime-chunk-LT4UVXE2.js.br +0 -0
  195. package/build/runtime-chunk-LT4UVXE2.js.gz +0 -0
  196. package/build/runtime-chunk-NTW4X3NC.js.br +0 -0
  197. package/build/runtime-chunk-NTW4X3NC.js.gz +0 -0
  198. package/build/runtime-chunk-OOC7YSI5.js.br +0 -0
  199. package/build/runtime-chunk-OOC7YSI5.js.gz +0 -0
  200. package/build/runtime-chunk-R7NC6CZZ.js.br +0 -0
  201. package/build/runtime-chunk-R7NC6CZZ.js.gz +0 -0
  202. package/build/runtime-chunk-RF63UVAU.js.br +0 -0
  203. package/build/runtime-chunk-RF63UVAU.js.gz +0 -0
  204. package/build/runtime-chunk-SL64ZYCB.js.br +0 -0
  205. package/build/runtime-chunk-SL64ZYCB.js.gz +0 -0
  206. package/build/runtime-chunk-TPKGBIJU.js.br +0 -0
  207. package/build/runtime-chunk-TPKGBIJU.js.gz +0 -0
  208. package/build/runtime-chunk-V5NUL7BL.js.br +0 -1
  209. package/build/runtime-chunk-V5NUL7BL.js.gz +0 -0
  210. package/build/runtime-chunk-V7XDOE2W.js.br +0 -0
  211. package/build/runtime-chunk-V7XDOE2W.js.gz +0 -0
  212. package/build/runtime-chunk-W4ZCHGLQ.js.br +0 -0
  213. package/build/runtime-chunk-W4ZCHGLQ.js.gz +0 -0
  214. package/build/runtime-chunk-WHKBOV2O.js.br +0 -0
  215. package/build/runtime-chunk-WHKBOV2O.js.gz +0 -0
  216. package/build/runtime-chunk-WMWQXAOH.js.br +0 -0
  217. package/build/runtime-chunk-WMWQXAOH.js.gz +0 -0
  218. package/build/runtime-chunk-YFAATRJU.js.br +0 -0
  219. package/build/runtime-chunk-YFAATRJU.js.gz +0 -0
  220. package/build/runtime-chunk-ZJPGZKPX.js.br +0 -0
  221. package/build/runtime-chunk-ZJPGZKPX.js.gz +0 -0
  222. package/build/runtime-chunk-ZMXEX5NX.js.br +0 -0
  223. package/build/runtime-chunk-ZMXEX5NX.js.gz +0 -0
  224. package/build/runtime-classicRuntime-UOZ6RID5.js.br +0 -0
  225. package/build/runtime-classicRuntime-UOZ6RID5.js.gz +0 -0
  226. package/build/runtime-cloners-DALMNZYL.js.br +0 -0
  227. package/build/runtime-cloners-DALMNZYL.js.gz +0 -0
  228. package/build/runtime-components-IGNRKI6T.js.br +0 -0
  229. package/build/runtime-components-IGNRKI6T.js.gz +0 -0
  230. package/build/runtime-createDestroy-JLB7IIQL.js.br +0 -0
  231. package/build/runtime-createDestroy-JLB7IIQL.js.gz +0 -0
  232. package/build/runtime-dragDrop-ERDSNA3S.js.br +0 -0
  233. package/build/runtime-dragDrop-ERDSNA3S.js.gz +0 -0
  234. package/build/runtime-gameControls-XKOQVZZC.js.br +0 -0
  235. package/build/runtime-gameControls-XKOQVZZC.js.gz +0 -0
  236. package/build/runtime-hair-EOZHA2BH.js.br +0 -0
  237. package/build/runtime-hair-EOZHA2BH.js.gz +0 -0
  238. package/build/runtime-mergeStaticGeometries-4Y3LE3VX.js.br +0 -0
  239. package/build/runtime-mergeStaticGeometries-4Y3LE3VX.js.gz +0 -0
  240. package/build/runtime-miscActions-KIRLTM7C.js.br +0 -0
  241. package/build/runtime-miscActions-KIRLTM7C.js.gz +0 -0
  242. package/build/runtime-mouseHover-WULIJFG2.js.br +0 -0
  243. package/build/runtime-mouseHover-WULIJFG2.js.gz +0 -0
  244. package/build/runtime-particles-NNV35DLD.js.br +0 -0
  245. package/build/runtime-particles-NNV35DLD.js.gz +0 -0
  246. package/build/runtime-paths-RRXZ3PXM.js.br +0 -0
  247. package/build/runtime-paths-RRXZ3PXM.js.gz +0 -0
  248. package/build/runtime-resize-V6LZSOZB.js.br +0 -0
  249. package/build/runtime-resize-V6LZSOZB.js.gz +0 -0
  250. package/build/runtime-sceneTransition-CP5TI3VP.js.br +0 -0
  251. package/build/runtime-sceneTransition-CP5TI3VP.js.gz +0 -0
  252. package/build/runtime-scroll-Q7VGS5NM.js.br +0 -0
  253. package/build/runtime-scroll-Q7VGS5NM.js.gz +0 -0
  254. package/build/runtime-shapeBlends-UN7GGFRG.js +0 -1
  255. package/build/runtime-shapeBlends-UN7GGFRG.js.br +0 -0
  256. package/build/runtime-shapeBlends-UN7GGFRG.js.gz +0 -0
  257. package/build/runtime-text-N6XLUSM2.js.br +0 -0
  258. package/build/runtime-text-N6XLUSM2.js.gz +0 -0
  259. package/build/runtime-textInputs-IW2E6BNU.js.br +0 -0
  260. package/build/runtime-textInputs-IW2E6BNU.js.gz +0 -0
  261. package/build/runtime-timeline-JA2JZIS7.js.br +0 -0
  262. package/build/runtime-timeline-JA2JZIS7.js.gz +0 -0
  263. package/build/runtime-tracking-M57J2PGK.js.br +0 -0
  264. package/build/runtime-tracking-M57J2PGK.js.gz +0 -0
  265. package/build/runtime-transitions-PELRDE7B.js.br +0 -0
  266. package/build/runtime-transitions-PELRDE7B.js.gz +0 -0
  267. package/build/runtime-ui2d-IOB5Y76W.js.br +0 -0
  268. package/build/runtime-ui2d-IOB5Y76W.js.gz +0 -0
  269. package/build/runtime-vectorShapes-ISY7MWHY.js.br +0 -0
  270. package/build/runtime-vectorShapes-ISY7MWHY.js.gz +0 -0
  271. package/build/runtime-webgpu-4ZCV5EAD.js +0 -1
  272. package/build/runtime-webgpu-4ZCV5EAD.js.br +0 -0
  273. package/build/runtime-webgpu-4ZCV5EAD.js.gz +0 -0
@@ -1 +1 @@
1
- import{b as t}from"./runtime-chunk-N2ZRGNPR.js";import{a as e,c as i}from"./runtime-chunk-VAVYZ35B.js";import{b as s,c as o,d as a,e as n}from"./runtime-chunk-FQNSP44B.js";import{a as r}from"./runtime-chunk-V5NUL7BL.js";import{G as h,a as l}from"./runtime-chunk-YFAATRJU.js";import{f as d,g as c}from"./runtime-chunk-QVC5UDJO.js";import{h as p}from"./runtime-chunk-OOC7YSI5.js";import{a as m,g as u,h as y,i as v}from"./runtime-chunk-2PT2WH66.js";import{a as g}from"./runtime-chunk-4KZXQGUQ.js";import{c as f}from"./runtime-chunk-TZCHGFVF.js";import{Fa as b}from"./runtime-chunk-OW6T4XFV.js";import{Bc as E,Dc as P,Ec as C,Fc as M,Oc as x,Oe as T,Pc as S,Rc as D,Xc as w,b as R,bd as j,cd as L,dd as G}from"./runtime-chunk-VGN7YHB7.js";var B=200,A=null;function W(t){A=t}function O(){return A}function I(t){let e=!1;return t.scene.objects.forEach(i=>{"Page"===i.data.type&&!e&&i.data.publish.gameControlObject&&b.traverseModuleInstances(t,i.id,(t,i,s)=>{for(let t of s)"GameControl"===t.data.type&&t.data.navmesh.enabled&&(e=!0)})}),e}function F(t){return s?t.metaKey:t.ctrlKey}function k(t,e){return Math.abs(t+3*e)<=2||Math.abs(t+3*window.devicePixelRatio*e)<=2}var V={type:"change"},z={type:"start"},H={type:"end",nonOrbit:!0},Z={type:"end",nonOrbit:!1},U={type:"end",isZoom:!0,nonOrbit:!0},Y={type:"end",changed:!1},X={type:"cameraAnimatingInTimeline"},N=new C,K=new P,_=2*Math.PI,q=new M,Q=new P,J=new M,$=new C,tt=new x,et={type:"requestRender"},it=class extends E{constructor(t,i,s={isPlayMode:!1,isExport:!1},a){super(),this.object=t,this.domElement=i,this.options=s,this.timelineState=a,this.enabled=!0,this.useKeyEvents=!0,this.enableDamping=!1,this.enableZoom=!0,this.enableRotate=!0,this.enablePan=!0,this.autoRotate=!1,this.rotationLimitsMode=0,this.panLimitsMode=0,this.rotationSoftLimit=2,this.panSoftLimit=2,this.hoverRotatePanMode=0,this.zoomLimitsEnabled=!1,this.mouseButtons=[0,5],this.mouseButtonsPlay=[3,4,5],this.touches=[null,R.DOLLY_ROTATE,R.PAN],this.offset=new M,this.eye=new M,this.lastPosition=new M,this.lastQuaternion=new C,this.current=new P,this.overShoot=new P,this.overRatio=new P,this.spherical=new T,this.sphericalDelta=new T,this.panOffset=new M,this.panLeftV=new M,this.panUpV=new M,this.panV=new M,this.rotateStart=new P,this.rotateEnd=new P,this.rotateDelta=new P,this.panStart=new P,this.panEnd=new P,this.panDelta=new P,this.dollyStart=new P,this.dollyEnd=new P,this.dollyDelta=new P,this.rotationRangeFactor=new P,this.panRangeFactor=new P,this.state=-1,this.zoomChanged=!1,this.isPointerDown=!1,this.isThetaFlipped=!1,this.prevScale=0,this.scale=1,this.gesture=!1,this.lastTrackpadPanTime=-1/0,this.lastMouseWheelZoomTime=-1/0,this.timer=-1,this.timerHover=-1,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPhi=0,this.maxPhi=Math.PI,this.minTheta=-1/0,this.maxTheta=1/0,this.minH=0,this.maxH=Math.PI,this.minV=-1/0,this.maxV=1/0,this.autoRotateClockwise=!0,this.isPanOverShoot=!1,this.isRotateOverShoot=!1,this.resetHoverEffectOnPointerLeave=!1,this.hasChange=!1,this.useWindowEvents=!1,this.isTouchZoom=!0,this.autoRotateSpeed=2,this.dampingFactor=.125,this.zoomSpeed=2,this.rotateSpeed=1,this.rotateFactor=1,this.panSpeed=1,this.hoverRotatePanStrength=.1,this.hoverRotateDamping=this.dampingFactor,this.isCurrentlyDamping=!1,this.thetaIsFree=!1,this.phiIsFree=!1,this.needsUpdate=!0,this.onCameraChange=t=>{this.object.removeEventListener("beginState",this.onBeginState),this.object.removeEventListener("completeState",this.onCompleteState),this.object.removeEventListener("cameraChange",this.onCameraChange),this.object=t.camera,this.object.addEventListener("beginState",this.onBeginState),this.object.addEventListener("completeState",this.onCompleteState),this.object.addEventListener("cameraChange",this.onCameraChange)},this.update=()=>{this.object.updateWorldMatrix(!0,!1),this.object.matrixWorld.decompose(J,$,q),this.offset.copy(J).sub(this.target),this.spherical.setFromVector3(this.offset),this.object.isUpVectorFlipped&&(this.spherical.phi*=-1,this.spherical.theta-=Math.PI),this.autoRotate&&-1===this.state&&this.rotateLeft((!0===this.autoRotateClockwise?1:-1)*this.getAutoRotationAngle()),0!==this.rotationLimitsMode&&this.applyLimits(this.sphericalDelta,this.rotationLimitsMode,this.rotationSoftLimit,this.maxTheta,this.minTheta,this.maxPhi,this.minPhi,this.rotationRangeFactor),2!==this.rotationLimitsMode&&(this.spherical.phi+=this.sphericalDelta.phi),(1!==this.rotationLimitsMode||!0===this.autoRotate)&&(this.spherical.theta+=this.sphericalDelta.theta),this.spherical.radius*=this.scale,this.zoomLimitsEnabled&&this.object.isPerspectiveCamera&&(this.spherical.radius=Math.max(this.minDistance,Math.min(this.maxDistance,this.spherical.radius))),0!==this.panLimitsMode&&(this.target.applyQuaternion(N.copy($).invert()),this.panOffset.applyQuaternion(N),this.applyLimits(this.panOffset,this.panLimitsMode,this.panSoftLimit,this.maxH,this.minH,this.maxV,this.minV,this.panRangeFactor),this.target.applyQuaternion($),this.panOffset.applyQuaternion($)),2===this.panLimitsMode&&(this.panOffset.y=0),1===this.panLimitsMode&&(this.panOffset.x=0),-1!==this.state||this.gesture?(this.target.add(this.panOffset),this.panOffset.set(0,0,0)):(this.panOffset.multiplyScalar(1-this.dampingFactor),this.target.add(this.panOffset)),this.offset.setFromSpherical(this.spherical),J.copy(this.target).add(this.offset),this.object.position.copy(this.target).add(this.offset),this.object.parent&&(tt.copy(this.object.parent.matrixWorld).invert(),this.object.position.applyMatrix4(tt));let t=this.spherical.phi%_;if(this.eye.copy(this.offset).normalize(),this.object.up.copy(D.DEFAULT_UP).applyAxisAngle(this.eye,this.object.angleOffsetFromUp),t>0&&t>Math.PI||t<0&&t>-Math.PI?(this.object.up.negate(),this.object.lookAt(this.target),this.object.isUpVectorFlipped=!0):(this.object.lookAt(this.target),this.object.isUpVectorFlipped=!1),-1===this.state||!0===this.enableDamping){let t=1===this.hoverRotatePanMode?this.hoverRotateDamping:this.dampingFactor;this.sphericalDelta.theta*=1-t,this.sphericalDelta.phi*=1-t}else this.sphericalDelta.set(0,0,0);if(this.scale=1,this.lastPosition.distanceToSquared(this.object.position)>.01||8*(1-this.lastQuaternion.dot(this.object.quaternion))>1e-8)return this.dispatchEvent(V),this.object.dispatchEvent(et),this.lastPosition.copy(this.object.position),this.lastQuaternion.copy(this.object.quaternion),void(this.isCurrentlyDamping=!0);this.isPanOverShoot=!1,this.isRotateOverShoot=!1,this.object.wasMovedBySwitchCameraAction=!1,this.sphericalDelta.set(0,0,0),this.panOffset.set(0,0,0),this.isCurrentlyDamping=!1},this.onPointerDown=t=>{!1!==this.enabled&&("touch"===t.pointerType||"pen"===t.pointerType&&n?this.onPointerDownTouch(t):this.onPointerDownMouse(t),-1!==this.state&&(this.isPointerDown=!0,this.dispatchEvent(z),this.domElement.addEventListener("pointermove",this.onPointerMove),this.domElement.addEventListener("pointerup",this.onPointerUp),t.stopPropagation(),"touch"===t.pointerType||"pen"===t.pointerType&&n||this.domElement.setPointerCapture(t.pointerId)))},this.onPointerLeave=t=>{this.resetHoverEffectOnPointerLeave&&!this.useWindowEvents?(1===this.hoverRotatePanMode?(this.sphericalDelta.theta=-this.spherical.theta,this.sphericalDelta.phi=-this.spherical.phi,q.subVectors(this.position0,this.target0),this.spherical.setFromVector3(q),this.sphericalDelta.theta+=this.spherical.theta,this.sphericalDelta.phi+=this.spherical.phi,this.sphericalDelta.theta/=8,this.sphericalDelta.phi/=8):2===this.hoverRotatePanMode&&this.panOffset.subVectors(this.target0,this.target).divideScalar(8),this.update()):this.pointerLeaveEvent=t},this.onPointerEnter=t=>{this.resetHoverEffectOnPointerLeave||void 0===this.pointerLeaveEvent?Q.set(t.clientX-this.domElement.clientWidth/2,t.clientY-this.domElement.clientHeight/2):Q.set(t.clientX-this.pointerLeaveEvent.clientX,t.clientY-this.pointerLeaveEvent.clientY),1===this.hoverRotatePanMode?(this.rotateDelta.copy(Q).multiplyScalar(this.rotateSpeed*this.hoverRotatePanStrength).rotateAround(K,-this.object.angleOffsetFromUp),this.rotateLeft(2*Math.PI*this.rotateDelta.x/this.domElement.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/this.domElement.clientHeight),this.rotateStart.set(t.clientX,t.clientY)):2===this.hoverRotatePanMode&&(this.panDelta.copy(Q).multiplyScalar(this.panSpeed*this.hoverRotatePanStrength),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.set(t.clientX,t.clientY)),this.update()},this.onPointerMove=t=>{this.timelineState?.isPlayingCameraAnimation?this.dispatchEvent(X):!1!==this.enabled&&(this.checkRaycastLock()||("touch"===t.pointerType||"pen"===t.pointerType&&n?this.onPointerMoveTouch(t):this.onPointerMoveMouse(t),t.stopPropagation()))},this.onPointerUp=t=>{this.isPointerDown=!1,0===e.length&&(this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp)),e.length>1&&t.preventDefault(),this.hasChange?this.dispatchEvent(0===this.state?Z:H):this.dispatchEvent(Y),this.state=-1,t&&(t.stopPropagation(),"touch"===t.pointerType||"pen"===t.pointerType&&n||this.domElement.releasePointerCapture(t.pointerId))},this.onPointerDownMouse=t=>{let e;switch(e=this.useKeyEvents?this.mouseButtons[t.button]:this.mouseButtonsPlay[t.button],e){case 0:if(!0!==t.altKey||t.shiftKey||F(t)){if(" "===this.key){if(!1===this.enablePan)return;this.handleMouseDownPan(t),this.state=2}}else{if(!1===this.enableRotate)return;this.handleMouseDownRotate(t),this.state=0}break;case 4:if(!1===this.enablePan)return;this.handleMouseDownPan(t),this.state=2;break;case 3:if(F(t)||t.shiftKey){if(!1===this.enablePan)return;this.handleMouseDownPan(t),this.state=2}else{if(!1===this.enableRotate)return;this.handleMouseDownRotate(t),this.state=0}break;case 5:if(F(t)||t.shiftKey){if(!1===this.enableRotate)return;this.handleMouseDownRotate(t),this.state=0}else{if(!1===this.enablePan)return;this.handleMouseDownPan(t),this.state=2}break;default:this.state=-1}},this.onPointerMoveMouse=t=>{switch(this.state){case 0:if(!1===this.enableRotate)return;this.handleMouseMoveRotate(t);break;case 1:if(!1===this.enableZoom)return;this.handleMouseMoveDolly(t);break;case 2:if(!1===this.enablePan)return;this.handleMouseMovePan(t)}this.object.wasMovedByUser=!0},this.onPointerDownTouch=t=>{switch(e.length>1&&t.preventDefault(),this.touches[e.length-1]){case R.ROTATE:if(!1===this.enableRotate)return void(this.state=-1);this.handleTouchStartRotate(),this.state=3;break;case R.PAN:if(!1===this.enablePan)return void(this.state=-1);this.handleTouchStartPan(),this.state=4;break;case R.DOLLY_PAN:if(!1===this.enableZoom&&!1===this.enablePan)return;this.handleTouchStartDollyPan(),this.state=5;break;case R.DOLLY_ROTATE:if(!1===this.enableZoom&&!1===this.enableRotate)return;this.handleTouchStartDollyRotate(),this.state=6;break;default:this.state=-1}},this.onPointerMoveTouch=t=>{switch(e.length>1&&t.preventDefault(),this.state){case 3:if(!1===this.enableRotate)return;this.handleTouchMoveRotate(t),this.update();break;case 4:if(!1===this.enablePan)return;this.handleTouchMovePan(t),this.update();break;case 5:if(!1===this.enableZoom&&!1===this.enablePan)return;this.handleTouchMoveDollyPan(t),this.update();break;case 6:if(!1===this.enableZoom&&!1===this.enableRotate)return;this.handleTouchMoveDollyRotate(t),this.update();break;default:this.state=-1}this.object.wasMovedByUser=!0},this.dispatchEndDebounced=g(()=>{this.zoomChanged?this.dispatchEvent(U):this.dispatchEvent(H),this.zoomChanged=!1},33),this.onMouseWheel=t=>{if(!1!==this.enabled&&(!1!==this.enableZoom||!1!==this.enablePan)&&!this.checkRaycastLock()){if(!this.options.isExport&&this.domElement.clientHeight===document.body.clientHeight&&this.domElement.clientWidth===document.body.clientWidth&&t.preventDefault(),this.dispatchEvent(z),this.timelineState?.isPlayingCameraAnimation)return void this.dispatchEvent(X);this.handleMouseWheel(t),this.dispatchEndDebounced(),this.object.wasMovedByUser=!0}},this.onGesture=t=>{if(t.preventDefault(),!1!==this.enabled&&!this.checkRaycastLock()&&!o){if(this.timelineState?.isPlayingCameraAnimation)return void this.dispatchEvent(X);if("gesturechange"===t.type){if(!1===this.enableZoom||!1===this.isTouchZoom)return;this.dispatchEvent(z),t.scale>this.prevScale?this.dollyIn(this.getZoomScale()):t.scale<this.prevScale&&this.dollyOut(this.getZoomScale()),this.prevScale=t.scale,this.update(),this.object.wasMovedByUser=!0}else this.dispatchEvent(H)}},this.onContextMenu=t=>{t.preventDefault()},this.onTouchEnd=t=>{t.preventDefault()},this.onKeyDown=t=>{!1!==this.enabled&&(this.key=t.key," "===t.key&&this.dispatchEvent(z))},this.onKeyUp=t=>{this.key=void 0,!1!==this.enabled&&(-1!==this.state&&"Alt"===t.key&&this.onPointerUp(e[0])," "===t.key&&this.dispatchEvent(H))},this.onPointerHover=t=>{"mouse"!==t.pointerType||!1===this.enabled||-1!==this.state||2===this.hoverRotatePanMode&&this.isPanOverShoot||1===this.hoverRotatePanMode&&this.isRotateOverShoot||(this.isPointerDown=!0,2===this.hoverRotatePanMode?this.handleMouseMovePan(t,this.hoverRotatePanStrength):1===this.hoverRotatePanMode&&this.handleMouseMoveRotate(t,this.hoverRotatePanStrength))},this.onBeginState=()=>{this.enabled=!1,this.needsUpdate=!1},this.onCompleteState=t=>{t.isfromEntity&&this.options.isPlayMode||(this.enabled=!0,this.needsUpdate=!0,this.object.updateUp(),this.object.getTarget(this.target))},this.target=this.object.getTarget(),this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.quat0=this.object.quaternion.clone(),this.isUpVectorFlipped0=this.object.isUpVectorFlipped,this.object.updateWorldMatrix(!0,!1),this.object.matrixWorld.decompose(J,$,q),this.offset.copy(J).sub(this.target),this.spherical.setFromVector3(this.offset),this.object.isUpVectorFlipped&&(this.spherical.phi*=-1,this.spherical.theta-=Math.PI),this.initialSphericalRadius=this.spherical.radius,this.addEventListenersToCamera()}dispatchEvent(t){"start"===t.type?this.hasChange=!1:this.hasChange=!0,super.dispatchEvent(t)}addEventListenersToCamera(){this.object.addEventListener("beginState",this.onBeginState),this.object.addEventListener("completeState",this.onCompleteState),this.object.addEventListener("cameraChange",this.onCameraChange)}removeEventListenersFromCamera(){this.object.removeEventListener("beginState",this.onBeginState),this.object.removeEventListener("completeState",this.onCompleteState),this.object.removeEventListener("cameraChange",this.onCameraChange)}updateUseWindowEvents(t){if(window.removeEventListener("pointermove",this.onPointerHover),this.domElement.removeEventListener("pointermove",this.onPointerHover),this.useWindowEvents=t,0!==this.hoverRotatePanMode&&(this.useWindowEvents?window.addEventListener("pointermove",this.onPointerHover):this.domElement.addEventListener("pointermove",this.onPointerHover)),this.domElement.removeEventListener("pointerleave",this.onPointerLeave),this.domElement.removeEventListener("pointerenter",this.onPointerEnter),window.removeEventListener("pointerleave",this.onPointerLeave),window.removeEventListener("pointerenter",this.onPointerEnter),0!==this.hoverRotatePanMode&&!this.useWindowEvents){let t=this.useWindowEvents?window:this.domElement;t.addEventListener("pointerleave",this.onPointerLeave),t.addEventListener("pointerenter",this.onPointerEnter)}}fromJSON(t,e){this.rotateFactor=t.rotationSpeed??1,this.setEnableDampingSpeed(t.enableDamping),this.enablePan=t.enablePan,this.enableZoom=t.enableZoom,this.enableRotate=t.enableRotate,this.rotationLimitsMode=t.rotationLimitsMode,this.thetaIsFree=t.rotationHorizontalOffset.min===t.rotationHorizontalOffset.max&&t.rotationHorizontalOffset.min===Math.PI,this.phiIsFree=t.rotationVerticalOffset.min===t.rotationVerticalOffset.max&&t.rotationVerticalOffset.min===Math.PI,this.panLimitsMode=t.panLimitsMode,this.panSoftLimit=t.panSoftLimit,this.rotationSoftLimit=t.rotationSoftLimit,this.hoverRotatePanMode=t.hoverRotatePanMode,this.hoverRotateDamping=t.hoverRotateDamping??this.dampingFactor,this.useWindowEvents="window"===e,0!==this.hoverRotatePanMode&&(this.useWindowEvents?window.addEventListener("pointermove",this.onPointerHover):this.domElement.addEventListener("pointermove",this.onPointerHover));let i=t.hoverRotatePanStrength/100;this.hoverRotatePanStrength=i**2,this.zoomLimitsEnabled=t.zoomLimitsEnabled,this.minZoom=t.zoomLimits.min,this.maxZoom=Math.max(t.zoomLimits.min,t.zoomLimits.max),this.minDistance=1e3/this.maxZoom,this.maxDistance=Math.max(this.minDistance,1e3/t.zoomLimits.min),this.autoRotate=t.autoRotate,this.autoRotateSpeed=t.autoRotateSpeed,this.autoRotateClockwise=t.autoRotateClockwise;let s=this.object.getTarget().applyQuaternion(N.copy(this.object.quaternion).invert());this.minV=-t.panVerticalOffset.min+s.y,this.maxV=t.panVerticalOffset.max+s.y,this.minH=-t.panHorizontalOffset.min+s.x,this.maxH=t.panHorizontalOffset.max+s.x,this.panRangeFactor.set(this.maxH-this.minH,this.maxV-this.minV).divideScalar(2),this.rotationRangeFactor.setScalar(Math.PI).divideScalar(4),this.minPhi=st(this.spherical.phi-t.rotationVerticalOffset.min),this.maxPhi=st(this.spherical.phi+t.rotationVerticalOffset.max),this.minTheta=st(st(this.spherical.theta)-t.rotationHorizontalOffset.min),this.maxTheta=st(st(this.spherical.theta)+t.rotationHorizontalOffset.max),this.isThetaFlipped=this.minTheta>this.maxTheta,1===t.orbitTouches&&(this.touches[0]=R.ROTATE),1===t.panTouches&&(this.touches[0]=R.PAN),2===t.orbitTouches&&(this.touches[1]=R.DOLLY_ROTATE),2===t.panTouches&&(this.touches[1]=R.DOLLY_PAN),3===t.orbitTouches&&(this.touches[2]=R.ROTATE),3===t.panTouches&&(this.touches[2]=R.PAN),this.isTouchZoom=t.isTouchZoom,this.resetHoverEffectOnPointerLeave=t.resetHoverEffectOnPointerLeave??!1}connect(){if(this.domElement.addEventListener("contextmenu",this.onContextMenu),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("wheel",this.onMouseWheel),window.addEventListener("keydown",this.onKeyDown,!1),window.addEventListener("keyup",this.onKeyUp,!1),this.domElement.addEventListener("gesturestart",this.onGesture),this.domElement.addEventListener("gesturechange",this.onGesture),this.domElement.addEventListener("gestureend",this.onGesture),this.domElement.addEventListener("touchend",this.onTouchEnd),0!==this.hoverRotatePanMode&&!this.useWindowEvents){let t=this.useWindowEvents?window:this.domElement;t.addEventListener("pointerleave",this.onPointerLeave),t.addEventListener("pointerenter",this.onPointerEnter)}this.pointerLeaveEvent=void 0}dispose(){this.removeEventListenersFromCamera(),this.domElement.removeEventListener("contextmenu",this.onContextMenu),this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("wheel",this.onMouseWheel),window.removeEventListener("keydown",this.onKeyDown,!1),window.removeEventListener("keyup",this.onKeyUp,!1),this.domElement.removeEventListener("pointermove",this.onPointerHover),window.removeEventListener("pointermove",this.onPointerHover),this.domElement.removeEventListener("gesturestart",this.onGesture),this.domElement.removeEventListener("gesturechange",this.onGesture),this.domElement.removeEventListener("gestureend",this.onGesture),this.domElement.removeEventListener("touchend",this.onTouchEnd),this.domElement.removeEventListener("pointerleave",this.onPointerLeave),this.domElement.removeEventListener("pointerenter",this.onPointerEnter),window.removeEventListener("pointerleave",this.onPointerLeave),window.removeEventListener("pointerenter",this.onPointerEnter),this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp)}applyLimits(t,e,i,s,o,a,n,r){let h,l,d;this.overShoot.set(0,0),t instanceof M?(h=t.x,l=t.y,this.current.set(this.target.x,this.target.y),d=!0):(h=t.theta,l=t.phi,this.current.set(st(this.spherical.theta),st(this.spherical.phi)),d=!1),0===i&&(this.current.x+=h,this.current.y+=l),(3===e||2===e)&&(!d&&this.isThetaFlipped?this.current.x>s&&this.current.x<0?this.overShoot.x=s-this.current.x:this.current.x<o&&this.current.x>0&&(this.overShoot.x=o-this.current.x):this.current.x>s?this.overShoot.x=s-this.current.x:this.current.x<o&&(this.overShoot.x=o-this.current.x)),(3===e||1===e)&&(this.current.y>a?this.overShoot.y=a-this.current.y:this.current.y<n&&(this.overShoot.y=n-this.current.y)),d||(this.overShoot.x=st(this.overShoot.x),this.overShoot.y=st(this.overShoot.y)),0!==i?(this.overRatio.copy(this.overShoot).divide(r),this.overRatio.x=Math.min(Math.abs(this.overRatio.x),1),this.overRatio.y=Math.min(Math.abs(this.overRatio.y),1),1===i&&(this.overRatio.x=ot(Math.abs(this.overRatio.x)),this.overRatio.y=ot(Math.abs(this.overRatio.y))),this.isPointerDown||1===i?2===i&&(this.overRatio.x>.9&&!this.thetaIsFree||this.overRatio.y>.9&&!this.phiIsFree)?this.isPointerDown=!1:(h*this.overShoot.x<0&&!this.thetaIsFree&&(h*=1-this.overRatio.x),l*this.overShoot.y<0&&!this.phiIsFree&&(l*=1-this.overRatio.y)):2===i&&(!d&&(this.overRatio.x>.002&&!this.thetaIsFree||this.overRatio.y>.002&&!this.phiIsFree)||d&&(Math.abs(this.overShoot.x)>2||Math.abs(this.overShoot.y)>2)?(this.thetaIsFree||(h=.05*this.overShoot.x),this.phiIsFree||(l=.05*this.overShoot.y),d?this.isPanOverShoot=!0:this.isRotateOverShoot=!0):d?this.isPanOverShoot=!1:this.isRotateOverShoot=!1)):(h+=this.overShoot.x,l+=this.overShoot.y),t instanceof M?(t.x=h,t.y=l):(this.thetaIsFree||(t.theta=h),this.phiIsFree||(t.phi=l))}setEnableDampingSpeed(t){this.enableDamping=t,this.rotateSpeed=(!0===t?.2:1)*this.rotateFactor}stopDamping(){this.sphericalDelta.theta=0,this.sphericalDelta.phi=0,this.panOffset.set(0,0,0)}setTarget(t,e,i){this.stopDamping(),this.target.set(t,e,i)}getAutoRotationAngle(){return 2*Math.PI/60/60*this.autoRotateSpeed}getZoomScale(){return Math.pow(.95,this.zoomSpeed)}rotateLeft(t){this.sphericalDelta.theta-=t}rotateUp(t){this.sphericalDelta.phi-=t}panLeft(t,e){this.panLeftV.setFromMatrixColumn(e,0),this.panLeftV.multiplyScalar(-t),this.panOffset.add(this.panLeftV)}panUp(t,e){this.panUpV.setFromMatrixColumn(e,1),this.panUpV.multiplyScalar(t),this.panOffset.add(this.panUpV)}pan(t,e){let i=this.domElement;if(i&&this.object.isPerspectiveCamera){let s=this.object.position;this.panV.copy(s).sub(this.target);let o=this.panV.length();o*=Math.tan(this.object.fov/2*Math.PI/180),this.panLeft(2*t*o/i.clientHeight,this.object.matrixWorld),this.panUp(2*e*o/i.clientHeight,this.object.matrixWorld)}else i&&this.object.isOrthographicCamera&&(this.panLeft(t*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrixWorld),this.panUp(e*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrixWorld));this.dispatchEvent(V)}dollyOut(t){this.object.isPerspectiveCamera?this.scale/=t:this.object.isOrthographicCamera&&(this.object.zoom*=t,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(V)}dollyIn(t){this.object.isPerspectiveCamera?this.scale*=t:this.object.isOrthographicCamera&&(this.object.zoom/=t,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(V)}setZoom(t){if(this.dispatchEvent(z),this.object.isPerspectiveCamera){let e=this.initialSphericalRadius/t/this.spherical.radius;this.scale=e}else this.object.isOrthographicCamera&&(this.object.zoom=t,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0);this.dispatchEvent(H)}handleMouseDownRotate(t){this.rotateStart.set(t.clientX,t.clientY)}handleMouseDownDolly(t){this.dollyStart.set(t.clientX,t.clientY)}handleMouseDownPan(t){this.panStart.set(t.clientX,t.clientY)}handleMouseMoveRotate(t,e=1){void 0!==t.movementX?this.rotateDelta.set(t.movementX,t.movementY):(this.rotateEnd.set(t.clientX,t.clientY),this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart),this.rotateStart.copy(this.rotateEnd)),this.rotateDelta.multiplyScalar(this.rotateSpeed*e).rotateAround(K,-this.object.angleOffsetFromUp);let i=this.domElement,s=this.useWindowEvents?window.innerHeight:i.clientHeight,o=2*Math.PI*this.rotateDelta.x/s,a=2*Math.PI*this.rotateDelta.y/s;this.rotateLeft(o),this.rotateUp(a),this.update()}handleMouseMoveDolly(t){this.dollyEnd.set(t.clientX,t.clientY),this.dollyDelta.subVectors(this.dollyEnd,this.dollyStart),this.dollyDelta.y>0?this.dollyOut(this.getZoomScale()):this.dollyDelta.y<0&&this.dollyIn(this.getZoomScale()),this.dollyStart.copy(this.dollyEnd),this.update()}handleMouseMovePan(t,e=1){void 0!==t.movementX?this.panDelta.set(t.movementX,t.movementY):(this.panEnd.set(t.clientX,t.clientY),this.panDelta.subVectors(this.panEnd,this.panStart),this.panStart.copy(this.panEnd)),this.panDelta.multiplyScalar(this.panSpeed*e),this.pan(this.panDelta.x,this.panDelta.y),this.update()}handleMouseWheel(t){if(0===t.deltaX&&0===t.deltaY)return;let e=!0===t.ctrlKey||!0===F(t),i=!1===F(t)&&!0===(0===(r=t).wheelDeltaY||0===r.deltaY?!(s&&r.shiftKey&&Math.abs(r.wheelDeltaX)>=120)&&(r.wheelDeltaX?k(r.wheelDeltaX,r.deltaX):0===r.deltaMode):r.wheelDeltaY?k(r.wheelDeltaY,r.deltaY):0===r.deltaMode),o=!1===e&&(!0===this.gesture||t.timeStamp-this.lastTrackpadPanTime<300),n=!1===e&&!1===o&&t.timeStamp-this.lastMouseWheelZoomTime<300;var r;if(!1!==a||!1!==n||!0!==i&&!0!==o){if(!1===this.enableZoom)return;this.gesture&&(window.clearTimeout(this.timer),this.gesture=!1,this.isPointerDown=!1,this.dispatchEvent(H)),!1===e&&!1===i&&(this.lastMouseWheelZoomTime=t.timeStamp),0===t.deltaY?t.deltaX<0?this.dollyIn(this.getZoomScale()):t.deltaX>0&&this.dollyOut(this.getZoomScale()):t.deltaY<0?this.dollyIn(this.getZoomScale()):t.deltaY>0&&this.dollyOut(this.getZoomScale()),this.update(),this.gesture=!1,this.isPointerDown=!1}else{if(!1===this.enablePan)return;let e=!1===this.gesture&&!1===o;this.lastTrackpadPanTime=t.timeStamp,this.gesture||(this.gesture=!0,this.isPointerDown=!0),!1===e&&(this.panDelta.set(-t.deltaX,-t.deltaY).multiplyScalar(this.panSpeed),this.panDelta.x=Math.min(Math.abs(this.panDelta.x),100)*(this.panDelta.x<0?-1:1),this.panDelta.y=Math.min(Math.abs(this.panDelta.y),100)*(this.panDelta.y<0?-1:1),t.altKey?this.pan(0,this.panDelta.y):t.shiftKey?this.pan(this.panDelta.x,0):this.pan(this.panDelta.x,this.panDelta.y),this.update()),window.clearTimeout(this.timer),this.timer=window.setTimeout(()=>{this.gesture=!1,this.isPointerDown=!1,this.dispatchEvent(H)},100)}}handleTouchStartRotate(){if(2===e.length){let t=.5*(e[0].pageX+e[1].pageX),i=.5*(e[0].pageY+e[1].pageY);this.rotateStart.set(t,i)}else this.rotateStart.set(e[0].pageX,e[0].pageY)}handleTouchStartPan(){if(2===e.length){let t=.5*(e[0].pageX+e[1].pageX),i=.5*(e[0].pageY+e[1].pageY);this.panStart.set(t,i)}else this.panStart.set(e[0].pageX,e[0].pageY)}handleTouchStartDolly(){let t=e[0].pageX-e[1].pageX,i=e[0].pageY-e[1].pageY,s=Math.sqrt(t*t+i*i);this.dollyStart.set(0,s)}handleTouchStartDollyPan(){this.enableZoom&&!0===this.isTouchZoom&&this.handleTouchStartDolly(),this.enablePan&&this.handleTouchStartPan()}handleTouchStartDollyRotate(){this.enableZoom&&!0===this.isTouchZoom&&this.handleTouchStartDolly(),this.enableRotate&&this.handleTouchStartRotate()}handleTouchMoveRotate(t){if(2===e.length){let e=i(t),s=.5*(t.pageX+e.x),o=.5*(t.pageY+e.y);this.rotateEnd.set(s,o)}else{if(t.pointerId!==e[0].pointerId)return;this.rotateEnd.set(t.pageX,t.pageY)}this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(this.rotateSpeed);let s=this.domElement;s&&(this.rotateLeft(2*Math.PI*this.rotateDelta.x/s.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/s.clientHeight)),this.rotateStart.copy(this.rotateEnd)}handleTouchMovePan(t){if(2===e.length){let e=i(t),s=.5*(t.pageX+e.x),o=.5*(t.pageY+e.y);this.panEnd.set(s,o)}else{if(t.pointerId!==e[0].pointerId)return;this.panEnd.set(t.pageX,t.pageY)}this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(this.panSpeed),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.copy(this.panEnd)}handleTouchMoveDolly(t){let e=i(t),s=t.pageX-e.x,o=t.pageY-e.y,a=Math.sqrt(s*s+o*o);this.dollyEnd.set(0,a),this.dollyDelta.set(0,Math.pow(this.dollyEnd.y/this.dollyStart.y,this.zoomSpeed)),this.dollyOut(this.dollyDelta.y),this.dollyStart.copy(this.dollyEnd)}handleTouchMoveDollyPan(t){this.enableZoom&&!0===this.isTouchZoom&&this.handleTouchMoveDolly(t),this.enablePan&&this.handleTouchMovePan(t)}handleTouchMoveDollyRotate(t){this.enableZoom&&!0===this.isTouchZoom&&this.handleTouchMoveDolly(t),this.enableRotate&&this.handleTouchMoveRotate(t)}checkRaycastLock(){if(this.object.data.raycastLock){if(this.options.isPlayMode)return!1;{let t=this.options?.showCameraLock;return t&&t(),!0}}return!1}};function st(t){let e=2*Math.PI;for(;t<=-Math.PI;)t+=e;for(;t>Math.PI;)t-=e;return t}function ot(t){return 1-Math.pow(1-t,4)}var at,nt,rt=new Promise(t=>{at=t});function ht(t){return nt||(nt=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.4/build",i=import("./physics.js"),[s,o]=await Promise.all([i,fetch(`${e}/physics.wasm`).then(t=>t.arrayBuffer())]);await s.init(o),at(s)}())}function lt(t){let e=t.elements,i=e[0]**2+e[1]**2+e[2]**2,s=e[4]**2+e[5]**2+e[6]**2,o=e[8]**2+e[9]**2+e[10]**2,a=e[0]**2+e[4]**2+e[8]**2,n=e[1]**2+e[5]**2+e[9]**2,r=e[2]**2+e[6]**2+e[10]**2,h=1e-8;return i<h||s<h||o<h||a<h||n<h||r<h}function dt(t,e){let i=new G;if(e&&lt(e))return i.setAttribute("position",new j([],3)),i.setIndex([]),i;if(!t.getAttribute("position"))return i.setAttribute("position",new j([],3)),i.setIndex([]),i;let{positions:s,triIndices:o}=h(t.getAttribute("position"),t.getIndex());return i.setAttribute("position",new j(s,3)),i.setIndex(o),e&&i.applyMatrix4(e),i}var ct,pt=class{constructor(t,e,i,s,o,a){this.id=t,this.data=e,this.object=i,this.initialDisabled=!1,this.actions=d(e,e.actions,s,o,a,i),this.target=e.target}disconnect(){c(this.actions)}dispatch(t){this.initialDisabled||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.actions.Transition.forEach(t=>{"Toggle"===t.data.runMode?t.toggle():t.play()}),this.actions.Animation.forEach(t=>{"Toggle"===t.data.runMode?t.toggle():t.play()}),this.actions.TimelineAnimation.forEach(t=>{"runMode"in t.data&&"Toggle"===t.data.runMode?t.toggle():t.play()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch(t??!1)}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch()))}},mt=class{constructor(t,e,i,s,o,a){this.id=t,this.data=e,this.object=i,this.page=s,this.currentIntersectedObjects=[],this.actions=d(e,e.actions,s,o,a,i),this.target=e.target,this.triggeringObjects=[];for(let t of e.triggeringObjects){let e=s.scene.find(t);e&&this.triggeringObjects.push(e)}}isValidTriggeringObject(t){return"all"===this.target||this.triggeringObjects.some(e=>e===t||e.isAncestorOf(t.uuid)||t.isAncestorOf(e.uuid))}disconnect(){c(this.actions)}dispatch(){this.object.destroyedInAction||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Trigger"}),this.actions.Transition.forEach(t=>{"Toggle"===t.data.runMode?t.toggle():t.play()}),this.actions.SwitchCamera.forEach(t=>{"Toggle"===t.data.runMode?t.toggle():t.play()}),this.actions.TimelineAnimation.forEach(t=>{"runMode"in t.data&&"Toggle"===t.data.runMode?t.toggle():t.play()}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch(!1)}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch()))}};rt.then(t=>ct=t);var ut=new M,yt=new C,vt=new M,gt=(new S(0,0,0,"YXZ"),new S(0,0,0,"XYZ")),ft=new M,bt=new M,Et=new M(1,1,1),Pt=new C,Ct=new x,Mt=new x,xt={type:"updateMatrix"},Tt=new C,St=new L,Dt=.01,wt={type:"beginEvent",eventName:"Collision"},Rt={type:"beginEvent",eventName:"Trigger"};function jt(t){if(b.physicsEnabled(t.scene.objects))return!0;let e=!1;return t.scene.objects.traverse((t,i)=>{if(i.events)if(Array.isArray(i.events)){for(let t of i.events)if(!0!==t.data.disabled&&"GameControl"===t.data.type&&t.data.collisionEnabled){e=!0;break}}else for(let t of Object.values(i.events))if(!0!==t.disabled&&"GameControl"===t.type&&t.collisionEnabled){e=!0;break}}),e}var Lt=t=>t.states.some(t=>void 0!==t.data.position||void 0!==t.data.rotation||void 0!==t.data.hiddenMatrix||void 0!==t.data.cloner||void 0!==t.data.pathSnapping);function Gt(t){return u(v(t)?t.object:t)}var Bt,At,Wt,Ot=class{constructor(t){this.eventContext=t,this.isEnabled=!1,this.gameControl=null,this.joysticks=[],this.joystickToGameControls=[],this.sharedGameControlGlobals={entitiesWithTransformAnim:[],entityToCollisionEvents:{},colliderToEntity:new Map,kinematicBodyToEntity:new Map,triggers:[],gamePads:[],createdObjects:[],nCreatedPerAction:{}},this.sensorToTriggerEvent={},this.eventManager=void 0,this.needsCollisionDetection=!1,this.initializationCounter=-1,this.fixedBodiesToWatch=[],this.rigidBodyToMesh=new Map,this.nActiveRigidBodies=0,this.collisionEvents=[],this.isExport=!1,this.skipRender=!0,this._staticBVHAttrIds=new WeakMap,this._staticBVHNextAttrId=1,this.processRigidBody=t=>{if(t.bodyType()!==ct.RigidBodyType.Dynamic)return;t.isSleeping()||this.nActiveRigidBodies++;let[e,i,s]=this.rigidBodyToMesh.get(t.handle);if(ut.copy(t.translation()).multiplyScalar(this.pixelsPerMeter),yt.copy(t.rotation()),e.matrixWorld.compose(ut,yt,i),e.hasNonUniformScale&&e.matrixWorld.multiply(e.shearScale),e.dispatchEvent(xt),s){let t=e.cloner;if(t&&void 0===t.objectForSample){t.matrixWorld.copy(e.matrixWorld);for(let e of t.children)e.updateMatrixWorld(!0)}for(let t of e.children)t.updateMatrixWorld(!0)}},this.accumulator=0,this.handleCollisionEvents=(t,e,i)=>{if(!1===i)return;let s,o;if(this.sensorToTriggerEvent[t]?(s=this.sensorToTriggerEvent[t],o=this.sharedGameControlGlobals.colliderToEntity.get(e)):this.sensorToTriggerEvent[e]&&(s=this.sensorToTriggerEvent[e],o=this.sharedGameControlGlobals.colliderToEntity.get(t)),s&&o&&s.isValidTriggeringObject(o))s.dispatch();else{for(let i=this.sharedGameControlGlobals.createdObjects.length-1;i>=0;i--){let s=this.sharedGameControlGlobals.createdObjects[i];if(s.userData.hasCollisionDestroy&&(s.rigidBody?.collider(0).handle===t||s.rigidBody?.collider(0).handle===e)){this.sharedGameControlGlobals.createdObjects.splice(i,1),s.removeFromParent(),requestAnimationFrame(()=>this.sharedGameControlGlobals.rapierWorld?.removeRigidBody(s.rigidBody));break}}if(void 0!==this.gameControl?.object&&this.gameControl.object===this.sharedGameControlGlobals.colliderToEntity.get(t)){let t=this.sharedGameControlGlobals.colliderToEntity.get(e),i=this.sharedGameControlGlobals.entityToCollisionEvents[t.uuid];if(void 0===i)return;for(let s of i)"character"===s.data.target&&this.dispatchCollisionEvent(s,t,e)}else if(void 0!==this.gameControl?.object&&this.gameControl.object===this.sharedGameControlGlobals.colliderToEntity.get(e)){let e=this.sharedGameControlGlobals.colliderToEntity.get(t),i=this.sharedGameControlGlobals.entityToCollisionEvents[e.uuid];if(void 0===i)return;for(let s of i)"character"===s.data.target&&this.dispatchCollisionEvent(s,e,t)}else{let i=this.sharedGameControlGlobals.colliderToEntity.get(t),s=this.sharedGameControlGlobals.entityToCollisionEvents[i.uuid];if(void 0!==s)for(let e of s)"scene"===e.data.target&&this.dispatchCollisionEvent(e,i,t);let o=this.sharedGameControlGlobals.colliderToEntity.get(e),a=this.sharedGameControlGlobals.entityToCollisionEvents[o?.uuid];if(void 0!==a)for(let t of a)"scene"===t.data.target&&this.dispatchCollisionEvent(t,o,e)}}},this.isExport=t.isExport,this.sharedAssets=t.sharedAssets,this.renderer=t.renderer,this.requestRender=t.requestRender,this.domElement=this.renderer.domElement,this.pixelsPerMeter=200,this.gravity=this.page.data.globalPhysics.gravity}get page(){return this.eventContext.page}markIsDestroyTarget(){this.page.traverseVisibleEntity(t=>{let e=t.dataPatched;for(let t of e.events){if(!0===t.data.disabled)continue;let e=t.data.actions?.find(t=>"Destroy"===t.data.type)?.data;if(e)for(let t of e.objects){let e=this.page.scene.find(t);e&&(e.userData.hasDestroy=!0)}}})}markIsDragObject(){this.page.traverseVisibleEntity(t=>{let e=t.dataPatched;for(let t of e.events)if(!0!==t.data.disabled&&"DragDrop"===t.data.type)for(let e of t.data.objects){let t=this.page.scene.find(e);t&&(t.userData.hasDrag=!0)}})}_staticBVHIdOf(t){let e=this._staticBVHAttrIds.get(t);return void 0===e&&(e=this._staticBVHNextAttrId++,this._staticBVHAttrIds.set(t,e)),e}initBVH(){if(null===t())return void f("collision-bvh","trigger/collision detection");let e=[],i=[];if(this.page.traverseChildren(t=>{let s,o=t instanceof r,a=m(t);if(y(t)||o||a)return;s=v(t)?t.object:t;let n=s.dataPatched;if("visibility"===n.physics?.enabled?!n.visible:!n.physics?.enabled)return!0;let h=t.geometry,l=!0===s.userData.hasDestroy,d=!0===s.userData.hasDrag;if(Lt(n)||l||d||s.dataPatched.events.some(t=>!0!==t.data.disabled&&("GameControl"===t.data.type||"Follow"===t.data.type)))return t.updateMatrixWorldRigid(),this.addBoundsTree(t),!0;if(h){let s=h.getAttribute("position");if(void 0!==s&&s.count>0){e.push({geometry:h,matrixWorld:t.matrixWorld}),i.push(h.id,this._staticBVHIdOf(s),s.version,null!==h.index?this._staticBVHIdOf(h.index):-1,null!==h.index?h.index.version:-1);for(let e of t.matrixWorld.elements)i.push(e)}}return!!Gt(t)||void 0}),e.length>0){let s=this._staticBVHCache;if(void 0!==s&&s.signature.length===i.length&&s.signature.every((t,e)=>t===i[e]))return void(this.sharedGameControlGlobals.staticMeshBVH=s.bvh);let o=e.map(t=>dt(t.geometry,t.matrixWorld)),a=l(o,!1),n=new(t())(a);this._staticBVHCache={signature:i,bvh:n},this.sharedGameControlGlobals.staticMeshBVH=n}}addRigidBody(t,e,i){if(lt(t.matrixWorld))return;let s=[],o="geometry"in t?t.geometry:void 0,a=e.dataPatched;if(void 0!==o?.getAttribute("position")&&s.push(dt(o,t.shearScale)),a.physics.fusedBody){let e=this.gatherChildrenGeom(t,s);t.traverseObject(e),t.children.forEach(t=>t.updateMatrixWorld(!0));let i=t.cloner;i&&void 0===i.objectForSample&&"dynamic"===a.physics.rigidBody&&(i.traverseObject(e),i.children.forEach(t=>t.updateMatrixWorld(!0)))}if(s.length>0){let n,r=!1,h=!i.fromCreate&&"dynamic"===a.physics.rigidBody||i.fromCreate&&i.dynamic;h?(n=ct.RigidBodyDesc.dynamic(),n.setLinearDamping(a.physics.damping).setAngularDamping(a.physics.damping).setAdditionalMass(1e-9).setGravityScale(a.physics.gravityScale).enabledRotations(...a.physics.enabledRotation).enabledTranslations(...a.physics.enabledTranslation)):(i.hasTransformAnim||i.hasFollow||i.hasDrag)&&!i.fromCreate?(n=ct.RigidBodyDesc.kinematicPositionBased(),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(t),r=!0):n=ct.RigidBodyDesc.fixed();let d=l(s);(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).decompose(ut,yt,vt),t.position0=ut.clone().divideScalar(this.pixelsPerMeter),t.rotation0=yt.clone(),ut.divideScalar(this.pixelsPerMeter),n.setTranslation(ut.x,ut.y,ut.z).setRotation(yt),o?d?.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter):d?.scale(vt.x/this.pixelsPerMeter,vt.y/this.pixelsPerMeter,vt.z/this.pixelsPerMeter);let c=this.sharedGameControlGlobals.rapierWorld.createRigidBody(n);h?this.rigidBodyToMesh.set(c.handle,[t,vt.clone(),a.physics.fusedBody]):r?this.sharedGameControlGlobals.kinematicBodyToEntity.set(c.handle,t):this.fixedBodiesToWatch.push([t,c,(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).clone()]);let p=!(void 0===a.geometry||"SubdivGeometry"===a.geometry.type||"NonParametricGeometry"===a.geometry.type||"BooleanGeometry"===a.geometry.type||"VectorGeometry"===a.geometry.type||"StarGeometry"===a.geometry.type||"RectangleGeometry"===a.geometry.type||"EllipseGeometry"===a.geometry.type||"TriangleGeometry"===a.geometry.type||"TorusGeometry"===a.geometry.type||"HelixGeometry"===a.geometry.type);try{this.addCollider(c,a.physics,d,e,p)}catch{try{this.addCollider(c,a.physics,d,e,!1)}catch(t){console.error(t)}}t.rigidBody=c}}addBoundsTree(e){let i=[];if(void 0!==e.geometry?.getAttribute("position")&&e.geometry?.getAttribute("position").count>0&&i.push(dt(e.geometry,e.shearScale)),e.traverseObject(this.gatherChildrenGeom(e,i)),e.children.forEach(t=>t.updateMatrixWorld(!0)),i.length>0){let s=l(i,!1);e.bvhGeometry=s,s.getAttribute("position").count>0&&(e.bvhGeometry.boundsTree=new(t())(s),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(e))}}addCollider(t,e,i,s,o=!0){if(0===i?.getAttribute("position").count||0===i?.getIndex()?.count)return;let a;i&&(a="trimesh"===e.colliderType?ct.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array):ct.ColliderDesc.convexMesh(i.getAttribute("position").array,o?i.getIndex().array:void 0)),a.setFrictionCombineRule(ct.CoefficientCombineRule.Average).setRestitutionCombineRule(ct.CoefficientCombineRule.Average).setDensity(e.density).setFriction(e.friction).setRestitution(e.restitution);let n=this.sharedGameControlGlobals.rapierWorld.createCollider(a,t);this.sharedGameControlGlobals.colliderToEntity.set(n.handle,s),this.sharedGameControlGlobals.entityToCollisionEvents[s.uuid]?.some(t=>"scene"===t.target)&&n.setActiveEvents(ct.ActiveEvents.COLLISION_EVENTS)}gatherChildrenGeom(t,e){let i=Gt(t);return(s,o)=>{if(0===o)return;if(i&&s.parent===t)return!0;let a;if(y(s)){if(!s.objectForSample)return!0===s.object.dataPatched.physics.fusedBody&&"dynamic"===s.object.dataPatched.physics.rigidBody||void 0;if(s.objectForSample.dataPatched.physics.fusedBody)return;a=s.object}else if(v(s))a=s.object;else if(a=s,a.dataPatched.cloner?.hideBase)return!0;let n=a.dataPatched;if("visibility"===n.physics.enabled?!n.visible:!n.physics.enabled)return!0;1===o?t.hasNonUniformScale?s.matrixWorld.multiplyMatrices(t.shearScale,s.hiddenMatrix):s.matrixWorld.copy(s.hiddenMatrix):s.matrixWorld.multiplyMatrices(s.parent.matrixWorld,s.hiddenMatrix),s.matrixWorld.multiply(s.matrix);let r=s.geometry;return void 0!==r?.getAttribute("position")&&e.push(dt(r,s.matrixWorld)),!!Gt(s)||void 0}}activate(t){if(this.isEnabled)return;this.isEnabled=!0,this.eventManager=t,this.usePhysics=this.page.data.globalPhysics.usePhysics;let e=this.page.playCamera,i=!1;this.page.traverseEntity(t=>{for(let e of t.dataPatched.events)if(!1===e.data.disabled&&"Trigger"===e.data.type)return this.needsCollisionDetection=!0,!0});let s=O();if(null!==s?i=s.setup({manager:this,camera:e,renderer:this.renderer,sharedAssets:this.sharedAssets,eventContext:this.eventContext,isExport:this.isExport})||i:null!==this.page.data.publish.gameControlObject&&f("game-controls","the scene's game controls"),!1===i){let{enableRotate:t,enablePan:i,enableZoom:s,autoRotate:o,hoverRotatePanMode:a}=this.eventManager.publish.orbitControls;(t||i||s||o||0!==a)&&(this.orbitControls=new it(e,this.renderer.domElement,{isExport:this.isExport,isPlayMode:!0}),this.orbitControls.addEventListener("change",this.requestRender),this.orbitControls.addEventListener("end",this.requestRender),this.orbitControls.addEventListener("start",this.requestRender),this.orbitControls.fromJSON(this.eventManager.publish.orbitControls,this.eventManager.publish.mouseEventTarget),this.orbitControls.useKeyEvents=!1,this.orbitControls.addEventListenersToCamera(),this.orbitControls.connect(),this.orbitControls.update())}let o=this.renderer.domElement.width/this.renderer.getPixelRatio(),a=this.renderer.domElement.height/this.renderer.getPixelRatio();O()?.createJoysticks(this,o,a),this.markIsDestroyTarget(),this.markIsDragObject(),this.rebuildBVH(),this.initializationCounter++,window.setTimeout(()=>{this.collisionEvents.forEach(t=>t.initialDisabled=!1)},80)}initPhysics(){this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=new ct.World(new ct.Vector3(0,this.gravity,0)),this.events=new ct.EventQueue(!0);let t=[],e=[];if(this.page.traverseChildren(i=>{let s;if(y(i)){if(!i.objectForSample)return!0===i.object.dataPatched.physics.fusedBody&&"dynamic"===i.object.dataPatched.physics.rigidBody||void 0;if(i.objectForSample.dataPatched.physics.fusedBody)return;s=i.object}else if(v(i))s=i.object;else{if(m(i)||i instanceof r)return;if(s=i,!1===s.dataPatched.cloner?.disabled&&s.dataPatched.cloner?.hideBase&&!0!==s.dataPatched.physics?.fusedBody)return!0}let o,a=s.dataPatched;for(let t of a.events)!0!==t.data.disabled&&"GameControl"===t.data.type&&(o=t.data);if(!a.physics||("visibility"===a.physics.enabled?!a.visible:!a.physics.enabled))return!0;i.updateMatrixWorldRigid();let n=Lt(a),h=!1,l=s.userData.hasDestroy,d=s.userData.hasDrag,c=!1;for(let t of a.events)if(!0!==t.data.disabled)if("Collision"===t.data.type){h=!0;let e=new pt(t.id,t.data,s,this.page,this.sharedAssets,this.eventManager);e.initialDisabled=!0,this.collisionEvents.push(e),this.sharedGameControlGlobals.entityToCollisionEvents[s.uuid]&&this.sharedGameControlGlobals.entityToCollisionEvents[s.uuid].every(e=>e.id!==t.id)?this.sharedGameControlGlobals.entityToCollisionEvents[s.uuid].push(e):this.sharedGameControlGlobals.entityToCollisionEvents[s.uuid]=[e]}else if("Follow"===t.data.type){c=!0;let e=t.data.target;i.traverseVisible(t=>{t.userData.isFollowingObj=e})}"dynamic"===a.physics.rigidBody&&!1===a.physics.fusedBody&&(i.matrixWorldFusedFalse=i.matrixWorld.clone());let p=i.geometry;if(void 0!==o){let t=ct.RigidBodyDesc.kinematicPositionBased();(i.hasNonUniformScale?i.matrixWorldRigid:i.matrixWorld).decompose(ut,yt,vt),i.position0=ut.clone().divideScalar(this.pixelsPerMeter),i.rotation0=yt.clone(),ut.divideScalar(this.pixelsPerMeter),t.setTranslation(ut.x,ut.y,ut.z).setRotation(yt);let e,n=this.sharedGameControlGlobals.rapierWorld.createRigidBody(t);i.rigidBody=n,e="sphere"===o.collider.type?ct.ColliderDesc.ball(o.collider.radius/this.pixelsPerMeter):"capsule"===o.collider.type?ct.ColliderDesc.capsule((o.collider.height/2-o.collider.radius)/this.pixelsPerMeter,o.collider.radius/this.pixelsPerMeter):ct.ColliderDesc.cuboid(o.collider.width/this.pixelsPerMeter/2,o.collider.height/this.pixelsPerMeter/2,o.collider.depth/this.pixelsPerMeter/2),e.setFrictionCombineRule(ct.CoefficientCombineRule.Average).setDensity(a.physics.density).setFriction(a.physics.friction).setRestitution(0).setRestitutionCombineRule(ct.CoefficientCombineRule.Min);let r=this.sharedGameControlGlobals.rapierWorld.createCollider(e,n);this.sharedGameControlGlobals.colliderToEntity.set(r.handle,s),ut.fromArray(o.collider.position.map(t=>"number"==typeof t?t:0)).multiply(vt.setFromMatrixScale(s.matrixWorld)).divideScalar(this.pixelsPerMeter),r.setTranslationWrtParent(ut);let h=(new C).setFromEuler((new S).setFromVector3((new M).fromArray(o.collider.rotation.map(t=>"number"==typeof t?t:0))));r.setRotationWrtParent(h),r.setActiveEvents(ct.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(s,!0)}else"dynamic"===a.physics.rigidBody||n||c||l||d||h?(this.addRigidBody(i,s,{hasFollow:c,hasTransformAnim:n,hasDrag:d}),this.generateSensorColliderDescs(s,a.physics.fusedBody)):(p&&t.push(dt(p,i.matrixWorld)),a.physics.fusedBody&&!Gt(i)&&i.traverseObject((e,i)=>{if(0===i)return;let s;if(y(e)){if(!e.objectForSample)return!0===e.object.dataPatched.physics.fusedBody&&"dynamic"===e.object.dataPatched.physics.rigidBody||void 0;if(e.objectForSample.dataPatched.physics.fusedBody)return;s=e.object}else{if(m(e)||e instanceof r)return;if(v(e))s=e.object;else if(s=e,s.dataPatched.cloner?.hideBase)return!0}let o=s.dataPatched;if("visibility"===o.physics.enabled?!o.visible:!o.physics.enabled)return!0;let a=e.geometry;return void 0!==a?.getAttribute("position")&&t.push(dt(a,e.matrixWorld)),!!Gt(e)||void 0}),this.generateSensorColliderDescs(s,a.physics.fusedBody,e));return!(!0!==a.physics?.fusedBody&&!o&&!Gt(i))||void 0}),0===t.length)return;let i=l(t);i.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let s=ct.RigidBodyDesc.fixed(),o=this.sharedGameControlGlobals.rapierWorld.createRigidBody(s),a=ct.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array).setFrictionCombineRule(ct.CoefficientCombineRule.Multiply).setRestitutionCombineRule(ct.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(a,o);for(let[t,i]of e){let e=this.sharedGameControlGlobals.rapierWorld.createCollider(t,o);this.sensorToTriggerEvent[e.handle]=i}}updatePositions(){return this.nActiveRigidBodies=0,this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody),this.nActiveRigidBodies>0}rebuildBVH(){this.usePhysics?this.initPhysics():(this.page.traverseEntity(t=>{for(let e of t.dataPatched.events)if("Trigger"===e.data.type&&!0!==e.data.disabled){let i=new mt(e.id,e.data,t,this.page,this.sharedAssets,this.eventManager),s=(new x).compose(ft.fromArray(e.data.position.map(t=>"number"==typeof t?t:0)),Pt.setFromEuler(gt.fromArray(e.data.rotation.map(t=>"number"==typeof t?t:0))),Et);if("box"===e.data.triggerZone){let o=new w;o.min.fromArray(e.data.size.map(t=>"number"==typeof t?t:0)).multiplyScalar(-.5),o.max.fromArray(e.data.size.map(t=>"number"==typeof t?t:0)).multiplyScalar(.5),this.sharedGameControlGlobals.triggers.push([o,s,t,i])}else this.sharedGameControlGlobals.triggers.push([e.data.radius,s,t,i])}}),this.needsCollisionDetection&&this.initBVH())}disconnectEvents(){this.collisionEvents.forEach(t=>t.disconnect()),this.sharedGameControlGlobals.triggers.forEach(t=>t[3].disconnect()),this.sharedGameControlGlobals.triggers.length=0}deactivate(){if(this.isEnabled){this.isEnabled=!1,this.page.traverse(t=>{let e=t;e.matrixWorldFusedFalse&&(e.matrixWorldFusedFalse=void 0),e.rigidBody&&(e.rigidBody=void 0),e.position0&&(e.position0=void 0),e.rotation0&&(e.rotation0=void 0)}),this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=void 0,this.sharedGameControlGlobals.staticMeshBVH=void 0,this.accumulator=0,this.sharedGameControlGlobals.entitiesWithTransformAnim=[],this.sharedGameControlGlobals.kinematicBodyToEntity.clear(),this.fixedBodiesToWatch=[],this.disconnectEvents(),this.gameControl?.reset(),this.gameControl?.dispose(),this.gameControl=null,this.initializationCounter=-1,this.joysticks.forEach(([t,e])=>{t?.destroy(),e.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls&&(this.orbitControls.dispose(),this.orbitControls=void 0),this.navigationMeshWrapper?.dispose(),this.navigationMeshWrapper=void 0;for(let t of Object.values(this.sharedGameControlGlobals.entityToCollisionEvents))t.forEach(t=>t.disconnect());this.sharedGameControlGlobals.entityToCollisionEvents={},this.page.updateMatrixWorld(!0)}}update(t){if(!this.isEnabled)return!0;let e=!0;if(void 0!==this.orbitControls&&this.orbitControls.needsUpdate&&(this.orbitControls.update(),e=!this.orbitControls.isCurrentlyDamping),this.initializationCounter>=0&&this.initializationCounter<2?(this.initializationCounter++,e=!1):2===this.initializationCounter&&this.gameControl&&(e=!this.gameControl.update(t)&&e),!1===this.usePhysics&&this.checkTrigger(),this.usePhysics){let i=.016666666666666666;if(0===t)e=this.stepPhysics()&&e;else{let s=t/1e3;s<i&&s>.55*i&&(s=i),this.accumulator+=s;let o=performance.now(),a=0,n=6;for(;this.accumulator>=i&&a<n&&(e=this.stepPhysics()&&e,this.accumulator-=i,a++,!(performance.now()-o>1e3*i)););this.accumulator=this.accumulator%i}}this.skipRender=e}recordPhysicsPose(t){(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).decompose(ut,yt,vt);let e=t;void 0===e.prevQ?(e.prevQ=yt.clone(),e.prevT=ut.clone()):(e.prevQ.copy(yt),e.prevT.copy(ut))}promoteMovedFixedBodies(){for(let t=this.fixedBodiesToWatch.length-1;t>=0;t--){let[e,i,s]=this.fixedBodiesToWatch[t];(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).equals(s)||(i.setBodyType(ct.RigidBodyType.KinematicPositionBased,!0),this.sharedGameControlGlobals.kinematicBodyToEntity.set(i.handle,e),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(e),this.fixedBodiesToWatch.splice(t,1))}}clampPushedBodies(){let t=this.gameControl?.object.rigidBody;if(void 0===t)return;let e=this.sharedGameControlGlobals.rapierWorld,i=t.linvel(),s=t.translation(),o=Math.hypot(i.x,i.z);for(let a=0;a<t.numColliders();a++){let n=t.collider(a);e.contactPairsWith(n,t=>{let a=t.parent();if(null===a||!a.isDynamic())return;let r=a.translation(),h=-1/0,l=0,d=0;if(e.contactPair(n,t,t=>{let e=t.normal(),o=e.x*(r.x-s.x)+e.y*(r.y-s.y)+e.z*(r.z-s.z)<0?-1:1;if(Math.abs(e.y)>.7)return;let a=o*e.x,n=o*e.z,c=Math.hypot(a,n);if(c<1e-4)return;let p=(i.x*a+i.z*n)/c;p>h&&(h=p,l=a/c,d=n/c)}),h===-1/0)return;let c=i.x*l+i.z*d;if(c<-Dt)return;let p=a.linvel();if(o>Dt&&c>Dt){let t=p.x*l+p.z*d;if(t<=0)return;let e=Math.min(t,c);return void a.setLinvel({x:l*e,y:p.y,z:d*e},!0)}let m=p.x*l+p.z*d-Math.max(0,c);if(m<=0)return;let u=.5*m;a.setLinvel({x:p.x-l*u,y:p.y,z:p.z-d*u},!0)})}}stepPhysics(){this.promoteMovedFixedBodies();for(let t of this.sharedGameControlGlobals.kinematicBodyToEntity.values())this.recordPhysicsPose(t),t.rigidBody.setNextKinematicTranslation(ut.divideScalar(this.pixelsPerMeter)),t.rigidBody.setNextKinematicRotation(yt);for(let t of this.sharedGameControlGlobals.entitiesWithTransformAnim)!0!==t.rigidBody?.isKinematic()&&this.recordPhysicsPose(t);return this.sharedGameControlGlobals.rapierWorld.step(this.events),this.clampPushedBodies(),this.events?.drainCollisionEvents(this.handleCollisionEvents),!this.updatePositions()}dispatchCollisionEvent(t,e,i){let s,o=(this.sharedGameControlGlobals.rapierWorld?.getCollider(i))._parent;if(e.cloner)for(let t of e.cloner.children)if(t.rigidBody===o){s=t;break}t.dispatch(s),e.dispatchEvent(wt)}updateUseWindowEvents(t){this.orbitControls?.updateUseWindowEvents(t)}generateSensorColliderDescs(t,e,i){let s=Mt.copy(t.matrixWorld).invert();t.traverseEntity((o,a)=>{if(!1===e&&1===a)return!0;for(let e of o.dataPatched.events)if("Trigger"===e.data.type&&!0!==e.data.disabled){let a,n=new mt(e.id,e.data,o,this.page,this.sharedAssets,this.eventManager);if(a="box"===e.data.triggerZone?ct.ColliderDesc.cuboid(...e.data.size.map(t=>("number"==typeof t?t:1)/(2*this.pixelsPerMeter))):ct.ColliderDesc.ball(e.data.radius/this.pixelsPerMeter),a.setDensity(0).setSensor(!0).setActiveEvents(ct.ActiveEvents.COLLISION_EVENTS),ft.fromArray(e.data.position.map(t=>"number"==typeof t?t:0)),Pt.setFromEuler(gt.fromArray(e.data.rotation.map(t=>"number"==typeof t?t:0))),Ct.compose(ft,Pt,Et).premultiply(o.matrixWorld),i?(Ct.decompose(ft,Pt,bt),a.setActiveCollisionTypes(ct.ActiveCollisionTypes.KINEMATIC_FIXED|ct.ActiveCollisionTypes.DYNAMIC_FIXED)):(Ct.premultiply(s).decompose(ft,Pt,bt),t.rigidBody.bodyType()===ct.RigidBodyType.Dynamic||(t.rigidBody.bodyType()===ct.RigidBodyType.Fixed?a.setActiveCollisionTypes(ct.ActiveCollisionTypes.KINEMATIC_FIXED|ct.ActiveCollisionTypes.DYNAMIC_FIXED):a.setActiveCollisionTypes(ct.ActiveCollisionTypes.KINEMATIC_KINEMATIC|ct.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),ft.divideScalar(this.pixelsPerMeter),a.setTranslation(ft.x,ft.y,ft.z),a.setRotation(Pt),i)i.push([a,n]);else{let e=this.sharedGameControlGlobals.rapierWorld.createCollider(a,t.rigidBody);this.sensorToTriggerEvent[e.handle]=n}}})}checkTrigger(){let t;for(let e=0;e<this.sharedGameControlGlobals.triggers.length;e++){let[i,s,o,a]=this.sharedGameControlGlobals.triggers[e];for(let e=0;e<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;e++){let n=this.sharedGameControlGlobals.entitiesWithTransformAnim[e];if(o===n||!1===a.isValidTriggeringObject(p.is(n)?n:n.object))continue;let r=Mt.copy(o.matrixWorld).decompose(ft,Tt,bt).compose(ft,Tt,Et).multiply(s),h=Ct.copy(n.matrixWorld).invert().multiply(r),l=n.bvhGeometry.boundsTree;i instanceof w?t=l.intersectsBox(i,h):(St.radius=i,St.center.setFromMatrixPosition(h),t=l.intersectsSphere(St)),t?-1===a.currentIntersectedObjects.indexOf(n)&&(a.currentIntersectedObjects.push(n),a.dispatch(),o.dispatchEvent(Rt)):a.currentIntersectedObjects=a.currentIntersectedObjects.filter(t=>t!==n)}}}},It=new Promise(t=>{Bt=t});function Ft(t){return Wt||(Wt=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.4/build";typeof window<"u"&&(At=new URL(e.endsWith("/")?e:`${e}/`,window.location.href).href);let i=import("./navmesh.js"),[s,o]=await Promise.all([i,fetch(`${e}/navmesh.wasm`).then(t=>t.arrayBuffer())]),a=s.default,n=await a({wasmBinary:o});Bt(n)}())}export{it as a,ht as b,B as c,W as d,I as e,dt as f,wt as g,jt as h,Lt as i,Ot as j,It as k,At as l,Ft as m};
1
+ import{b as t}from"./runtime-chunk-N2ZRGNPR.js";import{a as e,c as i}from"./runtime-chunk-VAVYZ35B.js";import{b as s,c as o,d as a,e as n}from"./runtime-chunk-FQNSP44B.js";import{a as r}from"./runtime-chunk-SXDO5LXF.js";import{G as h,a as l}from"./runtime-chunk-LALFWESO.js";import{f as d,g as c}from"./runtime-chunk-QVC5UDJO.js";import{h as p}from"./runtime-chunk-PLJ25O2X.js";import{a as m,g as u,h as y,i as v}from"./runtime-chunk-2PT2WH66.js";import{a as g}from"./runtime-chunk-4KZXQGUQ.js";import{c as f}from"./runtime-chunk-TZCHGFVF.js";import{Fa as b}from"./runtime-chunk-OW6T4XFV.js";import{Bc as E,Dc as P,Ec as C,Fc as M,Oc as x,Oe as T,Pc as S,Rc as D,Xc as w,b as R,bd as j,cd as L,dd as G}from"./runtime-chunk-VGN7YHB7.js";var B=200,A=null;function W(t){A=t}function O(){return A}function I(t){let e=!1;return t.scene.objects.forEach(i=>{"Page"===i.data.type&&!e&&i.data.publish.gameControlObject&&b.traverseModuleInstances(t,i.id,(t,i,s)=>{for(let t of s)"GameControl"===t.data.type&&t.data.navmesh.enabled&&(e=!0)})}),e}function F(t){return s?t.metaKey:t.ctrlKey}function k(t,e){return Math.abs(t+3*e)<=2||Math.abs(t+3*window.devicePixelRatio*e)<=2}var V={type:"change"},z={type:"start"},H={type:"end",nonOrbit:!0},Z={type:"end",nonOrbit:!1},U={type:"end",isZoom:!0,nonOrbit:!0},X={type:"end",changed:!1},Y={type:"cameraAnimatingInTimeline"},N=new C,K=new P,_=2*Math.PI,q=new M,Q=new P,J=new M,$=new C,tt=new x,et={type:"requestRender"},it=class extends E{constructor(t,i,s={isPlayMode:!1,isExport:!1},a){super(),this.object=t,this.domElement=i,this.options=s,this.timelineState=a,this.enabled=!0,this.useKeyEvents=!0,this.enableDamping=!1,this.enableZoom=!0,this.enableRotate=!0,this.enablePan=!0,this.autoRotate=!1,this.rotationLimitsMode=0,this.panLimitsMode=0,this.rotationSoftLimit=2,this.panSoftLimit=2,this.hoverRotatePanMode=0,this.zoomLimitsEnabled=!1,this.mouseButtons=[0,5],this.mouseButtonsPlay=[3,4,5],this.touches=[null,R.DOLLY_ROTATE,R.PAN],this.offset=new M,this.eye=new M,this.lastPosition=new M,this.lastQuaternion=new C,this.current=new P,this.overShoot=new P,this.overRatio=new P,this.spherical=new T,this.sphericalDelta=new T,this.panOffset=new M,this.panLeftV=new M,this.panUpV=new M,this.panV=new M,this.rotateStart=new P,this.rotateEnd=new P,this.rotateDelta=new P,this.panStart=new P,this.panEnd=new P,this.panDelta=new P,this.dollyStart=new P,this.dollyEnd=new P,this.dollyDelta=new P,this.rotationRangeFactor=new P,this.panRangeFactor=new P,this.state=-1,this.zoomChanged=!1,this.isPointerDown=!1,this.isThetaFlipped=!1,this.prevScale=0,this.scale=1,this.gesture=!1,this.lastTrackpadPanTime=-1/0,this.lastMouseWheelZoomTime=-1/0,this.timer=-1,this.timerHover=-1,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPhi=0,this.maxPhi=Math.PI,this.minTheta=-1/0,this.maxTheta=1/0,this.minH=0,this.maxH=Math.PI,this.minV=-1/0,this.maxV=1/0,this.autoRotateClockwise=!0,this.isPanOverShoot=!1,this.isRotateOverShoot=!1,this.resetHoverEffectOnPointerLeave=!1,this.hasChange=!1,this.useWindowEvents=!1,this.isTouchZoom=!0,this.autoRotateSpeed=2,this.dampingFactor=.125,this.zoomSpeed=2,this.rotateSpeed=1,this.rotateFactor=1,this.panSpeed=1,this.hoverRotatePanStrength=.1,this.hoverRotateDamping=this.dampingFactor,this.isCurrentlyDamping=!1,this.thetaIsFree=!1,this.phiIsFree=!1,this.needsUpdate=!0,this.onCameraChange=t=>{this.object.removeEventListener("beginState",this.onBeginState),this.object.removeEventListener("completeState",this.onCompleteState),this.object.removeEventListener("cameraChange",this.onCameraChange),this.object=t.camera,this.object.addEventListener("beginState",this.onBeginState),this.object.addEventListener("completeState",this.onCompleteState),this.object.addEventListener("cameraChange",this.onCameraChange)},this.update=()=>{this.object.updateWorldMatrix(!0,!1),this.object.matrixWorld.decompose(J,$,q),this.offset.copy(J).sub(this.target),this.spherical.setFromVector3(this.offset),this.object.isUpVectorFlipped&&(this.spherical.phi*=-1,this.spherical.theta-=Math.PI),this.autoRotate&&-1===this.state&&this.rotateLeft((!0===this.autoRotateClockwise?1:-1)*this.getAutoRotationAngle()),0!==this.rotationLimitsMode&&this.applyLimits(this.sphericalDelta,this.rotationLimitsMode,this.rotationSoftLimit,this.maxTheta,this.minTheta,this.maxPhi,this.minPhi,this.rotationRangeFactor),2!==this.rotationLimitsMode&&(this.spherical.phi+=this.sphericalDelta.phi),(1!==this.rotationLimitsMode||!0===this.autoRotate)&&(this.spherical.theta+=this.sphericalDelta.theta),this.spherical.radius*=this.scale,this.zoomLimitsEnabled&&this.object.isPerspectiveCamera&&(this.spherical.radius=Math.max(this.minDistance,Math.min(this.maxDistance,this.spherical.radius))),0!==this.panLimitsMode&&(this.target.applyQuaternion(N.copy($).invert()),this.panOffset.applyQuaternion(N),this.applyLimits(this.panOffset,this.panLimitsMode,this.panSoftLimit,this.maxH,this.minH,this.maxV,this.minV,this.panRangeFactor),this.target.applyQuaternion($),this.panOffset.applyQuaternion($)),2===this.panLimitsMode&&(this.panOffset.y=0),1===this.panLimitsMode&&(this.panOffset.x=0),-1!==this.state||this.gesture?(this.target.add(this.panOffset),this.panOffset.set(0,0,0)):(this.panOffset.multiplyScalar(1-this.dampingFactor),this.target.add(this.panOffset)),this.offset.setFromSpherical(this.spherical),J.copy(this.target).add(this.offset),this.object.position.copy(this.target).add(this.offset),this.object.parent&&(tt.copy(this.object.parent.matrixWorld).invert(),this.object.position.applyMatrix4(tt));let t=this.spherical.phi%_;if(this.eye.copy(this.offset).normalize(),this.object.up.copy(D.DEFAULT_UP).applyAxisAngle(this.eye,this.object.angleOffsetFromUp),t>0&&t>Math.PI||t<0&&t>-Math.PI?(this.object.up.negate(),this.object.lookAt(this.target),this.object.isUpVectorFlipped=!0):(this.object.lookAt(this.target),this.object.isUpVectorFlipped=!1),-1===this.state||!0===this.enableDamping){let t=1===this.hoverRotatePanMode?this.hoverRotateDamping:this.dampingFactor;this.sphericalDelta.theta*=1-t,this.sphericalDelta.phi*=1-t}else this.sphericalDelta.set(0,0,0);if(this.scale=1,this.lastPosition.distanceToSquared(this.object.position)>.01||8*(1-this.lastQuaternion.dot(this.object.quaternion))>1e-8)return this.dispatchEvent(V),this.object.dispatchEvent(et),this.lastPosition.copy(this.object.position),this.lastQuaternion.copy(this.object.quaternion),void(this.isCurrentlyDamping=!0);this.isPanOverShoot=!1,this.isRotateOverShoot=!1,this.object.wasMovedBySwitchCameraAction=!1,this.sphericalDelta.set(0,0,0),this.panOffset.set(0,0,0),this.isCurrentlyDamping=!1},this.onPointerDown=t=>{!1!==this.enabled&&("touch"===t.pointerType||"pen"===t.pointerType&&n?this.onPointerDownTouch(t):this.onPointerDownMouse(t),-1!==this.state&&(this.isPointerDown=!0,this.dispatchEvent(z),this.domElement.addEventListener("pointermove",this.onPointerMove),this.domElement.addEventListener("pointerup",this.onPointerUp),t.stopPropagation(),"touch"===t.pointerType||"pen"===t.pointerType&&n||this.domElement.setPointerCapture(t.pointerId)))},this.onPointerLeave=t=>{this.resetHoverEffectOnPointerLeave&&!this.useWindowEvents?(1===this.hoverRotatePanMode?(this.sphericalDelta.theta=-this.spherical.theta,this.sphericalDelta.phi=-this.spherical.phi,q.subVectors(this.position0,this.target0),this.spherical.setFromVector3(q),this.sphericalDelta.theta+=this.spherical.theta,this.sphericalDelta.phi+=this.spherical.phi,this.sphericalDelta.theta/=8,this.sphericalDelta.phi/=8):2===this.hoverRotatePanMode&&this.panOffset.subVectors(this.target0,this.target).divideScalar(8),this.update()):this.pointerLeaveEvent=t},this.onPointerEnter=t=>{this.resetHoverEffectOnPointerLeave||void 0===this.pointerLeaveEvent?Q.set(t.clientX-this.domElement.clientWidth/2,t.clientY-this.domElement.clientHeight/2):Q.set(t.clientX-this.pointerLeaveEvent.clientX,t.clientY-this.pointerLeaveEvent.clientY),1===this.hoverRotatePanMode?(this.rotateDelta.copy(Q).multiplyScalar(this.rotateSpeed*this.hoverRotatePanStrength).rotateAround(K,-this.object.angleOffsetFromUp),this.rotateLeft(2*Math.PI*this.rotateDelta.x/this.domElement.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/this.domElement.clientHeight),this.rotateStart.set(t.clientX,t.clientY)):2===this.hoverRotatePanMode&&(this.panDelta.copy(Q).multiplyScalar(this.panSpeed*this.hoverRotatePanStrength),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.set(t.clientX,t.clientY)),this.update()},this.onPointerMove=t=>{this.timelineState?.isPlayingCameraAnimation?this.dispatchEvent(Y):!1!==this.enabled&&(this.checkRaycastLock()||("touch"===t.pointerType||"pen"===t.pointerType&&n?this.onPointerMoveTouch(t):this.onPointerMoveMouse(t),t.stopPropagation()))},this.onPointerUp=t=>{this.isPointerDown=!1,0===e.length&&(this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp)),e.length>1&&t.preventDefault(),this.hasChange?this.dispatchEvent(0===this.state?Z:H):this.dispatchEvent(X),this.state=-1,t&&(t.stopPropagation(),"touch"===t.pointerType||"pen"===t.pointerType&&n||this.domElement.releasePointerCapture(t.pointerId))},this.onPointerDownMouse=t=>{let e;switch(e=this.useKeyEvents?this.mouseButtons[t.button]:this.mouseButtonsPlay[t.button],e){case 0:if(!0!==t.altKey||t.shiftKey||F(t)){if(" "===this.key){if(!1===this.enablePan)return;this.handleMouseDownPan(t),this.state=2}}else{if(!1===this.enableRotate)return;this.handleMouseDownRotate(t),this.state=0}break;case 4:if(!1===this.enablePan)return;this.handleMouseDownPan(t),this.state=2;break;case 3:if(F(t)||t.shiftKey){if(!1===this.enablePan)return;this.handleMouseDownPan(t),this.state=2}else{if(!1===this.enableRotate)return;this.handleMouseDownRotate(t),this.state=0}break;case 5:if(F(t)||t.shiftKey){if(!1===this.enableRotate)return;this.handleMouseDownRotate(t),this.state=0}else{if(!1===this.enablePan)return;this.handleMouseDownPan(t),this.state=2}break;default:this.state=-1}},this.onPointerMoveMouse=t=>{switch(this.state){case 0:if(!1===this.enableRotate)return;this.handleMouseMoveRotate(t);break;case 1:if(!1===this.enableZoom)return;this.handleMouseMoveDolly(t);break;case 2:if(!1===this.enablePan)return;this.handleMouseMovePan(t)}this.object.wasMovedByUser=!0},this.onPointerDownTouch=t=>{switch(e.length>1&&t.preventDefault(),this.touches[e.length-1]){case R.ROTATE:if(!1===this.enableRotate)return void(this.state=-1);this.handleTouchStartRotate(),this.state=3;break;case R.PAN:if(!1===this.enablePan)return void(this.state=-1);this.handleTouchStartPan(),this.state=4;break;case R.DOLLY_PAN:if(!1===this.enableZoom&&!1===this.enablePan)return;this.handleTouchStartDollyPan(),this.state=5;break;case R.DOLLY_ROTATE:if(!1===this.enableZoom&&!1===this.enableRotate)return;this.handleTouchStartDollyRotate(),this.state=6;break;default:this.state=-1}},this.onPointerMoveTouch=t=>{switch(e.length>1&&t.preventDefault(),this.state){case 3:if(!1===this.enableRotate)return;this.handleTouchMoveRotate(t),this.update();break;case 4:if(!1===this.enablePan)return;this.handleTouchMovePan(t),this.update();break;case 5:if(!1===this.enableZoom&&!1===this.enablePan)return;this.handleTouchMoveDollyPan(t),this.update();break;case 6:if(!1===this.enableZoom&&!1===this.enableRotate)return;this.handleTouchMoveDollyRotate(t),this.update();break;default:this.state=-1}this.object.wasMovedByUser=!0},this.dispatchEndDebounced=g(()=>{this.zoomChanged?this.dispatchEvent(U):this.dispatchEvent(H),this.zoomChanged=!1},33),this.onMouseWheel=t=>{if(!1!==this.enabled&&(!1!==this.enableZoom||!1!==this.enablePan)&&!this.checkRaycastLock()){if(!this.options.isExport&&this.domElement.clientHeight===document.body.clientHeight&&this.domElement.clientWidth===document.body.clientWidth&&t.preventDefault(),this.dispatchEvent(z),this.timelineState?.isPlayingCameraAnimation)return void this.dispatchEvent(Y);this.handleMouseWheel(t),this.dispatchEndDebounced(),this.object.wasMovedByUser=!0}},this.onGesture=t=>{if(t.preventDefault(),!1!==this.enabled&&!this.checkRaycastLock()&&!o){if(this.timelineState?.isPlayingCameraAnimation)return void this.dispatchEvent(Y);if("gesturechange"===t.type){if(!1===this.enableZoom||!1===this.isTouchZoom)return;this.dispatchEvent(z),t.scale>this.prevScale?this.dollyIn(this.getZoomScale()):t.scale<this.prevScale&&this.dollyOut(this.getZoomScale()),this.prevScale=t.scale,this.update(),this.object.wasMovedByUser=!0}else this.dispatchEvent(H)}},this.onContextMenu=t=>{t.preventDefault()},this.onTouchEnd=t=>{t.preventDefault()},this.onKeyDown=t=>{!1!==this.enabled&&(this.key=t.key," "===t.key&&this.dispatchEvent(z))},this.onKeyUp=t=>{this.key=void 0,!1!==this.enabled&&(-1!==this.state&&"Alt"===t.key&&this.onPointerUp(e[0])," "===t.key&&this.dispatchEvent(H))},this.onPointerHover=t=>{"mouse"!==t.pointerType||!1===this.enabled||-1!==this.state||2===this.hoverRotatePanMode&&this.isPanOverShoot||1===this.hoverRotatePanMode&&this.isRotateOverShoot||(this.isPointerDown=!0,2===this.hoverRotatePanMode?this.handleMouseMovePan(t,this.hoverRotatePanStrength):1===this.hoverRotatePanMode&&this.handleMouseMoveRotate(t,this.hoverRotatePanStrength))},this.onBeginState=()=>{this.enabled=!1,this.needsUpdate=!1},this.onCompleteState=t=>{t.isfromEntity&&this.options.isPlayMode||(this.enabled=!0,this.needsUpdate=!0,this.object.updateUp(),this.object.getTarget(this.target))},this.target=this.object.getTarget(),this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.quat0=this.object.quaternion.clone(),this.isUpVectorFlipped0=this.object.isUpVectorFlipped,this.object.updateWorldMatrix(!0,!1),this.object.matrixWorld.decompose(J,$,q),this.offset.copy(J).sub(this.target),this.spherical.setFromVector3(this.offset),this.object.isUpVectorFlipped&&(this.spherical.phi*=-1,this.spherical.theta-=Math.PI),this.initialSphericalRadius=this.spherical.radius,this.addEventListenersToCamera()}dispatchEvent(t){"start"===t.type?this.hasChange=!1:this.hasChange=!0,super.dispatchEvent(t)}addEventListenersToCamera(){this.object.addEventListener("beginState",this.onBeginState),this.object.addEventListener("completeState",this.onCompleteState),this.object.addEventListener("cameraChange",this.onCameraChange)}removeEventListenersFromCamera(){this.object.removeEventListener("beginState",this.onBeginState),this.object.removeEventListener("completeState",this.onCompleteState),this.object.removeEventListener("cameraChange",this.onCameraChange)}updateUseWindowEvents(t){if(window.removeEventListener("pointermove",this.onPointerHover),this.domElement.removeEventListener("pointermove",this.onPointerHover),this.useWindowEvents=t,0!==this.hoverRotatePanMode&&(this.useWindowEvents?window.addEventListener("pointermove",this.onPointerHover):this.domElement.addEventListener("pointermove",this.onPointerHover)),this.domElement.removeEventListener("pointerleave",this.onPointerLeave),this.domElement.removeEventListener("pointerenter",this.onPointerEnter),window.removeEventListener("pointerleave",this.onPointerLeave),window.removeEventListener("pointerenter",this.onPointerEnter),0!==this.hoverRotatePanMode&&!this.useWindowEvents){let t=this.useWindowEvents?window:this.domElement;t.addEventListener("pointerleave",this.onPointerLeave),t.addEventListener("pointerenter",this.onPointerEnter)}}fromJSON(t,e){this.rotateFactor=t.rotationSpeed??1,this.setEnableDampingSpeed(t.enableDamping),this.enablePan=t.enablePan,this.enableZoom=t.enableZoom,this.enableRotate=t.enableRotate,this.rotationLimitsMode=t.rotationLimitsMode,this.thetaIsFree=t.rotationHorizontalOffset.min===t.rotationHorizontalOffset.max&&t.rotationHorizontalOffset.min===Math.PI,this.phiIsFree=t.rotationVerticalOffset.min===t.rotationVerticalOffset.max&&t.rotationVerticalOffset.min===Math.PI,this.panLimitsMode=t.panLimitsMode,this.panSoftLimit=t.panSoftLimit,this.rotationSoftLimit=t.rotationSoftLimit,this.hoverRotatePanMode=t.hoverRotatePanMode,this.hoverRotateDamping=t.hoverRotateDamping??this.dampingFactor,this.useWindowEvents="window"===e,0!==this.hoverRotatePanMode&&(this.useWindowEvents?window.addEventListener("pointermove",this.onPointerHover):this.domElement.addEventListener("pointermove",this.onPointerHover));let i=t.hoverRotatePanStrength/100;this.hoverRotatePanStrength=i**2,this.zoomLimitsEnabled=t.zoomLimitsEnabled,this.minZoom=t.zoomLimits.min,this.maxZoom=Math.max(t.zoomLimits.min,t.zoomLimits.max),this.minDistance=1e3/this.maxZoom,this.maxDistance=Math.max(this.minDistance,1e3/t.zoomLimits.min),this.autoRotate=t.autoRotate,this.autoRotateSpeed=t.autoRotateSpeed,this.autoRotateClockwise=t.autoRotateClockwise;let s=this.object.getTarget().applyQuaternion(N.copy(this.object.quaternion).invert());this.minV=-t.panVerticalOffset.min+s.y,this.maxV=t.panVerticalOffset.max+s.y,this.minH=-t.panHorizontalOffset.min+s.x,this.maxH=t.panHorizontalOffset.max+s.x,this.panRangeFactor.set(this.maxH-this.minH,this.maxV-this.minV).divideScalar(2),this.rotationRangeFactor.setScalar(Math.PI).divideScalar(4),this.minPhi=st(this.spherical.phi-t.rotationVerticalOffset.min),this.maxPhi=st(this.spherical.phi+t.rotationVerticalOffset.max),this.minTheta=st(st(this.spherical.theta)-t.rotationHorizontalOffset.min),this.maxTheta=st(st(this.spherical.theta)+t.rotationHorizontalOffset.max),this.isThetaFlipped=this.minTheta>this.maxTheta,1===t.orbitTouches&&(this.touches[0]=R.ROTATE),1===t.panTouches&&(this.touches[0]=R.PAN),2===t.orbitTouches&&(this.touches[1]=R.DOLLY_ROTATE),2===t.panTouches&&(this.touches[1]=R.DOLLY_PAN),3===t.orbitTouches&&(this.touches[2]=R.ROTATE),3===t.panTouches&&(this.touches[2]=R.PAN),this.isTouchZoom=t.isTouchZoom,this.resetHoverEffectOnPointerLeave=t.resetHoverEffectOnPointerLeave??!1}connect(){if(this.domElement.addEventListener("contextmenu",this.onContextMenu),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("wheel",this.onMouseWheel),window.addEventListener("keydown",this.onKeyDown,!1),window.addEventListener("keyup",this.onKeyUp,!1),this.domElement.addEventListener("gesturestart",this.onGesture),this.domElement.addEventListener("gesturechange",this.onGesture),this.domElement.addEventListener("gestureend",this.onGesture),this.domElement.addEventListener("touchend",this.onTouchEnd),0!==this.hoverRotatePanMode&&!this.useWindowEvents){let t=this.useWindowEvents?window:this.domElement;t.addEventListener("pointerleave",this.onPointerLeave),t.addEventListener("pointerenter",this.onPointerEnter)}this.pointerLeaveEvent=void 0}dispose(){this.removeEventListenersFromCamera(),this.domElement.removeEventListener("contextmenu",this.onContextMenu),this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("wheel",this.onMouseWheel),window.removeEventListener("keydown",this.onKeyDown,!1),window.removeEventListener("keyup",this.onKeyUp,!1),this.domElement.removeEventListener("pointermove",this.onPointerHover),window.removeEventListener("pointermove",this.onPointerHover),this.domElement.removeEventListener("gesturestart",this.onGesture),this.domElement.removeEventListener("gesturechange",this.onGesture),this.domElement.removeEventListener("gestureend",this.onGesture),this.domElement.removeEventListener("touchend",this.onTouchEnd),this.domElement.removeEventListener("pointerleave",this.onPointerLeave),this.domElement.removeEventListener("pointerenter",this.onPointerEnter),window.removeEventListener("pointerleave",this.onPointerLeave),window.removeEventListener("pointerenter",this.onPointerEnter),this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp)}applyLimits(t,e,i,s,o,a,n,r){let h,l,d;this.overShoot.set(0,0),t instanceof M?(h=t.x,l=t.y,this.current.set(this.target.x,this.target.y),d=!0):(h=t.theta,l=t.phi,this.current.set(st(this.spherical.theta),st(this.spherical.phi)),d=!1),0===i&&(this.current.x+=h,this.current.y+=l),(3===e||2===e)&&(!d&&this.isThetaFlipped?this.current.x>s&&this.current.x<0?this.overShoot.x=s-this.current.x:this.current.x<o&&this.current.x>0&&(this.overShoot.x=o-this.current.x):this.current.x>s?this.overShoot.x=s-this.current.x:this.current.x<o&&(this.overShoot.x=o-this.current.x)),(3===e||1===e)&&(this.current.y>a?this.overShoot.y=a-this.current.y:this.current.y<n&&(this.overShoot.y=n-this.current.y)),d||(this.overShoot.x=st(this.overShoot.x),this.overShoot.y=st(this.overShoot.y)),0!==i?(this.overRatio.copy(this.overShoot).divide(r),this.overRatio.x=Math.min(Math.abs(this.overRatio.x),1),this.overRatio.y=Math.min(Math.abs(this.overRatio.y),1),1===i&&(this.overRatio.x=ot(Math.abs(this.overRatio.x)),this.overRatio.y=ot(Math.abs(this.overRatio.y))),this.isPointerDown||1===i?2===i&&(this.overRatio.x>.9&&!this.thetaIsFree||this.overRatio.y>.9&&!this.phiIsFree)?this.isPointerDown=!1:(h*this.overShoot.x<0&&!this.thetaIsFree&&(h*=1-this.overRatio.x),l*this.overShoot.y<0&&!this.phiIsFree&&(l*=1-this.overRatio.y)):2===i&&(!d&&(this.overRatio.x>.002&&!this.thetaIsFree||this.overRatio.y>.002&&!this.phiIsFree)||d&&(Math.abs(this.overShoot.x)>2||Math.abs(this.overShoot.y)>2)?(this.thetaIsFree||(h=.05*this.overShoot.x),this.phiIsFree||(l=.05*this.overShoot.y),d?this.isPanOverShoot=!0:this.isRotateOverShoot=!0):d?this.isPanOverShoot=!1:this.isRotateOverShoot=!1)):(h+=this.overShoot.x,l+=this.overShoot.y),t instanceof M?(t.x=h,t.y=l):(this.thetaIsFree||(t.theta=h),this.phiIsFree||(t.phi=l))}setEnableDampingSpeed(t){this.enableDamping=t,this.rotateSpeed=(!0===t?.2:1)*this.rotateFactor}stopDamping(){this.sphericalDelta.theta=0,this.sphericalDelta.phi=0,this.panOffset.set(0,0,0)}setTarget(t,e,i){this.stopDamping(),this.target.set(t,e,i)}getAutoRotationAngle(){return 2*Math.PI/60/60*this.autoRotateSpeed}getZoomScale(){return Math.pow(.95,this.zoomSpeed)}rotateLeft(t){this.sphericalDelta.theta-=t}rotateUp(t){this.sphericalDelta.phi-=t}panLeft(t,e){this.panLeftV.setFromMatrixColumn(e,0),this.panLeftV.multiplyScalar(-t),this.panOffset.add(this.panLeftV)}panUp(t,e){this.panUpV.setFromMatrixColumn(e,1),this.panUpV.multiplyScalar(t),this.panOffset.add(this.panUpV)}pan(t,e){let i=this.domElement;if(i&&this.object.isPerspectiveCamera){let s=this.object.position;this.panV.copy(s).sub(this.target);let o=this.panV.length();o*=Math.tan(this.object.fov/2*Math.PI/180),this.panLeft(2*t*o/i.clientHeight,this.object.matrixWorld),this.panUp(2*e*o/i.clientHeight,this.object.matrixWorld)}else i&&this.object.isOrthographicCamera&&(this.panLeft(t*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrixWorld),this.panUp(e*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrixWorld));this.dispatchEvent(V)}dollyOut(t){this.object.isPerspectiveCamera?this.scale/=t:this.object.isOrthographicCamera&&(this.object.zoom*=t,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(V)}dollyIn(t){this.object.isPerspectiveCamera?this.scale*=t:this.object.isOrthographicCamera&&(this.object.zoom/=t,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0),this.dispatchEvent(V)}setZoom(t){if(this.dispatchEvent(z),this.object.isPerspectiveCamera){let e=this.initialSphericalRadius/t/this.spherical.radius;this.scale=e}else this.object.isOrthographicCamera&&(this.object.zoom=t,this.zoomLimitsEnabled&&(this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom))),this.object.updateProjectionMatrix(),this.zoomChanged=!0);this.dispatchEvent(H)}handleMouseDownRotate(t){this.rotateStart.set(t.clientX,t.clientY)}handleMouseDownDolly(t){this.dollyStart.set(t.clientX,t.clientY)}handleMouseDownPan(t){this.panStart.set(t.clientX,t.clientY)}handleMouseMoveRotate(t,e=1){void 0!==t.movementX?this.rotateDelta.set(t.movementX,t.movementY):(this.rotateEnd.set(t.clientX,t.clientY),this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart),this.rotateStart.copy(this.rotateEnd)),this.rotateDelta.multiplyScalar(this.rotateSpeed*e).rotateAround(K,-this.object.angleOffsetFromUp);let i=this.domElement,s=this.useWindowEvents?window.innerHeight:i.clientHeight,o=2*Math.PI*this.rotateDelta.x/s,a=2*Math.PI*this.rotateDelta.y/s;this.rotateLeft(o),this.rotateUp(a),this.update()}handleMouseMoveDolly(t){this.dollyEnd.set(t.clientX,t.clientY),this.dollyDelta.subVectors(this.dollyEnd,this.dollyStart),this.dollyDelta.y>0?this.dollyOut(this.getZoomScale()):this.dollyDelta.y<0&&this.dollyIn(this.getZoomScale()),this.dollyStart.copy(this.dollyEnd),this.update()}handleMouseMovePan(t,e=1){void 0!==t.movementX?this.panDelta.set(t.movementX,t.movementY):(this.panEnd.set(t.clientX,t.clientY),this.panDelta.subVectors(this.panEnd,this.panStart),this.panStart.copy(this.panEnd)),this.panDelta.multiplyScalar(this.panSpeed*e),this.pan(this.panDelta.x,this.panDelta.y),this.update()}handleMouseWheel(t){if(0===t.deltaX&&0===t.deltaY)return;let e=!0===t.ctrlKey||!0===F(t),i=!1===F(t)&&!0===(0===(r=t).wheelDeltaY||0===r.deltaY?!(s&&r.shiftKey&&Math.abs(r.wheelDeltaX)>=120)&&(r.wheelDeltaX?k(r.wheelDeltaX,r.deltaX):0===r.deltaMode):r.wheelDeltaY?k(r.wheelDeltaY,r.deltaY):0===r.deltaMode),o=!1===e&&(!0===this.gesture||t.timeStamp-this.lastTrackpadPanTime<300),n=!1===e&&!1===o&&t.timeStamp-this.lastMouseWheelZoomTime<300;var r;if(!1!==a||!1!==n||!0!==i&&!0!==o){if(!1===this.enableZoom)return;this.gesture&&(window.clearTimeout(this.timer),this.gesture=!1,this.isPointerDown=!1,this.dispatchEvent(H)),!1===e&&!1===i&&(this.lastMouseWheelZoomTime=t.timeStamp),0===t.deltaY?t.deltaX<0?this.dollyIn(this.getZoomScale()):t.deltaX>0&&this.dollyOut(this.getZoomScale()):t.deltaY<0?this.dollyIn(this.getZoomScale()):t.deltaY>0&&this.dollyOut(this.getZoomScale()),this.update(),this.gesture=!1,this.isPointerDown=!1}else{if(!1===this.enablePan)return;let e=!1===this.gesture&&!1===o;this.lastTrackpadPanTime=t.timeStamp,this.gesture||(this.gesture=!0,this.isPointerDown=!0),!1===e&&(this.panDelta.set(-t.deltaX,-t.deltaY).multiplyScalar(this.panSpeed),this.panDelta.x=Math.min(Math.abs(this.panDelta.x),100)*(this.panDelta.x<0?-1:1),this.panDelta.y=Math.min(Math.abs(this.panDelta.y),100)*(this.panDelta.y<0?-1:1),t.altKey?this.pan(0,this.panDelta.y):t.shiftKey?this.pan(this.panDelta.x,0):this.pan(this.panDelta.x,this.panDelta.y),this.update()),window.clearTimeout(this.timer),this.timer=window.setTimeout(()=>{this.gesture=!1,this.isPointerDown=!1,this.dispatchEvent(H)},100)}}handleTouchStartRotate(){if(2===e.length){let t=.5*(e[0].pageX+e[1].pageX),i=.5*(e[0].pageY+e[1].pageY);this.rotateStart.set(t,i)}else this.rotateStart.set(e[0].pageX,e[0].pageY)}handleTouchStartPan(){if(2===e.length){let t=.5*(e[0].pageX+e[1].pageX),i=.5*(e[0].pageY+e[1].pageY);this.panStart.set(t,i)}else this.panStart.set(e[0].pageX,e[0].pageY)}handleTouchStartDolly(){let t=e[0].pageX-e[1].pageX,i=e[0].pageY-e[1].pageY,s=Math.sqrt(t*t+i*i);this.dollyStart.set(0,s)}handleTouchStartDollyPan(){this.enableZoom&&!0===this.isTouchZoom&&this.handleTouchStartDolly(),this.enablePan&&this.handleTouchStartPan()}handleTouchStartDollyRotate(){this.enableZoom&&!0===this.isTouchZoom&&this.handleTouchStartDolly(),this.enableRotate&&this.handleTouchStartRotate()}handleTouchMoveRotate(t){if(2===e.length){let e=i(t),s=.5*(t.pageX+e.x),o=.5*(t.pageY+e.y);this.rotateEnd.set(s,o)}else{if(t.pointerId!==e[0].pointerId)return;this.rotateEnd.set(t.pageX,t.pageY)}this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(this.rotateSpeed);let s=this.domElement;s&&(this.rotateLeft(2*Math.PI*this.rotateDelta.x/s.clientHeight),this.rotateUp(2*Math.PI*this.rotateDelta.y/s.clientHeight)),this.rotateStart.copy(this.rotateEnd)}handleTouchMovePan(t){if(2===e.length){let e=i(t),s=.5*(t.pageX+e.x),o=.5*(t.pageY+e.y);this.panEnd.set(s,o)}else{if(t.pointerId!==e[0].pointerId)return;this.panEnd.set(t.pageX,t.pageY)}this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(this.panSpeed),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.copy(this.panEnd)}handleTouchMoveDolly(t){let e=i(t),s=t.pageX-e.x,o=t.pageY-e.y,a=Math.sqrt(s*s+o*o);this.dollyEnd.set(0,a),this.dollyDelta.set(0,Math.pow(this.dollyEnd.y/this.dollyStart.y,this.zoomSpeed)),this.dollyOut(this.dollyDelta.y),this.dollyStart.copy(this.dollyEnd)}handleTouchMoveDollyPan(t){this.enableZoom&&!0===this.isTouchZoom&&this.handleTouchMoveDolly(t),this.enablePan&&this.handleTouchMovePan(t)}handleTouchMoveDollyRotate(t){this.enableZoom&&!0===this.isTouchZoom&&this.handleTouchMoveDolly(t),this.enableRotate&&this.handleTouchMoveRotate(t)}checkRaycastLock(){if(this.object.data.raycastLock){if(this.options.isPlayMode)return!1;{let t=this.options?.showCameraLock;return t&&t(),!0}}return!1}};function st(t){let e=2*Math.PI;for(;t<=-Math.PI;)t+=e;for(;t>Math.PI;)t-=e;return t}function ot(t){return 1-Math.pow(1-t,4)}var at,nt,rt=new Promise(t=>{at=t});function ht(t){return nt||(nt=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.5/build",i=import("./physics.js"),[s,o]=await Promise.all([i,fetch(`${e}/physics.wasm`).then(t=>t.arrayBuffer())]);await s.init(o),at(s)}())}function lt(t){let e=t.elements,i=e[0]**2+e[1]**2+e[2]**2,s=e[4]**2+e[5]**2+e[6]**2,o=e[8]**2+e[9]**2+e[10]**2,a=e[0]**2+e[4]**2+e[8]**2,n=e[1]**2+e[5]**2+e[9]**2,r=e[2]**2+e[6]**2+e[10]**2,h=1e-8;return i<h||s<h||o<h||a<h||n<h||r<h}function dt(t,e){let i=new G;if(e&&lt(e))return i.setAttribute("position",new j([],3)),i.setIndex([]),i;if(!t.getAttribute("position"))return i.setAttribute("position",new j([],3)),i.setIndex([]),i;let{positions:s,triIndices:o}=h(t.getAttribute("position"),t.getIndex());return i.setAttribute("position",new j(s,3)),i.setIndex(o),e&&i.applyMatrix4(e),i}var ct,pt=class{constructor(t,e,i,s,o,a){this.id=t,this.data=e,this.object=i,this.initialDisabled=!1,this.actions=d(e,e.actions,s,o,a,i),this.target=e.target}disconnect(){c(this.actions)}dispatch(t){this.initialDisabled||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Collision"}),this.actions.Transition.forEach(t=>{"Toggle"===t.data.runMode?t.toggle():t.play()}),this.actions.Animation.forEach(t=>{"Toggle"===t.data.runMode?t.toggle():t.play()}),this.actions.TimelineAnimation.forEach(t=>{"runMode"in t.data&&"Toggle"===t.data.runMode?t.toggle():t.play()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(e=>{e.dispatch(t??!1)}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch()))}},mt=class{constructor(t,e,i,s,o,a){this.id=t,this.data=e,this.object=i,this.page=s,this.currentIntersectedObjects=[],this.actions=d(e,e.actions,s,o,a,i),this.target=e.target,this.triggeringObjects=[];for(let t of e.triggeringObjects){let e=s.scene.find(t);e&&this.triggeringObjects.push(e)}}isValidTriggeringObject(t){return"all"===this.target||this.triggeringObjects.some(e=>e===t||e.isAncestorOf(t.uuid)||t.isAncestorOf(e.uuid))}disconnect(){c(this.actions)}dispatch(){this.object.destroyedInAction||(this.actions.Transition.forEach(t=>{t.object.currentTransitionEvent!==this&&(t.object.currentTransitionEvent=this,t.init())}),this.object.dispatchEvent({type:"beginEvent",eventName:"Trigger"}),this.actions.Transition.forEach(t=>{"Toggle"===t.data.runMode?t.toggle():t.play()}),this.actions.SwitchCamera.forEach(t=>{"Toggle"===t.data.runMode?t.toggle():t.play()}),this.actions.TimelineAnimation.forEach(t=>{"runMode"in t.data&&"Toggle"===t.data.runMode?t.toggle():t.play()}),this.actions.Link.forEach(t=>{t.dispatch()}),this.actions.Reset.forEach(t=>{t.dispatch()}),this.actions.Create.forEach(t=>{t.dispatch()}),this.actions.Destroy.forEach(t=>{t.dispatch(!1)}),this.actions.Audio.forEach(t=>{t.dispatchBasic()}),this.actions.Particles.forEach(t=>{t.dispatchBasic()}),this.actions.Video.forEach(t=>{t.dispatchBasic()}),this.actions.SceneTransition.forEach(t=>{t.dispatch()}),this.actions.SetVariable.forEach(t=>t.checkConditions()),this.actions.SetVariable.forEach(t=>t.dispatch()),this.actions.DynamicVariablePlay.forEach(t=>t.dispatch()),this.actions.ClearLocalStorage.forEach(t=>t.dispatch()),this.actions.UserAPI.forEach(t=>t.dispatch()))}};rt.then(t=>ct=t);var ut=new M,yt=new C,vt=new M,gt=(new S(0,0,0,"YXZ"),new S(0,0,0,"XYZ")),ft=new M,bt=new M,Et=new M(1,1,1),Pt=new C,Ct=new x,Mt=new x,xt={type:"updateMatrix"},Tt=new C,St=new L,Dt=.01,wt={type:"beginEvent",eventName:"Collision"},Rt={type:"beginEvent",eventName:"Trigger"};function jt(t){if(b.physicsEnabled(t.scene.objects))return!0;let e=!1;return t.scene.objects.traverse((t,i)=>{if(i.events)if(Array.isArray(i.events)){for(let t of i.events)if(!0!==t.data.disabled&&"GameControl"===t.data.type&&t.data.collisionEnabled){e=!0;break}}else for(let t of Object.values(i.events))if(!0!==t.disabled&&"GameControl"===t.type&&t.collisionEnabled){e=!0;break}}),e}var Lt=t=>t.states.some(t=>void 0!==t.data.position||void 0!==t.data.rotation||void 0!==t.data.hiddenMatrix||void 0!==t.data.cloner||void 0!==t.data.pathSnapping);function Gt(t){return u(v(t)?t.object:t)}var Bt,At,Wt,Ot=class{constructor(t){this.eventContext=t,this.isEnabled=!1,this.gameControl=null,this.joysticks=[],this.joystickToGameControls=[],this.sharedGameControlGlobals={entitiesWithTransformAnim:[],entityToCollisionEvents:{},colliderToEntity:new Map,kinematicBodyToEntity:new Map,triggers:[],gamePads:[],createdObjects:[],nCreatedPerAction:{}},this.sensorToTriggerEvent={},this.eventManager=void 0,this.needsCollisionDetection=!1,this.initializationCounter=-1,this.fixedBodiesToWatch=[],this.rigidBodyToMesh=new Map,this.nActiveRigidBodies=0,this.collisionEvents=[],this.isExport=!1,this.skipRender=!0,this._staticBVHAttrIds=new WeakMap,this._staticBVHNextAttrId=1,this.processRigidBody=t=>{if(t.bodyType()!==ct.RigidBodyType.Dynamic)return;t.isSleeping()||this.nActiveRigidBodies++;let[e,i,s]=this.rigidBodyToMesh.get(t.handle);if(ut.copy(t.translation()).multiplyScalar(this.pixelsPerMeter),yt.copy(t.rotation()),e.matrixWorld.compose(ut,yt,i),e.hasNonUniformScale&&e.matrixWorld.multiply(e.shearScale),e.dispatchEvent(xt),s){let t=e.cloner;if(t&&void 0===t.objectForSample){t.matrixWorld.copy(e.matrixWorld);for(let e of t.children)e.updateMatrixWorld(!0)}for(let t of e.children)t.updateMatrixWorld(!0)}},this.accumulator=0,this.handleCollisionEvents=(t,e,i)=>{if(!1===i)return;let s,o;if(this.sensorToTriggerEvent[t]?(s=this.sensorToTriggerEvent[t],o=this.sharedGameControlGlobals.colliderToEntity.get(e)):this.sensorToTriggerEvent[e]&&(s=this.sensorToTriggerEvent[e],o=this.sharedGameControlGlobals.colliderToEntity.get(t)),s&&o&&s.isValidTriggeringObject(o))s.dispatch();else{for(let i=this.sharedGameControlGlobals.createdObjects.length-1;i>=0;i--){let s=this.sharedGameControlGlobals.createdObjects[i];if(s.userData.hasCollisionDestroy&&(s.rigidBody?.collider(0).handle===t||s.rigidBody?.collider(0).handle===e)){this.sharedGameControlGlobals.createdObjects.splice(i,1),s.removeFromParent(),requestAnimationFrame(()=>this.sharedGameControlGlobals.rapierWorld?.removeRigidBody(s.rigidBody));break}}if(void 0!==this.gameControl?.object&&this.gameControl.object===this.sharedGameControlGlobals.colliderToEntity.get(t)){let t=this.sharedGameControlGlobals.colliderToEntity.get(e),i=this.sharedGameControlGlobals.entityToCollisionEvents[t.uuid];if(void 0===i)return;for(let s of i)"character"===s.data.target&&this.dispatchCollisionEvent(s,t,e)}else if(void 0!==this.gameControl?.object&&this.gameControl.object===this.sharedGameControlGlobals.colliderToEntity.get(e)){let e=this.sharedGameControlGlobals.colliderToEntity.get(t),i=this.sharedGameControlGlobals.entityToCollisionEvents[e.uuid];if(void 0===i)return;for(let s of i)"character"===s.data.target&&this.dispatchCollisionEvent(s,e,t)}else{let i=this.sharedGameControlGlobals.colliderToEntity.get(t),s=this.sharedGameControlGlobals.entityToCollisionEvents[i.uuid];if(void 0!==s)for(let e of s)"scene"===e.data.target&&this.dispatchCollisionEvent(e,i,t);let o=this.sharedGameControlGlobals.colliderToEntity.get(e),a=this.sharedGameControlGlobals.entityToCollisionEvents[o?.uuid];if(void 0!==a)for(let t of a)"scene"===t.data.target&&this.dispatchCollisionEvent(t,o,e)}}},this.isExport=t.isExport,this.sharedAssets=t.sharedAssets,this.renderer=t.renderer,this.requestRender=t.requestRender,this.domElement=this.renderer.domElement,this.pixelsPerMeter=200,this.gravity=this.page.data.globalPhysics.gravity}get page(){return this.eventContext.page}markIsDestroyTarget(){this.page.traverseVisibleEntity(t=>{let e=t.dataPatched;for(let t of e.events){if(!0===t.data.disabled)continue;let e=t.data.actions?.find(t=>"Destroy"===t.data.type)?.data;if(e)for(let t of e.objects){let e=this.page.scene.find(t);e&&(e.userData.hasDestroy=!0)}}})}markIsDragObject(){this.page.traverseVisibleEntity(t=>{let e=t.dataPatched;for(let t of e.events)if(!0!==t.data.disabled&&"DragDrop"===t.data.type)for(let e of t.data.objects){let t=this.page.scene.find(e);t&&(t.userData.hasDrag=!0)}})}_staticBVHIdOf(t){let e=this._staticBVHAttrIds.get(t);return void 0===e&&(e=this._staticBVHNextAttrId++,this._staticBVHAttrIds.set(t,e)),e}initBVH(){if(null===t())return void f("collision-bvh","trigger/collision detection");let e=[],i=[];if(this.page.traverseChildren(t=>{let s,o=t instanceof r,a=m(t);if(y(t)||o||a)return;s=v(t)?t.object:t;let n=s.dataPatched;if("visibility"===n.physics?.enabled?!n.visible:!n.physics?.enabled)return!0;let h=t.geometry,l=!0===s.userData.hasDestroy,d=!0===s.userData.hasDrag;if(Lt(n)||l||d||s.dataPatched.events.some(t=>!0!==t.data.disabled&&("GameControl"===t.data.type||"Follow"===t.data.type)))return t.updateMatrixWorldRigid(),this.addBoundsTree(t),!0;if(h){let s=h.getAttribute("position");if(void 0!==s&&s.count>0){e.push({geometry:h,matrixWorld:t.matrixWorld}),i.push(h.id,this._staticBVHIdOf(s),s.version,null!==h.index?this._staticBVHIdOf(h.index):-1,null!==h.index?h.index.version:-1);for(let e of t.matrixWorld.elements)i.push(e)}}return!!Gt(t)||void 0}),e.length>0){let s=this._staticBVHCache;if(void 0!==s&&s.signature.length===i.length&&s.signature.every((t,e)=>t===i[e]))return void(this.sharedGameControlGlobals.staticMeshBVH=s.bvh);let o=e.map(t=>dt(t.geometry,t.matrixWorld)),a=l(o,!1),n=new(t())(a);this._staticBVHCache={signature:i,bvh:n},this.sharedGameControlGlobals.staticMeshBVH=n}}addRigidBody(t,e,i){if(lt(t.matrixWorld))return;let s=[],o="geometry"in t?t.geometry:void 0,a=e.dataPatched;if(void 0!==o?.getAttribute("position")&&s.push(dt(o,t.shearScale)),a.physics.fusedBody){let e=this.gatherChildrenGeom(t,s);t.traverseObject(e),t.children.forEach(t=>t.updateMatrixWorld(!0));let i=t.cloner;i&&void 0===i.objectForSample&&"dynamic"===a.physics.rigidBody&&(i.traverseObject(e),i.children.forEach(t=>t.updateMatrixWorld(!0)))}if(s.length>0){let n,r=!1,h=!i.fromCreate&&"dynamic"===a.physics.rigidBody||i.fromCreate&&i.dynamic;h?(n=ct.RigidBodyDesc.dynamic(),n.setLinearDamping(a.physics.damping).setAngularDamping(a.physics.damping).setAdditionalMass(1e-9).setGravityScale(a.physics.gravityScale).enabledRotations(...a.physics.enabledRotation).enabledTranslations(...a.physics.enabledTranslation)):(i.hasTransformAnim||i.hasFollow||i.hasDrag)&&!i.fromCreate?(n=ct.RigidBodyDesc.kinematicPositionBased(),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(t),r=!0):n=ct.RigidBodyDesc.fixed();let d=l(s);(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).decompose(ut,yt,vt),t.position0=ut.clone().divideScalar(this.pixelsPerMeter),t.rotation0=yt.clone(),ut.divideScalar(this.pixelsPerMeter),n.setTranslation(ut.x,ut.y,ut.z).setRotation(yt),o?d?.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter):d?.scale(vt.x/this.pixelsPerMeter,vt.y/this.pixelsPerMeter,vt.z/this.pixelsPerMeter);let c=this.sharedGameControlGlobals.rapierWorld.createRigidBody(n);h?this.rigidBodyToMesh.set(c.handle,[t,vt.clone(),a.physics.fusedBody]):r?this.sharedGameControlGlobals.kinematicBodyToEntity.set(c.handle,t):this.fixedBodiesToWatch.push([t,c,(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).clone()]);let p=!(void 0===a.geometry||"SubdivGeometry"===a.geometry.type||"NonParametricGeometry"===a.geometry.type||"BooleanGeometry"===a.geometry.type||"VectorGeometry"===a.geometry.type||"StarGeometry"===a.geometry.type||"RectangleGeometry"===a.geometry.type||"EllipseGeometry"===a.geometry.type||"TriangleGeometry"===a.geometry.type||"TorusGeometry"===a.geometry.type||"HelixGeometry"===a.geometry.type);try{this.addCollider(c,a.physics,d,e,p)}catch{try{this.addCollider(c,a.physics,d,e,!1)}catch(t){console.error(t)}}t.rigidBody=c}}addBoundsTree(e){let i=[];if(void 0!==e.geometry?.getAttribute("position")&&e.geometry?.getAttribute("position").count>0&&i.push(dt(e.geometry,e.shearScale)),e.traverseObject(this.gatherChildrenGeom(e,i)),e.children.forEach(t=>t.updateMatrixWorld(!0)),i.length>0){let s=l(i,!1);e.bvhGeometry=s,s.getAttribute("position").count>0&&(e.bvhGeometry.boundsTree=new(t())(s),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(e))}}addCollider(t,e,i,s,o=!0){if(0===i?.getAttribute("position").count||0===i?.getIndex()?.count)return;let a;i&&(a="trimesh"===e.colliderType?ct.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array):ct.ColliderDesc.convexMesh(i.getAttribute("position").array,o?i.getIndex().array:void 0)),a.setFrictionCombineRule(ct.CoefficientCombineRule.Average).setRestitutionCombineRule(ct.CoefficientCombineRule.Average).setDensity(e.density).setFriction(e.friction).setRestitution(e.restitution);let n=this.sharedGameControlGlobals.rapierWorld.createCollider(a,t);this.sharedGameControlGlobals.colliderToEntity.set(n.handle,s),this.sharedGameControlGlobals.entityToCollisionEvents[s.uuid]?.some(t=>"scene"===t.target)&&n.setActiveEvents(ct.ActiveEvents.COLLISION_EVENTS)}gatherChildrenGeom(t,e){let i=Gt(t);return(s,o)=>{if(0===o)return;if(i&&s.parent===t)return!0;let a;if(y(s)){if(!s.objectForSample)return!0===s.object.dataPatched.physics.fusedBody&&"dynamic"===s.object.dataPatched.physics.rigidBody||void 0;if(s.objectForSample.dataPatched.physics.fusedBody)return;a=s.object}else if(v(s))a=s.object;else if(a=s,a.dataPatched.cloner?.hideBase)return!0;let n=a.dataPatched;if("visibility"===n.physics.enabled?!n.visible:!n.physics.enabled)return!0;1===o?t.hasNonUniformScale?s.matrixWorld.multiplyMatrices(t.shearScale,s.hiddenMatrix):s.matrixWorld.copy(s.hiddenMatrix):s.matrixWorld.multiplyMatrices(s.parent.matrixWorld,s.hiddenMatrix),s.matrixWorld.multiply(s.matrix);let r=s.geometry;return void 0!==r?.getAttribute("position")&&e.push(dt(r,s.matrixWorld)),!!Gt(s)||void 0}}activate(t){if(this.isEnabled)return;this.isEnabled=!0,this.eventManager=t,this.usePhysics=this.page.data.globalPhysics.usePhysics;let e=this.page.playCamera,i=!1;this.page.traverseEntity(t=>{for(let e of t.dataPatched.events)if(!1===e.data.disabled&&"Trigger"===e.data.type)return this.needsCollisionDetection=!0,!0});let s=O();if(null!==s?i=s.setup({manager:this,camera:e,renderer:this.renderer,sharedAssets:this.sharedAssets,eventContext:this.eventContext,isExport:this.isExport})||i:null!==this.page.data.publish.gameControlObject&&f("game-controls","the scene's game controls"),!1===i){let{enableRotate:t,enablePan:i,enableZoom:s,autoRotate:o,hoverRotatePanMode:a}=this.eventManager.publish.orbitControls;(t||i||s||o||0!==a)&&(this.orbitControls=new it(e,this.renderer.domElement,{isExport:this.isExport,isPlayMode:!0}),this.orbitControls.addEventListener("change",this.requestRender),this.orbitControls.addEventListener("end",this.requestRender),this.orbitControls.addEventListener("start",this.requestRender),this.orbitControls.fromJSON(this.eventManager.publish.orbitControls,this.eventManager.publish.mouseEventTarget),this.orbitControls.useKeyEvents=!1,this.orbitControls.addEventListenersToCamera(),this.orbitControls.connect(),this.orbitControls.update())}let o=this.renderer.domElement.width/this.renderer.getPixelRatio(),a=this.renderer.domElement.height/this.renderer.getPixelRatio();O()?.createJoysticks(this,o,a),this.markIsDestroyTarget(),this.markIsDragObject(),this.rebuildBVH(),this.initializationCounter++,window.setTimeout(()=>{this.collisionEvents.forEach(t=>t.initialDisabled=!1)},80)}initPhysics(){this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=new ct.World(new ct.Vector3(0,this.gravity,0)),this.events=new ct.EventQueue(!0);let t=[],e=[];if(this.page.traverseChildren(i=>{let s;if(y(i)){if(!i.objectForSample)return!0===i.object.dataPatched.physics.fusedBody&&"dynamic"===i.object.dataPatched.physics.rigidBody||void 0;if(i.objectForSample.dataPatched.physics.fusedBody)return;s=i.object}else if(v(i))s=i.object;else{if(m(i)||i instanceof r)return;if(s=i,!1===s.dataPatched.cloner?.disabled&&s.dataPatched.cloner?.hideBase&&!0!==s.dataPatched.physics?.fusedBody)return!0}let o,a=s.dataPatched;for(let t of a.events)!0!==t.data.disabled&&"GameControl"===t.data.type&&(o=t.data);if(!a.physics||("visibility"===a.physics.enabled?!a.visible:!a.physics.enabled))return!0;i.updateMatrixWorldRigid();let n=Lt(a),h=!1,l=s.userData.hasDestroy,d=s.userData.hasDrag,c=!1;for(let t of a.events)if(!0!==t.data.disabled)if("Collision"===t.data.type){h=!0;let e=new pt(t.id,t.data,s,this.page,this.sharedAssets,this.eventManager);e.initialDisabled=!0,this.collisionEvents.push(e),this.sharedGameControlGlobals.entityToCollisionEvents[s.uuid]&&this.sharedGameControlGlobals.entityToCollisionEvents[s.uuid].every(e=>e.id!==t.id)?this.sharedGameControlGlobals.entityToCollisionEvents[s.uuid].push(e):this.sharedGameControlGlobals.entityToCollisionEvents[s.uuid]=[e]}else if("Follow"===t.data.type){c=!0;let e=t.data.target;i.traverseVisible(t=>{t.userData.isFollowingObj=e})}"dynamic"===a.physics.rigidBody&&!1===a.physics.fusedBody&&(i.matrixWorldFusedFalse=i.matrixWorld.clone());let p=i.geometry;if(void 0!==o){let t=ct.RigidBodyDesc.kinematicPositionBased();(i.hasNonUniformScale?i.matrixWorldRigid:i.matrixWorld).decompose(ut,yt,vt),i.position0=ut.clone().divideScalar(this.pixelsPerMeter),i.rotation0=yt.clone(),ut.divideScalar(this.pixelsPerMeter),t.setTranslation(ut.x,ut.y,ut.z).setRotation(yt);let e,n=this.sharedGameControlGlobals.rapierWorld.createRigidBody(t);i.rigidBody=n,e="sphere"===o.collider.type?ct.ColliderDesc.ball(o.collider.radius/this.pixelsPerMeter):"capsule"===o.collider.type?ct.ColliderDesc.capsule((o.collider.height/2-o.collider.radius)/this.pixelsPerMeter,o.collider.radius/this.pixelsPerMeter):ct.ColliderDesc.cuboid(o.collider.width/this.pixelsPerMeter/2,o.collider.height/this.pixelsPerMeter/2,o.collider.depth/this.pixelsPerMeter/2),e.setFrictionCombineRule(ct.CoefficientCombineRule.Average).setDensity(a.physics.density).setFriction(a.physics.friction).setRestitution(0).setRestitutionCombineRule(ct.CoefficientCombineRule.Min);let r=this.sharedGameControlGlobals.rapierWorld.createCollider(e,n);this.sharedGameControlGlobals.colliderToEntity.set(r.handle,s),ut.fromArray(o.collider.position.map(t=>"number"==typeof t?t:0)).multiply(vt.setFromMatrixScale(s.matrixWorld)).divideScalar(this.pixelsPerMeter),r.setTranslationWrtParent(ut);let h=(new C).setFromEuler((new S).setFromVector3((new M).fromArray(o.collider.rotation.map(t=>"number"==typeof t?t:0))));r.setRotationWrtParent(h),r.setActiveEvents(ct.ActiveEvents.COLLISION_EVENTS),this.generateSensorColliderDescs(s,!0)}else"dynamic"===a.physics.rigidBody||n||c||l||d||h?(this.addRigidBody(i,s,{hasFollow:c,hasTransformAnim:n,hasDrag:d}),this.generateSensorColliderDescs(s,a.physics.fusedBody)):(p&&t.push(dt(p,i.matrixWorld)),a.physics.fusedBody&&!Gt(i)&&i.traverseObject((e,i)=>{if(0===i)return;let s;if(y(e)){if(!e.objectForSample)return!0===e.object.dataPatched.physics.fusedBody&&"dynamic"===e.object.dataPatched.physics.rigidBody||void 0;if(e.objectForSample.dataPatched.physics.fusedBody)return;s=e.object}else{if(m(e)||e instanceof r)return;if(v(e))s=e.object;else if(s=e,s.dataPatched.cloner?.hideBase)return!0}let o=s.dataPatched;if("visibility"===o.physics.enabled?!o.visible:!o.physics.enabled)return!0;let a=e.geometry;return void 0!==a?.getAttribute("position")&&t.push(dt(a,e.matrixWorld)),!!Gt(e)||void 0}),this.generateSensorColliderDescs(s,a.physics.fusedBody,e));return!(!0!==a.physics?.fusedBody&&!o&&!Gt(i))||void 0}),0===t.length)return;let i=l(t);i.scale(1/this.pixelsPerMeter,1/this.pixelsPerMeter,1/this.pixelsPerMeter);let s=ct.RigidBodyDesc.fixed(),o=this.sharedGameControlGlobals.rapierWorld.createRigidBody(s),a=ct.ColliderDesc.trimesh(i.getAttribute("position").array,i.getIndex().array).setFrictionCombineRule(ct.CoefficientCombineRule.Multiply).setRestitutionCombineRule(ct.CoefficientCombineRule.Multiply).setFriction(1).setRestitution(1);this.sharedGameControlGlobals.rapierWorld.createCollider(a,o);for(let[t,i]of e){let e=this.sharedGameControlGlobals.rapierWorld.createCollider(t,o);this.sensorToTriggerEvent[e.handle]=i}}updatePositions(){return this.nActiveRigidBodies=0,this.sharedGameControlGlobals.rapierWorld.forEachRigidBody(this.processRigidBody),this.nActiveRigidBodies>0}rebuildBVH(){this.usePhysics?this.initPhysics():(this.page.traverseEntity(t=>{for(let e of t.dataPatched.events)if("Trigger"===e.data.type&&!0!==e.data.disabled){let i=new mt(e.id,e.data,t,this.page,this.sharedAssets,this.eventManager),s=(new x).compose(ft.fromArray(e.data.position.map(t=>"number"==typeof t?t:0)),Pt.setFromEuler(gt.fromArray(e.data.rotation.map(t=>"number"==typeof t?t:0))),Et);if("box"===e.data.triggerZone){let o=new w;o.min.fromArray(e.data.size.map(t=>"number"==typeof t?t:0)).multiplyScalar(-.5),o.max.fromArray(e.data.size.map(t=>"number"==typeof t?t:0)).multiplyScalar(.5),this.sharedGameControlGlobals.triggers.push([o,s,t,i])}else this.sharedGameControlGlobals.triggers.push([e.data.radius,s,t,i])}}),this.needsCollisionDetection&&this.initBVH())}disconnectEvents(){this.collisionEvents.forEach(t=>t.disconnect()),this.sharedGameControlGlobals.triggers.forEach(t=>t[3].disconnect()),this.sharedGameControlGlobals.triggers.length=0}deactivate(){if(this.isEnabled){this.isEnabled=!1,this.page.traverse(t=>{let e=t;e.matrixWorldFusedFalse&&(e.matrixWorldFusedFalse=void 0),e.rigidBody&&(e.rigidBody=void 0),e.position0&&(e.position0=void 0),e.rotation0&&(e.rotation0=void 0)}),this.sharedGameControlGlobals.rapierWorld?.free(),this.sharedGameControlGlobals.rapierWorld=void 0,this.sharedGameControlGlobals.staticMeshBVH=void 0,this.accumulator=0,this.sharedGameControlGlobals.entitiesWithTransformAnim=[],this.sharedGameControlGlobals.kinematicBodyToEntity.clear(),this.fixedBodiesToWatch=[],this.disconnectEvents(),this.gameControl?.reset(),this.gameControl?.dispose(),this.gameControl=null,this.initializationCounter=-1,this.joysticks.forEach(([t,e])=>{t?.destroy(),e.remove()}),this.joystickToGameControls=[],this.joysticks=[],this.orbitControls&&(this.orbitControls.dispose(),this.orbitControls=void 0),this.navigationMeshWrapper?.dispose(),this.navigationMeshWrapper=void 0;for(let t of Object.values(this.sharedGameControlGlobals.entityToCollisionEvents))t.forEach(t=>t.disconnect());this.sharedGameControlGlobals.entityToCollisionEvents={},this.page.updateMatrixWorld(!0)}}update(t){if(!this.isEnabled)return!0;let e=!0;if(void 0!==this.orbitControls&&this.orbitControls.needsUpdate&&(this.orbitControls.update(),e=!this.orbitControls.isCurrentlyDamping),this.initializationCounter>=0&&this.initializationCounter<2?(this.initializationCounter++,e=!1):2===this.initializationCounter&&this.gameControl&&(e=!this.gameControl.update(t)&&e),!1===this.usePhysics&&this.checkTrigger(),this.usePhysics){let i=.016666666666666666;if(0===t)e=this.stepPhysics()&&e;else{let s=t/1e3;s<i&&s>.55*i&&(s=i),this.accumulator+=s;let o=performance.now(),a=0,n=6;for(;this.accumulator>=i&&a<n&&(e=this.stepPhysics()&&e,this.accumulator-=i,a++,!(performance.now()-o>1e3*i)););this.accumulator=this.accumulator%i}}this.skipRender=e}recordPhysicsPose(t){(t.hasNonUniformScale?t.matrixWorldRigid:t.matrixWorld).decompose(ut,yt,vt);let e=t;void 0===e.prevQ?(e.prevQ=yt.clone(),e.prevT=ut.clone()):(e.prevQ.copy(yt),e.prevT.copy(ut))}promoteMovedFixedBodies(){for(let t=this.fixedBodiesToWatch.length-1;t>=0;t--){let[e,i,s]=this.fixedBodiesToWatch[t];(e.hasNonUniformScale?e.matrixWorldRigid:e.matrixWorld).equals(s)||(i.setBodyType(ct.RigidBodyType.KinematicPositionBased,!0),this.sharedGameControlGlobals.kinematicBodyToEntity.set(i.handle,e),this.sharedGameControlGlobals.entitiesWithTransformAnim.push(e),this.fixedBodiesToWatch.splice(t,1))}}clampPushedBodies(){let t=this.gameControl?.object.rigidBody;if(void 0===t)return;let e=this.sharedGameControlGlobals.rapierWorld,i=t.linvel(),s=t.translation(),o=Math.hypot(i.x,i.z);for(let a=0;a<t.numColliders();a++){let n=t.collider(a);e.contactPairsWith(n,t=>{let a=t.parent();if(null===a||!a.isDynamic())return;let r=a.translation(),h=-1/0,l=0,d=0;if(e.contactPair(n,t,t=>{let e=t.normal(),o=e.x*(r.x-s.x)+e.y*(r.y-s.y)+e.z*(r.z-s.z)<0?-1:1;if(Math.abs(e.y)>.7)return;let a=o*e.x,n=o*e.z,c=Math.hypot(a,n);if(c<1e-4)return;let p=(i.x*a+i.z*n)/c;p>h&&(h=p,l=a/c,d=n/c)}),h===-1/0)return;let c=i.x*l+i.z*d;if(c<-Dt)return;let p=a.linvel();if(o>Dt&&c>Dt){let t=p.x*l+p.z*d;if(t<=0)return;let e=Math.min(t,c);return void a.setLinvel({x:l*e,y:p.y,z:d*e},!0)}let m=p.x*l+p.z*d-Math.max(0,c);if(m<=0)return;let u=.5*m;a.setLinvel({x:p.x-l*u,y:p.y,z:p.z-d*u},!0)})}}stepPhysics(){this.promoteMovedFixedBodies();for(let t of this.sharedGameControlGlobals.kinematicBodyToEntity.values())this.recordPhysicsPose(t),t.rigidBody.setNextKinematicTranslation(ut.divideScalar(this.pixelsPerMeter)),t.rigidBody.setNextKinematicRotation(yt);for(let t of this.sharedGameControlGlobals.entitiesWithTransformAnim)!0!==t.rigidBody?.isKinematic()&&this.recordPhysicsPose(t);return this.sharedGameControlGlobals.rapierWorld.step(this.events),this.clampPushedBodies(),this.events?.drainCollisionEvents(this.handleCollisionEvents),!this.updatePositions()}dispatchCollisionEvent(t,e,i){let s,o=(this.sharedGameControlGlobals.rapierWorld?.getCollider(i))._parent;if(e.cloner)for(let t of e.cloner.children)if(t.rigidBody===o){s=t;break}t.dispatch(s),e.dispatchEvent(wt)}updateUseWindowEvents(t){this.orbitControls?.updateUseWindowEvents(t)}generateSensorColliderDescs(t,e,i){let s=Mt.copy(t.matrixWorld).invert();t.traverseEntity((o,a)=>{if(!1===e&&1===a)return!0;for(let e of o.dataPatched.events)if("Trigger"===e.data.type&&!0!==e.data.disabled){let a,n=new mt(e.id,e.data,o,this.page,this.sharedAssets,this.eventManager);if(a="box"===e.data.triggerZone?ct.ColliderDesc.cuboid(...e.data.size.map(t=>("number"==typeof t?t:1)/(2*this.pixelsPerMeter))):ct.ColliderDesc.ball(e.data.radius/this.pixelsPerMeter),a.setDensity(0).setSensor(!0).setActiveEvents(ct.ActiveEvents.COLLISION_EVENTS),ft.fromArray(e.data.position.map(t=>"number"==typeof t?t:0)),Pt.setFromEuler(gt.fromArray(e.data.rotation.map(t=>"number"==typeof t?t:0))),Ct.compose(ft,Pt,Et).premultiply(o.matrixWorld),i?(Ct.decompose(ft,Pt,bt),a.setActiveCollisionTypes(ct.ActiveCollisionTypes.KINEMATIC_FIXED|ct.ActiveCollisionTypes.DYNAMIC_FIXED)):(Ct.premultiply(s).decompose(ft,Pt,bt),t.rigidBody.bodyType()===ct.RigidBodyType.Dynamic||(t.rigidBody.bodyType()===ct.RigidBodyType.Fixed?a.setActiveCollisionTypes(ct.ActiveCollisionTypes.KINEMATIC_FIXED|ct.ActiveCollisionTypes.DYNAMIC_FIXED):a.setActiveCollisionTypes(ct.ActiveCollisionTypes.KINEMATIC_KINEMATIC|ct.ActiveCollisionTypes.DYNAMIC_KINEMATIC))),ft.divideScalar(this.pixelsPerMeter),a.setTranslation(ft.x,ft.y,ft.z),a.setRotation(Pt),i)i.push([a,n]);else{let e=this.sharedGameControlGlobals.rapierWorld.createCollider(a,t.rigidBody);this.sensorToTriggerEvent[e.handle]=n}}})}checkTrigger(){let t;for(let e=0;e<this.sharedGameControlGlobals.triggers.length;e++){let[i,s,o,a]=this.sharedGameControlGlobals.triggers[e];for(let e=0;e<this.sharedGameControlGlobals.entitiesWithTransformAnim.length;e++){let n=this.sharedGameControlGlobals.entitiesWithTransformAnim[e];if(o===n||!1===a.isValidTriggeringObject(p.is(n)?n:n.object))continue;let r=Mt.copy(o.matrixWorld).decompose(ft,Tt,bt).compose(ft,Tt,Et).multiply(s),h=Ct.copy(n.matrixWorld).invert().multiply(r),l=n.bvhGeometry.boundsTree;i instanceof w?t=l.intersectsBox(i,h):(St.radius=i,St.center.setFromMatrixPosition(h),t=l.intersectsSphere(St)),t?-1===a.currentIntersectedObjects.indexOf(n)&&(a.currentIntersectedObjects.push(n),a.dispatch(),o.dispatchEvent(Rt)):a.currentIntersectedObjects=a.currentIntersectedObjects.filter(t=>t!==n)}}}},It=new Promise(t=>{Bt=t});function Ft(t){return Wt||(Wt=async function(){let e=t??"https://cdn.spline.design/@splinetool/runtime@2.0.5/build";typeof window<"u"&&(At=new URL(e.endsWith("/")?e:`${e}/`,window.location.href).href);let i=import("./navmesh.js"),[s,o]=await Promise.all([i,fetch(`${e}/navmesh.wasm`).then(t=>t.arrayBuffer())]),a=s.default,n=await a({wasmBinary:o});Bt(n)}())}export{it as a,ht as b,B as c,W as d,I as e,dt as f,wt as g,jt as h,Lt as i,Ot as j,It as k,At as l,Ft as m};
@@ -1 +1 @@
1
- import{a as t}from"./runtime-chunk-I5QFGBIU.js";import{d as e}from"./runtime-chunk-RF63UVAU.js";import{Sc as s}from"./runtime-chunk-VGN7YHB7.js";var r=class extends(e(s,t)){constructor(t,e){super(),this.super_Entity(t,e),this.objectHelper.update(),"Empty"===this.data.type&&(this.objectHelper.visible=!1)}updateState(t,e){this.updateState_Entity(t,e),"buffer"in t&&1===Object.keys(t).length&&e.scene.reloadSplats()}};export{r as a};
1
+ import{a as t}from"./runtime-chunk-DZOSSY2K.js";import{d as e}from"./runtime-chunk-CDZQF4NV.js";import{Sc as s}from"./runtime-chunk-VGN7YHB7.js";var r=class extends(e(s,t)){constructor(t,e){super(),this.super_Entity(t,e),this.objectHelper.update(),"Empty"===this.data.type&&(this.objectHelper.visible=!1)}updateState(t,e){this.updateState_Entity(t,e),"buffer"in t&&1===Object.keys(t).length&&e.scene.reloadSplats()}};export{r as a};
@@ -1 +1 @@
1
- import{v as e}from"./runtime-chunk-OOC7YSI5.js";import{Ec as t,Fc as a,Fd as s,Gc as i,Ge as r,Ib as n,Oc as h,Tc as o,Wd as l,Xd as d,Zc as c,kd as u,ld as g}from"./runtime-chunk-VGN7YHB7.js";var p=null;function b(e){p=e}function m(){return p}var S=null;function f(e){S=e}function M(){return S}var y=new o;function x(e,t,a){return y.setRGB(e,t,a,n),{r:y.r,g:y.g,b:y.b}}var R=(e,t)=>"number"==typeof e&&Number.isFinite(e)?e:t,w=e=>Array.isArray(e)&&"number"==typeof e[0]&&"number"==typeof e[1]?[e[0],e[1]]:[0,0];function v(e,t,a){let s,i=R(e.angle,0),[r,n]=w(e.offset),[h,o]=w(e.morph),l=e.colors??[],d=e.steps??[],c=Math.min(10,l.length,d.length);if(0===c)return[1,1,1,1];if(1===e.gradientType){let e=3*(t+h)-(t+r)-1,l=3*(a+o)-(a+n)-1;s=Math.hypot(e,l)+i}else if(2===e.gradientType){let e=-1*Math.atan2(t+h-.5+r,a+o-.5+n),l=i/Math.PI/-2+.5*e/Math.PI;s=l-Math.floor(l)}else{let e=.5+h/(0!==t?t:1e-6),l=o/(0!==a?a:1e-6),d=Math.cos(i)*e-Math.sin(i)*l,c=Math.sin(i)*e+Math.cos(i)*l,u=d*d+c*c;s=u>1e-12?(((t-.5+r)/2+d/2)*d+((a-.5+n)/2+c/2)*c)/u:0}let u=l[0][0],g=l[0][1],p=l[0][2],b=l[0][3];for(let t=1;t<c;t++){let a=d[t-1],i=d[t]-a,r=0!==i?Math.min(1,Math.max(0,(s-a)/i)):s>=a?1:0;e.smooth&&(r=r*r*(3-2*r)),u+=(l[t][0]-u)*r,g+=(l[t][1]-g)*r,p+=(l[t][2]-p)*r,b+=(l[t][3]-b)*r}return[u,g,p,b]}function A(e,t){let a=e,s=a?.data?.layers;if(s&&"function"==typeof s.forEach){let e=t,a=[];return s.forEach(t=>{let s=t.data;if(!1===s.visible||!0===s.isMask)return;let i=R(s.alpha,1);if(!(i<=0))if("color"===s.type){let t,r=s.color;"string"==typeof r?t="function"==typeof e?.color?e.color(r):void 0:r&&"number"==typeof r.r&&(t=r),t&&a.push({kind:"color",layer:s,rgb:{...x(t.r,t.g,t.b),a:t.a??1},alpha:i})}else"gradient"===s.type&&a.push({kind:"gradient",layer:s,alpha:i})}),0===a.length?null:(e,t)=>{let s=1,i=1,r=1,n=!0;for(let h of a){let a,o,l,d;if("color"===h.kind)({r:a,g:o,b:l}=h.rgb),d=h.rgb.a;else{let[s,i,r,n]=v(h.layer,e,t);({r:a,g:o,b:l}=x(s,i,r)),d=n}let c=n?1:Math.min(1,Math.max(0,d*h.alpha));s+=(a-s)*c,i+=(o-i)*c,r+=(l-r)*c,n=!1}return{r:s,g:i,b:r}}}if(a?.color&&!0===a.color.isColor){let{r:e,g:t,b:s}=a.color;return()=>({r:e,g:t,b:s})}return null}var j=32,I=16384,W=32*I,H=100;function O(e,t){if("torus"===e){let e=t()*Math.PI*2,a=t()*Math.PI*2,s=Math.cos(e),i=Math.sin(e),r=Math.cos(a),n=Math.sin(a);return{x:(1.4+.7*r)*s,y:-(1.4+.7*r)*i,z:.7*n,nx:r*s,ny:-r*i,nz:n,cr:1,cg:1,cb:1}}if("cylinder"===e){let e=t()*Math.PI*2,a=Math.cos(e),s=Math.sin(e);return{x:.8*a,y:1.6*(t()-.5),z:.8*s,nx:a,ny:0,nz:s,cr:1,cg:1,cb:1}}let a=t()*Math.PI*2,s=2*t()-1,i=Math.acos(s),r=Math.sin(i)*Math.cos(a),n=Math.cos(i),h=Math.sin(i)*Math.sin(a);return{x:r,y:n,z:h,nx:r,ny:n,nz:h,cr:1,cg:1,cb:1}}function C(e){let{geometry:t,matrix:a}=e,s=t.getAttribute("position");if(!s||s.count<3)return null;let r=t.getAttribute("normal"),n=t.getAttribute("uv"),h=t.getAttribute("color"),o=t.getIndex(),l=o?o.count/3:s.count/3;if(l<1)return null;let d=(e,t)=>o?o.getX(3*e+t):3*e+t,c=a?a.elements:null,u=a?(new i).getNormalMatrix(a).elements:null,g=e=>{let t=s.getX(e),a=s.getY(e),i=s.getZ(e);return c?c[0]*t+c[4]*a+c[8]*i+c[12]:t},p=e=>{let t=s.getX(e),a=s.getY(e),i=s.getZ(e);return c?c[1]*t+c[5]*a+c[9]*i+c[13]:a},b=e=>{let t=s.getX(e),a=s.getY(e),i=s.getZ(e);return c?c[2]*t+c[6]*a+c[10]*i+c[14]:i},m=new Float64Array(l),S=0;for(let e=0;e<l;e++){let t=d(e,0),a=d(e,1),s=d(e,2),i=g(t),r=p(t),n=b(t),h=g(a)-i,o=p(a)-r,l=b(a)-n,c=g(s)-i,u=p(s)-r,f=b(s)-n,M=o*f-l*u,y=l*c-h*f,x=h*u-o*c;S+=.5*Math.sqrt(M*M+y*y+x*x),m[e]=S}return S<=0?null:{total:S,sample:(t,a)=>{let s=0,i=l-1;for(;s<i;){let e=s+i>>1;m[e]<t?s=e+1:i=e}let o=s,c=d(o,0),S=d(o,1),f=d(o,2),M=a(),y=a();M+y>1&&(M=1-M,y=1-y);let x,R,w,v=1-M-y,A=g(c)*v+g(S)*M+g(f)*y,j=p(c)*v+p(S)*M+p(f)*y,I=b(c)*v+b(S)*M+b(f)*y;if(r){if(x=r.getX(c)*v+r.getX(S)*M+r.getX(f)*y,R=r.getY(c)*v+r.getY(S)*M+r.getY(f)*y,w=r.getZ(c)*v+r.getZ(S)*M+r.getZ(f)*y,u){let e=u[0]*x+u[3]*R+u[6]*w,t=u[1]*x+u[4]*R+u[7]*w,a=u[2]*x+u[5]*R+u[8]*w;x=e,R=t,w=a}}else{let e=g(c),t=p(c),a=b(c),s=g(S)-e,i=p(S)-t,r=b(S)-a,n=g(f)-e,h=p(f)-t,o=b(f)-a;x=i*o-r*h,R=r*n-s*o,w=s*h-i*n}let W=Math.sqrt(x*x+R*R+w*w)||1,H=1,O=1,C=1;if(h)H=h.getX(c)*v+h.getX(S)*M+h.getX(f)*y,O=h.getY(c)*v+h.getY(S)*M+h.getY(f)*y,C=h.getZ(c)*v+h.getZ(S)*M+h.getZ(f)*y;else if(e.sampleColor){let t=n?n.getX(c)*v+n.getX(S)*M+n.getX(f)*y:.5,a=n?n.getY(c)*v+n.getY(S)*M+n.getY(f)*y:.5,s=e.sampleColor(t,a);s&&(H=s.r,O=s.g,C=s.b)}return{x:A,y:j,z:I,nx:x/W,ny:R/W,nz:w/W,cr:H,cg:O,cb:C}}}}function F(e){let t=Math.min(Math.max(1,Math.floor(e.guideStrands)),I),a=function(e){let t=e>>>0;return()=>{t|=0,t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}(e.seed??1337),s="object"===e.shape&&e.sampler,i=s?e.samplerRadius??H:H,r=new Float32Array(4*W),n=new Float32Array(W),h=new Float32Array(4*I).fill(1);for(let o=0;o<t;o++){let t=s?e.sampler(a):O(e.shape,a),l=s?t.x:t.x*i,d=s?t.y:t.y*i,c=s?t.z:t.z*i,{nx:u,ny:g,nz:p}=t;h[4*o+0]=t.cr,h[4*o+1]=t.cg,h[4*o+2]=t.cb;let b,m,S,f=32*o,M=(1.8+.8*a())*e.hairLength*i/31,y=.5+1.5*a(),x=(.02+.06*a())*i;Math.abs(g)<.99?(b=-p,m=0,S=u):(b=1,m=0,S=0);let R=Math.sqrt(b*b+m*m+S*S)||1;for(let e=0;e<32;e++){let t=e/31,a=t*t*.4*i,s=x*Math.sin(t*y*Math.PI*2),h=4*(f+e);r[h+0]=l+u*M*e+s*b/R,r[h+1]=d+g*M*e-a+s*m/R,r[h+2]=c+p*M*e+s*S/R,r[h+3]=0===e?0:1,e<31&&(n[f+e]=M)}}return{initialPositions:r,restLengths:n,unitScale:i,rootColors:h}}var k=1/60,z=4,P=new h,G=new t,L=new a,X=new a,Y=class extends e{constructor(e,t,a){super(e,t),this.type="HairSystem",this.isHairSystem=!0,this.simRunning=!1,this.previewRequested=!1,this.playModeActive=!1,this.pendingSimSeconds=0,this.simTime=0,this.resetRequested=!0,this.generation=0,this.baseFoundAtRegen=!1,this.baseSourceGeomsAtRegen=[],this.baseSourceHashesAtRegen=[],this.baseColorHashAtRegen=0,this.baseScaleAtRegen=0,this.classicFallbackWarned=!1,this.regenSnapshot=null,this.context=a,this.data=t,this.geometry.setAttribute("position",new c(new Float32Array(0),3)),this.material=new u({colorWrite:!1,depthWrite:!1}),this.frustumCulled=!1,this.scalpMesh=new g(new l(H,48,32),new u({color:5448477})),this.scalpMesh.name="HairScalp",this.add(this.scalpMesh);let s=new r;s.setAttribute("position",new c(new Float32Array(12),3)),s.setIndex([0,2,1,2,3,1]),s.instanceCount=0,this.ribbonMesh=new g(s,new u({visible:!1})),this.ribbonMesh.name="HairRibbons",this.ribbonMesh.frustumCulled=!1,this.ribbonMesh.visible=!1,this.ribbonMesh.matrixAutoUpdate=!1,this.ribbonMesh.updateMatrixWorld=()=>{this.ribbonMesh.matrixWorld.identity()},this.ribbonMesh.updateWorldMatrix=()=>{this.ribbonMesh.matrixWorld.identity()},this.add(this.ribbonMesh),this.activeGuideStrands=t.guideStrands,this.roots=this.buildRoots(),this.regenSnapshot={guideStrands:t.guideStrands,hairLength:t.hairLength,spreadRadius:t.spreadRadius,headShape:t.headShape,baseObjectId:t.baseObjectId},this.applyScalpState(),this.applyShadowState(),this.syncSimRunning()}update(e){!this.simRunning||(this.pendingSimSeconds=Math.min(this.pendingSimSeconds+e/1e3,4*k*2))}get isSimulating(){return(this.simRunning||this.resetRequested)&&this.visible}startPreview(){this.previewRequested=!0,this.syncSimRunning()}stopPreview(){this.previewRequested=!1,this.syncSimRunning()}setPlayMode(e){this.playModeActive=e,e&&this.resetSimulation(),this.syncSimRunning()}resetSimulation(){this.resetRequested=!0,this.pendingSimSeconds=0,this.simTime=0}warnClassicFallbackOnce(){this.classicFallbackWarned||(this.classicFallbackWarned=!0,console.warn("[spline] Hair System strands require the WebGPU renderer — the WebGL fallback shows only the scalp. Reload with ?renderer=webgpu in a WebGPU-capable browser."))}syncSimRunning(){this.simRunning=this.playModeActive||this.previewRequested||this.data.autoPlay}updateState(e,t){super.updateState(e,t),this.updateHairState(e)}updateHairState(e){if((void 0!==e.guideStrands||void 0!==e.hairLength||void 0!==e.spreadRadius||void 0!==e.headShape||void 0!==e.baseObjectId)&&this.regenerate(),(void 0!==e.headShape||void 0!==e.baseObjectId)&&this.applyScalpState(),void 0!==e.headColor){let t=this.scalpMesh.material;!0===t.isMeshBasicMaterial&&t.color.setRGB(e.headColor.r,e.headColor.g,e.headColor.b,n)}(void 0!==e.castShadow||void 0!==e.receiveShadow)&&this.applyShadowState(),void 0!==e.autoPlay&&this.syncSimRunning()}applyShadowState(){let e=this.data.castShadow??!0,t=this.data.receiveShadow??!0;this.scalpMesh.castShadow=e,this.scalpMesh.receiveShadow=t,this.ribbonMesh.castShadow=e,this.ribbonMesh.receiveShadow=t}regenerate(){this.activeGuideStrands=Math.max(1,Math.min(Math.floor(this.data.guideStrands),16384)),this.roots=this.buildRoots(),this.generation++,this.regenSnapshot={guideStrands:this.data.guideStrands,hairLength:this.data.hairLength,spreadRadius:this.data.spreadRadius,headShape:this.data.headShape,baseObjectId:this.data.baseObjectId},this.resetSimulation()}checkDataDrift(){let e=this.data,t=this.regenSnapshot;if(null===t||t.guideStrands!==e.guideStrands||t.hairLength!==e.hairLength||t.spreadRadius!==e.spreadRadius||t.headShape!==e.headShape||t.baseObjectId!==e.baseObjectId){let a=null===t||t.headShape!==e.headShape||t.baseObjectId!==e.baseObjectId;this.regenerate(),a&&this.applyScalpState()}this.syncSimRunning(),this.applyShadowState(),this.checkBaseDrift()}buildRoots(){let{headShape:e,baseObjectId:t,guideStrands:a,hairLength:s}=this.data;if(this.baseFoundAtRegen=!1,this.baseSourceGeomsAtRegen=[],this.baseSourceHashesAtRegen=[],this.baseColorHashAtRegen=0,this.baseScaleAtRegen=0,"object"===e&&t){let e=this.context.scene.find(t);if(e){this.baseFoundAtRegen=!0,e.updateWorldMatrix(!0,!0);let t=this.collectBaseSources(e),i=t?function(e){let t=[];for(let a of e){let e=C(a);e&&t.push(e)}if(0===t.length)return null;let a=new Float64Array(t.length),s=0;for(let e=0;e<t.length;e++)s+=t[e].total,a[e]=s;return s<=0?null:e=>{let i=e()*s,r=0,n=t.length-1;for(;r<n;){let e=r+n>>1;a[e]<i?r=e+1:n=e}let h=0===r?i:i-a[r-1];return t[r].sample(h,e)}}(t.sources):null;if(this.baseSourceGeomsAtRegen=t?.sources.map(e=>e.geometry)??[],this.baseSourceHashesAtRegen=t?.hashes??[],this.baseColorHashAtRegen=t?.colorHash??0,t&&i){let r=this.baseWorldScale(e),n=Math.max(t.radius*r,.001);this.baseScaleAtRegen=r;let h=r;return F({shape:"object",guideStrands:a,hairLength:s,sampler:e=>{let t=i(e);return{...t,x:t.x*h,y:t.y*h,z:t.z*h}},samplerRadius:n})}}}return F({shape:"object"===e?"sphere":e,guideStrands:a,hairLength:s})}collectBaseSources(e){let t=[],a=[],s=0,i=0;P.copy(e.matrixWorld).invert();let r=P.clone(),n=o=>{if(!0===o.isHairSystem||o!==e&&!1===o.visible)return;let l=o.geometry;if(!0===o.isMesh&&l&&(l.getAttribute("position")?.count??0)>=3){let n=o===e?void 0:(new h).multiplyMatrices(r,o.matrixWorld),d=Array.isArray(o.material)?o.material[0]:o.material;t.push({geometry:l,matrix:n,sampleColor:A(d,this.context.shared)??void 0}),a.push(Y.matrixHash(n)),i+=function(e,t){let a=e,s=0,i=1,r=e=>{s+=e*i,i+=1},n=a?.data?.layers;if(n&&"function"==typeof n.forEach){let e=t;n.forEach(t=>{let a=t.data;if(!1!==a.visible)if("color"===a.type){let t=a.color,s="string"==typeof t?"function"==typeof e?.color?e.color(t):void 0:t;s&&"number"==typeof s.r&&(r(s.r),r(s.g),r(s.b)),r(R(a.alpha,1))}else if("gradient"===a.type){let e=a;for(let t of e.colors??[])r(t[0]),r(t[1]),r(t[2]),r(t[3]);for(let t of e.steps??[])r(t);r(R(e.angle,0)),r(e.gradientType),r(e.smooth?1:0)}})}else a?.color&&!0===a.color.isColor&&(r(a.color.r),r(a.color.g),r(a.color.b));return s}(d,this.context.shared),null===l.boundingSphere&&l.computeBoundingSphere();let c=l.boundingSphere;if(c){let e=0,t=1;n?(L.copy(c.center).applyMatrix4(n),e=L.length(),t=Y.matrixMaxScale(n)):e=c.center.length(),s=Math.max(s,e+c.radius*t)}}for(let e of o.children)n(e)};return n(e),0===t.length?null:{sources:t,hashes:a,radius:Math.max(s,.001),colorHash:i}}static matrixHash(e){if(!e)return 0;let t=e.elements,a=0;for(let e=0;e<16;e++)a+=t[e]*(e+1);return a}static matrixMaxScale(e){let t=e.elements,a=Math.hypot(t[0],t[1],t[2]),s=Math.hypot(t[4],t[5],t[6]),i=Math.hypot(t[8],t[9],t[10]);return Math.max(a,s,i,1e-6)}baseWorldScale(e){return P.copy(e.matrixWorld).decompose(L,G,X),Math.max(Math.abs(X.x),Math.abs(X.y),Math.abs(X.z),1e-6)}get widthWorldScale(){return"object"===this.data.headShape&&this.data.baseObjectId&&this.baseScaleAtRegen>0?this.baseScaleAtRegen:1}checkBaseDrift(){if("object"!==this.data.headShape||!this.data.baseObjectId)return;let e=this.context.scene.find(this.data.baseObjectId);if(!e)return;if(!this.baseFoundAtRegen)return void this.regenerate();e.updateWorldMatrix(!0,!0);let t=this.collectBaseSources(e),a=t?.sources??[],s=t?.hashes??[],i=this.baseSourceGeomsAtRegen,r=this.baseSourceHashesAtRegen,n=a.length!==i.length;if(!n)for(let e=0;e<a.length;e++)if(a[e].geometry!==i[e]||Math.abs(s[e]-r[e])>1e-4*Math.max(Math.abs(r[e]),1)){n=!0;break}if(!n&&"object"===this.data.hairColorSource&&(t?.colorHash??0)!==this.baseColorHashAtRegen&&(n=!0),!n&&a.length>0){let t=this.baseWorldScale(e);n=Math.abs(t-this.baseScaleAtRegen)>.001*Math.max(this.baseScaleAtRegen,1e-6)}n&&this.regenerate()}applyScalpState(){let e=this.data.headShape,t="object"===e&&null!==this.data.baseObjectId;this.scalpMesh.visible=!t,!t&&(this.scalpMesh.geometry.dispose(),this.scalpMesh.geometry="torus"===e?new d(140,70,24,48):"cylinder"===e?new s(80,80,160,48,1):new l(H,48,32))}boneTransform(e,t){let a=this.matrixWorld;if("object"===this.data.headShape&&this.data.baseObjectId){let e=this.context.scene.find(this.data.baseObjectId)?.matrixWorld;e&&(a=e)}P.copy(a).decompose(t,e,X)}raycast(e,t){if(!this.scalpMesh.visible)return;let a=[];this.scalpMesh.raycast(e,a);for(let e of a)e.object=this,t.push(e)}get shadowBoundsRadius(){return this.roots.unitScale*(1.5+2.6*Math.max(this.data.hairLength,0))}updateEntityBoxSize(e,t){let a=this.shadowBoundsRadius;e.set(0,0,0),t.set(a,a,a)}dispose(){super.dispose(),this.scalpMesh.geometry.dispose(),this.scalpMesh.material.dispose(),this.ribbonMesh.geometry.dispose(),this.ribbonMesh.material.dispose?.(),M()?.release(this)}};export{b as a,m as b,f as c,M as d,j as e,I as f,W as g,H as h,k as i,z as j,Y as k};
1
+ import{v as e}from"./runtime-chunk-PLJ25O2X.js";import{Ec as t,Fc as a,Fd as s,Gc as i,Ge as r,Ib as n,Oc as h,Tc as o,Wd as l,Xd as d,Zc as c,kd as u,ld as g}from"./runtime-chunk-VGN7YHB7.js";var p=null;function b(e){p=e}function m(){return p}var S=null;function f(e){S=e}function M(){return S}var y=new o;function x(e,t,a){return y.setRGB(e,t,a,n),{r:y.r,g:y.g,b:y.b}}var R=(e,t)=>"number"==typeof e&&Number.isFinite(e)?e:t,w=e=>Array.isArray(e)&&"number"==typeof e[0]&&"number"==typeof e[1]?[e[0],e[1]]:[0,0];function v(e,t,a){let s,i=R(e.angle,0),[r,n]=w(e.offset),[h,o]=w(e.morph),l=e.colors??[],d=e.steps??[],c=Math.min(10,l.length,d.length);if(0===c)return[1,1,1,1];if(1===e.gradientType){let e=3*(t+h)-(t+r)-1,l=3*(a+o)-(a+n)-1;s=Math.hypot(e,l)+i}else if(2===e.gradientType){let e=-1*Math.atan2(t+h-.5+r,a+o-.5+n),l=i/Math.PI/-2+.5*e/Math.PI;s=l-Math.floor(l)}else{let e=.5+h/(0!==t?t:1e-6),l=o/(0!==a?a:1e-6),d=Math.cos(i)*e-Math.sin(i)*l,c=Math.sin(i)*e+Math.cos(i)*l,u=d*d+c*c;s=u>1e-12?(((t-.5+r)/2+d/2)*d+((a-.5+n)/2+c/2)*c)/u:0}let u=l[0][0],g=l[0][1],p=l[0][2],b=l[0][3];for(let t=1;t<c;t++){let a=d[t-1],i=d[t]-a,r=0!==i?Math.min(1,Math.max(0,(s-a)/i)):s>=a?1:0;e.smooth&&(r=r*r*(3-2*r)),u+=(l[t][0]-u)*r,g+=(l[t][1]-g)*r,p+=(l[t][2]-p)*r,b+=(l[t][3]-b)*r}return[u,g,p,b]}function A(e,t){let a=e,s=a?.data?.layers;if(s&&"function"==typeof s.forEach){let e=t,a=[];return s.forEach(t=>{let s=t.data;if(!1===s.visible||!0===s.isMask)return;let i=R(s.alpha,1);if(!(i<=0))if("color"===s.type){let t,r=s.color;"string"==typeof r?t="function"==typeof e?.color?e.color(r):void 0:r&&"number"==typeof r.r&&(t=r),t&&a.push({kind:"color",layer:s,rgb:{...x(t.r,t.g,t.b),a:t.a??1},alpha:i})}else"gradient"===s.type&&a.push({kind:"gradient",layer:s,alpha:i})}),0===a.length?null:(e,t)=>{let s=1,i=1,r=1,n=!0;for(let h of a){let a,o,l,d;if("color"===h.kind)({r:a,g:o,b:l}=h.rgb),d=h.rgb.a;else{let[s,i,r,n]=v(h.layer,e,t);({r:a,g:o,b:l}=x(s,i,r)),d=n}let c=n?1:Math.min(1,Math.max(0,d*h.alpha));s+=(a-s)*c,i+=(o-i)*c,r+=(l-r)*c,n=!1}return{r:s,g:i,b:r}}}if(a?.color&&!0===a.color.isColor){let{r:e,g:t,b:s}=a.color;return()=>({r:e,g:t,b:s})}return null}var j=32,I=16384,W=32*I,H=100;function O(e,t){if("torus"===e){let e=t()*Math.PI*2,a=t()*Math.PI*2,s=Math.cos(e),i=Math.sin(e),r=Math.cos(a),n=Math.sin(a);return{x:(1.4+.7*r)*s,y:-(1.4+.7*r)*i,z:.7*n,nx:r*s,ny:-r*i,nz:n,cr:1,cg:1,cb:1}}if("cylinder"===e){let e=t()*Math.PI*2,a=Math.cos(e),s=Math.sin(e);return{x:.8*a,y:1.6*(t()-.5),z:.8*s,nx:a,ny:0,nz:s,cr:1,cg:1,cb:1}}let a=t()*Math.PI*2,s=2*t()-1,i=Math.acos(s),r=Math.sin(i)*Math.cos(a),n=Math.cos(i),h=Math.sin(i)*Math.sin(a);return{x:r,y:n,z:h,nx:r,ny:n,nz:h,cr:1,cg:1,cb:1}}function C(e){let{geometry:t,matrix:a}=e,s=t.getAttribute("position");if(!s||s.count<3)return null;let r=t.getAttribute("normal"),n=t.getAttribute("uv"),h=t.getAttribute("color"),o=t.getIndex(),l=o?o.count/3:s.count/3;if(l<1)return null;let d=(e,t)=>o?o.getX(3*e+t):3*e+t,c=a?a.elements:null,u=a?(new i).getNormalMatrix(a).elements:null,g=e=>{let t=s.getX(e),a=s.getY(e),i=s.getZ(e);return c?c[0]*t+c[4]*a+c[8]*i+c[12]:t},p=e=>{let t=s.getX(e),a=s.getY(e),i=s.getZ(e);return c?c[1]*t+c[5]*a+c[9]*i+c[13]:a},b=e=>{let t=s.getX(e),a=s.getY(e),i=s.getZ(e);return c?c[2]*t+c[6]*a+c[10]*i+c[14]:i},m=new Float64Array(l),S=0;for(let e=0;e<l;e++){let t=d(e,0),a=d(e,1),s=d(e,2),i=g(t),r=p(t),n=b(t),h=g(a)-i,o=p(a)-r,l=b(a)-n,c=g(s)-i,u=p(s)-r,f=b(s)-n,M=o*f-l*u,y=l*c-h*f,x=h*u-o*c;S+=.5*Math.sqrt(M*M+y*y+x*x),m[e]=S}return S<=0?null:{total:S,sample:(t,a)=>{let s=0,i=l-1;for(;s<i;){let e=s+i>>1;m[e]<t?s=e+1:i=e}let o=s,c=d(o,0),S=d(o,1),f=d(o,2),M=a(),y=a();M+y>1&&(M=1-M,y=1-y);let x,R,w,v=1-M-y,A=g(c)*v+g(S)*M+g(f)*y,j=p(c)*v+p(S)*M+p(f)*y,I=b(c)*v+b(S)*M+b(f)*y;if(r){if(x=r.getX(c)*v+r.getX(S)*M+r.getX(f)*y,R=r.getY(c)*v+r.getY(S)*M+r.getY(f)*y,w=r.getZ(c)*v+r.getZ(S)*M+r.getZ(f)*y,u){let e=u[0]*x+u[3]*R+u[6]*w,t=u[1]*x+u[4]*R+u[7]*w,a=u[2]*x+u[5]*R+u[8]*w;x=e,R=t,w=a}}else{let e=g(c),t=p(c),a=b(c),s=g(S)-e,i=p(S)-t,r=b(S)-a,n=g(f)-e,h=p(f)-t,o=b(f)-a;x=i*o-r*h,R=r*n-s*o,w=s*h-i*n}let W=Math.sqrt(x*x+R*R+w*w)||1,H=1,O=1,C=1;if(h)H=h.getX(c)*v+h.getX(S)*M+h.getX(f)*y,O=h.getY(c)*v+h.getY(S)*M+h.getY(f)*y,C=h.getZ(c)*v+h.getZ(S)*M+h.getZ(f)*y;else if(e.sampleColor){let t=n?n.getX(c)*v+n.getX(S)*M+n.getX(f)*y:.5,a=n?n.getY(c)*v+n.getY(S)*M+n.getY(f)*y:.5,s=e.sampleColor(t,a);s&&(H=s.r,O=s.g,C=s.b)}return{x:A,y:j,z:I,nx:x/W,ny:R/W,nz:w/W,cr:H,cg:O,cb:C}}}}function F(e){let t=Math.min(Math.max(1,Math.floor(e.guideStrands)),I),a=function(e){let t=e>>>0;return()=>{t|=0,t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}(e.seed??1337),s="object"===e.shape&&e.sampler,i=s?e.samplerRadius??H:H,r=new Float32Array(4*W),n=new Float32Array(W),h=new Float32Array(4*I).fill(1);for(let o=0;o<t;o++){let t=s?e.sampler(a):O(e.shape,a),l=s?t.x:t.x*i,d=s?t.y:t.y*i,c=s?t.z:t.z*i,{nx:u,ny:g,nz:p}=t;h[4*o+0]=t.cr,h[4*o+1]=t.cg,h[4*o+2]=t.cb;let b,m,S,f=32*o,M=(1.8+.8*a())*e.hairLength*i/31,y=.5+1.5*a(),x=(.02+.06*a())*i;Math.abs(g)<.99?(b=-p,m=0,S=u):(b=1,m=0,S=0);let R=Math.sqrt(b*b+m*m+S*S)||1;for(let e=0;e<32;e++){let t=e/31,a=t*t*.4*i,s=x*Math.sin(t*y*Math.PI*2),h=4*(f+e);r[h+0]=l+u*M*e+s*b/R,r[h+1]=d+g*M*e-a+s*m/R,r[h+2]=c+p*M*e+s*S/R,r[h+3]=0===e?0:1,e<31&&(n[f+e]=M)}}return{initialPositions:r,restLengths:n,unitScale:i,rootColors:h}}var k=1/60,P=4,z=new h,L=new t,X=new a,G=new a,B=class extends e{constructor(e,t,a){super(e,t),this.type="HairSystem",this.isHairSystem=!0,this.simRunning=!1,this.previewRequested=!1,this.playModeActive=!1,this.pendingSimSeconds=0,this.simTime=0,this.resetRequested=!0,this.generation=0,this.baseFoundAtRegen=!1,this.baseSourceGeomsAtRegen=[],this.baseSourceHashesAtRegen=[],this.baseColorHashAtRegen=0,this.baseScaleAtRegen=0,this.classicFallbackWarned=!1,this.regenSnapshot=null,this.context=a,this.data=t,this.geometry.setAttribute("position",new c(new Float32Array(0),3)),this.material=new u({colorWrite:!1,depthWrite:!1}),this.frustumCulled=!1,this.scalpMesh=new g(new l(H,48,32),new u({color:5448477})),this.scalpMesh.name="HairScalp",this.add(this.scalpMesh);let s=new r;s.setAttribute("position",new c(new Float32Array(12),3)),s.setIndex([0,2,1,2,3,1]),s.instanceCount=0,this.ribbonMesh=new g(s,new u({visible:!1})),this.ribbonMesh.name="HairRibbons",this.ribbonMesh.frustumCulled=!1,this.ribbonMesh.visible=!1,this.ribbonMesh.matrixAutoUpdate=!1,this.ribbonMesh.updateMatrixWorld=()=>{this.ribbonMesh.matrixWorld.identity()},this.ribbonMesh.updateWorldMatrix=()=>{this.ribbonMesh.matrixWorld.identity()},this.add(this.ribbonMesh),this.activeGuideStrands=t.guideStrands,this.roots=this.buildRoots(),this.regenSnapshot={guideStrands:t.guideStrands,hairLength:t.hairLength,spreadRadius:t.spreadRadius,headShape:t.headShape,baseObjectId:t.baseObjectId},this.applyScalpState(),this.applyShadowState(),this.syncSimRunning()}update(e){!this.simRunning||(this.pendingSimSeconds=Math.min(this.pendingSimSeconds+e/1e3,4*k*2))}get isSimulating(){return(this.simRunning||this.resetRequested)&&this.visible}startPreview(){this.previewRequested=!0,this.syncSimRunning()}stopPreview(){this.previewRequested=!1,this.syncSimRunning()}setPlayMode(e){this.playModeActive=e,e&&this.resetSimulation(),this.syncSimRunning()}resetSimulation(){this.resetRequested=!0,this.pendingSimSeconds=0,this.simTime=0}warnClassicFallbackOnce(){this.classicFallbackWarned||(this.classicFallbackWarned=!0,console.warn("[spline] Hair System strands require the WebGPU renderer — the WebGL fallback shows only the scalp. Reload with ?renderer=webgpu in a WebGPU-capable browser."))}syncSimRunning(){this.simRunning=this.playModeActive||this.previewRequested||this.data.autoPlay}updateState(e,t){super.updateState(e,t),this.updateHairState(e)}updateHairState(e){if((void 0!==e.guideStrands||void 0!==e.hairLength||void 0!==e.spreadRadius||void 0!==e.headShape||void 0!==e.baseObjectId)&&this.regenerate(),(void 0!==e.headShape||void 0!==e.baseObjectId)&&this.applyScalpState(),void 0!==e.headColor){let t=this.scalpMesh.material;!0===t.isMeshBasicMaterial&&t.color.setRGB(e.headColor.r,e.headColor.g,e.headColor.b,n)}(void 0!==e.castShadow||void 0!==e.receiveShadow)&&this.applyShadowState(),void 0!==e.autoPlay&&this.syncSimRunning()}applyShadowState(){let e=this.data.castShadow??!0,t=this.data.receiveShadow??!0;this.scalpMesh.castShadow=e,this.scalpMesh.receiveShadow=t,this.ribbonMesh.castShadow=e,this.ribbonMesh.receiveShadow=t}regenerate(){this.activeGuideStrands=Math.max(1,Math.min(Math.floor(this.data.guideStrands),16384)),this.roots=this.buildRoots(),this.generation++,this.regenSnapshot={guideStrands:this.data.guideStrands,hairLength:this.data.hairLength,spreadRadius:this.data.spreadRadius,headShape:this.data.headShape,baseObjectId:this.data.baseObjectId},this.resetSimulation()}checkDataDrift(){let e=this.data,t=this.regenSnapshot;if(null===t||t.guideStrands!==e.guideStrands||t.hairLength!==e.hairLength||t.spreadRadius!==e.spreadRadius||t.headShape!==e.headShape||t.baseObjectId!==e.baseObjectId){let a=null===t||t.headShape!==e.headShape||t.baseObjectId!==e.baseObjectId;this.regenerate(),a&&this.applyScalpState()}this.syncSimRunning(),this.applyShadowState(),this.checkBaseDrift()}buildRoots(){let{headShape:e,baseObjectId:t,guideStrands:a,hairLength:s}=this.data;if(this.baseFoundAtRegen=!1,this.baseSourceGeomsAtRegen=[],this.baseSourceHashesAtRegen=[],this.baseColorHashAtRegen=0,this.baseScaleAtRegen=0,"object"===e&&t){let e=this.context.scene.find(t);if(e){this.baseFoundAtRegen=!0,e.updateWorldMatrix(!0,!0);let t=this.collectBaseSources(e),i=t?function(e){let t=[];for(let a of e){let e=C(a);e&&t.push(e)}if(0===t.length)return null;let a=new Float64Array(t.length),s=0;for(let e=0;e<t.length;e++)s+=t[e].total,a[e]=s;return s<=0?null:e=>{let i=e()*s,r=0,n=t.length-1;for(;r<n;){let e=r+n>>1;a[e]<i?r=e+1:n=e}let h=0===r?i:i-a[r-1];return t[r].sample(h,e)}}(t.sources):null;if(this.baseSourceGeomsAtRegen=t?.sources.map(e=>e.geometry)??[],this.baseSourceHashesAtRegen=t?.hashes??[],this.baseColorHashAtRegen=t?.colorHash??0,t&&i){let r=this.baseWorldScale(e),n=Math.max(t.radius*r,.001);this.baseScaleAtRegen=r;let h=r;return F({shape:"object",guideStrands:a,hairLength:s,sampler:e=>{let t=i(e);return{...t,x:t.x*h,y:t.y*h,z:t.z*h}},samplerRadius:n})}}}return F({shape:"object"===e?"sphere":e,guideStrands:a,hairLength:s})}collectBaseSources(e){let t=[],a=[],s=0,i=0;z.copy(e.matrixWorld).invert();let r=z.clone(),n=o=>{if(!0===o.isHairSystem||o!==e&&!1===o.visible)return;let l=o.geometry;if(!0===o.isMesh&&l&&(l.getAttribute("position")?.count??0)>=3){let n=o===e?void 0:(new h).multiplyMatrices(r,o.matrixWorld),d=Array.isArray(o.material)?o.material[0]:o.material;t.push({geometry:l,matrix:n,sampleColor:A(d,this.context.shared)??void 0}),a.push(B.matrixHash(n)),i+=function(e,t){let a=e,s=0,i=1,r=e=>{s+=e*i,i+=1},n=a?.data?.layers;if(n&&"function"==typeof n.forEach){let e=t;n.forEach(t=>{let a=t.data;if(!1!==a.visible)if("color"===a.type){let t=a.color,s="string"==typeof t?"function"==typeof e?.color?e.color(t):void 0:t;s&&"number"==typeof s.r&&(r(s.r),r(s.g),r(s.b)),r(R(a.alpha,1))}else if("gradient"===a.type){let e=a;for(let t of e.colors??[])r(t[0]),r(t[1]),r(t[2]),r(t[3]);for(let t of e.steps??[])r(t);r(R(e.angle,0)),r(e.gradientType),r(e.smooth?1:0)}})}else a?.color&&!0===a.color.isColor&&(r(a.color.r),r(a.color.g),r(a.color.b));return s}(d,this.context.shared),null===l.boundingSphere&&l.computeBoundingSphere();let c=l.boundingSphere;if(c){let e=0,t=1;n?(X.copy(c.center).applyMatrix4(n),e=X.length(),t=B.matrixMaxScale(n)):e=c.center.length(),s=Math.max(s,e+c.radius*t)}}for(let e of o.children)n(e)};return n(e),0===t.length?null:{sources:t,hashes:a,radius:Math.max(s,.001),colorHash:i}}static matrixHash(e){if(!e)return 0;let t=e.elements,a=0;for(let e=0;e<16;e++)a+=t[e]*(e+1);return a}static matrixMaxScale(e){let t=e.elements,a=Math.hypot(t[0],t[1],t[2]),s=Math.hypot(t[4],t[5],t[6]),i=Math.hypot(t[8],t[9],t[10]);return Math.max(a,s,i,1e-6)}baseWorldScale(e){return z.copy(e.matrixWorld).decompose(X,L,G),Math.max(Math.abs(G.x),Math.abs(G.y),Math.abs(G.z),1e-6)}get widthWorldScale(){return"object"===this.data.headShape&&this.data.baseObjectId&&this.baseScaleAtRegen>0?this.baseScaleAtRegen:1}checkBaseDrift(){if("object"!==this.data.headShape||!this.data.baseObjectId)return;let e=this.context.scene.find(this.data.baseObjectId);if(!e)return;if(!this.baseFoundAtRegen)return void this.regenerate();e.updateWorldMatrix(!0,!0);let t=this.collectBaseSources(e),a=t?.sources??[],s=t?.hashes??[],i=this.baseSourceGeomsAtRegen,r=this.baseSourceHashesAtRegen,n=a.length!==i.length;if(!n)for(let e=0;e<a.length;e++)if(a[e].geometry!==i[e]||Math.abs(s[e]-r[e])>1e-4*Math.max(Math.abs(r[e]),1)){n=!0;break}if(!n&&"object"===this.data.hairColorSource&&(t?.colorHash??0)!==this.baseColorHashAtRegen&&(n=!0),!n&&a.length>0){let t=this.baseWorldScale(e);n=Math.abs(t-this.baseScaleAtRegen)>.001*Math.max(this.baseScaleAtRegen,1e-6)}n&&this.regenerate()}applyScalpState(){let e=this.data.headShape,t="object"===e&&null!==this.data.baseObjectId;this.scalpMesh.visible=!t,!t&&(this.scalpMesh.geometry.dispose(),this.scalpMesh.geometry="torus"===e?new d(140,70,24,48):"cylinder"===e?new s(80,80,160,48,1):new l(H,48,32))}boneTransform(e,t){let a=this.matrixWorld;if("object"===this.data.headShape&&this.data.baseObjectId){let e=this.context.scene.find(this.data.baseObjectId)?.matrixWorld;e&&(a=e)}z.copy(a).decompose(t,e,G)}raycast(e,t){if(!this.scalpMesh.visible)return;let a=[];this.scalpMesh.raycast(e,a);for(let e of a)e.object=this,t.push(e)}get shadowBoundsRadius(){return this.roots.unitScale*(1.5+2.6*Math.max(this.data.hairLength,0))}updateEntityBoxSize(e,t){let a=this.shadowBoundsRadius;e.set(0,0,0),t.set(a,a,a)}dispose(){super.dispose(),this.scalpMesh.geometry.dispose(),this.scalpMesh.material.dispose(),this.ribbonMesh.geometry.dispose(),this.ribbonMesh.material.dispose?.(),M()?.release(this)}};export{b as a,m as b,f as c,M as d,j as e,I as f,W as g,H as h,k as i,P as j,B as k};
@@ -1 +1 @@
1
- import{a as t}from"./runtime-chunk-I5QFGBIU.js";import{d as e}from"./runtime-chunk-RF63UVAU.js";import{Sc as s}from"./runtime-chunk-VGN7YHB7.js";var r=class extends(e(s,t)){constructor(t,e,s){super(),this.super_Entity(t,e),this.context=s,this.objectHelper.update()}updateState(t,e){this.updateState_Entity(t,e)}};export{r as a};
1
+ import{a as t}from"./runtime-chunk-DZOSSY2K.js";import{d as e}from"./runtime-chunk-CDZQF4NV.js";import{Sc as s}from"./runtime-chunk-VGN7YHB7.js";var r=class extends(e(s,t)){constructor(t,e,s){super(),this.super_Entity(t,e),this.context=s,this.objectHelper.update()}updateState(t,e){this.updateState_Entity(t,e)}};export{r as a};
@@ -1 +1 @@
1
- import{a as t}from"./runtime-chunk-CIBY4YG3.js";import{b as e}from"./runtime-chunk-WMWQXAOH.js";import{$ as i,C as r}from"./runtime-chunk-YFAATRJU.js";import{f as n,v as s}from"./runtime-chunk-OOC7YSI5.js";import{c as a}from"./runtime-chunk-2PT2WH66.js";import{c as o}from"./runtime-chunk-4KZXQGUQ.js";import{M as l}from"./runtime-chunk-OW6T4XFV.js";import{Cc as h,Ec as d,Fc as c,Oc as u,Pc as p,Rc as m,Wc as f,qd as y}from"./runtime-chunk-VGN7YHB7.js";import{a as b,b as x}from"./runtime-chunk-ML3Z74BL.js";var g=x(b((t,e)=>{var i,r;i=t,r=function(){return t.importState=function(e){var i=new t;return i.importState(e),i},t;function t(){return function(t){var e=0,i=0,r=0,n=1;0==t.length&&(t=[+new Date]);var s=function(){var t=4022871197,e=function(e){e=e.toString();for(var i=0;i<e.length;i++){var r=.02519603282416938*(t+=e.charCodeAt(i));r-=t=r>>>0,t=(r*=t)>>>0,t+=4294967296*(r-=t)}return 2.3283064365386963e-10*(t>>>0)};return e.version="Mash 0.9",e}();e=s(" "),i=s(" "),r=s(" ");for(var a=0;a<t.length;a++)(e-=s(t[a]))<0&&(e+=1),(i-=s(t[a]))<0&&(i+=1),(r-=s(t[a]))<0&&(r+=1);s=null;var o=function(){var t=2091639*e+2.3283064365386963e-10*n;return e=i,i=r,r=t-(n=0|t)};return o.next=o,o.uint32=function(){return 4294967296*o()},o.fract53=function(){return o()+11102230246251565e-32*(2097152*o()|0)},o.version="Alea 0.9",o.args=t,o.exportState=function(){return[e,i,r,n]},o.importState=function(t){e=+t[0]||0,i=+t[1]||0,r=+t[2]||0,n=+t[3]||0},o}(Array.prototype.slice.call(arguments))}},"object"==typeof t?e.exports=r():"function"==typeof define&&define.amd?define(r):i.Alea=r()})()),M=.5*(Math.sqrt(3)-1),v=(3-Math.sqrt(3))/6,w=1/3,j=1/6,A=(Math.sqrt(5),Math.sqrt(5),t=>0|Math.floor(t)),S=new Float64Array([1,1,-1,1,1,-1,-1,-1,1,0,-1,0,1,0,-1,0,0,1,0,-1,0,1,0,-1]),F=new Float64Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]);function _(t){let e=new Uint8Array(512);for(let t=0;t<256;t++)e[t]=t;for(let i=0;i<255;i++){let r=i+~~(t()*(256-i)),n=e[i];e[i]=e[r],e[r]=n}for(let t=256;t<512;t++)e[t]=e[t-256];return e}var W=new f,O=class{constructor(t){this.weightAttribute=null;let e=t.geometry;if(!e.isBufferGeometry||3!==e.attributes.position.itemSize)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");e.index&&(e=e.toNonIndexed()),this.geometry=e,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let t=this.positionAttribute,e=new Float32Array(t.count/3);for(let i=0;i<t.count;i+=3){let r=1;W.a.fromBufferAttribute(t,i),W.b.fromBufferAttribute(t,i+1),W.c.fromBufferAttribute(t,i+2),r*=W.getArea(),e[i/3]=r}this.distribution=new Float32Array(t.count/3);let i=0;for(let t=0;t<e.length;t++)i+=e[t],this.distribution[t]=i;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let i=this.distribution[this.distribution.length-1],r=this.binarySearch(this.randomFunction()*i);return this.sampleFace(r,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,i=0,r=e.length-1,n=-1;for(;i<=r;){let s=Math.ceil((i+r)/2);if(0===s||e[s-1]<=t&&e[s]>t){n=s;break}t<e[s]?r=s-1:i=s+1}return n}sampleFace(t,e,i){let r=this.randomFunction(),n=this.randomFunction();return r+n>1&&(r=1-r,n=1-n),W.a.fromBufferAttribute(this.positionAttribute,3*t),W.b.fromBufferAttribute(this.positionAttribute,3*t+1),W.c.fromBufferAttribute(this.positionAttribute,3*t+2),e.set(0,0,0).addScaledVector(W.a,r).addScaledVector(W.b,n).addScaledVector(W.c,1-(r+n)),W.getNormal(i),this}},z={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},C={polygon_center:0,edge:1,vertex:2},N=(t,e)=>(i,r)=>e&&0!==i&&0!==t?t*r/100:0,P=(t,e)=>{let i=Math.abs(e),r=-1*i;return(t- -1)*(i-r)/2+r},T=new c,V=new c,k=new c,B=new c;function I(t,e){let i=k.fromArray(t),r=B.fromArray(e);V.copy(r).sub(i);let n=V.length();return V.normalize().multiplyScalar(.5*n),T.copy(i).add(V).toArray()}var R,U,q,D,E=new f,G=new c,L=new c,$=new c,Y=class extends y{},H=class extends Y{constructor(t,e){super(void 0,void 0,e),this.source=t,this.isClonerInstancedMesh=!0,this.hiddenMatrix=new u,this.pivotMatrix=new u,this.previousModelViewMatrix=new u,this.copyPreviousMatrix=!0,this.capacity=e,this.count=0,this.matrixAutoUpdate=!1}raycast(t,e){}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(null===this.parent?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorld.multiply(this.pivotMatrix),this.matrixWorldNeedsUpdate=!1,t=!0);for(let e of this.children)e.updateMatrixWorld(t)}updateWorldMatrix(t,e){let i=this.parent;if(t&&null!==i&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorld.multiply(this.pivotMatrix),e)for(let t of this.children)t.updateWorldMatrix(!1,!0)}onAfterRender(t,e,i,r,n,s){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}get visible(){return!0!==this.source.cloner?.insideBoolean&&(this.source.visible||this.source.dataPatched.visible&&!0===this.source.dataPatched.cloner?.hideBase)}set visible(t){}get castShadow(){return this.source.castShadow}set castShadow(t){}get receiveShadow(){return this.source.receiveShadow}set receiveShadow(t){}get layers(){return this.source.layers}set layers(t){}get geometry(){return this.source.geometry}set geometry(t){}get material(){return this.source.material}set material(t){}get morphTargetInfluences(){return this.source.morphTargetInfluences}set morphTargetInfluences(t){}},Q=t=>.5*(1-Math.cos(t*Math.PI)),X=class{constructor(){this.perlin=new Array(4096)}noise(t,e=0,i=0){if(null==this.perlin){this.perlin=new Array(4096);for(let t=0;t<4096;t++)this.perlin[t]=Math.random()}t<0&&(t=-t),e<0&&(e=-e),i<0&&(i=-i);let r,n,s,a,o,l=Math.floor(t),h=Math.floor(e),d=Math.floor(i),c=t-l,u=e-h,p=i-d,m=0,f=.5;for(let t=0;t<4;t++){let t=l+(h<<4)+(d<<8);r=Q(c),n=Q(u),s=this.perlin[4095&t],s+=r*(this.perlin[t+1&4095]-s),a=this.perlin[t+16&4095],a+=r*(this.perlin[t+16+1&4095]-a),s+=n*(a-s),t+=256,a=this.perlin[4095&t],a+=r*(this.perlin[t+1&4095]-a),o=this.perlin[t+16&4095],o+=r*(this.perlin[t+16+1&4095]-o),a+=n*(o-a),s+=Q(p)*(a-s),m+=s*f,f*=.5,l<<=1,c*=2,h<<=1,u*=2,d<<=1,p*=2,c>=1&&(l++,c--),u>=1&&(h++,u--),p>=1&&(d++,p--)}return m}noiseSeed(t){let e=(()=>{let t,e;return{setSeed(i){e=t=(i??4294967296*Math.random())>>>0},getSeed:()=>t,rand:()=>(e=(1664525*e+1013904223)%4294967296,e/4294967296)}})();e.setSeed(t),this.perlin=new Array(4096);for(let t=0;t<4096;t++)this.perlin[t]=e.rand()}},Z=1e-4,J=new c,K=new c;r.then(t=>{U=[(R=t).get_face_center,R.get_edge_midpoint,R.get_vertex_position],q=[R.get_face_normal,R.get_edge_normal,R.get_vertex_normal],D=[R.face_count,R.edge_count,R.vertex_count]}),new u;var tt=new u,et=new u,it=new u,rt=new u,nt=new u,st=new u,at=new u,ot=new c,lt=new c,ht=new c,dt=new c,ct=new c,ut=new c,pt=new c,mt=new c,ft=new c,yt=new c,bt=new c,xt=new p,gt=new d;function Mt(t){return t?t.version??t.data?.version??0:-1}function vt(t,e){return["number"==typeof t?.[0]?t[0]:"string"==typeof t?.[0]&&e?parseFloat(String(e.shared.getVariable(t[0])??"0")):0,"number"==typeof t?.[1]?t[1]:"string"==typeof t?.[1]&&e?parseFloat(String(e.shared.getVariable(t[1])??"0")):0,"number"==typeof t?.[2]?t[2]:"string"==typeof t?.[2]&&e?parseFloat(String(e.shared.getVariable(t[2])??"0")):0]}var wt=class{constructor(t,e){this.data=t,this.is3D=e,this.perlin=new X,"perlin"===t.noiseType?(this.perlin.noiseSeed(t.seed),this.noise=e?(t,e,i)=>this.perlin.noise(t,e,i):t=>this.perlin.noise(t)):this.noise=e?function(t=Math.random){let e=_(t),i=new Float64Array(e).map(t=>F[t%12*3]),r=new Float64Array(e).map(t=>F[t%12*3+1]),n=new Float64Array(e).map(t=>F[t%12*3+2]);return function(t,s,a){let o,l,h,d,c,u,p,m,f,y,b=(t+s+a)*w,x=A(t+b),g=A(s+b),M=A(a+b),v=(x+g+M)*j,S=t-(x-v),F=s-(g-v),_=a-(M-v);S>=F?F>=_?(c=1,u=0,p=0,m=1,f=1,y=0):S>=_?(c=1,u=0,p=0,m=1,f=0,y=1):(c=0,u=0,p=1,m=1,f=0,y=1):F<_?(c=0,u=0,p=1,m=0,f=1,y=1):S<_?(c=0,u=1,p=0,m=0,f=1,y=1):(c=0,u=1,p=0,m=1,f=1,y=0);let W=S-c+j,O=F-u+j,z=_-p+j,C=S-m+2*j,N=F-f+2*j,P=_-y+2*j,T=S-1+.5,V=F-1+.5,k=_-1+.5,B=255&x,I=255&g,R=255&M,U=.6-S*S-F*F-_*_;if(U<0)o=0;else{let t=B+e[I+e[R]];U*=U,o=U*U*(i[t]*S+r[t]*F+n[t]*_)}let q=.6-W*W-O*O-z*z;if(q<0)l=0;else{let t=B+c+e[I+u+e[R+p]];q*=q,l=q*q*(i[t]*W+r[t]*O+n[t]*z)}let D=.6-C*C-N*N-P*P;if(D<0)h=0;else{let t=B+m+e[I+f+e[R+y]];D*=D,h=D*D*(i[t]*C+r[t]*N+n[t]*P)}let E=.6-T*T-V*V-k*k;if(E<0)d=0;else{let t=B+1+e[I+1+e[R+1]];E*=E,d=E*E*(i[t]*T+r[t]*V+n[t]*k)}return 32*(o+l+h+d)}}((0,g.default)(t.seed)):function(t=Math.random){let e=_(t),i=new Float64Array(e).map(t=>S[t%12*2]),r=new Float64Array(e).map(t=>S[t%12*2+1]);return function(t,n){let s,a,o=0,l=0,h=0,d=(t+n)*M,c=A(t+d),u=A(n+d),p=(c+u)*v,m=t-(c-p),f=n-(u-p);m>f?(s=1,a=0):(s=0,a=1);let y=m-s+v,b=f-a+v,x=m-1+2*v,g=f-1+2*v,w=255&c,j=255&u,S=.5-m*m-f*f;if(S>=0){let t=w+e[j];S*=S,o=S*S*(i[t]*m+r[t]*f)}let F=.5-y*y-b*b;if(F>=0){let t=w+s+e[j+a];F*=F,l=F*F*(i[t]*y+r[t]*b)}let _=.5-x*x-g*g;if(_>=0){let t=w+1+e[j+1];_*=_,h=_*_*(i[t]*x+r[t]*g)}return 70*(o+l+h)}}((0,g.default)(t.seed??""))}},jt=class extends(n(m)){constructor(t,e){super(),this.parameters=e,this.isCloner=!0,this.objectForSample=void 0,this._pendingMediaLoad=!1,this.random=null,this.surfaceSamplerCache=null,this.surfacePointsCache=null,this.object=t}resetOnMove(){this.removeFromParent(),this.parent=null}removeFromParent(){return super.removeFromParent(),this.instancedMesh?.removeFromParent(),this}dispose(){this.removeFromParent(),this._disposeInstancedMesh(),this._invalidateBoolean()}_invalidateBoolean(){this.object instanceof s&&this.object.onClonerLayoutUpdated()}expandClones(t){if(null===this.parent)this.updateState(this.parameters,t);else{for(let t of this.children)t instanceof i&&t.expand();this._syncInstancedMesh()}}invalidateTransform(t){this.matrixWorldNeedsUpdate=!0}onObjUpdateMatrix(){"toObject"!==this.parameters.type&&(this.matrixWorldNeedsUpdate=!0)}update(t){switch(this._updateCount(t),this.parameters.type){case"radial":this._updateRadial(this.parameters,t);break;case"linear":this._updateLinear(this.parameters,t);break;case"grid":this._updateGrid(this.parameters,t);break;case"toObject":this._updateToObject(this.parameters,t)}for(let t of this.children){let e=t.transformOverride;void 0!==e&&(t.position.fromArray(e.position),t.rotation.fromArray(e.rotation),t.scale.fromArray(e.scale)),t.updateMatrix(),t.hasNonUniformScale&&(t.updateMatrixWorld(),t.updateMatrixWorldRigid())}this._syncInstancedMesh(),this._invalidateBoolean()}get instancingActive(){return void 0!==this.instancedMesh}get insideBoolean(){return null!==this.parent&&"booleanOp"in this.parent}_instancingEligible(){if(!0!==this.parameters.instanced)return!1;let t=this.object;return!(t.entityChildrenCount()>0||!0!==t.isMesh||a(t)||!0===t.isDecalObject)}_syncInstancedMesh(){if(!this._instancingEligible())return void this._disposeInstancedMesh();let t=this.instancedMesh;if(void 0!==t&&t.capacity<this.children.length&&(this._disposeInstancedMesh(),t=void 0),void 0===t){let e=Math.max(8,Math.ceil(1.5*this.children.length));t=this.instancedMesh=new H(this.object,e)}t.matrix=this.matrix,t.hiddenMatrix=this.hiddenMatrix,t.matrixWorldNeedsUpdate=!0,t.parent!==this.parent&&(t.removeFromParent(),this.parent?.add(t)),this.syncInstanceMatrices()}syncInstanceMatrices(){this._invalidateBoolean();let t=this.instancedMesh;if(void 0===t)return;let e=0;for(let i of this.children)!1!==i.playModeVisible&&(et.multiplyMatrices(i.hiddenMatrix,i.matrix).multiply(i.pivotMatrix),t.setMatrixAt(e++,et));t.count=e,t.instanceMatrix.needsUpdate=!0,t.boundingSphere=null}_disposeInstancedMesh(){let t=this.instancedMesh;void 0!==t&&(this.instancedMesh=void 0,t.removeFromParent(),t.dispose())}_updateCount(t,e){let r;if(void 0!==e)r=e;else{let e=vt(this.parameters.grid.count,t);r="grid"===this.parameters.type?Math.round(e[0])*Math.round(e[1])*Math.round(e[2]):this.parameters.count}if("toObject"===this.parameters.type)if(this.parameters.toObject.object){if(void 0===e&&"random"!==this.parameters.toObject.spreadType)return}else r=0;if(this.children.length!==r)if(this.children.length<r)for(let t=0,e=r-this.children.length;t<e;++t){let t=new i(this.object);t.expand(),this.add(t)}else for(;this.children.length>r;){let t=this.children.pop();t.parent=null,t.dispatchEvent({type:"removed"}),this.dispatchEvent({type:"childremoved",child:t})}}getRandom(t,e=!1){return(null===this.random||this.random.data.seed!==t.seed||this.random.data.noiseType!==t.noiseType||this.random.is3D!==e)&&(this.random=new wt(t,e)),this.random}_updateRadial(t,e){let i,r=t.radial,n=r.start*h.DEG2RAD,s=n-r.end*h.DEG2RAD,a=vt(r.rotation,e),o=new p(a[0],a[1],a[2]);switch(r.axis){case"z":i=new c(0,0,1);break;case"y":i=new c(0,1,0);break;default:i=new c(1,0,0)}let d=t.randomnessObject??l.defaultData([1,1,1]).randomnessObject,u=!0===this.parameters.randomness&&0!==d.strength?this.getRandom(d):null,m=vt(r.scale,e),f=vt(r.position,e),y=vt(d.scale,e),b=vt(d.position,e),x=vt(d.rotation,e),g=s/t.count,M=N(d.strength,this.parameters.randomness);for(let[t,e]of this.children.entries()){let s=t*(d.freqScale/10)+d.movement,a=null===u?0:u.noise(s,s,s),l=t+1;e.scale.x=m[0]+M(l,P(a,y[0]))||Z,e.scale.y=m[1]+M(l,P(a,y[1]))||Z,e.scale.z=m[2]+M(l,P(a,y[2]))||Z;let h=g*t-n;switch(r.axis){default:case"x":xt.set(0,h,0);break;case"y":xt.set(0,0,h);break;case"z":xt.set(h,0,0)}pt.copy(i).applyQuaternion(gt.setFromEuler(xt)).multiplyScalar(r.radius),e.position.set(pt.x+(f[0]+M(l,P(a,b[0]))),pt.y+(f[1]+M(l,P(a,b[1]))),pt.z+(f[2]+M(l,P(a,b[2]))));let c=M(l,P(a,x[0])),p=M(l,P(a,x[1])),v=M(l,P(a,x[2]));!0===r.alignment?e.rotation.set(xt.x+(o.x+c),xt.y+(o.y+p),xt.z+(o.z+v)):e.rotation.set(o.x+c,o.y+p,o.z+v)}}_updateLinear(t,e){if("linear"!==t.type)throw new Error;let i=t.linear,r=vt(i.rotation,e),n=vt(i.scale,e),s=vt(i.position,e),a=new p(r[0]??0,r[1]??0,r[2]??0),o=t.randomnessObject??l.defaultData([1,1,1]).randomnessObject,h=vt(o.rotation,e),d=vt(o.scale,e),c=vt(o.position,e),u=!0===this.parameters.randomness&&0!==o.strength?this.getRandom(o):null,m=N(o.strength,this.parameters.randomness);for(let[t,e]of this.children.entries()){let i=t*(o.freqScale/10)+o.movement,r=null===u?0:u.noise(i,i,i),l=t+1,p=m(l,P(r,h[0])),f=m(l,P(r,h[1])),y=m(l,P(r,h[2]));e.scale.x=1+(n[0]-1)*t+m(l,P(r,d[0]))||Z,e.scale.y=1+(n[1]-1)*t+m(l,P(r,d[1]))||Z,e.scale.z=1+(n[2]-1)*t+m(l,P(r,d[2]))||Z,e.rotation.set(a.x*t+p,a.y*t+f,a.z*t+y),e.position.x=s[0]*t+m(l,P(r,c[0])),e.position.y=s[1]*t+m(l,P(r,c[1])),e.position.z=s[2]*t+m(l,P(r,c[2]))}}_updateGrid(t,e){let i=0,r=t.grid,n=t.randomnessObject??l.defaultData([1,1,1]).randomnessObject,s=vt(n.scale,e),a=vt(n.rotation,e),o=vt(n.position,e),h=!0===this.parameters.randomness&&0!==n.strength?this.getRandom(n,!0):null,d=N(n.strength,this.parameters.randomness),u=vt(r.count,e),p=vt(r.size,e);if(!0===r.useCenter){let t={x:u[0]%2==0?2:1,y:u[1]%2==0?2:1,z:u[2]%2==0?2:1},e=new c(p[0]*(u[0]-t.x)*.5,p[1]*(u[1]-t.y)*.5,p[2]*(u[2]-t.z)*.5);for(let t=0;t<u[0];t++)for(let r=0;r<u[1];r++)for(let l=0;l<u[2];l++){let c=this.children[i++];if(!c)continue;let u=null===h?0:h.noise((t+1)*(n.freqScale/10)+n.movement,(r+1)*(n.freqScale/10)+n.movement,(l+1)*(n.freqScale/10)+n.movement);c.scale.x=1+d(i,P(u,s[0]))||Z,c.scale.y=1+d(i,P(u,s[1]))||Z,c.scale.z=1+d(i,P(u,s[2]))||Z;let m=d(i,P(u,a[0])),f=d(i,P(u,a[1])),y=d(i,P(u,a[2]));c.rotation.set(m,f,y),c.position.x=p[0]*t-e.x+d(i,P(u,o[0])),c.position.y=p[1]*r-e.y+d(i,P(u,o[1])),c.position.z=p[2]*l-e.z+d(i,P(u,o[2]))}}else for(let t=0;t<u[0];t++)for(let e=0;e<u[1];e++)for(let r=0;r<u[2];r++){let l=this.children[i++];if(!l)continue;let c=null===h?0:h.noise((t+1)*(n.freqScale/10)+n.movement,(e+1)*(n.freqScale/10)+n.movement,(r+1)*(n.freqScale/10)+n.movement);l.scale.x=1+d(i,P(c,s[0]))||Z,l.scale.y=1+d(i,P(c,s[1]))||Z,l.scale.z=1+d(i,P(c,s[2]))||Z;let u=d(i,P(c,a[0])),m=d(i,P(c,a[1])),f=d(i,P(c,a[2]));l.rotation.set(u,m,f),l.position.x=p[0]*t+d(i,P(c,o[0])),l.position.y=-p[1]*e+d(i,P(c,o[1])),l.position.z=-p[2]*r+d(i,P(c,o[2]))}}_updateToObject(i,r){if("toObject"!==i.type)throw new Error;let{toObject:n}=i,s=vt(n.rotation,r),a=vt(n.position,r),o=vt(n.scale,r),h=new p(s[0],s[1],s[2]),d=i.randomnessObject??l.defaultData([1,1,1]).randomnessObject,c=vt(d.rotation,r),u=vt(d.position,r),m=vt(d.scale,r),f=!0===this.parameters.randomness&&0!==d.strength?this.getRandom(d):null,y=N(d.strength,this.parameters.randomness);if(!n.object){for(let[,t]of this.children.entries())t.position.set(0,0,0),t.scale.setScalar(1),t.rotation.set(0,0,0);return this.objectForSample=void 0,void this.invalidateSurfaceCaches()}if(!this.objectForSample)return;if(this.objectForSample instanceof t){if(!this.objectForSample.font?.isLoaded||void 0===this.objectForSample.geometry.attributes.position)return void(this._pendingMediaLoad=!0);this._pendingMediaLoad=!1}if(void 0===this.objectForSample.geometry&&this.objectForSample.isAncestorOf(this.object.uuid))return void console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) seem to be a child/descendant of the object it's being cloned to. Please re-parent it so that they are siblings instead.`);let b=this.getSubdivData();if(b.length>0){let t=Math.round(b.length*n.count/100);this._updateCount(r,t)}else{let t=this.objectForSample.geometry.getAttribute("position");if(!t||isNaN(t.count)||0===t.count)return void console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) cannot be cloned on the surface of "${this.objectForSample.name}" (${this.objectForSample.uuid}) because the latter does not have a valid geometry.`)}this.objectForSample.updateMatrixWorld();let x="random"===n.spreadType,M=null;x&&(M=this.getSurfaceSampler(),M.setRandomGenerator((0,g.default)(this.object.uuid+n.seed)));let v=z[n.axis],w=this.children;ot.fromArray(v),it.copy(this.object.hiddenMatrix).invert();let j=this.objectForSample instanceof e;j&&rt.copy(this.objectForSample.matrixWorld).invert(),"normal"!==n.align&&this.object.getWorldDirection(ut),yt.set(ot.y,ot.z,ot.x).normalize(),bt.copy(yt).cross(ot).normalize(),st.makeBasis(yt,ot,bt).invert();for(let[t,e]of w.entries()){let i=t*(d.freqScale/10)+d.movement,r=null===f?0:f.noise(i,i,i),s=t+1,l=y(s,P(r,c[0])),p=y(s,P(r,c[1])),g=y(s,P(r,c[2]));x?M.sample(ht,dt):(b.length&&(ht.fromArray(b[t].pos),dt.fromArray(b[t].norm)),j&&ht.applyMatrix4(rt)),ht.applyMatrix4(it),e.position.copy(ht);let v="normal"===n.align?dt:ut,w=lt.fromArray(a);lt.x+=y(s,P(r,u[0])),lt.y+=y(s,P(r,u[1])),lt.z+=y(s,P(r,u[2]));let A=Math.acos(v.dot(ot)),S=ct.crossVectors(ot,v).normalize(),F=tt.makeRotationAxis(S,A);mt.copy(v).cross(this.object.up).normalize(),ft.copy(mt).cross(v).normalize(),nt.makeBasis(mt,v,ft),at.multiplyMatrices(nt,st),xt.setFromRotationMatrix(at),w.applyMatrix4(F),e.position.add(w),e.rotation.set(xt.x+h.x+l,xt.y+h.y+p,xt.z+h.z+g),e.scale.set(1+o[0]+y(s,P(r,m[0]))||Z,1+o[1]+y(s,P(r,m[1]))||Z,1+o[2]+y(s,P(r,m[2]))||Z),e.scale.multiply(this.object.scale),e.hiddenMatrix=this.object.hiddenMatrix}}getSurfaceSampler(){let t=this.objectForSample,e=t.geometry,i=e.getAttribute("position"),r=e.index,n=this.surfaceSamplerCache;if(null!==n&&n.geometry===e&&n.position===i&&n.positionVersion===Mt(i)&&n.index===r&&n.indexVersion===(null===r?-1:r.version))return n.sampler;let s=new O(t).build();return this.surfaceSamplerCache={geometry:e,position:i,positionVersion:Mt(i),index:r,indexVersion:null===r?-1:r.version,sampler:s},s}invalidateSurfaceCaches(){this.surfaceSamplerCache=null,this.surfacePointsCache=null}getSubdivData(){if(!this.objectForSample)return[];let t=this.parameters.toObject.spreadType;if("random"===t)return[];let i=this.objectForSample instanceof e,r=this.objectForSample.geometry;if(!i&&r){let e=this.surfacePointsCache,i=r.getAttribute("position");if(null!==e&&e.spreadType===t&&e.geometry===r&&e.position===i&&e.positionVersion===Mt(i)&&e.index===r.index&&e.indexVersion===(null===r.index?-1:r.index.version))return e.points}let n=new Map,s=(t,e)=>{let i=Math.round(1e4*t[0])+"_"+Math.round(1e4*t[1])+"_"+Math.round(1e4*t[2]),r=n.get(i);r?(r.pos[0]+=t[0],r.pos[1]+=t[1],r.pos[2]+=t[2],r.norm[0]+=e[0],r.norm[1]+=e[1],r.norm[2]+=e[2],r.count+=1):n.set(i,{pos:[...t],norm:[...e],count:1})};if(i){let e=this.objectForSample,i=C[t],r=D[i],n=U[i],a=q[i],o=r(e.subdivPointerNew);for(let t=0;t<=o-1;t++){let i=n(e.subdivPointerNew,t),r=a(e.subdivPointerNew,t);J.fromArray(i).applyMatrix4(e.matrixWorld),K.fromArray(r),s(J.toArray(),K.toArray())}}else(r.index?function(t){let e=[],i=Math.floor(t.index.count/3);for(let r=0;r<i;r++)if(G.fromArray(t.index.array,3*r),E.setFromAttributeAndIndices(t.attributes.position,G.x,G.y,G.z),E.getNormal(L),E.getMidpoint($),!(isNaN($.x)||isNaN($.y)||isNaN($.z))){let{a:t,b:i,c:r}=E,n=t.toArray(),s=i.toArray(),a=r.toArray(),o=t.distanceTo(i),l=i.distanceTo(r),h=r.distanceTo(t),d=I(n,s),c=I(s,a),u=I(a,n),p=[o,l,h],m=Math.max(...p),f=p.filter(t=>Math.round(t)===Math.round(m)).length>1,y=[],b=E.getMidpoint($).toArray();m===o&&!f&&(y=[c,u,u],b=d),m===l&&!f&&(y=[d,u,u],b=c),m===h&&!f&&(y=[d,c,c],b=u),f&&(y=[d,c,u]),e.push({vertices:[n,s,a],faceCenters:y,midpoint:b,norm:E.getNormal(L).toArray()})}return e}(r):function(t){let e=[],{position:i}=t.attributes;for(let t=0;t<i.count;t++){E.setFromAttributeAndIndices(i,3*t,3*t+1,3*t+2),E.getNormal(L),E.getMidpoint($);let r=E.a.toArray(),n=E.b.toArray(),s=E.c.toArray();e.push({vertices:[r,n,s],faceCenters:[I(r,n),I(n,s),I(s,r)],midpoint:$.toArray(),norm:L.toArray()})}return e}(r)).forEach((e,i)=>{"polygon_center"===t&&s(e.midpoint,e.norm),"vertex"===t&&(s(e.vertices[0],e.norm),s(e.vertices[1],e.norm),s(e.vertices[2],e.norm)),"edge"===t&&(s(e.faceCenters[0],e.norm),s(e.faceCenters[1],e.norm),s(e.faceCenters[2],e.norm))});let a=Array.from(n.values());for(let t of a)t.pos[0]/=t.count,t.pos[1]/=t.count,t.pos[2]/=t.count,t.norm[0]/=t.count,t.norm[1]/=t.count,t.norm[2]/=t.count;if(!i&&r){let e=r.getAttribute("position");this.surfacePointsCache={spreadType:t,geometry:r,position:e,positionVersion:Mt(e),index:r.index,indexVersion:null===r.index?-1:r.index.version,points:a}}return a}updateState(t,e){if(this.parameters=o(t),"toObject"!==this.parameters.type)this.invalidateSurfaceCaches(),(null===this.parent||this.parent!==this.object)&&(this.removeFromParent(),this.object.parent?.add(this),this.matrix=this.object.matrix,this.hiddenMatrix=this.object.hiddenMatrix,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1);else if(null===this.parent||this.parent.uuid!==this.parameters.toObject.object){this.removeFromParent(),this.invalidateSurfaceCaches();let t=e.scene.find(this.parameters.toObject.object);this.objectForSample=t instanceof s?t:void 0,this.matrix=new u,this.hiddenMatrix=new u,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,t&&t.add(this)}this.update(e)}get pendingMediaLoad(){return this._pendingMediaLoad}};export{jt as a};
1
+ import{a as t}from"./runtime-chunk-243VQV5T.js";import{b as e}from"./runtime-chunk-F7OUYIT6.js";import{$ as i,C as r}from"./runtime-chunk-LALFWESO.js";import{f as n,v as s}from"./runtime-chunk-PLJ25O2X.js";import{c as a}from"./runtime-chunk-2PT2WH66.js";import{c as o}from"./runtime-chunk-4KZXQGUQ.js";import{M as l}from"./runtime-chunk-OW6T4XFV.js";import{Cc as h,Ec as d,Fc as c,Oc as u,Pc as p,Rc as m,Wc as f,qd as y}from"./runtime-chunk-VGN7YHB7.js";import{a as b,b as x}from"./runtime-chunk-ML3Z74BL.js";var g=x(b((t,e)=>{var i,r;i=t,r=function(){return t.importState=function(e){var i=new t;return i.importState(e),i},t;function t(){return function(t){var e=0,i=0,r=0,n=1;0==t.length&&(t=[+new Date]);var s=function(){var t=4022871197,e=function(e){e=e.toString();for(var i=0;i<e.length;i++){var r=.02519603282416938*(t+=e.charCodeAt(i));r-=t=r>>>0,t=(r*=t)>>>0,t+=4294967296*(r-=t)}return 2.3283064365386963e-10*(t>>>0)};return e.version="Mash 0.9",e}();e=s(" "),i=s(" "),r=s(" ");for(var a=0;a<t.length;a++)(e-=s(t[a]))<0&&(e+=1),(i-=s(t[a]))<0&&(i+=1),(r-=s(t[a]))<0&&(r+=1);s=null;var o=function(){var t=2091639*e+2.3283064365386963e-10*n;return e=i,i=r,r=t-(n=0|t)};return o.next=o,o.uint32=function(){return 4294967296*o()},o.fract53=function(){return o()+11102230246251565e-32*(2097152*o()|0)},o.version="Alea 0.9",o.args=t,o.exportState=function(){return[e,i,r,n]},o.importState=function(t){e=+t[0]||0,i=+t[1]||0,r=+t[2]||0,n=+t[3]||0},o}(Array.prototype.slice.call(arguments))}},"object"==typeof t?e.exports=r():"function"==typeof define&&define.amd?define(r):i.Alea=r()})()),v=.5*(Math.sqrt(3)-1),M=(3-Math.sqrt(3))/6,w=1/3,j=1/6,A=(Math.sqrt(5),Math.sqrt(5),t=>0|Math.floor(t)),S=new Float64Array([1,1,-1,1,1,-1,-1,-1,1,0,-1,0,1,0,-1,0,0,1,0,-1,0,1,0,-1]),F=new Float64Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]);function _(t){let e=new Uint8Array(512);for(let t=0;t<256;t++)e[t]=t;for(let i=0;i<255;i++){let r=i+~~(t()*(256-i)),n=e[i];e[i]=e[r],e[r]=n}for(let t=256;t<512;t++)e[t]=e[t-256];return e}var O=new f,W=class{constructor(t){this.weightAttribute=null;let e=t.geometry;if(!e.isBufferGeometry||3!==e.attributes.position.itemSize)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");e.index&&(e=e.toNonIndexed()),this.geometry=e,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let t=this.positionAttribute,e=new Float32Array(t.count/3);for(let i=0;i<t.count;i+=3){let r=1;O.a.fromBufferAttribute(t,i),O.b.fromBufferAttribute(t,i+1),O.c.fromBufferAttribute(t,i+2),r*=O.getArea(),e[i/3]=r}this.distribution=new Float32Array(t.count/3);let i=0;for(let t=0;t<e.length;t++)i+=e[t],this.distribution[t]=i;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let i=this.distribution[this.distribution.length-1],r=this.binarySearch(this.randomFunction()*i);return this.sampleFace(r,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,i=0,r=e.length-1,n=-1;for(;i<=r;){let s=Math.ceil((i+r)/2);if(0===s||e[s-1]<=t&&e[s]>t){n=s;break}t<e[s]?r=s-1:i=s+1}return n}sampleFace(t,e,i){let r=this.randomFunction(),n=this.randomFunction();return r+n>1&&(r=1-r,n=1-n),O.a.fromBufferAttribute(this.positionAttribute,3*t),O.b.fromBufferAttribute(this.positionAttribute,3*t+1),O.c.fromBufferAttribute(this.positionAttribute,3*t+2),e.set(0,0,0).addScaledVector(O.a,r).addScaledVector(O.b,n).addScaledVector(O.c,1-(r+n)),O.getNormal(i),this}},z={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},C={polygon_center:0,edge:1,vertex:2},N=(t,e)=>(i,r)=>e&&0!==i&&0!==t?t*r/100:0,P=(t,e)=>{let i=Math.abs(e),r=-1*i;return(t- -1)*(i-r)/2+r},T=new c,V=new c,k=new c,B=new c;function U(t,e){let i=k.fromArray(t),r=B.fromArray(e);V.copy(r).sub(i);let n=V.length();return V.normalize().multiplyScalar(.5*n),T.copy(i).add(V).toArray()}var I,R,q,D,E=new f,L=new c,G=new c,$=new c,Q=class extends y{},H=class extends Q{constructor(t,e){super(void 0,void 0,e),this.source=t,this.isClonerInstancedMesh=!0,this.hiddenMatrix=new u,this.pivotMatrix=new u,this.previousModelViewMatrix=new u,this.copyPreviousMatrix=!0,this.capacity=e,this.count=0,this.matrixAutoUpdate=!1}raycast(t,e){}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(null===this.parent?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorld.multiply(this.pivotMatrix),this.matrixWorldNeedsUpdate=!1,t=!0);for(let e of this.children)e.updateMatrixWorld(t)}updateWorldMatrix(t,e){let i=this.parent;if(t&&null!==i&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorld.multiply(this.pivotMatrix),e)for(let t of this.children)t.updateWorldMatrix(!1,!0)}onAfterRender(t,e,i,r,n,s){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}get visible(){return!0!==this.source.cloner?.insideBoolean&&(this.source.visible||this.source.dataPatched.visible&&!0===this.source.dataPatched.cloner?.hideBase)}set visible(t){}get castShadow(){return this.source.castShadow}set castShadow(t){}get receiveShadow(){return this.source.receiveShadow}set receiveShadow(t){}get layers(){return this.source.layers}set layers(t){}get geometry(){return this.source.geometry}set geometry(t){}get material(){return this.source.material}set material(t){}get morphTargetInfluences(){return this.source.morphTargetInfluences}set morphTargetInfluences(t){}},X=t=>.5*(1-Math.cos(t*Math.PI)),Y=class{constructor(){this.perlin=new Array(4096)}noise(t,e=0,i=0){if(null==this.perlin){this.perlin=new Array(4096);for(let t=0;t<4096;t++)this.perlin[t]=Math.random()}t<0&&(t=-t),e<0&&(e=-e),i<0&&(i=-i);let r,n,s,a,o,l=Math.floor(t),h=Math.floor(e),d=Math.floor(i),c=t-l,u=e-h,p=i-d,m=0,f=.5;for(let t=0;t<4;t++){let t=l+(h<<4)+(d<<8);r=X(c),n=X(u),s=this.perlin[4095&t],s+=r*(this.perlin[t+1&4095]-s),a=this.perlin[t+16&4095],a+=r*(this.perlin[t+16+1&4095]-a),s+=n*(a-s),t+=256,a=this.perlin[4095&t],a+=r*(this.perlin[t+1&4095]-a),o=this.perlin[t+16&4095],o+=r*(this.perlin[t+16+1&4095]-o),a+=n*(o-a),s+=X(p)*(a-s),m+=s*f,f*=.5,l<<=1,c*=2,h<<=1,u*=2,d<<=1,p*=2,c>=1&&(l++,c--),u>=1&&(h++,u--),p>=1&&(d++,p--)}return m}noiseSeed(t){let e=(()=>{let t,e;return{setSeed(i){e=t=(i??4294967296*Math.random())>>>0},getSeed:()=>t,rand:()=>(e=(1664525*e+1013904223)%4294967296,e/4294967296)}})();e.setSeed(t),this.perlin=new Array(4096);for(let t=0;t<4096;t++)this.perlin[t]=e.rand()}},Z=1e-4,J=new c,K=new c;r.then(t=>{R=[(I=t).get_face_center,I.get_edge_midpoint,I.get_vertex_position],q=[I.get_face_normal,I.get_edge_normal,I.get_vertex_normal],D=[I.face_count,I.edge_count,I.vertex_count]}),new u;var tt=new u,et=new u,it=new u,rt=new u,nt=new u,st=new u,at=new u,ot=new c,lt=new c,ht=new c,dt=new c,ct=new c,ut=new c,pt=new c,mt=new c,ft=new c,yt=new c,bt=new c,xt=new p,gt=new d;function vt(t){return t?t.version??t.data?.version??0:-1}function Mt(t,e){return["number"==typeof t?.[0]?t[0]:"string"==typeof t?.[0]&&e?parseFloat(String(e.shared.getVariable(t[0])??"0")):0,"number"==typeof t?.[1]?t[1]:"string"==typeof t?.[1]&&e?parseFloat(String(e.shared.getVariable(t[1])??"0")):0,"number"==typeof t?.[2]?t[2]:"string"==typeof t?.[2]&&e?parseFloat(String(e.shared.getVariable(t[2])??"0")):0]}var wt=class{constructor(t,e){this.data=t,this.is3D=e,this.perlin=new Y,"perlin"===t.noiseType?(this.perlin.noiseSeed(t.seed),this.noise=e?(t,e,i)=>this.perlin.noise(t,e,i):t=>this.perlin.noise(t)):this.noise=e?function(t=Math.random){let e=_(t),i=new Float64Array(e).map(t=>F[t%12*3]),r=new Float64Array(e).map(t=>F[t%12*3+1]),n=new Float64Array(e).map(t=>F[t%12*3+2]);return function(t,s,a){let o,l,h,d,c,u,p,m,f,y,b=(t+s+a)*w,x=A(t+b),g=A(s+b),v=A(a+b),M=(x+g+v)*j,S=t-(x-M),F=s-(g-M),_=a-(v-M);S>=F?F>=_?(c=1,u=0,p=0,m=1,f=1,y=0):S>=_?(c=1,u=0,p=0,m=1,f=0,y=1):(c=0,u=0,p=1,m=1,f=0,y=1):F<_?(c=0,u=0,p=1,m=0,f=1,y=1):S<_?(c=0,u=1,p=0,m=0,f=1,y=1):(c=0,u=1,p=0,m=1,f=1,y=0);let O=S-c+j,W=F-u+j,z=_-p+j,C=S-m+2*j,N=F-f+2*j,P=_-y+2*j,T=S-1+.5,V=F-1+.5,k=_-1+.5,B=255&x,U=255&g,I=255&v,R=.6-S*S-F*F-_*_;if(R<0)o=0;else{let t=B+e[U+e[I]];R*=R,o=R*R*(i[t]*S+r[t]*F+n[t]*_)}let q=.6-O*O-W*W-z*z;if(q<0)l=0;else{let t=B+c+e[U+u+e[I+p]];q*=q,l=q*q*(i[t]*O+r[t]*W+n[t]*z)}let D=.6-C*C-N*N-P*P;if(D<0)h=0;else{let t=B+m+e[U+f+e[I+y]];D*=D,h=D*D*(i[t]*C+r[t]*N+n[t]*P)}let E=.6-T*T-V*V-k*k;if(E<0)d=0;else{let t=B+1+e[U+1+e[I+1]];E*=E,d=E*E*(i[t]*T+r[t]*V+n[t]*k)}return 32*(o+l+h+d)}}((0,g.default)(t.seed)):function(t=Math.random){let e=_(t),i=new Float64Array(e).map(t=>S[t%12*2]),r=new Float64Array(e).map(t=>S[t%12*2+1]);return function(t,n){let s,a,o=0,l=0,h=0,d=(t+n)*v,c=A(t+d),u=A(n+d),p=(c+u)*M,m=t-(c-p),f=n-(u-p);m>f?(s=1,a=0):(s=0,a=1);let y=m-s+M,b=f-a+M,x=m-1+2*M,g=f-1+2*M,w=255&c,j=255&u,S=.5-m*m-f*f;if(S>=0){let t=w+e[j];S*=S,o=S*S*(i[t]*m+r[t]*f)}let F=.5-y*y-b*b;if(F>=0){let t=w+s+e[j+a];F*=F,l=F*F*(i[t]*y+r[t]*b)}let _=.5-x*x-g*g;if(_>=0){let t=w+1+e[j+1];_*=_,h=_*_*(i[t]*x+r[t]*g)}return 70*(o+l+h)}}((0,g.default)(t.seed??""))}},jt=class extends(n(m)){constructor(t,e){super(),this.parameters=e,this.isCloner=!0,this.objectForSample=void 0,this._pendingMediaLoad=!1,this.random=null,this.surfaceSamplerCache=null,this.surfacePointsCache=null,this.object=t}resetOnMove(){this.removeFromParent(),this.parent=null}removeFromParent(){return super.removeFromParent(),this.instancedMesh?.removeFromParent(),this}dispose(){this.removeFromParent(),this._disposeInstancedMesh(),this._invalidateBoolean()}_invalidateBoolean(){this.object instanceof s&&this.object.onClonerLayoutUpdated()}expandClones(t){if(null===this.parent)this.updateState(this.parameters,t);else{for(let t of this.children)t instanceof i&&t.expand();this._syncInstancedMesh()}}invalidateTransform(t){this.matrixWorldNeedsUpdate=!0}onObjUpdateMatrix(){"toObject"!==this.parameters.type&&(this.matrixWorldNeedsUpdate=!0)}update(t){switch(this._updateCount(t),this.parameters.type){case"radial":this._updateRadial(this.parameters,t);break;case"linear":this._updateLinear(this.parameters,t);break;case"grid":this._updateGrid(this.parameters,t);break;case"toObject":this._updateToObject(this.parameters,t)}for(let t of this.children){let e=t.transformOverride;void 0!==e&&(t.position.fromArray(e.position),t.rotation.fromArray(e.rotation),t.scale.fromArray(e.scale)),t.updateMatrix(),t.hasNonUniformScale&&(t.updateMatrixWorld(),t.updateMatrixWorldRigid())}this._syncInstancedMesh(),this._invalidateBoolean()}get instancingActive(){return void 0!==this.instancedMesh}get insideBoolean(){return null!==this.parent&&"booleanOp"in this.parent}_instancingEligible(){if(!0!==this.parameters.instanced)return!1;let t=this.object;return!(t.entityChildrenCount()>0||!0!==t.isMesh||a(t)||!0===t.isDecalObject)}_syncInstancedMesh(){if(!this._instancingEligible())return void this._disposeInstancedMesh();let t=this.instancedMesh;if(void 0!==t&&t.capacity<this.children.length&&(this._disposeInstancedMesh(),t=void 0),void 0===t){let e=Math.max(8,Math.ceil(1.5*this.children.length));t=this.instancedMesh=new H(this.object,e)}t.matrix=this.matrix,t.hiddenMatrix=this.hiddenMatrix,t.matrixWorldNeedsUpdate=!0,t.parent!==this.parent&&(t.removeFromParent(),this.parent?.add(t)),this.syncInstanceMatrices()}syncInstanceMatrices(){this._invalidateBoolean();let t=this.instancedMesh;if(void 0===t)return;let e=0;for(let i of this.children)!1!==i.playModeVisible&&(et.multiplyMatrices(i.hiddenMatrix,i.matrix).multiply(i.pivotMatrix),t.setMatrixAt(e++,et));t.count=e,t.instanceMatrix.needsUpdate=!0,t.boundingSphere=null}_disposeInstancedMesh(){let t=this.instancedMesh;void 0!==t&&(this.instancedMesh=void 0,t.removeFromParent(),t.dispose())}_updateCount(t,e){let r;if(void 0!==e)r=e;else{let e=Mt(this.parameters.grid.count,t);r="grid"===this.parameters.type?Math.round(e[0])*Math.round(e[1])*Math.round(e[2]):this.parameters.count}if("toObject"===this.parameters.type)if(this.parameters.toObject.object){if(void 0===e&&"random"!==this.parameters.toObject.spreadType)return}else r=0;if(this.children.length!==r)if(this.children.length<r)for(let t=0,e=r-this.children.length;t<e;++t){let t=new i(this.object);t.expand(),this.add(t)}else for(;this.children.length>r;){let t=this.children.pop();t.parent=null,t.dispatchEvent({type:"removed"}),this.dispatchEvent({type:"childremoved",child:t})}}getRandom(t,e=!1){return(null===this.random||this.random.data.seed!==t.seed||this.random.data.noiseType!==t.noiseType||this.random.is3D!==e)&&(this.random=new wt(t,e)),this.random}_updateRadial(t,e){let i,r=t.radial,n=r.start*h.DEG2RAD,s=n-r.end*h.DEG2RAD,a=Mt(r.rotation,e),o=new p(a[0],a[1],a[2]);switch(r.axis){case"z":i=new c(0,0,1);break;case"y":i=new c(0,1,0);break;default:i=new c(1,0,0)}let d=t.randomnessObject??l.defaultData([1,1,1]).randomnessObject,u=!0===this.parameters.randomness&&0!==d.strength?this.getRandom(d):null,m=Mt(r.scale,e),f=Mt(r.position,e),y=Mt(d.scale,e),b=Mt(d.position,e),x=Mt(d.rotation,e),g=s/t.count,v=N(d.strength,this.parameters.randomness);for(let[t,e]of this.children.entries()){let s=t*(d.freqScale/10)+d.movement,a=null===u?0:u.noise(s,s,s),l=t+1;e.scale.x=m[0]+v(l,P(a,y[0]))||Z,e.scale.y=m[1]+v(l,P(a,y[1]))||Z,e.scale.z=m[2]+v(l,P(a,y[2]))||Z;let h=g*t-n;switch(r.axis){default:case"x":xt.set(0,h,0);break;case"y":xt.set(0,0,h);break;case"z":xt.set(h,0,0)}pt.copy(i).applyQuaternion(gt.setFromEuler(xt)).multiplyScalar(r.radius),e.position.set(pt.x+(f[0]+v(l,P(a,b[0]))),pt.y+(f[1]+v(l,P(a,b[1]))),pt.z+(f[2]+v(l,P(a,b[2]))));let c=v(l,P(a,x[0])),p=v(l,P(a,x[1])),M=v(l,P(a,x[2]));!0===r.alignment?e.rotation.set(xt.x+(o.x+c),xt.y+(o.y+p),xt.z+(o.z+M)):e.rotation.set(o.x+c,o.y+p,o.z+M)}}_updateLinear(t,e){if("linear"!==t.type)throw new Error;let i=t.linear,r=Mt(i.rotation,e),n=Mt(i.scale,e),s=Mt(i.position,e),a=new p(r[0]??0,r[1]??0,r[2]??0),o=t.randomnessObject??l.defaultData([1,1,1]).randomnessObject,h=Mt(o.rotation,e),d=Mt(o.scale,e),c=Mt(o.position,e),u=!0===this.parameters.randomness&&0!==o.strength?this.getRandom(o):null,m=N(o.strength,this.parameters.randomness);for(let[t,e]of this.children.entries()){let i=t*(o.freqScale/10)+o.movement,r=null===u?0:u.noise(i,i,i),l=t+1,p=m(l,P(r,h[0])),f=m(l,P(r,h[1])),y=m(l,P(r,h[2]));e.scale.x=1+(n[0]-1)*t+m(l,P(r,d[0]))||Z,e.scale.y=1+(n[1]-1)*t+m(l,P(r,d[1]))||Z,e.scale.z=1+(n[2]-1)*t+m(l,P(r,d[2]))||Z,e.rotation.set(a.x*t+p,a.y*t+f,a.z*t+y),e.position.x=s[0]*t+m(l,P(r,c[0])),e.position.y=s[1]*t+m(l,P(r,c[1])),e.position.z=s[2]*t+m(l,P(r,c[2]))}}_updateGrid(t,e){let i=0,r=t.grid,n=t.randomnessObject??l.defaultData([1,1,1]).randomnessObject,s=Mt(n.scale,e),a=Mt(n.rotation,e),o=Mt(n.position,e),h=!0===this.parameters.randomness&&0!==n.strength?this.getRandom(n,!0):null,d=N(n.strength,this.parameters.randomness),u=Mt(r.count,e),p=Mt(r.size,e);if(!0===r.useCenter){let t={x:u[0]%2==0?2:1,y:u[1]%2==0?2:1,z:u[2]%2==0?2:1},e=new c(p[0]*(u[0]-t.x)*.5,p[1]*(u[1]-t.y)*.5,p[2]*(u[2]-t.z)*.5);for(let t=0;t<u[0];t++)for(let r=0;r<u[1];r++)for(let l=0;l<u[2];l++){let c=this.children[i++];if(!c)continue;let u=null===h?0:h.noise((t+1)*(n.freqScale/10)+n.movement,(r+1)*(n.freqScale/10)+n.movement,(l+1)*(n.freqScale/10)+n.movement);c.scale.x=1+d(i,P(u,s[0]))||Z,c.scale.y=1+d(i,P(u,s[1]))||Z,c.scale.z=1+d(i,P(u,s[2]))||Z;let m=d(i,P(u,a[0])),f=d(i,P(u,a[1])),y=d(i,P(u,a[2]));c.rotation.set(m,f,y),c.position.x=p[0]*t-e.x+d(i,P(u,o[0])),c.position.y=p[1]*r-e.y+d(i,P(u,o[1])),c.position.z=p[2]*l-e.z+d(i,P(u,o[2]))}}else for(let t=0;t<u[0];t++)for(let e=0;e<u[1];e++)for(let r=0;r<u[2];r++){let l=this.children[i++];if(!l)continue;let c=null===h?0:h.noise((t+1)*(n.freqScale/10)+n.movement,(e+1)*(n.freqScale/10)+n.movement,(r+1)*(n.freqScale/10)+n.movement);l.scale.x=1+d(i,P(c,s[0]))||Z,l.scale.y=1+d(i,P(c,s[1]))||Z,l.scale.z=1+d(i,P(c,s[2]))||Z;let u=d(i,P(c,a[0])),m=d(i,P(c,a[1])),f=d(i,P(c,a[2]));l.rotation.set(u,m,f),l.position.x=p[0]*t+d(i,P(c,o[0])),l.position.y=-p[1]*e+d(i,P(c,o[1])),l.position.z=-p[2]*r+d(i,P(c,o[2]))}}_updateToObject(i,r){if("toObject"!==i.type)throw new Error;let{toObject:n}=i,s=Mt(n.rotation,r),a=Mt(n.position,r),o=Mt(n.scale,r),h=new p(s[0],s[1],s[2]),d=i.randomnessObject??l.defaultData([1,1,1]).randomnessObject,c=Mt(d.rotation,r),u=Mt(d.position,r),m=Mt(d.scale,r),f=!0===this.parameters.randomness&&0!==d.strength?this.getRandom(d):null,y=N(d.strength,this.parameters.randomness);if(!n.object){for(let[,t]of this.children.entries())t.position.set(0,0,0),t.scale.setScalar(1),t.rotation.set(0,0,0);return this.objectForSample=void 0,void this.invalidateSurfaceCaches()}if(!this.objectForSample)return;if(this.objectForSample instanceof t){if(!this.objectForSample.font?.isLoaded||void 0===this.objectForSample.geometry.attributes.position)return void(this._pendingMediaLoad=!0);this._pendingMediaLoad=!1}if(void 0===this.objectForSample.geometry&&this.objectForSample.isAncestorOf(this.object.uuid))return void console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) seem to be a child/descendant of the object it's being cloned to. Please re-parent it so that they are siblings instead.`);let b=this.getSubdivData();if(b.length>0){let t=Math.round(b.length*n.count/100);this._updateCount(r,t)}else{let t=this.objectForSample.geometry.getAttribute("position");if(!t||isNaN(t.count)||0===t.count)return void console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) cannot be cloned on the surface of "${this.objectForSample.name}" (${this.objectForSample.uuid}) because the latter does not have a valid geometry.`)}this.objectForSample.updateMatrixWorld();let x="random"===n.spreadType,v=null;x&&(v=this.getSurfaceSampler(),v.setRandomGenerator((0,g.default)(this.object.uuid+n.seed)));let M=z[n.axis],w=this.children;ot.fromArray(M),it.copy(this.object.hiddenMatrix).invert();let j=this.objectForSample instanceof e;j&&rt.copy(this.objectForSample.matrixWorld).invert(),"normal"!==n.align&&this.object.getWorldDirection(ut),yt.set(ot.y,ot.z,ot.x).normalize(),bt.copy(yt).cross(ot).normalize(),st.makeBasis(yt,ot,bt).invert();for(let[t,e]of w.entries()){let i=t*(d.freqScale/10)+d.movement,r=null===f?0:f.noise(i,i,i),s=t+1,l=y(s,P(r,c[0])),p=y(s,P(r,c[1])),g=y(s,P(r,c[2]));x?v.sample(ht,dt):(b.length&&(ht.fromArray(b[t].pos),dt.fromArray(b[t].norm)),j&&ht.applyMatrix4(rt)),ht.applyMatrix4(it),e.position.copy(ht);let M="normal"===n.align?dt:ut,w=lt.fromArray(a);lt.x+=y(s,P(r,u[0])),lt.y+=y(s,P(r,u[1])),lt.z+=y(s,P(r,u[2]));let A=Math.acos(M.dot(ot)),S=ct.crossVectors(ot,M).normalize(),F=tt.makeRotationAxis(S,A);mt.copy(M).cross(this.object.up).normalize(),ft.copy(mt).cross(M).normalize(),nt.makeBasis(mt,M,ft),at.multiplyMatrices(nt,st),xt.setFromRotationMatrix(at),w.applyMatrix4(F),e.position.add(w),e.rotation.set(xt.x+h.x+l,xt.y+h.y+p,xt.z+h.z+g),e.scale.set(1+o[0]+y(s,P(r,m[0]))||Z,1+o[1]+y(s,P(r,m[1]))||Z,1+o[2]+y(s,P(r,m[2]))||Z),e.scale.multiply(this.object.scale),e.hiddenMatrix=this.object.hiddenMatrix}}getSurfaceSampler(){let t=this.objectForSample,e=t.geometry,i=e.getAttribute("position"),r=e.index,n=this.surfaceSamplerCache;if(null!==n&&n.geometry===e&&n.position===i&&n.positionVersion===vt(i)&&n.index===r&&n.indexVersion===(null===r?-1:r.version))return n.sampler;let s=new W(t).build();return this.surfaceSamplerCache={geometry:e,position:i,positionVersion:vt(i),index:r,indexVersion:null===r?-1:r.version,sampler:s},s}invalidateSurfaceCaches(){this.surfaceSamplerCache=null,this.surfacePointsCache=null}getSubdivData(){if(!this.objectForSample)return[];let t=this.parameters.toObject.spreadType;if("random"===t)return[];let i=this.objectForSample instanceof e,r=this.objectForSample.geometry;if(!i&&r){let e=this.surfacePointsCache,i=r.getAttribute("position");if(null!==e&&e.spreadType===t&&e.geometry===r&&e.position===i&&e.positionVersion===vt(i)&&e.index===r.index&&e.indexVersion===(null===r.index?-1:r.index.version))return e.points}let n=new Map,s=(t,e)=>{let i=Math.round(1e4*t[0])+"_"+Math.round(1e4*t[1])+"_"+Math.round(1e4*t[2]),r=n.get(i);r?(r.pos[0]+=t[0],r.pos[1]+=t[1],r.pos[2]+=t[2],r.norm[0]+=e[0],r.norm[1]+=e[1],r.norm[2]+=e[2],r.count+=1):n.set(i,{pos:[...t],norm:[...e],count:1})};if(i){let e=this.objectForSample,i=C[t],r=D[i],n=R[i],a=q[i],o=r(e.subdivPointerNew);for(let t=0;t<=o-1;t++){let i=n(e.subdivPointerNew,t),r=a(e.subdivPointerNew,t);J.fromArray(i).applyMatrix4(e.matrixWorld),K.fromArray(r),s(J.toArray(),K.toArray())}}else(r.index?function(t){let e=[],i=Math.floor(t.index.count/3);for(let r=0;r<i;r++)if(L.fromArray(t.index.array,3*r),E.setFromAttributeAndIndices(t.attributes.position,L.x,L.y,L.z),E.getNormal(G),E.getMidpoint($),!(isNaN($.x)||isNaN($.y)||isNaN($.z))){let{a:t,b:i,c:r}=E,n=t.toArray(),s=i.toArray(),a=r.toArray(),o=t.distanceTo(i),l=i.distanceTo(r),h=r.distanceTo(t),d=U(n,s),c=U(s,a),u=U(a,n),p=[o,l,h],m=Math.max(...p),f=p.filter(t=>Math.round(t)===Math.round(m)).length>1,y=[],b=E.getMidpoint($).toArray();m===o&&!f&&(y=[c,u,u],b=d),m===l&&!f&&(y=[d,u,u],b=c),m===h&&!f&&(y=[d,c,c],b=u),f&&(y=[d,c,u]),e.push({vertices:[n,s,a],faceCenters:y,midpoint:b,norm:E.getNormal(G).toArray()})}return e}(r):function(t){let e=[],{position:i}=t.attributes;for(let t=0;t<i.count;t++){E.setFromAttributeAndIndices(i,3*t,3*t+1,3*t+2),E.getNormal(G),E.getMidpoint($);let r=E.a.toArray(),n=E.b.toArray(),s=E.c.toArray();e.push({vertices:[r,n,s],faceCenters:[U(r,n),U(n,s),U(s,r)],midpoint:$.toArray(),norm:G.toArray()})}return e}(r)).forEach((e,i)=>{"polygon_center"===t&&s(e.midpoint,e.norm),"vertex"===t&&(s(e.vertices[0],e.norm),s(e.vertices[1],e.norm),s(e.vertices[2],e.norm)),"edge"===t&&(s(e.faceCenters[0],e.norm),s(e.faceCenters[1],e.norm),s(e.faceCenters[2],e.norm))});let a=Array.from(n.values());for(let t of a)t.pos[0]/=t.count,t.pos[1]/=t.count,t.pos[2]/=t.count,t.norm[0]/=t.count,t.norm[1]/=t.count,t.norm[2]/=t.count;if(!i&&r){let e=r.getAttribute("position");this.surfacePointsCache={spreadType:t,geometry:r,position:e,positionVersion:vt(e),index:r.index,indexVersion:null===r.index?-1:r.index.version,points:a}}return a}updateState(t,e){if(this.parameters=o(t),"toObject"!==this.parameters.type)this.invalidateSurfaceCaches(),(null===this.parent||this.parent!==this.object)&&(this.removeFromParent(),this.object.parent?.add(this),this.matrix=this.object.matrix,this.hiddenMatrix=this.object.hiddenMatrix,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1);else if(null===this.parent||this.parent.uuid!==this.parameters.toObject.object){this.removeFromParent(),this.invalidateSurfaceCaches();let t=e.scene.find(this.parameters.toObject.object);this.objectForSample=t instanceof s?t:void 0,this.matrix=new u,this.hiddenMatrix=new u,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,t&&t.add(this)}this.update(e)}get pendingMediaLoad(){return this._pendingMediaLoad}};export{jt as a};
@@ -1 +1 @@
1
- import{a as e}from"./runtime-chunk-TU4KDRKR.js";import{W as o}from"./runtime-chunk-YFAATRJU.js";import{Dc as n,Fc as t,Jc as r}from"./runtime-chunk-VGN7YHB7.js";var i={enabled:!1},s=new WeakMap;function a(e){if(!i.enabled)return e;let o=s.get(e);return o||(o={...e,bloom:{...e.bloom,kernelSize:0},depthOfField:{...e.depthOfField,enabled:!1}},s.set(e,o)),o}var c=new WeakSet;function l(e){if(!e.isPointLight&&!e.isSpotLight&&!e.isDirectionalLight)return!1;if(i.enabled){if(!0===e.castShadow)return e.castShadow=!1,c.add(e),!0}else if(c.has(e)&&(c.delete(e),!1===e.castShadow))return e.castShadow=!0,!0;return!1}function u(i,s){switch(i.type){case"cavity":return function(e,o){return{...h(e,o),ridge:e.ridge,valley:e.valley}}(i,s);case"dust":return function(n,t){return{...h(n,t),color:e(n.color,t),coverage:o(n.coverage,t)??.2,softness:o(n.softness,t)??.2,noiseStrength:o(n.noiseStrength,t)??.2,noiseScale:o(n.noiseScale,t)??1}}(i,s);case"fresnel":return function(o,n){let{bias:t,scale:r,intensity:i,factor:s,color:a}=o;return{...h(o,n),color:e(a,n),bias:t,scale:r,intensity:i,factor:s}}(i,s);case"gradient":return function(e,o){let{gradientType:t,smooth:i,colors:s,steps:a,angle:c,offset:l,morph:u}=e;return{...h(e,o),gradientType:t,smooth:i,colors:s.map(e=>new r(e[0],e[1],e[2],e[3])),num:s.length,steps:a,offset:new n(...l.map(e=>"number"==typeof e?e:0)),morph:new n(...u.map(e=>"number"==typeof e?e:0)),angle:c}}(i,s);case"depth":return function(e,o){let{gradientType:n,near:i,far:s,isVector:a,isWorldSpace:c,origin:l,direction:u,colors:f,steps:p,smooth:m}=e;return{...h(e,o),gradientType:n,near:i,far:s,isVector:a,isWorldSpace:c,origin:new t(...l),direction:u?new t(...u):new t(1,0,0),colors:f.map(e=>void 0!==e?new r(e[0],e[1],e[2],e[3]):new r(0,0,0,0)),steps:p.slice(0,f.length),smooth:m}}(i,s);case"normal":return function(e,o){let{cnormal:n}=e;return{...h(e,o),cnormal:new t(n[0],n[1],n[2])}}(i,s);case"noise":return function(o,r){return{...h(o,r),scale:o.scale,move:o.move,fA:new n(...o.fA.map(e=>"number"==typeof e?e:0)),fB:new n(...o.fB.map(e=>"number"==typeof e?e:0)),size:new t(...o.size),distortion:new n(...o.distortion.map(e=>"number"==typeof e?e:0)),colorA:e(o.colorA,r),colorB:e(o.colorB,r),colorC:e(o.colorC,r),colorD:e(o.colorD,r),noiseType:o.noiseType,voronoiStyle:o.voronoiStyle,highCut:o.highCut,lowCut:o.lowCut,smoothness:o.smoothness,seed:o.seed,quality:o.quality}}(i,s);case"rainbow":return function(e,o){return{...h(e,o),filmThickness:e.filmThickness,movement:e.movement,wavelengths:new t(...e.wavelengths),noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,offset:new t(...e.offset)}}(i,s);case"toon":return function(o,n){return{...h(o,n),positioning:o.positioning,colors:o.colors.map(e=>new r(e[0],e[1],e[2],e[3])),num:o.colors.length,steps:o.steps,source:new t(...o.source),isWorldSpace:o.isWorldSpace,noiseStrength:o.noiseStrength,noiseScale:o.noiseScale,shadowColor:e(o.shadowColor,n),offset:new t(...o.offset)}}(i,s);case"outline":return function(o,n){return{...h(o,n),outlineColor:e(o.outlineColor,n),contourColor:e(o.contourColor,n),outlineWidth:o.outlineWidth,contourWidth:o.contourWidth,outlineThreshold:o.outlineThreshold,contourThreshold:o.contourThreshold,outlineSmoothing:o.outlineSmoothing,contourFrequency:o.contourFrequency,contourDirection:new t(...o.contourDirection),positionalLines:o.positionalLines,compensation:o.compensation}}(i,s);case"transmission":return function(o,n){return{...h(o,n),thickness:o.thickness,ior:o.ior,roughness:o.roughness,attenuationColor:void 0!==o.attenuationColor?e(o.attenuationColor,n):{r:1,g:1,b:1,a:1},attenuationDistance:o.attenuationDistance??0}}(i,s);case"reflection":return function(e,n){return{...h(e,n),blur:o(e.blur,n)??0,thickness:o(e.thickness,n)??.001,steps:o(e.steps,n)??60,stepSize:o(e.stepSize,n)??.005,tracingMode:e.tracingMode,mirror:e.mirror??0}}(i,s);case"pattern":return function(o,t){return{...h(o,t),style:o.style,projection:o.projection,axis:o.axis,blending:o.blending,offset:new n(...o.offset.map(e=>"number"==typeof e?e:0)),colorA:e(o.colorA,t),colorB:e(o.colorB,t),frequency:new n(...o.frequency.map(e=>"number"==typeof e?e:0)),size:o.size,variation:o.variation,smoothness:o.smoothness,zigzag:o.zigzag,rotation:o.rotation,vertical:new n(...o.vertical.map(e=>"number"==typeof e?e:0)),horizontal:new n(...o.horizontal.map(e=>"number"==typeof e?e:0)),sides:o.sides}}(i,s);case"vertexColor":return h(i,s);default:return function(o,n){return{...h(o,n),color:e(o.color,n)}}(i,s)}}function f(e){return{type:e.type}}function h(e,o){let{alpha:n,mode:t,isMask:r}=e,i="string"==typeof n?Number(o.getVariable(n)??100)/100:n;return{...f(e),alpha:i,mode:t,isMask:r}}export{i as a,a as b,l as c,u as d};
1
+ import{a as e}from"./runtime-chunk-TU4KDRKR.js";import{W as o}from"./runtime-chunk-LALFWESO.js";import{Dc as n,Fc as t,Jc as r}from"./runtime-chunk-VGN7YHB7.js";var i={enabled:!1},s=new WeakMap;function a(e){if(!i.enabled)return e;let o=s.get(e);return o||(o={...e,bloom:{...e.bloom,kernelSize:0},depthOfField:{...e.depthOfField,enabled:!1}},s.set(e,o)),o}var c=new WeakSet;function l(e){if(!e.isPointLight&&!e.isSpotLight&&!e.isDirectionalLight)return!1;if(i.enabled){if(!0===e.castShadow)return e.castShadow=!1,c.add(e),!0}else if(c.has(e)&&(c.delete(e),!1===e.castShadow))return e.castShadow=!0,!0;return!1}function u(i,s){switch(i.type){case"cavity":return function(e,o){return{...h(e,o),ridge:e.ridge,valley:e.valley}}(i,s);case"dust":return function(n,t){return{...h(n,t),color:e(n.color,t),coverage:o(n.coverage,t)??.2,softness:o(n.softness,t)??.2,noiseStrength:o(n.noiseStrength,t)??.2,noiseScale:o(n.noiseScale,t)??1}}(i,s);case"fresnel":return function(o,n){let{bias:t,scale:r,intensity:i,factor:s,color:a}=o;return{...h(o,n),color:e(a,n),bias:t,scale:r,intensity:i,factor:s}}(i,s);case"gradient":return function(e,o){let{gradientType:t,smooth:i,colors:s,steps:a,angle:c,offset:l,morph:u}=e;return{...h(e,o),gradientType:t,smooth:i,colors:s.map(e=>new r(e[0],e[1],e[2],e[3])),num:s.length,steps:a,offset:new n(...l.map(e=>"number"==typeof e?e:0)),morph:new n(...u.map(e=>"number"==typeof e?e:0)),angle:c}}(i,s);case"depth":return function(e,o){let{gradientType:n,near:i,far:s,isVector:a,isWorldSpace:c,origin:l,direction:u,colors:f,steps:p,smooth:m}=e;return{...h(e,o),gradientType:n,near:i,far:s,isVector:a,isWorldSpace:c,origin:new t(...l),direction:u?new t(...u):new t(1,0,0),colors:f.map(e=>void 0!==e?new r(e[0],e[1],e[2],e[3]):new r(0,0,0,0)),steps:p.slice(0,f.length),smooth:m}}(i,s);case"normal":return function(e,o){let{cnormal:n}=e;return{...h(e,o),cnormal:new t(n[0],n[1],n[2])}}(i,s);case"noise":return function(o,r){return{...h(o,r),scale:o.scale,move:o.move,fA:new n(...o.fA.map(e=>"number"==typeof e?e:0)),fB:new n(...o.fB.map(e=>"number"==typeof e?e:0)),size:new t(...o.size),distortion:new n(...o.distortion.map(e=>"number"==typeof e?e:0)),colorA:e(o.colorA,r),colorB:e(o.colorB,r),colorC:e(o.colorC,r),colorD:e(o.colorD,r),noiseType:o.noiseType,voronoiStyle:o.voronoiStyle,highCut:o.highCut,lowCut:o.lowCut,smoothness:o.smoothness,seed:o.seed,quality:o.quality}}(i,s);case"rainbow":return function(e,o){return{...h(e,o),filmThickness:e.filmThickness,movement:e.movement,wavelengths:new t(...e.wavelengths),noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,offset:new t(...e.offset)}}(i,s);case"toon":return function(o,n){return{...h(o,n),positioning:o.positioning,colors:o.colors.map(e=>new r(e[0],e[1],e[2],e[3])),num:o.colors.length,steps:o.steps,source:new t(...o.source),isWorldSpace:o.isWorldSpace,noiseStrength:o.noiseStrength,noiseScale:o.noiseScale,shadowColor:e(o.shadowColor,n),offset:new t(...o.offset)}}(i,s);case"outline":return function(o,n){return{...h(o,n),outlineColor:e(o.outlineColor,n),contourColor:e(o.contourColor,n),outlineWidth:o.outlineWidth,contourWidth:o.contourWidth,outlineThreshold:o.outlineThreshold,contourThreshold:o.contourThreshold,outlineSmoothing:o.outlineSmoothing,contourFrequency:o.contourFrequency,contourDirection:new t(...o.contourDirection),positionalLines:o.positionalLines,compensation:o.compensation}}(i,s);case"transmission":return function(o,n){return{...h(o,n),thickness:o.thickness,ior:o.ior,roughness:o.roughness,attenuationColor:void 0!==o.attenuationColor?e(o.attenuationColor,n):{r:1,g:1,b:1,a:1},attenuationDistance:o.attenuationDistance??0}}(i,s);case"reflection":return function(e,n){return{...h(e,n),blur:o(e.blur,n)??0,thickness:o(e.thickness,n)??.001,steps:o(e.steps,n)??60,stepSize:o(e.stepSize,n)??.005,tracingMode:e.tracingMode,mirror:e.mirror??0}}(i,s);case"pattern":return function(o,t){return{...h(o,t),style:o.style,projection:o.projection,axis:o.axis,blending:o.blending,offset:new n(...o.offset.map(e=>"number"==typeof e?e:0)),colorA:e(o.colorA,t),colorB:e(o.colorB,t),frequency:new n(...o.frequency.map(e=>"number"==typeof e?e:0)),size:o.size,variation:o.variation,smoothness:o.smoothness,zigzag:o.zigzag,rotation:o.rotation,vertical:new n(...o.vertical.map(e=>"number"==typeof e?e:0)),horizontal:new n(...o.horizontal.map(e=>"number"==typeof e?e:0)),sides:o.sides}}(i,s);case"vertexColor":return h(i,s);default:return function(o,n){return{...h(o,n),color:e(o.color,n)}}(i,s)}}function f(e){return{type:e.type}}function h(e,o){let{alpha:n,mode:t,isMask:r}=e,i="string"==typeof n?Number(o.getVariable(n)??100)/100:n;return{...f(e),alpha:i,mode:t,isMask:r}}export{i as a,a as b,l as c,u as d};