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