@babylonjs/core 5.27.0 → 5.28.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 (432) hide show
  1. package/Animations/animatable.js +2 -1
  2. package/Animations/animatable.js.map +1 -1
  3. package/Animations/runtimeAnimation.js +1 -1
  4. package/Animations/runtimeAnimation.js.map +1 -1
  5. package/Audio/audioSceneComponent.js +2 -1
  6. package/Audio/audioSceneComponent.js.map +1 -1
  7. package/Audio/sound.js +70 -45
  8. package/Audio/sound.js.map +1 -1
  9. package/Audio/soundTrack.js +12 -6
  10. package/Audio/soundTrack.js.map +1 -1
  11. package/BakedVertexAnimation/bakedVertexAnimationManager.js +2 -1
  12. package/BakedVertexAnimation/bakedVertexAnimationManager.js.map +1 -1
  13. package/Behaviors/Cameras/autoRotationBehavior.js +1 -1
  14. package/Behaviors/Cameras/autoRotationBehavior.js.map +1 -1
  15. package/Behaviors/Meshes/followBehavior.js +2 -1
  16. package/Behaviors/Meshes/followBehavior.js.map +1 -1
  17. package/Behaviors/Meshes/handConstraintBehavior.js +6 -6
  18. package/Behaviors/Meshes/handConstraintBehavior.js.map +1 -1
  19. package/Bones/bone.js +2 -1
  20. package/Bones/bone.js.map +1 -1
  21. package/Bones/skeleton.js +3 -2
  22. package/Bones/skeleton.js.map +1 -1
  23. package/Cameras/Inputs/BaseCameraPointersInput.js +2 -2
  24. package/Cameras/Inputs/BaseCameraPointersInput.js.map +1 -1
  25. package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js +5 -3
  26. package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js.map +1 -1
  27. package/Cameras/Inputs/flyCameraMouseInput.js +2 -2
  28. package/Cameras/Inputs/flyCameraMouseInput.js.map +1 -1
  29. package/Cameras/Inputs/freeCameraMouseInput.js +2 -2
  30. package/Cameras/Inputs/freeCameraMouseInput.js.map +1 -1
  31. package/Cameras/arcRotateCamera.js +2 -1
  32. package/Cameras/arcRotateCamera.js.map +1 -1
  33. package/Cameras/camera.js +6 -4
  34. package/Cameras/camera.js.map +1 -1
  35. package/Compute/computeEffect.js +8 -5
  36. package/Compute/computeEffect.js.map +1 -1
  37. package/Compute/computeShader.js +12 -11
  38. package/Compute/computeShader.js.map +1 -1
  39. package/Culling/Octrees/octreeSceneComponent.js +2 -1
  40. package/Culling/Octrees/octreeSceneComponent.js.map +1 -1
  41. package/Culling/boundingBox.js +3 -2
  42. package/Culling/boundingBox.js.map +1 -1
  43. package/Culling/ray.js +2 -1
  44. package/Culling/ray.js.map +1 -1
  45. package/Debug/directionalLightFrustumViewer.js +9 -7
  46. package/Debug/directionalLightFrustumViewer.js.map +1 -1
  47. package/Debug/rayHelper.js +2 -1
  48. package/Debug/rayHelper.js.map +1 -1
  49. package/Debug/skeletonViewer.js +29 -24
  50. package/Debug/skeletonViewer.js.map +1 -1
  51. package/DeviceInput/InputDevices/deviceSourceManager.js +5 -3
  52. package/DeviceInput/InputDevices/deviceSourceManager.js.map +1 -1
  53. package/DeviceInput/internalDeviceSourceManager.js +2 -1
  54. package/DeviceInput/internalDeviceSourceManager.js.map +1 -1
  55. package/DeviceInput/webDeviceInputSystem.js +12 -9
  56. package/DeviceInput/webDeviceInputSystem.js.map +1 -1
  57. package/Engines/Extensions/engine.rawTexture.js +4 -4
  58. package/Engines/Extensions/engine.rawTexture.js.map +1 -1
  59. package/Engines/Extensions/engine.readTexture.js +3 -2
  60. package/Engines/Extensions/engine.readTexture.js.map +1 -1
  61. package/Engines/Extensions/engine.views.js +2 -1
  62. package/Engines/Extensions/engine.views.js.map +1 -1
  63. package/Engines/Processors/shaderProcessor.js +11 -6
  64. package/Engines/Processors/shaderProcessor.js.map +1 -1
  65. package/Engines/WebGPU/Extensions/engine.cubeTexture.js +1 -1
  66. package/Engines/WebGPU/Extensions/engine.cubeTexture.js.map +1 -1
  67. package/Engines/WebGPU/Extensions/engine.dynamicTexture.js +2 -1
  68. package/Engines/WebGPU/Extensions/engine.dynamicTexture.js.map +1 -1
  69. package/Engines/WebGPU/Extensions/engine.multiRender.js +2 -1
  70. package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
  71. package/Engines/WebGPU/Extensions/engine.query.js +4 -2
  72. package/Engines/WebGPU/Extensions/engine.query.js.map +1 -1
  73. package/Engines/WebGPU/Extensions/engine.rawTexture.js +4 -4
  74. package/Engines/WebGPU/Extensions/engine.rawTexture.js.map +1 -1
  75. package/Engines/WebGPU/Extensions/engine.renderTarget.js +2 -1
  76. package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
  77. package/Engines/WebGPU/Extensions/engine.storageBuffer.js +3 -2
  78. package/Engines/WebGPU/Extensions/engine.storageBuffer.js.map +1 -1
  79. package/Engines/WebGPU/Extensions/engine.textureSampler.js +2 -1
  80. package/Engines/WebGPU/Extensions/engine.textureSampler.js.map +1 -1
  81. package/Engines/WebGPU/Extensions/engine.videoTexture.js +2 -1
  82. package/Engines/WebGPU/Extensions/engine.videoTexture.js.map +1 -1
  83. package/Engines/WebGPU/webgpuCacheBindGroups.js +7 -6
  84. package/Engines/WebGPU/webgpuCacheBindGroups.js.map +1 -1
  85. package/Engines/WebGPU/webgpuCacheRenderPipeline.js +18 -14
  86. package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
  87. package/Engines/WebGPU/webgpuCacheSampler.js +4 -3
  88. package/Engines/WebGPU/webgpuCacheSampler.js.map +1 -1
  89. package/Engines/WebGPU/webgpuClearQuad.js +3 -2
  90. package/Engines/WebGPU/webgpuClearQuad.js.map +1 -1
  91. package/Engines/WebGPU/webgpuComputePipelineContext.js +2 -1
  92. package/Engines/WebGPU/webgpuComputePipelineContext.js.map +1 -1
  93. package/Engines/WebGPU/webgpuDepthCullingState.js +2 -2
  94. package/Engines/WebGPU/webgpuDepthCullingState.js.map +1 -1
  95. package/Engines/WebGPU/webgpuDrawContext.js +2 -1
  96. package/Engines/WebGPU/webgpuDrawContext.js.map +1 -1
  97. package/Engines/WebGPU/webgpuHardwareTexture.js +4 -3
  98. package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
  99. package/Engines/WebGPU/webgpuMaterialContext.js +5 -4
  100. package/Engines/WebGPU/webgpuMaterialContext.js.map +1 -1
  101. package/Engines/WebGPU/webgpuOcclusionQuery.js +5 -3
  102. package/Engines/WebGPU/webgpuOcclusionQuery.js.map +1 -1
  103. package/Engines/WebGPU/webgpuPipelineContext.js +4 -2
  104. package/Engines/WebGPU/webgpuPipelineContext.js.map +1 -1
  105. package/Engines/WebGPU/webgpuShaderProcessingContext.js +4 -2
  106. package/Engines/WebGPU/webgpuShaderProcessingContext.js.map +1 -1
  107. package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js +2 -1
  108. package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js.map +1 -1
  109. package/Engines/WebGPU/webgpuSnapshotRendering.js +3 -2
  110. package/Engines/WebGPU/webgpuSnapshotRendering.js.map +1 -1
  111. package/Engines/WebGPU/webgpuStencilStateComposer.js +2 -1
  112. package/Engines/WebGPU/webgpuStencilStateComposer.js.map +1 -1
  113. package/Engines/WebGPU/webgpuTextureHelper.js +40 -38
  114. package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
  115. package/Engines/engine.d.ts +898 -273
  116. package/Engines/engine.js +5 -3
  117. package/Engines/engine.js.map +1 -1
  118. package/Engines/nativeEngine.js +7 -5
  119. package/Engines/nativeEngine.js.map +1 -1
  120. package/Engines/nullEngine.d.ts +7 -0
  121. package/Engines/nullEngine.js +42 -0
  122. package/Engines/nullEngine.js.map +1 -1
  123. package/Engines/renderTargetWrapper.js +14 -9
  124. package/Engines/renderTargetWrapper.js.map +1 -1
  125. package/Engines/thinEngine.js +25 -16
  126. package/Engines/thinEngine.js.map +1 -1
  127. package/Engines/webgpuEngine.js +87 -61
  128. package/Engines/webgpuEngine.js.map +1 -1
  129. package/Gamepads/gamepadManager.js +1 -1
  130. package/Gamepads/gamepadManager.js.map +1 -1
  131. package/Gizmos/axisDragGizmo.js +4 -2
  132. package/Gizmos/axisDragGizmo.js.map +1 -1
  133. package/Gizmos/axisScaleGizmo.js +6 -4
  134. package/Gizmos/axisScaleGizmo.js.map +1 -1
  135. package/Gizmos/gizmo.js +21 -6
  136. package/Gizmos/gizmo.js.map +1 -1
  137. package/Gizmos/gizmoManager.js +3 -2
  138. package/Gizmos/gizmoManager.js.map +1 -1
  139. package/Gizmos/planeDragGizmo.js +4 -2
  140. package/Gizmos/planeDragGizmo.js.map +1 -1
  141. package/Gizmos/planeRotationGizmo.js +4 -2
  142. package/Gizmos/planeRotationGizmo.js.map +1 -1
  143. package/Helpers/videoDome.js +2 -1
  144. package/Helpers/videoDome.js.map +1 -1
  145. package/Layers/effectLayer.js +5 -3
  146. package/Layers/effectLayer.js.map +1 -1
  147. package/Layers/glowLayer.js +4 -3
  148. package/Layers/glowLayer.js.map +1 -1
  149. package/Layers/highlightLayer.js +2 -1
  150. package/Layers/highlightLayer.js.map +1 -1
  151. package/LensFlares/lensFlareSystem.js +2 -1
  152. package/LensFlares/lensFlareSystem.js.map +1 -1
  153. package/Lights/Shadows/cascadedShadowGenerator.js +25 -21
  154. package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
  155. package/Lights/Shadows/shadowGenerator.js +13 -8
  156. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  157. package/Loading/Plugins/babylonFileLoader.js +2 -1
  158. package/Loading/Plugins/babylonFileLoader.js.map +1 -1
  159. package/Loading/sceneLoader.d.ts +1 -1
  160. package/Loading/sceneLoader.js +3 -3
  161. package/Loading/sceneLoader.js.map +1 -1
  162. package/Materials/Node/Blocks/Dual/imageSourceBlock.js +2 -1
  163. package/Materials/Node/Blocks/Dual/imageSourceBlock.js.map +1 -1
  164. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js +2 -1
  165. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js.map +1 -1
  166. package/Materials/Node/Blocks/Dual/textureBlock.js +10 -6
  167. package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
  168. package/Materials/Node/Blocks/Fragment/TBNBlock.js +3 -2
  169. package/Materials/Node/Blocks/Fragment/TBNBlock.js.map +1 -1
  170. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +2 -1
  171. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
  172. package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js +2 -1
  173. package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js.map +1 -1
  174. package/Materials/Node/Blocks/Input/inputBlock.js +2 -1
  175. package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
  176. package/Materials/Node/Blocks/PBR/clearCoatBlock.js +26 -24
  177. package/Materials/Node/Blocks/PBR/clearCoatBlock.js.map +1 -1
  178. package/Materials/Node/Blocks/PBR/iridescenceBlock.js +3 -3
  179. package/Materials/Node/Blocks/PBR/iridescenceBlock.js.map +1 -1
  180. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +48 -44
  181. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
  182. package/Materials/Node/Blocks/PBR/reflectionBlock.js +2 -1
  183. package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
  184. package/Materials/Node/Blocks/PBR/refractionBlock.js +2 -1
  185. package/Materials/Node/Blocks/PBR/refractionBlock.js.map +1 -1
  186. package/Materials/Node/Blocks/PBR/sheenBlock.js +13 -13
  187. package/Materials/Node/Blocks/PBR/sheenBlock.js.map +1 -1
  188. package/Materials/Node/Blocks/PBR/subSurfaceBlock.js +27 -26
  189. package/Materials/Node/Blocks/PBR/subSurfaceBlock.js.map +1 -1
  190. package/Materials/Node/Blocks/Vertex/instancesBlock.js +2 -2
  191. package/Materials/Node/Blocks/Vertex/instancesBlock.js.map +1 -1
  192. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js +6 -6
  193. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
  194. package/Materials/Node/Blocks/cloudBlock.js +3 -2
  195. package/Materials/Node/Blocks/cloudBlock.js.map +1 -1
  196. package/Materials/Node/Blocks/colorMergerBlock.js +5 -4
  197. package/Materials/Node/Blocks/colorMergerBlock.js.map +1 -1
  198. package/Materials/Node/Blocks/customBlock.js +4 -3
  199. package/Materials/Node/Blocks/customBlock.js.map +1 -1
  200. package/Materials/Node/Blocks/vectorMergerBlock.js +5 -4
  201. package/Materials/Node/Blocks/vectorMergerBlock.js.map +1 -1
  202. package/Materials/Node/nodeMaterial.js +7 -6
  203. package/Materials/Node/nodeMaterial.js.map +1 -1
  204. package/Materials/Node/nodeMaterialBlock.js +4 -3
  205. package/Materials/Node/nodeMaterialBlock.js.map +1 -1
  206. package/Materials/Node/nodeMaterialDecorator.js +1 -1
  207. package/Materials/Node/nodeMaterialDecorator.js.map +1 -1
  208. package/Materials/PBR/pbrBaseMaterial.js +25 -19
  209. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  210. package/Materials/PBR/pbrClearCoatConfiguration.js +9 -6
  211. package/Materials/PBR/pbrClearCoatConfiguration.js.map +1 -1
  212. package/Materials/PBR/pbrIridescenceConfiguration.js +7 -4
  213. package/Materials/PBR/pbrIridescenceConfiguration.js.map +1 -1
  214. package/Materials/PBR/pbrSheenConfiguration.js +7 -4
  215. package/Materials/PBR/pbrSheenConfiguration.js.map +1 -1
  216. package/Materials/Textures/Loaders/envTextureLoader.js +2 -2
  217. package/Materials/Textures/Loaders/envTextureLoader.js.map +1 -1
  218. package/Materials/Textures/Packer/packer.js +14 -13
  219. package/Materials/Textures/Packer/packer.js.map +1 -1
  220. package/Materials/Textures/Procedurals/customProceduralTexture.d.ts +2 -1
  221. package/Materials/Textures/Procedurals/customProceduralTexture.js.map +1 -1
  222. package/Materials/Textures/Procedurals/noiseProceduralTexture.js +2 -1
  223. package/Materials/Textures/Procedurals/noiseProceduralTexture.js.map +1 -1
  224. package/Materials/Textures/Procedurals/proceduralTexture.js +7 -4
  225. package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
  226. package/Materials/Textures/baseTexture.d.ts +5 -4
  227. package/Materials/Textures/baseTexture.js +1 -0
  228. package/Materials/Textures/baseTexture.js.map +1 -1
  229. package/Materials/Textures/cubeTexture.js +8 -4
  230. package/Materials/Textures/cubeTexture.js.map +1 -1
  231. package/Materials/Textures/hdrCubeTexture.js +4 -2
  232. package/Materials/Textures/hdrCubeTexture.js.map +1 -1
  233. package/Materials/Textures/internalTexture.js +4 -2
  234. package/Materials/Textures/internalTexture.js.map +1 -1
  235. package/Materials/Textures/mirrorTexture.js +6 -3
  236. package/Materials/Textures/mirrorTexture.js.map +1 -1
  237. package/Materials/Textures/multiRenderTarget.js +6 -4
  238. package/Materials/Textures/multiRenderTarget.js.map +1 -1
  239. package/Materials/Textures/rawTexture.js +1 -1
  240. package/Materials/Textures/rawTexture.js.map +1 -1
  241. package/Materials/Textures/renderTargetTexture.js +26 -15
  242. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  243. package/Materials/Textures/texture.js +16 -13
  244. package/Materials/Textures/texture.js.map +1 -1
  245. package/Materials/Textures/thinRenderTargetTexture.js +4 -2
  246. package/Materials/Textures/thinRenderTargetTexture.js.map +1 -1
  247. package/Materials/Textures/thinTexture.d.ts +3 -3
  248. package/Materials/Textures/thinTexture.js.map +1 -1
  249. package/Materials/Textures/videoTexture.js +3 -3
  250. package/Materials/Textures/videoTexture.js.map +1 -1
  251. package/Materials/drawWrapper.js +4 -2
  252. package/Materials/drawWrapper.js.map +1 -1
  253. package/Materials/effect.js +15 -10
  254. package/Materials/effect.js.map +1 -1
  255. package/Materials/material.d.ts +14 -0
  256. package/Materials/material.detailMapConfiguration.js +2 -1
  257. package/Materials/material.detailMapConfiguration.js.map +1 -1
  258. package/Materials/material.js +35 -3
  259. package/Materials/material.js.map +1 -1
  260. package/Materials/materialDefines.js +6 -5
  261. package/Materials/materialDefines.js.map +1 -1
  262. package/Materials/materialHelper.js +1 -1
  263. package/Materials/materialHelper.js.map +1 -1
  264. package/Materials/materialPluginManager.js +3 -2
  265. package/Materials/materialPluginManager.js.map +1 -1
  266. package/Materials/multiMaterial.js +2 -1
  267. package/Materials/multiMaterial.js.map +1 -1
  268. package/Materials/shaderMaterial.js +12 -9
  269. package/Materials/shaderMaterial.js.map +1 -1
  270. package/Materials/shadowDepthWrapper.js +13 -8
  271. package/Materials/shadowDepthWrapper.js.map +1 -1
  272. package/Materials/standardMaterial.js +12 -10
  273. package/Materials/standardMaterial.js.map +1 -1
  274. package/Materials/uniformBuffer.js +1 -1
  275. package/Materials/uniformBuffer.js.map +1 -1
  276. package/Maths/math.vector.d.ts +7 -6
  277. package/Maths/math.vector.js +10 -8
  278. package/Maths/math.vector.js.map +1 -1
  279. package/Meshes/Builders/groundBuilder.js +1 -1
  280. package/Meshes/Builders/groundBuilder.js.map +1 -1
  281. package/Meshes/abstractMesh.js +8 -5
  282. package/Meshes/abstractMesh.js.map +1 -1
  283. package/Meshes/csg.js +2 -1
  284. package/Meshes/csg.js.map +1 -1
  285. package/Meshes/instancedMesh.js +2 -1
  286. package/Meshes/instancedMesh.js.map +1 -1
  287. package/Meshes/mesh.d.ts +1 -1
  288. package/Meshes/mesh.js +23 -13
  289. package/Meshes/mesh.js.map +1 -1
  290. package/Meshes/mesh.vertexData.js +4 -3
  291. package/Meshes/mesh.vertexData.js.map +1 -1
  292. package/Meshes/subMesh.js +14 -8
  293. package/Meshes/subMesh.js.map +1 -1
  294. package/Meshes/thinInstanceMesh.js +18 -12
  295. package/Meshes/thinInstanceMesh.js.map +1 -1
  296. package/Meshes/transformNode.d.ts +7 -1
  297. package/Meshes/transformNode.js +15 -4
  298. package/Meshes/transformNode.js.map +1 -1
  299. package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js +2 -1
  300. package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js.map +1 -1
  301. package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.js +12 -8
  302. package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.js.map +1 -1
  303. package/Misc/PerformanceViewer/performanceViewerCollector.js +3 -2
  304. package/Misc/PerformanceViewer/performanceViewerCollector.js.map +1 -1
  305. package/Misc/arrayTools.js +1 -1
  306. package/Misc/arrayTools.js.map +1 -1
  307. package/Misc/assetsManager.d.ts +22 -4
  308. package/Misc/assetsManager.js +20 -8
  309. package/Misc/assetsManager.js.map +1 -1
  310. package/Misc/computePressure.js +9 -6
  311. package/Misc/computePressure.js.map +1 -1
  312. package/Misc/dataStorage.js +1 -1
  313. package/Misc/dataStorage.js.map +1 -1
  314. package/Misc/dds.js +1 -1
  315. package/Misc/dds.js.map +1 -1
  316. package/Misc/environmentTextureTools.js +3 -2
  317. package/Misc/environmentTextureTools.js.map +1 -1
  318. package/Misc/fileTools.js +31 -8
  319. package/Misc/fileTools.js.map +1 -1
  320. package/Misc/logger.js +2 -1
  321. package/Misc/logger.js.map +1 -1
  322. package/Misc/minMaxReducer.js +3 -2
  323. package/Misc/minMaxReducer.js.map +1 -1
  324. package/Misc/sceneRecorder.js +1 -1
  325. package/Misc/sceneRecorder.js.map +1 -1
  326. package/Misc/textureTools.js +3 -3
  327. package/Misc/textureTools.js.map +1 -1
  328. package/Misc/timer.js +5 -3
  329. package/Misc/timer.js.map +1 -1
  330. package/Misc/tools.js +4 -4
  331. package/Misc/tools.js.map +1 -1
  332. package/Misc/trajectoryClassifier.js +3 -3
  333. package/Misc/trajectoryClassifier.js.map +1 -1
  334. package/Particles/EmitterTypes/meshParticleEmitter.js +2 -1
  335. package/Particles/EmitterTypes/meshParticleEmitter.js.map +1 -1
  336. package/Particles/computeShaderParticleSystem.js +6 -3
  337. package/Particles/computeShaderParticleSystem.js.map +1 -1
  338. package/Particles/gpuParticleSystem.js +13 -8
  339. package/Particles/gpuParticleSystem.js.map +1 -1
  340. package/Particles/particleSystem.js +22 -14
  341. package/Particles/particleSystem.js.map +1 -1
  342. package/Particles/particleSystemComponent.js +2 -1
  343. package/Particles/particleSystemComponent.js.map +1 -1
  344. package/Particles/pointsCloudSystem.js +7 -4
  345. package/Particles/pointsCloudSystem.js.map +1 -1
  346. package/Particles/solidParticleSystem.js +2 -2
  347. package/Particles/solidParticleSystem.js.map +1 -1
  348. package/Particles/webgl2ParticleSystem.js +2 -1
  349. package/Particles/webgl2ParticleSystem.js.map +1 -1
  350. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js +5 -4
  351. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
  352. package/PostProcesses/RenderPipeline/postProcessRenderPipeline.d.ts +4 -2
  353. package/PostProcesses/RenderPipeline/postProcessRenderPipeline.js.map +1 -1
  354. package/PostProcesses/colorCorrectionPostProcess.js +1 -1
  355. package/PostProcesses/colorCorrectionPostProcess.js.map +1 -1
  356. package/PostProcesses/postProcess.js +8 -5
  357. package/PostProcesses/postProcess.js.map +1 -1
  358. package/PostProcesses/postProcessManager.js +6 -4
  359. package/PostProcesses/postProcessManager.js.map +1 -1
  360. package/PostProcesses/screenSpaceReflectionPostProcess.js +1 -1
  361. package/PostProcesses/screenSpaceReflectionPostProcess.js.map +1 -1
  362. package/PostProcesses/volumetricLightScatteringPostProcess.js +7 -4
  363. package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
  364. package/PostProcesses/vrMultiviewToSingleviewPostProcess.js +1 -1
  365. package/PostProcesses/vrMultiviewToSingleviewPostProcess.js.map +1 -1
  366. package/Probes/reflectionProbe.js +4 -2
  367. package/Probes/reflectionProbe.js.map +1 -1
  368. package/Rendering/boundingBoxRenderer.js +3 -2
  369. package/Rendering/boundingBoxRenderer.js.map +1 -1
  370. package/Rendering/depthPeelingRenderer.d.ts +12 -0
  371. package/Rendering/depthPeelingRenderer.js +30 -6
  372. package/Rendering/depthPeelingRenderer.js.map +1 -1
  373. package/Rendering/depthPeelingSceneComponent.js +4 -2
  374. package/Rendering/depthPeelingSceneComponent.js.map +1 -1
  375. package/Rendering/depthRenderer.js +10 -6
  376. package/Rendering/depthRenderer.js.map +1 -1
  377. package/Rendering/edgesRenderer.js +11 -8
  378. package/Rendering/edgesRenderer.js.map +1 -1
  379. package/Rendering/outlineRenderer.js +2 -2
  380. package/Rendering/outlineRenderer.js.map +1 -1
  381. package/Rendering/prePassRenderer.js +4 -2
  382. package/Rendering/prePassRenderer.js.map +1 -1
  383. package/Shaders/ShadersInclude/shadowsFragmentFunctions.js +3 -3
  384. package/Shaders/ShadersInclude/shadowsFragmentFunctions.js.map +1 -1
  385. package/Shaders/pbr.fragment.js +4 -1
  386. package/Shaders/pbr.fragment.js.map +1 -1
  387. package/Sprites/spriteManager.js +2 -1
  388. package/Sprites/spriteManager.js.map +1 -1
  389. package/Sprites/spriteRenderer.js +2 -1
  390. package/Sprites/spriteRenderer.js.map +1 -1
  391. package/States/stencilStateComposer.js +4 -2
  392. package/States/stencilStateComposer.js.map +1 -1
  393. package/XR/features/WebXRAnchorSystem.js +2 -1
  394. package/XR/features/WebXRAnchorSystem.js.map +1 -1
  395. package/XR/features/WebXRControllerMovement.js +7 -6
  396. package/XR/features/WebXRControllerMovement.js.map +1 -1
  397. package/XR/features/WebXRControllerPhysics.js +6 -4
  398. package/XR/features/WebXRControllerPhysics.js.map +1 -1
  399. package/XR/features/WebXRControllerPointerSelection.js +2 -1
  400. package/XR/features/WebXRControllerPointerSelection.js.map +1 -1
  401. package/XR/features/WebXRHandTracking.d.ts +3 -3
  402. package/XR/features/WebXRHandTracking.js +126 -118
  403. package/XR/features/WebXRHandTracking.js.map +1 -1
  404. package/XR/features/WebXRHitTest.js.map +1 -1
  405. package/XR/features/WebXRLayers.js +1 -1
  406. package/XR/features/WebXRLayers.js.map +1 -1
  407. package/XR/features/WebXRLightEstimation.js +7 -4
  408. package/XR/features/WebXRLightEstimation.js.map +1 -1
  409. package/XR/features/WebXRMeshDetector.js +2 -1
  410. package/XR/features/WebXRMeshDetector.js.map +1 -1
  411. package/XR/features/WebXRNearInteraction.js +7 -4
  412. package/XR/features/WebXRNearInteraction.js.map +1 -1
  413. package/XR/features/WebXRPlaneDetector.js +2 -1
  414. package/XR/features/WebXRPlaneDetector.js.map +1 -1
  415. package/XR/native/nativeXRFrame.js +2 -1
  416. package/XR/native/nativeXRFrame.js.map +1 -1
  417. package/XR/webXRCamera.js +2 -1
  418. package/XR/webXRCamera.js.map +1 -1
  419. package/XR/webXRExperienceHelper.js +7 -5
  420. package/XR/webXRExperienceHelper.js.map +1 -1
  421. package/XR/webXRInput.js.map +1 -1
  422. package/XR/webXRInputSource.js +2 -1
  423. package/XR/webXRInputSource.js.map +1 -1
  424. package/XR/webXRManagedOutputCanvas.js +0 -1
  425. package/XR/webXRManagedOutputCanvas.js.map +1 -1
  426. package/XR/webXRSessionManager.js +27 -14
  427. package/XR/webXRSessionManager.js.map +1 -1
  428. package/XR/webXRWebGLLayer.js +3 -0
  429. package/XR/webXRWebGLLayer.js.map +1 -1
  430. package/package.json +1 -1
  431. package/scene.js +17 -11
  432. package/scene.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"sound.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Audio/sound.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD;;;;GAIG;AACH,MAAM,OAAO,KAAK;IAyJd;;;;;;;OAOG;IACH,YAAY,IAAY,EAAE,gBAAqB,EAAE,KAAuB,EAAE,sBAA4C,IAAI,EAAE,OAAuB;QA5JnJ;;WAEG;QACI,aAAQ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,GAAG,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC;gBACjF,QAAQ,CAAC,uBAAuB,CAAC,oBAAoB,CAAC,CAAC;aAC1D;SACJ;QACD,IAAI,WAAW,CAAC,eAAe,EAAE;YAC7B,MAAM,aAAa,GAAG,KAAK,CAAC,WAAW,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;YACrE,IAAI,aAAa,EAAE;gBACf,QAAQ,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;aACxC;SACJ;QAED,IAAI,WAAW,CAAC,QAAQ,EAAE;YACtB,QAAQ,CAAC,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC;SAC5C;QAED,OAAO,QAAQ,CAAC;IACpB,CAAC;;AAjiCD;;GAEG;AACW,mCAA6B,GAA2B,CAAC,CAAC,EAAE,EAAE;IACxE,MAAM,WAAW,CAAC,qBAAqB,CAAC,CAAC;AAC7C,CAAC,CAAC","sourcesContent":["import { Tools } from \"../Misc/tools\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport { Vector3 } from \"../Maths/math.vector\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport { Engine } from \"../Engines/engine\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { TransformNode } from \"../Meshes/transformNode\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { _WarnImport } from \"../Misc/devTools\";\r\nimport type { ISoundOptions } from \"./Interfaces/ISoundOptions\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\n\r\n/**\r\n * Defines a sound that can be played in the application.\r\n * The sound can either be an ambient track or a simple sound played in reaction to a user action.\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music\r\n */\r\nexport class Sound {\r\n /**\r\n * The name of the sound in the scene.\r\n */\r\n public name: string;\r\n /**\r\n * Does the sound autoplay once loaded.\r\n */\r\n public autoplay: boolean = false;\r\n\r\n private _loop = false;\r\n /**\r\n * Does the sound loop after it finishes playing once.\r\n */\r\n public get loop(): boolean {\r\n return this._loop;\r\n }\r\n\r\n public set loop(value: boolean) {\r\n if (value === this._loop) {\r\n return;\r\n }\r\n\r\n this._loop = value;\r\n this.updateOptions({ loop: value });\r\n }\r\n\r\n /**\r\n * Does the sound use a custom attenuation curve to simulate the falloff\r\n * happening when the source gets further away from the camera.\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function\r\n */\r\n public useCustomAttenuation: boolean = false;\r\n /**\r\n * The sound track id this sound belongs to.\r\n */\r\n public soundTrackId: number;\r\n /**\r\n * Is this sound currently played.\r\n */\r\n public isPlaying: boolean = false;\r\n /**\r\n * Is this sound currently paused.\r\n */\r\n public isPaused: boolean = false;\r\n /**\r\n * Define the reference distance the sound should be heard perfectly.\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound\r\n */\r\n public refDistance: number = 1;\r\n /**\r\n * Define the roll off factor of spatial sounds.\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound\r\n */\r\n public rolloffFactor: number = 1;\r\n /**\r\n * Define the max distance the sound should be heard (intensity just became 0 at this point).\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound\r\n */\r\n public maxDistance: number = 100;\r\n /**\r\n * Define the distance attenuation model the sound will follow.\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound\r\n */\r\n public distanceModel: string = \"linear\";\r\n /**\r\n * @internal\r\n * Back Compat\r\n **/\r\n public onended: () => any;\r\n /**\r\n * Gets or sets an object used to store user defined information for the sound.\r\n */\r\n public metadata: any = null;\r\n\r\n /**\r\n * Observable event when the current playing sound finishes.\r\n */\r\n public onEndedObservable = new Observable<Sound>();\r\n\r\n /**\r\n * Gets the current time for the sound.\r\n */\r\n public get currentTime(): number {\r\n if (this._htmlAudioElement) {\r\n return this._htmlAudioElement.currentTime;\r\n }\r\n\r\n let currentTime: number = this._startOffset;\r\n if (this.isPlaying && Engine.audioEngine?.audioContext) {\r\n currentTime += Engine.audioEngine.audioContext.currentTime - this._startTime;\r\n }\r\n return currentTime;\r\n }\r\n\r\n /**\r\n * Does this sound enables spatial sound.\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound\r\n */\r\n public get spatialSound(): boolean {\r\n return this._spatialSound;\r\n }\r\n /**\r\n * Does this sound enables spatial sound.\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound\r\n */\r\n public set spatialSound(newValue: boolean) {\r\n this._spatialSound = newValue;\r\n if (this._spatialSound && Engine.audioEngine?.canUseWebAudio && Engine.audioEngine.audioContext) {\r\n this._createSpatialParameters();\r\n }\r\n }\r\n private _spatialSound: boolean = false;\r\n private _panningModel: string = \"equalpower\";\r\n private _playbackRate: number = 1;\r\n private _streaming: boolean = false;\r\n private _startTime: number = 0;\r\n private _startOffset: number = 0;\r\n private _position: Vector3 = Vector3.Zero();\r\n private _localDirection: Vector3 = new Vector3(1, 0, 0);\r\n private _volume: number = 1;\r\n private _isReadyToPlay: boolean = false;\r\n private _isDirectional: boolean = false;\r\n private _readyToPlayCallback: Nullable<() => any>;\r\n private _audioBuffer: Nullable<AudioBuffer>;\r\n private _soundSource: Nullable<AudioBufferSourceNode>;\r\n private _streamingSource: AudioNode;\r\n private _soundPanner: Nullable<PannerNode>;\r\n private _soundGain: Nullable<GainNode>;\r\n private _inputAudioNode: Nullable<AudioNode>;\r\n private _outputAudioNode: Nullable<AudioNode>;\r\n // Used if you'd like to create a directional sound.\r\n // If not set, the sound will be omnidirectional\r\n private _coneInnerAngle: number = 360;\r\n private _coneOuterAngle: number = 360;\r\n private _coneOuterGain: number = 0;\r\n private _scene: Scene;\r\n private _connectedTransformNode: Nullable<TransformNode>;\r\n private _customAttenuationFunction: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number;\r\n private _registerFunc: Nullable<(connectedMesh: TransformNode) => void>;\r\n private _isOutputConnected = false;\r\n private _htmlAudioElement: HTMLAudioElement;\r\n private _urlType: \"Unknown\" | \"String\" | \"Array\" | \"ArrayBuffer\" | \"MediaStream\" | \"AudioBuffer\" | \"MediaElement\" = \"Unknown\";\r\n private _length?: number;\r\n private _offset?: number;\r\n\r\n /**\r\n * @internal\r\n */\r\n public static _SceneComponentInitialization: (scene: Scene) => void = (_) => {\r\n throw _WarnImport(\"AudioSceneComponent\");\r\n };\r\n\r\n /**\r\n * Create a sound and attach it to a scene\r\n * @param name Name of your sound\r\n * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams and AudioBuffers\r\n * @param scene defines the scene the sound belongs to\r\n * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played\r\n * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming\r\n */\r\n constructor(name: string, urlOrArrayBuffer: any, scene?: Nullable<Scene>, readyToPlayCallback: Nullable<() => void> = null, options?: ISoundOptions) {\r\n this.name = name;\r\n scene = scene || EngineStore.LastCreatedScene;\r\n if (!scene) {\r\n return;\r\n }\r\n this._scene = scene;\r\n Sound._SceneComponentInitialization(scene);\r\n\r\n this._readyToPlayCallback = readyToPlayCallback;\r\n // Default custom attenuation function is a linear attenuation\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n this._customAttenuationFunction = (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => {\r\n if (currentDistance < maxDistance) {\r\n return currentVolume * (1 - currentDistance / maxDistance);\r\n } else {\r\n return 0;\r\n }\r\n };\r\n if (options) {\r\n this.autoplay = options.autoplay || false;\r\n this._loop = options.loop || false;\r\n // if volume === 0, we need another way to check this option\r\n if (options.volume !== undefined) {\r\n this._volume = options.volume;\r\n }\r\n this._spatialSound = options.spatialSound ?? false;\r\n this.maxDistance = options.maxDistance ?? 100;\r\n this.useCustomAttenuation = options.useCustomAttenuation ?? false;\r\n this.rolloffFactor = options.rolloffFactor || 1;\r\n this.refDistance = options.refDistance || 1;\r\n this.distanceModel = options.distanceModel || \"linear\";\r\n this._playbackRate = options.playbackRate || 1;\r\n this._streaming = options.streaming ?? false;\r\n this._length = options.length;\r\n this._offset = options.offset;\r\n }\r\n\r\n if (Engine.audioEngine?.canUseWebAudio && Engine.audioEngine.audioContext) {\r\n this._soundGain = Engine.audioEngine.audioContext.createGain();\r\n this._soundGain!.gain.value = this._volume;\r\n this._inputAudioNode = this._soundGain;\r\n this._outputAudioNode = this._soundGain;\r\n if (this._spatialSound) {\r\n this._createSpatialParameters();\r\n }\r\n this._scene.mainSoundTrack.addSound(this);\r\n let validParameter = true;\r\n\r\n // if no parameter is passed, you need to call setAudioBuffer yourself to prepare the sound\r\n if (urlOrArrayBuffer) {\r\n try {\r\n if (typeof urlOrArrayBuffer === \"string\") {\r\n this._urlType = \"String\";\r\n } else if (urlOrArrayBuffer instanceof ArrayBuffer) {\r\n this._urlType = \"ArrayBuffer\";\r\n } else if (urlOrArrayBuffer instanceof HTMLMediaElement) {\r\n this._urlType = \"MediaElement\";\r\n } else if (urlOrArrayBuffer instanceof MediaStream) {\r\n this._urlType = \"MediaStream\";\r\n } else if (urlOrArrayBuffer instanceof AudioBuffer) {\r\n this._urlType = \"AudioBuffer\";\r\n } else if (Array.isArray(urlOrArrayBuffer)) {\r\n this._urlType = \"Array\";\r\n }\r\n\r\n let urls: string[] = [];\r\n let codecSupportedFound = false;\r\n\r\n switch (this._urlType) {\r\n case \"MediaElement\":\r\n this._streaming = true;\r\n this._isReadyToPlay = true;\r\n this._streamingSource = Engine.audioEngine.audioContext.createMediaElementSource(urlOrArrayBuffer);\r\n\r\n if (this.autoplay) {\r\n this.play(0, this._offset, this._length);\r\n }\r\n\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n break;\r\n case \"MediaStream\":\r\n this._streaming = true;\r\n this._isReadyToPlay = true;\r\n this._streamingSource = Engine.audioEngine.audioContext.createMediaStreamSource(urlOrArrayBuffer);\r\n\r\n if (this.autoplay) {\r\n this.play(0, this._offset, this._length);\r\n }\r\n\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n break;\r\n case \"ArrayBuffer\":\r\n if ((<ArrayBuffer>urlOrArrayBuffer).byteLength > 0) {\r\n codecSupportedFound = true;\r\n this._soundLoaded(urlOrArrayBuffer);\r\n }\r\n break;\r\n case \"AudioBuffer\":\r\n this._audioBufferLoaded(urlOrArrayBuffer);\r\n break;\r\n case \"String\":\r\n urls.push(urlOrArrayBuffer);\r\n // eslint-disable-next-line no-fallthrough\r\n case \"Array\":\r\n if (urls.length === 0) {\r\n urls = urlOrArrayBuffer;\r\n }\r\n // If we found a supported format, we load it immediately and stop the loop\r\n for (let i = 0; i < urls.length; i++) {\r\n const url = urls[i];\r\n codecSupportedFound =\r\n (options && options.skipCodecCheck) ||\r\n (url.indexOf(\".mp3\", url.length - 4) !== -1 && Engine.audioEngine.isMP3supported) ||\r\n (url.indexOf(\".ogg\", url.length - 4) !== -1 && Engine.audioEngine.isOGGsupported) ||\r\n url.indexOf(\".wav\", url.length - 4) !== -1 ||\r\n url.indexOf(\".m4a\", url.length - 4) !== -1 ||\r\n url.indexOf(\".mp4\", url.length - 4) !== -1 ||\r\n url.indexOf(\"blob:\") !== -1;\r\n if (codecSupportedFound) {\r\n // Loading sound\r\n if (!this._streaming) {\r\n this._scene._loadFile(\r\n url,\r\n (data) => {\r\n this._soundLoaded(data as ArrayBuffer);\r\n },\r\n undefined,\r\n true,\r\n true,\r\n (exception) => {\r\n if (exception) {\r\n Logger.Error(\"XHR \" + exception.status + \" error on: \" + url + \".\");\r\n }\r\n Logger.Error(\"Sound creation aborted.\");\r\n this._scene.mainSoundTrack.removeSound(this);\r\n }\r\n );\r\n }\r\n // Streaming sound using HTML5 Audio tag\r\n else {\r\n this._htmlAudioElement = new Audio(url);\r\n this._htmlAudioElement.controls = false;\r\n this._htmlAudioElement.loop = this.loop;\r\n Tools.SetCorsBehavior(url, this._htmlAudioElement);\r\n this._htmlAudioElement.preload = \"auto\";\r\n this._htmlAudioElement.addEventListener(\"canplaythrough\", () => {\r\n this._isReadyToPlay = true;\r\n if (this.autoplay) {\r\n this.play(0, this._offset, this._length);\r\n }\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n });\r\n document.body.appendChild(this._htmlAudioElement);\r\n this._htmlAudioElement.load();\r\n }\r\n break;\r\n }\r\n }\r\n break;\r\n default:\r\n validParameter = false;\r\n break;\r\n }\r\n\r\n if (!validParameter) {\r\n Logger.Error(\"Parameter must be a URL to the sound, an Array of URLs (.mp3 & .ogg) or an ArrayBuffer of the sound.\");\r\n } else {\r\n if (!codecSupportedFound) {\r\n this._isReadyToPlay = true;\r\n // Simulating a ready to play event to avoid breaking code path\r\n if (this._readyToPlayCallback) {\r\n window.setTimeout(() => {\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n }, 1000);\r\n }\r\n }\r\n }\r\n } catch (ex) {\r\n Logger.Error(\"Unexpected error. Sound creation aborted.\");\r\n this._scene.mainSoundTrack.removeSound(this);\r\n }\r\n }\r\n } else {\r\n // Adding an empty sound to avoid breaking audio calls for non Web Audio browsers\r\n this._scene.mainSoundTrack.addSound(this);\r\n if (Engine.audioEngine && !Engine.audioEngine.WarnedWebAudioUnsupported) {\r\n Logger.Error(\"Web Audio is not supported by your browser.\");\r\n Engine.audioEngine.WarnedWebAudioUnsupported = true;\r\n }\r\n // Simulating a ready to play event to avoid breaking code for non web audio browsers\r\n if (this._readyToPlayCallback) {\r\n window.setTimeout(() => {\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n }, 1000);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Release the sound and its associated resources\r\n */\r\n public dispose() {\r\n if (Engine.audioEngine?.canUseWebAudio) {\r\n if (this.isPlaying) {\r\n this.stop();\r\n }\r\n this._isReadyToPlay = false;\r\n if (this.soundTrackId === -1) {\r\n this._scene.mainSoundTrack.removeSound(this);\r\n } else if (this._scene.soundTracks) {\r\n this._scene.soundTracks[this.soundTrackId].removeSound(this);\r\n }\r\n if (this._soundGain) {\r\n this._soundGain.disconnect();\r\n this._soundGain = null;\r\n }\r\n if (this._soundPanner) {\r\n this._soundPanner.disconnect();\r\n this._soundPanner = null;\r\n }\r\n if (this._soundSource) {\r\n this._soundSource.disconnect();\r\n this._soundSource = null;\r\n }\r\n this._audioBuffer = null;\r\n\r\n if (this._htmlAudioElement) {\r\n this._htmlAudioElement.pause();\r\n this._htmlAudioElement.src = \"\";\r\n document.body.removeChild(this._htmlAudioElement);\r\n }\r\n\r\n if (this._streamingSource) {\r\n this._streamingSource.disconnect();\r\n }\r\n\r\n if (this._connectedTransformNode && this._registerFunc) {\r\n this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);\r\n this._connectedTransformNode = null;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets if the sounds is ready to be played or not.\r\n * @returns true if ready, otherwise false\r\n */\r\n public isReady(): boolean {\r\n return this._isReadyToPlay;\r\n }\r\n\r\n /**\r\n * Get the current class name.\r\n * @returns current class name\r\n */\r\n public getClassName(): string {\r\n return \"Sound\";\r\n }\r\n\r\n private _audioBufferLoaded(buffer: AudioBuffer) {\r\n if (!Engine.audioEngine?.audioContext) {\r\n return;\r\n }\r\n this._audioBuffer = buffer;\r\n this._isReadyToPlay = true;\r\n if (this.autoplay) {\r\n this.play(0, this._offset, this._length);\r\n }\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n }\r\n\r\n private _soundLoaded(audioData: ArrayBuffer) {\r\n if (!Engine.audioEngine?.audioContext) {\r\n return;\r\n }\r\n Engine.audioEngine.audioContext.decodeAudioData(\r\n audioData,\r\n (buffer) => {\r\n this._audioBufferLoaded(buffer);\r\n },\r\n (err: any) => {\r\n Logger.Error(\"Error while decoding audio data for: \" + this.name + \" / Error: \" + err);\r\n }\r\n );\r\n }\r\n\r\n /**\r\n * Sets the data of the sound from an audiobuffer\r\n * @param audioBuffer The audioBuffer containing the data\r\n */\r\n public setAudioBuffer(audioBuffer: AudioBuffer): void {\r\n if (Engine.audioEngine?.canUseWebAudio) {\r\n this._audioBuffer = audioBuffer;\r\n this._isReadyToPlay = true;\r\n }\r\n }\r\n\r\n /**\r\n * Updates the current sounds options such as maxdistance, loop...\r\n * @param options A JSON object containing values named as the object properties\r\n */\r\n public updateOptions(options: ISoundOptions): void {\r\n if (options) {\r\n this.loop = options.loop ?? this.loop;\r\n this.maxDistance = options.maxDistance ?? this.maxDistance;\r\n this.useCustomAttenuation = options.useCustomAttenuation ?? this.useCustomAttenuation;\r\n this.rolloffFactor = options.rolloffFactor ?? this.rolloffFactor;\r\n this.refDistance = options.refDistance ?? this.refDistance;\r\n this.distanceModel = options.distanceModel ?? this.distanceModel;\r\n this._playbackRate = options.playbackRate ?? this._playbackRate;\r\n this._length = options.length ?? undefined;\r\n this._offset = options.offset ?? undefined;\r\n this.setVolume(options.volume ?? this._volume);\r\n this._updateSpatialParameters();\r\n if (this.isPlaying) {\r\n if (this._streaming && this._htmlAudioElement) {\r\n this._htmlAudioElement.playbackRate = this._playbackRate;\r\n if (this._htmlAudioElement.loop !== this.loop) {\r\n this._htmlAudioElement.loop = this.loop;\r\n }\r\n } else {\r\n if (this._soundSource) {\r\n this._soundSource.playbackRate.value = this._playbackRate;\r\n if (this._soundSource.loop !== this.loop) {\r\n this._soundSource.loop = this.loop;\r\n }\r\n if (this._offset !== undefined && this._soundSource.loopStart !== this._offset) {\r\n this._soundSource.loopStart = this._offset;\r\n }\r\n if (this._length !== undefined && this._length !== this._soundSource.loopEnd) {\r\n this._soundSource.loopEnd = (this._offset! | 0) + this._length!;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n private _createSpatialParameters() {\r\n if (Engine.audioEngine?.canUseWebAudio && Engine.audioEngine.audioContext) {\r\n if (this._scene.headphone) {\r\n this._panningModel = \"HRTF\";\r\n }\r\n this._soundPanner = this._soundPanner ?? Engine.audioEngine.audioContext.createPanner();\r\n if (this._soundPanner && this._outputAudioNode) {\r\n this._updateSpatialParameters();\r\n this._soundPanner.connect(this._outputAudioNode);\r\n this._inputAudioNode = this._soundPanner;\r\n }\r\n }\r\n }\r\n\r\n private _updateSpatialParameters() {\r\n if (this._spatialSound && this._soundPanner) {\r\n if (this.useCustomAttenuation) {\r\n // Tricks to disable in a way embedded Web Audio attenuation\r\n this._soundPanner.distanceModel = \"linear\";\r\n this._soundPanner.maxDistance = Number.MAX_VALUE;\r\n this._soundPanner.refDistance = 1;\r\n this._soundPanner.rolloffFactor = 1;\r\n this._soundPanner.panningModel = this._panningModel as any;\r\n } else {\r\n this._soundPanner.distanceModel = this.distanceModel as any;\r\n this._soundPanner.maxDistance = this.maxDistance;\r\n this._soundPanner.refDistance = this.refDistance;\r\n this._soundPanner.rolloffFactor = this.rolloffFactor;\r\n this._soundPanner.panningModel = this._panningModel as any;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Switch the panning model to HRTF:\r\n * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound\r\n */\r\n public switchPanningModelToHRTF() {\r\n this._panningModel = \"HRTF\";\r\n this._switchPanningModel();\r\n }\r\n\r\n /**\r\n * Switch the panning model to Equal Power:\r\n * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound\r\n */\r\n public switchPanningModelToEqualPower() {\r\n this._panningModel = \"equalpower\";\r\n this._switchPanningModel();\r\n }\r\n\r\n private _switchPanningModel() {\r\n if (Engine.audioEngine?.canUseWebAudio && this._spatialSound && this._soundPanner) {\r\n this._soundPanner.panningModel = this._panningModel as any;\r\n }\r\n }\r\n\r\n /**\r\n * Connect this sound to a sound track audio node like gain...\r\n * @param soundTrackAudioNode the sound track audio node to connect to\r\n */\r\n public connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void {\r\n if (Engine.audioEngine?.canUseWebAudio && this._outputAudioNode) {\r\n if (this._isOutputConnected) {\r\n this._outputAudioNode.disconnect();\r\n }\r\n this._outputAudioNode.connect(soundTrackAudioNode);\r\n this._isOutputConnected = true;\r\n }\r\n }\r\n\r\n /**\r\n * Transform this sound into a directional source\r\n * @param coneInnerAngle Size of the inner cone in degree\r\n * @param coneOuterAngle Size of the outer cone in degree\r\n * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)\r\n */\r\n public setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void {\r\n if (coneOuterAngle < coneInnerAngle) {\r\n Logger.Error(\"setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.\");\r\n return;\r\n }\r\n this._coneInnerAngle = coneInnerAngle;\r\n this._coneOuterAngle = coneOuterAngle;\r\n this._coneOuterGain = coneOuterGain;\r\n this._isDirectional = true;\r\n\r\n if (this.isPlaying && this.loop) {\r\n this.stop();\r\n this.play(0, this._offset, this._length);\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets the inner angle for the directional cone.\r\n */\r\n public get directionalConeInnerAngle(): number {\r\n return this._coneInnerAngle;\r\n }\r\n\r\n /**\r\n * Gets or sets the inner angle for the directional cone.\r\n */\r\n public set directionalConeInnerAngle(value: number) {\r\n if (value != this._coneInnerAngle) {\r\n if (this._coneOuterAngle < value) {\r\n Logger.Error(\"directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.\");\r\n return;\r\n }\r\n\r\n this._coneInnerAngle = value;\r\n if (Engine.audioEngine?.canUseWebAudio && this._spatialSound && this._soundPanner) {\r\n this._soundPanner.coneInnerAngle = this._coneInnerAngle;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets the outer angle for the directional cone.\r\n */\r\n public get directionalConeOuterAngle(): number {\r\n return this._coneOuterAngle;\r\n }\r\n\r\n /**\r\n * Gets or sets the outer angle for the directional cone.\r\n */\r\n public set directionalConeOuterAngle(value: number) {\r\n if (value != this._coneOuterAngle) {\r\n if (value < this._coneInnerAngle) {\r\n Logger.Error(\"directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.\");\r\n return;\r\n }\r\n\r\n this._coneOuterAngle = value;\r\n if (Engine.audioEngine?.canUseWebAudio && this._spatialSound && this._soundPanner) {\r\n this._soundPanner.coneOuterAngle = this._coneOuterAngle;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Sets the position of the emitter if spatial sound is enabled\r\n * @param newPosition Defines the new position\r\n */\r\n public setPosition(newPosition: Vector3): void {\r\n if (newPosition.equals(this._position)) {\r\n return;\r\n }\r\n this._position.copyFrom(newPosition);\r\n\r\n if (Engine.audioEngine?.canUseWebAudio && this._spatialSound && this._soundPanner && !isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {\r\n this._soundPanner.positionX.value = this._position.x;\r\n this._soundPanner.positionY.value = this._position.y;\r\n this._soundPanner.positionZ.value = this._position.z;\r\n }\r\n }\r\n\r\n /**\r\n * Sets the local direction of the emitter if spatial sound is enabled\r\n * @param newLocalDirection Defines the new local direction\r\n */\r\n public setLocalDirectionToMesh(newLocalDirection: Vector3): void {\r\n this._localDirection = newLocalDirection;\r\n\r\n if (Engine.audioEngine?.canUseWebAudio && this._connectedTransformNode && this.isPlaying) {\r\n this._updateDirection();\r\n }\r\n }\r\n\r\n private _updateDirection() {\r\n if (!this._connectedTransformNode || !this._soundPanner) {\r\n return;\r\n }\r\n\r\n const mat = this._connectedTransformNode.getWorldMatrix();\r\n const direction = Vector3.TransformNormal(this._localDirection, mat);\r\n direction.normalize();\r\n this._soundPanner.orientationX.value = direction.x;\r\n this._soundPanner.orientationY.value = direction.y;\r\n this._soundPanner.orientationZ.value = direction.z;\r\n }\r\n\r\n /** @internal */\r\n public updateDistanceFromListener() {\r\n if (Engine.audioEngine?.canUseWebAudio && this._connectedTransformNode && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) {\r\n const distance = this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);\r\n this._soundGain.gain.value = this._customAttenuationFunction(this._volume, distance, this.maxDistance, this.refDistance, this.rolloffFactor);\r\n }\r\n }\r\n\r\n /**\r\n * Sets a new custom attenuation function for the sound.\r\n * @param callback Defines the function used for the attenuation\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function\r\n */\r\n public setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void {\r\n this._customAttenuationFunction = callback;\r\n }\r\n\r\n /**\r\n * Play the sound\r\n * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.\r\n * @param offset (optional) Start the sound at a specific time in seconds\r\n * @param length (optional) Sound duration (in seconds)\r\n */\r\n public play(time?: number, offset?: number, length?: number): void {\r\n if (this._isReadyToPlay && this._scene.audioEnabled && Engine.audioEngine?.audioContext) {\r\n try {\r\n if (this._startOffset < 0) {\r\n time = -this._startOffset;\r\n this._startOffset = 0;\r\n }\r\n let startTime = time ? Engine.audioEngine?.audioContext.currentTime + time : Engine.audioEngine?.audioContext.currentTime;\r\n if (!this._soundSource || !this._streamingSource) {\r\n if (this._spatialSound && this._soundPanner) {\r\n if (!isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {\r\n this._soundPanner.positionX.value = this._position.x;\r\n this._soundPanner.positionY.value = this._position.y;\r\n this._soundPanner.positionZ.value = this._position.z;\r\n }\r\n if (this._isDirectional) {\r\n this._soundPanner.coneInnerAngle = this._coneInnerAngle;\r\n this._soundPanner.coneOuterAngle = this._coneOuterAngle;\r\n this._soundPanner.coneOuterGain = this._coneOuterGain;\r\n if (this._connectedTransformNode) {\r\n this._updateDirection();\r\n } else {\r\n this._soundPanner.setOrientation(this._localDirection.x, this._localDirection.y, this._localDirection.z);\r\n }\r\n }\r\n }\r\n }\r\n if (this._streaming) {\r\n if (!this._streamingSource) {\r\n this._streamingSource = Engine.audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement);\r\n this._htmlAudioElement.onended = () => {\r\n this._onended();\r\n };\r\n this._htmlAudioElement.playbackRate = this._playbackRate;\r\n }\r\n this._streamingSource.disconnect();\r\n if (this._inputAudioNode) {\r\n this._streamingSource.connect(this._inputAudioNode);\r\n }\r\n if (this._htmlAudioElement) {\r\n // required to manage properly the new suspended default state of Chrome\r\n // When the option 'streaming: true' is used, we need first to wait for\r\n // the audio engine to be unlocked by a user gesture before trying to play\r\n // an HTML Audio element\r\n const tryToPlay = () => {\r\n if (Engine.audioEngine?.unlocked) {\r\n const playPromise = this._htmlAudioElement.play();\r\n\r\n // In browsers that don’t yet support this functionality,\r\n // playPromise won’t be defined.\r\n if (playPromise !== undefined) {\r\n playPromise.catch(() => {\r\n // Automatic playback failed.\r\n // Waiting for the audio engine to be unlocked by user click on unmute\r\n Engine.audioEngine?.lock();\r\n if (this.loop || this.autoplay) {\r\n Engine.audioEngine?.onAudioUnlockedObservable.addOnce(() => {\r\n tryToPlay();\r\n });\r\n }\r\n });\r\n }\r\n } else {\r\n if (this.loop || this.autoplay) {\r\n Engine.audioEngine?.onAudioUnlockedObservable.addOnce(() => {\r\n tryToPlay();\r\n });\r\n }\r\n }\r\n };\r\n tryToPlay();\r\n }\r\n } else {\r\n const tryToPlay = () => {\r\n if (Engine.audioEngine?.audioContext) {\r\n length = length || this._length;\r\n offset = offset || this._offset;\r\n\r\n if (this._soundSource) {\r\n const oldSource = this._soundSource;\r\n oldSource.onended = () => {\r\n oldSource.disconnect();\r\n };\r\n }\r\n this._soundSource = Engine.audioEngine?.audioContext.createBufferSource();\r\n if (this._soundSource && this._inputAudioNode) {\r\n this._soundSource.buffer = this._audioBuffer;\r\n this._soundSource.connect(this._inputAudioNode);\r\n this._soundSource.loop = this.loop;\r\n if (offset !== undefined) {\r\n this._soundSource.loopStart = offset;\r\n }\r\n if (length !== undefined) {\r\n this._soundSource.loopEnd = (offset! | 0) + length!;\r\n }\r\n this._soundSource.playbackRate.value = this._playbackRate;\r\n this._soundSource.onended = () => {\r\n this._onended();\r\n };\r\n startTime = time ? Engine.audioEngine?.audioContext!.currentTime + time : Engine.audioEngine.audioContext!.currentTime;\r\n const actualOffset = this.isPaused ? this._startOffset % this._soundSource!.buffer!.duration : offset ? offset : 0;\r\n this._soundSource!.start(startTime, actualOffset, this.loop ? undefined : length);\r\n }\r\n }\r\n };\r\n\r\n if (Engine.audioEngine?.audioContext.state === \"suspended\") {\r\n // Wait a bit for FF as context seems late to be ready.\r\n setTimeout(() => {\r\n if (Engine.audioEngine?.audioContext!.state === \"suspended\") {\r\n // Automatic playback failed.\r\n // Waiting for the audio engine to be unlocked by user click on unmute\r\n Engine.audioEngine.lock();\r\n if (this.loop || this.autoplay) {\r\n Engine.audioEngine.onAudioUnlockedObservable.addOnce(() => {\r\n tryToPlay();\r\n });\r\n }\r\n } else {\r\n tryToPlay();\r\n }\r\n }, 500);\r\n } else {\r\n tryToPlay();\r\n }\r\n }\r\n this._startTime = startTime;\r\n this.isPlaying = true;\r\n this.isPaused = false;\r\n } catch (ex) {\r\n Logger.Error(\"Error while trying to play audio: \" + this.name + \", \" + ex.message);\r\n }\r\n }\r\n }\r\n\r\n private _onended() {\r\n this.isPlaying = false;\r\n this._startOffset = 0;\r\n if (this.onended) {\r\n this.onended();\r\n }\r\n this.onEndedObservable.notifyObservers(this);\r\n }\r\n\r\n /**\r\n * Stop the sound\r\n * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.\r\n */\r\n public stop(time?: number): void {\r\n if (this.isPlaying) {\r\n if (this._streaming) {\r\n if (this._htmlAudioElement) {\r\n this._htmlAudioElement.pause();\r\n // Test needed for Firefox or it will generate an Invalid State Error\r\n if (this._htmlAudioElement.currentTime > 0) {\r\n this._htmlAudioElement.currentTime = 0;\r\n }\r\n } else {\r\n this._streamingSource.disconnect();\r\n }\r\n this.isPlaying = false;\r\n } else if (Engine.audioEngine?.audioContext && this._soundSource) {\r\n const stopTime = time ? Engine.audioEngine.audioContext.currentTime + time : undefined;\r\n this._soundSource.stop(stopTime);\r\n if (stopTime === undefined) {\r\n this.isPlaying = false;\r\n this._soundSource.onended = () => void 0;\r\n } else {\r\n this._soundSource.onended = () => {\r\n this.isPlaying = false;\r\n };\r\n }\r\n if (!this.isPaused) {\r\n this._startOffset = 0;\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Put the sound in pause\r\n */\r\n public pause(): void {\r\n if (this.isPlaying) {\r\n this.isPaused = true;\r\n if (this._streaming) {\r\n if (this._htmlAudioElement) {\r\n this._htmlAudioElement.pause();\r\n } else {\r\n this._streamingSource.disconnect();\r\n }\r\n this.isPlaying = false;\r\n } else if (Engine.audioEngine?.audioContext) {\r\n this.stop(0);\r\n this._startOffset += Engine.audioEngine.audioContext.currentTime - this._startTime;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Sets a dedicated volume for this sounds\r\n * @param newVolume Define the new volume of the sound\r\n * @param time Define time for gradual change to new volume\r\n */\r\n public setVolume(newVolume: number, time?: number): void {\r\n if (Engine.audioEngine?.canUseWebAudio && this._soundGain) {\r\n if (time && Engine.audioEngine.audioContext) {\r\n this._soundGain.gain.cancelScheduledValues(Engine.audioEngine.audioContext.currentTime);\r\n this._soundGain.gain.setValueAtTime(this._soundGain.gain.value, Engine.audioEngine.audioContext.currentTime);\r\n this._soundGain.gain.linearRampToValueAtTime(newVolume, Engine.audioEngine.audioContext.currentTime + time);\r\n } else {\r\n this._soundGain.gain.value = newVolume;\r\n }\r\n }\r\n this._volume = newVolume;\r\n }\r\n\r\n /**\r\n * Set the sound play back rate\r\n * @param newPlaybackRate Define the playback rate the sound should be played at\r\n */\r\n public setPlaybackRate(newPlaybackRate: number): void {\r\n this._playbackRate = newPlaybackRate;\r\n if (this.isPlaying) {\r\n if (this._streaming && this._htmlAudioElement) {\r\n this._htmlAudioElement.playbackRate = this._playbackRate;\r\n } else if (this._soundSource) {\r\n this._soundSource.playbackRate.value = this._playbackRate;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets the volume of the sound.\r\n * @returns the volume of the sound\r\n */\r\n public getVolume(): number {\r\n return this._volume;\r\n }\r\n\r\n /**\r\n * Attach the sound to a dedicated mesh\r\n * @param transformNode The transform node to connect the sound with\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh\r\n */\r\n public attachToMesh(transformNode: TransformNode): void {\r\n if (this._connectedTransformNode && this._registerFunc) {\r\n this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);\r\n this._registerFunc = null;\r\n }\r\n this._connectedTransformNode = transformNode;\r\n if (!this._spatialSound) {\r\n this._spatialSound = true;\r\n this._createSpatialParameters();\r\n if (this.isPlaying && this.loop) {\r\n this.stop();\r\n this.play(0, this._offset, this._length);\r\n }\r\n }\r\n this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode);\r\n this._registerFunc = (transformNode: TransformNode) => this._onRegisterAfterWorldMatrixUpdate(transformNode);\r\n this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc);\r\n }\r\n\r\n /**\r\n * Detach the sound from the previously attached mesh\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh\r\n */\r\n public detachFromMesh() {\r\n if (this._connectedTransformNode && this._registerFunc) {\r\n this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);\r\n this._registerFunc = null;\r\n this._connectedTransformNode = null;\r\n }\r\n }\r\n\r\n private _onRegisterAfterWorldMatrixUpdate(node: TransformNode): void {\r\n if (!(<any>node).getBoundingInfo) {\r\n this.setPosition(node.absolutePosition);\r\n } else {\r\n const mesh = node as AbstractMesh;\r\n const boundingInfo = mesh.getBoundingInfo();\r\n this.setPosition(boundingInfo.boundingSphere.centerWorld);\r\n }\r\n if (Engine.audioEngine?.canUseWebAudio && this._isDirectional && this.isPlaying) {\r\n this._updateDirection();\r\n }\r\n }\r\n\r\n /**\r\n * Clone the current sound in the scene.\r\n * @returns the new sound clone\r\n */\r\n public clone(): Nullable<Sound> {\r\n if (!this._streaming) {\r\n const setBufferAndRun = () => {\r\n if (this._isReadyToPlay) {\r\n clonedSound._audioBuffer = this.getAudioBuffer();\r\n clonedSound._isReadyToPlay = true;\r\n if (clonedSound.autoplay) {\r\n clonedSound.play(0, this._offset, this._length);\r\n }\r\n } else {\r\n window.setTimeout(setBufferAndRun, 300);\r\n }\r\n };\r\n\r\n const currentOptions = {\r\n autoplay: this.autoplay,\r\n loop: this.loop,\r\n volume: this._volume,\r\n spatialSound: this._spatialSound,\r\n maxDistance: this.maxDistance,\r\n useCustomAttenuation: this.useCustomAttenuation,\r\n rolloffFactor: this.rolloffFactor,\r\n refDistance: this.refDistance,\r\n distanceModel: this.distanceModel,\r\n };\r\n\r\n const clonedSound = new Sound(this.name + \"_cloned\", new ArrayBuffer(0), this._scene, null, currentOptions);\r\n if (this.useCustomAttenuation) {\r\n clonedSound.setAttenuationFunction(this._customAttenuationFunction);\r\n }\r\n clonedSound.setPosition(this._position);\r\n clonedSound.setPlaybackRate(this._playbackRate);\r\n setBufferAndRun();\r\n\r\n return clonedSound;\r\n }\r\n // Can't clone a streaming sound\r\n else {\r\n return null;\r\n }\r\n }\r\n\r\n /**\r\n * Gets the current underlying audio buffer containing the data\r\n * @returns the audio buffer\r\n */\r\n public getAudioBuffer(): Nullable<AudioBuffer> {\r\n return this._audioBuffer;\r\n }\r\n\r\n /**\r\n * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.\r\n * @returns the source node\r\n */\r\n public getSoundSource(): Nullable<AudioBufferSourceNode> {\r\n return this._soundSource;\r\n }\r\n\r\n /**\r\n * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.\r\n * @returns the gain node\r\n */\r\n public getSoundGain(): Nullable<GainNode> {\r\n return this._soundGain;\r\n }\r\n\r\n /**\r\n * Serializes the Sound in a JSON representation\r\n * @returns the JSON representation of the sound\r\n */\r\n public serialize(): any {\r\n const serializationObject: any = {\r\n name: this.name,\r\n url: this.name,\r\n autoplay: this.autoplay,\r\n loop: this.loop,\r\n volume: this._volume,\r\n spatialSound: this._spatialSound,\r\n maxDistance: this.maxDistance,\r\n rolloffFactor: this.rolloffFactor,\r\n refDistance: this.refDistance,\r\n distanceModel: this.distanceModel,\r\n playbackRate: this._playbackRate,\r\n panningModel: this._panningModel,\r\n soundTrackId: this.soundTrackId,\r\n metadata: this.metadata,\r\n };\r\n\r\n if (this._spatialSound) {\r\n if (this._connectedTransformNode) {\r\n serializationObject.connectedMeshId = this._connectedTransformNode.id;\r\n }\r\n\r\n serializationObject.position = this._position.asArray();\r\n serializationObject.refDistance = this.refDistance;\r\n serializationObject.distanceModel = this.distanceModel;\r\n\r\n serializationObject.isDirectional = this._isDirectional;\r\n serializationObject.localDirectionToMesh = this._localDirection.asArray();\r\n serializationObject.coneInnerAngle = this._coneInnerAngle;\r\n serializationObject.coneOuterAngle = this._coneOuterAngle;\r\n serializationObject.coneOuterGain = this._coneOuterGain;\r\n }\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse a JSON representation of a sound to instantiate in a given scene\r\n * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)\r\n * @param scene Define the scene the new parsed sound should be created in\r\n * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies\r\n * @param sourceSound Define a sound place holder if do not need to instantiate a new one\r\n * @returns the newly parsed sound\r\n */\r\n public static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound {\r\n const soundName = parsedSound.name;\r\n let soundUrl;\r\n\r\n if (parsedSound.url) {\r\n soundUrl = rootUrl + parsedSound.url;\r\n } else {\r\n soundUrl = rootUrl + soundName;\r\n }\r\n\r\n const options = {\r\n autoplay: parsedSound.autoplay,\r\n loop: parsedSound.loop,\r\n volume: parsedSound.volume,\r\n spatialSound: parsedSound.spatialSound,\r\n maxDistance: parsedSound.maxDistance,\r\n rolloffFactor: parsedSound.rolloffFactor,\r\n refDistance: parsedSound.refDistance,\r\n distanceModel: parsedSound.distanceModel,\r\n playbackRate: parsedSound.playbackRate,\r\n };\r\n\r\n let newSound: Sound;\r\n\r\n if (!sourceSound) {\r\n newSound = new Sound(\r\n soundName,\r\n soundUrl,\r\n scene,\r\n () => {\r\n scene.removePendingData(newSound);\r\n },\r\n options\r\n );\r\n scene.addPendingData(newSound);\r\n } else {\r\n const setBufferAndRun = () => {\r\n if (sourceSound._isReadyToPlay) {\r\n newSound._audioBuffer = sourceSound.getAudioBuffer();\r\n newSound._isReadyToPlay = true;\r\n if (newSound.autoplay) {\r\n newSound.play(0, newSound._offset, newSound._length);\r\n }\r\n } else {\r\n window.setTimeout(setBufferAndRun, 300);\r\n }\r\n };\r\n\r\n newSound = new Sound(soundName, new ArrayBuffer(0), scene, null, options);\r\n setBufferAndRun();\r\n }\r\n\r\n if (parsedSound.position) {\r\n const soundPosition = Vector3.FromArray(parsedSound.position);\r\n newSound.setPosition(soundPosition);\r\n }\r\n if (parsedSound.isDirectional) {\r\n newSound.setDirectionalCone(parsedSound.coneInnerAngle || 360, parsedSound.coneOuterAngle || 360, parsedSound.coneOuterGain || 0);\r\n if (parsedSound.localDirectionToMesh) {\r\n const localDirectionToMesh = Vector3.FromArray(parsedSound.localDirectionToMesh);\r\n newSound.setLocalDirectionToMesh(localDirectionToMesh);\r\n }\r\n }\r\n if (parsedSound.connectedMeshId) {\r\n const connectedMesh = scene.getMeshById(parsedSound.connectedMeshId);\r\n if (connectedMesh) {\r\n newSound.attachToMesh(connectedMesh);\r\n }\r\n }\r\n\r\n if (parsedSound.metadata) {\r\n newSound.metadata = parsedSound.metadata;\r\n }\r\n\r\n return newSound;\r\n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AC;aAC1D;SACJ;QACD,IAAI,WAAW,CAAC,eAAe,EAAE;YAC7B,MAAM,aAAa,GAAG,KAAK,CAAC,WAAW,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;YACrE,IAAI,aAAa,EAAE;gBACf,QAAQ,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;aACxC;SACJ;QAED,IAAI,WAAW,CAAC,QAAQ,EAAE;YACtB,QAAQ,CAAC,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC;SAC5C;QAED,OAAO,QAAQ,CAAC;IACpB,CAAC;;AAjiCD;;GAEG;AACW,mCAA6B,GAA2B,CAAC,CAAC,EAAE,EAAE;IACxE,MAAM,WAAW,CAAC,qBAAqB,CAAC,CAAC;AAC7C,CAAC,CAAC","sourcesContent":["import { Tools } from \"../Misc/tools\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport { Vector3 } from \"../Maths/math.vector\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport { Engine } from \"../Engines/engine\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { TransformNode } from \"../Meshes/transformNode\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { _WarnImport } from \"../Misc/devTools\";\r\nimport type { ISoundOptions } from \"./Interfaces/ISoundOptions\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\n\r\n/**\r\n * Defines a sound that can be played in the application.\r\n * The sound can either be an ambient track or a simple sound played in reaction to a user action.\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music\r\n */\r\nexport class Sound {\r\n /**\r\n * The name of the sound in the scene.\r\n */\r\n public name: string;\r\n /**\r\n * Does the sound autoplay once loaded.\r\n */\r\n public autoplay: boolean = false;\r\n\r\n private _loop = false;\r\n /**\r\n * Does the sound loop after it finishes playing once.\r\n */\r\n public get loop(): boolean {\r\n return this._loop;\r\n }\r\n\r\n public set loop(value: boolean) {\r\n if (value === this._loop) {\r\n return;\r\n }\r\n\r\n this._loop = value;\r\n this.updateOptions({ loop: value });\r\n }\r\n\r\n /**\r\n * Does the sound use a custom attenuation curve to simulate the falloff\r\n * happening when the source gets further away from the camera.\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function\r\n */\r\n public useCustomAttenuation: boolean = false;\r\n /**\r\n * The sound track id this sound belongs to.\r\n */\r\n public soundTrackId: number;\r\n /**\r\n * Is this sound currently played.\r\n */\r\n public isPlaying: boolean = false;\r\n /**\r\n * Is this sound currently paused.\r\n */\r\n public isPaused: boolean = false;\r\n /**\r\n * Define the reference distance the sound should be heard perfectly.\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound\r\n */\r\n public refDistance: number = 1;\r\n /**\r\n * Define the roll off factor of spatial sounds.\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound\r\n */\r\n public rolloffFactor: number = 1;\r\n /**\r\n * Define the max distance the sound should be heard (intensity just became 0 at this point).\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound\r\n */\r\n public maxDistance: number = 100;\r\n /**\r\n * Define the distance attenuation model the sound will follow.\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound\r\n */\r\n public distanceModel: string = \"linear\";\r\n /**\r\n * @internal\r\n * Back Compat\r\n **/\r\n public onended: () => any;\r\n /**\r\n * Gets or sets an object used to store user defined information for the sound.\r\n */\r\n public metadata: any = null;\r\n\r\n /**\r\n * Observable event when the current playing sound finishes.\r\n */\r\n public onEndedObservable = new Observable<Sound>();\r\n\r\n /**\r\n * Gets the current time for the sound.\r\n */\r\n public get currentTime(): number {\r\n if (this._htmlAudioElement) {\r\n return this._htmlAudioElement.currentTime;\r\n }\r\n\r\n let currentTime: number = this._startOffset;\r\n if (this.isPlaying && Engine.audioEngine?.audioContext) {\r\n currentTime += Engine.audioEngine.audioContext.currentTime - this._startTime;\r\n }\r\n return currentTime;\r\n }\r\n\r\n /**\r\n * Does this sound enables spatial sound.\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound\r\n */\r\n public get spatialSound(): boolean {\r\n return this._spatialSound;\r\n }\r\n /**\r\n * Does this sound enables spatial sound.\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound\r\n */\r\n public set spatialSound(newValue: boolean) {\r\n this._spatialSound = newValue;\r\n if (this._spatialSound && Engine.audioEngine?.canUseWebAudio && Engine.audioEngine.audioContext) {\r\n this._createSpatialParameters();\r\n }\r\n }\r\n private _spatialSound: boolean = false;\r\n private _panningModel: string = \"equalpower\";\r\n private _playbackRate: number = 1;\r\n private _streaming: boolean = false;\r\n private _startTime: number = 0;\r\n private _startOffset: number = 0;\r\n private _position: Vector3 = Vector3.Zero();\r\n private _localDirection: Vector3 = new Vector3(1, 0, 0);\r\n private _volume: number = 1;\r\n private _isReadyToPlay: boolean = false;\r\n private _isDirectional: boolean = false;\r\n private _readyToPlayCallback: Nullable<() => any>;\r\n private _audioBuffer: Nullable<AudioBuffer>;\r\n private _soundSource: Nullable<AudioBufferSourceNode>;\r\n private _streamingSource: AudioNode;\r\n private _soundPanner: Nullable<PannerNode>;\r\n private _soundGain: Nullable<GainNode>;\r\n private _inputAudioNode: Nullable<AudioNode>;\r\n private _outputAudioNode: Nullable<AudioNode>;\r\n // Used if you'd like to create a directional sound.\r\n // If not set, the sound will be omnidirectional\r\n private _coneInnerAngle: number = 360;\r\n private _coneOuterAngle: number = 360;\r\n private _coneOuterGain: number = 0;\r\n private _scene: Scene;\r\n private _connectedTransformNode: Nullable<TransformNode>;\r\n private _customAttenuationFunction: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number;\r\n private _registerFunc: Nullable<(connectedMesh: TransformNode) => void>;\r\n private _isOutputConnected = false;\r\n private _htmlAudioElement: HTMLAudioElement;\r\n private _urlType: \"Unknown\" | \"String\" | \"Array\" | \"ArrayBuffer\" | \"MediaStream\" | \"AudioBuffer\" | \"MediaElement\" = \"Unknown\";\r\n private _length?: number;\r\n private _offset?: number;\r\n\r\n /**\r\n * @internal\r\n */\r\n public static _SceneComponentInitialization: (scene: Scene) => void = (_) => {\r\n throw _WarnImport(\"AudioSceneComponent\");\r\n };\r\n\r\n /**\r\n * Create a sound and attach it to a scene\r\n * @param name Name of your sound\r\n * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams and AudioBuffers\r\n * @param scene defines the scene the sound belongs to\r\n * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played\r\n * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming\r\n */\r\n constructor(name: string, urlOrArrayBuffer: any, scene?: Nullable<Scene>, readyToPlayCallback: Nullable<() => void> = null, options?: ISoundOptions) {\r\n this.name = name;\r\n scene = scene || EngineStore.LastCreatedScene;\r\n if (!scene) {\r\n return;\r\n }\r\n this._scene = scene;\r\n Sound._SceneComponentInitialization(scene);\r\n\r\n this._readyToPlayCallback = readyToPlayCallback;\r\n // Default custom attenuation function is a linear attenuation\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n this._customAttenuationFunction = (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => {\r\n if (currentDistance < maxDistance) {\r\n return currentVolume * (1 - currentDistance / maxDistance);\r\n } else {\r\n return 0;\r\n }\r\n };\r\n if (options) {\r\n this.autoplay = options.autoplay || false;\r\n this._loop = options.loop || false;\r\n // if volume === 0, we need another way to check this option\r\n if (options.volume !== undefined) {\r\n this._volume = options.volume;\r\n }\r\n this._spatialSound = options.spatialSound ?? false;\r\n this.maxDistance = options.maxDistance ?? 100;\r\n this.useCustomAttenuation = options.useCustomAttenuation ?? false;\r\n this.rolloffFactor = options.rolloffFactor || 1;\r\n this.refDistance = options.refDistance || 1;\r\n this.distanceModel = options.distanceModel || \"linear\";\r\n this._playbackRate = options.playbackRate || 1;\r\n this._streaming = options.streaming ?? false;\r\n this._length = options.length;\r\n this._offset = options.offset;\r\n }\r\n\r\n if (Engine.audioEngine?.canUseWebAudio && Engine.audioEngine.audioContext) {\r\n this._soundGain = Engine.audioEngine.audioContext.createGain();\r\n this._soundGain!.gain.value = this._volume;\r\n this._inputAudioNode = this._soundGain;\r\n this._outputAudioNode = this._soundGain;\r\n if (this._spatialSound) {\r\n this._createSpatialParameters();\r\n }\r\n this._scene.mainSoundTrack.addSound(this);\r\n let validParameter = true;\r\n\r\n // if no parameter is passed, you need to call setAudioBuffer yourself to prepare the sound\r\n if (urlOrArrayBuffer) {\r\n try {\r\n if (typeof urlOrArrayBuffer === \"string\") {\r\n this._urlType = \"String\";\r\n } else if (urlOrArrayBuffer instanceof ArrayBuffer) {\r\n this._urlType = \"ArrayBuffer\";\r\n } else if (urlOrArrayBuffer instanceof HTMLMediaElement) {\r\n this._urlType = \"MediaElement\";\r\n } else if (urlOrArrayBuffer instanceof MediaStream) {\r\n this._urlType = \"MediaStream\";\r\n } else if (urlOrArrayBuffer instanceof AudioBuffer) {\r\n this._urlType = \"AudioBuffer\";\r\n } else if (Array.isArray(urlOrArrayBuffer)) {\r\n this._urlType = \"Array\";\r\n }\r\n\r\n let urls: string[] = [];\r\n let codecSupportedFound = false;\r\n\r\n switch (this._urlType) {\r\n case \"MediaElement\":\r\n this._streaming = true;\r\n this._isReadyToPlay = true;\r\n this._streamingSource = Engine.audioEngine.audioContext.createMediaElementSource(urlOrArrayBuffer);\r\n\r\n if (this.autoplay) {\r\n this.play(0, this._offset, this._length);\r\n }\r\n\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n break;\r\n case \"MediaStream\":\r\n this._streaming = true;\r\n this._isReadyToPlay = true;\r\n this._streamingSource = Engine.audioEngine.audioContext.createMediaStreamSource(urlOrArrayBuffer);\r\n\r\n if (this.autoplay) {\r\n this.play(0, this._offset, this._length);\r\n }\r\n\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n break;\r\n case \"ArrayBuffer\":\r\n if ((<ArrayBuffer>urlOrArrayBuffer).byteLength > 0) {\r\n codecSupportedFound = true;\r\n this._soundLoaded(urlOrArrayBuffer);\r\n }\r\n break;\r\n case \"AudioBuffer\":\r\n this._audioBufferLoaded(urlOrArrayBuffer);\r\n break;\r\n case \"String\":\r\n urls.push(urlOrArrayBuffer);\r\n // eslint-disable-next-line no-fallthrough\r\n case \"Array\":\r\n if (urls.length === 0) {\r\n urls = urlOrArrayBuffer;\r\n }\r\n // If we found a supported format, we load it immediately and stop the loop\r\n for (let i = 0; i < urls.length; i++) {\r\n const url = urls[i];\r\n codecSupportedFound =\r\n (options && options.skipCodecCheck) ||\r\n (url.indexOf(\".mp3\", url.length - 4) !== -1 && Engine.audioEngine.isMP3supported) ||\r\n (url.indexOf(\".ogg\", url.length - 4) !== -1 && Engine.audioEngine.isOGGsupported) ||\r\n url.indexOf(\".wav\", url.length - 4) !== -1 ||\r\n url.indexOf(\".m4a\", url.length - 4) !== -1 ||\r\n url.indexOf(\".mp4\", url.length - 4) !== -1 ||\r\n url.indexOf(\"blob:\") !== -1;\r\n if (codecSupportedFound) {\r\n // Loading sound\r\n if (!this._streaming) {\r\n this._scene._loadFile(\r\n url,\r\n (data) => {\r\n this._soundLoaded(data as ArrayBuffer);\r\n },\r\n undefined,\r\n true,\r\n true,\r\n (exception) => {\r\n if (exception) {\r\n Logger.Error(\"XHR \" + exception.status + \" error on: \" + url + \".\");\r\n }\r\n Logger.Error(\"Sound creation aborted.\");\r\n this._scene.mainSoundTrack.removeSound(this);\r\n }\r\n );\r\n }\r\n // Streaming sound using HTML5 Audio tag\r\n else {\r\n this._htmlAudioElement = new Audio(url);\r\n this._htmlAudioElement.controls = false;\r\n this._htmlAudioElement.loop = this.loop;\r\n Tools.SetCorsBehavior(url, this._htmlAudioElement);\r\n this._htmlAudioElement.preload = \"auto\";\r\n this._htmlAudioElement.addEventListener(\"canplaythrough\", () => {\r\n this._isReadyToPlay = true;\r\n if (this.autoplay) {\r\n this.play(0, this._offset, this._length);\r\n }\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n });\r\n document.body.appendChild(this._htmlAudioElement);\r\n this._htmlAudioElement.load();\r\n }\r\n break;\r\n }\r\n }\r\n break;\r\n default:\r\n validParameter = false;\r\n break;\r\n }\r\n\r\n if (!validParameter) {\r\n Logger.Error(\"Parameter must be a URL to the sound, an Array of URLs (.mp3 & .ogg) or an ArrayBuffer of the sound.\");\r\n } else {\r\n if (!codecSupportedFound) {\r\n this._isReadyToPlay = true;\r\n // Simulating a ready to play event to avoid breaking code path\r\n if (this._readyToPlayCallback) {\r\n window.setTimeout(() => {\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n }, 1000);\r\n }\r\n }\r\n }\r\n } catch (ex) {\r\n Logger.Error(\"Unexpected error. Sound creation aborted.\");\r\n this._scene.mainSoundTrack.removeSound(this);\r\n }\r\n }\r\n } else {\r\n // Adding an empty sound to avoid breaking audio calls for non Web Audio browsers\r\n this._scene.mainSoundTrack.addSound(this);\r\n if (Engine.audioEngine && !Engine.audioEngine.WarnedWebAudioUnsupported) {\r\n Logger.Error(\"Web Audio is not supported by your browser.\");\r\n Engine.audioEngine.WarnedWebAudioUnsupported = true;\r\n }\r\n // Simulating a ready to play event to avoid breaking code for non web audio browsers\r\n if (this._readyToPlayCallback) {\r\n window.setTimeout(() => {\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n }, 1000);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Release the sound and its associated resources\r\n */\r\n public dispose() {\r\n if (Engine.audioEngine?.canUseWebAudio) {\r\n if (this.isPlaying) {\r\n this.stop();\r\n }\r\n this._isReadyToPlay = false;\r\n if (this.soundTrackId === -1) {\r\n this._scene.mainSoundTrack.removeSound(this);\r\n } else if (this._scene.soundTracks) {\r\n this._scene.soundTracks[this.soundTrackId].removeSound(this);\r\n }\r\n if (this._soundGain) {\r\n this._soundGain.disconnect();\r\n this._soundGain = null;\r\n }\r\n if (this._soundPanner) {\r\n this._soundPanner.disconnect();\r\n this._soundPanner = null;\r\n }\r\n if (this._soundSource) {\r\n this._soundSource.disconnect();\r\n this._soundSource = null;\r\n }\r\n this._audioBuffer = null;\r\n\r\n if (this._htmlAudioElement) {\r\n this._htmlAudioElement.pause();\r\n this._htmlAudioElement.src = \"\";\r\n document.body.removeChild(this._htmlAudioElement);\r\n }\r\n\r\n if (this._streamingSource) {\r\n this._streamingSource.disconnect();\r\n }\r\n\r\n if (this._connectedTransformNode && this._registerFunc) {\r\n this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);\r\n this._connectedTransformNode = null;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets if the sounds is ready to be played or not.\r\n * @returns true if ready, otherwise false\r\n */\r\n public isReady(): boolean {\r\n return this._isReadyToPlay;\r\n }\r\n\r\n /**\r\n * Get the current class name.\r\n * @returns current class name\r\n */\r\n public getClassName(): string {\r\n return \"Sound\";\r\n }\r\n\r\n private _audioBufferLoaded(buffer: AudioBuffer) {\r\n if (!Engine.audioEngine?.audioContext) {\r\n return;\r\n }\r\n this._audioBuffer = buffer;\r\n this._isReadyToPlay = true;\r\n if (this.autoplay) {\r\n this.play(0, this._offset, this._length);\r\n }\r\n if (this._readyToPlayCallback) {\r\n this._readyToPlayCallback();\r\n }\r\n }\r\n\r\n private _soundLoaded(audioData: ArrayBuffer) {\r\n if (!Engine.audioEngine?.audioContext) {\r\n return;\r\n }\r\n Engine.audioEngine.audioContext.decodeAudioData(\r\n audioData,\r\n (buffer) => {\r\n this._audioBufferLoaded(buffer);\r\n },\r\n (err: any) => {\r\n Logger.Error(\"Error while decoding audio data for: \" + this.name + \" / Error: \" + err);\r\n }\r\n );\r\n }\r\n\r\n /**\r\n * Sets the data of the sound from an audiobuffer\r\n * @param audioBuffer The audioBuffer containing the data\r\n */\r\n public setAudioBuffer(audioBuffer: AudioBuffer): void {\r\n if (Engine.audioEngine?.canUseWebAudio) {\r\n this._audioBuffer = audioBuffer;\r\n this._isReadyToPlay = true;\r\n }\r\n }\r\n\r\n /**\r\n * Updates the current sounds options such as maxdistance, loop...\r\n * @param options A JSON object containing values named as the object properties\r\n */\r\n public updateOptions(options: ISoundOptions): void {\r\n if (options) {\r\n this.loop = options.loop ?? this.loop;\r\n this.maxDistance = options.maxDistance ?? this.maxDistance;\r\n this.useCustomAttenuation = options.useCustomAttenuation ?? this.useCustomAttenuation;\r\n this.rolloffFactor = options.rolloffFactor ?? this.rolloffFactor;\r\n this.refDistance = options.refDistance ?? this.refDistance;\r\n this.distanceModel = options.distanceModel ?? this.distanceModel;\r\n this._playbackRate = options.playbackRate ?? this._playbackRate;\r\n this._length = options.length ?? undefined;\r\n this._offset = options.offset ?? undefined;\r\n this.setVolume(options.volume ?? this._volume);\r\n this._updateSpatialParameters();\r\n if (this.isPlaying) {\r\n if (this._streaming && this._htmlAudioElement) {\r\n this._htmlAudioElement.playbackRate = this._playbackRate;\r\n if (this._htmlAudioElement.loop !== this.loop) {\r\n this._htmlAudioElement.loop = this.loop;\r\n }\r\n } else {\r\n if (this._soundSource) {\r\n this._soundSource.playbackRate.value = this._playbackRate;\r\n if (this._soundSource.loop !== this.loop) {\r\n this._soundSource.loop = this.loop;\r\n }\r\n if (this._offset !== undefined && this._soundSource.loopStart !== this._offset) {\r\n this._soundSource.loopStart = this._offset;\r\n }\r\n if (this._length !== undefined && this._length !== this._soundSource.loopEnd) {\r\n this._soundSource.loopEnd = (this._offset! | 0) + this._length!;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n private _createSpatialParameters() {\r\n if (Engine.audioEngine?.canUseWebAudio && Engine.audioEngine.audioContext) {\r\n if (this._scene.headphone) {\r\n this._panningModel = \"HRTF\";\r\n }\r\n this._soundPanner = this._soundPanner ?? Engine.audioEngine.audioContext.createPanner();\r\n if (this._soundPanner && this._outputAudioNode) {\r\n this._updateSpatialParameters();\r\n this._soundPanner.connect(this._outputAudioNode);\r\n this._inputAudioNode = this._soundPanner;\r\n }\r\n }\r\n }\r\n\r\n private _updateSpatialParameters() {\r\n if (this._spatialSound && this._soundPanner) {\r\n if (this.useCustomAttenuation) {\r\n // Tricks to disable in a way embedded Web Audio attenuation\r\n this._soundPanner.distanceModel = \"linear\";\r\n this._soundPanner.maxDistance = Number.MAX_VALUE;\r\n this._soundPanner.refDistance = 1;\r\n this._soundPanner.rolloffFactor = 1;\r\n this._soundPanner.panningModel = this._panningModel as any;\r\n } else {\r\n this._soundPanner.distanceModel = this.distanceModel as any;\r\n this._soundPanner.maxDistance = this.maxDistance;\r\n this._soundPanner.refDistance = this.refDistance;\r\n this._soundPanner.rolloffFactor = this.rolloffFactor;\r\n this._soundPanner.panningModel = this._panningModel as any;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Switch the panning model to HRTF:\r\n * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound\r\n */\r\n public switchPanningModelToHRTF() {\r\n this._panningModel = \"HRTF\";\r\n this._switchPanningModel();\r\n }\r\n\r\n /**\r\n * Switch the panning model to Equal Power:\r\n * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound\r\n */\r\n public switchPanningModelToEqualPower() {\r\n this._panningModel = \"equalpower\";\r\n this._switchPanningModel();\r\n }\r\n\r\n private _switchPanningModel() {\r\n if (Engine.audioEngine?.canUseWebAudio && this._spatialSound && this._soundPanner) {\r\n this._soundPanner.panningModel = this._panningModel as any;\r\n }\r\n }\r\n\r\n /**\r\n * Connect this sound to a sound track audio node like gain...\r\n * @param soundTrackAudioNode the sound track audio node to connect to\r\n */\r\n public connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void {\r\n if (Engine.audioEngine?.canUseWebAudio && this._outputAudioNode) {\r\n if (this._isOutputConnected) {\r\n this._outputAudioNode.disconnect();\r\n }\r\n this._outputAudioNode.connect(soundTrackAudioNode);\r\n this._isOutputConnected = true;\r\n }\r\n }\r\n\r\n /**\r\n * Transform this sound into a directional source\r\n * @param coneInnerAngle Size of the inner cone in degree\r\n * @param coneOuterAngle Size of the outer cone in degree\r\n * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)\r\n */\r\n public setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void {\r\n if (coneOuterAngle < coneInnerAngle) {\r\n Logger.Error(\"setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.\");\r\n return;\r\n }\r\n this._coneInnerAngle = coneInnerAngle;\r\n this._coneOuterAngle = coneOuterAngle;\r\n this._coneOuterGain = coneOuterGain;\r\n this._isDirectional = true;\r\n\r\n if (this.isPlaying && this.loop) {\r\n this.stop();\r\n this.play(0, this._offset, this._length);\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets the inner angle for the directional cone.\r\n */\r\n public get directionalConeInnerAngle(): number {\r\n return this._coneInnerAngle;\r\n }\r\n\r\n /**\r\n * Gets or sets the inner angle for the directional cone.\r\n */\r\n public set directionalConeInnerAngle(value: number) {\r\n if (value != this._coneInnerAngle) {\r\n if (this._coneOuterAngle < value) {\r\n Logger.Error(\"directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.\");\r\n return;\r\n }\r\n\r\n this._coneInnerAngle = value;\r\n if (Engine.audioEngine?.canUseWebAudio && this._spatialSound && this._soundPanner) {\r\n this._soundPanner.coneInnerAngle = this._coneInnerAngle;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets or sets the outer angle for the directional cone.\r\n */\r\n public get directionalConeOuterAngle(): number {\r\n return this._coneOuterAngle;\r\n }\r\n\r\n /**\r\n * Gets or sets the outer angle for the directional cone.\r\n */\r\n public set directionalConeOuterAngle(value: number) {\r\n if (value != this._coneOuterAngle) {\r\n if (value < this._coneInnerAngle) {\r\n Logger.Error(\"directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.\");\r\n return;\r\n }\r\n\r\n this._coneOuterAngle = value;\r\n if (Engine.audioEngine?.canUseWebAudio && this._spatialSound && this._soundPanner) {\r\n this._soundPanner.coneOuterAngle = this._coneOuterAngle;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Sets the position of the emitter if spatial sound is enabled\r\n * @param newPosition Defines the new position\r\n */\r\n public setPosition(newPosition: Vector3): void {\r\n if (newPosition.equals(this._position)) {\r\n return;\r\n }\r\n this._position.copyFrom(newPosition);\r\n\r\n if (Engine.audioEngine?.canUseWebAudio && this._spatialSound && this._soundPanner && !isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {\r\n this._soundPanner.positionX.value = this._position.x;\r\n this._soundPanner.positionY.value = this._position.y;\r\n this._soundPanner.positionZ.value = this._position.z;\r\n }\r\n }\r\n\r\n /**\r\n * Sets the local direction of the emitter if spatial sound is enabled\r\n * @param newLocalDirection Defines the new local direction\r\n */\r\n public setLocalDirectionToMesh(newLocalDirection: Vector3): void {\r\n this._localDirection = newLocalDirection;\r\n\r\n if (Engine.audioEngine?.canUseWebAudio && this._connectedTransformNode && this.isPlaying) {\r\n this._updateDirection();\r\n }\r\n }\r\n\r\n private _updateDirection() {\r\n if (!this._connectedTransformNode || !this._soundPanner) {\r\n return;\r\n }\r\n\r\n const mat = this._connectedTransformNode.getWorldMatrix();\r\n const direction = Vector3.TransformNormal(this._localDirection, mat);\r\n direction.normalize();\r\n this._soundPanner.orientationX.value = direction.x;\r\n this._soundPanner.orientationY.value = direction.y;\r\n this._soundPanner.orientationZ.value = direction.z;\r\n }\r\n\r\n /** @internal */\r\n public updateDistanceFromListener() {\r\n if (Engine.audioEngine?.canUseWebAudio && this._connectedTransformNode && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) {\r\n const distance = this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);\r\n this._soundGain.gain.value = this._customAttenuationFunction(this._volume, distance, this.maxDistance, this.refDistance, this.rolloffFactor);\r\n }\r\n }\r\n\r\n /**\r\n * Sets a new custom attenuation function for the sound.\r\n * @param callback Defines the function used for the attenuation\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function\r\n */\r\n public setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void {\r\n this._customAttenuationFunction = callback;\r\n }\r\n\r\n /**\r\n * Play the sound\r\n * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.\r\n * @param offset (optional) Start the sound at a specific time in seconds\r\n * @param length (optional) Sound duration (in seconds)\r\n */\r\n public play(time?: number, offset?: number, length?: number): void {\r\n if (this._isReadyToPlay && this._scene.audioEnabled && Engine.audioEngine?.audioContext) {\r\n try {\r\n if (this._startOffset < 0) {\r\n time = -this._startOffset;\r\n this._startOffset = 0;\r\n }\r\n let startTime = time ? Engine.audioEngine?.audioContext.currentTime + time : Engine.audioEngine?.audioContext.currentTime;\r\n if (!this._soundSource || !this._streamingSource) {\r\n if (this._spatialSound && this._soundPanner) {\r\n if (!isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {\r\n this._soundPanner.positionX.value = this._position.x;\r\n this._soundPanner.positionY.value = this._position.y;\r\n this._soundPanner.positionZ.value = this._position.z;\r\n }\r\n if (this._isDirectional) {\r\n this._soundPanner.coneInnerAngle = this._coneInnerAngle;\r\n this._soundPanner.coneOuterAngle = this._coneOuterAngle;\r\n this._soundPanner.coneOuterGain = this._coneOuterGain;\r\n if (this._connectedTransformNode) {\r\n this._updateDirection();\r\n } else {\r\n this._soundPanner.setOrientation(this._localDirection.x, this._localDirection.y, this._localDirection.z);\r\n }\r\n }\r\n }\r\n }\r\n if (this._streaming) {\r\n if (!this._streamingSource) {\r\n this._streamingSource = Engine.audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement);\r\n this._htmlAudioElement.onended = () => {\r\n this._onended();\r\n };\r\n this._htmlAudioElement.playbackRate = this._playbackRate;\r\n }\r\n this._streamingSource.disconnect();\r\n if (this._inputAudioNode) {\r\n this._streamingSource.connect(this._inputAudioNode);\r\n }\r\n if (this._htmlAudioElement) {\r\n // required to manage properly the new suspended default state of Chrome\r\n // When the option 'streaming: true' is used, we need first to wait for\r\n // the audio engine to be unlocked by a user gesture before trying to play\r\n // an HTML Audio element\r\n const tryToPlay = () => {\r\n if (Engine.audioEngine?.unlocked) {\r\n const playPromise = this._htmlAudioElement.play();\r\n\r\n // In browsers that don’t yet support this functionality,\r\n // playPromise won’t be defined.\r\n if (playPromise !== undefined) {\r\n playPromise.catch(() => {\r\n // Automatic playback failed.\r\n // Waiting for the audio engine to be unlocked by user click on unmute\r\n Engine.audioEngine?.lock();\r\n if (this.loop || this.autoplay) {\r\n Engine.audioEngine?.onAudioUnlockedObservable.addOnce(() => {\r\n tryToPlay();\r\n });\r\n }\r\n });\r\n }\r\n } else {\r\n if (this.loop || this.autoplay) {\r\n Engine.audioEngine?.onAudioUnlockedObservable.addOnce(() => {\r\n tryToPlay();\r\n });\r\n }\r\n }\r\n };\r\n tryToPlay();\r\n }\r\n } else {\r\n const tryToPlay = () => {\r\n if (Engine.audioEngine?.audioContext) {\r\n length = length || this._length;\r\n offset = offset || this._offset;\r\n\r\n if (this._soundSource) {\r\n const oldSource = this._soundSource;\r\n oldSource.onended = () => {\r\n oldSource.disconnect();\r\n };\r\n }\r\n this._soundSource = Engine.audioEngine?.audioContext.createBufferSource();\r\n if (this._soundSource && this._inputAudioNode) {\r\n this._soundSource.buffer = this._audioBuffer;\r\n this._soundSource.connect(this._inputAudioNode);\r\n this._soundSource.loop = this.loop;\r\n if (offset !== undefined) {\r\n this._soundSource.loopStart = offset;\r\n }\r\n if (length !== undefined) {\r\n this._soundSource.loopEnd = (offset! | 0) + length!;\r\n }\r\n this._soundSource.playbackRate.value = this._playbackRate;\r\n this._soundSource.onended = () => {\r\n this._onended();\r\n };\r\n startTime = time ? Engine.audioEngine?.audioContext!.currentTime + time : Engine.audioEngine.audioContext!.currentTime;\r\n const actualOffset = this.isPaused ? this._startOffset % this._soundSource!.buffer!.duration : offset ? offset : 0;\r\n this._soundSource!.start(startTime, actualOffset, this.loop ? undefined : length);\r\n }\r\n }\r\n };\r\n\r\n if (Engine.audioEngine?.audioContext.state === \"suspended\") {\r\n // Wait a bit for FF as context seems late to be ready.\r\n setTimeout(() => {\r\n if (Engine.audioEngine?.audioContext!.state === \"suspended\") {\r\n // Automatic playback failed.\r\n // Waiting for the audio engine to be unlocked by user click on unmute\r\n Engine.audioEngine.lock();\r\n if (this.loop || this.autoplay) {\r\n Engine.audioEngine.onAudioUnlockedObservable.addOnce(() => {\r\n tryToPlay();\r\n });\r\n }\r\n } else {\r\n tryToPlay();\r\n }\r\n }, 500);\r\n } else {\r\n tryToPlay();\r\n }\r\n }\r\n this._startTime = startTime;\r\n this.isPlaying = true;\r\n this.isPaused = false;\r\n } catch (ex) {\r\n Logger.Error(\"Error while trying to play audio: \" + this.name + \", \" + ex.message);\r\n }\r\n }\r\n }\r\n\r\n private _onended() {\r\n this.isPlaying = false;\r\n this._startOffset = 0;\r\n if (this.onended) {\r\n this.onended();\r\n }\r\n this.onEndedObservable.notifyObservers(this);\r\n }\r\n\r\n /**\r\n * Stop the sound\r\n * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.\r\n */\r\n public stop(time?: number): void {\r\n if (this.isPlaying) {\r\n if (this._streaming) {\r\n if (this._htmlAudioElement) {\r\n this._htmlAudioElement.pause();\r\n // Test needed for Firefox or it will generate an Invalid State Error\r\n if (this._htmlAudioElement.currentTime > 0) {\r\n this._htmlAudioElement.currentTime = 0;\r\n }\r\n } else {\r\n this._streamingSource.disconnect();\r\n }\r\n this.isPlaying = false;\r\n } else if (Engine.audioEngine?.audioContext && this._soundSource) {\r\n const stopTime = time ? Engine.audioEngine.audioContext.currentTime + time : undefined;\r\n this._soundSource.stop(stopTime);\r\n if (stopTime === undefined) {\r\n this.isPlaying = false;\r\n this._soundSource.onended = () => void 0;\r\n } else {\r\n this._soundSource.onended = () => {\r\n this.isPlaying = false;\r\n };\r\n }\r\n if (!this.isPaused) {\r\n this._startOffset = 0;\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Put the sound in pause\r\n */\r\n public pause(): void {\r\n if (this.isPlaying) {\r\n this.isPaused = true;\r\n if (this._streaming) {\r\n if (this._htmlAudioElement) {\r\n this._htmlAudioElement.pause();\r\n } else {\r\n this._streamingSource.disconnect();\r\n }\r\n this.isPlaying = false;\r\n } else if (Engine.audioEngine?.audioContext) {\r\n this.stop(0);\r\n this._startOffset += Engine.audioEngine.audioContext.currentTime - this._startTime;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Sets a dedicated volume for this sounds\r\n * @param newVolume Define the new volume of the sound\r\n * @param time Define time for gradual change to new volume\r\n */\r\n public setVolume(newVolume: number, time?: number): void {\r\n if (Engine.audioEngine?.canUseWebAudio && this._soundGain) {\r\n if (time && Engine.audioEngine.audioContext) {\r\n this._soundGain.gain.cancelScheduledValues(Engine.audioEngine.audioContext.currentTime);\r\n this._soundGain.gain.setValueAtTime(this._soundGain.gain.value, Engine.audioEngine.audioContext.currentTime);\r\n this._soundGain.gain.linearRampToValueAtTime(newVolume, Engine.audioEngine.audioContext.currentTime + time);\r\n } else {\r\n this._soundGain.gain.value = newVolume;\r\n }\r\n }\r\n this._volume = newVolume;\r\n }\r\n\r\n /**\r\n * Set the sound play back rate\r\n * @param newPlaybackRate Define the playback rate the sound should be played at\r\n */\r\n public setPlaybackRate(newPlaybackRate: number): void {\r\n this._playbackRate = newPlaybackRate;\r\n if (this.isPlaying) {\r\n if (this._streaming && this._htmlAudioElement) {\r\n this._htmlAudioElement.playbackRate = this._playbackRate;\r\n } else if (this._soundSource) {\r\n this._soundSource.playbackRate.value = this._playbackRate;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Gets the volume of the sound.\r\n * @returns the volume of the sound\r\n */\r\n public getVolume(): number {\r\n return this._volume;\r\n }\r\n\r\n /**\r\n * Attach the sound to a dedicated mesh\r\n * @param transformNode The transform node to connect the sound with\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh\r\n */\r\n public attachToMesh(transformNode: TransformNode): void {\r\n if (this._connectedTransformNode && this._registerFunc) {\r\n this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);\r\n this._registerFunc = null;\r\n }\r\n this._connectedTransformNode = transformNode;\r\n if (!this._spatialSound) {\r\n this._spatialSound = true;\r\n this._createSpatialParameters();\r\n if (this.isPlaying && this.loop) {\r\n this.stop();\r\n this.play(0, this._offset, this._length);\r\n }\r\n }\r\n this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode);\r\n this._registerFunc = (transformNode: TransformNode) => this._onRegisterAfterWorldMatrixUpdate(transformNode);\r\n this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc);\r\n }\r\n\r\n /**\r\n * Detach the sound from the previously attached mesh\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh\r\n */\r\n public detachFromMesh() {\r\n if (this._connectedTransformNode && this._registerFunc) {\r\n this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);\r\n this._registerFunc = null;\r\n this._connectedTransformNode = null;\r\n }\r\n }\r\n\r\n private _onRegisterAfterWorldMatrixUpdate(node: TransformNode): void {\r\n if (!(<any>node).getBoundingInfo) {\r\n this.setPosition(node.absolutePosition);\r\n } else {\r\n const mesh = node as AbstractMesh;\r\n const boundingInfo = mesh.getBoundingInfo();\r\n this.setPosition(boundingInfo.boundingSphere.centerWorld);\r\n }\r\n if (Engine.audioEngine?.canUseWebAudio && this._isDirectional && this.isPlaying) {\r\n this._updateDirection();\r\n }\r\n }\r\n\r\n /**\r\n * Clone the current sound in the scene.\r\n * @returns the new sound clone\r\n */\r\n public clone(): Nullable<Sound> {\r\n if (!this._streaming) {\r\n const setBufferAndRun = () => {\r\n if (this._isReadyToPlay) {\r\n clonedSound._audioBuffer = this.getAudioBuffer();\r\n clonedSound._isReadyToPlay = true;\r\n if (clonedSound.autoplay) {\r\n clonedSound.play(0, this._offset, this._length);\r\n }\r\n } else {\r\n window.setTimeout(setBufferAndRun, 300);\r\n }\r\n };\r\n\r\n const currentOptions = {\r\n autoplay: this.autoplay,\r\n loop: this.loop,\r\n volume: this._volume,\r\n spatialSound: this._spatialSound,\r\n maxDistance: this.maxDistance,\r\n useCustomAttenuation: this.useCustomAttenuation,\r\n rolloffFactor: this.rolloffFactor,\r\n refDistance: this.refDistance,\r\n distanceModel: this.distanceModel,\r\n };\r\n\r\n const clonedSound = new Sound(this.name + \"_cloned\", new ArrayBuffer(0), this._scene, null, currentOptions);\r\n if (this.useCustomAttenuation) {\r\n clonedSound.setAttenuationFunction(this._customAttenuationFunction);\r\n }\r\n clonedSound.setPosition(this._position);\r\n clonedSound.setPlaybackRate(this._playbackRate);\r\n setBufferAndRun();\r\n\r\n return clonedSound;\r\n }\r\n // Can't clone a streaming sound\r\n else {\r\n return null;\r\n }\r\n }\r\n\r\n /**\r\n * Gets the current underlying audio buffer containing the data\r\n * @returns the audio buffer\r\n */\r\n public getAudioBuffer(): Nullable<AudioBuffer> {\r\n return this._audioBuffer;\r\n }\r\n\r\n /**\r\n * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.\r\n * @returns the source node\r\n */\r\n public getSoundSource(): Nullable<AudioBufferSourceNode> {\r\n return this._soundSource;\r\n }\r\n\r\n /**\r\n * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.\r\n * @returns the gain node\r\n */\r\n public getSoundGain(): Nullable<GainNode> {\r\n return this._soundGain;\r\n }\r\n\r\n /**\r\n * Serializes the Sound in a JSON representation\r\n * @returns the JSON representation of the sound\r\n */\r\n public serialize(): any {\r\n const serializationObject: any = {\r\n name: this.name,\r\n url: this.name,\r\n autoplay: this.autoplay,\r\n loop: this.loop,\r\n volume: this._volume,\r\n spatialSound: this._spatialSound,\r\n maxDistance: this.maxDistance,\r\n rolloffFactor: this.rolloffFactor,\r\n refDistance: this.refDistance,\r\n distanceModel: this.distanceModel,\r\n playbackRate: this._playbackRate,\r\n panningModel: this._panningModel,\r\n soundTrackId: this.soundTrackId,\r\n metadata: this.metadata,\r\n };\r\n\r\n if (this._spatialSound) {\r\n if (this._connectedTransformNode) {\r\n serializationObject.connectedMeshId = this._connectedTransformNode.id;\r\n }\r\n\r\n serializationObject.position = this._position.asArray();\r\n serializationObject.refDistance = this.refDistance;\r\n serializationObject.distanceModel = this.distanceModel;\r\n\r\n serializationObject.isDirectional = this._isDirectional;\r\n serializationObject.localDirectionToMesh = this._localDirection.asArray();\r\n serializationObject.coneInnerAngle = this._coneInnerAngle;\r\n serializationObject.coneOuterAngle = this._coneOuterAngle;\r\n serializationObject.coneOuterGain = this._coneOuterGain;\r\n }\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse a JSON representation of a sound to instantiate in a given scene\r\n * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)\r\n * @param scene Define the scene the new parsed sound should be created in\r\n * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies\r\n * @param sourceSound Define a sound place holder if do not need to instantiate a new one\r\n * @returns the newly parsed sound\r\n */\r\n public static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound {\r\n const soundName = parsedSound.name;\r\n let soundUrl;\r\n\r\n if (parsedSound.url) {\r\n soundUrl = rootUrl + parsedSound.url;\r\n } else {\r\n soundUrl = rootUrl + soundName;\r\n }\r\n\r\n const options = {\r\n autoplay: parsedSound.autoplay,\r\n loop: parsedSound.loop,\r\n volume: parsedSound.volume,\r\n spatialSound: parsedSound.spatialSound,\r\n maxDistance: parsedSound.maxDistance,\r\n rolloffFactor: parsedSound.rolloffFactor,\r\n refDistance: parsedSound.refDistance,\r\n distanceModel: parsedSound.distanceModel,\r\n playbackRate: parsedSound.playbackRate,\r\n };\r\n\r\n let newSound: Sound;\r\n\r\n if (!sourceSound) {\r\n newSound = new Sound(\r\n soundName,\r\n soundUrl,\r\n scene,\r\n () => {\r\n scene.removePendingData(newSound);\r\n },\r\n options\r\n );\r\n scene.addPendingData(newSound);\r\n } else {\r\n const setBufferAndRun = () => {\r\n if (sourceSound._isReadyToPlay) {\r\n newSound._audioBuffer = sourceSound.getAudioBuffer();\r\n newSound._isReadyToPlay = true;\r\n if (newSound.autoplay) {\r\n newSound.play(0, newSound._offset, newSound._length);\r\n }\r\n } else {\r\n window.setTimeout(setBufferAndRun, 300);\r\n }\r\n };\r\n\r\n newSound = new Sound(soundName, new ArrayBuffer(0), scene, null, options);\r\n setBufferAndRun();\r\n }\r\n\r\n if (parsedSound.position) {\r\n const soundPosition = Vector3.FromArray(parsedSound.position);\r\n newSound.setPosition(soundPosition);\r\n }\r\n if (parsedSound.isDirectional) {\r\n newSound.setDirectionalCone(parsedSound.coneInnerAngle || 360, parsedSound.coneOuterAngle || 360, parsedSound.coneOuterGain || 0);\r\n if (parsedSound.localDirectionToMesh) {\r\n const localDirectionToMesh = Vector3.FromArray(parsedSound.localDirectionToMesh);\r\n newSound.setLocalDirectionToMesh(localDirectionToMesh);\r\n }\r\n }\r\n if (parsedSound.connectedMeshId) {\r\n const connectedMesh = scene.getMeshById(parsedSound.connectedMeshId);\r\n if (connectedMesh) {\r\n newSound.attachToMesh(connectedMesh);\r\n }\r\n }\r\n\r\n if (parsedSound.metadata) {\r\n newSound.metadata = parsedSound.metadata;\r\n }\r\n\r\n return newSound;\r\n }\r\n}\r\n"]}
