@babylonjs/viewer 7.41.0-alpha → 7.41.1

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 (619) 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 +28 -19
  158. package/readme.md +28 -28
  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_ies-CFzvmxxg.esm.min.js +0 -2
  198. package/dist/chunks/EXT_lights_ies-CFzvmxxg.esm.min.js.map +0 -1
  199. package/dist/chunks/EXT_lights_ies-cyFdY7yl.esm.js +0 -84
  200. package/dist/chunks/EXT_lights_ies-cyFdY7yl.esm.js.map +0 -1
  201. package/dist/chunks/EXT_lights_image_based-BNmSqx40.esm.min.js +0 -2
  202. package/dist/chunks/EXT_lights_image_based-BNmSqx40.esm.min.js.map +0 -1
  203. package/dist/chunks/EXT_lights_image_based-CC48JVU0.esm.js +0 -171
  204. package/dist/chunks/EXT_lights_image_based-CC48JVU0.esm.js.map +0 -1
  205. package/dist/chunks/EXT_mesh_gpu_instancing-B2qj3kQu.esm.js +0 -86
  206. package/dist/chunks/EXT_mesh_gpu_instancing-B2qj3kQu.esm.js.map +0 -1
  207. package/dist/chunks/EXT_mesh_gpu_instancing-lanrAAoi.esm.min.js +0 -2
  208. package/dist/chunks/EXT_mesh_gpu_instancing-lanrAAoi.esm.min.js.map +0 -1
  209. package/dist/chunks/EXT_meshopt_compression-DjvHx7gJ.esm.js +0 -134
  210. package/dist/chunks/EXT_meshopt_compression-DjvHx7gJ.esm.js.map +0 -1
  211. package/dist/chunks/EXT_meshopt_compression-oH6HzGir.esm.min.js +0 -2
  212. package/dist/chunks/EXT_meshopt_compression-oH6HzGir.esm.min.js.map +0 -1
  213. package/dist/chunks/EXT_texture_avif-BYWETW7-.esm.min.js +0 -2
  214. package/dist/chunks/EXT_texture_avif-BYWETW7-.esm.min.js.map +0 -1
  215. package/dist/chunks/EXT_texture_avif-CKXEq29h.esm.js +0 -44
  216. package/dist/chunks/EXT_texture_avif-CKXEq29h.esm.js.map +0 -1
  217. package/dist/chunks/EXT_texture_webp-Dl4GPoEU.esm.min.js +0 -2
  218. package/dist/chunks/EXT_texture_webp-Dl4GPoEU.esm.min.js.map +0 -1
  219. package/dist/chunks/EXT_texture_webp-fAiSgaNl.esm.js +0 -43
  220. package/dist/chunks/EXT_texture_webp-fAiSgaNl.esm.js.map +0 -1
  221. package/dist/chunks/ExtrasAsMetadata-BUQ3X3M6.esm.js +0 -64
  222. package/dist/chunks/ExtrasAsMetadata-BUQ3X3M6.esm.js.map +0 -1
  223. package/dist/chunks/ExtrasAsMetadata-C_M9nxb4.esm.min.js +0 -2
  224. package/dist/chunks/ExtrasAsMetadata-C_M9nxb4.esm.min.js.map +0 -1
  225. package/dist/chunks/KHR_animation_pointer-BdFZyLUq.esm.js +0 -352
  226. package/dist/chunks/KHR_animation_pointer-BdFZyLUq.esm.js.map +0 -1
  227. package/dist/chunks/KHR_animation_pointer-CBqZcURZ.esm.min.js +0 -2
  228. package/dist/chunks/KHR_animation_pointer-CBqZcURZ.esm.min.js.map +0 -1
  229. package/dist/chunks/KHR_draco_mesh_compression-DU2Rk2nj.esm.min.js +0 -2
  230. package/dist/chunks/KHR_draco_mesh_compression-DU2Rk2nj.esm.min.js.map +0 -1
  231. package/dist/chunks/KHR_draco_mesh_compression-hVF9XuFz.esm.js +0 -610
  232. package/dist/chunks/KHR_draco_mesh_compression-hVF9XuFz.esm.js.map +0 -1
  233. package/dist/chunks/KHR_interactivity-COE1p684.esm.min.js +0 -2
  234. package/dist/chunks/KHR_interactivity-COE1p684.esm.min.js.map +0 -1
  235. package/dist/chunks/KHR_interactivity-Cv1s_pea.esm.js +0 -4033
  236. package/dist/chunks/KHR_interactivity-Cv1s_pea.esm.js.map +0 -1
  237. package/dist/chunks/KHR_lights_punctual-CHf5kbKi.esm.js +0 -581
  238. package/dist/chunks/KHR_lights_punctual-CHf5kbKi.esm.js.map +0 -1
  239. package/dist/chunks/KHR_lights_punctual-DIEAP5SG.esm.min.js +0 -2
  240. package/dist/chunks/KHR_lights_punctual-DIEAP5SG.esm.min.js.map +0 -1
  241. package/dist/chunks/KHR_materials_anisotropy-CU-xxV6y.esm.js +0 -65
  242. package/dist/chunks/KHR_materials_anisotropy-CU-xxV6y.esm.js.map +0 -1
  243. package/dist/chunks/KHR_materials_anisotropy-Cq6CU4qW.esm.min.js +0 -2
  244. package/dist/chunks/KHR_materials_anisotropy-Cq6CU4qW.esm.min.js.map +0 -1
  245. package/dist/chunks/KHR_materials_clearcoat-BSjcmIju.esm.js +0 -96
  246. package/dist/chunks/KHR_materials_clearcoat-BSjcmIju.esm.js.map +0 -1
  247. package/dist/chunks/KHR_materials_clearcoat-CVNNhJRE.esm.min.js +0 -2
  248. package/dist/chunks/KHR_materials_clearcoat-CVNNhJRE.esm.min.js.map +0 -1
  249. package/dist/chunks/KHR_materials_diffuse_transmission-BDuGIkOh.esm.min.js +0 -2
  250. package/dist/chunks/KHR_materials_diffuse_transmission-BDuGIkOh.esm.min.js.map +0 -1
  251. package/dist/chunks/KHR_materials_diffuse_transmission-BZ-9rJUf.esm.js +0 -97
  252. package/dist/chunks/KHR_materials_diffuse_transmission-BZ-9rJUf.esm.js.map +0 -1
  253. package/dist/chunks/KHR_materials_dispersion-BxiGElVU.esm.min.js +0 -2
  254. package/dist/chunks/KHR_materials_dispersion-BxiGElVU.esm.min.js.map +0 -1
  255. package/dist/chunks/KHR_materials_dispersion-UI4zH1V_.esm.js +0 -62
  256. package/dist/chunks/KHR_materials_dispersion-UI4zH1V_.esm.js.map +0 -1
  257. package/dist/chunks/KHR_materials_emissive_strength-BT-Nu60T.esm.js +0 -55
  258. package/dist/chunks/KHR_materials_emissive_strength-BT-Nu60T.esm.js.map +0 -1
  259. package/dist/chunks/KHR_materials_emissive_strength-CwkVNmN7.esm.min.js +0 -2
  260. package/dist/chunks/KHR_materials_emissive_strength-CwkVNmN7.esm.min.js.map +0 -1
  261. package/dist/chunks/KHR_materials_ior-BGUUe5AW.esm.min.js +0 -2
  262. package/dist/chunks/KHR_materials_ior-BGUUe5AW.esm.min.js.map +0 -1
  263. package/dist/chunks/KHR_materials_ior-BbBQF-yw.esm.js +0 -64
  264. package/dist/chunks/KHR_materials_ior-BbBQF-yw.esm.js.map +0 -1
  265. package/dist/chunks/KHR_materials_iridescence-IFN2ewvr.esm.min.js +0 -2
  266. package/dist/chunks/KHR_materials_iridescence-IFN2ewvr.esm.min.js.map +0 -1
  267. package/dist/chunks/KHR_materials_iridescence-nLZDN7sc.esm.js +0 -72
  268. package/dist/chunks/KHR_materials_iridescence-nLZDN7sc.esm.js.map +0 -1
  269. package/dist/chunks/KHR_materials_pbrSpecularGlossiness-CyNVQC-W.esm.js +0 -81
  270. package/dist/chunks/KHR_materials_pbrSpecularGlossiness-CyNVQC-W.esm.js.map +0 -1
  271. package/dist/chunks/KHR_materials_pbrSpecularGlossiness-zxcydJdp.esm.min.js +0 -2
  272. package/dist/chunks/KHR_materials_pbrSpecularGlossiness-zxcydJdp.esm.min.js.map +0 -1
  273. package/dist/chunks/KHR_materials_sheen-BWL9yo8Z.esm.min.js +0 -2
  274. package/dist/chunks/KHR_materials_sheen-BWL9yo8Z.esm.min.js.map +0 -1
  275. package/dist/chunks/KHR_materials_sheen-DSThWwq2.esm.js +0 -85
  276. package/dist/chunks/KHR_materials_sheen-DSThWwq2.esm.js.map +0 -1
  277. package/dist/chunks/KHR_materials_specular-B96NRFEV.esm.js +0 -75
  278. package/dist/chunks/KHR_materials_specular-B96NRFEV.esm.js.map +0 -1
  279. package/dist/chunks/KHR_materials_specular-D2JwOdxw.esm.min.js +0 -2
  280. package/dist/chunks/KHR_materials_specular-D2JwOdxw.esm.min.js.map +0 -1
  281. package/dist/chunks/KHR_materials_transmission-BvqtJXfD.esm.js +0 -307
  282. package/dist/chunks/KHR_materials_transmission-BvqtJXfD.esm.js.map +0 -1
  283. package/dist/chunks/KHR_materials_transmission-ljXN4y_0.esm.min.js +0 -2
  284. package/dist/chunks/KHR_materials_transmission-ljXN4y_0.esm.min.js.map +0 -1
  285. package/dist/chunks/KHR_materials_unlit-CjGTXU3z.esm.min.js +0 -2
  286. package/dist/chunks/KHR_materials_unlit-CjGTXU3z.esm.min.js.map +0 -1
  287. package/dist/chunks/KHR_materials_unlit-ww00IloC.esm.js +0 -74
  288. package/dist/chunks/KHR_materials_unlit-ww00IloC.esm.js.map +0 -1
  289. package/dist/chunks/KHR_materials_variants-D0pVU1lm.esm.min.js +0 -2
  290. package/dist/chunks/KHR_materials_variants-D0pVU1lm.esm.min.js.map +0 -1
  291. package/dist/chunks/KHR_materials_variants-D3IDOJfB.esm.js +0 -262
  292. package/dist/chunks/KHR_materials_variants-D3IDOJfB.esm.js.map +0 -1
  293. package/dist/chunks/KHR_materials_volume-BfZR8rbr.esm.min.js +0 -2
  294. package/dist/chunks/KHR_materials_volume-BfZR8rbr.esm.min.js.map +0 -1
  295. package/dist/chunks/KHR_materials_volume-CLkC_Bvi.esm.js +0 -87
  296. package/dist/chunks/KHR_materials_volume-CLkC_Bvi.esm.js.map +0 -1
  297. package/dist/chunks/KHR_mesh_quantization-BJv1P2Wt.esm.js +0 -26
  298. package/dist/chunks/KHR_mesh_quantization-BJv1P2Wt.esm.js.map +0 -1
  299. package/dist/chunks/KHR_mesh_quantization-D69X_5bR.esm.min.js +0 -2
  300. package/dist/chunks/KHR_mesh_quantization-D69X_5bR.esm.min.js.map +0 -1
  301. package/dist/chunks/KHR_node_hoverability-CG6s7hhs.esm.min.js +0 -2
  302. package/dist/chunks/KHR_node_hoverability-CG6s7hhs.esm.min.js.map +0 -1
  303. package/dist/chunks/KHR_node_hoverability-xgvyZ_r-.esm.js +0 -39
  304. package/dist/chunks/KHR_node_hoverability-xgvyZ_r-.esm.js.map +0 -1
  305. package/dist/chunks/KHR_node_visibility-DUozjXRR.esm.min.js +0 -2
  306. package/dist/chunks/KHR_node_visibility-DUozjXRR.esm.min.js.map +0 -1
  307. package/dist/chunks/KHR_node_visibility-aAs5Kkey.esm.js +0 -46
  308. package/dist/chunks/KHR_node_visibility-aAs5Kkey.esm.js.map +0 -1
  309. package/dist/chunks/KHR_texture_basisu-Bjw0jG1d.esm.js +0 -43
  310. package/dist/chunks/KHR_texture_basisu-Bjw0jG1d.esm.js.map +0 -1
  311. package/dist/chunks/KHR_texture_basisu-FWm46QOj.esm.min.js +0 -2
  312. package/dist/chunks/KHR_texture_basisu-FWm46QOj.esm.min.js.map +0 -1
  313. package/dist/chunks/KHR_texture_transform-BZYr2brj.esm.min.js +0 -2
  314. package/dist/chunks/KHR_texture_transform-BZYr2brj.esm.min.js.map +0 -1
  315. package/dist/chunks/KHR_texture_transform-DdsN6SA_.esm.js +0 -63
  316. package/dist/chunks/KHR_texture_transform-DdsN6SA_.esm.js.map +0 -1
  317. package/dist/chunks/KHR_xmp_json_ld-DhFD64vh.esm.min.js +0 -2
  318. package/dist/chunks/KHR_xmp_json_ld-DhFD64vh.esm.min.js.map +0 -1
  319. package/dist/chunks/KHR_xmp_json_ld-sTn6N13E.esm.js +0 -51
  320. package/dist/chunks/KHR_xmp_json_ld-sTn6N13E.esm.js.map +0 -1
  321. package/dist/chunks/MSFT_audio_emitter-5lrNj8-c.esm.min.js +0 -2
  322. package/dist/chunks/MSFT_audio_emitter-5lrNj8-c.esm.min.js.map +0 -1
  323. package/dist/chunks/MSFT_audio_emitter-B7RJSCaF.esm.js +0 -2201
  324. package/dist/chunks/MSFT_audio_emitter-B7RJSCaF.esm.js.map +0 -1
  325. package/dist/chunks/MSFT_lod-BJBjM7Gp.esm.js +0 -337
  326. package/dist/chunks/MSFT_lod-BJBjM7Gp.esm.js.map +0 -1
  327. package/dist/chunks/MSFT_lod-DpEZMnoU.esm.min.js +0 -2
  328. package/dist/chunks/MSFT_lod-DpEZMnoU.esm.min.js.map +0 -1
  329. package/dist/chunks/MSFT_minecraftMesh-CXHPdyar.esm.min.js +0 -2
  330. package/dist/chunks/MSFT_minecraftMesh-CXHPdyar.esm.min.js.map +0 -1
  331. package/dist/chunks/MSFT_minecraftMesh-DRC2tMvY.esm.js +0 -46
  332. package/dist/chunks/MSFT_minecraftMesh-DRC2tMvY.esm.js.map +0 -1
  333. package/dist/chunks/MSFT_sRGBFactors-Db1asZRk.esm.js +0 -47
  334. package/dist/chunks/MSFT_sRGBFactors-Db1asZRk.esm.js.map +0 -1
  335. package/dist/chunks/MSFT_sRGBFactors-RhAtY3q7.esm.min.js +0 -2
  336. package/dist/chunks/MSFT_sRGBFactors-RhAtY3q7.esm.min.js.map +0 -1
  337. package/dist/chunks/animationGroup-CjaFhT87.esm.min.js +0 -2
  338. package/dist/chunks/animationGroup-CjaFhT87.esm.min.js.map +0 -1
  339. package/dist/chunks/animationGroup-Ctc6BUYh.esm.js +0 -2482
  340. package/dist/chunks/animationGroup-Ctc6BUYh.esm.js.map +0 -1
  341. package/dist/chunks/assetContainer-DDEska5G.esm.min.js +0 -2
  342. package/dist/chunks/assetContainer-DDEska5G.esm.min.js.map +0 -1
  343. package/dist/chunks/assetContainer-QD3gUzyx.esm.js +0 -1720
  344. package/dist/chunks/assetContainer-QD3gUzyx.esm.js.map +0 -1
  345. package/dist/chunks/audioEngine-C6R2Ow6e.esm.js +0 -305
  346. package/dist/chunks/audioEngine-C6R2Ow6e.esm.js.map +0 -1
  347. package/dist/chunks/audioEngine-FKYFzzDb.esm.min.js +0 -2
  348. package/dist/chunks/audioEngine-FKYFzzDb.esm.min.js.map +0 -1
  349. package/dist/chunks/bakedVertexAnimation-DKR6lpIg.esm.min.js +0 -2
  350. package/dist/chunks/bakedVertexAnimation-DKR6lpIg.esm.min.js.map +0 -1
  351. package/dist/chunks/bakedVertexAnimation-Hxn22qoJ.esm.js +0 -114
  352. package/dist/chunks/bakedVertexAnimation-Hxn22qoJ.esm.js.map +0 -1
  353. package/dist/chunks/basisTextureLoader-BcNAHqjw.esm.min.js +0 -2
  354. package/dist/chunks/basisTextureLoader-BcNAHqjw.esm.min.js.map +0 -1
  355. package/dist/chunks/basisTextureLoader-Dr2d0ez5.esm.js +0 -600
  356. package/dist/chunks/basisTextureLoader-Dr2d0ez5.esm.js.map +0 -1
  357. package/dist/chunks/dds-CFrq_XFM.esm.js +0 -540
  358. package/dist/chunks/dds-CFrq_XFM.esm.js.map +0 -1
  359. package/dist/chunks/dds-D1NTXLIL.esm.min.js +0 -2
  360. package/dist/chunks/dds-D1NTXLIL.esm.min.js.map +0 -1
  361. package/dist/chunks/ddsTextureLoader-DbvffCUa.esm.min.js +0 -2
  362. package/dist/chunks/ddsTextureLoader-DbvffCUa.esm.min.js.map +0 -1
  363. package/dist/chunks/ddsTextureLoader-wyjUdBoO.esm.js +0 -88
  364. package/dist/chunks/ddsTextureLoader-wyjUdBoO.esm.js.map +0 -1
  365. package/dist/chunks/decalFragment-CGto5zyq.esm.js +0 -18
  366. package/dist/chunks/decalFragment-CGto5zyq.esm.js.map +0 -1
  367. package/dist/chunks/decalFragment-CU64C8uG.esm.min.js +0 -2
  368. package/dist/chunks/decalFragment-CU64C8uG.esm.min.js.map +0 -1
  369. package/dist/chunks/default.fragment-B2bhCC4E.esm.js +0 -446
  370. package/dist/chunks/default.fragment-B2bhCC4E.esm.js.map +0 -1
  371. package/dist/chunks/default.fragment-Boq79lom.esm.min.js +0 -2
  372. package/dist/chunks/default.fragment-Boq79lom.esm.min.js.map +0 -1
  373. package/dist/chunks/default.fragment-CluFtXFp.esm.min.js +0 -2
  374. package/dist/chunks/default.fragment-CluFtXFp.esm.min.js.map +0 -1
  375. package/dist/chunks/default.fragment-Dshl5Uqc.esm.js +0 -515
  376. package/dist/chunks/default.fragment-Dshl5Uqc.esm.js.map +0 -1
  377. package/dist/chunks/default.vertex-BAAgCiYo.esm.min.js +0 -2
  378. package/dist/chunks/default.vertex-BAAgCiYo.esm.min.js.map +0 -1
  379. package/dist/chunks/default.vertex-BhOIicZW.esm.min.js +0 -2
  380. package/dist/chunks/default.vertex-BhOIicZW.esm.min.js.map +0 -1
  381. package/dist/chunks/default.vertex-DL7IogGB.esm.js +0 -211
  382. package/dist/chunks/default.vertex-DL7IogGB.esm.js.map +0 -1
  383. package/dist/chunks/default.vertex-DOXcZEQ0.esm.js +0 -190
  384. package/dist/chunks/default.vertex-DOXcZEQ0.esm.js.map +0 -1
  385. package/dist/chunks/defaultUboDeclaration-1qBz6EuF.esm.js +0 -15
  386. package/dist/chunks/defaultUboDeclaration-1qBz6EuF.esm.js.map +0 -1
  387. package/dist/chunks/defaultUboDeclaration-B9LzMzlw.esm.min.js +0 -2
  388. package/dist/chunks/defaultUboDeclaration-B9LzMzlw.esm.min.js.map +0 -1
  389. package/dist/chunks/defaultUboDeclaration-CXdodf7i.esm.js +0 -13
  390. package/dist/chunks/defaultUboDeclaration-CXdodf7i.esm.js.map +0 -1
  391. package/dist/chunks/defaultUboDeclaration-CZlCaxgu.esm.min.js +0 -2
  392. package/dist/chunks/defaultUboDeclaration-CZlCaxgu.esm.min.js.map +0 -1
  393. package/dist/chunks/drawWrapper.functions-CKg3_9x4.esm.js +0 -11
  394. package/dist/chunks/drawWrapper.functions-CKg3_9x4.esm.js.map +0 -1
  395. package/dist/chunks/drawWrapper.functions-ng7lvueZ.esm.min.js +0 -2
  396. package/dist/chunks/drawWrapper.functions-ng7lvueZ.esm.min.js.map +0 -1
  397. package/dist/chunks/dumpTools-C3vcqEdz.esm.js +0 -200
  398. package/dist/chunks/dumpTools-C3vcqEdz.esm.js.map +0 -1
  399. package/dist/chunks/dumpTools-C8ZzlWEh.esm.min.js +0 -2
  400. package/dist/chunks/dumpTools-C8ZzlWEh.esm.min.js.map +0 -1
  401. package/dist/chunks/engine-_wVL12I1.esm.js +0 -2213
  402. package/dist/chunks/engine-_wVL12I1.esm.js.map +0 -1
  403. package/dist/chunks/engine-nCWszV_w.esm.min.js +0 -2
  404. package/dist/chunks/engine-nCWszV_w.esm.min.js.map +0 -1
  405. package/dist/chunks/engine.common-BuPfo1Wj.esm.min.js +0 -2
  406. package/dist/chunks/engine.common-BuPfo1Wj.esm.min.js.map +0 -1
  407. package/dist/chunks/engine.common-CT5iq3ZT.esm.js +0 -1162
  408. package/dist/chunks/engine.common-CT5iq3ZT.esm.js.map +0 -1
  409. package/dist/chunks/envTextureLoader-D7L0fVXR.esm.min.js +0 -2
  410. package/dist/chunks/envTextureLoader-D7L0fVXR.esm.min.js.map +0 -1
  411. package/dist/chunks/envTextureLoader-PtuRNDrr.esm.js +0 -64
  412. package/dist/chunks/envTextureLoader-PtuRNDrr.esm.js.map +0 -1
  413. package/dist/chunks/environmentTextureTools-BjmCbfSf.esm.min.js +0 -2
  414. package/dist/chunks/environmentTextureTools-BjmCbfSf.esm.min.js.map +0 -1
  415. package/dist/chunks/environmentTextureTools-DYbFmR95.esm.js +0 -382
  416. package/dist/chunks/environmentTextureTools-DYbFmR95.esm.js.map +0 -1
  417. package/dist/chunks/exrTextureLoader-BIPK0bPG.esm.min.js +0 -2
  418. package/dist/chunks/exrTextureLoader-BIPK0bPG.esm.min.js.map +0 -1
  419. package/dist/chunks/exrTextureLoader-CEhv_7O9.esm.js +0 -1683
  420. package/dist/chunks/exrTextureLoader-CEhv_7O9.esm.js.map +0 -1
  421. package/dist/chunks/fogFragment-B7_evZbY.esm.js +0 -102
  422. package/dist/chunks/fogFragment-B7_evZbY.esm.js.map +0 -1
  423. package/dist/chunks/fogFragment-CoZPb7oI.esm.min.js +0 -2
  424. package/dist/chunks/fogFragment-CoZPb7oI.esm.min.js.map +0 -1
  425. package/dist/chunks/fogFragment-DSO97-dc.esm.min.js +0 -2
  426. package/dist/chunks/fogFragment-DSO97-dc.esm.min.js.map +0 -1
  427. package/dist/chunks/fogFragment-wY2jQ7fb.esm.js +0 -101
  428. package/dist/chunks/fogFragment-wY2jQ7fb.esm.js.map +0 -1
  429. package/dist/chunks/fresnelFunction-BSEp5SCT.esm.js +0 -12
  430. package/dist/chunks/fresnelFunction-BSEp5SCT.esm.js.map +0 -1
  431. package/dist/chunks/fresnelFunction-Cg-NNSrz.esm.min.js +0 -2
  432. package/dist/chunks/fresnelFunction-Cg-NNSrz.esm.min.js.map +0 -1
  433. package/dist/chunks/glTFLoader-3ZUBWawQ.esm.min.js +0 -2
  434. package/dist/chunks/glTFLoader-3ZUBWawQ.esm.min.js.map +0 -1
  435. package/dist/chunks/glTFLoader-DVoAJl_A.esm.js +0 -7658
  436. package/dist/chunks/glTFLoader-DVoAJl_A.esm.js.map +0 -1
  437. package/dist/chunks/glTFLoaderAnimation-By7yP8sQ.esm.js +0 -77
  438. package/dist/chunks/glTFLoaderAnimation-By7yP8sQ.esm.js.map +0 -1
  439. package/dist/chunks/glTFLoaderAnimation-C9g-SHaJ.esm.min.js +0 -2
  440. package/dist/chunks/glTFLoaderAnimation-C9g-SHaJ.esm.min.js.map +0 -1
  441. package/dist/chunks/gltfPathToObjectConverter-Dyt_Y9jE.esm.min.js +0 -2
  442. package/dist/chunks/gltfPathToObjectConverter-Dyt_Y9jE.esm.min.js.map +0 -1
  443. package/dist/chunks/gltfPathToObjectConverter-GcUmfOyo.esm.js +0 -67
  444. package/dist/chunks/gltfPathToObjectConverter-GcUmfOyo.esm.js.map +0 -1
  445. package/dist/chunks/harmonicsFunctions-B8pgRSdd.esm.min.js +0 -2
  446. package/dist/chunks/harmonicsFunctions-B8pgRSdd.esm.min.js.map +0 -1
  447. package/dist/chunks/harmonicsFunctions-BcfkM4gb.esm.js +0 -35
  448. package/dist/chunks/harmonicsFunctions-BcfkM4gb.esm.js.map +0 -1
  449. package/dist/chunks/harmonicsFunctions-DF1x585z.esm.min.js +0 -2
  450. package/dist/chunks/harmonicsFunctions-DF1x585z.esm.min.js.map +0 -1
  451. package/dist/chunks/harmonicsFunctions-a48Ki58F.esm.js +0 -34
  452. package/dist/chunks/harmonicsFunctions-a48Ki58F.esm.js.map +0 -1
  453. package/dist/chunks/hdrTextureLoader-BWnO8u1r.esm.js +0 -253
  454. package/dist/chunks/hdrTextureLoader-BWnO8u1r.esm.js.map +0 -1
  455. package/dist/chunks/hdrTextureLoader-Bii9QpYI.esm.min.js +0 -2
  456. package/dist/chunks/hdrTextureLoader-Bii9QpYI.esm.min.js.map +0 -1
  457. package/dist/chunks/helperFunctions-BinFB44e.esm.js +0 -110
  458. package/dist/chunks/helperFunctions-BinFB44e.esm.js.map +0 -1
  459. package/dist/chunks/helperFunctions-CZAyJNTJ.esm.min.js +0 -2
  460. package/dist/chunks/helperFunctions-CZAyJNTJ.esm.min.js.map +0 -1
  461. package/dist/chunks/helperFunctions-DjoUVhI2.esm.min.js +0 -2
  462. package/dist/chunks/helperFunctions-DjoUVhI2.esm.min.js.map +0 -1
  463. package/dist/chunks/helperFunctions-Ds3-3-tu.esm.js +0 -83
  464. package/dist/chunks/helperFunctions-Ds3-3-tu.esm.js.map +0 -1
  465. package/dist/chunks/iesTextureLoader-CsnjIN7M.esm.js +0 -189
  466. package/dist/chunks/iesTextureLoader-CsnjIN7M.esm.js.map +0 -1
  467. package/dist/chunks/iesTextureLoader-DkmTomCD.esm.min.js +0 -2
  468. package/dist/chunks/iesTextureLoader-DkmTomCD.esm.min.js.map +0 -1
  469. package/dist/chunks/index-Cw2FZpYY.esm.js +0 -74870
  470. package/dist/chunks/index-Cw2FZpYY.esm.js.map +0 -1
  471. package/dist/chunks/index-DRbhrB0j.esm.min.js +0 -57
  472. package/dist/chunks/index-DRbhrB0j.esm.min.js.map +0 -1
  473. package/dist/chunks/ktxTextureLoader-B4pmAFQl.esm.js +0 -814
  474. package/dist/chunks/ktxTextureLoader-B4pmAFQl.esm.js.map +0 -1
  475. package/dist/chunks/ktxTextureLoader-B8Rlj2T0.esm.min.js +0 -2
  476. package/dist/chunks/ktxTextureLoader-B8Rlj2T0.esm.min.js.map +0 -1
  477. package/dist/chunks/logDepthDeclaration-CGz2sG_K.esm.js +0 -11
  478. package/dist/chunks/logDepthDeclaration-CGz2sG_K.esm.js.map +0 -1
  479. package/dist/chunks/logDepthDeclaration-CfVFs2QC.esm.min.js +0 -2
  480. package/dist/chunks/logDepthDeclaration-CfVFs2QC.esm.min.js.map +0 -1
  481. package/dist/chunks/logDepthDeclaration-CzVshpad.esm.min.js +0 -2
  482. package/dist/chunks/logDepthDeclaration-CzVshpad.esm.min.js.map +0 -1
  483. package/dist/chunks/logDepthDeclaration-xOwnAKtd.esm.js +0 -35
  484. package/dist/chunks/logDepthDeclaration-xOwnAKtd.esm.js.map +0 -1
  485. package/dist/chunks/logDepthVertex-BRgUZAsw.esm.js +0 -81
  486. package/dist/chunks/logDepthVertex-BRgUZAsw.esm.js.map +0 -1
  487. package/dist/chunks/logDepthVertex-CWfPfN9-.esm.min.js +0 -2
  488. package/dist/chunks/logDepthVertex-CWfPfN9-.esm.min.js.map +0 -1
  489. package/dist/chunks/logDepthVertex-HDlt7vTP.esm.min.js +0 -2
  490. package/dist/chunks/logDepthVertex-HDlt7vTP.esm.min.js.map +0 -1
  491. package/dist/chunks/logDepthVertex-l0uEG89p.esm.js +0 -77
  492. package/dist/chunks/logDepthVertex-l0uEG89p.esm.js.map +0 -1
  493. package/dist/chunks/mainUVVaryingDeclaration-B72zV2P9.esm.min.js +0 -2
  494. package/dist/chunks/mainUVVaryingDeclaration-B72zV2P9.esm.min.js.map +0 -1
  495. package/dist/chunks/mainUVVaryingDeclaration-BDogjZrz.esm.js +0 -11
  496. package/dist/chunks/mainUVVaryingDeclaration-BDogjZrz.esm.js.map +0 -1
  497. package/dist/chunks/mainUVVaryingDeclaration-DO5HJKyl.esm.min.js +0 -2
  498. package/dist/chunks/mainUVVaryingDeclaration-DO5HJKyl.esm.min.js.map +0 -1
  499. package/dist/chunks/mainUVVaryingDeclaration-DqzNajlu.esm.js +0 -11
  500. package/dist/chunks/mainUVVaryingDeclaration-DqzNajlu.esm.js.map +0 -1
  501. package/dist/chunks/mesh.vertexData.functions-B_pMCAzZ.esm.js +0 -119
  502. package/dist/chunks/mesh.vertexData.functions-B_pMCAzZ.esm.js.map +0 -1
  503. package/dist/chunks/mesh.vertexData.functions-Bo7e6Of9.esm.min.js +0 -2
  504. package/dist/chunks/mesh.vertexData.functions-Bo7e6Of9.esm.min.js.map +0 -1
  505. package/dist/chunks/meshUboDeclaration-BCO87lfZ.esm.js +0 -26
  506. package/dist/chunks/meshUboDeclaration-BCO87lfZ.esm.js.map +0 -1
  507. package/dist/chunks/meshUboDeclaration-o4Xf2fwW.esm.min.js +0 -2
  508. package/dist/chunks/meshUboDeclaration-o4Xf2fwW.esm.min.js.map +0 -1
  509. package/dist/chunks/objFileLoader-BfPYM2Sh.esm.min.js +0 -2
  510. package/dist/chunks/objFileLoader-BfPYM2Sh.esm.min.js.map +0 -1
  511. package/dist/chunks/objFileLoader-D1emf4Qh.esm.js +0 -1338
  512. package/dist/chunks/objFileLoader-D1emf4Qh.esm.js.map +0 -1
  513. package/dist/chunks/oitFragment-B92YpEfj.esm.min.js +0 -2
  514. package/dist/chunks/oitFragment-B92YpEfj.esm.min.js.map +0 -1
  515. package/dist/chunks/oitFragment-BoFKkDNv.esm.js +0 -1078
  516. package/dist/chunks/oitFragment-BoFKkDNv.esm.js.map +0 -1
  517. package/dist/chunks/oitFragment-Cfx3g0iX.esm.js +0 -1240
  518. package/dist/chunks/oitFragment-Cfx3g0iX.esm.js.map +0 -1
  519. package/dist/chunks/oitFragment-CiA7gld-.esm.min.js +0 -2
  520. package/dist/chunks/oitFragment-CiA7gld-.esm.min.js.map +0 -1
  521. package/dist/chunks/pass.fragment-BLbIViJ7.esm.js +0 -15
  522. package/dist/chunks/pass.fragment-BLbIViJ7.esm.js.map +0 -1
  523. package/dist/chunks/pass.fragment-BqMk9ouF.esm.min.js +0 -2
  524. package/dist/chunks/pass.fragment-BqMk9ouF.esm.min.js.map +0 -1
  525. package/dist/chunks/pass.fragment-BuVDFNSR.esm.js +0 -15
  526. package/dist/chunks/pass.fragment-BuVDFNSR.esm.js.map +0 -1
  527. package/dist/chunks/pass.fragment-cM5FBHLm.esm.min.js +0 -2
  528. package/dist/chunks/pass.fragment-cM5FBHLm.esm.min.js.map +0 -1
  529. package/dist/chunks/pbr.fragment-5L_F7nGn.esm.js +0 -3222
  530. package/dist/chunks/pbr.fragment-5L_F7nGn.esm.js.map +0 -1
  531. package/dist/chunks/pbr.fragment-BJNPHSa-.esm.min.js +0 -2
  532. package/dist/chunks/pbr.fragment-BJNPHSa-.esm.min.js.map +0 -1
  533. package/dist/chunks/pbr.fragment-CTLrOzV2.esm.js +0 -3269
  534. package/dist/chunks/pbr.fragment-CTLrOzV2.esm.js.map +0 -1
  535. package/dist/chunks/pbr.fragment-D9MJFOr2.esm.min.js +0 -2
  536. package/dist/chunks/pbr.fragment-D9MJFOr2.esm.min.js.map +0 -1
  537. package/dist/chunks/pbr.vertex-BJyjq_fb.esm.js +0 -223
  538. package/dist/chunks/pbr.vertex-BJyjq_fb.esm.js.map +0 -1
  539. package/dist/chunks/pbr.vertex-Bm8Ng4Sx.esm.min.js +0 -2
  540. package/dist/chunks/pbr.vertex-Bm8Ng4Sx.esm.min.js.map +0 -1
  541. package/dist/chunks/pbr.vertex-CAKPUhfb.esm.min.js +0 -2
  542. package/dist/chunks/pbr.vertex-CAKPUhfb.esm.min.js.map +0 -1
  543. package/dist/chunks/pbr.vertex-DJd_-MvE.esm.js +0 -348
  544. package/dist/chunks/pbr.vertex-DJd_-MvE.esm.js.map +0 -1
  545. package/dist/chunks/postprocess.vertex-BjRX5eGi.esm.min.js +0 -2
  546. package/dist/chunks/postprocess.vertex-BjRX5eGi.esm.min.js.map +0 -1
  547. package/dist/chunks/postprocess.vertex-CFaKNIU-.esm.js +0 -20
  548. package/dist/chunks/postprocess.vertex-CFaKNIU-.esm.js.map +0 -1
  549. package/dist/chunks/rawTexture-ByD8l28R.esm.min.js +0 -2
  550. package/dist/chunks/rawTexture-ByD8l28R.esm.min.js.map +0 -1
  551. package/dist/chunks/rawTexture-DGz22uaX.esm.js +0 -191
  552. package/dist/chunks/rawTexture-DGz22uaX.esm.js.map +0 -1
  553. package/dist/chunks/ray-ByafiITx.esm.js +0 -946
  554. package/dist/chunks/ray-ByafiITx.esm.js.map +0 -1
  555. package/dist/chunks/ray-ChSTYrPm.esm.min.js +0 -2
  556. package/dist/chunks/ray-ChSTYrPm.esm.min.js.map +0 -1
  557. package/dist/chunks/rgbdDecode.fragment-CJ7PpH1N.esm.js +0 -13
  558. package/dist/chunks/rgbdDecode.fragment-CJ7PpH1N.esm.js.map +0 -1
  559. package/dist/chunks/rgbdDecode.fragment-DJ9crbPP.esm.js +0 -13
  560. package/dist/chunks/rgbdDecode.fragment-DJ9crbPP.esm.js.map +0 -1
  561. package/dist/chunks/rgbdDecode.fragment-DLpb3z18.esm.min.js +0 -2
  562. package/dist/chunks/rgbdDecode.fragment-DLpb3z18.esm.min.js.map +0 -1
  563. package/dist/chunks/rgbdDecode.fragment-ygeOUzIi.esm.min.js +0 -2
  564. package/dist/chunks/rgbdDecode.fragment-ygeOUzIi.esm.min.js.map +0 -1
  565. package/dist/chunks/rgbdEncode.fragment-BTG_wbck.esm.min.js +0 -2
  566. package/dist/chunks/rgbdEncode.fragment-BTG_wbck.esm.min.js.map +0 -1
  567. package/dist/chunks/rgbdEncode.fragment-C2s4AQaM.esm.js +0 -13
  568. package/dist/chunks/rgbdEncode.fragment-C2s4AQaM.esm.js.map +0 -1
  569. package/dist/chunks/rgbdEncode.fragment-C6LKySQH.esm.js +0 -13
  570. package/dist/chunks/rgbdEncode.fragment-C6LKySQH.esm.js.map +0 -1
  571. package/dist/chunks/rgbdEncode.fragment-CKB2lpgL.esm.min.js +0 -2
  572. package/dist/chunks/rgbdEncode.fragment-CKB2lpgL.esm.min.js.map +0 -1
  573. package/dist/chunks/splatFileLoader-BtSUlfZs.esm.min.js +0 -2
  574. package/dist/chunks/splatFileLoader-BtSUlfZs.esm.min.js.map +0 -1
  575. package/dist/chunks/splatFileLoader-Wn5sDtLq.esm.js +0 -3379
  576. package/dist/chunks/splatFileLoader-Wn5sDtLq.esm.js.map +0 -1
  577. package/dist/chunks/spotLight-CmDQEB8V.esm.js +0 -701
  578. package/dist/chunks/spotLight-CmDQEB8V.esm.js.map +0 -1
  579. package/dist/chunks/spotLight-hg94aMJD.esm.min.js +0 -2
  580. package/dist/chunks/spotLight-hg94aMJD.esm.min.js.map +0 -1
  581. package/dist/chunks/standardMaterial-BhIiLn1_.esm.js +0 -1806
  582. package/dist/chunks/standardMaterial-BhIiLn1_.esm.js.map +0 -1
  583. package/dist/chunks/standardMaterial-DQii8fRL.esm.min.js +0 -2
  584. package/dist/chunks/standardMaterial-DQii8fRL.esm.min.js.map +0 -1
  585. package/dist/chunks/stlFileLoader-D83u9BOr.esm.js +0 -238
  586. package/dist/chunks/stlFileLoader-D83u9BOr.esm.js.map +0 -1
  587. package/dist/chunks/stlFileLoader-DkXWqjZo.esm.min.js +0 -2
  588. package/dist/chunks/stlFileLoader-DkXWqjZo.esm.min.js.map +0 -1
  589. package/dist/chunks/tgaTextureLoader-C9xl6cvE.esm.js +0 -349
  590. package/dist/chunks/tgaTextureLoader-C9xl6cvE.esm.js.map +0 -1
  591. package/dist/chunks/tgaTextureLoader-DfzjGulW.esm.min.js +0 -2
  592. package/dist/chunks/tgaTextureLoader-DfzjGulW.esm.min.js.map +0 -1
  593. package/dist/chunks/thinEngine-Cu21aOSC.esm.min.js +0 -2
  594. package/dist/chunks/thinEngine-Cu21aOSC.esm.min.js.map +0 -1
  595. package/dist/chunks/thinEngine-IzS60pqU.esm.js +0 -3853
  596. package/dist/chunks/thinEngine-IzS60pqU.esm.js.map +0 -1
  597. package/dist/chunks/thinInstanceMesh-BN8Ev-h8.esm.js +0 -314
  598. package/dist/chunks/thinInstanceMesh-BN8Ev-h8.esm.js.map +0 -1
  599. package/dist/chunks/thinInstanceMesh-Bm9vmKU4.esm.min.js +0 -2
  600. package/dist/chunks/thinInstanceMesh-Bm9vmKU4.esm.min.js.map +0 -1
  601. package/dist/chunks/vertexColorMixing-Cazf4vEl.esm.min.js +0 -2
  602. package/dist/chunks/vertexColorMixing-Cazf4vEl.esm.min.js.map +0 -1
  603. package/dist/chunks/vertexColorMixing-DGvq3Fju.esm.js +0 -421
  604. package/dist/chunks/vertexColorMixing-DGvq3Fju.esm.js.map +0 -1
  605. package/dist/chunks/vertexColorMixing-D_6ZvivZ.esm.min.js +0 -2
  606. package/dist/chunks/vertexColorMixing-D_6ZvivZ.esm.min.js.map +0 -1
  607. package/dist/chunks/vertexColorMixing-DuYHnuUm.esm.js +0 -531
  608. package/dist/chunks/vertexColorMixing-DuYHnuUm.esm.js.map +0 -1
  609. package/dist/chunks/webgpuEngine-DHaXinU4.esm.min.js +0 -2
  610. package/dist/chunks/webgpuEngine-DHaXinU4.esm.min.js.map +0 -1
  611. package/dist/chunks/webgpuEngine-Dxev7pbz.esm.js +0 -11538
  612. package/dist/chunks/webgpuEngine-Dxev7pbz.esm.js.map +0 -1
  613. package/dist/chunks/workerPool-BUOov2K1.esm.js +0 -122
  614. package/dist/chunks/workerPool-BUOov2K1.esm.js.map +0 -1
  615. package/dist/chunks/workerPool-BWHiDmEZ.esm.min.js +0 -2
  616. package/dist/chunks/workerPool-BWHiDmEZ.esm.min.js.map +0 -1
  617. package/lib/index.d.ts +0 -591
  618. package/lib/index.js +0 -2165
  619. package/lib/index.js.map +0 -1
