@babylonjs/viewer 7.42.0 → 7.44.0

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