@babylonjs/viewer 7.29.0 → 7.30.0-alpha

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 (587) hide show
  1. package/assets/photoStudio.env +0 -0
  2. package/dist/babylon-viewer.esm.js +2 -0
  3. package/dist/babylon-viewer.esm.js.map +1 -0
  4. package/dist/babylon-viewer.esm.min.js +2 -0
  5. package/dist/babylon-viewer.esm.min.js.map +1 -0
  6. package/dist/chunks/EXT_lights_image_based-B4Xt4AvY.esm.min.js +2 -0
  7. package/dist/chunks/EXT_lights_image_based-B4Xt4AvY.esm.min.js.map +1 -0
  8. package/dist/chunks/EXT_lights_image_based-BRvZpdd4.esm.js +172 -0
  9. package/dist/chunks/EXT_lights_image_based-BRvZpdd4.esm.js.map +1 -0
  10. package/dist/chunks/EXT_mesh_gpu_instancing-BqLQo4Vx.esm.min.js +2 -0
  11. package/dist/chunks/EXT_mesh_gpu_instancing-BqLQo4Vx.esm.min.js.map +1 -0
  12. package/dist/chunks/EXT_mesh_gpu_instancing-ua5eHgOH.esm.js +86 -0
  13. package/dist/chunks/EXT_mesh_gpu_instancing-ua5eHgOH.esm.js.map +1 -0
  14. package/dist/chunks/EXT_meshopt_compression-CRDQWjAR.esm.js +134 -0
  15. package/dist/chunks/EXT_meshopt_compression-CRDQWjAR.esm.js.map +1 -0
  16. package/dist/chunks/EXT_meshopt_compression-W8L60mKL.esm.min.js +2 -0
  17. package/dist/chunks/EXT_meshopt_compression-W8L60mKL.esm.min.js.map +1 -0
  18. package/dist/chunks/EXT_texture_avif-D1fIwaNM.esm.min.js +2 -0
  19. package/dist/chunks/EXT_texture_avif-D1fIwaNM.esm.min.js.map +1 -0
  20. package/dist/chunks/EXT_texture_avif-p27vq5Yf.esm.js +44 -0
  21. package/dist/chunks/EXT_texture_avif-p27vq5Yf.esm.js.map +1 -0
  22. package/dist/chunks/EXT_texture_webp-BH7GGRed.esm.js +43 -0
  23. package/dist/chunks/EXT_texture_webp-BH7GGRed.esm.js.map +1 -0
  24. package/dist/chunks/EXT_texture_webp-CKV0mQmY.esm.min.js +2 -0
  25. package/dist/chunks/EXT_texture_webp-CKV0mQmY.esm.min.js.map +1 -0
  26. package/dist/chunks/ExtrasAsMetadata-CJnenqsC.esm.min.js +2 -0
  27. package/dist/chunks/ExtrasAsMetadata-CJnenqsC.esm.min.js.map +1 -0
  28. package/dist/chunks/ExtrasAsMetadata-CuWNhdYD.esm.js +64 -0
  29. package/dist/chunks/ExtrasAsMetadata-CuWNhdYD.esm.js.map +1 -0
  30. package/dist/chunks/KHR_animation_pointer-B9MwkxxI.esm.js +343 -0
  31. package/dist/chunks/KHR_animation_pointer-B9MwkxxI.esm.js.map +1 -0
  32. package/dist/chunks/KHR_animation_pointer-OKndtcZ4.esm.min.js +2 -0
  33. package/dist/chunks/KHR_animation_pointer-OKndtcZ4.esm.min.js.map +1 -0
  34. package/dist/chunks/KHR_draco_mesh_compression-BfVEM6a3.esm.js +610 -0
  35. package/dist/chunks/KHR_draco_mesh_compression-BfVEM6a3.esm.js.map +1 -0
  36. package/dist/chunks/KHR_draco_mesh_compression-DVS_gHcG.esm.min.js +2 -0
  37. package/dist/chunks/KHR_draco_mesh_compression-DVS_gHcG.esm.min.js.map +1 -0
  38. package/dist/chunks/KHR_interactivity-5quPuMwF.esm.js +4033 -0
  39. package/dist/chunks/KHR_interactivity-5quPuMwF.esm.js.map +1 -0
  40. package/dist/chunks/KHR_interactivity-XBa4dMpI.esm.min.js +2 -0
  41. package/dist/chunks/KHR_interactivity-XBa4dMpI.esm.min.js.map +1 -0
  42. package/dist/chunks/KHR_lights_punctual-B7Rxkv7-.esm.min.js +2 -0
  43. package/dist/chunks/KHR_lights_punctual-B7Rxkv7-.esm.min.js.map +1 -0
  44. package/dist/chunks/KHR_lights_punctual-CNwt0QLf.esm.js +1253 -0
  45. package/dist/chunks/KHR_lights_punctual-CNwt0QLf.esm.js.map +1 -0
  46. package/dist/chunks/KHR_materials_anisotropy-BAFTyZiR.esm.js +64 -0
  47. package/dist/chunks/KHR_materials_anisotropy-BAFTyZiR.esm.js.map +1 -0
  48. package/dist/chunks/KHR_materials_anisotropy-oViSetIs.esm.min.js +2 -0
  49. package/dist/chunks/KHR_materials_anisotropy-oViSetIs.esm.min.js.map +1 -0
  50. package/dist/chunks/KHR_materials_clearcoat-5qLT0AOT.esm.min.js +2 -0
  51. package/dist/chunks/KHR_materials_clearcoat-5qLT0AOT.esm.min.js.map +1 -0
  52. package/dist/chunks/KHR_materials_clearcoat-B1L15R_S.esm.js +96 -0
  53. package/dist/chunks/KHR_materials_clearcoat-B1L15R_S.esm.js.map +1 -0
  54. package/dist/chunks/KHR_materials_diffuse_transmission-BS8lBPS0.esm.min.js +2 -0
  55. package/dist/chunks/KHR_materials_diffuse_transmission-BS8lBPS0.esm.min.js.map +1 -0
  56. package/dist/chunks/KHR_materials_diffuse_transmission-TevKWUOq.esm.js +97 -0
  57. package/dist/chunks/KHR_materials_diffuse_transmission-TevKWUOq.esm.js.map +1 -0
  58. package/dist/chunks/KHR_materials_dispersion-BQZSVfHy.esm.min.js +2 -0
  59. package/dist/chunks/KHR_materials_dispersion-BQZSVfHy.esm.min.js.map +1 -0
  60. package/dist/chunks/KHR_materials_dispersion-Cq9yaReu.esm.js +62 -0
  61. package/dist/chunks/KHR_materials_dispersion-Cq9yaReu.esm.js.map +1 -0
  62. package/dist/chunks/KHR_materials_emissive_strength-Ce346XXu.esm.js +55 -0
  63. package/dist/chunks/KHR_materials_emissive_strength-Ce346XXu.esm.js.map +1 -0
  64. package/dist/chunks/KHR_materials_emissive_strength-SHFGsIaq.esm.min.js +2 -0
  65. package/dist/chunks/KHR_materials_emissive_strength-SHFGsIaq.esm.min.js.map +1 -0
  66. package/dist/chunks/KHR_materials_ior-CTHicJIL.esm.js +64 -0
  67. package/dist/chunks/KHR_materials_ior-CTHicJIL.esm.js.map +1 -0
  68. package/dist/chunks/KHR_materials_ior-D5SP8TfG.esm.min.js +2 -0
  69. package/dist/chunks/KHR_materials_ior-D5SP8TfG.esm.min.js.map +1 -0
  70. package/dist/chunks/KHR_materials_iridescence-CTpiXRMt.esm.js +72 -0
  71. package/dist/chunks/KHR_materials_iridescence-CTpiXRMt.esm.js.map +1 -0
  72. package/dist/chunks/KHR_materials_iridescence-Lmm2mJIb.esm.min.js +2 -0
  73. package/dist/chunks/KHR_materials_iridescence-Lmm2mJIb.esm.min.js.map +1 -0
  74. package/dist/chunks/KHR_materials_pbrSpecularGlossiness-BOA2n0lL.esm.min.js +2 -0
  75. package/dist/chunks/KHR_materials_pbrSpecularGlossiness-BOA2n0lL.esm.min.js.map +1 -0
  76. package/dist/chunks/KHR_materials_pbrSpecularGlossiness-B_cxOfAG.esm.js +81 -0
  77. package/dist/chunks/KHR_materials_pbrSpecularGlossiness-B_cxOfAG.esm.js.map +1 -0
  78. package/dist/chunks/KHR_materials_sheen-BeBV2f5V.esm.min.js +2 -0
  79. package/dist/chunks/KHR_materials_sheen-BeBV2f5V.esm.min.js.map +1 -0
  80. package/dist/chunks/KHR_materials_sheen-rEkwk_qf.esm.js +85 -0
  81. package/dist/chunks/KHR_materials_sheen-rEkwk_qf.esm.js.map +1 -0
  82. package/dist/chunks/KHR_materials_specular-3QfzQZ4C.esm.js +75 -0
  83. package/dist/chunks/KHR_materials_specular-3QfzQZ4C.esm.js.map +1 -0
  84. package/dist/chunks/KHR_materials_specular-D60n51mC.esm.min.js +2 -0
  85. package/dist/chunks/KHR_materials_specular-D60n51mC.esm.min.js.map +1 -0
  86. package/dist/chunks/KHR_materials_transmission-ChRPypfG.esm.min.js +2 -0
  87. package/dist/chunks/KHR_materials_transmission-ChRPypfG.esm.min.js.map +1 -0
  88. package/dist/chunks/KHR_materials_transmission-PcBf5srt.esm.js +307 -0
  89. package/dist/chunks/KHR_materials_transmission-PcBf5srt.esm.js.map +1 -0
  90. package/dist/chunks/KHR_materials_unlit-CeDIqHL0.esm.js +74 -0
  91. package/dist/chunks/KHR_materials_unlit-CeDIqHL0.esm.js.map +1 -0
  92. package/dist/chunks/KHR_materials_unlit-wEsp1t5U.esm.min.js +2 -0
  93. package/dist/chunks/KHR_materials_unlit-wEsp1t5U.esm.min.js.map +1 -0
  94. package/dist/chunks/KHR_materials_variants-CkJeN1Gu.esm.js +238 -0
  95. package/dist/chunks/KHR_materials_variants-CkJeN1Gu.esm.js.map +1 -0
  96. package/dist/chunks/KHR_materials_variants-bRFFd4Z_.esm.min.js +2 -0
  97. package/dist/chunks/KHR_materials_variants-bRFFd4Z_.esm.min.js.map +1 -0
  98. package/dist/chunks/KHR_materials_volume-CWyybXGD.esm.js +87 -0
  99. package/dist/chunks/KHR_materials_volume-CWyybXGD.esm.js.map +1 -0
  100. package/dist/chunks/KHR_materials_volume-DeFCqj9d.esm.min.js +2 -0
  101. package/dist/chunks/KHR_materials_volume-DeFCqj9d.esm.min.js.map +1 -0
  102. package/dist/chunks/KHR_mesh_quantization-LWID2Hhs.esm.js +26 -0
  103. package/dist/chunks/KHR_mesh_quantization-LWID2Hhs.esm.js.map +1 -0
  104. package/dist/chunks/KHR_mesh_quantization-h74l2bXe.esm.min.js +2 -0
  105. package/dist/chunks/KHR_mesh_quantization-h74l2bXe.esm.min.js.map +1 -0
  106. package/dist/chunks/KHR_texture_basisu-DuFmJTdG.esm.js +43 -0
  107. package/dist/chunks/KHR_texture_basisu-DuFmJTdG.esm.js.map +1 -0
  108. package/dist/chunks/KHR_texture_basisu-HVmBlv46.esm.min.js +2 -0
  109. package/dist/chunks/KHR_texture_basisu-HVmBlv46.esm.min.js.map +1 -0
  110. package/dist/chunks/KHR_texture_transform-CrxnTEHA.esm.js +63 -0
  111. package/dist/chunks/KHR_texture_transform-CrxnTEHA.esm.js.map +1 -0
  112. package/dist/chunks/KHR_texture_transform-DQqJ1P3H.esm.min.js +2 -0
  113. package/dist/chunks/KHR_texture_transform-DQqJ1P3H.esm.min.js.map +1 -0
  114. package/dist/chunks/KHR_xmp_json_ld-BlIyp160.esm.min.js +2 -0
  115. package/dist/chunks/KHR_xmp_json_ld-BlIyp160.esm.min.js.map +1 -0
  116. package/dist/chunks/KHR_xmp_json_ld-CdBV8pKC.esm.js +51 -0
  117. package/dist/chunks/KHR_xmp_json_ld-CdBV8pKC.esm.js.map +1 -0
  118. package/dist/chunks/MSFT_audio_emitter-16nvoUyy.esm.min.js +2 -0
  119. package/dist/chunks/MSFT_audio_emitter-16nvoUyy.esm.min.js.map +1 -0
  120. package/dist/chunks/MSFT_audio_emitter-DWMijzpF.esm.js +2207 -0
  121. package/dist/chunks/MSFT_audio_emitter-DWMijzpF.esm.js.map +1 -0
  122. package/dist/chunks/MSFT_lod-BuMFATKv.esm.min.js +2 -0
  123. package/dist/chunks/MSFT_lod-BuMFATKv.esm.min.js.map +1 -0
  124. package/dist/chunks/MSFT_lod-CylrxheB.esm.js +337 -0
  125. package/dist/chunks/MSFT_lod-CylrxheB.esm.js.map +1 -0
  126. package/dist/chunks/MSFT_minecraftMesh-A_gbARss.esm.min.js +2 -0
  127. package/dist/chunks/MSFT_minecraftMesh-A_gbARss.esm.min.js.map +1 -0
  128. package/dist/chunks/MSFT_minecraftMesh-DWRlrr0e.esm.js +46 -0
  129. package/dist/chunks/MSFT_minecraftMesh-DWRlrr0e.esm.js.map +1 -0
  130. package/dist/chunks/MSFT_sRGBFactors-D9OfsqP5.esm.min.js +2 -0
  131. package/dist/chunks/MSFT_sRGBFactors-D9OfsqP5.esm.min.js.map +1 -0
  132. package/dist/chunks/MSFT_sRGBFactors-DkKTM2sQ.esm.js +47 -0
  133. package/dist/chunks/MSFT_sRGBFactors-DkKTM2sQ.esm.js.map +1 -0
  134. package/dist/chunks/animationGroup-BP53dhpk.esm.min.js +2 -0
  135. package/dist/chunks/animationGroup-BP53dhpk.esm.min.js.map +1 -0
  136. package/dist/chunks/animationGroup-ZEdzz7Rp.esm.js +2479 -0
  137. package/dist/chunks/animationGroup-ZEdzz7Rp.esm.js.map +1 -0
  138. package/dist/chunks/assetContainer-BrmmAQqf.esm.js +1720 -0
  139. package/dist/chunks/assetContainer-BrmmAQqf.esm.js.map +1 -0
  140. package/dist/chunks/assetContainer-EHiJBw6m.esm.min.js +2 -0
  141. package/dist/chunks/assetContainer-EHiJBw6m.esm.min.js.map +1 -0
  142. package/dist/chunks/audioEngine-Bl-V_xWs.esm.js +305 -0
  143. package/dist/chunks/audioEngine-Bl-V_xWs.esm.js.map +1 -0
  144. package/dist/chunks/audioEngine-C391rgB7.esm.min.js +2 -0
  145. package/dist/chunks/audioEngine-C391rgB7.esm.min.js.map +1 -0
  146. package/dist/chunks/bakedVertexAnimation-CGiPluyk.esm.js +119 -0
  147. package/dist/chunks/bakedVertexAnimation-CGiPluyk.esm.js.map +1 -0
  148. package/dist/chunks/bakedVertexAnimation-Dge7hdZG.esm.min.js +2 -0
  149. package/dist/chunks/bakedVertexAnimation-Dge7hdZG.esm.min.js.map +1 -0
  150. package/dist/chunks/basisTextureLoader-Bc4P2Hq-.esm.js +600 -0
  151. package/dist/chunks/basisTextureLoader-Bc4P2Hq-.esm.js.map +1 -0
  152. package/dist/chunks/basisTextureLoader-C-qnWNed.esm.min.js +2 -0
  153. package/dist/chunks/basisTextureLoader-C-qnWNed.esm.min.js.map +1 -0
  154. package/dist/chunks/dds-BG7k2xlh.esm.js +540 -0
  155. package/dist/chunks/dds-BG7k2xlh.esm.js.map +1 -0
  156. package/dist/chunks/dds-CuthKiJg.esm.min.js +2 -0
  157. package/dist/chunks/dds-CuthKiJg.esm.min.js.map +1 -0
  158. package/dist/chunks/ddsTextureLoader-9zLW4poX.esm.min.js +2 -0
  159. package/dist/chunks/ddsTextureLoader-9zLW4poX.esm.min.js.map +1 -0
  160. package/dist/chunks/ddsTextureLoader-DMd7ykRq.esm.js +88 -0
  161. package/dist/chunks/ddsTextureLoader-DMd7ykRq.esm.js.map +1 -0
  162. package/dist/chunks/decalFragment-D0g_uzVu.esm.js +18 -0
  163. package/dist/chunks/decalFragment-D0g_uzVu.esm.js.map +1 -0
  164. package/dist/chunks/decalFragment-Ddg15UlL.esm.min.js +2 -0
  165. package/dist/chunks/decalFragment-Ddg15UlL.esm.min.js.map +1 -0
  166. package/dist/chunks/default.fragment-9JSiYlCh.esm.min.js +2 -0
  167. package/dist/chunks/default.fragment-9JSiYlCh.esm.min.js.map +1 -0
  168. package/dist/chunks/default.fragment-BmwG-luV.esm.min.js +2 -0
  169. package/dist/chunks/default.fragment-BmwG-luV.esm.min.js.map +1 -0
  170. package/dist/chunks/default.fragment-DRQjxOwb.esm.js +449 -0
  171. package/dist/chunks/default.fragment-DRQjxOwb.esm.js.map +1 -0
  172. package/dist/chunks/default.fragment-Deigj0Q2.esm.js +515 -0
  173. package/dist/chunks/default.fragment-Deigj0Q2.esm.js.map +1 -0
  174. package/dist/chunks/default.vertex-CH2XtSMw.esm.min.js +2 -0
  175. package/dist/chunks/default.vertex-CH2XtSMw.esm.min.js.map +1 -0
  176. package/dist/chunks/default.vertex-XL5Bzzg0.esm.min.js +2 -0
  177. package/dist/chunks/default.vertex-XL5Bzzg0.esm.min.js.map +1 -0
  178. package/dist/chunks/default.vertex-ho2YN-vx.esm.js +199 -0
  179. package/dist/chunks/default.vertex-ho2YN-vx.esm.js.map +1 -0
  180. package/dist/chunks/default.vertex-n2K0S1Zx.esm.js +180 -0
  181. package/dist/chunks/default.vertex-n2K0S1Zx.esm.js.map +1 -0
  182. package/dist/chunks/defaultUboDeclaration-Bu1z_Z5I.esm.js +15 -0
  183. package/dist/chunks/defaultUboDeclaration-Bu1z_Z5I.esm.js.map +1 -0
  184. package/dist/chunks/defaultUboDeclaration-DQJ-Joa1.esm.min.js +2 -0
  185. package/dist/chunks/defaultUboDeclaration-DQJ-Joa1.esm.min.js.map +1 -0
  186. package/dist/chunks/defaultUboDeclaration-SE8nYnOu.esm.js +13 -0
  187. package/dist/chunks/defaultUboDeclaration-SE8nYnOu.esm.js.map +1 -0
  188. package/dist/chunks/defaultUboDeclaration-eMXwSllo.esm.min.js +2 -0
  189. package/dist/chunks/defaultUboDeclaration-eMXwSllo.esm.min.js.map +1 -0
  190. package/dist/chunks/drawWrapper.functions-CKg3_9x4.esm.js +11 -0
  191. package/dist/chunks/drawWrapper.functions-CKg3_9x4.esm.js.map +1 -0
  192. package/dist/chunks/drawWrapper.functions-ng7lvueZ.esm.min.js +2 -0
  193. package/dist/chunks/drawWrapper.functions-ng7lvueZ.esm.min.js.map +1 -0
  194. package/dist/chunks/dumpTools-BA0AiO2-.esm.min.js +2 -0
  195. package/dist/chunks/dumpTools-BA0AiO2-.esm.min.js.map +1 -0
  196. package/dist/chunks/dumpTools-BeroMY8P.esm.js +401 -0
  197. package/dist/chunks/dumpTools-BeroMY8P.esm.js.map +1 -0
  198. package/dist/chunks/engine-BponnUEA.esm.js +2174 -0
  199. package/dist/chunks/engine-BponnUEA.esm.js.map +1 -0
  200. package/dist/chunks/engine-hvlYkRXH.esm.min.js +2 -0
  201. package/dist/chunks/engine-hvlYkRXH.esm.min.js.map +1 -0
  202. package/dist/chunks/engine.common-C-zFydIX.esm.min.js +2 -0
  203. package/dist/chunks/engine.common-C-zFydIX.esm.min.js.map +1 -0
  204. package/dist/chunks/engine.common-D9raApEJ.esm.js +1088 -0
  205. package/dist/chunks/engine.common-D9raApEJ.esm.js.map +1 -0
  206. package/dist/chunks/envTextureLoader-D1y2KvQy.esm.js +65 -0
  207. package/dist/chunks/envTextureLoader-D1y2KvQy.esm.js.map +1 -0
  208. package/dist/chunks/envTextureLoader-DJzPxg42.esm.min.js +2 -0
  209. package/dist/chunks/envTextureLoader-DJzPxg42.esm.min.js.map +1 -0
  210. package/dist/chunks/environmentTextureTools-C4Fxqpe8.esm.js +382 -0
  211. package/dist/chunks/environmentTextureTools-C4Fxqpe8.esm.js.map +1 -0
  212. package/dist/chunks/environmentTextureTools-DToTGSrH.esm.min.js +2 -0
  213. package/dist/chunks/environmentTextureTools-DToTGSrH.esm.min.js.map +1 -0
  214. package/dist/chunks/exrTextureLoader-DvL84Eax.esm.min.js +2 -0
  215. package/dist/chunks/exrTextureLoader-DvL84Eax.esm.min.js.map +1 -0
  216. package/dist/chunks/exrTextureLoader-q6eCg2vv.esm.js +1682 -0
  217. package/dist/chunks/exrTextureLoader-q6eCg2vv.esm.js.map +1 -0
  218. package/dist/chunks/fogFragment-B-SgDvU3.esm.min.js +2 -0
  219. package/dist/chunks/fogFragment-B-SgDvU3.esm.min.js.map +1 -0
  220. package/dist/chunks/fogFragment-n-fnZX94.esm.js +102 -0
  221. package/dist/chunks/fogFragment-n-fnZX94.esm.js.map +1 -0
  222. package/dist/chunks/fresnelFunction-B6PWvywn.esm.min.js +2 -0
  223. package/dist/chunks/fresnelFunction-B6PWvywn.esm.min.js.map +1 -0
  224. package/dist/chunks/fresnelFunction-D-whmVhn.esm.js +12 -0
  225. package/dist/chunks/fresnelFunction-D-whmVhn.esm.js.map +1 -0
  226. package/dist/chunks/glTFLoader-Dm9XfNeo.esm.min.js +2 -0
  227. package/dist/chunks/glTFLoader-Dm9XfNeo.esm.min.js.map +1 -0
  228. package/dist/chunks/glTFLoader-Xw19UZ20.esm.js +7562 -0
  229. package/dist/chunks/glTFLoader-Xw19UZ20.esm.js.map +1 -0
  230. package/dist/chunks/glTFLoaderAnimation-Bk4N1D9z.esm.js +77 -0
  231. package/dist/chunks/glTFLoaderAnimation-Bk4N1D9z.esm.js.map +1 -0
  232. package/dist/chunks/glTFLoaderAnimation-PL24R6Mg.esm.min.js +2 -0
  233. package/dist/chunks/glTFLoaderAnimation-PL24R6Mg.esm.min.js.map +1 -0
  234. package/dist/chunks/gltfPathToObjectConverter-Dyt_Y9jE.esm.min.js +2 -0
  235. package/dist/chunks/gltfPathToObjectConverter-Dyt_Y9jE.esm.min.js.map +1 -0
  236. package/dist/chunks/gltfPathToObjectConverter-GcUmfOyo.esm.js +67 -0
  237. package/dist/chunks/gltfPathToObjectConverter-GcUmfOyo.esm.js.map +1 -0
  238. package/dist/chunks/harmonicsFunctions-Bz6Qagd3.esm.js +35 -0
  239. package/dist/chunks/harmonicsFunctions-Bz6Qagd3.esm.js.map +1 -0
  240. package/dist/chunks/harmonicsFunctions-C1EkOgp3.esm.min.js +2 -0
  241. package/dist/chunks/harmonicsFunctions-C1EkOgp3.esm.min.js.map +1 -0
  242. package/dist/chunks/harmonicsFunctions-CDkb6KiL.esm.min.js +2 -0
  243. package/dist/chunks/harmonicsFunctions-CDkb6KiL.esm.min.js.map +1 -0
  244. package/dist/chunks/harmonicsFunctions-DVYeo2vE.esm.js +34 -0
  245. package/dist/chunks/harmonicsFunctions-DVYeo2vE.esm.js.map +1 -0
  246. package/dist/chunks/hdrTextureLoader-CuLmZKJK.esm.js +252 -0
  247. package/dist/chunks/hdrTextureLoader-CuLmZKJK.esm.js.map +1 -0
  248. package/dist/chunks/hdrTextureLoader-g5DTHiEG.esm.min.js +2 -0
  249. package/dist/chunks/hdrTextureLoader-g5DTHiEG.esm.min.js.map +1 -0
  250. package/dist/chunks/helperFunctions-7JG-lsyn.esm.js +108 -0
  251. package/dist/chunks/helperFunctions-7JG-lsyn.esm.js.map +1 -0
  252. package/dist/chunks/helperFunctions-BdzvbKSC.esm.min.js +2 -0
  253. package/dist/chunks/helperFunctions-BdzvbKSC.esm.min.js.map +1 -0
  254. package/dist/chunks/helperFunctions-C0y7EPxj.esm.min.js +2 -0
  255. package/dist/chunks/helperFunctions-C0y7EPxj.esm.min.js.map +1 -0
  256. package/dist/chunks/helperFunctions-Ddzd7G-L.esm.js +80 -0
  257. package/dist/chunks/helperFunctions-Ddzd7G-L.esm.js.map +1 -0
  258. package/dist/chunks/index-ClSS0i3r.esm.min.js +57 -0
  259. package/dist/chunks/index-ClSS0i3r.esm.min.js.map +1 -0
  260. package/dist/chunks/index-DzE-qoIA.esm.js +72021 -0
  261. package/dist/chunks/index-DzE-qoIA.esm.js.map +1 -0
  262. package/dist/chunks/ktxTextureLoader-C3ev8CyA.esm.min.js +2 -0
  263. package/dist/chunks/ktxTextureLoader-C3ev8CyA.esm.min.js.map +1 -0
  264. package/dist/chunks/ktxTextureLoader-lXvRBTya.esm.js +814 -0
  265. package/dist/chunks/ktxTextureLoader-lXvRBTya.esm.js.map +1 -0
  266. package/dist/chunks/logDepthDeclaration-9by0-jjx.esm.min.js +2 -0
  267. package/dist/chunks/logDepthDeclaration-9by0-jjx.esm.min.js.map +1 -0
  268. package/dist/chunks/logDepthDeclaration-B-8DXc3B.esm.js +35 -0
  269. package/dist/chunks/logDepthDeclaration-B-8DXc3B.esm.js.map +1 -0
  270. package/dist/chunks/logDepthDeclaration-BeXo0BcS.esm.js +20 -0
  271. package/dist/chunks/logDepthDeclaration-BeXo0BcS.esm.js.map +1 -0
  272. package/dist/chunks/logDepthDeclaration-BrAOAbMB.esm.min.js +2 -0
  273. package/dist/chunks/logDepthDeclaration-BrAOAbMB.esm.min.js.map +1 -0
  274. package/dist/chunks/logDepthVertex-B_oWUNEG.esm.min.js +2 -0
  275. package/dist/chunks/logDepthVertex-B_oWUNEG.esm.min.js.map +1 -0
  276. package/dist/chunks/logDepthVertex-CWz8hqId.esm.min.js +2 -0
  277. package/dist/chunks/logDepthVertex-CWz8hqId.esm.min.js.map +1 -0
  278. package/dist/chunks/logDepthVertex-CtgMxuTW.esm.js +77 -0
  279. package/dist/chunks/logDepthVertex-CtgMxuTW.esm.js.map +1 -0
  280. package/dist/chunks/logDepthVertex-DmlNzN_-.esm.js +488 -0
  281. package/dist/chunks/logDepthVertex-DmlNzN_-.esm.js.map +1 -0
  282. package/dist/chunks/mainUVVaryingDeclaration-3mZFgM2Y.esm.min.js +2 -0
  283. package/dist/chunks/mainUVVaryingDeclaration-3mZFgM2Y.esm.min.js.map +1 -0
  284. package/dist/chunks/mainUVVaryingDeclaration-BQImfxZc.esm.js +11 -0
  285. package/dist/chunks/mainUVVaryingDeclaration-BQImfxZc.esm.js.map +1 -0
  286. package/dist/chunks/meshUboDeclaration-D-QLXKpv.esm.min.js +2 -0
  287. package/dist/chunks/meshUboDeclaration-D-QLXKpv.esm.min.js.map +1 -0
  288. package/dist/chunks/meshUboDeclaration-DvRjgZbt.esm.js +24 -0
  289. package/dist/chunks/meshUboDeclaration-DvRjgZbt.esm.js.map +1 -0
  290. package/dist/chunks/objFileLoader-DClQXLHy.esm.min.js +2 -0
  291. package/dist/chunks/objFileLoader-DClQXLHy.esm.min.js.map +1 -0
  292. package/dist/chunks/objFileLoader-DjjND6jn.esm.js +1338 -0
  293. package/dist/chunks/objFileLoader-DjjND6jn.esm.js.map +1 -0
  294. package/dist/chunks/oitFragment-C9F7PGky.esm.js +1210 -0
  295. package/dist/chunks/oitFragment-C9F7PGky.esm.js.map +1 -0
  296. package/dist/chunks/oitFragment-CkqULQ2P.esm.js +1150 -0
  297. package/dist/chunks/oitFragment-CkqULQ2P.esm.js.map +1 -0
  298. package/dist/chunks/oitFragment-VzjooioR.esm.min.js +2 -0
  299. package/dist/chunks/oitFragment-VzjooioR.esm.min.js.map +1 -0
  300. package/dist/chunks/oitFragment-l1zYpRGk.esm.min.js +2 -0
  301. package/dist/chunks/oitFragment-l1zYpRGk.esm.min.js.map +1 -0
  302. package/dist/chunks/pass.fragment-BIWANx5e.esm.js +15 -0
  303. package/dist/chunks/pass.fragment-BIWANx5e.esm.js.map +1 -0
  304. package/dist/chunks/pass.fragment-DT7shxRk.esm.min.js +2 -0
  305. package/dist/chunks/pass.fragment-DT7shxRk.esm.min.js.map +1 -0
  306. package/dist/chunks/pass.fragment-DaW-t9oK.esm.min.js +2 -0
  307. package/dist/chunks/pass.fragment-DaW-t9oK.esm.min.js.map +1 -0
  308. package/dist/chunks/pass.fragment-f8kDdeJw.esm.js +15 -0
  309. package/dist/chunks/pass.fragment-f8kDdeJw.esm.js.map +1 -0
  310. package/dist/chunks/pbr.fragment-CoSdvQ8t.esm.min.js +2 -0
  311. package/dist/chunks/pbr.fragment-CoSdvQ8t.esm.min.js.map +1 -0
  312. package/dist/chunks/pbr.fragment-DD65SO1E.esm.min.js +2 -0
  313. package/dist/chunks/pbr.fragment-DD65SO1E.esm.min.js.map +1 -0
  314. package/dist/chunks/pbr.fragment-DWuVX98p.esm.js +3165 -0
  315. package/dist/chunks/pbr.fragment-DWuVX98p.esm.js.map +1 -0
  316. package/dist/chunks/pbr.fragment-PRP9y9HC.esm.js +3219 -0
  317. package/dist/chunks/pbr.fragment-PRP9y9HC.esm.js.map +1 -0
  318. package/dist/chunks/pbr.vertex-Ckrh7rKU.esm.js +210 -0
  319. package/dist/chunks/pbr.vertex-Ckrh7rKU.esm.js.map +1 -0
  320. package/dist/chunks/pbr.vertex-CsLrd0Yv.esm.min.js +2 -0
  321. package/dist/chunks/pbr.vertex-CsLrd0Yv.esm.min.js.map +1 -0
  322. package/dist/chunks/pbr.vertex-DpJSNiZg.esm.js +335 -0
  323. package/dist/chunks/pbr.vertex-DpJSNiZg.esm.js.map +1 -0
  324. package/dist/chunks/pbr.vertex-mhLIVycb.esm.min.js +2 -0
  325. package/dist/chunks/pbr.vertex-mhLIVycb.esm.min.js.map +1 -0
  326. package/dist/chunks/postprocess.vertex-BbfEpvuD.esm.min.js +2 -0
  327. package/dist/chunks/postprocess.vertex-BbfEpvuD.esm.min.js.map +1 -0
  328. package/dist/chunks/postprocess.vertex-BhSMqTXY.esm.js +20 -0
  329. package/dist/chunks/postprocess.vertex-BhSMqTXY.esm.js.map +1 -0
  330. package/dist/chunks/postprocess.vertex-CuuqVRdu.esm.min.js +2 -0
  331. package/dist/chunks/postprocess.vertex-CuuqVRdu.esm.min.js.map +1 -0
  332. package/dist/chunks/postprocess.vertex-D3iGIN1h.esm.js +18 -0
  333. package/dist/chunks/postprocess.vertex-D3iGIN1h.esm.js.map +1 -0
  334. package/dist/chunks/rawTexture-zt95iEpe.esm.min.js +2 -0
  335. package/dist/chunks/rawTexture-zt95iEpe.esm.min.js.map +1 -0
  336. package/dist/chunks/rawTexture-zvoEayWf.esm.js +191 -0
  337. package/dist/chunks/rawTexture-zvoEayWf.esm.js.map +1 -0
  338. package/dist/chunks/rgbdDecode.fragment-Bj_jNFxi.esm.min.js +2 -0
  339. package/dist/chunks/rgbdDecode.fragment-Bj_jNFxi.esm.min.js.map +1 -0
  340. package/dist/chunks/rgbdDecode.fragment-DchJ-wMV.esm.js +17 -0
  341. package/dist/chunks/rgbdDecode.fragment-DchJ-wMV.esm.js.map +1 -0
  342. package/dist/chunks/rgbdDecode.fragment-gnC9piGK.esm.min.js +2 -0
  343. package/dist/chunks/rgbdDecode.fragment-gnC9piGK.esm.min.js.map +1 -0
  344. package/dist/chunks/rgbdDecode.fragment-kNMM7IfV.esm.js +17 -0
  345. package/dist/chunks/rgbdDecode.fragment-kNMM7IfV.esm.js.map +1 -0
  346. package/dist/chunks/rgbdEncode.fragment-BXMjseFJ.esm.js +17 -0
  347. package/dist/chunks/rgbdEncode.fragment-BXMjseFJ.esm.js.map +1 -0
  348. package/dist/chunks/rgbdEncode.fragment-Bc9j02e4.esm.min.js +2 -0
  349. package/dist/chunks/rgbdEncode.fragment-Bc9j02e4.esm.min.js.map +1 -0
  350. package/dist/chunks/rgbdEncode.fragment-DObDEzXe.esm.min.js +2 -0
  351. package/dist/chunks/rgbdEncode.fragment-DObDEzXe.esm.min.js.map +1 -0
  352. package/dist/chunks/rgbdEncode.fragment-DgDRT4Gd.esm.js +17 -0
  353. package/dist/chunks/rgbdEncode.fragment-DgDRT4Gd.esm.js.map +1 -0
  354. package/dist/chunks/splatFileLoader-BUtGja1v.esm.min.js +2 -0
  355. package/dist/chunks/splatFileLoader-BUtGja1v.esm.min.js.map +1 -0
  356. package/dist/chunks/splatFileLoader-D53T0YTp.esm.js +3534 -0
  357. package/dist/chunks/splatFileLoader-D53T0YTp.esm.js.map +1 -0
  358. package/dist/chunks/standardMaterial-Dvhii-7v.esm.js +1809 -0
  359. package/dist/chunks/standardMaterial-Dvhii-7v.esm.js.map +1 -0
  360. package/dist/chunks/standardMaterial-LF_eriLy.esm.min.js +2 -0
  361. package/dist/chunks/standardMaterial-LF_eriLy.esm.min.js.map +1 -0
  362. package/dist/chunks/stlFileLoader-3SXw180V.esm.js +238 -0
  363. package/dist/chunks/stlFileLoader-3SXw180V.esm.js.map +1 -0
  364. package/dist/chunks/stlFileLoader-D1hHexdJ.esm.min.js +2 -0
  365. package/dist/chunks/stlFileLoader-D1hHexdJ.esm.min.js.map +1 -0
  366. package/dist/chunks/tgaTextureLoader-CN7-1ud6.esm.js +349 -0
  367. package/dist/chunks/tgaTextureLoader-CN7-1ud6.esm.js.map +1 -0
  368. package/dist/chunks/tgaTextureLoader-Dm6cp9Nf.esm.min.js +2 -0
  369. package/dist/chunks/tgaTextureLoader-Dm6cp9Nf.esm.min.js.map +1 -0
  370. package/dist/chunks/thinEngine-B8tKoyxK.esm.js +3721 -0
  371. package/dist/chunks/thinEngine-B8tKoyxK.esm.js.map +1 -0
  372. package/dist/chunks/thinEngine-BCXMjxvZ.esm.min.js +2 -0
  373. package/dist/chunks/thinEngine-BCXMjxvZ.esm.min.js.map +1 -0
  374. package/dist/chunks/thinInstanceMesh-CNjlSPEU.esm.js +314 -0
  375. package/dist/chunks/thinInstanceMesh-CNjlSPEU.esm.js.map +1 -0
  376. package/dist/chunks/thinInstanceMesh-C_RNveny.esm.min.js +2 -0
  377. package/dist/chunks/thinInstanceMesh-C_RNveny.esm.min.js.map +1 -0
  378. package/dist/chunks/vertexColorMixing-G4bYfHKj.esm.js +528 -0
  379. package/dist/chunks/vertexColorMixing-G4bYfHKj.esm.js.map +1 -0
  380. package/dist/chunks/vertexColorMixing-tDXsQPJJ.esm.min.js +2 -0
  381. package/dist/chunks/vertexColorMixing-tDXsQPJJ.esm.min.js.map +1 -0
  382. package/dist/chunks/webgpuEngine-ChhJDb03.esm.js +11181 -0
  383. package/dist/chunks/webgpuEngine-ChhJDb03.esm.js.map +1 -0
  384. package/dist/chunks/webgpuEngine-DczCfHyB.esm.min.js +2 -0
  385. package/dist/chunks/webgpuEngine-DczCfHyB.esm.min.js.map +1 -0
  386. package/dist/chunks/workerPool-BUOov2K1.esm.js +122 -0
  387. package/dist/chunks/workerPool-BUOov2K1.esm.js.map +1 -0
  388. package/dist/chunks/workerPool-BWHiDmEZ.esm.min.js +2 -0
  389. package/dist/chunks/workerPool-BWHiDmEZ.esm.min.js.map +1 -0
  390. package/docs/ViewerDefault.jpg +0 -0
  391. package/docs/ViewerParts.jpg +0 -0
  392. package/docs/ViewerSlots.jpg +0 -0
  393. package/docs/ViewerStyled.jpg +0 -0
  394. package/lib/index.d.ts +325 -0
  395. package/lib/index.js +1116 -0
  396. package/lib/index.js.map +1 -0
  397. package/package.json +18 -27
  398. package/readme.md +145 -21
  399. package/configuration/configuration.d.ts +0 -107
  400. package/configuration/configuration.js +0 -16
  401. package/configuration/configuration.js.map +0 -1
  402. package/configuration/configurationCompatibility.d.ts +0 -8
  403. package/configuration/configurationCompatibility.js +0 -66
  404. package/configuration/configurationCompatibility.js.map +0 -1
  405. package/configuration/configurationContainer.d.ts +0 -10
  406. package/configuration/configurationContainer.js +0 -10
  407. package/configuration/configurationContainer.js.map +0 -1
  408. package/configuration/globals.d.ts +0 -6
  409. package/configuration/globals.js +0 -18
  410. package/configuration/globals.js.map +0 -1
  411. package/configuration/index.d.ts +0 -2
  412. package/configuration/index.js +0 -4
  413. package/configuration/index.js.map +0 -1
  414. package/configuration/interfaces/cameraConfiguration.d.ts +0 -31
  415. package/configuration/interfaces/cameraConfiguration.js +0 -2
  416. package/configuration/interfaces/cameraConfiguration.js.map +0 -1
  417. package/configuration/interfaces/colorGradingConfiguration.d.ts +0 -81
  418. package/configuration/interfaces/colorGradingConfiguration.js +0 -2
  419. package/configuration/interfaces/colorGradingConfiguration.js.map +0 -1
  420. package/configuration/interfaces/defaultRenderingPipelineConfiguration.d.ts +0 -20
  421. package/configuration/interfaces/defaultRenderingPipelineConfiguration.js +0 -2
  422. package/configuration/interfaces/defaultRenderingPipelineConfiguration.js.map +0 -1
  423. package/configuration/interfaces/environmentMapConfiguration.d.ts +0 -22
  424. package/configuration/interfaces/environmentMapConfiguration.js +0 -2
  425. package/configuration/interfaces/environmentMapConfiguration.js.map +0 -1
  426. package/configuration/interfaces/groundConfiguration.d.ts +0 -24
  427. package/configuration/interfaces/groundConfiguration.js +0 -2
  428. package/configuration/interfaces/groundConfiguration.js.map +0 -1
  429. package/configuration/interfaces/imageProcessingConfiguration.d.ts +0 -45
  430. package/configuration/interfaces/imageProcessingConfiguration.js +0 -2
  431. package/configuration/interfaces/imageProcessingConfiguration.js.map +0 -1
  432. package/configuration/interfaces/index.d.ts +0 -15
  433. package/configuration/interfaces/index.js +0 -16
  434. package/configuration/interfaces/index.js.map +0 -1
  435. package/configuration/interfaces/lightConfiguration.d.ts +0 -60
  436. package/configuration/interfaces/lightConfiguration.js +0 -2
  437. package/configuration/interfaces/lightConfiguration.js.map +0 -1
  438. package/configuration/interfaces/modelAnimationConfiguration.d.ts +0 -26
  439. package/configuration/interfaces/modelAnimationConfiguration.js +0 -2
  440. package/configuration/interfaces/modelAnimationConfiguration.js.map +0 -1
  441. package/configuration/interfaces/modelConfiguration.d.ts +0 -65
  442. package/configuration/interfaces/modelConfiguration.js +0 -2
  443. package/configuration/interfaces/modelConfiguration.js.map +0 -1
  444. package/configuration/interfaces/observersConfiguration.d.ts +0 -5
  445. package/configuration/interfaces/observersConfiguration.js +0 -2
  446. package/configuration/interfaces/observersConfiguration.js.map +0 -1
  447. package/configuration/interfaces/sceneConfiguration.d.ts +0 -48
  448. package/configuration/interfaces/sceneConfiguration.js +0 -2
  449. package/configuration/interfaces/sceneConfiguration.js.map +0 -1
  450. package/configuration/interfaces/sceneOptimizerConfiguration.d.ts +0 -23
  451. package/configuration/interfaces/sceneOptimizerConfiguration.js +0 -2
  452. package/configuration/interfaces/sceneOptimizerConfiguration.js.map +0 -1
  453. package/configuration/interfaces/skyboxConfiguration.d.ts +0 -21
  454. package/configuration/interfaces/skyboxConfiguration.js +0 -2
  455. package/configuration/interfaces/skyboxConfiguration.js.map +0 -1
  456. package/configuration/interfaces/templateConfiguration.d.ts +0 -67
  457. package/configuration/interfaces/templateConfiguration.js +0 -2
  458. package/configuration/interfaces/templateConfiguration.js.map +0 -1
  459. package/configuration/interfaces/vrConfiguration.d.ts +0 -16
  460. package/configuration/interfaces/vrConfiguration.js +0 -2
  461. package/configuration/interfaces/vrConfiguration.js.map +0 -1
  462. package/configuration/loader.d.ts +0 -4
  463. package/configuration/loader.js +0 -17
  464. package/configuration/loader.js.map +0 -1
  465. package/configuration/mappers.d.ts +0 -43
  466. package/configuration/mappers.js +0 -192
  467. package/configuration/mappers.js.map +0 -1
  468. package/configuration/renderOnlyLoader.d.ts +0 -33
  469. package/configuration/renderOnlyLoader.js +0 -162
  470. package/configuration/renderOnlyLoader.js.map +0 -1
  471. package/configuration/types/default.d.ts +0 -6
  472. package/configuration/types/default.js +0 -121
  473. package/configuration/types/default.js.map +0 -1
  474. package/configuration/types/environmentMap.d.ts +0 -5
  475. package/configuration/types/environmentMap.js +0 -14
  476. package/configuration/types/environmentMap.js.map +0 -1
  477. package/configuration/types/extended.d.ts +0 -6
  478. package/configuration/types/extended.js +0 -317
  479. package/configuration/types/extended.js.map +0 -1
  480. package/configuration/types/index.d.ts +0 -14
  481. package/configuration/types/index.js +0 -51
  482. package/configuration/types/index.js.map +0 -1
  483. package/configuration/types/minimal.d.ts +0 -6
  484. package/configuration/types/minimal.js +0 -43
  485. package/configuration/types/minimal.js.map +0 -1
  486. package/configuration/types/renderOnlyDefault.d.ts +0 -30
  487. package/configuration/types/renderOnlyDefault.js +0 -31
  488. package/configuration/types/renderOnlyDefault.js.map +0 -1
  489. package/configuration/types/shadowLight.d.ts +0 -9
  490. package/configuration/types/shadowLight.js +0 -64
  491. package/configuration/types/shadowLight.js.map +0 -1
  492. package/helper/index.d.ts +0 -29
  493. package/helper/index.js +0 -66
  494. package/helper/index.js.map +0 -1
  495. package/index.d.ts +0 -30
  496. package/index.js +0 -46
  497. package/index.js.map +0 -1
  498. package/initializer.d.ts +0 -11
  499. package/initializer.js +0 -35
  500. package/initializer.js.map +0 -1
  501. package/interfaces.d.ts +0 -5
  502. package/interfaces.js +0 -7
  503. package/interfaces.js.map +0 -1
  504. package/labs/environmentSerializer.d.ts +0 -126
  505. package/labs/environmentSerializer.js +0 -191
  506. package/labs/environmentSerializer.js.map +0 -1
  507. package/labs/texture.d.ts +0 -183
  508. package/labs/texture.js +0 -350
  509. package/labs/texture.js.map +0 -1
  510. package/labs/viewerLabs.d.ts +0 -51
  511. package/labs/viewerLabs.js +0 -134
  512. package/labs/viewerLabs.js.map +0 -1
  513. package/loader/modelLoader.d.ts +0 -56
  514. package/loader/modelLoader.js +0 -199
  515. package/loader/modelLoader.js.map +0 -1
  516. package/loader/plugins/applyMaterialConfig.d.ts +0 -12
  517. package/loader/plugins/applyMaterialConfig.js +0 -16
  518. package/loader/plugins/applyMaterialConfig.js.map +0 -1
  519. package/loader/plugins/extendedMaterialLoaderPlugin.d.ts +0 -9
  520. package/loader/plugins/extendedMaterialLoaderPlugin.js +0 -16
  521. package/loader/plugins/extendedMaterialLoaderPlugin.js.map +0 -1
  522. package/loader/plugins/index.d.ts +0 -19
  523. package/loader/plugins/index.js +0 -44
  524. package/loader/plugins/index.js.map +0 -1
  525. package/loader/plugins/loaderPlugin.d.ts +0 -24
  526. package/loader/plugins/loaderPlugin.js +0 -2
  527. package/loader/plugins/loaderPlugin.js.map +0 -1
  528. package/loader/plugins/msftLodLoaderPlugin.d.ts +0 -12
  529. package/loader/plugins/msftLodLoaderPlugin.js +0 -21
  530. package/loader/plugins/msftLodLoaderPlugin.js.map +0 -1
  531. package/loader/plugins/telemetryLoaderPlugin.d.ts +0 -12
  532. package/loader/plugins/telemetryLoaderPlugin.js +0 -36
  533. package/loader/plugins/telemetryLoaderPlugin.js.map +0 -1
  534. package/managers/observablesManager.d.ts +0 -66
  535. package/managers/observablesManager.js +0 -35
  536. package/managers/observablesManager.js.map +0 -1
  537. package/managers/sceneManager.d.ts +0 -245
  538. package/managers/sceneManager.js +0 -1375
  539. package/managers/sceneManager.js.map +0 -1
  540. package/managers/telemetryManager.d.ts +0 -78
  541. package/managers/telemetryManager.js +0 -117
  542. package/managers/telemetryManager.js.map +0 -1
  543. package/model/modelAnimation.d.ts +0 -215
  544. package/model/modelAnimation.js +0 -237
  545. package/model/modelAnimation.js.map +0 -1
  546. package/model/viewerModel.d.ts +0 -233
  547. package/model/viewerModel.js +0 -673
  548. package/model/viewerModel.js.map +0 -1
  549. package/optimizer/custom/extended.d.ts +0 -13
  550. package/optimizer/custom/extended.js +0 -101
  551. package/optimizer/custom/extended.js.map +0 -1
  552. package/optimizer/custom/index.d.ts +0 -9
  553. package/optimizer/custom/index.js +0 -26
  554. package/optimizer/custom/index.js.map +0 -1
  555. package/renderOnlyIndex.d.ts +0 -11
  556. package/renderOnlyIndex.js +0 -18
  557. package/renderOnlyIndex.js.map +0 -1
  558. package/templating/eventManager.d.ts +0 -35
  559. package/templating/eventManager.js +0 -66
  560. package/templating/eventManager.js.map +0 -1
  561. package/templating/plugins/hdButtonPlugin.d.ts +0 -9
  562. package/templating/plugins/hdButtonPlugin.js +0 -21
  563. package/templating/plugins/hdButtonPlugin.js.map +0 -1
  564. package/templating/plugins/printButton.d.ts +0 -9
  565. package/templating/plugins/printButton.js +0 -40
  566. package/templating/plugins/printButton.js.map +0 -1
  567. package/templating/templateManager.d.ts +0 -197
  568. package/templating/templateManager.js +0 -561
  569. package/templating/templateManager.js.map +0 -1
  570. package/templating/viewerTemplatePlugin.d.ts +0 -21
  571. package/templating/viewerTemplatePlugin.js +0 -69
  572. package/templating/viewerTemplatePlugin.js.map +0 -1
  573. package/viewer/defaultViewer.d.ts +0 -130
  574. package/viewer/defaultViewer.js +0 -672
  575. package/viewer/defaultViewer.js.map +0 -1
  576. package/viewer/renderOnlyViewer.d.ts +0 -9
  577. package/viewer/renderOnlyViewer.js +0 -46
  578. package/viewer/renderOnlyViewer.js.map +0 -1
  579. package/viewer/viewer.d.ts +0 -258
  580. package/viewer/viewer.js +0 -783
  581. package/viewer/viewer.js.map +0 -1
  582. package/viewer/viewerManager.d.ts +0 -58
  583. package/viewer/viewerManager.js +0 -91
  584. package/viewer/viewerManager.js.map +0 -1
  585. package/viewer/viewerWithTemplate.d.ts +0 -9
  586. package/viewer/viewerWithTemplate.js +0 -20
  587. package/viewer/viewerWithTemplate.js.map +0 -1