@@ -1,2201 +0,0 @@
1
- import { bD as _WarnImport, R as RegisterClass, A as AbstractEngine, aV as Observable, v as Vector3, E as EngineStore, L as Logger, T as Tools, _ as _retryWithInterval, al as Scene, bE as SceneComponentConstants, a5 as Matrix, o as PrecisionDate, aQ as unregisterGLTFExtension, aR as registerGLTFExtension } from './index-Cw2FZpYY.esm.js';
2
- import { A as ArrayItem, G as GLTFLoader } from './glTFLoader-DVoAJl_A.esm.js';
3
- import './audioEngine-C6R2Ow6e.esm.js';
4
- import './rawTexture-DGz22uaX.esm.js';
5
- import './assetContainer-QD3gUzyx.esm.js';
6
- import './glTFLoaderAnimation-By7yP8sQ.esm.js';
7
-
8
- /**
9
- * Composed of a frame, and an action function
10
- */
11
- class AnimationEvent {
12
- /**
13
- * Initializes the animation event
14
- * @param frame The frame for which the event is triggered
15
- * @param action The event to perform when triggered
16
- * @param onlyOnce Specifies if the event should be triggered only once
17
- */
18
- constructor(
19
- /** The frame for which the event is triggered **/
20
- frame,
21
- /** The event to perform when triggered **/
22
- action,
23
- /** Specifies if the event should be triggered only once**/
24
- onlyOnce) {
25
- this.frame = frame;
26
- this.action = action;
27
- this.onlyOnce = onlyOnce;
28
- /**
29
- * Specifies if the animation event is done
30
- */
31
- this.isDone = false;
32
- }
33
- /** @internal */
34
- _clone() {
35
- return new AnimationEvent(this.frame, this.action, this.onlyOnce);
36
- }
37
- }
38
-
39
- /**
40
- * Defines a sound that can be played in the application.
41
- * The sound can either be an ambient track or a simple sound played in reaction to a user action.
42
- * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic
43
- */
44
- class Sound {
45
- /**
46
- * Does the sound loop after it finishes playing once.
47
- */
48
- get loop() {
49
- return this._loop;
50
- }
51
- set loop(value) {
52
- if (value === this._loop) {
53
- return;
54
- }
55
- this._loop = value;
56
- this.updateOptions({ loop: value });
57
- }
58
- /**
59
- * Gets the current time for the sound.
60
- */
61
- get currentTime() {
62
- if (this._htmlAudioElement) {
63
- return this._htmlAudioElement.currentTime;
64
- }
65
- if (AbstractEngine.audioEngine?.audioContext && (this.isPlaying || this.isPaused)) {
66
- // The `_currentTime` member is only updated when the sound is paused. Add the time since the last start
67
- // to get the actual current time.
68
- const timeSinceLastStart = this.isPaused ? 0 : AbstractEngine.audioEngine.audioContext.currentTime - this._startTime;
69
- return this._currentTime + timeSinceLastStart;
70
- }
71
- return 0;
72
- }
73
- /**
74
- * Does this sound enables spatial sound.
75
- * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound
76
- */
77
- get spatialSound() {
78
- return this._spatialSound;
79
- }
80
- /**
81
- * Does this sound enables spatial sound.
82
- * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound
83
- */
84
- set spatialSound(newValue) {
85
- if (newValue == this._spatialSound) {
86
- return;
87
- }
88
- const wasPlaying = this.isPlaying;
89
- this.pause();
90
- if (newValue) {
91
- this._spatialSound = newValue;
92
- this._updateSpatialParameters();
93
- }
94
- else {
95
- this._disableSpatialSound();
96
- }
97
- if (wasPlaying) {
98
- this.play();
99
- }
100
- }
101
- /**
102
- * Create a sound and attach it to a scene
103
- * @param name Name of your sound
104
- * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams and AudioBuffers
105
- * @param scene defines the scene the sound belongs to
106
- * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
107
- * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
108
- */
109
- constructor(name, urlOrArrayBuffer, scene, readyToPlayCallback = null, options) {
110
- /**
111
- * Does the sound autoplay once loaded.
112
- */
113
- this.autoplay = false;
114
- this._loop = false;
115
- /**
116
- * Does the sound use a custom attenuation curve to simulate the falloff
117
- * happening when the source gets further away from the camera.
118
- * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-your-own-custom-attenuation-function
119
- */
120
- this.useCustomAttenuation = false;
121
- /**
122
- * Is this sound currently played.
123
- */
124
- this.isPlaying = false;
125
- /**
126
- * Is this sound currently paused.
127
- */
128
- this.isPaused = false;
129
- /**
130
- * Define the reference distance the sound should be heard perfectly.
131
- * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound
132
- */
133
- this.refDistance = 1;
134
- /**
135
- * Define the roll off factor of spatial sounds.
136
- * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound
137
- */
138
- this.rolloffFactor = 1;
139
- /**
140
- * Define the max distance the sound should be heard (intensity just became 0 at this point).
141
- * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound
142
- */
143
- this.maxDistance = 100;
144
- /**
145
- * Define the distance attenuation model the sound will follow.
146
- * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound
147
- */
148
- this.distanceModel = "linear";
149
- /**
150
- * Gets or sets an object used to store user defined information for the sound.
151
- */
152
- this.metadata = null;
153
- /**
154
- * Observable event when the current playing sound finishes.
155
- */
156
- this.onEndedObservable = new Observable();
157
- this._spatialSound = false;
158
- this._panningModel = "equalpower";
159
- this._playbackRate = 1;
160
- this._streaming = false;
161
- this._startTime = 0;
162
- this._currentTime = 0;
163
- this._position = Vector3.Zero();
164
- this._localDirection = new Vector3(1, 0, 0);
165
- this._volume = 1;
166
- this._isReadyToPlay = false;
167
- this._isDirectional = false;
168
- // Used if you'd like to create a directional sound.
169
- // If not set, the sound will be omnidirectional
170
- this._coneInnerAngle = 360;
171
- this._coneOuterAngle = 360;
172
- this._coneOuterGain = 0;
173
- this._isOutputConnected = false;
174
- this._urlType = "Unknown";
175
- this.name = name;
176
- scene = scene || EngineStore.LastCreatedScene;
177
- if (!scene) {
178
- return;
179
- }
180
- this._scene = scene;
181
- Sound._SceneComponentInitialization(scene);
182
- this._readyToPlayCallback = readyToPlayCallback;
183
- // Default custom attenuation function is a linear attenuation
184
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
185
- this._customAttenuationFunction = (currentVolume, currentDistance, maxDistance, refDistance, rolloffFactor) => {
186
- if (currentDistance < maxDistance) {
187
- return currentVolume * (1 - currentDistance / maxDistance);
188
- }
189
- else {
190
- return 0;
191
- }
192
- };
193
- if (options) {
194
- this.autoplay = options.autoplay || false;
195
- this._loop = options.loop || false;
196
- // if volume === 0, we need another way to check this option
197
- if (options.volume !== undefined) {
198
- this._volume = options.volume;
199
- }
200
- this._spatialSound = options.spatialSound ?? false;
201
- this.maxDistance = options.maxDistance ?? 100;
202
- this.useCustomAttenuation = options.useCustomAttenuation ?? false;
203
- this.rolloffFactor = options.rolloffFactor || 1;
204
- this.refDistance = options.refDistance || 1;
205
- this.distanceModel = options.distanceModel || "linear";
206
- this._playbackRate = options.playbackRate || 1;
207
- this._streaming = options.streaming ?? false;
208
- this._length = options.length;
209
- this._offset = options.offset;
210
- }
211
- if (AbstractEngine.audioEngine?.canUseWebAudio && AbstractEngine.audioEngine.audioContext) {
212
- this._soundGain = AbstractEngine.audioEngine.audioContext.createGain();
213
- this._soundGain.gain.value = this._volume;
214
- this._inputAudioNode = this._soundGain;
215
- this._outputAudioNode = this._soundGain;
216
- if (this._spatialSound) {
217
- this._createSpatialParameters();
218
- }
219
- this._scene.mainSoundTrack.addSound(this);
220
- let validParameter = true;
221
- // if no parameter is passed, you need to call setAudioBuffer yourself to prepare the sound
222
- if (urlOrArrayBuffer) {
223
- try {
224
- if (typeof urlOrArrayBuffer === "string") {
225
- this._urlType = "String";
226
- this._url = urlOrArrayBuffer;
227
- }
228
- else if (urlOrArrayBuffer instanceof ArrayBuffer) {
229
- this._urlType = "ArrayBuffer";
230
- }
231
- else if (urlOrArrayBuffer instanceof HTMLMediaElement) {
232
- this._urlType = "MediaElement";
233
- }
234
- else if (urlOrArrayBuffer instanceof MediaStream) {
235
- this._urlType = "MediaStream";
236
- }
237
- else if (urlOrArrayBuffer instanceof AudioBuffer) {
238
- this._urlType = "AudioBuffer";
239
- }
240
- else if (Array.isArray(urlOrArrayBuffer)) {
241
- this._urlType = "Array";
242
- }
243
- let urls = [];
244
- let codecSupportedFound = false;
245
- switch (this._urlType) {
246
- case "MediaElement":
247
- this._streaming = true;
248
- this._isReadyToPlay = true;
249
- this._streamingSource = AbstractEngine.audioEngine.audioContext.createMediaElementSource(urlOrArrayBuffer);
250
- if (this.autoplay) {
251
- this.play(0, this._offset, this._length);
252
- }
253
- if (this._readyToPlayCallback) {
254
- this._readyToPlayCallback();
255
- }
256
- break;
257
- case "MediaStream":
258
- this._streaming = true;
259
- this._isReadyToPlay = true;
260
- this._streamingSource = AbstractEngine.audioEngine.audioContext.createMediaStreamSource(urlOrArrayBuffer);
261
- if (this.autoplay) {
262
- this.play(0, this._offset, this._length);
263
- }
264
- if (this._readyToPlayCallback) {
265
- this._readyToPlayCallback();
266
- }
267
- break;
268
- case "ArrayBuffer":
269
- if (urlOrArrayBuffer.byteLength > 0) {
270
- codecSupportedFound = true;
271
- this._soundLoaded(urlOrArrayBuffer);
272
- }
273
- break;
274
- case "AudioBuffer":
275
- this._audioBufferLoaded(urlOrArrayBuffer);
276
- break;
277
- case "String":
278
- urls.push(urlOrArrayBuffer);
279
- // eslint-disable-next-line no-fallthrough
280
- case "Array":
281
- if (urls.length === 0) {
282
- urls = urlOrArrayBuffer;
283
- }
284
- // If we found a supported format, we load it immediately and stop the loop
285
- for (let i = 0; i < urls.length; i++) {
286
- const url = urls[i];
287
- codecSupportedFound =
288
- (options && options.skipCodecCheck) ||
289
- (url.indexOf(".mp3", url.length - 4) !== -1 && AbstractEngine.audioEngine.isMP3supported) ||
290
- (url.indexOf(".ogg", url.length - 4) !== -1 && AbstractEngine.audioEngine.isOGGsupported) ||
291
- url.indexOf(".wav", url.length - 4) !== -1 ||
292
- url.indexOf(".m4a", url.length - 4) !== -1 ||
293
- url.indexOf(".mp4", url.length - 4) !== -1 ||
294
- url.indexOf("blob:") !== -1;
295
- if (codecSupportedFound) {
296
- // Loading sound
297
- if (!this._streaming) {
298
- this._scene._loadFile(url, (data) => {
299
- this._soundLoaded(data);
300
- }, undefined, true, true, (exception) => {
301
- if (exception) {
302
- Logger.Error("XHR " + exception.status + " error on: " + url + ".");
303
- }
304
- Logger.Error("Sound creation aborted.");
305
- this._scene.mainSoundTrack.removeSound(this);
306
- });
307
- }
308
- // Streaming sound using HTML5 Audio tag
309
- else {
310
- this._htmlAudioElement = new Audio(url);
311
- this._htmlAudioElement.controls = false;
312
- this._htmlAudioElement.loop = this.loop;
313
- Tools.SetCorsBehavior(url, this._htmlAudioElement);
314
- this._htmlAudioElement.preload = "auto";
315
- this._htmlAudioElement.addEventListener("canplaythrough", () => {
316
- this._isReadyToPlay = true;
317
- if (this.autoplay) {
318
- this.play(0, this._offset, this._length);
319
- }
320
- if (this._readyToPlayCallback) {
321
- this._readyToPlayCallback();
322
- }
323
- }, { once: true });
324
- document.body.appendChild(this._htmlAudioElement);
325
- this._htmlAudioElement.load();
326
- }
327
- break;
328
- }
329
- }
330
- break;
331
- default:
332
- validParameter = false;
333
- break;
334
- }
335
- if (!validParameter) {
336
- Logger.Error("Parameter must be a URL to the sound, an Array of URLs (.mp3 & .ogg) or an ArrayBuffer of the sound.");
337
- }
338
- else {
339
- if (!codecSupportedFound) {
340
- this._isReadyToPlay = true;
341
- // Simulating a ready to play event to avoid breaking code path
342
- if (this._readyToPlayCallback) {
343
- setTimeout(() => {
344
- if (this._readyToPlayCallback) {
345
- this._readyToPlayCallback();
346
- }
347
- }, 1000);
348
- }
349
- }
350
- }
351
- }
352
- catch (ex) {
353
- Logger.Error("Unexpected error. Sound creation aborted.");
354
- this._scene.mainSoundTrack.removeSound(this);
355
- }
356
- }
357
- }
358
- else {
359
- // Adding an empty sound to avoid breaking audio calls for non Web Audio browsers
360
- this._scene.mainSoundTrack.addSound(this);
361
- if (AbstractEngine.audioEngine && !AbstractEngine.audioEngine.WarnedWebAudioUnsupported) {
362
- Logger.Error("Web Audio is not supported by your browser.");
363
- AbstractEngine.audioEngine.WarnedWebAudioUnsupported = true;
364
- }
365
- // Simulating a ready to play event to avoid breaking code for non web audio browsers
366
- if (this._readyToPlayCallback) {
367
- setTimeout(() => {
368
- if (this._readyToPlayCallback) {
369
- this._readyToPlayCallback();
370
- }
371
- }, 1000);
372
- }
373
- }
374
- }
375
- /**
376
- * Release the sound and its associated resources
377
- */
378
- dispose() {
379
- if (AbstractEngine.audioEngine?.canUseWebAudio) {
380
- if (this.isPlaying) {
381
- this.stop();
382
- }
383
- this._isReadyToPlay = false;
384
- if (this.soundTrackId === -1) {
385
- this._scene.mainSoundTrack.removeSound(this);
386
- }
387
- else if (this._scene.soundTracks) {
388
- this._scene.soundTracks[this.soundTrackId].removeSound(this);
389
- }
390
- if (this._soundGain) {
391
- this._soundGain.disconnect();
392
- this._soundGain = null;
393
- }
394
- if (this._soundPanner) {
395
- this._soundPanner.disconnect();
396
- this._soundPanner = null;
397
- }
398
- if (this._soundSource) {
399
- this._soundSource.disconnect();
400
- this._soundSource = null;
401
- }
402
- this._audioBuffer = null;
403
- if (this._htmlAudioElement) {
404
- this._htmlAudioElement.pause();
405
- this._htmlAudioElement.src = "";
406
- document.body.removeChild(this._htmlAudioElement);
407
- this._htmlAudioElement = null;
408
- }
409
- if (this._streamingSource) {
410
- this._streamingSource.disconnect();
411
- this._streamingSource = null;
412
- }
413
- if (this._connectedTransformNode && this._registerFunc) {
414
- this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
415
- this._connectedTransformNode = null;
416
- }
417
- this._clearTimeoutsAndObservers();
418
- }
419
- }
420
- /**
421
- * Gets if the sounds is ready to be played or not.
422
- * @returns true if ready, otherwise false
423
- */
424
- isReady() {
425
- return this._isReadyToPlay;
426
- }
427
- /**
428
- * Get the current class name.
429
- * @returns current class name
430
- */
431
- getClassName() {
432
- return "Sound";
433
- }
434
- _audioBufferLoaded(buffer) {
435
- if (!AbstractEngine.audioEngine?.audioContext) {
436
- return;
437
- }
438
- this._audioBuffer = buffer;
439
- this._isReadyToPlay = true;
440
- if (this.autoplay) {
441
- this.play(0, this._offset, this._length);
442
- }
443
- if (this._readyToPlayCallback) {
444
- this._readyToPlayCallback();
445
- }
446
- }
447
- _soundLoaded(audioData) {
448
- if (!AbstractEngine.audioEngine?.audioContext) {
449
- return;
450
- }
451
- AbstractEngine.audioEngine.audioContext.decodeAudioData(audioData, (buffer) => {
452
- this._audioBufferLoaded(buffer);
453
- }, (err) => {
454
- Logger.Error("Error while decoding audio data for: " + this.name + " / Error: " + err);
455
- });
456
- }
457
- /**
458
- * Sets the data of the sound from an audiobuffer
459
- * @param audioBuffer The audioBuffer containing the data
460
- */
461
- setAudioBuffer(audioBuffer) {
462
- if (AbstractEngine.audioEngine?.canUseWebAudio) {
463
- this._audioBuffer = audioBuffer;
464
- this._isReadyToPlay = true;
465
- }
466
- }
467
- /**
468
- * Updates the current sounds options such as maxdistance, loop...
469
- * @param options A JSON object containing values named as the object properties
470
- */
471
- updateOptions(options) {
472
- if (options) {
473
- this.loop = options.loop ?? this.loop;
474
- this.maxDistance = options.maxDistance ?? this.maxDistance;
475
- this.useCustomAttenuation = options.useCustomAttenuation ?? this.useCustomAttenuation;
476
- this.rolloffFactor = options.rolloffFactor ?? this.rolloffFactor;
477
- this.refDistance = options.refDistance ?? this.refDistance;
478
- this.distanceModel = options.distanceModel ?? this.distanceModel;
479
- this._playbackRate = options.playbackRate ?? this._playbackRate;
480
- this._length = options.length ?? undefined;
481
- this.spatialSound = options.spatialSound ?? this._spatialSound;
482
- this._setOffset(options.offset ?? undefined);
483
- this.setVolume(options.volume ?? this._volume);
484
- this._updateSpatialParameters();
485
- if (this.isPlaying) {
486
- if (this._streaming && this._htmlAudioElement) {
487
- this._htmlAudioElement.playbackRate = this._playbackRate;
488
- if (this._htmlAudioElement.loop !== this.loop) {
489
- this._htmlAudioElement.loop = this.loop;
490
- }
491
- }
492
- else {
493
- if (this._soundSource) {
494
- this._soundSource.playbackRate.value = this._playbackRate;
495
- if (this._soundSource.loop !== this.loop) {
496
- this._soundSource.loop = this.loop;
497
- }
498
- if (this._offset !== undefined && this._soundSource.loopStart !== this._offset) {
499
- this._soundSource.loopStart = this._offset;
500
- }
501
- if (this._length !== undefined && this._length !== this._soundSource.loopEnd) {
502
- this._soundSource.loopEnd = (this._offset | 0) + this._length;
503
- }
504
- }
505
- }
506
- }
507
- }
508
- }
509
- _createSpatialParameters() {
510
- if (AbstractEngine.audioEngine?.canUseWebAudio && AbstractEngine.audioEngine.audioContext) {
511
- if (this._scene.headphone) {
512
- this._panningModel = "HRTF";
513
- }
514
- this._soundPanner = this._soundPanner ?? AbstractEngine.audioEngine.audioContext.createPanner();
515
- if (this._soundPanner && this._outputAudioNode) {
516
- this._updateSpatialParameters();
517
- this._soundPanner.connect(this._outputAudioNode);
518
- this._inputAudioNode = this._soundPanner;
519
- }
520
- }
521
- }
522
- _disableSpatialSound() {
523
- if (!this._spatialSound) {
524
- return;
525
- }
526
- this._inputAudioNode = this._soundGain;
527
- this._soundPanner?.disconnect();
528
- this._soundPanner = null;
529
- this._spatialSound = false;
530
- }
531
- _updateSpatialParameters() {
532
- if (!this._spatialSound) {
533
- return;
534
- }
535
- if (this._soundPanner) {
536
- if (this.useCustomAttenuation) {
537
- // Tricks to disable in a way embedded Web Audio attenuation
538
- this._soundPanner.distanceModel = "linear";
539
- this._soundPanner.maxDistance = Number.MAX_VALUE;
540
- this._soundPanner.refDistance = 1;
541
- this._soundPanner.rolloffFactor = 1;
542
- this._soundPanner.panningModel = this._panningModel;
543
- }
544
- else {
545
- this._soundPanner.distanceModel = this.distanceModel;
546
- this._soundPanner.maxDistance = this.maxDistance;
547
- this._soundPanner.refDistance = this.refDistance;
548
- this._soundPanner.rolloffFactor = this.rolloffFactor;
549
- this._soundPanner.panningModel = this._panningModel;
550
- }
551
- }
552
- else {
553
- this._createSpatialParameters();
554
- }
555
- }
556
- /**
557
- * Switch the panning model to HRTF:
558
- * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
559
- * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound
560
- */
561
- switchPanningModelToHRTF() {
562
- this._panningModel = "HRTF";
563
- this._switchPanningModel();
564
- }
565
- /**
566
- * Switch the panning model to Equal Power:
567
- * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
568
- * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound
569
- */
570
- switchPanningModelToEqualPower() {
571
- this._panningModel = "equalpower";
572
- this._switchPanningModel();
573
- }
574
- _switchPanningModel() {
575
- if (AbstractEngine.audioEngine?.canUseWebAudio && this._spatialSound && this._soundPanner) {
576
- this._soundPanner.panningModel = this._panningModel;
577
- }
578
- }
579
- /**
580
- * Connect this sound to a sound track audio node like gain...
581
- * @param soundTrackAudioNode the sound track audio node to connect to
582
- */
583
- connectToSoundTrackAudioNode(soundTrackAudioNode) {
584
- if (AbstractEngine.audioEngine?.canUseWebAudio && this._outputAudioNode) {
585
- if (this._isOutputConnected) {
586
- this._outputAudioNode.disconnect();
587
- }
588
- this._outputAudioNode.connect(soundTrackAudioNode);
589
- this._isOutputConnected = true;
590
- }
591
- }
592
- /**
593
- * Transform this sound into a directional source
594
- * @param coneInnerAngle Size of the inner cone in degree
595
- * @param coneOuterAngle Size of the outer cone in degree
596
- * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
597
- */
598
- setDirectionalCone(coneInnerAngle, coneOuterAngle, coneOuterGain) {
599
- if (coneOuterAngle < coneInnerAngle) {
600
- Logger.Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.");
601
- return;
602
- }
603
- this._coneInnerAngle = coneInnerAngle;
604
- this._coneOuterAngle = coneOuterAngle;
605
- this._coneOuterGain = coneOuterGain;
606
- this._isDirectional = true;
607
- if (this.isPlaying && this.loop) {
608
- this.stop();
609
- this.play(0, this._offset, this._length);
610
- }
611
- }
612
- /**
613
- * Gets or sets the inner angle for the directional cone.
614
- */
615
- get directionalConeInnerAngle() {
616
- return this._coneInnerAngle;
617
- }
618
- /**
619
- * Gets or sets the inner angle for the directional cone.
620
- */
621
- set directionalConeInnerAngle(value) {
622
- if (value != this._coneInnerAngle) {
623
- if (this._coneOuterAngle < value) {
624
- Logger.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
625
- return;
626
- }
627
- this._coneInnerAngle = value;
628
- if (AbstractEngine.audioEngine?.canUseWebAudio && this._spatialSound && this._soundPanner) {
629
- this._soundPanner.coneInnerAngle = this._coneInnerAngle;
630
- }
631
- }
632
- }
633
- /**
634
- * Gets or sets the outer angle for the directional cone.
635
- */
636
- get directionalConeOuterAngle() {
637
- return this._coneOuterAngle;
638
- }
639
- /**
640
- * Gets or sets the outer angle for the directional cone.
641
- */
642
- set directionalConeOuterAngle(value) {
643
- if (value != this._coneOuterAngle) {
644
- if (value < this._coneInnerAngle) {
645
- Logger.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
646
- return;
647
- }
648
- this._coneOuterAngle = value;
649
- if (AbstractEngine.audioEngine?.canUseWebAudio && this._spatialSound && this._soundPanner) {
650
- this._soundPanner.coneOuterAngle = this._coneOuterAngle;
651
- }
652
- }
653
- }
654
- /**
655
- * Sets the position of the emitter if spatial sound is enabled
656
- * @param newPosition Defines the new position
657
- */
658
- setPosition(newPosition) {
659
- if (newPosition.equals(this._position)) {
660
- return;
661
- }
662
- this._position.copyFrom(newPosition);
663
- if (AbstractEngine.audioEngine?.canUseWebAudio &&
664
- this._spatialSound &&
665
- this._soundPanner &&
666
- !isNaN(this._position.x) &&
667
- !isNaN(this._position.y) &&
668
- !isNaN(this._position.z)) {
669
- this._soundPanner.positionX.value = this._position.x;
670
- this._soundPanner.positionY.value = this._position.y;
671
- this._soundPanner.positionZ.value = this._position.z;
672
- }
673
- }
674
- /**
675
- * Sets the local direction of the emitter if spatial sound is enabled
676
- * @param newLocalDirection Defines the new local direction
677
- */
678
- setLocalDirectionToMesh(newLocalDirection) {
679
- this._localDirection = newLocalDirection;
680
- if (AbstractEngine.audioEngine?.canUseWebAudio && this._connectedTransformNode && this.isPlaying) {
681
- this._updateDirection();
682
- }
683
- }
684
- _updateDirection() {
685
- if (!this._connectedTransformNode || !this._soundPanner) {
686
- return;
687
- }
688
- const mat = this._connectedTransformNode.getWorldMatrix();
689
- const direction = Vector3.TransformNormal(this._localDirection, mat);
690
- direction.normalize();
691
- this._soundPanner.orientationX.value = direction.x;
692
- this._soundPanner.orientationY.value = direction.y;
693
- this._soundPanner.orientationZ.value = direction.z;
694
- }
695
- /** @internal */
696
- updateDistanceFromListener() {
697
- if (AbstractEngine.audioEngine?.canUseWebAudio && this._connectedTransformNode && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) {
698
- const distance = this._scene.audioListenerPositionProvider
699
- ? this._connectedTransformNode.position.subtract(this._scene.audioListenerPositionProvider()).length()
700
- : this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);
701
- this._soundGain.gain.value = this._customAttenuationFunction(this._volume, distance, this.maxDistance, this.refDistance, this.rolloffFactor);
702
- }
703
- }
704
- /**
705
- * Sets a new custom attenuation function for the sound.
706
- * @param callback Defines the function used for the attenuation
707
- * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-your-own-custom-attenuation-function
708
- */
709
- setAttenuationFunction(callback) {
710
- this._customAttenuationFunction = callback;
711
- }
712
- /**
713
- * Play the sound
714
- * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
715
- * @param offset (optional) Start the sound at a specific time in seconds
716
- * @param length (optional) Sound duration (in seconds)
717
- */
718
- play(time, offset, length) {
719
- if (this._isReadyToPlay && this._scene.audioEnabled && AbstractEngine.audioEngine?.audioContext) {
720
- try {
721
- this._clearTimeoutsAndObservers();
722
- let startTime = time ? AbstractEngine.audioEngine?.audioContext.currentTime + time : AbstractEngine.audioEngine?.audioContext.currentTime;
723
- if (!this._soundSource || !this._streamingSource) {
724
- if (this._spatialSound && this._soundPanner) {
725
- if (!isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {
726
- this._soundPanner.positionX.value = this._position.x;
727
- this._soundPanner.positionY.value = this._position.y;
728
- this._soundPanner.positionZ.value = this._position.z;
729
- }
730
- if (this._isDirectional) {
731
- this._soundPanner.coneInnerAngle = this._coneInnerAngle;
732
- this._soundPanner.coneOuterAngle = this._coneOuterAngle;
733
- this._soundPanner.coneOuterGain = this._coneOuterGain;
734
- if (this._connectedTransformNode) {
735
- this._updateDirection();
736
- }
737
- else {
738
- this._soundPanner.setOrientation(this._localDirection.x, this._localDirection.y, this._localDirection.z);
739
- }
740
- }
741
- }
742
- }
743
- if (this._streaming) {
744
- if (!this._streamingSource && this._htmlAudioElement) {
745
- this._streamingSource = AbstractEngine.audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement);
746
- this._htmlAudioElement.onended = () => {
747
- this._onended();
748
- };
749
- this._htmlAudioElement.playbackRate = this._playbackRate;
750
- }
751
- if (this._streamingSource) {
752
- this._streamingSource.disconnect();
753
- if (this._inputAudioNode) {
754
- this._streamingSource.connect(this._inputAudioNode);
755
- }
756
- }
757
- if (this._htmlAudioElement) {
758
- // required to manage properly the new suspended default state of Chrome
759
- // When the option 'streaming: true' is used, we need first to wait for
760
- // the audio engine to be unlocked by a user gesture before trying to play
761
- // an HTML Audio element
762
- const tryToPlay = () => {
763
- if (AbstractEngine.audioEngine?.unlocked) {
764
- if (!this._htmlAudioElement) {
765
- return;
766
- }
767
- this._htmlAudioElement.currentTime = offset ?? 0;
768
- const playPromise = this._htmlAudioElement.play();
769
- // In browsers that don’t yet support this functionality,
770
- // playPromise won’t be defined.
771
- if (playPromise !== undefined) {
772
- playPromise.catch(() => {
773
- // Automatic playback failed.
774
- // Waiting for the audio engine to be unlocked by user click on unmute
775
- AbstractEngine.audioEngine?.lock();
776
- if (this.loop || this.autoplay) {
777
- this._audioUnlockedObserver = AbstractEngine.audioEngine?.onAudioUnlockedObservable.addOnce(() => {
778
- tryToPlay();
779
- });
780
- }
781
- });
782
- }
783
- }
784
- else {
785
- if (this.loop || this.autoplay) {
786
- this._audioUnlockedObserver = AbstractEngine.audioEngine?.onAudioUnlockedObservable.addOnce(() => {
787
- tryToPlay();
788
- });
789
- }
790
- }
791
- };
792
- tryToPlay();
793
- }
794
- }
795
- else {
796
- const tryToPlay = () => {
797
- if (AbstractEngine.audioEngine?.audioContext) {
798
- length = length || this._length;
799
- if (offset !== undefined) {
800
- this._setOffset(offset);
801
- }
802
- if (this._soundSource) {
803
- const oldSource = this._soundSource;
804
- oldSource.onended = () => {
805
- oldSource.disconnect();
806
- };
807
- }
808
- this._soundSource = AbstractEngine.audioEngine?.audioContext.createBufferSource();
809
- if (this._soundSource && this._inputAudioNode) {
810
- this._soundSource.buffer = this._audioBuffer;
811
- this._soundSource.connect(this._inputAudioNode);
812
- this._soundSource.loop = this.loop;
813
- if (offset !== undefined) {
814
- this._soundSource.loopStart = offset;
815
- }
816
- if (length !== undefined) {
817
- this._soundSource.loopEnd = (offset | 0) + length;
818
- }
819
- this._soundSource.playbackRate.value = this._playbackRate;
820
- this._soundSource.onended = () => {
821
- this._onended();
822
- };
823
- startTime = time ? AbstractEngine.audioEngine?.audioContext.currentTime + time : AbstractEngine.audioEngine.audioContext.currentTime;
824
- const actualOffset = ((this.isPaused ? this.currentTime : 0) + (this._offset ?? 0)) % this._soundSource.buffer.duration;
825
- this._soundSource.start(startTime, actualOffset, this.loop ? undefined : length);
826
- }
827
- }
828
- };
829
- if (AbstractEngine.audioEngine?.audioContext.state === "suspended") {
830
- // Wait a bit for FF as context seems late to be ready.
831
- this._tryToPlayTimeout = setTimeout(() => {
832
- if (AbstractEngine.audioEngine?.audioContext.state === "suspended") {
833
- // Automatic playback failed.
834
- // Waiting for the audio engine to be unlocked by user click on unmute
835
- AbstractEngine.audioEngine.lock();
836
- if (this.loop || this.autoplay) {
837
- this._audioUnlockedObserver = AbstractEngine.audioEngine.onAudioUnlockedObservable.addOnce(() => {
838
- tryToPlay();
839
- });
840
- }
841
- }
842
- else {
843
- tryToPlay();
844
- }
845
- }, 500);
846
- }
847
- else {
848
- tryToPlay();
849
- }
850
- }
851
- this._startTime = startTime;
852
- this.isPlaying = true;
853
- this.isPaused = false;
854
- }
855
- catch (ex) {
856
- Logger.Error("Error while trying to play audio: " + this.name + ", " + ex.message);
857
- }
858
- }
859
- }
860
- _onended() {
861
- this.isPlaying = false;
862
- this._startTime = 0;
863
- this._currentTime = 0;
864
- if (this.onended) {
865
- this.onended();
866
- }
867
- this.onEndedObservable.notifyObservers(this);
868
- }
869
- /**
870
- * Stop the sound
871
- * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
872
- */
873
- stop(time) {
874
- if (this.isPlaying) {
875
- this._clearTimeoutsAndObservers();
876
- if (this._streaming) {
877
- if (this._htmlAudioElement) {
878
- this._htmlAudioElement.pause();
879
- // Test needed for Firefox or it will generate an Invalid State Error
880
- if (this._htmlAudioElement.currentTime > 0) {
881
- this._htmlAudioElement.currentTime = 0;
882
- }
883
- }
884
- else {
885
- this._streamingSource?.disconnect();
886
- }
887
- this.isPlaying = false;
888
- }
889
- else if (AbstractEngine.audioEngine?.audioContext && this._soundSource) {
890
- const stopTime = time ? AbstractEngine.audioEngine.audioContext.currentTime + time : undefined;
891
- this._soundSource.onended = () => {
892
- this.isPlaying = false;
893
- this.isPaused = false;
894
- this._startTime = 0;
895
- this._currentTime = 0;
896
- if (this._soundSource) {
897
- this._soundSource.onended = () => void 0;
898
- }
899
- this._onended();
900
- };
901
- this._soundSource.stop(stopTime);
902
- }
903
- else {
904
- this.isPlaying = false;
905
- }
906
- }
907
- else if (this.isPaused) {
908
- this.isPaused = false;
909
- this._startTime = 0;
910
- this._currentTime = 0;
911
- }
912
- }
913
- /**
914
- * Put the sound in pause
915
- */
916
- pause() {
917
- if (this.isPlaying) {
918
- this._clearTimeoutsAndObservers();
919
- if (this._streaming) {
920
- if (this._htmlAudioElement) {
921
- this._htmlAudioElement.pause();
922
- }
923
- else {
924
- this._streamingSource?.disconnect();
925
- }
926
- this.isPlaying = false;
927
- this.isPaused = true;
928
- }
929
- else if (AbstractEngine.audioEngine?.audioContext && this._soundSource) {
930
- this._soundSource.onended = () => void 0;
931
- this._soundSource.stop();
932
- this.isPlaying = false;
933
- this.isPaused = true;
934
- this._currentTime += AbstractEngine.audioEngine.audioContext.currentTime - this._startTime;
935
- }
936
- }
937
- }
938
- /**
939
- * Sets a dedicated volume for this sounds
940
- * @param newVolume Define the new volume of the sound
941
- * @param time Define time for gradual change to new volume
942
- */
943
- setVolume(newVolume, time) {
944
- if (AbstractEngine.audioEngine?.canUseWebAudio && this._soundGain) {
945
- if (time && AbstractEngine.audioEngine.audioContext) {
946
- this._soundGain.gain.cancelScheduledValues(AbstractEngine.audioEngine.audioContext.currentTime);
947
- this._soundGain.gain.setValueAtTime(this._soundGain.gain.value, AbstractEngine.audioEngine.audioContext.currentTime);
948
- this._soundGain.gain.linearRampToValueAtTime(newVolume, AbstractEngine.audioEngine.audioContext.currentTime + time);
949
- }
950
- else {
951
- this._soundGain.gain.value = newVolume;
952
- }
953
- }
954
- this._volume = newVolume;
955
- }
956
- /**
957
- * Set the sound play back rate
958
- * @param newPlaybackRate Define the playback rate the sound should be played at
959
- */
960
- setPlaybackRate(newPlaybackRate) {
961
- this._playbackRate = newPlaybackRate;
962
- if (this.isPlaying) {
963
- if (this._streaming && this._htmlAudioElement) {
964
- this._htmlAudioElement.playbackRate = this._playbackRate;
965
- }
966
- else if (this._soundSource) {
967
- this._soundSource.playbackRate.value = this._playbackRate;
968
- }
969
- }
970
- }
971
- /**
972
- * Gets the sound play back rate.
973
- * @returns the play back rate of the sound
974
- */
975
- getPlaybackRate() {
976
- return this._playbackRate;
977
- }
978
- /**
979
- * Gets the volume of the sound.
980
- * @returns the volume of the sound
981
- */
982
- getVolume() {
983
- return this._volume;
984
- }
985
- /**
986
- * Attach the sound to a dedicated mesh
987
- * @param transformNode The transform node to connect the sound with
988
- * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#attaching-a-sound-to-a-mesh
989
- */
990
- attachToMesh(transformNode) {
991
- if (this._connectedTransformNode && this._registerFunc) {
992
- this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
993
- this._registerFunc = null;
994
- }
995
- this._connectedTransformNode = transformNode;
996
- if (!this._spatialSound) {
997
- this._spatialSound = true;
998
- this._createSpatialParameters();
999
- if (this.isPlaying && this.loop) {
1000
- this.stop();
1001
- this.play(0, this._offset, this._length);
1002
- }
1003
- }
1004
- this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode);
1005
- this._registerFunc = (transformNode) => this._onRegisterAfterWorldMatrixUpdate(transformNode);
1006
- this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc);
1007
- }
1008
- /**
1009
- * Detach the sound from the previously attached mesh
1010
- * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#attaching-a-sound-to-a-mesh
1011
- */
1012
- detachFromMesh() {
1013
- if (this._connectedTransformNode && this._registerFunc) {
1014
- this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
1015
- this._registerFunc = null;
1016
- this._connectedTransformNode = null;
1017
- }
1018
- }
1019
- _onRegisterAfterWorldMatrixUpdate(node) {
1020
- if (!node.getBoundingInfo) {
1021
- this.setPosition(node.absolutePosition);
1022
- }
1023
- else {
1024
- const mesh = node;
1025
- const boundingInfo = mesh.getBoundingInfo();
1026
- this.setPosition(boundingInfo.boundingSphere.centerWorld);
1027
- }
1028
- if (AbstractEngine.audioEngine?.canUseWebAudio && this._isDirectional && this.isPlaying) {
1029
- this._updateDirection();
1030
- }
1031
- }
1032
- /**
1033
- * Clone the current sound in the scene.
1034
- * @returns the new sound clone
1035
- */
1036
- clone() {
1037
- if (!this._streaming) {
1038
- const setBufferAndRun = () => {
1039
- _retryWithInterval(() => this._isReadyToPlay, () => {
1040
- clonedSound._audioBuffer = this.getAudioBuffer();
1041
- clonedSound._isReadyToPlay = true;
1042
- if (clonedSound.autoplay) {
1043
- clonedSound.play(0, this._offset, this._length);
1044
- }
1045
- }, undefined, 300);
1046
- };
1047
- const currentOptions = {
1048
- autoplay: this.autoplay,
1049
- loop: this.loop,
1050
- volume: this._volume,
1051
- spatialSound: this._spatialSound,
1052
- maxDistance: this.maxDistance,
1053
- useCustomAttenuation: this.useCustomAttenuation,
1054
- rolloffFactor: this.rolloffFactor,
1055
- refDistance: this.refDistance,
1056
- distanceModel: this.distanceModel,
1057
- };
1058
- const clonedSound = new Sound(this.name + "_cloned", new ArrayBuffer(0), this._scene, null, currentOptions);
1059
- if (this.useCustomAttenuation) {
1060
- clonedSound.setAttenuationFunction(this._customAttenuationFunction);
1061
- }
1062
- clonedSound.setPosition(this._position);
1063
- clonedSound.setPlaybackRate(this._playbackRate);
1064
- setBufferAndRun();
1065
- return clonedSound;
1066
- }
1067
- // Can't clone a streaming sound
1068
- else {
1069
- return null;
1070
- }
1071
- }
1072
- /**
1073
- * Gets the current underlying audio buffer containing the data
1074
- * @returns the audio buffer
1075
- */
1076
- getAudioBuffer() {
1077
- return this._audioBuffer;
1078
- }
1079
- /**
1080
- * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
1081
- * @returns the source node
1082
- */
1083
- getSoundSource() {
1084
- return this._soundSource;
1085
- }
1086
- /**
1087
- * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
1088
- * @returns the gain node
1089
- */
1090
- getSoundGain() {
1091
- return this._soundGain;
1092
- }
1093
- /**
1094
- * Serializes the Sound in a JSON representation
1095
- * @returns the JSON representation of the sound
1096
- */
1097
- serialize() {
1098
- const serializationObject = {
1099
- name: this.name,
1100
- url: this._url,
1101
- autoplay: this.autoplay,
1102
- loop: this.loop,
1103
- volume: this._volume,
1104
- spatialSound: this._spatialSound,
1105
- maxDistance: this.maxDistance,
1106
- rolloffFactor: this.rolloffFactor,
1107
- refDistance: this.refDistance,
1108
- distanceModel: this.distanceModel,
1109
- playbackRate: this._playbackRate,
1110
- panningModel: this._panningModel,
1111
- soundTrackId: this.soundTrackId,
1112
- metadata: this.metadata,
1113
- };
1114
- if (this._spatialSound) {
1115
- if (this._connectedTransformNode) {
1116
- serializationObject.connectedMeshId = this._connectedTransformNode.id;
1117
- }
1118
- serializationObject.position = this._position.asArray();
1119
- serializationObject.refDistance = this.refDistance;
1120
- serializationObject.distanceModel = this.distanceModel;
1121
- serializationObject.isDirectional = this._isDirectional;
1122
- serializationObject.localDirectionToMesh = this._localDirection.asArray();
1123
- serializationObject.coneInnerAngle = this._coneInnerAngle;
1124
- serializationObject.coneOuterAngle = this._coneOuterAngle;
1125
- serializationObject.coneOuterGain = this._coneOuterGain;
1126
- }
1127
- return serializationObject;
1128
- }
1129
- /**
1130
- * Parse a JSON representation of a sound to instantiate in a given scene
1131
- * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
1132
- * @param scene Define the scene the new parsed sound should be created in
1133
- * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
1134
- * @param sourceSound Define a sound place holder if do not need to instantiate a new one
1135
- * @returns the newly parsed sound
1136
- */
1137
- static Parse(parsedSound, scene, rootUrl, sourceSound) {
1138
- const soundName = parsedSound.name;
1139
- let soundUrl;
1140
- if (parsedSound.url) {
1141
- soundUrl = rootUrl + parsedSound.url;
1142
- }
1143
- else {
1144
- soundUrl = rootUrl + soundName;
1145
- }
1146
- const options = {
1147
- autoplay: parsedSound.autoplay,
1148
- loop: parsedSound.loop,
1149
- volume: parsedSound.volume,
1150
- spatialSound: parsedSound.spatialSound,
1151
- maxDistance: parsedSound.maxDistance,
1152
- rolloffFactor: parsedSound.rolloffFactor,
1153
- refDistance: parsedSound.refDistance,
1154
- distanceModel: parsedSound.distanceModel,
1155
- playbackRate: parsedSound.playbackRate,
1156
- };
1157
- let newSound;
1158
- if (!sourceSound) {
1159
- newSound = new Sound(soundName, soundUrl, scene, () => {
1160
- scene.removePendingData(newSound);
1161
- }, options);
1162
- scene.addPendingData(newSound);
1163
- }
1164
- else {
1165
- const setBufferAndRun = () => {
1166
- _retryWithInterval(() => sourceSound._isReadyToPlay, () => {
1167
- newSound._audioBuffer = sourceSound.getAudioBuffer();
1168
- newSound._isReadyToPlay = true;
1169
- if (newSound.autoplay) {
1170
- newSound.play(0, newSound._offset, newSound._length);
1171
- }
1172
- }, undefined, 300);
1173
- };
1174
- newSound = new Sound(soundName, new ArrayBuffer(0), scene, null, options);
1175
- setBufferAndRun();
1176
- }
1177
- if (parsedSound.position) {
1178
- const soundPosition = Vector3.FromArray(parsedSound.position);
1179
- newSound.setPosition(soundPosition);
1180
- }
1181
- if (parsedSound.isDirectional) {
1182
- newSound.setDirectionalCone(parsedSound.coneInnerAngle || 360, parsedSound.coneOuterAngle || 360, parsedSound.coneOuterGain || 0);
1183
- if (parsedSound.localDirectionToMesh) {
1184
- const localDirectionToMesh = Vector3.FromArray(parsedSound.localDirectionToMesh);
1185
- newSound.setLocalDirectionToMesh(localDirectionToMesh);
1186
- }
1187
- }
1188
- if (parsedSound.connectedMeshId) {
1189
- const connectedMesh = scene.getMeshById(parsedSound.connectedMeshId);
1190
- if (connectedMesh) {
1191
- newSound.attachToMesh(connectedMesh);
1192
- }
1193
- }
1194
- if (parsedSound.metadata) {
1195
- newSound.metadata = parsedSound.metadata;
1196
- }
1197
- return newSound;
1198
- }
1199
- _setOffset(value) {
1200
- if (this._offset === value) {
1201
- return;
1202
- }
1203
- if (this.isPaused) {
1204
- this.stop();
1205
- this.isPaused = false;
1206
- }
1207
- this._offset = value;
1208
- }
1209
- _clearTimeoutsAndObservers() {
1210
- if (this._tryToPlayTimeout) {
1211
- clearTimeout(this._tryToPlayTimeout);
1212
- this._tryToPlayTimeout = null;
1213
- }
1214
- if (this._audioUnlockedObserver) {
1215
- AbstractEngine.audioEngine?.onAudioUnlockedObservable.remove(this._audioUnlockedObserver);
1216
- this._audioUnlockedObserver = null;
1217
- }
1218
- }
1219
- }
1220
- /**
1221
- * @internal
1222
- */
1223
- Sound._SceneComponentInitialization = (_) => {
1224
- throw _WarnImport("AudioSceneComponent");
1225
- };
1226
- // Register Class Name
1227
- RegisterClass("BABYLON.Sound", Sound);
1228
-
1229
- /**
1230
- * Wraps one or more Sound objects and selects one with random weight for playback.
1231
- */
1232
- class WeightedSound {
1233
- /**
1234
- * Creates a new WeightedSound from the list of sounds given.
1235
- * @param loop When true a Sound will be selected and played when the current playing Sound completes.
1236
- * @param sounds Array of Sounds that will be selected from.
1237
- * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
1238
- */
1239
- constructor(loop, sounds, weights) {
1240
- /** When true a Sound will be selected and played when the current playing Sound completes. */
1241
- this.loop = false;
1242
- this._coneInnerAngle = 360;
1243
- this._coneOuterAngle = 360;
1244
- this._volume = 1;
1245
- /** A Sound is currently playing. */
1246
- this.isPlaying = false;
1247
- /** A Sound is currently paused. */
1248
- this.isPaused = false;
1249
- this._sounds = [];
1250
- this._weights = [];
1251
- if (sounds.length !== weights.length) {
1252
- throw new Error("Sounds length does not equal weights length");
1253
- }
1254
- this.loop = loop;
1255
- this._weights = weights;
1256
- // Normalize the weights
1257
- let weightSum = 0;
1258
- for (const weight of weights) {
1259
- weightSum += weight;
1260
- }
1261
- const invWeightSum = weightSum > 0 ? 1 / weightSum : 0;
1262
- for (let i = 0; i < this._weights.length; i++) {
1263
- this._weights[i] *= invWeightSum;
1264
- }
1265
- this._sounds = sounds;
1266
- for (const sound of this._sounds) {
1267
- sound.onEndedObservable.add(() => {
1268
- this._onended();
1269
- });
1270
- }
1271
- }
1272
- /**
1273
- * The size of cone in degrees for a directional sound in which there will be no attenuation.
1274
- */
1275
- get directionalConeInnerAngle() {
1276
- return this._coneInnerAngle;
1277
- }
1278
- /**
1279
- * The size of cone in degrees for a directional sound in which there will be no attenuation.
1280
- */
1281
- set directionalConeInnerAngle(value) {
1282
- if (value !== this._coneInnerAngle) {
1283
- if (this._coneOuterAngle < value) {
1284
- Logger.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
1285
- return;
1286
- }
1287
- this._coneInnerAngle = value;
1288
- for (const sound of this._sounds) {
1289
- sound.directionalConeInnerAngle = value;
1290
- }
1291
- }
1292
- }
1293
- /**
1294
- * Size of cone in degrees for a directional sound outside of which there will be no sound.
1295
- * Listener angles between innerAngle and outerAngle will falloff linearly.
1296
- */
1297
- get directionalConeOuterAngle() {
1298
- return this._coneOuterAngle;
1299
- }
1300
- /**
1301
- * Size of cone in degrees for a directional sound outside of which there will be no sound.
1302
- * Listener angles between innerAngle and outerAngle will falloff linearly.
1303
- */
1304
- set directionalConeOuterAngle(value) {
1305
- if (value !== this._coneOuterAngle) {
1306
- if (value < this._coneInnerAngle) {
1307
- Logger.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
1308
- return;
1309
- }
1310
- this._coneOuterAngle = value;
1311
- for (const sound of this._sounds) {
1312
- sound.directionalConeOuterAngle = value;
1313
- }
1314
- }
1315
- }
1316
- /**
1317
- * Playback volume.
1318
- */
1319
- get volume() {
1320
- return this._volume;
1321
- }
1322
- /**
1323
- * Playback volume.
1324
- */
1325
- set volume(value) {
1326
- if (value !== this._volume) {
1327
- for (const sound of this._sounds) {
1328
- sound.setVolume(value);
1329
- }
1330
- }
1331
- }
1332
- _onended() {
1333
- if (this._currentIndex !== undefined) {
1334
- this._sounds[this._currentIndex].autoplay = false;
1335
- }
1336
- if (this.loop && this.isPlaying) {
1337
- this.play();
1338
- }
1339
- else {
1340
- this.isPlaying = false;
1341
- }
1342
- }
1343
- /**
1344
- * Suspend playback
1345
- */
1346
- pause() {
1347
- if (this.isPlaying) {
1348
- this.isPaused = true;
1349
- if (this._currentIndex !== undefined) {
1350
- this._sounds[this._currentIndex].pause();
1351
- }
1352
- }
1353
- }
1354
- /**
1355
- * Stop playback
1356
- */
1357
- stop() {
1358
- this.isPlaying = false;
1359
- if (this._currentIndex !== undefined) {
1360
- this._sounds[this._currentIndex].stop();
1361
- }
1362
- }
1363
- /**
1364
- * Start playback.
1365
- * @param startOffset Position the clip head at a specific time in seconds.
1366
- */
1367
- play(startOffset) {
1368
- if (!this.isPaused) {
1369
- this.stop();
1370
- const randomValue = Math.random();
1371
- let total = 0;
1372
- for (let i = 0; i < this._weights.length; i++) {
1373
- total += this._weights[i];
1374
- if (randomValue <= total) {
1375
- this._currentIndex = i;
1376
- break;
1377
- }
1378
- }
1379
- }
1380
- const sound = this._sounds[this._currentIndex ?? 0];
1381
- if (sound.isReady()) {
1382
- sound.play(0, this.isPaused ? undefined : startOffset);
1383
- }
1384
- else {
1385
- sound.autoplay = true;
1386
- }
1387
- this.isPlaying = true;
1388
- this.isPaused = false;
1389
- }
1390
- }
1391
-
1392
- /**
1393
- * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
1394
- * It will be also used in a future release to apply effects on a specific track.
1395
- * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#using-sound-tracks
1396
- */
1397
- class SoundTrack {
1398
- /**
1399
- * Creates a new sound track.
1400
- * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#using-sound-tracks
1401
- * @param scene Define the scene the sound track belongs to
1402
- * @param options
1403
- */
1404
- constructor(scene, options = {}) {
1405
- /**
1406
- * The unique identifier of the sound track in the scene.
1407
- */
1408
- this.id = -1;
1409
- this._isInitialized = false;
1410
- scene = scene || EngineStore.LastCreatedScene;
1411
- if (!scene) {
1412
- return;
1413
- }
1414
- this._scene = scene;
1415
- this.soundCollection = [];
1416
- this._options = options;
1417
- if (!this._options.mainTrack && this._scene.soundTracks) {
1418
- this._scene.soundTracks.push(this);
1419
- this.id = this._scene.soundTracks.length - 1;
1420
- }
1421
- }
1422
- _initializeSoundTrackAudioGraph() {
1423
- if (AbstractEngine.audioEngine?.canUseWebAudio && AbstractEngine.audioEngine.audioContext) {
1424
- this._outputAudioNode = AbstractEngine.audioEngine.audioContext.createGain();
1425
- this._outputAudioNode.connect(AbstractEngine.audioEngine.masterGain);
1426
- if (this._options) {
1427
- if (this._options.volume) {
1428
- this._outputAudioNode.gain.value = this._options.volume;
1429
- }
1430
- }
1431
- this._isInitialized = true;
1432
- }
1433
- }
1434
- /**
1435
- * Release the sound track and its associated resources
1436
- */
1437
- dispose() {
1438
- if (AbstractEngine.audioEngine && AbstractEngine.audioEngine.canUseWebAudio) {
1439
- if (this._connectedAnalyser) {
1440
- this._connectedAnalyser.stopDebugCanvas();
1441
- }
1442
- while (this.soundCollection.length) {
1443
- this.soundCollection[0].dispose();
1444
- }
1445
- if (this._outputAudioNode) {
1446
- this._outputAudioNode.disconnect();
1447
- }
1448
- this._outputAudioNode = null;
1449
- }
1450
- }
1451
- /**
1452
- * Adds a sound to this sound track
1453
- * @param sound define the sound to add
1454
- * @ignoreNaming
1455
- */
1456
- addSound(sound) {
1457
- if (!this._isInitialized) {
1458
- this._initializeSoundTrackAudioGraph();
1459
- }
1460
- if (AbstractEngine.audioEngine?.canUseWebAudio && this._outputAudioNode) {
1461
- sound.connectToSoundTrackAudioNode(this._outputAudioNode);
1462
- }
1463
- if (sound.soundTrackId !== undefined) {
1464
- if (sound.soundTrackId === -1) {
1465
- this._scene.mainSoundTrack.removeSound(sound);
1466
- }
1467
- else if (this._scene.soundTracks) {
1468
- this._scene.soundTracks[sound.soundTrackId].removeSound(sound);
1469
- }
1470
- }
1471
- this.soundCollection.push(sound);
1472
- sound.soundTrackId = this.id;
1473
- }
1474
- /**
1475
- * Removes a sound to this sound track
1476
- * @param sound define the sound to remove
1477
- * @ignoreNaming
1478
- */
1479
- removeSound(sound) {
1480
- const index = this.soundCollection.indexOf(sound);
1481
- if (index !== -1) {
1482
- this.soundCollection.splice(index, 1);
1483
- }
1484
- }
1485
- /**
1486
- * Set a global volume for the full sound track.
1487
- * @param newVolume Define the new volume of the sound track
1488
- */
1489
- setVolume(newVolume) {
1490
- if (AbstractEngine.audioEngine?.canUseWebAudio && this._outputAudioNode) {
1491
- this._outputAudioNode.gain.value = newVolume;
1492
- }
1493
- }
1494
- /**
1495
- * Switch the panning model to HRTF:
1496
- * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
1497
- * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound
1498
- */
1499
- switchPanningModelToHRTF() {
1500
- if (AbstractEngine.audioEngine?.canUseWebAudio) {
1501
- for (let i = 0; i < this.soundCollection.length; i++) {
1502
- this.soundCollection[i].switchPanningModelToHRTF();
1503
- }
1504
- }
1505
- }
1506
- /**
1507
- * Switch the panning model to Equal Power:
1508
- * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
1509
- * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound
1510
- */
1511
- switchPanningModelToEqualPower() {
1512
- if (AbstractEngine.audioEngine?.canUseWebAudio) {
1513
- for (let i = 0; i < this.soundCollection.length; i++) {
1514
- this.soundCollection[i].switchPanningModelToEqualPower();
1515
- }
1516
- }
1517
- }
1518
- /**
1519
- * Connect the sound track to an audio analyser allowing some amazing
1520
- * synchronization between the sounds/music and your visualization (VuMeter for instance).
1521
- * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#using-the-analyser
1522
- * @param analyser The analyser to connect to the engine
1523
- */
1524
- connectToAnalyser(analyser) {
1525
- if (this._connectedAnalyser) {
1526
- this._connectedAnalyser.stopDebugCanvas();
1527
- }
1528
- this._connectedAnalyser = analyser;
1529
- if (AbstractEngine.audioEngine?.canUseWebAudio && this._outputAudioNode) {
1530
- this._outputAudioNode.disconnect();
1531
- this._connectedAnalyser.connectAudioNodes(this._outputAudioNode, AbstractEngine.audioEngine.masterGain);
1532
- }
1533
- }
1534
- }
1535
-
1536
- Object.defineProperty(Scene.prototype, "mainSoundTrack", {
1537
- get: function () {
1538
- let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO);
1539
- if (!compo) {
1540
- compo = new AudioSceneComponent(this);
1541
- this._addComponent(compo);
1542
- }
1543
- if (!this._mainSoundTrack) {
1544
- this._mainSoundTrack = new SoundTrack(this, { mainTrack: true });
1545
- }
1546
- return this._mainSoundTrack;
1547
- },
1548
- enumerable: true,
1549
- configurable: true,
1550
- });
1551
- Scene.prototype.getSoundByName = function (name) {
1552
- let index;
1553
- for (index = 0; index < this.mainSoundTrack.soundCollection.length; index++) {
1554
- if (this.mainSoundTrack.soundCollection[index].name === name) {
1555
- return this.mainSoundTrack.soundCollection[index];
1556
- }
1557
- }
1558
- if (this.soundTracks) {
1559
- for (let sdIndex = 0; sdIndex < this.soundTracks.length; sdIndex++) {
1560
- for (index = 0; index < this.soundTracks[sdIndex].soundCollection.length; index++) {
1561
- if (this.soundTracks[sdIndex].soundCollection[index].name === name) {
1562
- return this.soundTracks[sdIndex].soundCollection[index];
1563
- }
1564
- }
1565
- }
1566
- }
1567
- return null;
1568
- };
1569
- Object.defineProperty(Scene.prototype, "audioEnabled", {
1570
- get: function () {
1571
- let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO);
1572
- if (!compo) {
1573
- compo = new AudioSceneComponent(this);
1574
- this._addComponent(compo);
1575
- }
1576
- return compo.audioEnabled;
1577
- },
1578
- set: function (value) {
1579
- let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO);
1580
- if (!compo) {
1581
- compo = new AudioSceneComponent(this);
1582
- this._addComponent(compo);
1583
- }
1584
- if (value) {
1585
- compo.enableAudio();
1586
- }
1587
- else {
1588
- compo.disableAudio();
1589
- }
1590
- },
1591
- enumerable: true,
1592
- configurable: true,
1593
- });
1594
- Object.defineProperty(Scene.prototype, "headphone", {
1595
- get: function () {
1596
- let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO);
1597
- if (!compo) {
1598
- compo = new AudioSceneComponent(this);
1599
- this._addComponent(compo);
1600
- }
1601
- return compo.headphone;
1602
- },
1603
- set: function (value) {
1604
- let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO);
1605
- if (!compo) {
1606
- compo = new AudioSceneComponent(this);
1607
- this._addComponent(compo);
1608
- }
1609
- if (value) {
1610
- compo.switchAudioModeForHeadphones();
1611
- }
1612
- else {
1613
- compo.switchAudioModeForNormalSpeakers();
1614
- }
1615
- },
1616
- enumerable: true,
1617
- configurable: true,
1618
- });
1619
- Object.defineProperty(Scene.prototype, "audioListenerPositionProvider", {
1620
- get: function () {
1621
- let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO);
1622
- if (!compo) {
1623
- compo = new AudioSceneComponent(this);
1624
- this._addComponent(compo);
1625
- }
1626
- return compo.audioListenerPositionProvider;
1627
- },
1628
- set: function (value) {
1629
- let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO);
1630
- if (!compo) {
1631
- compo = new AudioSceneComponent(this);
1632
- this._addComponent(compo);
1633
- }
1634
- if (value && typeof value !== "function") {
1635
- throw new Error("The value passed to [Scene.audioListenerPositionProvider] must be a function that returns a Vector3");
1636
- }
1637
- else {
1638
- compo.audioListenerPositionProvider = value;
1639
- }
1640
- },
1641
- enumerable: true,
1642
- configurable: true,
1643
- });
1644
- Object.defineProperty(Scene.prototype, "audioListenerRotationProvider", {
1645
- get: function () {
1646
- let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO);
1647
- if (!compo) {
1648
- compo = new AudioSceneComponent(this);
1649
- this._addComponent(compo);
1650
- }
1651
- return compo.audioListenerRotationProvider;
1652
- },
1653
- set: function (value) {
1654
- let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO);
1655
- if (!compo) {
1656
- compo = new AudioSceneComponent(this);
1657
- this._addComponent(compo);
1658
- }
1659
- if (value && typeof value !== "function") {
1660
- throw new Error("The value passed to [Scene.audioListenerRotationProvider] must be a function that returns a Vector3");
1661
- }
1662
- else {
1663
- compo.audioListenerRotationProvider = value;
1664
- }
1665
- },
1666
- enumerable: true,
1667
- configurable: true,
1668
- });
1669
- Object.defineProperty(Scene.prototype, "audioPositioningRefreshRate", {
1670
- get: function () {
1671
- let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO);
1672
- if (!compo) {
1673
- compo = new AudioSceneComponent(this);
1674
- this._addComponent(compo);
1675
- }
1676
- return compo.audioPositioningRefreshRate;
1677
- },
1678
- set: function (value) {
1679
- let compo = this._getComponent(SceneComponentConstants.NAME_AUDIO);
1680
- if (!compo) {
1681
- compo = new AudioSceneComponent(this);
1682
- this._addComponent(compo);
1683
- }
1684
- compo.audioPositioningRefreshRate = value;
1685
- },
1686
- enumerable: true,
1687
- configurable: true,
1688
- });
1689
- /**
1690
- * Defines the sound scene component responsible to manage any sounds
1691
- * in a given scene.
1692
- */
1693
- class AudioSceneComponent {
1694
- /**
1695
- * Gets whether audio is enabled or not.
1696
- * Please use related enable/disable method to switch state.
1697
- */
1698
- get audioEnabled() {
1699
- return this._audioEnabled;
1700
- }
1701
- /**
1702
- * Gets whether audio is outputting to headphone or not.
1703
- * Please use the according Switch methods to change output.
1704
- */
1705
- get headphone() {
1706
- return this._headphone;
1707
- }
1708
- /**
1709
- * Creates a new instance of the component for the given scene
1710
- * @param scene Defines the scene to register the component in
1711
- */
1712
- constructor(scene) {
1713
- /**
1714
- * The component name helpful to identify the component in the list of scene components.
1715
- */
1716
- this.name = SceneComponentConstants.NAME_AUDIO;
1717
- this._audioEnabled = true;
1718
- this._headphone = false;
1719
- /**
1720
- * Gets or sets a refresh rate when using 3D audio positioning
1721
- */
1722
- this.audioPositioningRefreshRate = 500;
1723
- /**
1724
- * Gets or Sets a custom listener position for all sounds in the scene
1725
- * By default, this is the position of the first active camera
1726
- */
1727
- this.audioListenerPositionProvider = null;
1728
- /**
1729
- * Gets or Sets a custom listener rotation for all sounds in the scene
1730
- * By default, this is the rotation of the first active camera
1731
- */
1732
- this.audioListenerRotationProvider = null;
1733
- this._cachedCameraDirection = new Vector3();
1734
- this._cachedCameraPosition = new Vector3();
1735
- this._lastCheck = 0;
1736
- this._invertMatrixTemp = new Matrix();
1737
- this._cameraDirectionTemp = new Vector3();
1738
- scene = scene || EngineStore.LastCreatedScene;
1739
- if (!scene) {
1740
- return;
1741
- }
1742
- this.scene = scene;
1743
- scene.soundTracks = [];
1744
- scene.sounds = [];
1745
- }
1746
- /**
1747
- * Registers the component in a given scene
1748
- */
1749
- register() {
1750
- this.scene._afterRenderStage.registerStep(SceneComponentConstants.STEP_AFTERRENDER_AUDIO, this, this._afterRender);
1751
- }
1752
- /**
1753
- * Rebuilds the elements related to this component in case of
1754
- * context lost for instance.
1755
- */
1756
- rebuild() {
1757
- // Nothing to do here. (Not rendering related)
1758
- }
1759
- /**
1760
- * Serializes the component data to the specified json object
1761
- * @param serializationObject The object to serialize to
1762
- */
1763
- serialize(serializationObject) {
1764
- serializationObject.sounds = [];
1765
- if (this.scene.soundTracks) {
1766
- for (let index = 0; index < this.scene.soundTracks.length; index++) {
1767
- const soundtrack = this.scene.soundTracks[index];
1768
- for (let soundId = 0; soundId < soundtrack.soundCollection.length; soundId++) {
1769
- serializationObject.sounds.push(soundtrack.soundCollection[soundId].serialize());
1770
- }
1771
- }
1772
- }
1773
- }
1774
- /**
1775
- * Adds all the elements from the container to the scene
1776
- * @param container the container holding the elements
1777
- */
1778
- addFromContainer(container) {
1779
- if (!container.sounds) {
1780
- return;
1781
- }
1782
- container.sounds.forEach((sound) => {
1783
- sound.play();
1784
- sound.autoplay = true;
1785
- this.scene.mainSoundTrack.addSound(sound);
1786
- });
1787
- }
1788
- /**
1789
- * Removes all the elements in the container from the scene
1790
- * @param container contains the elements to remove
1791
- * @param dispose if the removed element should be disposed (default: false)
1792
- */
1793
- removeFromContainer(container, dispose = false) {
1794
- if (!container.sounds) {
1795
- return;
1796
- }
1797
- container.sounds.forEach((sound) => {
1798
- sound.stop();
1799
- sound.autoplay = false;
1800
- this.scene.mainSoundTrack.removeSound(sound);
1801
- if (dispose) {
1802
- sound.dispose();
1803
- }
1804
- });
1805
- }
1806
- /**
1807
- * Disposes the component and the associated resources.
1808
- */
1809
- dispose() {
1810
- const scene = this.scene;
1811
- if (scene._mainSoundTrack) {
1812
- scene.mainSoundTrack.dispose();
1813
- }
1814
- if (scene.soundTracks) {
1815
- for (let scIndex = 0; scIndex < scene.soundTracks.length; scIndex++) {
1816
- scene.soundTracks[scIndex].dispose();
1817
- }
1818
- }
1819
- }
1820
- /**
1821
- * Disables audio in the associated scene.
1822
- */
1823
- disableAudio() {
1824
- const scene = this.scene;
1825
- this._audioEnabled = false;
1826
- if (AbstractEngine.audioEngine && AbstractEngine.audioEngine.audioContext) {
1827
- AbstractEngine.audioEngine.audioContext.suspend();
1828
- }
1829
- let i;
1830
- for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
1831
- scene.mainSoundTrack.soundCollection[i].pause();
1832
- }
1833
- if (scene.soundTracks) {
1834
- for (i = 0; i < scene.soundTracks.length; i++) {
1835
- for (let j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
1836
- scene.soundTracks[i].soundCollection[j].pause();
1837
- }
1838
- }
1839
- }
1840
- }
1841
- /**
1842
- * Enables audio in the associated scene.
1843
- */
1844
- enableAudio() {
1845
- const scene = this.scene;
1846
- this._audioEnabled = true;
1847
- if (AbstractEngine.audioEngine && AbstractEngine.audioEngine.audioContext) {
1848
- AbstractEngine.audioEngine.audioContext.resume();
1849
- }
1850
- let i;
1851
- for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
1852
- if (scene.mainSoundTrack.soundCollection[i].isPaused) {
1853
- scene.mainSoundTrack.soundCollection[i].play();
1854
- }
1855
- }
1856
- if (scene.soundTracks) {
1857
- for (i = 0; i < scene.soundTracks.length; i++) {
1858
- for (let j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
1859
- if (scene.soundTracks[i].soundCollection[j].isPaused) {
1860
- scene.soundTracks[i].soundCollection[j].play();
1861
- }
1862
- }
1863
- }
1864
- }
1865
- }
1866
- /**
1867
- * Switch audio to headphone output.
1868
- */
1869
- switchAudioModeForHeadphones() {
1870
- const scene = this.scene;
1871
- this._headphone = true;
1872
- scene.mainSoundTrack.switchPanningModelToHRTF();
1873
- if (scene.soundTracks) {
1874
- for (let i = 0; i < scene.soundTracks.length; i++) {
1875
- scene.soundTracks[i].switchPanningModelToHRTF();
1876
- }
1877
- }
1878
- }
1879
- /**
1880
- * Switch audio to normal speakers.
1881
- */
1882
- switchAudioModeForNormalSpeakers() {
1883
- const scene = this.scene;
1884
- this._headphone = false;
1885
- scene.mainSoundTrack.switchPanningModelToEqualPower();
1886
- if (scene.soundTracks) {
1887
- for (let i = 0; i < scene.soundTracks.length; i++) {
1888
- scene.soundTracks[i].switchPanningModelToEqualPower();
1889
- }
1890
- }
1891
- }
1892
- _afterRender() {
1893
- const now = PrecisionDate.Now;
1894
- if (this._lastCheck && now - this._lastCheck < this.audioPositioningRefreshRate) {
1895
- return;
1896
- }
1897
- this._lastCheck = now;
1898
- const scene = this.scene;
1899
- if (!this._audioEnabled || !scene._mainSoundTrack || !scene.soundTracks || (scene._mainSoundTrack.soundCollection.length === 0 && scene.soundTracks.length === 1)) {
1900
- return;
1901
- }
1902
- const audioEngine = AbstractEngine.audioEngine;
1903
- if (!audioEngine) {
1904
- return;
1905
- }
1906
- if (audioEngine.audioContext) {
1907
- let listeningCamera = scene.activeCamera;
1908
- if (scene.activeCameras && scene.activeCameras.length > 0) {
1909
- listeningCamera = scene.activeCameras[0];
1910
- }
1911
- // A custom listener position provider was set
1912
- // Use the users provided position instead of camera's
1913
- if (this.audioListenerPositionProvider) {
1914
- const position = this.audioListenerPositionProvider();
1915
- // Set the listener position
1916
- audioEngine.audioContext.listener.setPosition(position.x || 0, position.y || 0, position.z || 0);
1917
- // Check if there is a listening camera
1918
- }
1919
- else if (listeningCamera) {
1920
- // Set the listener position to the listening camera global position
1921
- if (!this._cachedCameraPosition.equals(listeningCamera.globalPosition)) {
1922
- this._cachedCameraPosition.copyFrom(listeningCamera.globalPosition);
1923
- audioEngine.audioContext.listener.setPosition(listeningCamera.globalPosition.x, listeningCamera.globalPosition.y, listeningCamera.globalPosition.z);
1924
- }
1925
- }
1926
- // Otherwise set the listener position to 0, 0 ,0
1927
- else {
1928
- // Set the listener position
1929
- audioEngine.audioContext.listener.setPosition(0, 0, 0);
1930
- }
1931
- // A custom listener rotation provider was set
1932
- // Use the users provided rotation instead of camera's
1933
- if (this.audioListenerRotationProvider) {
1934
- const rotation = this.audioListenerRotationProvider();
1935
- audioEngine.audioContext.listener.setOrientation(rotation.x || 0, rotation.y || 0, rotation.z || 0, 0, 1, 0);
1936
- // Check if there is a listening camera
1937
- }
1938
- else if (listeningCamera) {
1939
- // for VR cameras
1940
- if (listeningCamera.rigCameras && listeningCamera.rigCameras.length > 0) {
1941
- listeningCamera = listeningCamera.rigCameras[0];
1942
- }
1943
- listeningCamera.getViewMatrix().invertToRef(this._invertMatrixTemp);
1944
- Vector3.TransformNormalToRef(AudioSceneComponent._CameraDirection, this._invertMatrixTemp, this._cameraDirectionTemp);
1945
- this._cameraDirectionTemp.normalize();
1946
- // To avoid some errors on GearVR
1947
- if (!isNaN(this._cameraDirectionTemp.x) && !isNaN(this._cameraDirectionTemp.y) && !isNaN(this._cameraDirectionTemp.z)) {
1948
- if (!this._cachedCameraDirection.equals(this._cameraDirectionTemp)) {
1949
- this._cachedCameraDirection.copyFrom(this._cameraDirectionTemp);
1950
- audioEngine.audioContext.listener.setOrientation(this._cameraDirectionTemp.x, this._cameraDirectionTemp.y, this._cameraDirectionTemp.z, 0, 1, 0);
1951
- }
1952
- }
1953
- }
1954
- // Otherwise set the listener rotation to 0, 0 ,0
1955
- else {
1956
- // Set the listener position
1957
- audioEngine.audioContext.listener.setOrientation(0, 0, 0, 0, 1, 0);
1958
- }
1959
- let i;
1960
- for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
1961
- const sound = scene.mainSoundTrack.soundCollection[i];
1962
- if (sound.useCustomAttenuation) {
1963
- sound.updateDistanceFromListener();
1964
- }
1965
- }
1966
- if (scene.soundTracks) {
1967
- for (i = 0; i < scene.soundTracks.length; i++) {
1968
- for (let j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
1969
- const sound = scene.soundTracks[i].soundCollection[j];
1970
- if (sound.useCustomAttenuation) {
1971
- sound.updateDistanceFromListener();
1972
- }
1973
- }
1974
- }
1975
- }
1976
- }
1977
- }
1978
- }
1979
- AudioSceneComponent._CameraDirection = new Vector3(0, 0, -1);
1980
- Sound._SceneComponentInitialization = (scene) => {
1981
- let compo = scene._getComponent(SceneComponentConstants.NAME_AUDIO);
1982
- if (!compo) {
1983
- compo = new AudioSceneComponent(scene);
1984
- scene._addComponent(compo);
1985
- }
1986
- };
1987
-
1988
- const NAME = "MSFT_audio_emitter";
1989
- /**
1990
- * [Specification](https://github.com/najadojo/glTF/blob/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter/README.md)
1991
- * !!! Experimental Extension Subject to Changes !!!
1992
- */
1993
- // eslint-disable-next-line @typescript-eslint/naming-convention
1994
- class MSFT_audio_emitter {
1995
- /**
1996
- * @internal
1997
- */
1998
- constructor(loader) {
1999
- /**
2000
- * The name of this extension.
2001
- */
2002
- this.name = NAME;
2003
- this._loader = loader;
2004
- this.enabled = this._loader.isExtensionUsed(NAME);
2005
- }
2006
- /** @internal */
2007
- dispose() {
2008
- this._loader = null;
2009
- this._clips = null;
2010
- this._emitters = null;
2011
- }
2012
- /** @internal */
2013
- onLoading() {
2014
- const extensions = this._loader.gltf.extensions;
2015
- if (extensions && extensions[this.name]) {
2016
- const extension = extensions[this.name];
2017
- this._clips = extension.clips;
2018
- this._emitters = extension.emitters;
2019
- ArrayItem.Assign(this._clips);
2020
- ArrayItem.Assign(this._emitters);
2021
- }
2022
- }
2023
- /**
2024
- * @internal
2025
- */
2026
- loadSceneAsync(context, scene) {
2027
- return GLTFLoader.LoadExtensionAsync(context, scene, this.name, (extensionContext, extension) => {
2028
- const promises = new Array();
2029
- promises.push(this._loader.loadSceneAsync(context, scene));
2030
- for (const emitterIndex of extension.emitters) {
2031
- const emitter = ArrayItem.Get(`${extensionContext}/emitters`, this._emitters, emitterIndex);
2032
- if (emitter.refDistance != undefined ||
2033
- emitter.maxDistance != undefined ||
2034
- emitter.rolloffFactor != undefined ||
2035
- emitter.distanceModel != undefined ||
2036
- emitter.innerAngle != undefined ||
2037
- emitter.outerAngle != undefined) {
2038
- throw new Error(`${extensionContext}: Direction or Distance properties are not allowed on emitters attached to a scene`);
2039
- }
2040
- promises.push(this._loadEmitterAsync(`${extensionContext}/emitters/${emitter.index}`, emitter));
2041
- }
2042
- return Promise.all(promises).then(() => { });
2043
- });
2044
- }
2045
- /**
2046
- * @internal
2047
- */
2048
- loadNodeAsync(context, node, assign) {
2049
- return GLTFLoader.LoadExtensionAsync(context, node, this.name, (extensionContext, extension) => {
2050
- const promises = new Array();
2051
- return this._loader
2052
- .loadNodeAsync(extensionContext, node, (babylonMesh) => {
2053
- for (const emitterIndex of extension.emitters) {
2054
- const emitter = ArrayItem.Get(`${extensionContext}/emitters`, this._emitters, emitterIndex);
2055
- promises.push(this._loadEmitterAsync(`${extensionContext}/emitters/${emitter.index}`, emitter).then(() => {
2056
- for (const sound of emitter._babylonSounds) {
2057
- sound.attachToMesh(babylonMesh);
2058
- if (emitter.innerAngle != undefined || emitter.outerAngle != undefined) {
2059
- sound.setLocalDirectionToMesh(Vector3.Forward());
2060
- sound.setDirectionalCone(2 * Tools.ToDegrees(emitter.innerAngle == undefined ? Math.PI : emitter.innerAngle), 2 * Tools.ToDegrees(emitter.outerAngle == undefined ? Math.PI : emitter.outerAngle), 0);
2061
- }
2062
- }
2063
- }));
2064
- }
2065
- assign(babylonMesh);
2066
- })
2067
- .then((babylonMesh) => {
2068
- return Promise.all(promises).then(() => {
2069
- return babylonMesh;
2070
- });
2071
- });
2072
- });
2073
- }
2074
- /**
2075
- * @internal
2076
- */
2077
- loadAnimationAsync(context, animation) {
2078
- return GLTFLoader.LoadExtensionAsync(context, animation, this.name, (extensionContext, extension) => {
2079
- return this._loader.loadAnimationAsync(context, animation).then((babylonAnimationGroup) => {
2080
- const promises = new Array();
2081
- ArrayItem.Assign(extension.events);
2082
- for (const event of extension.events) {
2083
- promises.push(this._loadAnimationEventAsync(`${extensionContext}/events/${event.index}`, context, animation, event, babylonAnimationGroup));
2084
- }
2085
- return Promise.all(promises).then(() => {
2086
- return babylonAnimationGroup;
2087
- });
2088
- });
2089
- });
2090
- }
2091
- _loadClipAsync(context, clip) {
2092
- if (clip._objectURL) {
2093
- return clip._objectURL;
2094
- }
2095
- let promise;
2096
- if (clip.uri) {
2097
- promise = this._loader.loadUriAsync(context, clip, clip.uri);
2098
- }
2099
- else {
2100
- const bufferView = ArrayItem.Get(`${context}/bufferView`, this._loader.gltf.bufferViews, clip.bufferView);
2101
- promise = this._loader.loadBufferViewAsync(`/bufferViews/${bufferView.index}`, bufferView);
2102
- }
2103
- clip._objectURL = promise.then((data) => {
2104
- return URL.createObjectURL(new Blob([data], { type: clip.mimeType }));
2105
- });
2106
- return clip._objectURL;
2107
- }
2108
- _loadEmitterAsync(context, emitter) {
2109
- emitter._babylonSounds = emitter._babylonSounds || [];
2110
- if (!emitter._babylonData) {
2111
- const clipPromises = new Array();
2112
- const name = emitter.name || `emitter${emitter.index}`;
2113
- const options = {
2114
- loop: false,
2115
- autoplay: false,
2116
- volume: emitter.volume == undefined ? 1 : emitter.volume,
2117
- };
2118
- for (let i = 0; i < emitter.clips.length; i++) {
2119
- const clipContext = `/extensions/${this.name}/clips`;
2120
- const clip = ArrayItem.Get(clipContext, this._clips, emitter.clips[i].clip);
2121
- clipPromises.push(this._loadClipAsync(`${clipContext}/${emitter.clips[i].clip}`, clip).then((objectURL) => {
2122
- const sound = (emitter._babylonSounds[i] = new Sound(name, objectURL, this._loader.babylonScene, null, options));
2123
- sound.refDistance = emitter.refDistance || 1;
2124
- sound.maxDistance = emitter.maxDistance || 256;
2125
- sound.rolloffFactor = emitter.rolloffFactor || 1;
2126
- sound.distanceModel = emitter.distanceModel || "exponential";
2127
- }));
2128
- }
2129
- const promise = Promise.all(clipPromises).then(() => {
2130
- const weights = emitter.clips.map((clip) => {
2131
- return clip.weight || 1;
2132
- });
2133
- const weightedSound = new WeightedSound(emitter.loop || false, emitter._babylonSounds, weights);
2134
- if (emitter.innerAngle) {
2135
- weightedSound.directionalConeInnerAngle = 2 * Tools.ToDegrees(emitter.innerAngle);
2136
- }
2137
- if (emitter.outerAngle) {
2138
- weightedSound.directionalConeOuterAngle = 2 * Tools.ToDegrees(emitter.outerAngle);
2139
- }
2140
- if (emitter.volume) {
2141
- weightedSound.volume = emitter.volume;
2142
- }
2143
- emitter._babylonData.sound = weightedSound;
2144
- });
2145
- emitter._babylonData = {
2146
- loaded: promise,
2147
- };
2148
- }
2149
- return emitter._babylonData.loaded;
2150
- }
2151
- _getEventAction(context, sound, action, time, startOffset) {
2152
- switch (action) {
2153
- case "play" /* IMSFTAudioEmitter_AnimationEventAction.play */: {
2154
- return (currentFrame) => {
2155
- const frameOffset = (startOffset || 0) + (currentFrame - time);
2156
- sound.play(frameOffset);
2157
- };
2158
- }
2159
- case "stop" /* IMSFTAudioEmitter_AnimationEventAction.stop */: {
2160
- return () => {
2161
- sound.stop();
2162
- };
2163
- }
2164
- case "pause" /* IMSFTAudioEmitter_AnimationEventAction.pause */: {
2165
- return () => {
2166
- sound.pause();
2167
- };
2168
- }
2169
- default: {
2170
- throw new Error(`${context}: Unsupported action ${action}`);
2171
- }
2172
- }
2173
- }
2174
- _loadAnimationEventAsync(context, animationContext, animation, event, babylonAnimationGroup) {
2175
- if (babylonAnimationGroup.targetedAnimations.length == 0) {
2176
- return Promise.resolve();
2177
- }
2178
- const babylonAnimation = babylonAnimationGroup.targetedAnimations[0];
2179
- const emitterIndex = event.emitter;
2180
- const emitter = ArrayItem.Get(`/extensions/${this.name}/emitters`, this._emitters, emitterIndex);
2181
- return this._loadEmitterAsync(context, emitter).then(() => {
2182
- const sound = emitter._babylonData.sound;
2183
- if (sound) {
2184
- const babylonAnimationEvent = new AnimationEvent(event.time, this._getEventAction(context, sound, event.action, event.time, event.startOffset));
2185
- babylonAnimation.animation.addEvent(babylonAnimationEvent);
2186
- // Make sure all started audio stops when this animation is terminated.
2187
- babylonAnimationGroup.onAnimationGroupEndObservable.add(() => {
2188
- sound.stop();
2189
- });
2190
- babylonAnimationGroup.onAnimationGroupPauseObservable.add(() => {
2191
- sound.pause();
2192
- });
2193
- }
2194
- });
2195
- }
2196
- }
2197
- unregisterGLTFExtension(NAME);
2198
- registerGLTFExtension(NAME, true, (loader) => new MSFT_audio_emitter(loader));
2199
-
2200
- export { MSFT_audio_emitter };
2201
- //# sourceMappingURL=MSFT_audio_emitter-B7RJSCaF.esm.js.map