@@ -31,7 +31,8 @@ export class SoundTrack {
31
31
  }
32
32
  }
33
33
  _initializeSoundTrackAudioGraph() {
34
- if (Engine.audioEngine?.canUseWebAudio && Engine.audioEngine.audioContext) {
34
+ var _a;
35
+ if (((_a = Engine.audioEngine) === null || _a === void 0 ? void 0 : _a.canUseWebAudio) && Engine.audioEngine.audioContext) {
35
36
  this._outputAudioNode = Engine.audioEngine.audioContext.createGain();
36
37
  this._outputAudioNode.connect(Engine.audioEngine.masterGain);
37
38
  if (this._options) {
@@ -65,10 +66,11 @@ export class SoundTrack {
65
66
  * @ignoreNaming
66
67
  */
67
68
  addSound(sound) {
69
+ var _a;
68
70
  if (!this._isInitialized) {
69
71
  this._initializeSoundTrackAudioGraph();
70
72
  }
71
- if (Engine.audioEngine?.canUseWebAudio && this._outputAudioNode) {
73
+ if (((_a = Engine.audioEngine) === null || _a === void 0 ? void 0 : _a.canUseWebAudio) && this._outputAudioNode) {
72
74
  sound.connectToSoundTrackAudioNode(this._outputAudioNode);
73
75
  }
74
76
  if (sound.soundTrackId) {
@@ -98,7 +100,8 @@ export class SoundTrack {
98
100
  * @param newVolume Define the new volume of the sound track
99
101
  */
100
102
  setVolume(newVolume) {
101
- if (Engine.audioEngine?.canUseWebAudio && this._outputAudioNode) {
103
+ var _a;
104
+ if (((_a = Engine.audioEngine) === null || _a === void 0 ? void 0 : _a.canUseWebAudio) && this._outputAudioNode) {
102
105
  this._outputAudioNode.gain.value = newVolume;
103
106
  }
104
107
  }
@@ -108,7 +111,8 @@ export class SoundTrack {
108
111
  * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
109
112
  */
110
113
  switchPanningModelToHRTF() {
111
- if (Engine.audioEngine?.canUseWebAudio) {
114
+ var _a;
115
+ if ((_a = Engine.audioEngine) === null || _a === void 0 ? void 0 : _a.canUseWebAudio) {
112
116
  for (let i = 0; i < this.soundCollection.length; i++) {
113
117
  this.soundCollection[i].switchPanningModelToHRTF();
114
118
  }
@@ -120,7 +124,8 @@ export class SoundTrack {
120
124
  * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
121
125
  */
122
126
  switchPanningModelToEqualPower() {
123
- if (Engine.audioEngine?.canUseWebAudio) {
127
+ var _a;
128
+ if ((_a = Engine.audioEngine) === null || _a === void 0 ? void 0 : _a.canUseWebAudio) {
124
129
  for (let i = 0; i < this.soundCollection.length; i++) {
125
130
  this.soundCollection[i].switchPanningModelToEqualPower();
126
131
  }
@@ -133,11 +138,12 @@ export class SoundTrack {
133
138
  * @param analyser The analyser to connect to the engine
134
139
  */
135
140
  connectToAnalyser(analyser) {
141
+ var _a;
136
142
  if (this._connectedAnalyser) {
137
143
  this._connectedAnalyser.stopDebugCanvas();
138
144
  }
139
145
  this._connectedAnalyser = analyser;
140
- if (Engine.audioEngine?.canUseWebAudio && this._outputAudioNode) {
146
+ if (((_a = Engine.audioEngine) === null || _a === void 0 ? void 0 : _a.canUseWebAudio) && this._outputAudioNode) {
141
147
  this._outputAudioNode.disconnect();
142
148
  this._connectedAnalyser.connectAudioNodes(this._outputAudioNode, Engine.audioEngine.masterGain);
143
149
  }
@@ -1 +1 @@
1
- {"version":3,"file":"soundTrack.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Audio/soundTrack.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAgBrD;;;;GAIG;AACH,MAAM,OAAO,UAAU;IAgBnB;;;;;OAKG;IACH,YAAY,KAAuB,EAAE,UAA8B,EAAE;QArBrE;;WAEG;QACI,OAAE,GAAW,CAAC,CAAC,CAAC;QAUf,mBAAc,GAAG,KAAK,CAAC;QAS3B,KAAK,GAAG,KAAK,IAAI,WAAW,CAAC,gBAAgB,CAAC;QAC9C,IAAI,CAAC,KAAK,EAAE;YACR,OAAO;SACV;QACD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,eAAe,GAAG,IAAI,KAAK,EAAE,CAAC;QACnC,IAAI,CAAC,QAAQ,GAAG,OA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AIG;IACI,wBAAwB;QAC3B,IAAI,MAAM,CAAC,WAAW,EAAE,cAAc,EAAE;YACpC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBAClD,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,wBAAwB,EAAE,CAAC;aACtD;SACJ;IACL,CAAC;IAED;;;;OAIG;IACI,8BAA8B;QACjC,IAAI,MAAM,CAAC,WAAW,EAAE,cAAc,EAAE;YACpC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBAClD,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,8BAA8B,EAAE,CAAC;aAC5D;SACJ;IACL,CAAC;IAED;;;;;OAKG;IACI,iBAAiB,CAAC,QAAkB;QACvC,IAAI,IAAI,CAAC,kBAAkB,EAAE;YACzB,IAAI,CAAC,kBAAkB,CAAC,eAAe,EAAE,CAAC;SAC7C;QACD,IAAI,CAAC,kBAAkB,GAAG,QAAQ,CAAC;QACnC,IAAI,MAAM,CAAC,WAAW,EAAE,cAAc,IAAI,IAAI,CAAC,gBAAgB,EAAE;YAC7D,IAAI,CAAC,gBAAgB,CAAC,UAAU,EAAE,CAAC;YACnC,IAAI,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;SACnG;IACL,CAAC;CACJ","sourcesContent":["import type { Sound } from \"./sound\";\r\nimport type { Analyser } from \"./analyser\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport { Engine } from \"../Engines/engine\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\n\r\n/**\r\n * Options allowed during the creation of a sound track.\r\n */\r\nexport interface ISoundTrackOptions {\r\n /**\r\n * The volume the sound track should take during creation\r\n */\r\n volume?: number;\r\n /**\r\n * Define if the sound track is the main sound track of the scene\r\n */\r\n mainTrack?: boolean;\r\n}\r\n\r\n/**\r\n * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.\r\n * It will be also used in a future release to apply effects on a specific track.\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks\r\n */\r\nexport class SoundTrack {\r\n /**\r\n * The unique identifier of the sound track in the scene.\r\n */\r\n public id: number = -1;\r\n /**\r\n * The list of sounds included in the sound track.\r\n */\r\n public soundCollection: Array<Sound>;\r\n\r\n private _outputAudioNode: Nullable<GainNode>;\r\n private _scene: Scene;\r\n private _connectedAnalyser: Analyser;\r\n private _options: ISoundTrackOptions;\r\n private _isInitialized = false;\r\n\r\n /**\r\n * Creates a new sound track.\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks\r\n * @param scene Define the scene the sound track belongs to\r\n * @param options\r\n */\r\n constructor(scene?: Nullable<Scene>, options: ISoundTrackOptions = {}) {\r\n scene = scene || EngineStore.LastCreatedScene;\r\n if (!scene) {\r\n return;\r\n }\r\n this._scene = scene;\r\n this.soundCollection = new Array();\r\n this._options = options;\r\n\r\n if (!this._options.mainTrack && this._scene.soundTracks) {\r\n this._scene.soundTracks.push(this);\r\n this.id = this._scene.soundTracks.length - 1;\r\n }\r\n }\r\n\r\n private _initializeSoundTrackAudioGraph() {\r\n if (Engine.audioEngine?.canUseWebAudio && Engine.audioEngine.audioContext) {\r\n this._outputAudioNode = Engine.audioEngine.audioContext.createGain();\r\n this._outputAudioNode.connect(Engine.audioEngine.masterGain);\r\n\r\n if (this._options) {\r\n if (this._options.volume) {\r\n this._outputAudioNode.gain.value = this._options.volume;\r\n }\r\n }\r\n\r\n this._isInitialized = true;\r\n }\r\n }\r\n\r\n /**\r\n * Release the sound track and its associated resources\r\n */\r\n public dispose(): void {\r\n if (Engine.audioEngine && Engine.audioEngine.canUseWebAudio) {\r\n if (this._connectedAnalyser) {\r\n this._connectedAnalyser.stopDebugCanvas();\r\n }\r\n while (this.soundCollection.length) {\r\n this.soundCollection[0].dispose();\r\n }\r\n if (this._outputAudioNode) {\r\n this._outputAudioNode.disconnect();\r\n }\r\n this._outputAudioNode = null;\r\n }\r\n }\r\n\r\n /**\r\n * Adds a sound to this sound track\r\n * @param sound define the sound to add\r\n * @ignoreNaming\r\n */\r\n public addSound(sound: Sound): void {\r\n if (!this._isInitialized) {\r\n this._initializeSoundTrackAudioGraph();\r\n }\r\n if (Engine.audioEngine?.canUseWebAudio && this._outputAudioNode) {\r\n sound.connectToSoundTrackAudioNode(this._outputAudioNode);\r\n }\r\n if (sound.soundTrackId) {\r\n if (sound.soundTrackId === -1) {\r\n this._scene.mainSoundTrack.removeSound(sound);\r\n } else if (this._scene.soundTracks) {\r\n this._scene.soundTracks[sound.soundTrackId].removeSound(sound);\r\n }\r\n }\r\n\r\n this.soundCollection.push(sound);\r\n sound.soundTrackId = this.id;\r\n }\r\n\r\n /**\r\n * Removes a sound to this sound track\r\n * @param sound define the sound to remove\r\n * @ignoreNaming\r\n */\r\n public removeSound(sound: Sound): void {\r\n const index = this.soundCollection.indexOf(sound);\r\n if (index !== -1) {\r\n this.soundCollection.splice(index, 1);\r\n }\r\n }\r\n\r\n /**\r\n * Set a global volume for the full sound track.\r\n * @param newVolume Define the new volume of the sound track\r\n */\r\n public setVolume(newVolume: number): void {\r\n if (Engine.audioEngine?.canUseWebAudio && this._outputAudioNode) {\r\n this._outputAudioNode.gain.value = newVolume;\r\n }\r\n }\r\n\r\n /**\r\n * Switch the panning model to HRTF:\r\n * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound\r\n */\r\n public switchPanningModelToHRTF(): void {\r\n if (Engine.audioEngine?.canUseWebAudio) {\r\n for (let i = 0; i < this.soundCollection.length; i++) {\r\n this.soundCollection[i].switchPanningModelToHRTF();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Switch the panning model to Equal Power:\r\n * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound\r\n */\r\n public switchPanningModelToEqualPower(): void {\r\n if (Engine.audioEngine?.canUseWebAudio) {\r\n for (let i = 0; i < this.soundCollection.length; i++) {\r\n this.soundCollection[i].switchPanningModelToEqualPower();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Connect the sound track to an audio analyser allowing some amazing\r\n * synchronization between the sounds/music and your visualization (VuMeter for instance).\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser\r\n * @param analyser The analyser to connect to the engine\r\n */\r\n public connectToAnalyser(analyser: Analyser): void {\r\n if (this._connectedAnalyser) {\r\n this._connectedAnalyser.stopDebugCanvas();\r\n }\r\n this._connectedAnalyser = analyser;\r\n if (Engine.audioEngine?.canUseWebAudio && this._outputAudioNode) {\r\n this._outputAudioNode.disconnect();\r\n this._connectedAnalyser.connectAudioNodes(this._outputAudioNode, Engine.audioEngine.masterGain);\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"soundTrack.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Audio/soundTrack.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAgBrD;;;;GAIG;AACH,MAAM,OAAO,UAAU;IAgBnB;;;;;OAKG;IACH,YAAY,KAAuB,EAAE,UAA8B,EAAE;QArBrE;;WAEG;QACI,OAAE,GAAW,CAAC,CAAC,CAAC;QAUf,mBAAc,GAAG,KAAK,CAAC;QAS3B,KAAK,GAAG,KAAK,IAAI,WAAW,CAAC,gBAAgB,CAAC;QAC9C,IAAI,CAAC,KAAK,EAAE;YACR,OAAO;S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nimport type { Analyser } from \"./analyser\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport { Engine } from \"../Engines/engine\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\n\r\n/**\r\n * Options allowed during the creation of a sound track.\r\n */\r\nexport interface ISoundTrackOptions {\r\n /**\r\n * The volume the sound track should take during creation\r\n */\r\n volume?: number;\r\n /**\r\n * Define if the sound track is the main sound track of the scene\r\n */\r\n mainTrack?: boolean;\r\n}\r\n\r\n/**\r\n * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.\r\n * It will be also used in a future release to apply effects on a specific track.\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks\r\n */\r\nexport class SoundTrack {\r\n /**\r\n * The unique identifier of the sound track in the scene.\r\n */\r\n public id: number = -1;\r\n /**\r\n * The list of sounds included in the sound track.\r\n */\r\n public soundCollection: Array<Sound>;\r\n\r\n private _outputAudioNode: Nullable<GainNode>;\r\n private _scene: Scene;\r\n private _connectedAnalyser: Analyser;\r\n private _options: ISoundTrackOptions;\r\n private _isInitialized = false;\r\n\r\n /**\r\n * Creates a new sound track.\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks\r\n * @param scene Define the scene the sound track belongs to\r\n * @param options\r\n */\r\n constructor(scene?: Nullable<Scene>, options: ISoundTrackOptions = {}) {\r\n scene = scene || EngineStore.LastCreatedScene;\r\n if (!scene) {\r\n return;\r\n }\r\n this._scene = scene;\r\n this.soundCollection = new Array();\r\n this._options = options;\r\n\r\n if (!this._options.mainTrack && this._scene.soundTracks) {\r\n this._scene.soundTracks.push(this);\r\n this.id = this._scene.soundTracks.length - 1;\r\n }\r\n }\r\n\r\n private _initializeSoundTrackAudioGraph() {\r\n if (Engine.audioEngine?.canUseWebAudio && Engine.audioEngine.audioContext) {\r\n this._outputAudioNode = Engine.audioEngine.audioContext.createGain();\r\n this._outputAudioNode.connect(Engine.audioEngine.masterGain);\r\n\r\n if (this._options) {\r\n if (this._options.volume) {\r\n this._outputAudioNode.gain.value = this._options.volume;\r\n }\r\n }\r\n\r\n this._isInitialized = true;\r\n }\r\n }\r\n\r\n /**\r\n * Release the sound track and its associated resources\r\n */\r\n public dispose(): void {\r\n if (Engine.audioEngine && Engine.audioEngine.canUseWebAudio) {\r\n if (this._connectedAnalyser) {\r\n this._connectedAnalyser.stopDebugCanvas();\r\n }\r\n while (this.soundCollection.length) {\r\n this.soundCollection[0].dispose();\r\n }\r\n if (this._outputAudioNode) {\r\n this._outputAudioNode.disconnect();\r\n }\r\n this._outputAudioNode = null;\r\n }\r\n }\r\n\r\n /**\r\n * Adds a sound to this sound track\r\n * @param sound define the sound to add\r\n * @ignoreNaming\r\n */\r\n public addSound(sound: Sound): void {\r\n if (!this._isInitialized) {\r\n this._initializeSoundTrackAudioGraph();\r\n }\r\n if (Engine.audioEngine?.canUseWebAudio && this._outputAudioNode) {\r\n sound.connectToSoundTrackAudioNode(this._outputAudioNode);\r\n }\r\n if (sound.soundTrackId) {\r\n if (sound.soundTrackId === -1) {\r\n this._scene.mainSoundTrack.removeSound(sound);\r\n } else if (this._scene.soundTracks) {\r\n this._scene.soundTracks[sound.soundTrackId].removeSound(sound);\r\n }\r\n }\r\n\r\n this.soundCollection.push(sound);\r\n sound.soundTrackId = this.id;\r\n }\r\n\r\n /**\r\n * Removes a sound to this sound track\r\n * @param sound define the sound to remove\r\n * @ignoreNaming\r\n */\r\n public removeSound(sound: Sound): void {\r\n const index = this.soundCollection.indexOf(sound);\r\n if (index !== -1) {\r\n this.soundCollection.splice(index, 1);\r\n }\r\n }\r\n\r\n /**\r\n * Set a global volume for the full sound track.\r\n * @param newVolume Define the new volume of the sound track\r\n */\r\n public setVolume(newVolume: number): void {\r\n if (Engine.audioEngine?.canUseWebAudio && this._outputAudioNode) {\r\n this._outputAudioNode.gain.value = newVolume;\r\n }\r\n }\r\n\r\n /**\r\n * Switch the panning model to HRTF:\r\n * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound\r\n */\r\n public switchPanningModelToHRTF(): void {\r\n if (Engine.audioEngine?.canUseWebAudio) {\r\n for (let i = 0; i < this.soundCollection.length; i++) {\r\n this.soundCollection[i].switchPanningModelToHRTF();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Switch the panning model to Equal Power:\r\n * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound\r\n */\r\n public switchPanningModelToEqualPower(): void {\r\n if (Engine.audioEngine?.canUseWebAudio) {\r\n for (let i = 0; i < this.soundCollection.length; i++) {\r\n this.soundCollection[i].switchPanningModelToEqualPower();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Connect the sound track to an audio analyser allowing some amazing\r\n * synchronization between the sounds/music and your visualization (VuMeter for instance).\r\n * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser\r\n * @param analyser The analyser to connect to the engine\r\n */\r\n public connectToAnalyser(analyser: Analyser): void {\r\n if (this._connectedAnalyser) {\r\n this._connectedAnalyser.stopDebugCanvas();\r\n }\r\n this._connectedAnalyser = analyser;\r\n if (Engine.audioEngine?.canUseWebAudio && this._outputAudioNode) {\r\n this._outputAudioNode.disconnect();\r\n this._connectedAnalyser.connectAudioNodes(this._outputAudioNode, Engine.audioEngine.masterGain);\r\n }\r\n }\r\n}\r\n"]}
@@ -79,8 +79,9 @@ export class BakedVertexAnimationManager {
79
79
  * @param forceDisposeTextures - Forces the disposal of all textures.
80
80
  */
81
81
  dispose(forceDisposeTextures) {
82
+ var _a;
82
83
  if (forceDisposeTextures) {
83
- this._texture?.dispose();
84
+ (_a = this._texture) === null || _a === void 0 ? void 0 : _a.dispose();
84
85
  }
85
86
  }
86
87
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"bakedVertexAnimationManager.js","sourceRoot":"","sources":["../../../../../lts/core/generated/BakedVertexAnimation/bakedVertexAnimationManager.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE1G,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAwDrD;;;;GAIG;AACH,MAAM,OAAO,2BAA2B;IA+BpC;;;OAGG;IACH,YAAY,KAAuB;QAhC3B,aAAQ,GAA0B,IAAI,CAAC;QAQvC,eAAU,GAAG,IAAI,CAAC;QAC1B;;WAEG;QAGI,cAAS,GAAG,IAAI,CAAC;QAQxB;;WAEG;QAEI,SAAI,GAAG,CAAC,CAAC;QAOZ,KAAK,GAAG,KAAK,IAAI,WAAW,CAAC,gBAAgB,CAAC;QAC9C,IAAI,CAAC,KAAK,EAAE;YACR,OAAO;SACV;QACD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,mBAAmB,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IACxD,CAAC;IAED,gBAAgB;IACT,+BAA+B;QAClC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;YACnC,IAAU,IAAK,CAAC,2BAA2B,KAAK,IAAI,EAAE;gBAClD,IAAI,CAAC,+BAA+B,EAAE,CAAC;aAC1C;SACJ;IACL,CAAC;IAED;;;;OAIG;IACI,IAAI,CAAC,MAAc,EAAE,YAAY,GAAG,KAAK;QAC5C,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YACpC,OAAO;SACV;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;QACrC,MAAM,CAAC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C,MAAW,EAAE,KAAY,EAAE,OAAe;QACnD,mBAAmB,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAClE,CAAC;CACJ;AAjIG;IAFC,kBAAkB,EAAE;IACpB,gBAAgB,CAAC,iCAAiC,CAAC;4DACd;AAQtC;IAFC,SAAS,EAAE;IACX,gBAAgB,CAAC,iCAAiC,CAAC;8DAC5B;AAMxB;IADC,SAAS,EAAE;wEACwB;AAMpC;IADC,SAAS,EAAE;yDACI","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport { serialize, expandToProperty, serializeAsTexture, SerializationHelper } from \"../Misc/decorators\";\r\nimport type { BaseTexture } from \"../Materials/Textures/baseTexture\";\r\nimport { Vector4 } from \"../Maths/math.vector\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\n\r\n/**\r\n * Interface for baked vertex animation texture, see BakedVertexAnimationManager\r\n * @since 5.0\r\n */\r\nexport interface IBakedVertexAnimationManager {\r\n /**\r\n * The vertex animation texture\r\n */\r\n texture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the edgesRenderer is active\r\n */\r\n isEnabled: boolean;\r\n\r\n /**\r\n * The animation parameters for the mesh. See setAnimationParameters()\r\n */\r\n animationParameters: Vector4;\r\n\r\n /**\r\n * The time counter, to pick the correct animation frame.\r\n */\r\n time: number;\r\n\r\n /**\r\n * Binds to the effect.\r\n * @param effect The effect to bind to.\r\n * @param useInstances True when it's an instance.\r\n */\r\n bind(effect: Effect, useInstances: boolean): void;\r\n\r\n /**\r\n * Sets animation parameters.\r\n * @param startFrame The first frame of the animation.\r\n * @param endFrame The last frame of the animation.\r\n * @param offset The offset when starting the animation.\r\n * @param speedFramesPerSecond The frame rate.\r\n */\r\n setAnimationParameters(startFrame: number, endFrame: number, offset: number, speedFramesPerSecond: number): void;\r\n\r\n /**\r\n * Disposes the resources of the manager.\r\n * @param forceDisposeTextures - Forces the disposal of all textures.\r\n */\r\n dispose(forceDisposeTextures?: boolean): void;\r\n\r\n /**\r\n * Get the current class name useful for serialization or dynamic coding.\r\n * @returns \"BakedVertexAnimationManager\"\r\n */\r\n getClassName(): string;\r\n}\r\n\r\n/**\r\n * This class is used to animate meshes using a baked vertex animation texture\r\n * @see https://doc.babylonjs.com/divingDeeper/animation/baked_texture_animations\r\n * @since 5.0\r\n */\r\nexport class BakedVertexAnimationManager implements IBakedVertexAnimationManager {\r\n private _scene: Scene;\r\n\r\n private _texture: Nullable<BaseTexture> = null;\r\n /**\r\n * The vertex animation texture\r\n */\r\n @serializeAsTexture()\r\n @expandToProperty(\"_markSubMeshesAsAttributesDirty\")\r\n public texture: Nullable<BaseTexture>;\r\n\r\n private _isEnabled = true;\r\n /**\r\n * Enable or disable the vertex animation manager\r\n */\r\n @serialize()\r\n @expandToProperty(\"_markSubMeshesAsAttributesDirty\")\r\n public isEnabled = true;\r\n\r\n /**\r\n * The animation parameters for the mesh. See setAnimationParameters()\r\n */\r\n @serialize()\r\n public animationParameters: Vector4;\r\n\r\n /**\r\n * The time counter, to pick the correct animation frame.\r\n */\r\n @serialize()\r\n public time = 0;\r\n\r\n /**\r\n * Creates a new BakedVertexAnimationManager\r\n * @param scene defines the current scene\r\n */\r\n constructor(scene?: Nullable<Scene>) {\r\n scene = scene || EngineStore.LastCreatedScene;\r\n if (!scene) {\r\n return;\r\n }\r\n this._scene = scene;\r\n this.animationParameters = new Vector4(0, 0, 0, 30);\r\n }\r\n\r\n /** @internal */\r\n public _markSubMeshesAsAttributesDirty(): void {\r\n for (const mesh of this._scene.meshes) {\r\n if ((<any>mesh).bakedVertexAnimationManager === this) {\r\n mesh._markSubMeshesAsAttributesDirty();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Binds to the effect.\r\n * @param effect The effect to bind to.\r\n * @param useInstances True when it's an instance.\r\n */\r\n public bind(effect: Effect, useInstances = false): void {\r\n if (!this._texture || !this._isEnabled) {\r\n return;\r\n }\r\n\r\n const size = this._texture.getSize();\r\n effect.setFloat2(\"bakedVertexAnimationTextureSizeInverted\", 1.0 / size.width, 1.0 / size.height);\r\n effect.setFloat(\"bakedVertexAnimationTime\", this.time);\r\n\r\n if (!useInstances) {\r\n effect.setVector4(\"bakedVertexAnimationSettings\", this.animationParameters);\r\n }\r\n\r\n effect.setTexture(\"bakedVertexAnimationTexture\", this._texture);\r\n }\r\n\r\n /**\r\n * Clone the current manager\r\n * @returns a new BakedVertexAnimationManager\r\n */\r\n public clone(): BakedVertexAnimationManager {\r\n const copy = new BakedVertexAnimationManager(this._scene);\r\n this.copyTo(copy);\r\n return copy;\r\n }\r\n\r\n /**\r\n * Sets animation parameters.\r\n * @param startFrame The first frame of the animation.\r\n * @param endFrame The last frame of the animation.\r\n * @param offset The offset when starting the animation.\r\n * @param speedFramesPerSecond The frame rate.\r\n */\r\n public setAnimationParameters(startFrame: number, endFrame: number, offset: number = 0, speedFramesPerSecond: number = 30): void {\r\n this.animationParameters = new Vector4(startFrame, endFrame, offset, speedFramesPerSecond);\r\n }\r\n\r\n /**\r\n * Disposes the resources of the manager.\r\n * @param forceDisposeTextures - Forces the disposal of all textures.\r\n */\r\n public dispose(forceDisposeTextures?: boolean): void {\r\n if (forceDisposeTextures) {\r\n this._texture?.dispose();\r\n }\r\n }\r\n\r\n /**\r\n * Get the current class name useful for serialization or dynamic coding.\r\n * @returns \"BakedVertexAnimationManager\"\r\n */\r\n public getClassName(): string {\r\n return \"BakedVertexAnimationManager\";\r\n }\r\n\r\n /**\r\n * Makes a duplicate of the current instance into another one.\r\n * @param vatMap define the instance where to copy the info\r\n */\r\n public copyTo(vatMap: BakedVertexAnimationManager): void {\r\n SerializationHelper.Clone(() => vatMap, this);\r\n }\r\n\r\n /**\r\n * Serializes this vertex animation instance\r\n * @returns - An object with the serialized instance.\r\n */\r\n public serialize(): any {\r\n return SerializationHelper.Serialize(this);\r\n }\r\n\r\n /**\r\n * Parses a vertex animation setting from a serialized object.\r\n * @param source - Serialized object.\r\n * @param scene Defines the scene we are parsing for\r\n * @param rootUrl Defines the rootUrl to load from\r\n */\r\n public parse(source: any, scene: Scene, rootUrl: string): void {\r\n SerializationHelper.Parse(() => this, source, scene, rootUrl);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"bakedVertexAnimationManager.js","sourceRoot":"","sources":["../../../../../lts/core/generated/BakedVertexAnimation/bakedVertexAnimationManager.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE1G,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAwDrD;;;;GAIG;AACH,MAAM,OAAO,2BAA2B;IA+BpC;;;OAGG;IACH,YAAY,KAAuB;QAhC3B,aAAQ,GAA0B,IAAI,CAAC;QAQvC,eAAU,GAAG,IAAI,CAAC;QAC1B;;WAEG;QAGI,cAAS,GAAG,IAAI,CAAC;QAQxB;;WAEG;QAEI,SAAI,GAAG,CAAC,CAAC;QAOZ,KAAK,GAAG,KAAK,IAAI,WAAW,CAAC,gBAAgB,CAAC;QAC9C,IAAI,CAAC,KAAK,EAAE;YACR,OAAO;SACV;QACD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,mBAAmB,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IACxD,CAAC;IAED,gBAAgB;IACT,+BAA+B;QAClC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;YACnC,IAAU,IAAK,CAAC,2BAA2B,KAAK,IAAI,EAAE;gBAClD,IAAI,CAAC,+BAA+B,EAAE,CAAC;aAC1C;SACJ;IACL,CAA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AGG;IACI,MAAM,CAAC,MAAmC;QAC7C,mBAAmB,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAClD,CAAC;IAED;;;OAGG;IACI,SAAS;QACZ,OAAO,mBAAmB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC/C,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,MAAW,EAAE,KAAY,EAAE,OAAe;QACnD,mBAAmB,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAClE,CAAC;CACJ;AAjIG;IAFC,kBAAkB,EAAE;IACpB,gBAAgB,CAAC,iCAAiC,CAAC;4DACd;AAQtC;IAFC,SAAS,EAAE;IACX,gBAAgB,CAAC,iCAAiC,CAAC;8DAC5B;AAMxB;IADC,SAAS,EAAE;wEACwB;AAMpC;IADC,SAAS,EAAE;yDACI","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport { serialize, expandToProperty, serializeAsTexture, SerializationHelper } from \"../Misc/decorators\";\r\nimport type { BaseTexture } from \"../Materials/Textures/baseTexture\";\r\nimport { Vector4 } from \"../Maths/math.vector\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\n\r\n/**\r\n * Interface for baked vertex animation texture, see BakedVertexAnimationManager\r\n * @since 5.0\r\n */\r\nexport interface IBakedVertexAnimationManager {\r\n /**\r\n * The vertex animation texture\r\n */\r\n texture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the edgesRenderer is active\r\n */\r\n isEnabled: boolean;\r\n\r\n /**\r\n * The animation parameters for the mesh. See setAnimationParameters()\r\n */\r\n animationParameters: Vector4;\r\n\r\n /**\r\n * The time counter, to pick the correct animation frame.\r\n */\r\n time: number;\r\n\r\n /**\r\n * Binds to the effect.\r\n * @param effect The effect to bind to.\r\n * @param useInstances True when it's an instance.\r\n */\r\n bind(effect: Effect, useInstances: boolean): void;\r\n\r\n /**\r\n * Sets animation parameters.\r\n * @param startFrame The first frame of the animation.\r\n * @param endFrame The last frame of the animation.\r\n * @param offset The offset when starting the animation.\r\n * @param speedFramesPerSecond The frame rate.\r\n */\r\n setAnimationParameters(startFrame: number, endFrame: number, offset: number, speedFramesPerSecond: number): void;\r\n\r\n /**\r\n * Disposes the resources of the manager.\r\n * @param forceDisposeTextures - Forces the disposal of all textures.\r\n */\r\n dispose(forceDisposeTextures?: boolean): void;\r\n\r\n /**\r\n * Get the current class name useful for serialization or dynamic coding.\r\n * @returns \"BakedVertexAnimationManager\"\r\n */\r\n getClassName(): string;\r\n}\r\n\r\n/**\r\n * This class is used to animate meshes using a baked vertex animation texture\r\n * @see https://doc.babylonjs.com/divingDeeper/animation/baked_texture_animations\r\n * @since 5.0\r\n */\r\nexport class BakedVertexAnimationManager implements IBakedVertexAnimationManager {\r\n private _scene: Scene;\r\n\r\n private _texture: Nullable<BaseTexture> = null;\r\n /**\r\n * The vertex animation texture\r\n */\r\n @serializeAsTexture()\r\n @expandToProperty(\"_markSubMeshesAsAttributesDirty\")\r\n public texture: Nullable<BaseTexture>;\r\n\r\n private _isEnabled = true;\r\n /**\r\n * Enable or disable the vertex animation manager\r\n */\r\n @serialize()\r\n @expandToProperty(\"_markSubMeshesAsAttributesDirty\")\r\n public isEnabled = true;\r\n\r\n /**\r\n * The animation parameters for the mesh. See setAnimationParameters()\r\n */\r\n @serialize()\r\n public animationParameters: Vector4;\r\n\r\n /**\r\n * The time counter, to pick the correct animation frame.\r\n */\r\n @serialize()\r\n public time = 0;\r\n\r\n /**\r\n * Creates a new BakedVertexAnimationManager\r\n * @param scene defines the current scene\r\n */\r\n constructor(scene?: Nullable<Scene>) {\r\n scene = scene || EngineStore.LastCreatedScene;\r\n if (!scene) {\r\n return;\r\n }\r\n this._scene = scene;\r\n this.animationParameters = new Vector4(0, 0, 0, 30);\r\n }\r\n\r\n /** @internal */\r\n public _markSubMeshesAsAttributesDirty(): void {\r\n for (const mesh of this._scene.meshes) {\r\n if ((<any>mesh).bakedVertexAnimationManager === this) {\r\n mesh._markSubMeshesAsAttributesDirty();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Binds to the effect.\r\n * @param effect The effect to bind to.\r\n * @param useInstances True when it's an instance.\r\n */\r\n public bind(effect: Effect, useInstances = false): void {\r\n if (!this._texture || !this._isEnabled) {\r\n return;\r\n }\r\n\r\n const size = this._texture.getSize();\r\n effect.setFloat2(\"bakedVertexAnimationTextureSizeInverted\", 1.0 / size.width, 1.0 / size.height);\r\n effect.setFloat(\"bakedVertexAnimationTime\", this.time);\r\n\r\n if (!useInstances) {\r\n effect.setVector4(\"bakedVertexAnimationSettings\", this.animationParameters);\r\n }\r\n\r\n effect.setTexture(\"bakedVertexAnimationTexture\", this._texture);\r\n }\r\n\r\n /**\r\n * Clone the current manager\r\n * @returns a new BakedVertexAnimationManager\r\n */\r\n public clone(): BakedVertexAnimationManager {\r\n const copy = new BakedVertexAnimationManager(this._scene);\r\n this.copyTo(copy);\r\n return copy;\r\n }\r\n\r\n /**\r\n * Sets animation parameters.\r\n * @param startFrame The first frame of the animation.\r\n * @param endFrame The last frame of the animation.\r\n * @param offset The offset when starting the animation.\r\n * @param speedFramesPerSecond The frame rate.\r\n */\r\n public setAnimationParameters(startFrame: number, endFrame: number, offset: number = 0, speedFramesPerSecond: number = 30): void {\r\n this.animationParameters = new Vector4(startFrame, endFrame, offset, speedFramesPerSecond);\r\n }\r\n\r\n /**\r\n * Disposes the resources of the manager.\r\n * @param forceDisposeTextures - Forces the disposal of all textures.\r\n */\r\n public dispose(forceDisposeTextures?: boolean): void {\r\n if (forceDisposeTextures) {\r\n this._texture?.dispose();\r\n }\r\n }\r\n\r\n /**\r\n * Get the current class name useful for serialization or dynamic coding.\r\n * @returns \"BakedVertexAnimationManager\"\r\n */\r\n public getClassName(): string {\r\n return \"BakedVertexAnimationManager\";\r\n }\r\n\r\n /**\r\n * Makes a duplicate of the current instance into another one.\r\n * @param vatMap define the instance where to copy the info\r\n */\r\n public copyTo(vatMap: BakedVertexAnimationManager): void {\r\n SerializationHelper.Clone(() => vatMap, this);\r\n }\r\n\r\n /**\r\n * Serializes this vertex animation instance\r\n * @returns - An object with the serialized instance.\r\n */\r\n public serialize(): any {\r\n return SerializationHelper.Serialize(this);\r\n }\r\n\r\n /**\r\n * Parses a vertex animation setting from a serialized object.\r\n * @param source - Serialized object.\r\n * @param scene Defines the scene we are parsing for\r\n * @param rootUrl Defines the rootUrl to load from\r\n */\r\n public parse(source: any, scene: Scene, rootUrl: string): void {\r\n SerializationHelper.Parse(() => this, source, scene, rootUrl);\r\n }\r\n}\r\n"]}