@@ -0,0 +1,3534 @@
1
+ import { i as ShaderStore, R as RegisterClass, x as PushMaterial, y as PrepareDefinesForMisc, z as PrepareDefinesForFrameBoundValues, H as PrepareDefinesForAttributes, J as PrepareAttributesForInstances, K as PrepareUniformsAndSamplersList, N as addClipPlaneUniforms, Q as Camera, W as bindClipPlane, X as BindFogParameters, Y as BindLogDepth, Z as SerializationHelper, _ as MaterialDefines, V as VertexBuffer, M as Mesh, $ as Matrix, t as Vector3, v as VertexData, a0 as SubMesh, a1 as TmpVectors, L as Logger, T as Tools, s as Vector2, a2 as Quaternion, C as Constants, k as Color4, a3 as BuildArray, a4 as Epsilon, a5 as IntersectionInfo, E as EngineStore, a6 as PickingInfo, a7 as _ImportHelper, a8 as Scene, p as Color3, a9 as Vector4, aa as RandomRange, B as BaseTexture, ab as functions, ac as HighestCommonFactor, ad as SPLATFileLoaderMetadata, w as registerSceneLoaderPlugin } from './index-DzE-qoIA.esm.js';
2
+ import './fogFragment-n-fnZX94.esm.js';
3
+ import './logDepthDeclaration-B-8DXc3B.esm.js';
4
+ import './logDepthVertex-CtgMxuTW.esm.js';
5
+ import { R as RawTexture } from './rawTexture-zvoEayWf.esm.js';
6
+ import './thinInstanceMesh-CNjlSPEU.esm.js';
7
+ import { A as AssetContainer } from './assetContainer-BrmmAQqf.esm.js';
8
+ import { S as StandardMaterial } from './standardMaterial-Dvhii-7v.esm.js';
9
+
10
+ // Do not edit.
11
+ const name$3 = "gaussianSplattingPixelShader";
12
+ const shader$3 = `#include<clipPlaneFragmentDeclaration>
13
+ #include<logDepthDeclaration>
14
+ #include<fogFragmentDeclaration>
15
+ varying vec4 vColor;varying vec2 vPosition;void main () {
16
+ #include<clipPlaneFragment>
17
+ float A=-dot(vPosition,vPosition);if (A<-4.0) discard;float B=exp(A)*vColor.a;
18
+ #include<logDepthFragment>
19
+ vec3 color=vColor.rgb;
20
+ #ifdef FOG
21
+ #include<fogFragment>
22
+ #endif
23
+ gl_FragColor=vec4(color,B);}
24
+ `;
25
+ // Sideeffect
26
+ ShaderStore.ShadersStore[name$3] = shader$3;
27
+
28
+ // Do not edit.
29
+ const name$2 = "gaussianSplattingVertexDeclaration";
30
+ const shader$2 = `uniform mat4 world;uniform mat4 view;uniform mat4 projection;
31
+ `;
32
+ // Sideeffect
33
+ ShaderStore.IncludesShadersStore[name$2] = shader$2;
34
+
35
+ // Do not edit.
36
+ const name$1 = "gaussianSplattingUboDeclaration";
37
+ const shader$1 = `#include<sceneUboDeclaration>
38
+ #include<meshUboDeclaration>
39
+ `;
40
+ // Sideeffect
41
+ ShaderStore.IncludesShadersStore[name$1] = shader$1;
42
+
43
+ // Do not edit.
44
+ const name = "gaussianSplattingVertexShader";
45
+ const shader = `#include<__decl__gaussianSplattingVertex>
46
+ #ifdef LOGARITHMICDEPTH
47
+ #extension GL_EXT_frag_depth : enable
48
+ #endif
49
+ #include<clipPlaneVertexDeclaration>
50
+ #include<fogVertexDeclaration>
51
+ #include<logDepthDeclaration>
52
+ attribute vec2 position;attribute float splatIndex;uniform vec2 invViewport;uniform vec2 dataTextureSize;uniform vec2 focal;uniform sampler2D covariancesATexture;uniform sampler2D covariancesBTexture;uniform sampler2D centersTexture;uniform sampler2D colorsTexture;varying vec4 vColor;varying vec2 vPosition;
53
+ #if !defined(WEBGL2) && !defined(WEBGPU) && !defined(NATIVE)
54
+ mat3 transpose(mat3 matrix) {return mat3(matrix[0][0],matrix[1][0],matrix[2][0],
55
+ matrix[0][1],matrix[1][1],matrix[2][1],
56
+ matrix[0][2],matrix[1][2],matrix[2][2]);}
57
+ #endif
58
+ vec2 getDataUV(float index,vec2 textureSize) {float y=floor(index/textureSize.x);float x=index-y*textureSize.x;return vec2((x+0.5)/textureSize.x,(y+0.5)/textureSize.y);}
59
+ void main () {vec2 splatUV=getDataUV(splatIndex,dataTextureSize);vec3 center=texture2D(centersTexture,splatUV).xyz;vec4 color=texture2D(colorsTexture,splatUV);vec3 covA=texture2D(covariancesATexture,splatUV).xyz;vec3 covB=texture2D(covariancesBTexture,splatUV).xyz;vec4 worldPos=world*vec4(center,1.0);mat4 modelView=view*world;vec4 camspace=view*worldPos;vec4 pos2d=projection*camspace;float bounds=1.2*pos2d.w;if (pos2d.z<-pos2d.w || pos2d.x<-bounds || pos2d.x>bounds
60
+ || pos2d.y<-bounds || pos2d.y>bounds) {gl_Position=vec4(0.0,0.0,2.0,1.0);return;}
61
+ mat3 Vrk=mat3(
62
+ covA.x,covA.y,covA.z,
63
+ covA.y,covB.x,covB.y,
64
+ covA.z,covB.y,covB.z
65
+ );mat3 J=mat3(
66
+ focal.x/camspace.z,0.,-(focal.x*camspace.x)/(camspace.z*camspace.z),
67
+ 0.,focal.y/camspace.z,-(focal.y*camspace.y)/(camspace.z*camspace.z),
68
+ 0.,0.,0.
69
+ );mat3 invy=mat3(1,0,0,0,-1,0,0,0,1);mat3 T=invy*transpose(mat3(modelView))*J;mat3 cov2d=transpose(T)*Vrk*T;float mid=(cov2d[0][0]+cov2d[1][1])/2.0;float radius=length(vec2((cov2d[0][0]-cov2d[1][1])/2.0,cov2d[0][1]));float lambda1=mid+radius,lambda2=mid-radius;if (lambda2<0.0) return;vec2 diagonalVector=normalize(vec2(cov2d[0][1],lambda1-cov2d[0][0]));vec2 majorAxis=min(sqrt(2.0*lambda1),1024.0)*diagonalVector;vec2 minorAxis=min(sqrt(2.0*lambda2),1024.0)*vec2(diagonalVector.y,-diagonalVector.x);vColor=color;vPosition=position;vec2 vCenter=vec2(pos2d);gl_Position=vec4(
70
+ vCenter
71
+ + (position.x*majorAxis
72
+ + position.y*minorAxis)*invViewport*pos2d.w,pos2d.zw);
73
+ #include<clipPlaneVertex>
74
+ #include<fogVertex>
75
+ #include<logDepthVertex>
76
+ }
77
+ `;
78
+ // Sideeffect
79
+ ShaderStore.ShadersStore[name] = shader;
80
+
81
+ /**
82
+ * @internal
83
+ */
84
+ class GaussianSplattingMaterialDefines extends MaterialDefines {
85
+ /**
86
+ * Constructor of the defines.
87
+ */
88
+ constructor() {
89
+ super();
90
+ this.FOG = false;
91
+ this.THIN_INSTANCES = true;
92
+ this.LOGARITHMICDEPTH = false;
93
+ this.CLIPPLANE = false;
94
+ this.CLIPPLANE2 = false;
95
+ this.CLIPPLANE3 = false;
96
+ this.CLIPPLANE4 = false;
97
+ this.CLIPPLANE5 = false;
98
+ this.CLIPPLANE6 = false;
99
+ this.rebuild();
100
+ }
101
+ }
102
+ /**
103
+ * GaussianSplattingMaterial material used to render Gaussian Splatting
104
+ * @experimental
105
+ */
106
+ class GaussianSplattingMaterial extends PushMaterial {
107
+ /**
108
+ * Instantiates a Gaussian Splatting Material in the given scene
109
+ * @param name The friendly name of the material
110
+ * @param scene The scene to add the material to
111
+ */
112
+ constructor(name, scene) {
113
+ super(name, scene);
114
+ this.backFaceCulling = false;
115
+ }
116
+ /**
117
+ * Gets a boolean indicating that current material needs to register RTT
118
+ */
119
+ get hasRenderTargetTextures() {
120
+ return false;
121
+ }
122
+ /**
123
+ * Specifies whether or not this material should be rendered in alpha test mode.
124
+ * @returns false
125
+ */
126
+ needAlphaTesting() {
127
+ return false;
128
+ }
129
+ /**
130
+ * Specifies whether or not this material should be rendered in alpha blend mode.
131
+ * @returns true
132
+ */
133
+ needAlphaBlending() {
134
+ return true;
135
+ }
136
+ /**
137
+ * Checks whether the material is ready to be rendered for a given mesh.
138
+ * @param mesh The mesh to render
139
+ * @param subMesh The submesh to check against
140
+ * @returns true if all the dependencies are ready (Textures, Effects...)
141
+ */
142
+ isReadyForSubMesh(mesh, subMesh) {
143
+ const useInstances = true;
144
+ const drawWrapper = subMesh._drawWrapper;
145
+ if (drawWrapper.effect && this.isFrozen) {
146
+ if (drawWrapper._wasPreviouslyReady && drawWrapper._wasPreviouslyUsingInstances === useInstances) {
147
+ return true;
148
+ }
149
+ }
150
+ if (!subMesh.materialDefines) {
151
+ subMesh.materialDefines = new GaussianSplattingMaterialDefines();
152
+ }
153
+ const scene = this.getScene();
154
+ const defines = subMesh.materialDefines;
155
+ if (this._isReadyForSubMesh(subMesh)) {
156
+ return true;
157
+ }
158
+ const engine = scene.getEngine();
159
+ // Misc.
160
+ PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, false, defines);
161
+ // Values that need to be evaluated on every frame
162
+ PrepareDefinesForFrameBoundValues(scene, engine, this, defines, useInstances, null, true);
163
+ // Attribs
164
+ PrepareDefinesForAttributes(mesh, defines, false, false);
165
+ // Get correct effect
166
+ if (defines.isDirty) {
167
+ defines.markAsProcessed();
168
+ scene.resetCachedMaterial();
169
+ //Attributes
170
+ const attribs = [VertexBuffer.PositionKind, "splatIndex"];
171
+ PrepareAttributesForInstances(attribs, defines);
172
+ const uniforms = ["world", "view", "projection", "vFogInfos", "vFogColor", "logarithmicDepthConstant", "invViewport", "dataTextureSize", "focal"];
173
+ const samplers = ["covariancesATexture", "covariancesBTexture", "centersTexture", "colorsTexture"];
174
+ const uniformBuffers = ["Scene", "Mesh"];
175
+ PrepareUniformsAndSamplersList({
176
+ uniformsNames: uniforms,
177
+ uniformBuffersNames: uniformBuffers,
178
+ samplers: samplers,
179
+ defines: defines,
180
+ });
181
+ addClipPlaneUniforms(uniforms);
182
+ const join = defines.toString();
183
+ const effect = scene.getEngine().createEffect("gaussianSplatting", {
184
+ attributes: attribs,
185
+ uniformsNames: uniforms,
186
+ uniformBuffersNames: uniformBuffers,
187
+ samplers: samplers,
188
+ defines: join,
189
+ onCompiled: this.onCompiled,
190
+ onError: this.onError,
191
+ }, engine);
192
+ subMesh.setEffect(effect, defines, this._materialContext);
193
+ }
194
+ if (!subMesh.effect || !subMesh.effect.isReady()) {
195
+ return false;
196
+ }
197
+ defines._renderId = scene.getRenderId();
198
+ drawWrapper._wasPreviouslyReady = true;
199
+ drawWrapper._wasPreviouslyUsingInstances = useInstances;
200
+ return true;
201
+ }
202
+ /**
203
+ * Binds the submesh to this material by preparing the effect and shader to draw
204
+ * @param world defines the world transformation matrix
205
+ * @param mesh defines the mesh containing the submesh
206
+ * @param subMesh defines the submesh to bind the material to
207
+ */
208
+ bindForSubMesh(world, mesh, subMesh) {
209
+ const scene = this.getScene();
210
+ const defines = subMesh.materialDefines;
211
+ if (!defines) {
212
+ return;
213
+ }
214
+ const effect = subMesh.effect;
215
+ if (!effect) {
216
+ return;
217
+ }
218
+ this._activeEffect = effect;
219
+ // Matrices Mesh.
220
+ mesh.getMeshUniformBuffer().bindToEffect(effect, "Mesh");
221
+ mesh.transferToEffect(world);
222
+ // Bind data
223
+ const mustRebind = this._mustRebind(scene, effect, subMesh, mesh.visibility);
224
+ if (mustRebind) {
225
+ this.bindView(effect);
226
+ this.bindViewProjection(effect);
227
+ const engine = scene.getEngine();
228
+ const camera = this.getScene().activeCamera;
229
+ const renderWidth = engine.getRenderWidth();
230
+ const renderHeight = engine.getRenderHeight();
231
+ // check if rigcamera, get number of rigs
232
+ const numberOfRigs = camera?.rigParent?.rigCameras.length || 1;
233
+ this._activeEffect.setFloat2("invViewport", 1 / (renderWidth / numberOfRigs), 1 / renderHeight);
234
+ let focal = 1000;
235
+ if (camera) {
236
+ /*
237
+ more explicit version:
238
+ const t = camera.getProjectionMatrix().m[5];
239
+ const FovY = Math.atan(1.0 / t) * 2.0;
240
+ focal = renderHeight / 2.0 / Math.tan(FovY / 2.0);
241
+ Using a shorter version here to not have tan(atan) and 2.0 factor
242
+ */
243
+ const t = camera.getProjectionMatrix().m[5];
244
+ if (camera.fovMode == Camera.FOVMODE_VERTICAL_FIXED) {
245
+ focal = (renderHeight * t) / 2.0;
246
+ }
247
+ else {
248
+ focal = (renderWidth * t) / 2.0;
249
+ }
250
+ }
251
+ this._activeEffect.setFloat2("focal", focal, focal);
252
+ const gsMesh = mesh;
253
+ if (gsMesh.covariancesATexture) {
254
+ const textureSize = gsMesh.covariancesATexture.getSize();
255
+ effect.setFloat2("dataTextureSize", textureSize.width, textureSize.height);
256
+ effect.setTexture("covariancesATexture", gsMesh.covariancesATexture);
257
+ effect.setTexture("covariancesBTexture", gsMesh.covariancesBTexture);
258
+ effect.setTexture("centersTexture", gsMesh.centersTexture);
259
+ effect.setTexture("colorsTexture", gsMesh.colorsTexture);
260
+ }
261
+ // Clip plane
262
+ bindClipPlane(effect, this, scene);
263
+ }
264
+ else if (scene.getEngine()._features.needToAlwaysBindUniformBuffers) {
265
+ this._needToBindSceneUbo = true;
266
+ }
267
+ // Fog
268
+ BindFogParameters(scene, mesh, effect);
269
+ // Log. depth
270
+ if (this.useLogarithmicDepth) {
271
+ BindLogDepth(defines, effect, scene);
272
+ }
273
+ this._afterBind(mesh, this._activeEffect, subMesh);
274
+ }
275
+ /**
276
+ * Clones the material.
277
+ * @param name The cloned name.
278
+ * @returns The cloned material.
279
+ */
280
+ clone(name) {
281
+ return SerializationHelper.Clone(() => new GaussianSplattingMaterial(name, this.getScene()), this);
282
+ }
283
+ /**
284
+ * Serializes the current material to its JSON representation.
285
+ * @returns The JSON representation.
286
+ */
287
+ serialize() {
288
+ const serializationObject = super.serialize();
289
+ serializationObject.customType = "BABYLON.GaussianSplattingMaterial";
290
+ return serializationObject;
291
+ }
292
+ /**
293
+ * Gets the class name of the material
294
+ * @returns "GaussianSplattingMaterial"
295
+ */
296
+ getClassName() {
297
+ return "GaussianSplattingMaterial";
298
+ }
299
+ /**
300
+ * Parse a JSON input to create back a Gaussian Splatting material.
301
+ * @param source The JSON data to parse
302
+ * @param scene The scene to create the parsed material in
303
+ * @param rootUrl The root url of the assets the material depends upon
304
+ * @returns the instantiated GaussianSplattingMaterial.
305
+ */
306
+ static Parse(source, scene, rootUrl) {
307
+ return SerializationHelper.Parse(() => new GaussianSplattingMaterial(source.name, scene), source, scene, rootUrl);
308
+ }
309
+ }
310
+ RegisterClass("BABYLON.GaussianSplattingMaterial", GaussianSplattingMaterial);
311
+
312
+ /**
313
+ * Class used to render a gaussian splatting mesh
314
+ */
315
+ class GaussianSplattingMesh extends Mesh {
316
+ /**
317
+ * Gets the covariancesA texture
318
+ */
319
+ get covariancesATexture() {
320
+ return this._covariancesATexture;
321
+ }
322
+ /**
323
+ * Gets the covariancesB texture
324
+ */
325
+ get covariancesBTexture() {
326
+ return this._covariancesBTexture;
327
+ }
328
+ /**
329
+ * Gets the centers texture
330
+ */
331
+ get centersTexture() {
332
+ return this._centersTexture;
333
+ }
334
+ /**
335
+ * Gets the colors texture
336
+ */
337
+ get colorsTexture() {
338
+ return this._colorsTexture;
339
+ }
340
+ /**
341
+ * Creates a new gaussian splatting mesh
342
+ * @param name defines the name of the mesh
343
+ * @param url defines the url to load from (optional)
344
+ * @param scene defines the hosting scene (optional)
345
+ * @param keepInRam keep datas in ram for editing purpose
346
+ */
347
+ constructor(name, url = null, scene = null, keepInRam = false) {
348
+ super(name, scene);
349
+ this._vertexCount = 0;
350
+ this._worker = null;
351
+ this._frameIdLastUpdate = -1;
352
+ this._modelViewMatrix = Matrix.Identity();
353
+ this._canPostToWorker = true;
354
+ this._readyToDisplay = false;
355
+ this._covariancesATexture = null;
356
+ this._covariancesBTexture = null;
357
+ this._centersTexture = null;
358
+ this._colorsTexture = null;
359
+ this._splatPositions = null;
360
+ this._splatIndex = null;
361
+ //@ts-expect-error
362
+ this._covariancesA = null;
363
+ //@ts-expect-error
364
+ this._covariancesB = null;
365
+ //@ts-expect-error
366
+ this._colors = null;
367
+ this._keepInRam = false;
368
+ this._delayedTextureUpdate = null;
369
+ this._oldDirection = new Vector3();
370
+ const vertexData = new VertexData();
371
+ vertexData.positions = [-2, -2, 0, 2, -2, 0, 2, 2, 0, -2, 2, 0];
372
+ vertexData.indices = [0, 1, 2, 0, 2, 3];
373
+ vertexData.applyToMesh(this);
374
+ this.subMeshes = [];
375
+ new SubMesh(0, 0, 4, 0, 6, this);
376
+ this.setEnabled(false);
377
+ this._keepInRam = keepInRam;
378
+ if (url) {
379
+ this.loadFileAsync(url);
380
+ }
381
+ this.material = new GaussianSplattingMaterial(this.name + "_material", this._scene);
382
+ }
383
+ /**
384
+ * Returns the class name
385
+ * @returns "GaussianSplattingMesh"
386
+ */
387
+ getClassName() {
388
+ return "GaussianSplattingMesh";
389
+ }
390
+ /**
391
+ * Returns the total number of vertices (splats) within the mesh
392
+ * @returns the total number of vertices
393
+ */
394
+ getTotalVertices() {
395
+ return this._vertexCount;
396
+ }
397
+ /**
398
+ * Is this node ready to be used/rendered
399
+ * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
400
+ * @returns true when ready
401
+ */
402
+ isReady(completeCheck = false) {
403
+ if (!super.isReady(completeCheck, true)) {
404
+ return false;
405
+ }
406
+ if (!this._readyToDisplay) {
407
+ // mesh is ready when worker has done at least 1 sorting
408
+ this._postToWorker(true);
409
+ return false;
410
+ }
411
+ return true;
412
+ }
413
+ _postToWorker(forced = false) {
414
+ const frameId = this.getScene().getFrameId();
415
+ if (frameId !== this._frameIdLastUpdate && this._worker && this._scene.activeCamera && this._canPostToWorker) {
416
+ const cameraMatrix = this._scene.activeCamera.getViewMatrix();
417
+ this.getWorldMatrix().multiplyToRef(cameraMatrix, this._modelViewMatrix);
418
+ cameraMatrix.invertToRef(TmpVectors.Matrix[0]);
419
+ this.getWorldMatrix().multiplyToRef(TmpVectors.Matrix[0], TmpVectors.Matrix[1]);
420
+ Vector3.TransformNormalToRef(Vector3.Forward(this._scene.useRightHandedSystem), TmpVectors.Matrix[1], TmpVectors.Vector3[2]);
421
+ TmpVectors.Vector3[2].normalize();
422
+ const dot = Vector3.Dot(TmpVectors.Vector3[2], this._oldDirection);
423
+ if (forced || Math.abs(dot - 1) >= 0.01) {
424
+ this._oldDirection.copyFrom(TmpVectors.Vector3[2]);
425
+ this._frameIdLastUpdate = frameId;
426
+ this._canPostToWorker = false;
427
+ this._worker.postMessage({ view: this._modelViewMatrix.m, depthMix: this._depthMix, useRightHandedSystem: this._scene.useRightHandedSystem }, [
428
+ this._depthMix.buffer,
429
+ ]);
430
+ }
431
+ }
432
+ }
433
+ /**
434
+ * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager
435
+ * @param subMesh defines the subMesh to render
436
+ * @param enableAlphaMode defines if alpha mode can be changed
437
+ * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
438
+ * @returns the current mesh
439
+ */
440
+ render(subMesh, enableAlphaMode, effectiveMeshReplacement) {
441
+ this._postToWorker();
442
+ return super.render(subMesh, enableAlphaMode, effectiveMeshReplacement);
443
+ }
444
+ /**
445
+ * Code from https://github.com/dylanebert/gsplat.js/blob/main/src/loaders/PLYLoader.ts Under MIT license
446
+ * Converts a .ply data array buffer to splat
447
+ * if data array buffer is not ply, returns the original buffer
448
+ * @param data the .ply data to load
449
+ * @returns the loaded splat buffer
450
+ * @deprecated Please use SceneLoader.ImportMeshAsync instead
451
+ */
452
+ static ConvertPLYToSplat(data) {
453
+ const ubuf = new Uint8Array(data);
454
+ const header = new TextDecoder().decode(ubuf.slice(0, 1024 * 10));
455
+ const headerEnd = "end_header\n";
456
+ const headerEndIndex = header.indexOf(headerEnd);
457
+ if (headerEndIndex < 0 || !header) {
458
+ return data;
459
+ }
460
+ const vertexCount = parseInt(/element vertex (\d+)\n/.exec(header)[1]);
461
+ let rowOffset = 0;
462
+ const offsets = {
463
+ double: 8,
464
+ int: 4,
465
+ uint: 4,
466
+ float: 4,
467
+ short: 2,
468
+ ushort: 2,
469
+ uchar: 1,
470
+ };
471
+ const properties = [];
472
+ const filtered = header
473
+ .slice(0, headerEndIndex)
474
+ .split("\n")
475
+ .filter((k) => k.startsWith("property "));
476
+ for (const prop of filtered) {
477
+ const [, type, name] = prop.split(" ");
478
+ properties.push({ name, type, offset: rowOffset });
479
+ if (offsets[type]) {
480
+ rowOffset += offsets[type];
481
+ }
482
+ else {
483
+ Logger.Error(`Unsupported property type: ${type}. Are you sure it's a valid Gaussian Splatting file?`);
484
+ return new ArrayBuffer(0);
485
+ }
486
+ }
487
+ const rowLength = 3 * 4 + 3 * 4 + 4 + 4;
488
+ const SH_C0 = 0.28209479177387814;
489
+ const dataView = new DataView(data, headerEndIndex + headerEnd.length);
490
+ const buffer = new ArrayBuffer(rowLength * vertexCount);
491
+ const q = new Quaternion();
492
+ for (let i = 0; i < vertexCount; i++) {
493
+ const position = new Float32Array(buffer, i * rowLength, 3);
494
+ const scale = new Float32Array(buffer, i * rowLength + 12, 3);
495
+ const rgba = new Uint8ClampedArray(buffer, i * rowLength + 24, 4);
496
+ const rot = new Uint8ClampedArray(buffer, i * rowLength + 28, 4);
497
+ let r0 = 255;
498
+ let r1 = 0;
499
+ let r2 = 0;
500
+ let r3 = 0;
501
+ for (let propertyIndex = 0; propertyIndex < properties.length; propertyIndex++) {
502
+ const property = properties[propertyIndex];
503
+ let value;
504
+ switch (property.type) {
505
+ case "float":
506
+ value = dataView.getFloat32(property.offset + i * rowOffset, true);
507
+ break;
508
+ case "int":
509
+ value = dataView.getInt32(property.offset + i * rowOffset, true);
510
+ break;
511
+ default:
512
+ throw new Error(`Unsupported property type: ${property.type}`);
513
+ }
514
+ switch (property.name) {
515
+ case "x":
516
+ position[0] = value;
517
+ break;
518
+ case "y":
519
+ position[1] = value;
520
+ break;
521
+ case "z":
522
+ position[2] = value;
523
+ break;
524
+ case "scale_0":
525
+ scale[0] = Math.exp(value);
526
+ break;
527
+ case "scale_1":
528
+ scale[1] = Math.exp(value);
529
+ break;
530
+ case "scale_2":
531
+ scale[2] = Math.exp(value);
532
+ break;
533
+ case "red":
534
+ rgba[0] = value;
535
+ break;
536
+ case "green":
537
+ rgba[1] = value;
538
+ break;
539
+ case "blue":
540
+ rgba[2] = value;
541
+ break;
542
+ case "f_dc_0":
543
+ rgba[0] = (0.5 + SH_C0 * value) * 255;
544
+ break;
545
+ case "f_dc_1":
546
+ rgba[1] = (0.5 + SH_C0 * value) * 255;
547
+ break;
548
+ case "f_dc_2":
549
+ rgba[2] = (0.5 + SH_C0 * value) * 255;
550
+ break;
551
+ case "f_dc_3":
552
+ rgba[3] = (0.5 + SH_C0 * value) * 255;
553
+ break;
554
+ case "opacity":
555
+ rgba[3] = (1 / (1 + Math.exp(-value))) * 255;
556
+ break;
557
+ case "rot_0":
558
+ r0 = value;
559
+ break;
560
+ case "rot_1":
561
+ r1 = value;
562
+ break;
563
+ case "rot_2":
564
+ r2 = value;
565
+ break;
566
+ case "rot_3":
567
+ r3 = value;
568
+ break;
569
+ }
570
+ }
571
+ q.set(r1, r2, r3, r0);
572
+ q.normalize();
573
+ rot[0] = q.w * 128 + 128;
574
+ rot[1] = q.x * 128 + 128;
575
+ rot[2] = q.y * 128 + 128;
576
+ rot[3] = q.z * 128 + 128;
577
+ }
578
+ return buffer;
579
+ }
580
+ /**
581
+ * Loads a .splat Gaussian Splatting array buffer asynchronously
582
+ * @param data arraybuffer containing splat file
583
+ * @returns a promise that resolves when the operation is complete
584
+ */
585
+ loadDataAsync(data) {
586
+ return Promise.resolve(this._loadData(data));
587
+ }
588
+ /**
589
+ * Loads a .splat Gaussian or .ply Splatting file asynchronously
590
+ * @param url path to the splat file to load
591
+ * @returns a promise that resolves when the operation is complete
592
+ * @deprecated Please use SceneLoader.ImportMeshAsync instead
593
+ */
594
+ loadFileAsync(url) {
595
+ return Tools.LoadFileAsync(url, true).then((data) => {
596
+ this._loadData(GaussianSplattingMesh.ConvertPLYToSplat(data));
597
+ });
598
+ }
599
+ /**
600
+ * Releases resources associated with this mesh.
601
+ * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
602
+ */
603
+ dispose(doNotRecurse) {
604
+ this._covariancesATexture?.dispose();
605
+ this._covariancesBTexture?.dispose();
606
+ this._centersTexture?.dispose();
607
+ this._colorsTexture?.dispose();
608
+ this._covariancesATexture = null;
609
+ this._covariancesBTexture = null;
610
+ this._centersTexture = null;
611
+ this._colorsTexture = null;
612
+ this._worker?.terminate();
613
+ this._worker = null;
614
+ super.dispose(doNotRecurse, true);
615
+ }
616
+ _copyTextures(source) {
617
+ this._covariancesATexture = source.covariancesATexture?.clone();
618
+ this._covariancesBTexture = source.covariancesBTexture?.clone();
619
+ this._centersTexture = source.centersTexture?.clone();
620
+ this._colorsTexture = source.colorsTexture?.clone();
621
+ }
622
+ /**
623
+ * Returns a new Mesh object generated from the current mesh properties.
624
+ * @param name is a string, the name given to the new mesh
625
+ * @returns a new Gaussian Splatting Mesh
626
+ */
627
+ clone(name = "") {
628
+ const newGS = new GaussianSplattingMesh(name, undefined, this.getScene());
629
+ newGS._copySource(this);
630
+ newGS.makeGeometryUnique();
631
+ newGS._vertexCount = this._vertexCount;
632
+ newGS._copyTextures(this);
633
+ newGS._modelViewMatrix = Matrix.Identity();
634
+ newGS._splatPositions = this._splatPositions;
635
+ newGS._readyToDisplay = false;
636
+ newGS._instanciateWorker();
637
+ const binfo = this.getBoundingInfo();
638
+ newGS.getBoundingInfo().reConstruct(binfo.minimum, binfo.maximum, this.getWorldMatrix());
639
+ newGS.forcedInstanceCount = newGS._vertexCount;
640
+ newGS.setEnabled(true);
641
+ return newGS;
642
+ }
643
+ /**
644
+ * @experimental
645
+ * Update data from GS (position, orientation, color, scaling)
646
+ * @param data array that contain all the datas
647
+ */
648
+ updateData(data) {
649
+ if (!data.byteLength) {
650
+ return;
651
+ }
652
+ // if a covariance texture is present, then it's not a creation but an update
653
+ if (!this._covariancesATexture) {
654
+ this._readyToDisplay = false;
655
+ }
656
+ // Parse the data
657
+ const uBuffer = new Uint8Array(data);
658
+ const fBuffer = new Float32Array(uBuffer.buffer);
659
+ const rowLength = 3 * 4 + 3 * 4 + 4 + 4;
660
+ const vertexCount = uBuffer.length / rowLength;
661
+ if (vertexCount != this._vertexCount) {
662
+ this._updateSplatIndexBuffer(vertexCount);
663
+ }
664
+ this._vertexCount = vertexCount;
665
+ const textureSize = this._getTextureSize(vertexCount);
666
+ const textureLength = textureSize.x * textureSize.y;
667
+ this._splatPositions = new Float32Array(3 * textureLength);
668
+ const covA = new Float32Array(3 * textureLength);
669
+ const covB = new Float32Array(3 * textureLength);
670
+ const matrixRotation = TmpVectors.Matrix[0];
671
+ const matrixScale = TmpVectors.Matrix[1];
672
+ const quaternion = TmpVectors.Quaternion[0];
673
+ const minimum = new Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
674
+ const maximum = new Vector3(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
675
+ for (let i = 0; i < vertexCount; i++) {
676
+ const x = fBuffer[8 * i + 0];
677
+ const y = -fBuffer[8 * i + 1];
678
+ const z = fBuffer[8 * i + 2];
679
+ this._splatPositions[3 * i + 0] = x;
680
+ this._splatPositions[3 * i + 1] = y;
681
+ this._splatPositions[3 * i + 2] = z;
682
+ minimum.minimizeInPlaceFromFloats(x, y, z);
683
+ maximum.maximizeInPlaceFromFloats(x, y, z);
684
+ quaternion.set((uBuffer[32 * i + 28 + 1] - 128) / 128, (uBuffer[32 * i + 28 + 2] - 128) / 128, (uBuffer[32 * i + 28 + 3] - 128) / 128, -(uBuffer[32 * i + 28 + 0] - 128) / 128);
685
+ quaternion.toRotationMatrix(matrixRotation);
686
+ Matrix.ScalingToRef(fBuffer[8 * i + 3 + 0] * 2, fBuffer[8 * i + 3 + 1] * 2, fBuffer[8 * i + 3 + 2] * 2, matrixScale);
687
+ const M = matrixRotation.multiplyToRef(matrixScale, TmpVectors.Matrix[0]).m;
688
+ covA[i * 3 + 0] = M[0] * M[0] + M[1] * M[1] + M[2] * M[2];
689
+ covA[i * 3 + 1] = M[0] * M[4] + M[1] * M[5] + M[2] * M[6];
690
+ covA[i * 3 + 2] = M[0] * M[8] + M[1] * M[9] + M[2] * M[10];
691
+ covB[i * 3 + 0] = M[4] * M[4] + M[5] * M[5] + M[6] * M[6];
692
+ covB[i * 3 + 1] = M[4] * M[8] + M[5] * M[9] + M[6] * M[10];
693
+ covB[i * 3 + 2] = M[8] * M[8] + M[9] * M[9] + M[10] * M[10];
694
+ }
695
+ // Update the mesh
696
+ const binfo = this.getBoundingInfo();
697
+ binfo.reConstruct(minimum, maximum, this.getWorldMatrix());
698
+ this.setEnabled(true);
699
+ // Update the material
700
+ const createTextureFromData = (data, width, height, format) => {
701
+ return new RawTexture(data, width, height, format, this._scene, false, false, Constants.TEXTURE_BILINEAR_SAMPLINGMODE, Constants.TEXTURETYPE_FLOAT);
702
+ };
703
+ const convertRgbToRgba = (rgb) => {
704
+ const count = rgb.length / 3;
705
+ const rgba = new Float32Array(count * 4);
706
+ for (let i = 0; i < count; ++i) {
707
+ rgba[i * 4 + 0] = rgb[i * 3 + 0];
708
+ rgba[i * 4 + 1] = rgb[i * 3 + 1];
709
+ rgba[i * 4 + 2] = rgb[i * 3 + 2];
710
+ rgba[i * 4 + 3] = 1.0;
711
+ }
712
+ return rgba;
713
+ };
714
+ const colorArray = new Float32Array(textureSize.x * textureSize.y * 4);
715
+ for (let i = 0; i < this._vertexCount; ++i) {
716
+ colorArray[i * 4 + 0] = uBuffer[32 * i + 24 + 0] / 255;
717
+ colorArray[i * 4 + 1] = uBuffer[32 * i + 24 + 1] / 255;
718
+ colorArray[i * 4 + 2] = uBuffer[32 * i + 24 + 2] / 255;
719
+ colorArray[i * 4 + 3] = uBuffer[32 * i + 24 + 3] / 255;
720
+ }
721
+ if (this._keepInRam) {
722
+ this._covariancesA = covA;
723
+ this._covariancesB = covB;
724
+ this._colors = colorArray;
725
+ }
726
+ if (this._covariancesATexture) {
727
+ this._delayedTextureUpdate = { covA: convertRgbToRgba(covA), covB: convertRgbToRgba(covB), colors: colorArray, centers: convertRgbToRgba(this._splatPositions) };
728
+ const positions = Float32Array.from(this._splatPositions);
729
+ const vertexCount = this._vertexCount;
730
+ this._worker.postMessage({ positions, vertexCount }, [positions.buffer]);
731
+ this._postToWorker(true);
732
+ }
733
+ else {
734
+ this._covariancesATexture = createTextureFromData(convertRgbToRgba(covA), textureSize.x, textureSize.y, Constants.TEXTUREFORMAT_RGBA);
735
+ this._covariancesBTexture = createTextureFromData(convertRgbToRgba(covB), textureSize.x, textureSize.y, Constants.TEXTUREFORMAT_RGBA);
736
+ this._centersTexture = createTextureFromData(convertRgbToRgba(this._splatPositions), textureSize.x, textureSize.y, Constants.TEXTUREFORMAT_RGBA);
737
+ this._colorsTexture = createTextureFromData(colorArray, textureSize.x, textureSize.y, Constants.TEXTUREFORMAT_RGBA);
738
+ this._instanciateWorker();
739
+ }
740
+ }
741
+ _loadData(data) {
742
+ if (!data.byteLength) {
743
+ return;
744
+ }
745
+ this.updateData(data);
746
+ }
747
+ // in case size is different
748
+ _updateSplatIndexBuffer(vertexCount) {
749
+ if (!this._splatIndex || vertexCount > this._splatIndex.length) {
750
+ this._splatIndex = new Float32Array(vertexCount);
751
+ this.thinInstanceSetBuffer("splatIndex", this._splatIndex, 1, false);
752
+ }
753
+ this.forcedInstanceCount = vertexCount;
754
+ }
755
+ _instanciateWorker() {
756
+ if (!this._vertexCount) {
757
+ return;
758
+ }
759
+ this._updateSplatIndexBuffer(this._vertexCount);
760
+ // Start the worker thread
761
+ this._worker?.terminate();
762
+ this._worker = new Worker(URL.createObjectURL(new Blob(["(", GaussianSplattingMesh._CreateWorker.toString(), ")(self)"], {
763
+ type: "application/javascript",
764
+ })));
765
+ this._depthMix = new BigInt64Array(this._vertexCount);
766
+ const positions = Float32Array.from(this._splatPositions);
767
+ const vertexCount = this._vertexCount;
768
+ this._worker.postMessage({ positions, vertexCount }, [positions.buffer]);
769
+ this._worker.onmessage = (e) => {
770
+ this._depthMix = e.data.depthMix;
771
+ const indexMix = new Uint32Array(e.data.depthMix.buffer);
772
+ if (this._splatIndex) {
773
+ for (let j = 0; j < this._vertexCount; j++) {
774
+ this._splatIndex[j] = indexMix[2 * j];
775
+ }
776
+ }
777
+ if (this._delayedTextureUpdate) {
778
+ const updateTextureFromData = (texture, data, width, height) => {
779
+ this.getEngine().updateTextureData(texture.getInternalTexture(), data, 0, 0, width, height, 0, 0, false);
780
+ };
781
+ const textureSize = this._getTextureSize(vertexCount);
782
+ updateTextureFromData(this._covariancesATexture, this._delayedTextureUpdate.covA, textureSize.x, textureSize.y);
783
+ updateTextureFromData(this._covariancesBTexture, this._delayedTextureUpdate.covB, textureSize.x, textureSize.y);
784
+ updateTextureFromData(this._centersTexture, this._delayedTextureUpdate.centers, textureSize.x, textureSize.y);
785
+ updateTextureFromData(this._colorsTexture, this._delayedTextureUpdate.colors, textureSize.x, textureSize.y);
786
+ this._delayedTextureUpdate = null;
787
+ }
788
+ this.thinInstanceBufferUpdated("splatIndex");
789
+ this._canPostToWorker = true;
790
+ this._readyToDisplay = true;
791
+ };
792
+ }
793
+ _getTextureSize(length) {
794
+ const engine = this._scene.getEngine();
795
+ const width = engine.getCaps().maxTextureSize;
796
+ let height = 1;
797
+ if (engine.version === 1 && !engine.isWebGPU) {
798
+ while (width * height < length) {
799
+ height *= 2;
800
+ }
801
+ }
802
+ else {
803
+ height = Math.ceil(length / width);
804
+ }
805
+ if (height > width) {
806
+ Logger.Error("GaussianSplatting texture size: (" + width + ", " + height + "), maxTextureSize: " + width);
807
+ height = width;
808
+ }
809
+ return new Vector2(width, height);
810
+ }
811
+ }
812
+ GaussianSplattingMesh._CreateWorker = function (self) {
813
+ let vertexCount = 0;
814
+ let positions;
815
+ let depthMix;
816
+ let indices;
817
+ let floatMix;
818
+ self.onmessage = (e) => {
819
+ // updated on init
820
+ if (e.data.positions) {
821
+ positions = e.data.positions;
822
+ vertexCount = e.data.vertexCount;
823
+ }
824
+ // udpate on view changed
825
+ else {
826
+ const viewProj = e.data.view;
827
+ if (!positions || !viewProj) {
828
+ // Sanity check, it shouldn't happen!
829
+ throw new Error("positions or view is not defined!");
830
+ }
831
+ depthMix = e.data.depthMix;
832
+ indices = new Uint32Array(depthMix.buffer);
833
+ floatMix = new Float32Array(depthMix.buffer);
834
+ // Sort
835
+ for (let j = 0; j < vertexCount; j++) {
836
+ indices[2 * j] = j;
837
+ }
838
+ let depthFactor = -1;
839
+ if (e.data.useRightHandedSystem) {
840
+ depthFactor = 1;
841
+ }
842
+ for (let j = 0; j < vertexCount; j++) {
843
+ floatMix[2 * j + 1] = 10000 + (viewProj[2] * positions[3 * j + 0] + viewProj[6] * positions[3 * j + 1] + viewProj[10] * positions[3 * j + 2]) * depthFactor;
844
+ }
845
+ depthMix.sort();
846
+ self.postMessage({ depthMix }, [depthMix.buffer]);
847
+ }
848
+ };
849
+ };
850
+
851
+ /**
852
+ * Represents one particle of a points cloud system.
853
+ */
854
+ class CloudPoint {
855
+ /**
856
+ * Creates a Point Cloud object.
857
+ * Don't create particles manually, use instead the PCS internal tools like _addParticle()
858
+ * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
859
+ * @param group (PointsGroup) is the group the particle belongs to
860
+ * @param groupId (integer) is the group identifier in the PCS.
861
+ * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
862
+ * @param pcs defines the PCS it is associated to
863
+ */
864
+ constructor(particleIndex, group, groupId, idxInGroup, pcs) {
865
+ /**
866
+ * particle global index
867
+ */
868
+ this.idx = 0;
869
+ /**
870
+ * The color of the particle
871
+ */
872
+ this.color = new Color4(1.0, 1.0, 1.0, 1.0);
873
+ /**
874
+ * The world space position of the particle.
875
+ */
876
+ this.position = Vector3.Zero();
877
+ /**
878
+ * The world space rotation of the particle. (Not use if rotationQuaternion is set)
879
+ */
880
+ this.rotation = Vector3.Zero();
881
+ /**
882
+ * The uv of the particle.
883
+ */
884
+ this.uv = new Vector2(0.0, 0.0);
885
+ /**
886
+ * The current speed of the particle.
887
+ */
888
+ this.velocity = Vector3.Zero();
889
+ /**
890
+ * The pivot point in the particle local space.
891
+ */
892
+ this.pivot = Vector3.Zero();
893
+ /**
894
+ * Must the particle be translated from its pivot point in its local space ?
895
+ * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
896
+ * Default : false
897
+ */
898
+ this.translateFromPivot = false;
899
+ /**
900
+ * Index of this particle in the global "positions" array (Internal use)
901
+ * @internal
902
+ */
903
+ this._pos = 0;
904
+ /**
905
+ * @internal Index of this particle in the global "indices" array (Internal use)
906
+ */
907
+ this._ind = 0;
908
+ /**
909
+ * Group id of this particle
910
+ */
911
+ this.groupId = 0;
912
+ /**
913
+ * Index of the particle in its group id (Internal use)
914
+ */
915
+ this.idxInGroup = 0;
916
+ /**
917
+ * @internal Still set as invisible in order to skip useless computations (Internal use)
918
+ */
919
+ this._stillInvisible = false;
920
+ /**
921
+ * @internal Last computed particle rotation matrix
922
+ */
923
+ this._rotationMatrix = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0];
924
+ /**
925
+ * Parent particle Id, if any.
926
+ * Default null.
927
+ */
928
+ this.parentId = null;
929
+ /**
930
+ * @internal Internal global position in the PCS.
931
+ */
932
+ this._globalPosition = Vector3.Zero();
933
+ this.idx = particleIndex;
934
+ this._group = group;
935
+ this.groupId = groupId;
936
+ this.idxInGroup = idxInGroup;
937
+ this._pcs = pcs;
938
+ }
939
+ /**
940
+ * get point size
941
+ */
942
+ get size() {
943
+ return this.size;
944
+ }
945
+ /**
946
+ * Set point size
947
+ */
948
+ set size(scale) {
949
+ this.size = scale;
950
+ }
951
+ /**
952
+ * Legacy support, changed quaternion to rotationQuaternion
953
+ */
954
+ get quaternion() {
955
+ return this.rotationQuaternion;
956
+ }
957
+ /**
958
+ * Legacy support, changed quaternion to rotationQuaternion
959
+ */
960
+ set quaternion(q) {
961
+ this.rotationQuaternion = q;
962
+ }
963
+ /**
964
+ * Returns a boolean. True if the particle intersects a mesh, else false
965
+ * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
966
+ * @param target is the object (point or mesh) what the intersection is computed against
967
+ * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bounding sphere is used
968
+ * @returns true if it intersects
969
+ */
970
+ intersectsMesh(target, isSphere) {
971
+ if (!target.hasBoundingInfo) {
972
+ return false;
973
+ }
974
+ if (!this._pcs.mesh) {
975
+ throw new Error("Point Cloud System doesnt contain the Mesh");
976
+ }
977
+ if (isSphere) {
978
+ return target.getBoundingInfo().boundingSphere.intersectsPoint(this.position.add(this._pcs.mesh.position));
979
+ }
980
+ const bbox = target.getBoundingInfo().boundingBox;
981
+ const maxX = bbox.maximumWorld.x;
982
+ const minX = bbox.minimumWorld.x;
983
+ const maxY = bbox.maximumWorld.y;
984
+ const minY = bbox.minimumWorld.y;
985
+ const maxZ = bbox.maximumWorld.z;
986
+ const minZ = bbox.minimumWorld.z;
987
+ const x = this.position.x + this._pcs.mesh.position.x;
988
+ const y = this.position.y + this._pcs.mesh.position.y;
989
+ const z = this.position.z + this._pcs.mesh.position.z;
990
+ return minX <= x && x <= maxX && minY <= y && y <= maxY && minZ <= z && z <= maxZ;
991
+ }
992
+ /**
993
+ * get the rotation matrix of the particle
994
+ * @internal
995
+ */
996
+ getRotationMatrix(m) {
997
+ let quaternion;
998
+ if (this.rotationQuaternion) {
999
+ quaternion = this.rotationQuaternion;
1000
+ }
1001
+ else {
1002
+ quaternion = TmpVectors.Quaternion[0];
1003
+ const rotation = this.rotation;
1004
+ Quaternion.RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
1005
+ }
1006
+ quaternion.toRotationMatrix(m);
1007
+ }
1008
+ }
1009
+ /**
1010
+ * Represents a group of points in a points cloud system
1011
+ * * PCS internal tool, don't use it manually.
1012
+ */
1013
+ class PointsGroup {
1014
+ /**
1015
+ * Get or set the groupId
1016
+ * @deprecated Please use groupId instead
1017
+ */
1018
+ get groupID() {
1019
+ return this.groupId;
1020
+ }
1021
+ set groupID(groupID) {
1022
+ this.groupId = groupID;
1023
+ }
1024
+ /**
1025
+ * Creates a points group object. This is an internal reference to produce particles for the PCS.
1026
+ * PCS internal tool, don't use it manually.
1027
+ * @internal
1028
+ */
1029
+ constructor(id, posFunction) {
1030
+ this.groupId = id;
1031
+ this._positionFunction = posFunction;
1032
+ }
1033
+ }
1034
+
1035
+ /**
1036
+ * Class representing a ray with position and direction
1037
+ */
1038
+ class Ray {
1039
+ /**
1040
+ * Creates a new ray
1041
+ * @param origin origin point
1042
+ * @param direction direction
1043
+ * @param length length of the ray
1044
+ * @param epsilon The epsilon value to use when calculating the ray/triangle intersection (default: 0)
1045
+ */
1046
+ constructor(
1047
+ /** origin point */
1048
+ origin,
1049
+ /** direction */
1050
+ direction,
1051
+ /** [Number.MAX_VALUE] length of the ray */
1052
+ length = Number.MAX_VALUE,
1053
+ /** [Epsilon] The epsilon value to use when calculating the ray/triangle intersection (default: Epsilon from math constants) */
1054
+ epsilon = Epsilon) {
1055
+ this.origin = origin;
1056
+ this.direction = direction;
1057
+ this.length = length;
1058
+ this.epsilon = epsilon;
1059
+ }
1060
+ // Methods
1061
+ /**
1062
+ * Clone the current ray
1063
+ * @returns a new ray
1064
+ */
1065
+ clone() {
1066
+ return new Ray(this.origin.clone(), this.direction.clone(), this.length);
1067
+ }
1068
+ /**
1069
+ * Checks if the ray intersects a box
1070
+ * This does not account for the ray length by design to improve perfs.
1071
+ * @param minimum bound of the box
1072
+ * @param maximum bound of the box
1073
+ * @param intersectionTreshold extra extend to be added to the box in all direction
1074
+ * @returns if the box was hit
1075
+ */
1076
+ intersectsBoxMinMax(minimum, maximum, intersectionTreshold = 0) {
1077
+ const newMinimum = Ray._TmpVector3[0].copyFromFloats(minimum.x - intersectionTreshold, minimum.y - intersectionTreshold, minimum.z - intersectionTreshold);
1078
+ const newMaximum = Ray._TmpVector3[1].copyFromFloats(maximum.x + intersectionTreshold, maximum.y + intersectionTreshold, maximum.z + intersectionTreshold);
1079
+ let d = 0.0;
1080
+ let maxValue = Number.MAX_VALUE;
1081
+ let inv;
1082
+ let min;
1083
+ let max;
1084
+ let temp;
1085
+ if (Math.abs(this.direction.x) < 0.0000001) {
1086
+ if (this.origin.x < newMinimum.x || this.origin.x > newMaximum.x) {
1087
+ return false;
1088
+ }
1089
+ }
1090
+ else {
1091
+ inv = 1.0 / this.direction.x;
1092
+ min = (newMinimum.x - this.origin.x) * inv;
1093
+ max = (newMaximum.x - this.origin.x) * inv;
1094
+ if (max === -Infinity) {
1095
+ max = Infinity;
1096
+ }
1097
+ if (min > max) {
1098
+ temp = min;
1099
+ min = max;
1100
+ max = temp;
1101
+ }
1102
+ d = Math.max(min, d);
1103
+ maxValue = Math.min(max, maxValue);
1104
+ if (d > maxValue) {
1105
+ return false;
1106
+ }
1107
+ }
1108
+ if (Math.abs(this.direction.y) < 0.0000001) {
1109
+ if (this.origin.y < newMinimum.y || this.origin.y > newMaximum.y) {
1110
+ return false;
1111
+ }
1112
+ }
1113
+ else {
1114
+ inv = 1.0 / this.direction.y;
1115
+ min = (newMinimum.y - this.origin.y) * inv;
1116
+ max = (newMaximum.y - this.origin.y) * inv;
1117
+ if (max === -Infinity) {
1118
+ max = Infinity;
1119
+ }
1120
+ if (min > max) {
1121
+ temp = min;
1122
+ min = max;
1123
+ max = temp;
1124
+ }
1125
+ d = Math.max(min, d);
1126
+ maxValue = Math.min(max, maxValue);
1127
+ if (d > maxValue) {
1128
+ return false;
1129
+ }
1130
+ }
1131
+ if (Math.abs(this.direction.z) < 0.0000001) {
1132
+ if (this.origin.z < newMinimum.z || this.origin.z > newMaximum.z) {
1133
+ return false;
1134
+ }
1135
+ }
1136
+ else {
1137
+ inv = 1.0 / this.direction.z;
1138
+ min = (newMinimum.z - this.origin.z) * inv;
1139
+ max = (newMaximum.z - this.origin.z) * inv;
1140
+ if (max === -Infinity) {
1141
+ max = Infinity;
1142
+ }
1143
+ if (min > max) {
1144
+ temp = min;
1145
+ min = max;
1146
+ max = temp;
1147
+ }
1148
+ d = Math.max(min, d);
1149
+ maxValue = Math.min(max, maxValue);
1150
+ if (d > maxValue) {
1151
+ return false;
1152
+ }
1153
+ }
1154
+ return true;
1155
+ }
1156
+ /**
1157
+ * Checks if the ray intersects a box
1158
+ * This does not account for the ray lenght by design to improve perfs.
1159
+ * @param box the bounding box to check
1160
+ * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
1161
+ * @returns if the box was hit
1162
+ */
1163
+ intersectsBox(box, intersectionTreshold = 0) {
1164
+ return this.intersectsBoxMinMax(box.minimum, box.maximum, intersectionTreshold);
1165
+ }
1166
+ /**
1167
+ * If the ray hits a sphere
1168
+ * @param sphere the bounding sphere to check
1169
+ * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
1170
+ * @returns true if it hits the sphere
1171
+ */
1172
+ intersectsSphere(sphere, intersectionTreshold = 0) {
1173
+ const x = sphere.center.x - this.origin.x;
1174
+ const y = sphere.center.y - this.origin.y;
1175
+ const z = sphere.center.z - this.origin.z;
1176
+ const pyth = x * x + y * y + z * z;
1177
+ const radius = sphere.radius + intersectionTreshold;
1178
+ const rr = radius * radius;
1179
+ if (pyth <= rr) {
1180
+ return true;
1181
+ }
1182
+ const dot = x * this.direction.x + y * this.direction.y + z * this.direction.z;
1183
+ if (dot < 0.0) {
1184
+ return false;
1185
+ }
1186
+ const temp = pyth - dot * dot;
1187
+ return temp <= rr;
1188
+ }
1189
+ /**
1190
+ * If the ray hits a triange
1191
+ * @param vertex0 triangle vertex
1192
+ * @param vertex1 triangle vertex
1193
+ * @param vertex2 triangle vertex
1194
+ * @returns intersection information if hit
1195
+ */
1196
+ intersectsTriangle(vertex0, vertex1, vertex2) {
1197
+ const edge1 = Ray._TmpVector3[0];
1198
+ const edge2 = Ray._TmpVector3[1];
1199
+ const pvec = Ray._TmpVector3[2];
1200
+ const tvec = Ray._TmpVector3[3];
1201
+ const qvec = Ray._TmpVector3[4];
1202
+ vertex1.subtractToRef(vertex0, edge1);
1203
+ vertex2.subtractToRef(vertex0, edge2);
1204
+ Vector3.CrossToRef(this.direction, edge2, pvec);
1205
+ const det = Vector3.Dot(edge1, pvec);
1206
+ if (det === 0) {
1207
+ return null;
1208
+ }
1209
+ const invdet = 1 / det;
1210
+ this.origin.subtractToRef(vertex0, tvec);
1211
+ const bv = Vector3.Dot(tvec, pvec) * invdet;
1212
+ if (bv < -this.epsilon || bv > 1.0 + this.epsilon) {
1213
+ return null;
1214
+ }
1215
+ Vector3.CrossToRef(tvec, edge1, qvec);
1216
+ const bw = Vector3.Dot(this.direction, qvec) * invdet;
1217
+ if (bw < -this.epsilon || bv + bw > 1.0 + this.epsilon) {
1218
+ return null;
1219
+ }
1220
+ //check if the distance is longer than the predefined length.
1221
+ const distance = Vector3.Dot(edge2, qvec) * invdet;
1222
+ if (distance > this.length) {
1223
+ return null;
1224
+ }
1225
+ return new IntersectionInfo(1 - bv - bw, bv, distance);
1226
+ }
1227
+ /**
1228
+ * Checks if ray intersects a plane
1229
+ * @param plane the plane to check
1230
+ * @returns the distance away it was hit
1231
+ */
1232
+ intersectsPlane(plane) {
1233
+ let distance;
1234
+ const result1 = Vector3.Dot(plane.normal, this.direction);
1235
+ if (Math.abs(result1) < 9.99999997475243e-7) {
1236
+ return null;
1237
+ }
1238
+ else {
1239
+ const result2 = Vector3.Dot(plane.normal, this.origin);
1240
+ distance = (-plane.d - result2) / result1;
1241
+ if (distance < 0.0) {
1242
+ if (distance < -9.99999997475243e-7) {
1243
+ return null;
1244
+ }
1245
+ else {
1246
+ return 0;
1247
+ }
1248
+ }
1249
+ return distance;
1250
+ }
1251
+ }
1252
+ /**
1253
+ * Calculate the intercept of a ray on a given axis
1254
+ * @param axis to check 'x' | 'y' | 'z'
1255
+ * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
1256
+ * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
1257
+ */
1258
+ intersectsAxis(axis, offset = 0) {
1259
+ switch (axis) {
1260
+ case "y": {
1261
+ const t = (this.origin.y - offset) / this.direction.y;
1262
+ if (t > 0) {
1263
+ return null;
1264
+ }
1265
+ return new Vector3(this.origin.x + this.direction.x * -t, offset, this.origin.z + this.direction.z * -t);
1266
+ }
1267
+ case "x": {
1268
+ const t = (this.origin.x - offset) / this.direction.x;
1269
+ if (t > 0) {
1270
+ return null;
1271
+ }
1272
+ return new Vector3(offset, this.origin.y + this.direction.y * -t, this.origin.z + this.direction.z * -t);
1273
+ }
1274
+ case "z": {
1275
+ const t = (this.origin.z - offset) / this.direction.z;
1276
+ if (t > 0) {
1277
+ return null;
1278
+ }
1279
+ return new Vector3(this.origin.x + this.direction.x * -t, this.origin.y + this.direction.y * -t, offset);
1280
+ }
1281
+ default:
1282
+ return null;
1283
+ }
1284
+ }
1285
+ /**
1286
+ * Checks if ray intersects a mesh. The ray is defined in WORLD space. A mesh triangle can be picked both from its front and back sides,
1287
+ * irrespective of orientation.
1288
+ * @param mesh the mesh to check
1289
+ * @param fastCheck defines if the first intersection will be used (and not the closest)
1290
+ * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
1291
+ * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
1292
+ * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
1293
+ * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
1294
+ * @returns picking info of the intersection
1295
+ */
1296
+ intersectsMesh(mesh, fastCheck, trianglePredicate, onlyBoundingInfo = false, worldToUse, skipBoundingInfo = false) {
1297
+ const tm = TmpVectors.Matrix[0];
1298
+ mesh.getWorldMatrix().invertToRef(tm);
1299
+ if (this._tmpRay) {
1300
+ Ray.TransformToRef(this, tm, this._tmpRay);
1301
+ }
1302
+ else {
1303
+ this._tmpRay = Ray.Transform(this, tm);
1304
+ }
1305
+ return mesh.intersects(this._tmpRay, fastCheck, trianglePredicate, onlyBoundingInfo, worldToUse, skipBoundingInfo);
1306
+ }
1307
+ /**
1308
+ * Checks if ray intersects a mesh
1309
+ * @param meshes the meshes to check
1310
+ * @param fastCheck defines if the first intersection will be used (and not the closest)
1311
+ * @param results array to store result in
1312
+ * @returns Array of picking infos
1313
+ */
1314
+ intersectsMeshes(meshes, fastCheck, results) {
1315
+ if (results) {
1316
+ results.length = 0;
1317
+ }
1318
+ else {
1319
+ results = [];
1320
+ }
1321
+ for (let i = 0; i < meshes.length; i++) {
1322
+ const pickInfo = this.intersectsMesh(meshes[i], fastCheck);
1323
+ if (pickInfo.hit) {
1324
+ results.push(pickInfo);
1325
+ }
1326
+ }
1327
+ results.sort(this._comparePickingInfo);
1328
+ return results;
1329
+ }
1330
+ _comparePickingInfo(pickingInfoA, pickingInfoB) {
1331
+ if (pickingInfoA.distance < pickingInfoB.distance) {
1332
+ return -1;
1333
+ }
1334
+ else if (pickingInfoA.distance > pickingInfoB.distance) {
1335
+ return 1;
1336
+ }
1337
+ else {
1338
+ return 0;
1339
+ }
1340
+ }
1341
+ /**
1342
+ * Intersection test between the ray and a given segment within a given tolerance (threshold)
1343
+ * @param sega the first point of the segment to test the intersection against
1344
+ * @param segb the second point of the segment to test the intersection against
1345
+ * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
1346
+ * @returns the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
1347
+ */
1348
+ intersectionSegment(sega, segb, threshold) {
1349
+ const o = this.origin;
1350
+ const u = TmpVectors.Vector3[0];
1351
+ const rsegb = TmpVectors.Vector3[1];
1352
+ const v = TmpVectors.Vector3[2];
1353
+ const w = TmpVectors.Vector3[3];
1354
+ segb.subtractToRef(sega, u);
1355
+ this.direction.scaleToRef(Ray._Rayl, v);
1356
+ o.addToRef(v, rsegb);
1357
+ sega.subtractToRef(o, w);
1358
+ const a = Vector3.Dot(u, u); // always >= 0
1359
+ const b = Vector3.Dot(u, v);
1360
+ const c = Vector3.Dot(v, v); // always >= 0
1361
+ const d = Vector3.Dot(u, w);
1362
+ const e = Vector3.Dot(v, w);
1363
+ const D = a * c - b * b; // always >= 0
1364
+ let sN, sD = D; // sc = sN / sD, default sD = D >= 0
1365
+ let tN, tD = D; // tc = tN / tD, default tD = D >= 0
1366
+ // compute the line parameters of the two closest points
1367
+ if (D < Ray._Smallnum) {
1368
+ // the lines are almost parallel
1369
+ sN = 0.0; // force using point P0 on segment S1
1370
+ sD = 1.0; // to prevent possible division by 0.0 later
1371
+ tN = e;
1372
+ tD = c;
1373
+ }
1374
+ else {
1375
+ // get the closest points on the infinite lines
1376
+ sN = b * e - c * d;
1377
+ tN = a * e - b * d;
1378
+ if (sN < 0.0) {
1379
+ // sc < 0 => the s=0 edge is visible
1380
+ sN = 0.0;
1381
+ tN = e;
1382
+ tD = c;
1383
+ }
1384
+ else if (sN > sD) {
1385
+ // sc > 1 => the s=1 edge is visible
1386
+ sN = sD;
1387
+ tN = e + b;
1388
+ tD = c;
1389
+ }
1390
+ }
1391
+ if (tN < 0.0) {
1392
+ // tc < 0 => the t=0 edge is visible
1393
+ tN = 0.0;
1394
+ // recompute sc for this edge
1395
+ if (-d < 0.0) {
1396
+ sN = 0.0;
1397
+ }
1398
+ else if (-d > a) {
1399
+ sN = sD;
1400
+ }
1401
+ else {
1402
+ sN = -d;
1403
+ sD = a;
1404
+ }
1405
+ }
1406
+ else if (tN > tD) {
1407
+ // tc > 1 => the t=1 edge is visible
1408
+ tN = tD;
1409
+ // recompute sc for this edge
1410
+ if (-d + b < 0.0) {
1411
+ sN = 0;
1412
+ }
1413
+ else if (-d + b > a) {
1414
+ sN = sD;
1415
+ }
1416
+ else {
1417
+ sN = -d + b;
1418
+ sD = a;
1419
+ }
1420
+ }
1421
+ // finally do the division to get sc and tc
1422
+ const sc = Math.abs(sN) < Ray._Smallnum ? 0.0 : sN / sD;
1423
+ const tc = Math.abs(tN) < Ray._Smallnum ? 0.0 : tN / tD;
1424
+ // get the difference of the two closest points
1425
+ const qtc = TmpVectors.Vector3[4];
1426
+ v.scaleToRef(tc, qtc);
1427
+ const qsc = TmpVectors.Vector3[5];
1428
+ u.scaleToRef(sc, qsc);
1429
+ qsc.addInPlace(w);
1430
+ const dP = TmpVectors.Vector3[6];
1431
+ qsc.subtractToRef(qtc, dP); // = S1(sc) - S2(tc)
1432
+ const isIntersected = tc > 0 && tc <= this.length && dP.lengthSquared() < threshold * threshold; // return intersection result
1433
+ if (isIntersected) {
1434
+ return qsc.length();
1435
+ }
1436
+ return -1;
1437
+ }
1438
+ /**
1439
+ * Update the ray from viewport position
1440
+ * @param x position
1441
+ * @param y y position
1442
+ * @param viewportWidth viewport width
1443
+ * @param viewportHeight viewport height
1444
+ * @param world world matrix
1445
+ * @param view view matrix
1446
+ * @param projection projection matrix
1447
+ * @param enableDistantPicking defines if picking should handle large values for mesh position/scaling (false by default)
1448
+ * @returns this ray updated
1449
+ */
1450
+ update(x, y, viewportWidth, viewportHeight, world, view, projection, enableDistantPicking = false) {
1451
+ if (enableDistantPicking) {
1452
+ // With world matrices having great values (like 8000000000 on 1 or more scaling or position axis),
1453
+ // multiplying view/projection/world and doing invert will result in loss of float precision in the matrix.
1454
+ // One way to fix it is to compute the ray with world at identity then transform the ray in object space.
1455
+ // This is slower (2 matrix inverts instead of 1) but precision is preserved.
1456
+ // This is hidden behind `EnableDistantPicking` flag (default is false)
1457
+ if (!Ray._RayDistant) {
1458
+ Ray._RayDistant = Ray.Zero();
1459
+ }
1460
+ Ray._RayDistant.unprojectRayToRef(x, y, viewportWidth, viewportHeight, Matrix.IdentityReadOnly, view, projection);
1461
+ const tm = TmpVectors.Matrix[0];
1462
+ world.invertToRef(tm);
1463
+ Ray.TransformToRef(Ray._RayDistant, tm, this);
1464
+ }
1465
+ else {
1466
+ this.unprojectRayToRef(x, y, viewportWidth, viewportHeight, world, view, projection);
1467
+ }
1468
+ return this;
1469
+ }
1470
+ // Statics
1471
+ /**
1472
+ * Creates a ray with origin and direction of 0,0,0
1473
+ * @returns the new ray
1474
+ */
1475
+ static Zero() {
1476
+ return new Ray(Vector3.Zero(), Vector3.Zero());
1477
+ }
1478
+ /**
1479
+ * Creates a new ray from screen space and viewport
1480
+ * @param x position
1481
+ * @param y y position
1482
+ * @param viewportWidth viewport width
1483
+ * @param viewportHeight viewport height
1484
+ * @param world world matrix
1485
+ * @param view view matrix
1486
+ * @param projection projection matrix
1487
+ * @returns new ray
1488
+ */
1489
+ static CreateNew(x, y, viewportWidth, viewportHeight, world, view, projection) {
1490
+ const result = Ray.Zero();
1491
+ return result.update(x, y, viewportWidth, viewportHeight, world, view, projection);
1492
+ }
1493
+ /**
1494
+ * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
1495
+ * transformed to the given world matrix.
1496
+ * @param origin The origin point
1497
+ * @param end The end point
1498
+ * @param world a matrix to transform the ray to. Default is the identity matrix.
1499
+ * @returns the new ray
1500
+ */
1501
+ static CreateNewFromTo(origin, end, world = Matrix.IdentityReadOnly) {
1502
+ const result = new Ray(new Vector3(0, 0, 0), new Vector3(0, 0, 0));
1503
+ return Ray.CreateFromToToRef(origin, end, result, world);
1504
+ }
1505
+ /**
1506
+ * Function will update a transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
1507
+ * transformed to the given world matrix.
1508
+ * @param origin The origin point
1509
+ * @param end The end point
1510
+ * @param result the object to store the result
1511
+ * @param world a matrix to transform the ray to. Default is the identity matrix.
1512
+ * @returns the ref ray
1513
+ */
1514
+ static CreateFromToToRef(origin, end, result, world = Matrix.IdentityReadOnly) {
1515
+ result.origin.copyFrom(origin);
1516
+ const direction = end.subtractToRef(origin, result.direction);
1517
+ const length = Math.sqrt(direction.x * direction.x + direction.y * direction.y + direction.z * direction.z);
1518
+ result.length = length;
1519
+ result.direction.normalize();
1520
+ return Ray.TransformToRef(result, world, result);
1521
+ }
1522
+ /**
1523
+ * Transforms a ray by a matrix
1524
+ * @param ray ray to transform
1525
+ * @param matrix matrix to apply
1526
+ * @returns the resulting new ray
1527
+ */
1528
+ static Transform(ray, matrix) {
1529
+ const result = new Ray(new Vector3(0, 0, 0), new Vector3(0, 0, 0));
1530
+ Ray.TransformToRef(ray, matrix, result);
1531
+ return result;
1532
+ }
1533
+ /**
1534
+ * Transforms a ray by a matrix
1535
+ * @param ray ray to transform
1536
+ * @param matrix matrix to apply
1537
+ * @param result ray to store result in
1538
+ * @returns the updated result ray
1539
+ */
1540
+ static TransformToRef(ray, matrix, result) {
1541
+ Vector3.TransformCoordinatesToRef(ray.origin, matrix, result.origin);
1542
+ Vector3.TransformNormalToRef(ray.direction, matrix, result.direction);
1543
+ result.length = ray.length;
1544
+ result.epsilon = ray.epsilon;
1545
+ const dir = result.direction;
1546
+ const len = dir.length();
1547
+ if (!(len === 0 || len === 1)) {
1548
+ const num = 1.0 / len;
1549
+ dir.x *= num;
1550
+ dir.y *= num;
1551
+ dir.z *= num;
1552
+ result.length *= len;
1553
+ }
1554
+ return result;
1555
+ }
1556
+ /**
1557
+ * Unproject a ray from screen space to object space
1558
+ * @param sourceX defines the screen space x coordinate to use
1559
+ * @param sourceY defines the screen space y coordinate to use
1560
+ * @param viewportWidth defines the current width of the viewport
1561
+ * @param viewportHeight defines the current height of the viewport
1562
+ * @param world defines the world matrix to use (can be set to Identity to go to world space)
1563
+ * @param view defines the view matrix to use
1564
+ * @param projection defines the projection matrix to use
1565
+ */
1566
+ unprojectRayToRef(sourceX, sourceY, viewportWidth, viewportHeight, world, view, projection) {
1567
+ const matrix = TmpVectors.Matrix[0];
1568
+ world.multiplyToRef(view, matrix);
1569
+ matrix.multiplyToRef(projection, matrix);
1570
+ matrix.invert();
1571
+ const engine = EngineStore.LastCreatedEngine;
1572
+ const nearScreenSource = TmpVectors.Vector3[0];
1573
+ nearScreenSource.x = (sourceX / viewportWidth) * 2 - 1;
1574
+ nearScreenSource.y = -((sourceY / viewportHeight) * 2 - 1);
1575
+ nearScreenSource.z = engine?.useReverseDepthBuffer ? 1 : engine?.isNDCHalfZRange ? 0 : -1;
1576
+ // far Z need to be close but < to 1 or camera projection matrix with maxZ = 0 will NaN
1577
+ const farScreenSource = TmpVectors.Vector3[1].copyFromFloats(nearScreenSource.x, nearScreenSource.y, 1.0 - 1e-8);
1578
+ const nearVec3 = TmpVectors.Vector3[2];
1579
+ const farVec3 = TmpVectors.Vector3[3];
1580
+ Vector3._UnprojectFromInvertedMatrixToRef(nearScreenSource, matrix, nearVec3);
1581
+ Vector3._UnprojectFromInvertedMatrixToRef(farScreenSource, matrix, farVec3);
1582
+ this.origin.copyFrom(nearVec3);
1583
+ farVec3.subtractToRef(nearVec3, this.direction);
1584
+ this.direction.normalize();
1585
+ }
1586
+ }
1587
+ Ray._TmpVector3 = BuildArray(6, Vector3.Zero);
1588
+ Ray._RayDistant = Ray.Zero();
1589
+ Ray._Smallnum = 0.00000001;
1590
+ Ray._Rayl = 10e8;
1591
+ /**
1592
+ * Creates a ray that can be used to pick in the scene
1593
+ * @param scene defines the scene to use for the picking
1594
+ * @param x defines the x coordinate of the origin (on-screen)
1595
+ * @param y defines the y coordinate of the origin (on-screen)
1596
+ * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
1597
+ * @param camera defines the camera to use for the picking
1598
+ * @param cameraViewSpace defines if picking will be done in view space (false by default)
1599
+ * @returns a Ray
1600
+ */
1601
+ function CreatePickingRay(scene, x, y, world, camera, cameraViewSpace = false) {
1602
+ const result = Ray.Zero();
1603
+ CreatePickingRayToRef(scene, x, y, world, result, camera, cameraViewSpace);
1604
+ return result;
1605
+ }
1606
+ /**
1607
+ * Creates a ray that can be used to pick in the scene
1608
+ * @param scene defines the scene to use for the picking
1609
+ * @param x defines the x coordinate of the origin (on-screen)
1610
+ * @param y defines the y coordinate of the origin (on-screen)
1611
+ * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
1612
+ * @param result defines the ray where to store the picking ray
1613
+ * @param camera defines the camera to use for the picking
1614
+ * @param cameraViewSpace defines if picking will be done in view space (false by default)
1615
+ * @param enableDistantPicking defines if picking should handle large values for mesh position/scaling (false by default)
1616
+ * @returns the current scene
1617
+ */
1618
+ function CreatePickingRayToRef(scene, x, y, world, result, camera, cameraViewSpace = false, enableDistantPicking = false) {
1619
+ const engine = scene.getEngine();
1620
+ if (!camera && !(camera = scene.activeCamera)) {
1621
+ return scene;
1622
+ }
1623
+ const cameraViewport = camera.viewport;
1624
+ const renderHeight = engine.getRenderHeight();
1625
+ const { x: vx, y: vy, width, height } = cameraViewport.toGlobal(engine.getRenderWidth(), renderHeight);
1626
+ // Moving coordinates to local viewport world
1627
+ const levelInv = 1 / engine.getHardwareScalingLevel();
1628
+ x = x * levelInv - vx;
1629
+ y = y * levelInv - (renderHeight - vy - height);
1630
+ result.update(x, y, width, height, world ? world : Matrix.IdentityReadOnly, cameraViewSpace ? Matrix.IdentityReadOnly : camera.getViewMatrix(), camera.getProjectionMatrix(), enableDistantPicking);
1631
+ return scene;
1632
+ }
1633
+ /**
1634
+ * Creates a ray that can be used to pick in the scene
1635
+ * @param scene defines the scene to use for the picking
1636
+ * @param x defines the x coordinate of the origin (on-screen)
1637
+ * @param y defines the y coordinate of the origin (on-screen)
1638
+ * @param camera defines the camera to use for the picking
1639
+ * @returns a Ray
1640
+ */
1641
+ function CreatePickingRayInCameraSpace(scene, x, y, camera) {
1642
+ const result = Ray.Zero();
1643
+ CreatePickingRayInCameraSpaceToRef(scene, x, y, result, camera);
1644
+ return result;
1645
+ }
1646
+ /**
1647
+ * Creates a ray that can be used to pick in the scene
1648
+ * @param scene defines the scene to use for the picking
1649
+ * @param x defines the x coordinate of the origin (on-screen)
1650
+ * @param y defines the y coordinate of the origin (on-screen)
1651
+ * @param result defines the ray where to store the picking ray
1652
+ * @param camera defines the camera to use for the picking
1653
+ * @returns the current scene
1654
+ */
1655
+ function CreatePickingRayInCameraSpaceToRef(scene, x, y, result, camera) {
1656
+ if (!PickingInfo) {
1657
+ return scene;
1658
+ }
1659
+ const engine = scene.getEngine();
1660
+ if (!camera && !(camera = scene.activeCamera)) {
1661
+ throw new Error("Active camera not set");
1662
+ }
1663
+ const cameraViewport = camera.viewport;
1664
+ const renderHeight = engine.getRenderHeight();
1665
+ const { x: vx, y: vy, width, height } = cameraViewport.toGlobal(engine.getRenderWidth(), renderHeight);
1666
+ const identity = Matrix.Identity();
1667
+ // Moving coordinates to local viewport world
1668
+ const levelInv = 1 / engine.getHardwareScalingLevel();
1669
+ x = x * levelInv - vx;
1670
+ y = y * levelInv - (renderHeight - vy - height);
1671
+ result.update(x, y, width, height, identity, identity, camera.getProjectionMatrix());
1672
+ return scene;
1673
+ }
1674
+ function InternalPickForMesh(pickingInfo, rayFunction, mesh, world, fastCheck, onlyBoundingInfo, trianglePredicate, skipBoundingInfo) {
1675
+ const ray = rayFunction(world, mesh.enableDistantPicking);
1676
+ const result = mesh.intersects(ray, fastCheck, trianglePredicate, onlyBoundingInfo, world, skipBoundingInfo);
1677
+ if (!result || !result.hit) {
1678
+ return null;
1679
+ }
1680
+ if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
1681
+ return null;
1682
+ }
1683
+ return result;
1684
+ }
1685
+ function InternalPick(scene, rayFunction, predicate, fastCheck, onlyBoundingInfo, trianglePredicate) {
1686
+ let pickingInfo = null;
1687
+ const computeWorldMatrixForCamera = !!(scene.activeCameras && scene.activeCameras.length > 1 && scene.cameraToUseForPointers !== scene.activeCamera);
1688
+ const currentCamera = scene.cameraToUseForPointers || scene.activeCamera;
1689
+ const picker = InternalPickForMesh;
1690
+ for (let meshIndex = 0; meshIndex < scene.meshes.length; meshIndex++) {
1691
+ const mesh = scene.meshes[meshIndex];
1692
+ if (predicate) {
1693
+ if (!predicate(mesh, -1)) {
1694
+ continue;
1695
+ }
1696
+ }
1697
+ else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
1698
+ continue;
1699
+ }
1700
+ const forceCompute = computeWorldMatrixForCamera && mesh.isWorldMatrixCameraDependent();
1701
+ const world = mesh.computeWorldMatrix(forceCompute, currentCamera);
1702
+ if (mesh.hasThinInstances && mesh.thinInstanceEnablePicking) {
1703
+ // first check if the ray intersects the whole bounding box/sphere of the mesh
1704
+ const result = picker(pickingInfo, rayFunction, mesh, world, true, true, trianglePredicate);
1705
+ if (result) {
1706
+ if (onlyBoundingInfo) {
1707
+ // the user only asked for a bounding info check so we can return
1708
+ return result;
1709
+ }
1710
+ const tmpMatrix = TmpVectors.Matrix[1];
1711
+ const thinMatrices = mesh.thinInstanceGetWorldMatrices();
1712
+ for (let index = 0; index < thinMatrices.length; index++) {
1713
+ if (predicate && !predicate(mesh, index)) {
1714
+ continue;
1715
+ }
1716
+ const thinMatrix = thinMatrices[index];
1717
+ thinMatrix.multiplyToRef(world, tmpMatrix);
1718
+ const result = picker(pickingInfo, rayFunction, mesh, tmpMatrix, fastCheck, onlyBoundingInfo, trianglePredicate, true);
1719
+ if (result) {
1720
+ pickingInfo = result;
1721
+ pickingInfo.thinInstanceIndex = index;
1722
+ if (fastCheck) {
1723
+ return pickingInfo;
1724
+ }
1725
+ }
1726
+ }
1727
+ }
1728
+ }
1729
+ else {
1730
+ const result = picker(pickingInfo, rayFunction, mesh, world, fastCheck, onlyBoundingInfo, trianglePredicate);
1731
+ if (result) {
1732
+ pickingInfo = result;
1733
+ if (fastCheck) {
1734
+ return pickingInfo;
1735
+ }
1736
+ }
1737
+ }
1738
+ }
1739
+ return pickingInfo || new PickingInfo();
1740
+ }
1741
+ function InternalMultiPick(scene, rayFunction, predicate, trianglePredicate) {
1742
+ if (!PickingInfo) {
1743
+ return null;
1744
+ }
1745
+ const pickingInfos = [];
1746
+ const computeWorldMatrixForCamera = !!(scene.activeCameras && scene.activeCameras.length > 1 && scene.cameraToUseForPointers !== scene.activeCamera);
1747
+ const currentCamera = scene.cameraToUseForPointers || scene.activeCamera;
1748
+ const picker = InternalPickForMesh;
1749
+ for (let meshIndex = 0; meshIndex < scene.meshes.length; meshIndex++) {
1750
+ const mesh = scene.meshes[meshIndex];
1751
+ if (predicate) {
1752
+ if (!predicate(mesh, -1)) {
1753
+ continue;
1754
+ }
1755
+ }
1756
+ else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
1757
+ continue;
1758
+ }
1759
+ const forceCompute = computeWorldMatrixForCamera && mesh.isWorldMatrixCameraDependent();
1760
+ const world = mesh.computeWorldMatrix(forceCompute, currentCamera);
1761
+ if (mesh.hasThinInstances && mesh.thinInstanceEnablePicking) {
1762
+ const result = picker(null, rayFunction, mesh, world, true, true, trianglePredicate);
1763
+ if (result) {
1764
+ const tmpMatrix = TmpVectors.Matrix[1];
1765
+ const thinMatrices = mesh.thinInstanceGetWorldMatrices();
1766
+ for (let index = 0; index < thinMatrices.length; index++) {
1767
+ if (predicate && !predicate(mesh, index)) {
1768
+ continue;
1769
+ }
1770
+ const thinMatrix = thinMatrices[index];
1771
+ thinMatrix.multiplyToRef(world, tmpMatrix);
1772
+ const result = picker(null, rayFunction, mesh, tmpMatrix, false, false, trianglePredicate, true);
1773
+ if (result) {
1774
+ result.thinInstanceIndex = index;
1775
+ pickingInfos.push(result);
1776
+ }
1777
+ }
1778
+ }
1779
+ }
1780
+ else {
1781
+ const result = picker(null, rayFunction, mesh, world, false, false, trianglePredicate);
1782
+ if (result) {
1783
+ pickingInfos.push(result);
1784
+ }
1785
+ }
1786
+ }
1787
+ return pickingInfos;
1788
+ }
1789
+ /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
1790
+ * @param scene defines the scene to use for the picking
1791
+ * @param x position on screen
1792
+ * @param y position on screen
1793
+ * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true. thinInstanceIndex is -1 when the mesh is non-instanced
1794
+ * @param fastCheck defines if the first intersection will be used (and not the closest)
1795
+ * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
1796
+ * @returns a PickingInfo (Please note that some info will not be set like distance, bv, bu and everything that cannot be capture by only using bounding infos)
1797
+ */
1798
+ function PickWithBoundingInfo(scene, x, y, predicate, fastCheck, camera) {
1799
+ if (!PickingInfo) {
1800
+ return null;
1801
+ }
1802
+ const result = InternalPick(scene, (world) => {
1803
+ if (!scene._tempPickingRay) {
1804
+ scene._tempPickingRay = Ray.Zero();
1805
+ }
1806
+ CreatePickingRayToRef(scene, x, y, world, scene._tempPickingRay, camera || null);
1807
+ return scene._tempPickingRay;
1808
+ }, predicate, fastCheck, true);
1809
+ if (result) {
1810
+ result.ray = CreatePickingRay(scene, x, y, Matrix.Identity(), camera || null);
1811
+ }
1812
+ return result;
1813
+ }
1814
+ /** Launch a ray to try to pick a mesh in the scene
1815
+ * @param scene defines the scene to use for the picking
1816
+ * @param x position on screen
1817
+ * @param y position on screen
1818
+ * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true. thinInstanceIndex is -1 when the mesh is non-instanced
1819
+ * @param fastCheck defines if the first intersection will be used (and not the closest)
1820
+ * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
1821
+ * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
1822
+ * @param _enableDistantPicking defines if picking should handle large values for mesh position/scaling (false by default)
1823
+ * @returns a PickingInfo
1824
+ */
1825
+ function Pick(scene, x, y, predicate, fastCheck, camera, trianglePredicate, _enableDistantPicking = false) {
1826
+ const result = InternalPick(scene, (world, enableDistantPicking) => {
1827
+ if (!scene._tempPickingRay) {
1828
+ scene._tempPickingRay = Ray.Zero();
1829
+ }
1830
+ CreatePickingRayToRef(scene, x, y, world, scene._tempPickingRay, camera || null, false, enableDistantPicking);
1831
+ return scene._tempPickingRay;
1832
+ }, predicate, fastCheck, false, trianglePredicate);
1833
+ if (result) {
1834
+ result.ray = CreatePickingRay(scene, x, y, Matrix.Identity(), camera || null);
1835
+ }
1836
+ return result;
1837
+ }
1838
+ /**
1839
+ * Use the given ray to pick a mesh in the scene. A mesh triangle can be picked both from its front and back sides,
1840
+ * irrespective of orientation.
1841
+ * @param scene defines the scene to use for the picking
1842
+ * @param ray The ray to use to pick meshes
1843
+ * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must have isPickable set to true. thinInstanceIndex is -1 when the mesh is non-instanced
1844
+ * @param fastCheck defines if the first intersection will be used (and not the closest)
1845
+ * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
1846
+ * @returns a PickingInfo
1847
+ */
1848
+ function PickWithRay(scene, ray, predicate, fastCheck, trianglePredicate) {
1849
+ const result = InternalPick(scene, (world) => {
1850
+ if (!scene._pickWithRayInverseMatrix) {
1851
+ scene._pickWithRayInverseMatrix = Matrix.Identity();
1852
+ }
1853
+ world.invertToRef(scene._pickWithRayInverseMatrix);
1854
+ if (!scene._cachedRayForTransform) {
1855
+ scene._cachedRayForTransform = Ray.Zero();
1856
+ }
1857
+ Ray.TransformToRef(ray, scene._pickWithRayInverseMatrix, scene._cachedRayForTransform);
1858
+ return scene._cachedRayForTransform;
1859
+ }, predicate, fastCheck, false, trianglePredicate);
1860
+ if (result) {
1861
+ result.ray = ray;
1862
+ }
1863
+ return result;
1864
+ }
1865
+ /**
1866
+ * Launch a ray to try to pick a mesh in the scene. A mesh triangle can be picked both from its front and back sides,
1867
+ * irrespective of orientation.
1868
+ * @param scene defines the scene to use for the picking
1869
+ * @param x X position on screen
1870
+ * @param y Y position on screen
1871
+ * @param predicate Predicate function used to determine eligible meshes and instances. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true. thinInstanceIndex is -1 when the mesh is non-instanced
1872
+ * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
1873
+ * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
1874
+ * @returns an array of PickingInfo
1875
+ */
1876
+ function MultiPick(scene, x, y, predicate, camera, trianglePredicate) {
1877
+ return InternalMultiPick(scene, (world) => CreatePickingRay(scene, x, y, world, camera || null), predicate, trianglePredicate);
1878
+ }
1879
+ /**
1880
+ * Launch a ray to try to pick a mesh in the scene
1881
+ * @param scene defines the scene to use for the picking
1882
+ * @param ray Ray to use
1883
+ * @param predicate Predicate function used to determine eligible meshes and instances. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true. thinInstanceIndex is -1 when the mesh is non-instanced
1884
+ * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
1885
+ * @returns an array of PickingInfo
1886
+ */
1887
+ function MultiPickWithRay(scene, ray, predicate, trianglePredicate) {
1888
+ return InternalMultiPick(scene, (world) => {
1889
+ if (!scene._pickWithRayInverseMatrix) {
1890
+ scene._pickWithRayInverseMatrix = Matrix.Identity();
1891
+ }
1892
+ world.invertToRef(scene._pickWithRayInverseMatrix);
1893
+ if (!scene._cachedRayForTransform) {
1894
+ scene._cachedRayForTransform = Ray.Zero();
1895
+ }
1896
+ Ray.TransformToRef(ray, scene._pickWithRayInverseMatrix, scene._cachedRayForTransform);
1897
+ return scene._cachedRayForTransform;
1898
+ }, predicate, trianglePredicate);
1899
+ }
1900
+ /**
1901
+ * Gets a ray in the forward direction from the camera.
1902
+ * @param camera Defines the camera to use to get the ray from
1903
+ * @param refRay the ray to (re)use when setting the values
1904
+ * @param length Defines the length of the ray to create
1905
+ * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
1906
+ * @param origin Defines the start point of the ray which defaults to the camera position
1907
+ * @returns the forward ray
1908
+ */
1909
+ function GetForwardRayToRef(camera, refRay, length = 100, transform, origin) {
1910
+ if (!transform) {
1911
+ transform = camera.getWorldMatrix();
1912
+ }
1913
+ refRay.length = length;
1914
+ if (origin) {
1915
+ refRay.origin.copyFrom(origin);
1916
+ }
1917
+ else {
1918
+ refRay.origin.copyFrom(camera.position);
1919
+ }
1920
+ const forward = TmpVectors.Vector3[2];
1921
+ forward.set(0, 0, camera._scene.useRightHandedSystem ? -1 : 1);
1922
+ const worldForward = TmpVectors.Vector3[3];
1923
+ Vector3.TransformNormalToRef(forward, transform, worldForward);
1924
+ Vector3.NormalizeToRef(worldForward, refRay.direction);
1925
+ return refRay;
1926
+ }
1927
+ /**
1928
+ * Initialize the minimal interdependecies between the Ray and Scene and Camera
1929
+ * @param sceneClass defines the scene prototype to use
1930
+ * @param cameraClass defines the camera prototype to use
1931
+ */
1932
+ function AddRayExtensions(sceneClass, cameraClass) {
1933
+ if (cameraClass) {
1934
+ cameraClass.prototype.getForwardRay = function (length = 100, transform, origin) {
1935
+ return GetForwardRayToRef(this, new Ray(Vector3.Zero(), Vector3.Zero(), length), length, transform, origin);
1936
+ };
1937
+ cameraClass.prototype.getForwardRayToRef = function (refRay, length = 100, transform, origin) {
1938
+ return GetForwardRayToRef(this, refRay, length, transform, origin);
1939
+ };
1940
+ }
1941
+ if (!sceneClass) {
1942
+ return;
1943
+ }
1944
+ _ImportHelper._IsPickingAvailable = true;
1945
+ sceneClass.prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace = false) {
1946
+ return CreatePickingRay(this, x, y, world, camera, cameraViewSpace);
1947
+ };
1948
+ }
1949
+
1950
+ // Picking
1951
+ AddRayExtensions(Scene, Camera);
1952
+ Scene.prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace = false, enableDistantPicking = false) {
1953
+ return CreatePickingRayToRef(this, x, y, world, result, camera, cameraViewSpace, enableDistantPicking);
1954
+ };
1955
+ Scene.prototype.createPickingRayInCameraSpace = function (x, y, camera) {
1956
+ return CreatePickingRayInCameraSpace(this, x, y, camera);
1957
+ };
1958
+ Scene.prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
1959
+ return CreatePickingRayInCameraSpaceToRef(this, x, y, result, camera);
1960
+ };
1961
+ Scene.prototype.pickWithBoundingInfo = function (x, y, predicate, fastCheck, camera) {
1962
+ return PickWithBoundingInfo(this, x, y, predicate, fastCheck, camera);
1963
+ };
1964
+ Scene.prototype.pick = function (x, y, predicate, fastCheck, camera, trianglePredicate, _enableDistantPicking = false) {
1965
+ return Pick(this, x, y, predicate, fastCheck, camera, trianglePredicate, _enableDistantPicking);
1966
+ };
1967
+ Scene.prototype.pickWithRay = function (ray, predicate, fastCheck, trianglePredicate) {
1968
+ return PickWithRay(this, ray, predicate, fastCheck, trianglePredicate);
1969
+ };
1970
+ Scene.prototype.multiPick = function (x, y, predicate, camera, trianglePredicate) {
1971
+ return MultiPick(this, x, y, predicate, camera, trianglePredicate);
1972
+ };
1973
+ Scene.prototype.multiPickWithRay = function (ray, predicate, trianglePredicate) {
1974
+ return MultiPickWithRay(this, ray, predicate, trianglePredicate);
1975
+ };
1976
+
1977
+ /** Defines the 4 color options */
1978
+ var PointColor;
1979
+ (function (PointColor) {
1980
+ /** color value */
1981
+ PointColor[PointColor["Color"] = 2] = "Color";
1982
+ /** uv value */
1983
+ PointColor[PointColor["UV"] = 1] = "UV";
1984
+ /** random value */
1985
+ PointColor[PointColor["Random"] = 0] = "Random";
1986
+ /** stated value */
1987
+ PointColor[PointColor["Stated"] = 3] = "Stated";
1988
+ })(PointColor || (PointColor = {}));
1989
+ /**
1990
+ * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
1991
+ * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
1992
+
1993
+ * The PointCloudSystem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
1994
+ * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
1995
+ *
1996
+ * Full documentation here : TO BE ENTERED
1997
+ */
1998
+ class PointsCloudSystem {
1999
+ /**
2000
+ * Gets the particle positions computed by the Point Cloud System
2001
+ */
2002
+ get positions() {
2003
+ return this._positions32;
2004
+ }
2005
+ /**
2006
+ * Gets the particle colors computed by the Point Cloud System
2007
+ */
2008
+ get colors() {
2009
+ return this._colors32;
2010
+ }
2011
+ /**
2012
+ * Gets the particle uvs computed by the Point Cloud System
2013
+ */
2014
+ get uvs() {
2015
+ return this._uvs32;
2016
+ }
2017
+ /**
2018
+ * Creates a PCS (Points Cloud System) object
2019
+ * @param name (String) is the PCS name, this will be the underlying mesh name
2020
+ * @param pointSize (number) is the size for each point. Has no effect on a WebGPU engine.
2021
+ * @param scene (Scene) is the scene in which the PCS is added
2022
+ * @param options defines the options of the PCS e.g.
2023
+ * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
2024
+ */
2025
+ constructor(name, pointSize, scene, options) {
2026
+ /**
2027
+ * The PCS array of cloud point objects. Just access each particle as with any classic array.
2028
+ * Example : var p = SPS.particles[i];
2029
+ */
2030
+ this.particles = new Array();
2031
+ /**
2032
+ * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
2033
+ */
2034
+ this.nbParticles = 0;
2035
+ /**
2036
+ * This a counter for your own usage. It's not set by any SPS functions.
2037
+ */
2038
+ this.counter = 0;
2039
+ /**
2040
+ * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
2041
+ * Please read :
2042
+ */
2043
+ this.vars = {};
2044
+ this._promises = [];
2045
+ this._positions = new Array();
2046
+ this._indices = new Array();
2047
+ this._normals = new Array();
2048
+ this._colors = new Array();
2049
+ this._uvs = new Array();
2050
+ this._updatable = true;
2051
+ this._isVisibilityBoxLocked = false;
2052
+ this._alwaysVisible = false;
2053
+ this._groups = new Array(); //start indices for each group of particles
2054
+ this._groupCounter = 0;
2055
+ this._computeParticleColor = true;
2056
+ this._computeParticleTexture = true;
2057
+ this._computeParticleRotation = true;
2058
+ this._computeBoundingBox = false;
2059
+ this._isReady = false;
2060
+ this.name = name;
2061
+ this._size = pointSize;
2062
+ this._scene = scene || EngineStore.LastCreatedScene;
2063
+ if (options && options.updatable !== undefined) {
2064
+ this._updatable = options.updatable;
2065
+ }
2066
+ else {
2067
+ this._updatable = true;
2068
+ }
2069
+ }
2070
+ /**
2071
+ * Builds the PCS underlying mesh. Returns a standard Mesh.
2072
+ * If no points were added to the PCS, the returned mesh is just a single point.
2073
+ * @param material The material to use to render the mesh. If not provided, will create a default one
2074
+ * @returns a promise for the created mesh
2075
+ */
2076
+ buildMeshAsync(material) {
2077
+ return Promise.all(this._promises).then(() => {
2078
+ this._isReady = true;
2079
+ return this._buildMesh(material);
2080
+ });
2081
+ }
2082
+ /**
2083
+ * @internal
2084
+ */
2085
+ _buildMesh(material) {
2086
+ if (this.nbParticles === 0) {
2087
+ this.addPoints(1);
2088
+ }
2089
+ this._positions32 = new Float32Array(this._positions);
2090
+ this._uvs32 = new Float32Array(this._uvs);
2091
+ this._colors32 = new Float32Array(this._colors);
2092
+ const vertexData = new VertexData();
2093
+ vertexData.set(this._positions32, VertexBuffer.PositionKind);
2094
+ if (this._uvs32.length > 0) {
2095
+ vertexData.set(this._uvs32, VertexBuffer.UVKind);
2096
+ }
2097
+ let ec = 0; //emissive color value 0 for UVs, 1 for color
2098
+ if (this._colors32.length > 0) {
2099
+ ec = 1;
2100
+ vertexData.set(this._colors32, VertexBuffer.ColorKind);
2101
+ }
2102
+ const mesh = new Mesh(this.name, this._scene);
2103
+ vertexData.applyToMesh(mesh, this._updatable);
2104
+ this.mesh = mesh;
2105
+ // free memory
2106
+ this._positions = null;
2107
+ this._uvs = null;
2108
+ this._colors = null;
2109
+ if (!this._updatable) {
2110
+ this.particles.length = 0;
2111
+ }
2112
+ let mat = material;
2113
+ if (!mat) {
2114
+ mat = new StandardMaterial("point cloud material", this._scene);
2115
+ mat.emissiveColor = new Color3(ec, ec, ec);
2116
+ mat.disableLighting = true;
2117
+ mat.pointsCloud = true;
2118
+ mat.pointSize = this._size;
2119
+ }
2120
+ mesh.material = mat;
2121
+ return new Promise((resolve) => resolve(mesh));
2122
+ }
2123
+ // adds a new particle object in the particles array
2124
+ _addParticle(idx, group, groupId, idxInGroup) {
2125
+ const cp = new CloudPoint(idx, group, groupId, idxInGroup, this);
2126
+ this.particles.push(cp);
2127
+ return cp;
2128
+ }
2129
+ _randomUnitVector(particle) {
2130
+ particle.position = new Vector3(Math.random(), Math.random(), Math.random());
2131
+ particle.color = new Color4(1, 1, 1, 1);
2132
+ }
2133
+ _getColorIndicesForCoord(pointsGroup, x, y, width) {
2134
+ const imageData = pointsGroup._groupImageData;
2135
+ const color = y * (width * 4) + x * 4;
2136
+ const colorIndices = [color, color + 1, color + 2, color + 3];
2137
+ const redIndex = colorIndices[0];
2138
+ const greenIndex = colorIndices[1];
2139
+ const blueIndex = colorIndices[2];
2140
+ const alphaIndex = colorIndices[3];
2141
+ const redForCoord = imageData[redIndex];
2142
+ const greenForCoord = imageData[greenIndex];
2143
+ const blueForCoord = imageData[blueIndex];
2144
+ const alphaForCoord = imageData[alphaIndex];
2145
+ return new Color4(redForCoord / 255, greenForCoord / 255, blueForCoord / 255, alphaForCoord);
2146
+ }
2147
+ _setPointsColorOrUV(mesh, pointsGroup, isVolume, colorFromTexture, hasTexture, color, range, uvSetIndex) {
2148
+ uvSetIndex = uvSetIndex ?? 0;
2149
+ if (isVolume) {
2150
+ mesh.updateFacetData();
2151
+ }
2152
+ const boundInfo = mesh.getBoundingInfo();
2153
+ const diameter = 2 * boundInfo.boundingSphere.radius;
2154
+ let meshPos = mesh.getVerticesData(VertexBuffer.PositionKind);
2155
+ const meshInd = mesh.getIndices();
2156
+ const meshUV = mesh.getVerticesData(VertexBuffer.UVKind + (uvSetIndex ? uvSetIndex + 1 : ""));
2157
+ const meshCol = mesh.getVerticesData(VertexBuffer.ColorKind);
2158
+ const place = Vector3.Zero();
2159
+ mesh.computeWorldMatrix();
2160
+ const meshMatrix = mesh.getWorldMatrix();
2161
+ if (!meshMatrix.isIdentity()) {
2162
+ meshPos = meshPos.slice(0);
2163
+ for (let p = 0; p < meshPos.length / 3; p++) {
2164
+ Vector3.TransformCoordinatesFromFloatsToRef(meshPos[3 * p], meshPos[3 * p + 1], meshPos[3 * p + 2], meshMatrix, place);
2165
+ meshPos[3 * p] = place.x;
2166
+ meshPos[3 * p + 1] = place.y;
2167
+ meshPos[3 * p + 2] = place.z;
2168
+ }
2169
+ }
2170
+ let idxPoints = 0;
2171
+ let id0 = 0;
2172
+ let id1 = 0;
2173
+ let id2 = 0;
2174
+ let v0X = 0;
2175
+ let v0Y = 0;
2176
+ let v0Z = 0;
2177
+ let v1X = 0;
2178
+ let v1Y = 0;
2179
+ let v1Z = 0;
2180
+ let v2X = 0;
2181
+ let v2Y = 0;
2182
+ let v2Z = 0;
2183
+ const vertex0 = Vector3.Zero();
2184
+ const vertex1 = Vector3.Zero();
2185
+ const vertex2 = Vector3.Zero();
2186
+ const vec0 = Vector3.Zero();
2187
+ const vec1 = Vector3.Zero();
2188
+ let uv0X = 0;
2189
+ let uv0Y = 0;
2190
+ let uv1X = 0;
2191
+ let uv1Y = 0;
2192
+ let uv2X = 0;
2193
+ let uv2Y = 0;
2194
+ const uv0 = Vector2.Zero();
2195
+ const uv1 = Vector2.Zero();
2196
+ const uv2 = Vector2.Zero();
2197
+ const uvec0 = Vector2.Zero();
2198
+ const uvec1 = Vector2.Zero();
2199
+ let col0X = 0;
2200
+ let col0Y = 0;
2201
+ let col0Z = 0;
2202
+ let col0A = 0;
2203
+ let col1X = 0;
2204
+ let col1Y = 0;
2205
+ let col1Z = 0;
2206
+ let col1A = 0;
2207
+ let col2X = 0;
2208
+ let col2Y = 0;
2209
+ let col2Z = 0;
2210
+ let col2A = 0;
2211
+ const col0 = Vector4.Zero();
2212
+ const col1 = Vector4.Zero();
2213
+ const col2 = Vector4.Zero();
2214
+ const colvec0 = Vector4.Zero();
2215
+ const colvec1 = Vector4.Zero();
2216
+ let lamda = 0;
2217
+ let mu = 0;
2218
+ range = range ? range : 0;
2219
+ let facetPoint;
2220
+ let uvPoint;
2221
+ let colPoint = new Vector4(0, 0, 0, 0);
2222
+ let norm = Vector3.Zero();
2223
+ let tang = Vector3.Zero();
2224
+ let biNorm = Vector3.Zero();
2225
+ let angle = 0;
2226
+ let facetPlaneVec = Vector3.Zero();
2227
+ let gap = 0;
2228
+ let distance = 0;
2229
+ const ray = new Ray(Vector3.Zero(), new Vector3(1, 0, 0));
2230
+ let pickInfo;
2231
+ let direction = Vector3.Zero();
2232
+ for (let index = 0; index < meshInd.length / 3; index++) {
2233
+ id0 = meshInd[3 * index];
2234
+ id1 = meshInd[3 * index + 1];
2235
+ id2 = meshInd[3 * index + 2];
2236
+ v0X = meshPos[3 * id0];
2237
+ v0Y = meshPos[3 * id0 + 1];
2238
+ v0Z = meshPos[3 * id0 + 2];
2239
+ v1X = meshPos[3 * id1];
2240
+ v1Y = meshPos[3 * id1 + 1];
2241
+ v1Z = meshPos[3 * id1 + 2];
2242
+ v2X = meshPos[3 * id2];
2243
+ v2Y = meshPos[3 * id2 + 1];
2244
+ v2Z = meshPos[3 * id2 + 2];
2245
+ vertex0.set(v0X, v0Y, v0Z);
2246
+ vertex1.set(v1X, v1Y, v1Z);
2247
+ vertex2.set(v2X, v2Y, v2Z);
2248
+ vertex1.subtractToRef(vertex0, vec0);
2249
+ vertex2.subtractToRef(vertex1, vec1);
2250
+ if (meshUV) {
2251
+ uv0X = meshUV[2 * id0];
2252
+ uv0Y = meshUV[2 * id0 + 1];
2253
+ uv1X = meshUV[2 * id1];
2254
+ uv1Y = meshUV[2 * id1 + 1];
2255
+ uv2X = meshUV[2 * id2];
2256
+ uv2Y = meshUV[2 * id2 + 1];
2257
+ uv0.set(uv0X, uv0Y);
2258
+ uv1.set(uv1X, uv1Y);
2259
+ uv2.set(uv2X, uv2Y);
2260
+ uv1.subtractToRef(uv0, uvec0);
2261
+ uv2.subtractToRef(uv1, uvec1);
2262
+ }
2263
+ if (meshCol && colorFromTexture) {
2264
+ col0X = meshCol[4 * id0];
2265
+ col0Y = meshCol[4 * id0 + 1];
2266
+ col0Z = meshCol[4 * id0 + 2];
2267
+ col0A = meshCol[4 * id0 + 3];
2268
+ col1X = meshCol[4 * id1];
2269
+ col1Y = meshCol[4 * id1 + 1];
2270
+ col1Z = meshCol[4 * id1 + 2];
2271
+ col1A = meshCol[4 * id1 + 3];
2272
+ col2X = meshCol[4 * id2];
2273
+ col2Y = meshCol[4 * id2 + 1];
2274
+ col2Z = meshCol[4 * id2 + 2];
2275
+ col2A = meshCol[4 * id2 + 3];
2276
+ col0.set(col0X, col0Y, col0Z, col0A);
2277
+ col1.set(col1X, col1Y, col1Z, col1A);
2278
+ col2.set(col2X, col2Y, col2Z, col2A);
2279
+ col1.subtractToRef(col0, colvec0);
2280
+ col2.subtractToRef(col1, colvec1);
2281
+ }
2282
+ let width;
2283
+ let height;
2284
+ let deltaS;
2285
+ let deltaV;
2286
+ let h;
2287
+ let s;
2288
+ let v;
2289
+ let hsvCol;
2290
+ const statedColor = new Color3(0, 0, 0);
2291
+ const colPoint3 = new Color3(0, 0, 0);
2292
+ let pointColors;
2293
+ let particle;
2294
+ for (let i = 0; i < pointsGroup._groupDensity[index]; i++) {
2295
+ idxPoints = this.particles.length;
2296
+ this._addParticle(idxPoints, pointsGroup, this._groupCounter, index + i);
2297
+ particle = this.particles[idxPoints];
2298
+ //form a point inside the facet v0, v1, v2;
2299
+ lamda = Math.sqrt(RandomRange(0, 1));
2300
+ mu = RandomRange(0, 1);
2301
+ facetPoint = vertex0.add(vec0.scale(lamda)).add(vec1.scale(lamda * mu));
2302
+ if (isVolume) {
2303
+ norm = mesh.getFacetNormal(index).normalize().scale(-1);
2304
+ tang = vec0.clone().normalize();
2305
+ biNorm = Vector3.Cross(norm, tang);
2306
+ angle = RandomRange(0, 2 * Math.PI);
2307
+ facetPlaneVec = tang.scale(Math.cos(angle)).add(biNorm.scale(Math.sin(angle)));
2308
+ angle = RandomRange(0.1, Math.PI / 2);
2309
+ direction = facetPlaneVec.scale(Math.cos(angle)).add(norm.scale(Math.sin(angle)));
2310
+ ray.origin = facetPoint.add(direction.scale(0.00001));
2311
+ ray.direction = direction;
2312
+ ray.length = diameter;
2313
+ pickInfo = ray.intersectsMesh(mesh);
2314
+ if (pickInfo.hit) {
2315
+ distance = pickInfo.pickedPoint.subtract(facetPoint).length();
2316
+ gap = RandomRange(0, 1) * distance;
2317
+ facetPoint.addInPlace(direction.scale(gap));
2318
+ }
2319
+ }
2320
+ particle.position = facetPoint.clone();
2321
+ this._positions.push(particle.position.x, particle.position.y, particle.position.z);
2322
+ if (colorFromTexture !== undefined) {
2323
+ if (meshUV) {
2324
+ uvPoint = uv0.add(uvec0.scale(lamda)).add(uvec1.scale(lamda * mu));
2325
+ if (colorFromTexture) {
2326
+ //Set particle color to texture color
2327
+ if (hasTexture && pointsGroup._groupImageData !== null) {
2328
+ width = pointsGroup._groupImgWidth;
2329
+ height = pointsGroup._groupImgHeight;
2330
+ pointColors = this._getColorIndicesForCoord(pointsGroup, Math.round(uvPoint.x * width), Math.round(uvPoint.y * height), width);
2331
+ particle.color = pointColors;
2332
+ this._colors.push(pointColors.r, pointColors.g, pointColors.b, pointColors.a);
2333
+ }
2334
+ else {
2335
+ if (meshCol) {
2336
+ //failure in texture and colors available
2337
+ colPoint = col0.add(colvec0.scale(lamda)).add(colvec1.scale(lamda * mu));
2338
+ particle.color = new Color4(colPoint.x, colPoint.y, colPoint.z, colPoint.w);
2339
+ this._colors.push(colPoint.x, colPoint.y, colPoint.z, colPoint.w);
2340
+ }
2341
+ else {
2342
+ colPoint = col0.set(Math.random(), Math.random(), Math.random(), 1);
2343
+ particle.color = new Color4(colPoint.x, colPoint.y, colPoint.z, colPoint.w);
2344
+ this._colors.push(colPoint.x, colPoint.y, colPoint.z, colPoint.w);
2345
+ }
2346
+ }
2347
+ }
2348
+ else {
2349
+ //Set particle uv based on a mesh uv
2350
+ particle.uv = uvPoint.clone();
2351
+ this._uvs.push(particle.uv.x, particle.uv.y);
2352
+ }
2353
+ }
2354
+ }
2355
+ else {
2356
+ if (color) {
2357
+ statedColor.set(color.r, color.g, color.b);
2358
+ deltaS = RandomRange(-range, range);
2359
+ deltaV = RandomRange(-range, range);
2360
+ hsvCol = statedColor.toHSV();
2361
+ h = hsvCol.r;
2362
+ s = hsvCol.g + deltaS;
2363
+ v = hsvCol.b + deltaV;
2364
+ if (s < 0) {
2365
+ s = 0;
2366
+ }
2367
+ if (s > 1) {
2368
+ s = 1;
2369
+ }
2370
+ if (v < 0) {
2371
+ v = 0;
2372
+ }
2373
+ if (v > 1) {
2374
+ v = 1;
2375
+ }
2376
+ Color3.HSVtoRGBToRef(h, s, v, colPoint3);
2377
+ colPoint.set(colPoint3.r, colPoint3.g, colPoint3.b, 1);
2378
+ }
2379
+ else {
2380
+ colPoint = col0.set(Math.random(), Math.random(), Math.random(), 1);
2381
+ }
2382
+ particle.color = new Color4(colPoint.x, colPoint.y, colPoint.z, colPoint.w);
2383
+ this._colors.push(colPoint.x, colPoint.y, colPoint.z, colPoint.w);
2384
+ }
2385
+ }
2386
+ }
2387
+ }
2388
+ // stores mesh texture in dynamic texture for color pixel retrieval
2389
+ // when pointColor type is color for surface points
2390
+ _colorFromTexture(mesh, pointsGroup, isVolume) {
2391
+ if (mesh.material === null) {
2392
+ Logger.Warn(mesh.name + "has no material.");
2393
+ pointsGroup._groupImageData = null;
2394
+ this._setPointsColorOrUV(mesh, pointsGroup, isVolume, true, false);
2395
+ return;
2396
+ }
2397
+ const mat = mesh.material;
2398
+ const textureList = mat.getActiveTextures();
2399
+ if (textureList.length === 0) {
2400
+ Logger.Warn(mesh.name + "has no usable texture.");
2401
+ pointsGroup._groupImageData = null;
2402
+ this._setPointsColorOrUV(mesh, pointsGroup, isVolume, true, false);
2403
+ return;
2404
+ }
2405
+ const clone = mesh.clone();
2406
+ clone.setEnabled(false);
2407
+ this._promises.push(new Promise((resolve) => {
2408
+ BaseTexture.WhenAllReady(textureList, () => {
2409
+ let n = pointsGroup._textureNb;
2410
+ if (n < 0) {
2411
+ n = 0;
2412
+ }
2413
+ if (n > textureList.length - 1) {
2414
+ n = textureList.length - 1;
2415
+ }
2416
+ const finalize = () => {
2417
+ pointsGroup._groupImgWidth = textureList[n].getSize().width;
2418
+ pointsGroup._groupImgHeight = textureList[n].getSize().height;
2419
+ this._setPointsColorOrUV(clone, pointsGroup, isVolume, true, true, undefined, undefined, textureList[n].coordinatesIndex);
2420
+ clone.dispose();
2421
+ resolve();
2422
+ };
2423
+ pointsGroup._groupImageData = null;
2424
+ const dataPromise = textureList[n].readPixels();
2425
+ if (!dataPromise) {
2426
+ finalize();
2427
+ }
2428
+ else {
2429
+ dataPromise.then((data) => {
2430
+ pointsGroup._groupImageData = data;
2431
+ finalize();
2432
+ });
2433
+ }
2434
+ });
2435
+ }));
2436
+ }
2437
+ // calculates the point density per facet of a mesh for surface points
2438
+ _calculateDensity(nbPoints, positions, indices) {
2439
+ let id0;
2440
+ let id1;
2441
+ let id2;
2442
+ let v0X;
2443
+ let v0Y;
2444
+ let v0Z;
2445
+ let v1X;
2446
+ let v1Y;
2447
+ let v1Z;
2448
+ let v2X;
2449
+ let v2Y;
2450
+ let v2Z;
2451
+ const vertex0 = Vector3.Zero();
2452
+ const vertex1 = Vector3.Zero();
2453
+ const vertex2 = Vector3.Zero();
2454
+ const vec0 = Vector3.Zero();
2455
+ const vec1 = Vector3.Zero();
2456
+ const normal = Vector3.Zero();
2457
+ let area;
2458
+ const cumulativeAreas = [];
2459
+ let surfaceArea = 0;
2460
+ const nbFacets = indices.length / 3;
2461
+ //surface area
2462
+ for (let index = 0; index < nbFacets; index++) {
2463
+ id0 = indices[3 * index];
2464
+ id1 = indices[3 * index + 1];
2465
+ id2 = indices[3 * index + 2];
2466
+ v0X = positions[3 * id0];
2467
+ v0Y = positions[3 * id0 + 1];
2468
+ v0Z = positions[3 * id0 + 2];
2469
+ v1X = positions[3 * id1];
2470
+ v1Y = positions[3 * id1 + 1];
2471
+ v1Z = positions[3 * id1 + 2];
2472
+ v2X = positions[3 * id2];
2473
+ v2Y = positions[3 * id2 + 1];
2474
+ v2Z = positions[3 * id2 + 2];
2475
+ vertex0.set(v0X, v0Y, v0Z);
2476
+ vertex1.set(v1X, v1Y, v1Z);
2477
+ vertex2.set(v2X, v2Y, v2Z);
2478
+ vertex1.subtractToRef(vertex0, vec0);
2479
+ vertex2.subtractToRef(vertex1, vec1);
2480
+ Vector3.CrossToRef(vec0, vec1, normal);
2481
+ area = 0.5 * normal.length();
2482
+ surfaceArea += area;
2483
+ cumulativeAreas[index] = surfaceArea;
2484
+ }
2485
+ const density = new Array(nbFacets);
2486
+ let remainingPoints = nbPoints;
2487
+ for (let index = nbFacets - 1; index > 0; index--) {
2488
+ const cumulativeArea = cumulativeAreas[index];
2489
+ if (cumulativeArea === 0) {
2490
+ // avoiding division by 0 upon degenerate triangles
2491
+ density[index] = 0;
2492
+ }
2493
+ else {
2494
+ const area = cumulativeArea - cumulativeAreas[index - 1];
2495
+ const facetPointsWithFraction = (area / cumulativeArea) * remainingPoints;
2496
+ const floored = Math.floor(facetPointsWithFraction);
2497
+ const fraction = facetPointsWithFraction - floored;
2498
+ const extraPoint = Number(Math.random() < fraction);
2499
+ const facetPoints = floored + extraPoint;
2500
+ density[index] = facetPoints;
2501
+ remainingPoints -= facetPoints;
2502
+ }
2503
+ }
2504
+ density[0] = remainingPoints;
2505
+ return density;
2506
+ }
2507
+ /**
2508
+ * Adds points to the PCS in random positions within a unit sphere
2509
+ * @param nb (positive integer) the number of particles to be created from this model
2510
+ * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
2511
+ * @returns the number of groups in the system
2512
+ */
2513
+ addPoints(nb, pointFunction = this._randomUnitVector) {
2514
+ const pointsGroup = new PointsGroup(this._groupCounter, pointFunction);
2515
+ let cp;
2516
+ // particles
2517
+ let idx = this.nbParticles;
2518
+ for (let i = 0; i < nb; i++) {
2519
+ cp = this._addParticle(idx, pointsGroup, this._groupCounter, i);
2520
+ if (pointsGroup && pointsGroup._positionFunction) {
2521
+ pointsGroup._positionFunction(cp, idx, i);
2522
+ }
2523
+ this._positions.push(cp.position.x, cp.position.y, cp.position.z);
2524
+ if (cp.color) {
2525
+ this._colors.push(cp.color.r, cp.color.g, cp.color.b, cp.color.a);
2526
+ }
2527
+ if (cp.uv) {
2528
+ this._uvs.push(cp.uv.x, cp.uv.y);
2529
+ }
2530
+ idx++;
2531
+ }
2532
+ this.nbParticles += nb;
2533
+ this._groupCounter++;
2534
+ return this._groupCounter;
2535
+ }
2536
+ /**
2537
+ * Adds points to the PCS from the surface of the model shape
2538
+ * @param mesh is any Mesh object that will be used as a surface model for the points
2539
+ * @param nb (positive integer) the number of particles to be created from this model
2540
+ * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
2541
+ * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
2542
+ * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
2543
+ * @returns the number of groups in the system
2544
+ */
2545
+ addSurfacePoints(mesh, nb, colorWith, color, range) {
2546
+ let colored = colorWith ? colorWith : 0 /* PointColor.Random */;
2547
+ if (isNaN(colored) || colored < 0 || colored > 3) {
2548
+ colored = 0 /* PointColor.Random */;
2549
+ }
2550
+ const meshPos = mesh.getVerticesData(VertexBuffer.PositionKind);
2551
+ const meshInd = mesh.getIndices();
2552
+ this._groups.push(this._groupCounter);
2553
+ const pointsGroup = new PointsGroup(this._groupCounter, null);
2554
+ pointsGroup._groupDensity = this._calculateDensity(nb, meshPos, meshInd);
2555
+ if (colored === 2 /* PointColor.Color */) {
2556
+ pointsGroup._textureNb = color ? color : 0;
2557
+ }
2558
+ else {
2559
+ color = color ? color : new Color4(1, 1, 1, 1);
2560
+ }
2561
+ switch (colored) {
2562
+ case 2 /* PointColor.Color */:
2563
+ this._colorFromTexture(mesh, pointsGroup, false);
2564
+ break;
2565
+ case 1 /* PointColor.UV */:
2566
+ this._setPointsColorOrUV(mesh, pointsGroup, false, false, false);
2567
+ break;
2568
+ case 0 /* PointColor.Random */:
2569
+ this._setPointsColorOrUV(mesh, pointsGroup, false);
2570
+ break;
2571
+ case 3 /* PointColor.Stated */:
2572
+ this._setPointsColorOrUV(mesh, pointsGroup, false, undefined, undefined, color, range);
2573
+ break;
2574
+ }
2575
+ this.nbParticles += nb;
2576
+ this._groupCounter++;
2577
+ return this._groupCounter - 1;
2578
+ }
2579
+ /**
2580
+ * Adds points to the PCS inside the model shape
2581
+ * @param mesh is any Mesh object that will be used as a surface model for the points
2582
+ * @param nb (positive integer) the number of particles to be created from this model
2583
+ * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
2584
+ * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
2585
+ * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
2586
+ * @returns the number of groups in the system
2587
+ */
2588
+ addVolumePoints(mesh, nb, colorWith, color, range) {
2589
+ let colored = colorWith ? colorWith : 0 /* PointColor.Random */;
2590
+ if (isNaN(colored) || colored < 0 || colored > 3) {
2591
+ colored = 0 /* PointColor.Random */;
2592
+ }
2593
+ const meshPos = mesh.getVerticesData(VertexBuffer.PositionKind);
2594
+ const meshInd = mesh.getIndices();
2595
+ this._groups.push(this._groupCounter);
2596
+ const pointsGroup = new PointsGroup(this._groupCounter, null);
2597
+ pointsGroup._groupDensity = this._calculateDensity(nb, meshPos, meshInd);
2598
+ if (colored === 2 /* PointColor.Color */) {
2599
+ pointsGroup._textureNb = color ? color : 0;
2600
+ }
2601
+ else {
2602
+ color = color ? color : new Color4(1, 1, 1, 1);
2603
+ }
2604
+ switch (colored) {
2605
+ case 2 /* PointColor.Color */:
2606
+ this._colorFromTexture(mesh, pointsGroup, true);
2607
+ break;
2608
+ case 1 /* PointColor.UV */:
2609
+ this._setPointsColorOrUV(mesh, pointsGroup, true, false, false);
2610
+ break;
2611
+ case 0 /* PointColor.Random */:
2612
+ this._setPointsColorOrUV(mesh, pointsGroup, true);
2613
+ break;
2614
+ case 3 /* PointColor.Stated */:
2615
+ this._setPointsColorOrUV(mesh, pointsGroup, true, undefined, undefined, color, range);
2616
+ break;
2617
+ }
2618
+ this.nbParticles += nb;
2619
+ this._groupCounter++;
2620
+ return this._groupCounter - 1;
2621
+ }
2622
+ /**
2623
+ * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
2624
+ * This method calls `updateParticle()` for each particle of the SPS.
2625
+ * For an animated SPS, it is usually called within the render loop.
2626
+ * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
2627
+ * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
2628
+ * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
2629
+ * @returns the PCS.
2630
+ */
2631
+ setParticles(start = 0, end = this.nbParticles - 1, update = true) {
2632
+ if (!this._updatable || !this._isReady) {
2633
+ return this;
2634
+ }
2635
+ // custom beforeUpdate
2636
+ this.beforeUpdateParticles(start, end, update);
2637
+ const rotMatrix = TmpVectors.Matrix[0];
2638
+ const mesh = this.mesh;
2639
+ const colors32 = this._colors32;
2640
+ const positions32 = this._positions32;
2641
+ const uvs32 = this._uvs32;
2642
+ const tempVectors = TmpVectors.Vector3;
2643
+ const camAxisX = tempVectors[5].copyFromFloats(1.0, 0.0, 0.0);
2644
+ const camAxisY = tempVectors[6].copyFromFloats(0.0, 1.0, 0.0);
2645
+ const camAxisZ = tempVectors[7].copyFromFloats(0.0, 0.0, 1.0);
2646
+ const minimum = tempVectors[8].setAll(Number.MAX_VALUE);
2647
+ const maximum = tempVectors[9].setAll(-Number.MAX_VALUE);
2648
+ Matrix.IdentityToRef(rotMatrix);
2649
+ let idx = 0; // current index of the particle
2650
+ if (this.mesh?.isFacetDataEnabled) {
2651
+ this._computeBoundingBox = true;
2652
+ }
2653
+ end = end >= this.nbParticles ? this.nbParticles - 1 : end;
2654
+ if (this._computeBoundingBox) {
2655
+ if (start != 0 || end != this.nbParticles - 1) {
2656
+ // only some particles are updated, then use the current existing BBox basis. Note : it can only increase.
2657
+ const boundingInfo = this.mesh?.getBoundingInfo();
2658
+ if (boundingInfo) {
2659
+ minimum.copyFrom(boundingInfo.minimum);
2660
+ maximum.copyFrom(boundingInfo.maximum);
2661
+ }
2662
+ }
2663
+ }
2664
+ idx = 0; // particle index
2665
+ let pindex = 0; //index in positions array
2666
+ let cindex = 0; //index in color array
2667
+ let uindex = 0; //index in uv array
2668
+ // particle loop
2669
+ for (let p = start; p <= end; p++) {
2670
+ const particle = this.particles[p];
2671
+ idx = particle.idx;
2672
+ pindex = 3 * idx;
2673
+ cindex = 4 * idx;
2674
+ uindex = 2 * idx;
2675
+ // call to custom user function to update the particle properties
2676
+ this.updateParticle(particle);
2677
+ const particleRotationMatrix = particle._rotationMatrix;
2678
+ const particlePosition = particle.position;
2679
+ const particleGlobalPosition = particle._globalPosition;
2680
+ if (this._computeParticleRotation) {
2681
+ particle.getRotationMatrix(rotMatrix);
2682
+ }
2683
+ const particleHasParent = particle.parentId !== null;
2684
+ if (particleHasParent) {
2685
+ const parent = this.particles[particle.parentId];
2686
+ const parentRotationMatrix = parent._rotationMatrix;
2687
+ const parentGlobalPosition = parent._globalPosition;
2688
+ const rotatedY = particlePosition.x * parentRotationMatrix[1] + particlePosition.y * parentRotationMatrix[4] + particlePosition.z * parentRotationMatrix[7];
2689
+ const rotatedX = particlePosition.x * parentRotationMatrix[0] + particlePosition.y * parentRotationMatrix[3] + particlePosition.z * parentRotationMatrix[6];
2690
+ const rotatedZ = particlePosition.x * parentRotationMatrix[2] + particlePosition.y * parentRotationMatrix[5] + particlePosition.z * parentRotationMatrix[8];
2691
+ particleGlobalPosition.x = parentGlobalPosition.x + rotatedX;
2692
+ particleGlobalPosition.y = parentGlobalPosition.y + rotatedY;
2693
+ particleGlobalPosition.z = parentGlobalPosition.z + rotatedZ;
2694
+ if (this._computeParticleRotation) {
2695
+ const rotMatrixValues = rotMatrix.m;
2696
+ particleRotationMatrix[0] =
2697
+ rotMatrixValues[0] * parentRotationMatrix[0] + rotMatrixValues[1] * parentRotationMatrix[3] + rotMatrixValues[2] * parentRotationMatrix[6];
2698
+ particleRotationMatrix[1] =
2699
+ rotMatrixValues[0] * parentRotationMatrix[1] + rotMatrixValues[1] * parentRotationMatrix[4] + rotMatrixValues[2] * parentRotationMatrix[7];
2700
+ particleRotationMatrix[2] =
2701
+ rotMatrixValues[0] * parentRotationMatrix[2] + rotMatrixValues[1] * parentRotationMatrix[5] + rotMatrixValues[2] * parentRotationMatrix[8];
2702
+ particleRotationMatrix[3] =
2703
+ rotMatrixValues[4] * parentRotationMatrix[0] + rotMatrixValues[5] * parentRotationMatrix[3] + rotMatrixValues[6] * parentRotationMatrix[6];
2704
+ particleRotationMatrix[4] =
2705
+ rotMatrixValues[4] * parentRotationMatrix[1] + rotMatrixValues[5] * parentRotationMatrix[4] + rotMatrixValues[6] * parentRotationMatrix[7];
2706
+ particleRotationMatrix[5] =
2707
+ rotMatrixValues[4] * parentRotationMatrix[2] + rotMatrixValues[5] * parentRotationMatrix[5] + rotMatrixValues[6] * parentRotationMatrix[8];
2708
+ particleRotationMatrix[6] =
2709
+ rotMatrixValues[8] * parentRotationMatrix[0] + rotMatrixValues[9] * parentRotationMatrix[3] + rotMatrixValues[10] * parentRotationMatrix[6];
2710
+ particleRotationMatrix[7] =
2711
+ rotMatrixValues[8] * parentRotationMatrix[1] + rotMatrixValues[9] * parentRotationMatrix[4] + rotMatrixValues[10] * parentRotationMatrix[7];
2712
+ particleRotationMatrix[8] =
2713
+ rotMatrixValues[8] * parentRotationMatrix[2] + rotMatrixValues[9] * parentRotationMatrix[5] + rotMatrixValues[10] * parentRotationMatrix[8];
2714
+ }
2715
+ }
2716
+ else {
2717
+ particleGlobalPosition.x = 0;
2718
+ particleGlobalPosition.y = 0;
2719
+ particleGlobalPosition.z = 0;
2720
+ if (this._computeParticleRotation) {
2721
+ const rotMatrixValues = rotMatrix.m;
2722
+ particleRotationMatrix[0] = rotMatrixValues[0];
2723
+ particleRotationMatrix[1] = rotMatrixValues[1];
2724
+ particleRotationMatrix[2] = rotMatrixValues[2];
2725
+ particleRotationMatrix[3] = rotMatrixValues[4];
2726
+ particleRotationMatrix[4] = rotMatrixValues[5];
2727
+ particleRotationMatrix[5] = rotMatrixValues[6];
2728
+ particleRotationMatrix[6] = rotMatrixValues[8];
2729
+ particleRotationMatrix[7] = rotMatrixValues[9];
2730
+ particleRotationMatrix[8] = rotMatrixValues[10];
2731
+ }
2732
+ }
2733
+ const pivotBackTranslation = tempVectors[11];
2734
+ if (particle.translateFromPivot) {
2735
+ pivotBackTranslation.setAll(0.0);
2736
+ }
2737
+ else {
2738
+ pivotBackTranslation.copyFrom(particle.pivot);
2739
+ }
2740
+ // positions
2741
+ const tmpVertex = tempVectors[0];
2742
+ tmpVertex.copyFrom(particle.position);
2743
+ const vertexX = tmpVertex.x - particle.pivot.x;
2744
+ const vertexY = tmpVertex.y - particle.pivot.y;
2745
+ const vertexZ = tmpVertex.z - particle.pivot.z;
2746
+ let rotatedX = vertexX * particleRotationMatrix[0] + vertexY * particleRotationMatrix[3] + vertexZ * particleRotationMatrix[6];
2747
+ let rotatedY = vertexX * particleRotationMatrix[1] + vertexY * particleRotationMatrix[4] + vertexZ * particleRotationMatrix[7];
2748
+ let rotatedZ = vertexX * particleRotationMatrix[2] + vertexY * particleRotationMatrix[5] + vertexZ * particleRotationMatrix[8];
2749
+ rotatedX += pivotBackTranslation.x;
2750
+ rotatedY += pivotBackTranslation.y;
2751
+ rotatedZ += pivotBackTranslation.z;
2752
+ const px = (positions32[pindex] = particleGlobalPosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ);
2753
+ const py = (positions32[pindex + 1] = particleGlobalPosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ);
2754
+ const pz = (positions32[pindex + 2] = particleGlobalPosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ);
2755
+ if (this._computeBoundingBox) {
2756
+ minimum.minimizeInPlaceFromFloats(px, py, pz);
2757
+ maximum.maximizeInPlaceFromFloats(px, py, pz);
2758
+ }
2759
+ if (this._computeParticleColor && particle.color) {
2760
+ const color = particle.color;
2761
+ const colors32 = this._colors32;
2762
+ colors32[cindex] = color.r;
2763
+ colors32[cindex + 1] = color.g;
2764
+ colors32[cindex + 2] = color.b;
2765
+ colors32[cindex + 3] = color.a;
2766
+ }
2767
+ if (this._computeParticleTexture && particle.uv) {
2768
+ const uv = particle.uv;
2769
+ const uvs32 = this._uvs32;
2770
+ uvs32[uindex] = uv.x;
2771
+ uvs32[uindex + 1] = uv.y;
2772
+ }
2773
+ }
2774
+ // if the VBO must be updated
2775
+ if (mesh) {
2776
+ if (update) {
2777
+ if (this._computeParticleColor) {
2778
+ mesh.updateVerticesData(VertexBuffer.ColorKind, colors32, false, false);
2779
+ }
2780
+ if (this._computeParticleTexture) {
2781
+ mesh.updateVerticesData(VertexBuffer.UVKind, uvs32, false, false);
2782
+ }
2783
+ mesh.updateVerticesData(VertexBuffer.PositionKind, positions32, false, false);
2784
+ }
2785
+ if (this._computeBoundingBox) {
2786
+ if (mesh.hasBoundingInfo) {
2787
+ mesh.getBoundingInfo().reConstruct(minimum, maximum, mesh._worldMatrix);
2788
+ }
2789
+ else {
2790
+ mesh.buildBoundingInfo(minimum, maximum, mesh._worldMatrix);
2791
+ }
2792
+ }
2793
+ }
2794
+ this.afterUpdateParticles(start, end, update);
2795
+ return this;
2796
+ }
2797
+ /**
2798
+ * Disposes the PCS.
2799
+ */
2800
+ dispose() {
2801
+ this.mesh?.dispose();
2802
+ this.vars = null;
2803
+ // drop references to internal big arrays for the GC
2804
+ this._positions = null;
2805
+ this._indices = null;
2806
+ this._normals = null;
2807
+ this._uvs = null;
2808
+ this._colors = null;
2809
+ this._indices32 = null;
2810
+ this._positions32 = null;
2811
+ this._uvs32 = null;
2812
+ this._colors32 = null;
2813
+ }
2814
+ /**
2815
+ * Visibility helper : Recomputes the visible size according to the mesh bounding box
2816
+ * doc :
2817
+ * @returns the PCS.
2818
+ */
2819
+ refreshVisibleSize() {
2820
+ if (!this._isVisibilityBoxLocked) {
2821
+ this.mesh?.refreshBoundingInfo();
2822
+ }
2823
+ return this;
2824
+ }
2825
+ /**
2826
+ * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
2827
+ * @param size the size (float) of the visibility box
2828
+ * note : this doesn't lock the PCS mesh bounding box.
2829
+ * doc :
2830
+ */
2831
+ setVisibilityBox(size) {
2832
+ if (!this.mesh) {
2833
+ return;
2834
+ }
2835
+ const vis = size / 2;
2836
+ this.mesh.buildBoundingInfo(new Vector3(-vis, -vis, -vis), new Vector3(vis, vis, vis));
2837
+ }
2838
+ /**
2839
+ * Gets whether the PCS is always visible or not
2840
+ * doc :
2841
+ */
2842
+ get isAlwaysVisible() {
2843
+ return this._alwaysVisible;
2844
+ }
2845
+ /**
2846
+ * Sets the PCS as always visible or not
2847
+ * doc :
2848
+ */
2849
+ set isAlwaysVisible(val) {
2850
+ if (!this.mesh) {
2851
+ return;
2852
+ }
2853
+ this._alwaysVisible = val;
2854
+ this.mesh.alwaysSelectAsActiveMesh = val;
2855
+ }
2856
+ /**
2857
+ * Tells to `setParticles()` to compute the particle rotations or not
2858
+ * Default value : false. The PCS is faster when it's set to false
2859
+ * Note : particle rotations are only applied to parent particles
2860
+ * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
2861
+ */
2862
+ set computeParticleRotation(val) {
2863
+ this._computeParticleRotation = val;
2864
+ }
2865
+ /**
2866
+ * Tells to `setParticles()` to compute the particle colors or not.
2867
+ * Default value : true. The PCS is faster when it's set to false.
2868
+ * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
2869
+ */
2870
+ set computeParticleColor(val) {
2871
+ this._computeParticleColor = val;
2872
+ }
2873
+ set computeParticleTexture(val) {
2874
+ this._computeParticleTexture = val;
2875
+ }
2876
+ /**
2877
+ * Gets if `setParticles()` computes the particle colors or not.
2878
+ * Default value : false. The PCS is faster when it's set to false.
2879
+ * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
2880
+ */
2881
+ get computeParticleColor() {
2882
+ return this._computeParticleColor;
2883
+ }
2884
+ /**
2885
+ * Gets if `setParticles()` computes the particle textures or not.
2886
+ * Default value : false. The PCS is faster when it's set to false.
2887
+ * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
2888
+ */
2889
+ get computeParticleTexture() {
2890
+ return this._computeParticleTexture;
2891
+ }
2892
+ /**
2893
+ * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
2894
+ */
2895
+ set computeBoundingBox(val) {
2896
+ this._computeBoundingBox = val;
2897
+ }
2898
+ /**
2899
+ * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
2900
+ */
2901
+ get computeBoundingBox() {
2902
+ return this._computeBoundingBox;
2903
+ }
2904
+ // =======================================================================
2905
+ // Particle behavior logic
2906
+ // these following methods may be overwritten by users to fit their needs
2907
+ /**
2908
+ * This function does nothing. It may be overwritten to set all the particle first values.
2909
+ * The PCS doesn't call this function, you may have to call it by your own.
2910
+ * doc :
2911
+ */
2912
+ initParticles() { }
2913
+ /**
2914
+ * This function does nothing. It may be overwritten to recycle a particle
2915
+ * The PCS doesn't call this function, you can to call it
2916
+ * doc :
2917
+ * @param particle The particle to recycle
2918
+ * @returns the recycled particle
2919
+ */
2920
+ recycleParticle(particle) {
2921
+ return particle;
2922
+ }
2923
+ /**
2924
+ * Updates a particle : this function should be overwritten by the user.
2925
+ * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
2926
+ * doc :
2927
+ * @example : just set a particle position or velocity and recycle conditions
2928
+ * @param particle The particle to update
2929
+ * @returns the updated particle
2930
+ */
2931
+ updateParticle(particle) {
2932
+ return particle;
2933
+ }
2934
+ /**
2935
+ * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
2936
+ * This does nothing and may be overwritten by the user.
2937
+ * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
2938
+ * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
2939
+ * @param update the boolean update value actually passed to setParticles()
2940
+ */
2941
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2942
+ beforeUpdateParticles(start, stop, update) { }
2943
+ /**
2944
+ * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
2945
+ * This will be passed three parameters.
2946
+ * This does nothing and may be overwritten by the user.
2947
+ * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
2948
+ * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
2949
+ * @param update the boolean update value actually passed to setParticles()
2950
+ */
2951
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2952
+ afterUpdateParticles(start, stop, update) { }
2953
+ }
2954
+
2955
+ const HCF = HighestCommonFactor;
2956
+ /**
2957
+ * Scalar computation library
2958
+ * @deprecated Please use the scalar functions
2959
+ */
2960
+ /* eslint-disable @typescript-eslint/naming-convention */
2961
+ const Scalar = {
2962
+ ...functions,
2963
+ /**
2964
+ * Two pi constants convenient for computation.
2965
+ */
2966
+ TwoPi: Math.PI * 2,
2967
+ /**
2968
+ * Returns -1 if value is negative and +1 is value is positive.
2969
+ * @param value the value
2970
+ * @returns the value itself if it's equal to zero.
2971
+ */
2972
+ Sign: Math.sign,
2973
+ /**
2974
+ * the log2 of value.
2975
+ * @param value the value to compute log2 of
2976
+ * @returns the log2 of value.
2977
+ */
2978
+ Log2: Math.log2,
2979
+ /**
2980
+ * Returns the highest common factor of two integers.
2981
+ * @param a first parameter
2982
+ * @param b second parameter
2983
+ * @returns HCF of a and b
2984
+ */
2985
+ HCF,
2986
+ };
2987
+ /* eslint-enable @typescript-eslint/naming-convention */
2988
+
2989
+ /**
2990
+ * Indicator of the parsed ply buffer. A standard ready to use splat or an array of positions for a point cloud
2991
+ */
2992
+ var Mode;
2993
+ (function (Mode) {
2994
+ Mode[Mode["Splat"] = 0] = "Splat";
2995
+ Mode[Mode["PointCloud"] = 1] = "PointCloud";
2996
+ Mode[Mode["Mesh"] = 2] = "Mesh";
2997
+ })(Mode || (Mode = {}));
2998
+ /** @internal */
2999
+ var ElementMode;
3000
+ (function (ElementMode) {
3001
+ ElementMode[ElementMode["Vertex"] = 0] = "Vertex";
3002
+ ElementMode[ElementMode["Chunk"] = 1] = "Chunk";
3003
+ })(ElementMode || (ElementMode = {}));
3004
+ /**
3005
+ * @experimental
3006
+ * SPLAT file type loader.
3007
+ * This is a babylon scene loader plugin.
3008
+ */
3009
+ class SPLATFileLoader {
3010
+ /**
3011
+ * Creates loader for gaussian splatting files
3012
+ * @param loadingOptions options for loading and parsing splat and PLY files.
3013
+ */
3014
+ constructor(loadingOptions = SPLATFileLoader._DefaultLoadingOptions) {
3015
+ /**
3016
+ * Defines the name of the plugin.
3017
+ */
3018
+ this.name = SPLATFileLoaderMetadata.name;
3019
+ this._assetContainer = null;
3020
+ /**
3021
+ * Defines the extensions the splat loader is able to load.
3022
+ * force data to come in as an ArrayBuffer
3023
+ */
3024
+ this.extensions = SPLATFileLoaderMetadata.extensions;
3025
+ this._loadingOptions = loadingOptions;
3026
+ }
3027
+ /** @internal */
3028
+ createPlugin(options) {
3029
+ return new SPLATFileLoader(options[SPLATFileLoaderMetadata.name]);
3030
+ }
3031
+ /**
3032
+ * Imports from the loaded gaussian splatting data and adds them to the scene
3033
+ * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
3034
+ * @param scene the scene the meshes should be added to
3035
+ * @param data the gaussian splatting data to load
3036
+ * @param rootUrl root url to load from
3037
+ * @param onProgress callback called while file is loading
3038
+ * @param fileName Defines the name of the file to load
3039
+ * @returns a promise containing the loaded meshes, particles, skeletons and animations
3040
+ */
3041
+ async importMeshAsync(meshesNames, scene, data, rootUrl, onProgress, fileName) {
3042
+ return this._parse(meshesNames, scene, data, rootUrl).then((meshes) => {
3043
+ return {
3044
+ meshes: meshes,
3045
+ particleSystems: [],
3046
+ skeletons: [],
3047
+ animationGroups: [],
3048
+ transformNodes: [],
3049
+ geometries: [],
3050
+ lights: [],
3051
+ spriteManagers: [],
3052
+ };
3053
+ });
3054
+ }
3055
+ static _BuildPointCloud(pointcloud, data) {
3056
+ if (!data.byteLength) {
3057
+ return false;
3058
+ }
3059
+ const uBuffer = new Uint8Array(data);
3060
+ const fBuffer = new Float32Array(data);
3061
+ // parsed array contains room for position(3floats), normal(3floats), color (4b), quantized quaternion (4b)
3062
+ const rowLength = 3 * 4 + 3 * 4 + 4 + 4;
3063
+ const vertexCount = uBuffer.length / rowLength;
3064
+ const pointcloudfunc = function (particle, i) {
3065
+ const x = fBuffer[8 * i + 0];
3066
+ const y = fBuffer[8 * i + 1];
3067
+ const z = fBuffer[8 * i + 2];
3068
+ particle.position = new Vector3(x, y, z);
3069
+ const r = uBuffer[rowLength * i + 24 + 0] / 255;
3070
+ const g = uBuffer[rowLength * i + 24 + 1] / 255;
3071
+ const b = uBuffer[rowLength * i + 24 + 2] / 255;
3072
+ particle.color = new Color4(r, g, b, 1);
3073
+ };
3074
+ pointcloud.addPoints(vertexCount, pointcloudfunc);
3075
+ return true;
3076
+ }
3077
+ static _BuildMesh(scene, parsedPLY) {
3078
+ const mesh = new Mesh("PLYMesh", scene);
3079
+ const uBuffer = new Uint8Array(parsedPLY.data);
3080
+ const fBuffer = new Float32Array(parsedPLY.data);
3081
+ const rowLength = 3 * 4 + 3 * 4 + 4 + 4;
3082
+ const vertexCount = uBuffer.length / rowLength;
3083
+ const positions = [];
3084
+ const vertexData = new VertexData();
3085
+ for (let i = 0; i < vertexCount; i++) {
3086
+ const x = fBuffer[8 * i + 0];
3087
+ const y = fBuffer[8 * i + 1];
3088
+ const z = fBuffer[8 * i + 2];
3089
+ positions.push(x, y, z);
3090
+ }
3091
+ if (parsedPLY.hasVertexColors) {
3092
+ const colors = new Float32Array(vertexCount * 4);
3093
+ for (let i = 0; i < vertexCount; i++) {
3094
+ const r = uBuffer[rowLength * i + 24 + 0] / 255;
3095
+ const g = uBuffer[rowLength * i + 24 + 1] / 255;
3096
+ const b = uBuffer[rowLength * i + 24 + 2] / 255;
3097
+ colors[i * 4 + 0] = r;
3098
+ colors[i * 4 + 1] = g;
3099
+ colors[i * 4 + 2] = b;
3100
+ colors[i * 4 + 3] = 1;
3101
+ }
3102
+ vertexData.colors = colors;
3103
+ }
3104
+ vertexData.positions = positions;
3105
+ vertexData.indices = parsedPLY.faces;
3106
+ vertexData.applyToMesh(mesh);
3107
+ return mesh;
3108
+ }
3109
+ _parse(meshesNames, scene, data, rootUrl) {
3110
+ const babylonMeshesArray = []; //The mesh for babylon
3111
+ const parsedPLY = SPLATFileLoader._ConvertPLYToSplat(data);
3112
+ switch (parsedPLY.mode) {
3113
+ case 0 /* Mode.Splat */:
3114
+ {
3115
+ const gaussianSplatting = new GaussianSplattingMesh("GaussianSplatting", null, scene, this._loadingOptions.keepInRam);
3116
+ gaussianSplatting._parentContainer = this._assetContainer;
3117
+ babylonMeshesArray.push(gaussianSplatting);
3118
+ gaussianSplatting.loadDataAsync(parsedPLY.data);
3119
+ }
3120
+ break;
3121
+ case 1 /* Mode.PointCloud */:
3122
+ {
3123
+ const pointcloud = new PointsCloudSystem("PointCloud", 1, scene);
3124
+ if (SPLATFileLoader._BuildPointCloud(pointcloud, parsedPLY.data)) {
3125
+ return Promise.all([pointcloud.buildMeshAsync()]).then((mesh) => {
3126
+ babylonMeshesArray.push(mesh[0]);
3127
+ return babylonMeshesArray;
3128
+ });
3129
+ }
3130
+ else {
3131
+ pointcloud.dispose();
3132
+ }
3133
+ }
3134
+ break;
3135
+ case 2 /* Mode.Mesh */:
3136
+ {
3137
+ if (parsedPLY.faces) {
3138
+ babylonMeshesArray.push(SPLATFileLoader._BuildMesh(scene, parsedPLY));
3139
+ }
3140
+ else {
3141
+ throw new Error("PLY mesh doesn't contain face informations.");
3142
+ }
3143
+ }
3144
+ break;
3145
+ default:
3146
+ throw new Error("Unsupported Splat mode");
3147
+ }
3148
+ return Promise.resolve(babylonMeshesArray);
3149
+ }
3150
+ /**
3151
+ * Load into an asset container.
3152
+ * @param scene The scene to load into
3153
+ * @param data The data to import
3154
+ * @param rootUrl The root url for scene and resources
3155
+ * @returns The loaded asset container
3156
+ */
3157
+ loadAssetContainerAsync(scene, data, rootUrl) {
3158
+ const container = new AssetContainer(scene);
3159
+ this._assetContainer = container;
3160
+ return this.importMeshAsync(null, scene, data, rootUrl)
3161
+ .then((result) => {
3162
+ result.meshes.forEach((mesh) => container.meshes.push(mesh));
3163
+ // mesh material will be null before 1st rendered frame.
3164
+ this._assetContainer = null;
3165
+ return container;
3166
+ })
3167
+ .catch((ex) => {
3168
+ this._assetContainer = null;
3169
+ throw ex;
3170
+ });
3171
+ }
3172
+ /**
3173
+ * Imports all objects from the loaded OBJ data and adds them to the scene
3174
+ * @param scene the scene the objects should be added to
3175
+ * @param data the OBJ data to load
3176
+ * @param rootUrl root url to load from
3177
+ * @returns a promise which completes when objects have been loaded to the scene
3178
+ */
3179
+ loadAsync(scene, data, rootUrl) {
3180
+ //Get the 3D model
3181
+ return this.importMeshAsync(null, scene, data, rootUrl).then(() => {
3182
+ // return void
3183
+ });
3184
+ }
3185
+ /**
3186
+ * Code from https://github.com/dylanebert/gsplat.js/blob/main/src/loaders/PLYLoader.ts Under MIT license
3187
+ * Converts a .ply data array buffer to splat
3188
+ * if data array buffer is not ply, returns the original buffer
3189
+ * @param data the .ply data to load
3190
+ * @returns the loaded splat buffer
3191
+ */
3192
+ static _ConvertPLYToSplat(data) {
3193
+ const ubuf = new Uint8Array(data);
3194
+ const header = new TextDecoder().decode(ubuf.slice(0, 1024 * 10));
3195
+ const headerEnd = "end_header\n";
3196
+ const headerEndIndex = header.indexOf(headerEnd);
3197
+ if (headerEndIndex < 0 || !header) {
3198
+ // standard splat
3199
+ return { mode: 0 /* Mode.Splat */, data: data };
3200
+ }
3201
+ const vertexCount = parseInt(/element vertex (\d+)\n/.exec(header)[1]);
3202
+ const faceElement = /element face (\d+)\n/.exec(header);
3203
+ const chunkElement = /element chunk (\d+)\n/.exec(header);
3204
+ let faceCount = 0;
3205
+ let chunkCount = 0;
3206
+ if (faceElement) {
3207
+ faceCount = parseInt(faceElement[1]);
3208
+ }
3209
+ if (chunkElement) {
3210
+ chunkCount = parseInt(chunkElement[1]);
3211
+ }
3212
+ let rowVertexOffset = 0;
3213
+ let rowChunkOffset = 0;
3214
+ const offsets = {
3215
+ double: 8,
3216
+ int: 4,
3217
+ uint: 4,
3218
+ float: 4,
3219
+ short: 2,
3220
+ ushort: 2,
3221
+ uchar: 1,
3222
+ list: 0,
3223
+ };
3224
+ let chunkMode = 1 /* ElementMode.Chunk */;
3225
+ const vertexProperties = [];
3226
+ const chunkProperties = [];
3227
+ const filtered = header.slice(0, headerEndIndex).split("\n");
3228
+ for (const prop of filtered) {
3229
+ if (prop.startsWith("property ")) {
3230
+ const [, type, name] = prop.split(" ");
3231
+ if (chunkMode == 1 /* ElementMode.Chunk */) {
3232
+ chunkProperties.push({ name, type, offset: rowChunkOffset });
3233
+ rowChunkOffset += offsets[type];
3234
+ }
3235
+ else if (chunkMode == 0 /* ElementMode.Vertex */) {
3236
+ vertexProperties.push({ name, type, offset: rowVertexOffset });
3237
+ rowVertexOffset += offsets[type];
3238
+ }
3239
+ if (!offsets[type]) {
3240
+ Logger.Warn(`Unsupported property type: ${type}.`);
3241
+ }
3242
+ }
3243
+ else if (prop.startsWith("element ")) {
3244
+ const [, type] = prop.split(" ");
3245
+ if (type == "chunk") {
3246
+ chunkMode = 1 /* ElementMode.Chunk */;
3247
+ }
3248
+ else if (type == "vertex") {
3249
+ chunkMode = 0 /* ElementMode.Vertex */;
3250
+ }
3251
+ }
3252
+ }
3253
+ const rowVertexLength = rowVertexOffset;
3254
+ const rowChunkLength = rowChunkOffset;
3255
+ const rowOutputLength = 3 * 4 + 3 * 4 + 4 + 4; // Vector3 position, Vector3 scale, 1 u8 quaternion, 1 color with alpha
3256
+ const SH_C0 = 0.28209479177387814;
3257
+ let offset = 0;
3258
+ const dataView = new DataView(data, headerEndIndex + headerEnd.length);
3259
+ const buffer = new ArrayBuffer(rowOutputLength * vertexCount);
3260
+ const q = new Quaternion();
3261
+ const temp3 = TmpVectors.Vector3[0];
3262
+ const unpackUnorm = (value, bits) => {
3263
+ const t = (1 << bits) - 1;
3264
+ return (value & t) / t;
3265
+ };
3266
+ const unpack111011 = (value, result) => {
3267
+ result.x = unpackUnorm(value >>> 21, 11);
3268
+ result.y = unpackUnorm(value >>> 11, 10);
3269
+ result.z = unpackUnorm(value, 11);
3270
+ };
3271
+ const unpack8888 = (value, result) => {
3272
+ result[0] = unpackUnorm(value >>> 24, 8) * 255;
3273
+ result[1] = unpackUnorm(value >>> 16, 8) * 255;
3274
+ result[2] = unpackUnorm(value >>> 8, 8) * 255;
3275
+ result[3] = unpackUnorm(value, 8) * 255;
3276
+ };
3277
+ // unpack quaternion with 2,10,10,10 format (largest element, 3x10bit element)
3278
+ const unpackRot = (value, result) => {
3279
+ const norm = 1.0 / (Math.sqrt(2) * 0.5);
3280
+ const a = (unpackUnorm(value >>> 20, 10) - 0.5) * norm;
3281
+ const b = (unpackUnorm(value >>> 10, 10) - 0.5) * norm;
3282
+ const c = (unpackUnorm(value, 10) - 0.5) * norm;
3283
+ const m = Math.sqrt(1.0 - (a * a + b * b + c * c));
3284
+ switch (value >>> 30) {
3285
+ case 0:
3286
+ result.set(m, a, b, c);
3287
+ break;
3288
+ case 1:
3289
+ result.set(a, m, b, c);
3290
+ break;
3291
+ case 2:
3292
+ result.set(a, b, m, c);
3293
+ break;
3294
+ case 3:
3295
+ result.set(a, b, c, m);
3296
+ break;
3297
+ }
3298
+ };
3299
+ const compressedChunks = new Array(chunkCount);
3300
+ for (let i = 0; i < chunkCount; i++) {
3301
+ const currentChunk = { min: new Vector3(), max: new Vector3(), minScale: new Vector3(), maxScale: new Vector3() };
3302
+ compressedChunks[i] = currentChunk;
3303
+ for (let propertyIndex = 0; propertyIndex < chunkProperties.length; propertyIndex++) {
3304
+ const property = chunkProperties[propertyIndex];
3305
+ let value;
3306
+ switch (property.type) {
3307
+ case "float":
3308
+ value = dataView.getFloat32(property.offset + offset, true);
3309
+ break;
3310
+ default:
3311
+ //throw new Error(`Unsupported property type: ${property.type}`);
3312
+ continue;
3313
+ }
3314
+ switch (property.name) {
3315
+ case "min_x":
3316
+ currentChunk.min.x = value;
3317
+ break;
3318
+ case "min_y":
3319
+ currentChunk.min.y = value;
3320
+ break;
3321
+ case "min_z":
3322
+ currentChunk.min.z = value;
3323
+ break;
3324
+ case "max_x":
3325
+ currentChunk.max.x = value;
3326
+ break;
3327
+ case "max_y":
3328
+ currentChunk.max.y = value;
3329
+ break;
3330
+ case "max_z":
3331
+ currentChunk.max.z = value;
3332
+ break;
3333
+ case "min_scale_x":
3334
+ currentChunk.minScale.x = value;
3335
+ break;
3336
+ case "min_scale_y":
3337
+ currentChunk.minScale.y = value;
3338
+ break;
3339
+ case "min_scale_z":
3340
+ currentChunk.minScale.z = value;
3341
+ break;
3342
+ case "max_scale_x":
3343
+ currentChunk.maxScale.x = value;
3344
+ break;
3345
+ case "max_scale_y":
3346
+ currentChunk.maxScale.y = value;
3347
+ break;
3348
+ case "max_scale_z":
3349
+ currentChunk.maxScale.z = value;
3350
+ break;
3351
+ }
3352
+ }
3353
+ offset += rowChunkLength;
3354
+ }
3355
+ for (let i = 0; i < vertexCount; i++) {
3356
+ const position = new Float32Array(buffer, i * rowOutputLength, 3);
3357
+ const scale = new Float32Array(buffer, i * rowOutputLength + 12, 3);
3358
+ const rgba = new Uint8ClampedArray(buffer, i * rowOutputLength + 24, 4);
3359
+ const rot = new Uint8ClampedArray(buffer, i * rowOutputLength + 28, 4);
3360
+ const chunkIndex = i >> 8;
3361
+ let r0 = 255;
3362
+ let r1 = 0;
3363
+ let r2 = 0;
3364
+ let r3 = 0;
3365
+ for (let propertyIndex = 0; propertyIndex < vertexProperties.length; propertyIndex++) {
3366
+ const property = vertexProperties[propertyIndex];
3367
+ let value;
3368
+ switch (property.type) {
3369
+ case "float":
3370
+ value = dataView.getFloat32(offset + property.offset, true);
3371
+ break;
3372
+ case "int":
3373
+ value = dataView.getInt32(offset + property.offset, true);
3374
+ break;
3375
+ case "uint":
3376
+ value = dataView.getUint32(offset + property.offset, true);
3377
+ break;
3378
+ case "double":
3379
+ value = dataView.getFloat64(offset + property.offset, true);
3380
+ break;
3381
+ case "uchar":
3382
+ value = dataView.getUint8(offset + property.offset);
3383
+ break;
3384
+ default:
3385
+ //throw new Error(`Unsupported property type: ${property.type}`);
3386
+ continue;
3387
+ }
3388
+ switch (property.name) {
3389
+ case "packed_position":
3390
+ {
3391
+ const compressedChunk = compressedChunks[chunkIndex];
3392
+ unpack111011(value, temp3);
3393
+ position[0] = Scalar.Lerp(compressedChunk.min.x, compressedChunk.max.x, temp3.x);
3394
+ position[1] = -Scalar.Lerp(compressedChunk.min.y, compressedChunk.max.y, temp3.y);
3395
+ position[2] = Scalar.Lerp(compressedChunk.min.z, compressedChunk.max.z, temp3.z);
3396
+ }
3397
+ break;
3398
+ case "packed_rotation":
3399
+ {
3400
+ unpackRot(value, q);
3401
+ r0 = q.w;
3402
+ r1 = q.z;
3403
+ r2 = q.y;
3404
+ r3 = q.x;
3405
+ }
3406
+ break;
3407
+ case "packed_scale":
3408
+ {
3409
+ const compressedChunk = compressedChunks[chunkIndex];
3410
+ unpack111011(value, temp3);
3411
+ scale[0] = Math.exp(Scalar.Lerp(compressedChunk.minScale.x, compressedChunk.maxScale.x, temp3.x));
3412
+ scale[1] = Math.exp(Scalar.Lerp(compressedChunk.minScale.y, compressedChunk.maxScale.y, temp3.y));
3413
+ scale[2] = Math.exp(Scalar.Lerp(compressedChunk.minScale.z, compressedChunk.maxScale.z, temp3.z));
3414
+ }
3415
+ break;
3416
+ case "packed_color":
3417
+ unpack8888(value, rgba);
3418
+ break;
3419
+ case "x":
3420
+ position[0] = value;
3421
+ break;
3422
+ case "y":
3423
+ position[1] = value;
3424
+ break;
3425
+ case "z":
3426
+ position[2] = value;
3427
+ break;
3428
+ case "scale_0":
3429
+ scale[0] = Math.exp(value);
3430
+ break;
3431
+ case "scale_1":
3432
+ scale[1] = Math.exp(value);
3433
+ break;
3434
+ case "scale_2":
3435
+ scale[2] = Math.exp(value);
3436
+ break;
3437
+ case "diffuse_red":
3438
+ case "red":
3439
+ rgba[0] = value;
3440
+ break;
3441
+ case "diffuse_green":
3442
+ case "green":
3443
+ rgba[1] = value;
3444
+ break;
3445
+ case "diffuse_blue":
3446
+ case "blue":
3447
+ rgba[2] = value;
3448
+ break;
3449
+ case "f_dc_0":
3450
+ rgba[0] = (0.5 + SH_C0 * value) * 255;
3451
+ break;
3452
+ case "f_dc_1":
3453
+ rgba[1] = (0.5 + SH_C0 * value) * 255;
3454
+ break;
3455
+ case "f_dc_2":
3456
+ rgba[2] = (0.5 + SH_C0 * value) * 255;
3457
+ break;
3458
+ case "f_dc_3":
3459
+ rgba[3] = (0.5 + SH_C0 * value) * 255;
3460
+ break;
3461
+ case "opacity":
3462
+ rgba[3] = (1 / (1 + Math.exp(-value))) * 255;
3463
+ break;
3464
+ case "rot_0":
3465
+ r0 = value;
3466
+ break;
3467
+ case "rot_1":
3468
+ r1 = value;
3469
+ break;
3470
+ case "rot_2":
3471
+ r2 = value;
3472
+ break;
3473
+ case "rot_3":
3474
+ r3 = value;
3475
+ break;
3476
+ }
3477
+ }
3478
+ q.set(r1, r2, r3, r0);
3479
+ q.normalize();
3480
+ rot[0] = q.w * 128 + 128;
3481
+ rot[1] = q.x * 128 + 128;
3482
+ rot[2] = q.y * 128 + 128;
3483
+ rot[3] = q.z * 128 + 128;
3484
+ offset += rowVertexLength;
3485
+ }
3486
+ // faces
3487
+ const faces = [];
3488
+ if (faceCount) {
3489
+ for (let i = 0; i < faceCount; i++) {
3490
+ const faceVertexCount = dataView.getUint8(offset);
3491
+ if (faceVertexCount != 3) {
3492
+ continue; // only support triangles
3493
+ }
3494
+ offset += 1;
3495
+ for (let j = 0; j < faceVertexCount; j++) {
3496
+ const vertexIndex = dataView.getUint32(offset + (2 - j) * 4, true); // change face winding
3497
+ faces.push(vertexIndex);
3498
+ }
3499
+ offset += 12;
3500
+ }
3501
+ }
3502
+ // early exit for chunked/quantized ply
3503
+ if (chunkCount) {
3504
+ return { mode: 0 /* Mode.Splat */, data: buffer, faces: faces, hasVertexColors: false };
3505
+ }
3506
+ // count available properties. if all necessary are present then it's a splat. Otherwise, it's a point cloud
3507
+ // if faces are found, then it's a standard mesh
3508
+ let propertyCount = 0;
3509
+ let propertyColorCount = 0;
3510
+ const splatProperties = ["x", "y", "z", "scale_0", "scale_1", "scale_2", "opacity", "rot_0", "rot_1", "rot_2", "rot_3"];
3511
+ const splatColorProperties = ["red", "green", "blue", "f_dc_0", "f_dc_1", "f_dc_2"];
3512
+ for (let propertyIndex = 0; propertyIndex < vertexProperties.length; propertyIndex++) {
3513
+ const property = vertexProperties[propertyIndex];
3514
+ if (splatProperties.includes(property.name)) {
3515
+ propertyCount++;
3516
+ }
3517
+ if (splatColorProperties.includes(property.name)) {
3518
+ propertyColorCount++;
3519
+ }
3520
+ }
3521
+ const hasMandatoryProperties = propertyCount == splatProperties.length && propertyColorCount == 3;
3522
+ const currentMode = faceCount ? 2 /* Mode.Mesh */ : hasMandatoryProperties ? 0 /* Mode.Splat */ : 1 /* Mode.PointCloud */;
3523
+ // parsed ready ready to be used as a splat
3524
+ return { mode: currentMode, data: buffer, faces: faces, hasVertexColors: !!propertyColorCount };
3525
+ }
3526
+ }
3527
+ SPLATFileLoader._DefaultLoadingOptions = {
3528
+ keepInRam: false,
3529
+ };
3530
+ // Add this loader into the register plugin
3531
+ registerSceneLoaderPlugin(new SPLATFileLoader());
3532
+
3533
+ export { SPLATFileLoader };
3534
+ //# sourceMappingURL=splatFileLoader-D53T0YTp.esm.js.map