@babylonjs/viewer 7.37.2-alpha → 7.37.2

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