@onerjs/core 8.32.0 → 8.32.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Audio/Interfaces/ISoundOptions.d.ts +1 -1
- package/Audio/Interfaces/ISoundOptions.js.map +1 -1
- package/Audio/audioEngine.d.ts +3 -4
- package/Audio/audioEngine.js +9 -6
- package/Audio/audioEngine.js.map +1 -1
- package/Audio/sound.d.ts +33 -54
- package/Audio/sound.js +450 -718
- package/Audio/sound.js.map +1 -1
- package/AudioV2/abstractAudio/abstractAudioOutNode.d.ts +1 -1
- package/AudioV2/abstractAudio/abstractAudioOutNode.js +1 -1
- package/AudioV2/abstractAudio/abstractAudioOutNode.js.map +1 -1
- package/AudioV2/abstractAudio/abstractSound.d.ts +1 -1
- package/AudioV2/abstractAudio/abstractSound.js +2 -2
- package/AudioV2/abstractAudio/abstractSound.js.map +1 -1
- package/AudioV2/abstractAudio/abstractSoundSource.d.ts +11 -3
- package/AudioV2/abstractAudio/abstractSoundSource.js +37 -1
- package/AudioV2/abstractAudio/abstractSoundSource.js.map +1 -1
- package/AudioV2/abstractAudio/audioBus.d.ts +8 -3
- package/AudioV2/abstractAudio/audioBus.js +24 -1
- package/AudioV2/abstractAudio/audioBus.js.map +1 -1
- package/AudioV2/abstractAudio/staticSound.d.ts +1 -1
- package/AudioV2/abstractAudio/staticSound.js +2 -2
- package/AudioV2/abstractAudio/staticSound.js.map +1 -1
- package/AudioV2/abstractAudio/streamingSound.d.ts +1 -1
- package/AudioV2/abstractAudio/streamingSound.js +2 -2
- package/AudioV2/abstractAudio/streamingSound.js.map +1 -1
- package/AudioV2/abstractAudio/subNodes/abstractAudioSubGraph.d.ts +1 -1
- package/AudioV2/abstractAudio/subNodes/abstractAudioSubGraph.js +3 -0
- package/AudioV2/abstractAudio/subNodes/abstractAudioSubGraph.js.map +1 -1
- package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.d.ts +1 -0
- package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.js +1 -0
- package/AudioV2/abstractAudio/subNodes/spatialAudioSubNode.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.d.ts +12 -2
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.js +2 -0
- package/AudioV2/abstractAudio/subProperties/abstractSpatialAudio.js.map +1 -1
- package/AudioV2/abstractAudio/subProperties/spatialAudio.d.ts +6 -0
- package/AudioV2/abstractAudio/subProperties/spatialAudio.js +25 -0
- package/AudioV2/abstractAudio/subProperties/spatialAudio.js.map +1 -1
- package/AudioV2/webAudio/components/webAudioParameterComponent.js +2 -2
- package/AudioV2/webAudio/components/webAudioParameterComponent.js.map +1 -1
- package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.d.ts +3 -0
- package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.js +14 -17
- package/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.js.map +1 -1
- package/AudioV2/webAudio/subNodes/webAudioBusAndSoundSubGraph.js +1 -0
- package/AudioV2/webAudio/subNodes/webAudioBusAndSoundSubGraph.js.map +1 -1
- package/AudioV2/webAudio/subProperties/spatialWebAudio.js +1 -0
- package/AudioV2/webAudio/subProperties/spatialWebAudio.js.map +1 -1
- package/AudioV2/webAudio/webAudioBus.d.ts +2 -7
- package/AudioV2/webAudio/webAudioBus.js +4 -24
- package/AudioV2/webAudio/webAudioBus.js.map +1 -1
- package/AudioV2/webAudio/webAudioEngine.js +1 -0
- package/AudioV2/webAudio/webAudioEngine.js.map +1 -1
- package/AudioV2/webAudio/webAudioSoundSource.d.ts +2 -7
- package/AudioV2/webAudio/webAudioSoundSource.js +3 -24
- package/AudioV2/webAudio/webAudioSoundSource.js.map +1 -1
- package/AudioV2/webAudio/webAudioStaticSound.d.ts +3 -7
- package/AudioV2/webAudio/webAudioStaticSound.js +13 -26
- package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
- package/AudioV2/webAudio/webAudioStreamingSound.d.ts +3 -7
- package/AudioV2/webAudio/webAudioStreamingSound.js +6 -23
- package/AudioV2/webAudio/webAudioStreamingSound.js.map +1 -1
- package/Cameras/arcRotateCamera.js +4 -5
- package/Cameras/arcRotateCamera.js.map +1 -1
- package/Compute/computeEffect.js +5 -1
- package/Compute/computeEffect.js.map +1 -1
- package/Compute/computeShader.d.ts +4 -0
- package/Compute/computeShader.js +9 -3
- package/Compute/computeShader.js.map +1 -1
- package/Debug/debugLayer.d.ts +1 -1
- package/Debug/debugLayer.js.map +1 -1
- package/Engines/abstractEngine.d.ts +2 -2
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/thinEngine.js +1 -1
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +8 -9
- package/Engines/webgpuEngine.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/volumetricLightingBlock.d.ts +74 -0
- package/FrameGraph/Node/Blocks/PostProcesses/volumetricLightingBlock.js +179 -0
- package/FrameGraph/Node/Blocks/PostProcesses/volumetricLightingBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/index.d.ts +2 -0
- package/FrameGraph/Node/Blocks/index.js +2 -0
- package/FrameGraph/Node/Blocks/index.js.map +1 -1
- package/FrameGraph/Node/Blocks/lightingVolumeBlock.d.ts +43 -0
- package/FrameGraph/Node/Blocks/lightingVolumeBlock.js +93 -0
- package/FrameGraph/Node/Blocks/lightingVolumeBlock.js.map +1 -0
- package/FrameGraph/Passes/renderPass.js +2 -2
- package/FrameGraph/Passes/renderPass.js.map +1 -1
- package/FrameGraph/Tasks/Layers/baseLayerTask.d.ts +2 -0
- package/FrameGraph/Tasks/Layers/baseLayerTask.js +6 -0
- package/FrameGraph/Tasks/Layers/baseLayerTask.js.map +1 -1
- package/FrameGraph/Tasks/Layers/glowLayerTask.d.ts +1 -0
- package/FrameGraph/Tasks/Layers/glowLayerTask.js +3 -0
- package/FrameGraph/Tasks/Layers/glowLayerTask.js.map +1 -1
- package/FrameGraph/Tasks/Layers/highlightLayerTask.d.ts +1 -0
- package/FrameGraph/Tasks/Layers/highlightLayerTask.js +3 -0
- package/FrameGraph/Tasks/Layers/highlightLayerTask.js.map +1 -1
- package/FrameGraph/Tasks/Misc/computeShaderTask.d.ts +1 -0
- package/FrameGraph/Tasks/Misc/computeShaderTask.js +3 -0
- package/FrameGraph/Tasks/Misc/computeShaderTask.js.map +1 -1
- package/FrameGraph/Tasks/Misc/cullObjectsTask.d.ts +1 -0
- package/FrameGraph/Tasks/Misc/cullObjectsTask.js +3 -0
- package/FrameGraph/Tasks/Misc/cullObjectsTask.js.map +1 -1
- package/FrameGraph/Tasks/Misc/executeTask.d.ts +1 -0
- package/FrameGraph/Tasks/Misc/executeTask.js +3 -0
- package/FrameGraph/Tasks/Misc/executeTask.js.map +1 -1
- package/FrameGraph/Tasks/Misc/lightingVolumeTask.d.ts +32 -0
- package/FrameGraph/Tasks/Misc/lightingVolumeTask.js +63 -0
- package/FrameGraph/Tasks/Misc/lightingVolumeTask.js.map +1 -0
- package/FrameGraph/Tasks/PostProcesses/anaglyphTask.d.ts +1 -0
- package/FrameGraph/Tasks/PostProcesses/anaglyphTask.js +3 -0
- package/FrameGraph/Tasks/PostProcesses/anaglyphTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/blackAndWhiteTask.d.ts +1 -0
- package/FrameGraph/Tasks/PostProcesses/blackAndWhiteTask.js +3 -0
- package/FrameGraph/Tasks/PostProcesses/blackAndWhiteTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomMergeTask.d.ts +1 -0
- package/FrameGraph/Tasks/PostProcesses/bloomMergeTask.js +3 -0
- package/FrameGraph/Tasks/PostProcesses/bloomMergeTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomTask.d.ts +1 -0
- package/FrameGraph/Tasks/PostProcesses/bloomTask.js +3 -0
- package/FrameGraph/Tasks/PostProcesses/bloomTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/blurTask.d.ts +1 -0
- package/FrameGraph/Tasks/PostProcesses/blurTask.js +3 -0
- package/FrameGraph/Tasks/PostProcesses/blurTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/chromaticAberrationTask.d.ts +1 -0
- package/FrameGraph/Tasks/PostProcesses/chromaticAberrationTask.js +3 -0
- package/FrameGraph/Tasks/PostProcesses/chromaticAberrationTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/circleOfConfusionTask.d.ts +1 -0
- package/FrameGraph/Tasks/PostProcesses/circleOfConfusionTask.js +3 -0
- package/FrameGraph/Tasks/PostProcesses/circleOfConfusionTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/colorCorrectionTask.d.ts +1 -0
- package/FrameGraph/Tasks/PostProcesses/colorCorrectionTask.js +3 -0
- package/FrameGraph/Tasks/PostProcesses/colorCorrectionTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/convolutionTask.d.ts +1 -0
- package/FrameGraph/Tasks/PostProcesses/convolutionTask.js +3 -0
- package/FrameGraph/Tasks/PostProcesses/convolutionTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/customPostProcessTask.d.ts +1 -0
- package/FrameGraph/Tasks/PostProcesses/customPostProcessTask.js +3 -0
- package/FrameGraph/Tasks/PostProcesses/customPostProcessTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldBlurTask.d.ts +1 -0
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldBlurTask.js +3 -0
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldBlurTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.d.ts +1 -0
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.js +3 -0
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.d.ts +1 -0
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js +3 -0
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/extractHighlightsTask.d.ts +1 -0
- package/FrameGraph/Tasks/PostProcesses/extractHighlightsTask.js +3 -0
- package/FrameGraph/Tasks/PostProcesses/extractHighlightsTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/filterTask.d.ts +1 -0
- package/FrameGraph/Tasks/PostProcesses/filterTask.js +3 -0
- package/FrameGraph/Tasks/PostProcesses/filterTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/fxaaTask.d.ts +1 -0
- package/FrameGraph/Tasks/PostProcesses/fxaaTask.js +3 -0
- package/FrameGraph/Tasks/PostProcesses/fxaaTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/grainTask.d.ts +1 -0
- package/FrameGraph/Tasks/PostProcesses/grainTask.js +3 -0
- package/FrameGraph/Tasks/PostProcesses/grainTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/imageProcessingTask.d.ts +1 -0
- package/FrameGraph/Tasks/PostProcesses/imageProcessingTask.js +3 -0
- package/FrameGraph/Tasks/PostProcesses/imageProcessingTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/motionBlurTask.d.ts +1 -0
- package/FrameGraph/Tasks/PostProcesses/motionBlurTask.js +3 -0
- package/FrameGraph/Tasks/PostProcesses/motionBlurTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/passTask.d.ts +2 -0
- package/FrameGraph/Tasks/PostProcesses/passTask.js +6 -0
- package/FrameGraph/Tasks/PostProcesses/passTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.d.ts +3 -2
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +3 -0
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/screenSpaceCurvatureTask.d.ts +1 -0
- package/FrameGraph/Tasks/PostProcesses/screenSpaceCurvatureTask.js +3 -0
- package/FrameGraph/Tasks/PostProcesses/screenSpaceCurvatureTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/sharpenTask.d.ts +1 -0
- package/FrameGraph/Tasks/PostProcesses/sharpenTask.js +3 -0
- package/FrameGraph/Tasks/PostProcesses/sharpenTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/ssao2BlurTask.d.ts +1 -0
- package/FrameGraph/Tasks/PostProcesses/ssao2BlurTask.js +3 -0
- package/FrameGraph/Tasks/PostProcesses/ssao2BlurTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/ssao2RenderingPipelineTask.d.ts +1 -0
- package/FrameGraph/Tasks/PostProcesses/ssao2RenderingPipelineTask.js +3 -0
- package/FrameGraph/Tasks/PostProcesses/ssao2RenderingPipelineTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/ssao2Task.d.ts +1 -0
- package/FrameGraph/Tasks/PostProcesses/ssao2Task.js +3 -0
- package/FrameGraph/Tasks/PostProcesses/ssao2Task.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/ssrBlurTask.d.ts +1 -0
- package/FrameGraph/Tasks/PostProcesses/ssrBlurTask.js +3 -0
- package/FrameGraph/Tasks/PostProcesses/ssrBlurTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/ssrRenderingPipelineTask.d.ts +1 -0
- package/FrameGraph/Tasks/PostProcesses/ssrRenderingPipelineTask.js +3 -0
- package/FrameGraph/Tasks/PostProcesses/ssrRenderingPipelineTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/ssrTask.d.ts +1 -0
- package/FrameGraph/Tasks/PostProcesses/ssrTask.js +3 -0
- package/FrameGraph/Tasks/PostProcesses/ssrTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/taaTask.d.ts +1 -0
- package/FrameGraph/Tasks/PostProcesses/taaTask.js +3 -0
- package/FrameGraph/Tasks/PostProcesses/taaTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/tonemapTask.d.ts +1 -0
- package/FrameGraph/Tasks/PostProcesses/tonemapTask.js +3 -0
- package/FrameGraph/Tasks/PostProcesses/tonemapTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/volumetricLightingBlendVolumeTask.d.ts +31 -0
- package/FrameGraph/Tasks/PostProcesses/volumetricLightingBlendVolumeTask.js +60 -0
- package/FrameGraph/Tasks/PostProcesses/volumetricLightingBlendVolumeTask.js.map +1 -0
- package/FrameGraph/Tasks/PostProcesses/volumetricLightingTask.d.ts +93 -0
- package/FrameGraph/Tasks/PostProcesses/volumetricLightingTask.js +183 -0
- package/FrameGraph/Tasks/PostProcesses/volumetricLightingTask.js.map +1 -0
- package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.d.ts +1 -0
- package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.js +3 -0
- package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.d.ts +1 -0
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +3 -0
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +1 -0
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +4 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.d.ts +1 -0
- package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.js +3 -0
- package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/utilityLayerRendererTask.d.ts +1 -0
- package/FrameGraph/Tasks/Rendering/utilityLayerRendererTask.js +3 -0
- package/FrameGraph/Tasks/Rendering/utilityLayerRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.d.ts +1 -0
- package/FrameGraph/Tasks/Texture/clearTextureTask.js +4 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/copyToBackbufferColorTask.d.ts +1 -0
- package/FrameGraph/Tasks/Texture/copyToBackbufferColorTask.js +3 -0
- package/FrameGraph/Tasks/Texture/copyToBackbufferColorTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/copyToTextureTask.d.ts +1 -0
- package/FrameGraph/Tasks/Texture/copyToTextureTask.js +21 -4
- package/FrameGraph/Tasks/Texture/copyToTextureTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/generateMipMapsTask.d.ts +1 -0
- package/FrameGraph/Tasks/Texture/generateMipMapsTask.js +3 -0
- package/FrameGraph/Tasks/Texture/generateMipMapsTask.js.map +1 -1
- package/FrameGraph/frameGraphRenderContext.d.ts +3 -2
- package/FrameGraph/frameGraphRenderContext.js +14 -5
- package/FrameGraph/frameGraphRenderContext.js.map +1 -1
- package/FrameGraph/frameGraphTask.d.ts +5 -0
- package/FrameGraph/frameGraphTask.js +11 -2
- package/FrameGraph/frameGraphTask.js.map +1 -1
- package/FrameGraph/index.d.ts +2 -0
- package/FrameGraph/index.js +2 -0
- package/FrameGraph/index.js.map +1 -1
- package/Lights/lightingVolume.d.ts +12 -6
- package/Lights/lightingVolume.js +218 -108
- package/Lights/lightingVolume.js.map +1 -1
- package/Loading/Plugins/babylonFileLoader.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +2 -0
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +2 -2
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/geometry.d.ts +2 -1
- package/Meshes/geometry.js +6 -2
- package/Meshes/geometry.js.map +1 -1
- package/Meshes/mesh.d.ts +2 -1
- package/Meshes/mesh.js +4 -3
- package/Meshes/mesh.js.map +1 -1
- package/Particles/Node/Blocks/Update/updateFlowMapBlock.d.ts +9 -1
- package/Particles/Node/Blocks/Update/updateFlowMapBlock.js +8 -0
- package/Particles/Node/Blocks/Update/updateFlowMapBlock.js.map +1 -1
- package/Particles/Node/Blocks/Update/updateNoiseBlock.d.ts +39 -0
- package/Particles/Node/Blocks/Update/updateNoiseBlock.js +102 -0
- package/Particles/Node/Blocks/Update/updateNoiseBlock.js.map +1 -0
- package/Particles/Node/Blocks/index.d.ts +1 -0
- package/Particles/Node/Blocks/index.js +1 -0
- package/Particles/Node/Blocks/index.js.map +1 -1
- package/Particles/Node/Blocks/particleSourceTextureBlock.d.ts +9 -5
- package/Particles/Node/Blocks/particleSourceTextureBlock.js +31 -13
- package/Particles/Node/Blocks/particleSourceTextureBlock.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.helper.js +39 -21
- package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
- package/Particles/particle.d.ts +2 -2
- package/Particles/particle.js +4 -2
- package/Particles/particle.js.map +1 -1
- package/Particles/thinParticleSystem.d.ts +1 -1
- package/Particles/thinParticleSystem.function.js +2 -2
- package/Particles/thinParticleSystem.function.js.map +1 -1
- package/Particles/thinParticleSystem.js.map +1 -1
- package/Physics/v2/characterController.d.ts +42 -2
- package/Physics/v2/characterController.js +140 -46
- package/Physics/v2/characterController.js.map +1 -1
- package/Shaders/gaussianSplatting.vertex.js +2 -2
- package/Shaders/gaussianSplatting.vertex.js.map +1 -1
- package/Shaders/volumetricLightingBlendVolume.fragment.d.ts +5 -0
- package/Shaders/volumetricLightingBlendVolume.fragment.js +21 -0
- package/Shaders/volumetricLightingBlendVolume.fragment.js.map +1 -0
- package/Shaders/volumetricLightingRenderVolume.fragment.d.ts +7 -0
- package/Shaders/volumetricLightingRenderVolume.fragment.js +25 -0
- package/Shaders/volumetricLightingRenderVolume.fragment.js.map +1 -0
- package/Shaders/volumetricLightingRenderVolume.vertex.d.ts +9 -0
- package/Shaders/volumetricLightingRenderVolume.vertex.js +18 -0
- package/Shaders/volumetricLightingRenderVolume.vertex.js.map +1 -0
- package/ShadersWGSL/gaussianSplatting.vertex.js +3 -3
- package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
- package/ShadersWGSL/lightingVolume.compute.js +10 -4
- package/ShadersWGSL/lightingVolume.compute.js.map +1 -1
- package/ShadersWGSL/volumetricLightingBlendVolume.fragment.d.ts +5 -0
- package/ShadersWGSL/volumetricLightingBlendVolume.fragment.js +22 -0
- package/ShadersWGSL/volumetricLightingBlendVolume.fragment.js.map +1 -0
- package/ShadersWGSL/volumetricLightingRenderVolume.fragment.d.ts +7 -0
- package/ShadersWGSL/volumetricLightingRenderVolume.fragment.js +27 -0
- package/ShadersWGSL/volumetricLightingRenderVolume.fragment.js.map +1 -0
- package/ShadersWGSL/volumetricLightingRenderVolume.vertex.d.ts +7 -0
- package/ShadersWGSL/volumetricLightingRenderVolume.vertex.js +17 -0
- package/ShadersWGSL/volumetricLightingRenderVolume.vertex.js.map +1 -0
- package/States/IStencilState.d.ts +48 -2
- package/States/IStencilState.js.map +1 -1
- package/States/alphaCullingState.d.ts +1 -0
- package/States/alphaCullingState.js +3 -0
- package/States/alphaCullingState.js.map +1 -1
- package/package.json +1 -1
|
@@ -40,7 +40,7 @@ export interface ISoundOptions {
|
|
|
40
40
|
* Define the distance attenuation model the sound will follow.
|
|
41
41
|
* @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound
|
|
42
42
|
*/
|
|
43
|
-
distanceModel?:
|
|
43
|
+
distanceModel?: "linear" | "inverse" | "exponential";
|
|
44
44
|
/**
|
|
45
45
|
* Defines the playback speed (1 by default)
|
|
46
46
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ISoundOptions.js","sourceRoot":"","sources":["../../../../../dev/core/src/Audio/Interfaces/ISoundOptions.ts"],"names":[],"mappings":"","sourcesContent":["/**\r\n * Interface used to define options for Sound class\r\n */\r\nexport interface ISoundOptions {\r\n /**\r\n * Does the sound autoplay once loaded.\r\n */\r\n autoplay?: boolean;\r\n /**\r\n * Does the sound loop after it finishes playing once.\r\n */\r\n loop?: boolean;\r\n /**\r\n * Sound's volume\r\n */\r\n volume?: number;\r\n /**\r\n * Is it a spatial sound?\r\n */\r\n spatialSound?: boolean;\r\n /**\r\n * Maximum distance to hear that sound\r\n */\r\n maxDistance?: number;\r\n /**\r\n * Uses user defined attenuation function\r\n */\r\n useCustomAttenuation?: boolean;\r\n /**\r\n * Define the roll off factor of spatial sounds.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n rolloffFactor?: number;\r\n /**\r\n * Define the reference distance the sound should be heard perfectly.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n refDistance?: number;\r\n /**\r\n * Define the distance attenuation model the sound will follow.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n distanceModel?:
|
|
1
|
+
{"version":3,"file":"ISoundOptions.js","sourceRoot":"","sources":["../../../../../dev/core/src/Audio/Interfaces/ISoundOptions.ts"],"names":[],"mappings":"","sourcesContent":["/**\r\n * Interface used to define options for Sound class\r\n */\r\nexport interface ISoundOptions {\r\n /**\r\n * Does the sound autoplay once loaded.\r\n */\r\n autoplay?: boolean;\r\n /**\r\n * Does the sound loop after it finishes playing once.\r\n */\r\n loop?: boolean;\r\n /**\r\n * Sound's volume\r\n */\r\n volume?: number;\r\n /**\r\n * Is it a spatial sound?\r\n */\r\n spatialSound?: boolean;\r\n /**\r\n * Maximum distance to hear that sound\r\n */\r\n maxDistance?: number;\r\n /**\r\n * Uses user defined attenuation function\r\n */\r\n useCustomAttenuation?: boolean;\r\n /**\r\n * Define the roll off factor of spatial sounds.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n rolloffFactor?: number;\r\n /**\r\n * Define the reference distance the sound should be heard perfectly.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n refDistance?: number;\r\n /**\r\n * Define the distance attenuation model the sound will follow.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound\r\n */\r\n distanceModel?: \"linear\" | \"inverse\" | \"exponential\";\r\n /**\r\n * Defines the playback speed (1 by default)\r\n */\r\n playbackRate?: number;\r\n /**\r\n * Defines if the sound is from a streaming source\r\n */\r\n streaming?: boolean;\r\n /**\r\n * Defines an optional length (in seconds) inside the sound file\r\n */\r\n length?: number;\r\n /**\r\n * Defines an optional offset (in seconds) inside the sound file\r\n */\r\n offset?: number;\r\n /**\r\n * If true, URLs will not be required to state the audio file codec to use.\r\n */\r\n skipCodecCheck?: boolean;\r\n}\r\n"]}
|
package/Audio/audioEngine.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { Nullable } from "../types.js";
|
|
1
|
+
import { _WebAudioEngine } from "../AudioV2/webAudio/webAudioEngine.js";
|
|
3
2
|
import { Observable } from "../Misc/observable.js";
|
|
3
|
+
import type { Nullable } from "../types.js";
|
|
4
|
+
import type { Analyser } from "./analyser.js";
|
|
4
5
|
import type { IAudioEngine } from "./Interfaces/IAudioEngine.js";
|
|
5
|
-
import { _WebAudioEngine } from "../AudioV2/webAudio/webAudioEngine.js";
|
|
6
6
|
/**
|
|
7
7
|
* This represents the default audio engine used in babylon.
|
|
8
8
|
* It is responsible to play, synchronize and analyse sounds throughout the application.
|
|
9
9
|
* @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic
|
|
10
10
|
*/
|
|
11
11
|
export declare class AudioEngine implements IAudioEngine {
|
|
12
|
-
private _audioContext;
|
|
13
12
|
private _masterGain;
|
|
14
13
|
private _tryToRun;
|
|
15
14
|
private _useCustomUnlockedButton;
|
package/Audio/audioEngine.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Observable } from "../Misc/observable.js";
|
|
2
|
-
import { AbstractEngine } from "../Engines/abstractEngine.js";
|
|
3
1
|
import { _WebAudioEngine } from "../AudioV2/webAudio/webAudioEngine.js";
|
|
2
|
+
import { AbstractEngine } from "../Engines/abstractEngine.js";
|
|
3
|
+
import { Observable } from "../Misc/observable.js";
|
|
4
4
|
// Sets the default audio engine to Babylon.js
|
|
5
5
|
AbstractEngine.AudioEngineFactory = (hostElement, audioContext, audioDestination) => {
|
|
6
6
|
return new AudioEngine(hostElement, audioContext, audioDestination);
|
|
@@ -50,7 +50,6 @@ export class AudioEngine {
|
|
|
50
50
|
* @param audioDestination defines the audio destination node to be used by audio engine
|
|
51
51
|
*/
|
|
52
52
|
constructor(hostElement = null, audioContext = null, audioDestination = null) {
|
|
53
|
-
this._audioContext = null;
|
|
54
53
|
this._tryToRun = false;
|
|
55
54
|
this._useCustomUnlockedButton = false;
|
|
56
55
|
/**
|
|
@@ -133,7 +132,7 @@ export class AudioEngine {
|
|
|
133
132
|
* This is helpful to resume play once browser policies have been satisfied.
|
|
134
133
|
*/
|
|
135
134
|
unlock() {
|
|
136
|
-
if (this._audioContext?.state === "running") {
|
|
135
|
+
if (this._v2._audioContext?.state === "running") {
|
|
137
136
|
if (!this.unlocked) {
|
|
138
137
|
// Notify users that the audio stack is unlocked/unmuted
|
|
139
138
|
this.unlocked = true;
|
|
@@ -146,8 +145,8 @@ export class AudioEngine {
|
|
|
146
145
|
}
|
|
147
146
|
/** @internal */
|
|
148
147
|
_resumeAudioContextOnStateChange() {
|
|
149
|
-
this._audioContext?.addEventListener("statechange", () => {
|
|
150
|
-
if (this.unlocked && this._audioContext?.state !== "running") {
|
|
148
|
+
this._v2._audioContext?.addEventListener("statechange", () => {
|
|
149
|
+
if (this.unlocked && this._v2._audioContext?.state !== "running") {
|
|
151
150
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
152
151
|
this._resumeAudioContextAsync();
|
|
153
152
|
}
|
|
@@ -162,6 +161,9 @@ export class AudioEngine {
|
|
|
162
161
|
if (this._v2._isUsingOfflineAudioContext) {
|
|
163
162
|
return Promise.resolve();
|
|
164
163
|
}
|
|
164
|
+
if (this._v2._audioContext.state === "suspended" && !this._useCustomUnlockedButton) {
|
|
165
|
+
this._v2._unmuteUIEnabled = true;
|
|
166
|
+
}
|
|
165
167
|
return this._v2._audioContext.resume();
|
|
166
168
|
}
|
|
167
169
|
/**
|
|
@@ -202,6 +204,7 @@ export class AudioEngine {
|
|
|
202
204
|
}
|
|
203
205
|
async _triggerRunningStateAsync() {
|
|
204
206
|
if (this._tryToRun) {
|
|
207
|
+
void this._v2._audioContext.resume();
|
|
205
208
|
return;
|
|
206
209
|
}
|
|
207
210
|
this._tryToRun = true;
|
package/Audio/audioEngine.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audioEngine.js","sourceRoot":"","sources":["../../../../dev/core/src/Audio/audioEngine.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAGrE,8CAA8C;AAC9C,cAAc,CAAC,kBAAkB,GAAG,CAChC,WAAkC,EAClC,YAAoC,EACpC,gBAAkF,EACpF,EAAE;IACA,OAAO,IAAI,WAAW,CAAC,WAAW,EAAE,YAAY,EAAE,gBAAgB,CAAC,CAAC;AACxE,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,OAAO,WAAW;IAWpB;;OAEG;IACH,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAED,IAAW,UAAU,CAAC,KAAe;QACjC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,OAA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esContent":["import type { Analyser } from \"./analyser\";\r\n\r\nimport type { Nullable } from \"../types\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport type { IAudioEngine } from \"./Interfaces/IAudioEngine\";\r\nimport { _WebAudioEngine } from \"../AudioV2/webAudio/webAudioEngine\";\r\nimport type { _WebAudioMainBus } from \"../AudioV2/webAudio/webAudioMainBus\";\r\n\r\n// Sets the default audio engine to Babylon.js\r\nAbstractEngine.AudioEngineFactory = (\r\n hostElement: Nullable<HTMLElement>,\r\n audioContext: Nullable<AudioContext>,\r\n audioDestination: Nullable<AudioDestinationNode | MediaStreamAudioDestinationNode>\r\n) => {\r\n return new AudioEngine(hostElement, audioContext, audioDestination);\r\n};\r\n\r\n/**\r\n * This represents the default audio engine used in babylon.\r\n * It is responsible to play, synchronize and analyse sounds throughout the application.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic\r\n */\r\nexport class AudioEngine implements IAudioEngine {\r\n private _audioContext: Nullable<AudioContext> = null;\r\n private _masterGain: GainNode;\r\n private _tryToRun = false;\r\n private _useCustomUnlockedButton: boolean = false;\r\n\r\n /**\r\n * Gets whether the current host supports Web Audio and thus could create AudioContexts.\r\n */\r\n public canUseWebAudio: boolean = true;\r\n\r\n /**\r\n * The master gain node defines the global audio volume of your audio engine.\r\n */\r\n public get masterGain(): GainNode {\r\n return this._masterGain;\r\n }\r\n\r\n public set masterGain(value: GainNode) {\r\n this._masterGain = this._v2.mainOut._inNode = value;\r\n }\r\n\r\n /**\r\n * Defines if Babylon should emit a warning if WebAudio is not supported.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public WarnedWebAudioUnsupported: boolean = false;\r\n\r\n /**\r\n * Gets whether or not mp3 are supported by your browser.\r\n */\r\n public isMP3supported: boolean = false;\r\n\r\n /**\r\n * Gets whether or not ogg are supported by your browser.\r\n */\r\n public isOGGsupported: boolean = false;\r\n\r\n /**\r\n * Gets whether audio has been unlocked on the device.\r\n * Some Browsers have strong restrictions about Audio and won't autoplay unless\r\n * a user interaction has happened.\r\n */\r\n public unlocked: boolean = false;\r\n\r\n /**\r\n * Defines if the audio engine relies on a custom unlocked button.\r\n * In this case, the embedded button will not be displayed.\r\n */\r\n public get useCustomUnlockedButton(): boolean {\r\n return this._useCustomUnlockedButton;\r\n }\r\n\r\n public set useCustomUnlockedButton(value: boolean) {\r\n this._useCustomUnlockedButton = value;\r\n this._v2._unmuteUIEnabled = !value;\r\n }\r\n\r\n /**\r\n * Event raised when audio has been unlocked on the browser.\r\n */\r\n public onAudioUnlockedObservable = new Observable<IAudioEngine>();\r\n\r\n /**\r\n * Event raised when audio has been locked on the browser.\r\n */\r\n public onAudioLockedObservable = new Observable<IAudioEngine>();\r\n\r\n /** @internal */\r\n public _v2: _WebAudioEngine;\r\n\r\n /**\r\n * Gets the current AudioContext if available.\r\n */\r\n public get audioContext(): Nullable<AudioContext> {\r\n if (this._v2.state === \"running\") {\r\n // Do not wait for the promise to unlock.\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this._triggerRunningStateAsync();\r\n }\r\n return this._v2._audioContext;\r\n }\r\n\r\n private _connectedAnalyser: Nullable<Analyser>;\r\n\r\n /**\r\n * Instantiates a new audio engine.\r\n *\r\n * @param hostElement defines the host element where to display the mute icon if necessary\r\n * @param audioContext defines the audio context to be used by the audio engine\r\n * @param audioDestination defines the audio destination node to be used by audio engine\r\n */\r\n constructor(\r\n hostElement: Nullable<HTMLElement> = null,\r\n audioContext: Nullable<AudioContext> = null,\r\n audioDestination: Nullable<AudioDestinationNode | MediaStreamAudioDestinationNode> = null\r\n ) {\r\n const v2 = new _WebAudioEngine({\r\n audioContext: audioContext ? audioContext : undefined,\r\n defaultUIParentElement: hostElement?.parentElement ? hostElement.parentElement : undefined,\r\n });\r\n\r\n // Historically the unmute button is disabled until a sound tries to play and can't, which results in a call\r\n // to `AudioEngine.lock()`, which is where the unmute button is enabled if no custom UI is requested.\r\n v2._unmuteUIEnabled = false;\r\n\r\n this._masterGain = new GainNode(v2._audioContext);\r\n v2._audioDestination = audioDestination;\r\n\r\n v2.stateChangedObservable.add((state) => {\r\n if (state === \"running\") {\r\n this.unlocked = true;\r\n this.onAudioUnlockedObservable.notifyObservers(this);\r\n } else {\r\n this.unlocked = false;\r\n this.onAudioLockedObservable.notifyObservers(this);\r\n }\r\n });\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\r\n v2._initAsync({ resumeOnInteraction: false }).then(() => {\r\n const mainBusOutNode = (v2.defaultMainBus as _WebAudioMainBus)._outNode;\r\n if (mainBusOutNode) {\r\n mainBusOutNode.disconnect(v2.mainOut._inNode);\r\n mainBusOutNode.connect(this._masterGain);\r\n }\r\n\r\n v2.mainOut._inNode = this._masterGain;\r\n v2.stateChangedObservable.notifyObservers(v2.state);\r\n });\r\n\r\n this.isMP3supported = v2.isFormatValid(\"mp3\");\r\n this.isOGGsupported = v2.isFormatValid(\"ogg\");\r\n\r\n this._v2 = v2;\r\n }\r\n\r\n /**\r\n * Flags the audio engine in Locked state.\r\n * This happens due to new browser policies preventing audio to autoplay.\r\n */\r\n public lock() {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this._v2._audioContext.suspend();\r\n\r\n if (!this._useCustomUnlockedButton) {\r\n this._v2._unmuteUIEnabled = true;\r\n }\r\n }\r\n\r\n /**\r\n * Unlocks the audio engine once a user action has been done on the dom.\r\n * This is helpful to resume play once browser policies have been satisfied.\r\n */\r\n public unlock() {\r\n if (this._audioContext?.state === \"running\") {\r\n if (!this.unlocked) {\r\n // Notify users that the audio stack is unlocked/unmuted\r\n this.unlocked = true;\r\n this.onAudioUnlockedObservable.notifyObservers(this);\r\n }\r\n\r\n return;\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this._triggerRunningStateAsync();\r\n }\r\n\r\n /** @internal */\r\n public _resumeAudioContextOnStateChange(): void {\r\n this._audioContext?.addEventListener(\r\n \"statechange\",\r\n () => {\r\n if (this.unlocked && this._audioContext?.state !== \"running\") {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this._resumeAudioContextAsync();\r\n }\r\n },\r\n {\r\n once: true,\r\n passive: true,\r\n signal: AbortSignal.timeout(3000),\r\n }\r\n );\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\r\n private _resumeAudioContextAsync(): Promise<void> {\r\n if (this._v2._isUsingOfflineAudioContext) {\r\n return Promise.resolve();\r\n }\r\n\r\n return this._v2._audioContext.resume();\r\n }\r\n\r\n /**\r\n * Destroy and release the resources associated with the audio context.\r\n */\r\n public dispose(): void {\r\n this._v2.dispose();\r\n\r\n this.onAudioUnlockedObservable.clear();\r\n this.onAudioLockedObservable.clear();\r\n }\r\n\r\n /**\r\n * Gets the global volume sets on the master gain.\r\n * @returns the global volume if set or -1 otherwise\r\n */\r\n public getGlobalVolume(): number {\r\n return this.masterGain.gain.value;\r\n }\r\n\r\n /**\r\n * Sets the global volume of your experience (sets on the master gain).\r\n * @param newVolume Defines the new global volume of the application\r\n */\r\n public setGlobalVolume(newVolume: number): void {\r\n this.masterGain.gain.value = newVolume;\r\n }\r\n\r\n /**\r\n * Connect the audio engine 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/features/featuresDeepDive/audio/playingSoundsMusic#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\r\n this._connectedAnalyser = analyser;\r\n this.masterGain.disconnect();\r\n this._connectedAnalyser.connectAudioNodes(this.masterGain, this._v2._audioContext.destination);\r\n }\r\n\r\n private async _triggerRunningStateAsync() {\r\n if (this._tryToRun) {\r\n return;\r\n }\r\n this._tryToRun = true;\r\n\r\n await this._resumeAudioContextAsync();\r\n\r\n this._tryToRun = false;\r\n this.unlocked = true;\r\n\r\n this.onAudioUnlockedObservable.notifyObservers(this);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"audioEngine.js","sourceRoot":"","sources":["../../../../dev/core/src/Audio/audioEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAErE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAKhD,8CAA8C;AAC9C,cAAc,CAAC,kBAAkB,GAAG,CAChC,WAAkC,EAClC,YAAoC,EACpC,gBAAkF,EACpF,EAAE;IACA,OAAO,IAAI,WAAW,CAAC,WAAW,EAAE,YAAY,EAAE,gBAAgB,CAAC,CAAC;AACxE,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,OAAO,WAAW;IAUpB;;OAEG;IACH,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAED,IAAW,UAAU,CAAC,KAAe;QACjC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC;IACxD,CAAC;IAyBD;;;OAGG;IACH,IAAW,uBAAuB;QAC9B,OAAO,IAAI,CAAC,wBAAwB,CAAC;IACzC,CAAC;IAED,IAAW,uBAAuB,CAAC,KAAc;QAC7C,IAAI,CAAC,wBAAwB,GAAG,KAAK,CAAC;QACtC,IAAI,CAAC,GAAG,CAAC,gBAAgB,GAAG,CAAC,KAAK,CAAC;IACvC,CAAC;IAeD;;OAEG;IACH,IAAW,YAAY;QACnB,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC/B,yCAAyC;YACzC,mEAAmE;YACnE,IAAI,CAAC,yBAAyB,EAAE,CAAC;QACrC,CAAC;QACD,OAAO,IAAI,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AGG;IACI,eAAe;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC;IACtC,CAAC;IAED;;;OAGG;IACI,eAAe,CAAC,SAAiB;QACpC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;IAC3C,CAAC;IAED;;;;;OAKG;IACI,iBAAiB,CAAC,QAAkB;QACvC,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC1B,IAAI,CAAC,kBAAkB,CAAC,eAAe,EAAE,CAAC;QAC9C,CAAC;QAED,IAAI,CAAC,kBAAkB,GAAG,QAAQ,CAAC;QACnC,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC;QAC7B,IAAI,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;IACnG,CAAC;IAEO,KAAK,CAAC,yBAAyB;QACnC,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACjB,KAAK,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC;YACrC,OAAO;QACX,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QAEtB,MAAM,IAAI,CAAC,wBAAwB,EAAE,CAAC;QAEtC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QAErB,IAAI,CAAC,yBAAyB,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACzD,CAAC;CACJ","sourcesContent":["import { _WebAudioEngine } from \"../AudioV2/webAudio/webAudioEngine\";\r\nimport type { _WebAudioMainBus } from \"../AudioV2/webAudio/webAudioMainBus\";\r\nimport { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Analyser } from \"./analyser\";\r\nimport type { IAudioEngine } from \"./Interfaces/IAudioEngine\";\r\n\r\n// Sets the default audio engine to Babylon.js\r\nAbstractEngine.AudioEngineFactory = (\r\n hostElement: Nullable<HTMLElement>,\r\n audioContext: Nullable<AudioContext>,\r\n audioDestination: Nullable<AudioDestinationNode | MediaStreamAudioDestinationNode>\r\n) => {\r\n return new AudioEngine(hostElement, audioContext, audioDestination);\r\n};\r\n\r\n/**\r\n * This represents the default audio engine used in babylon.\r\n * It is responsible to play, synchronize and analyse sounds throughout the application.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic\r\n */\r\nexport class AudioEngine implements IAudioEngine {\r\n private _masterGain: GainNode;\r\n private _tryToRun = false;\r\n private _useCustomUnlockedButton: boolean = false;\r\n\r\n /**\r\n * Gets whether the current host supports Web Audio and thus could create AudioContexts.\r\n */\r\n public canUseWebAudio: boolean = true;\r\n\r\n /**\r\n * The master gain node defines the global audio volume of your audio engine.\r\n */\r\n public get masterGain(): GainNode {\r\n return this._masterGain;\r\n }\r\n\r\n public set masterGain(value: GainNode) {\r\n this._masterGain = this._v2.mainOut._inNode = value;\r\n }\r\n\r\n /**\r\n * Defines if Babylon should emit a warning if WebAudio is not supported.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public WarnedWebAudioUnsupported: boolean = false;\r\n\r\n /**\r\n * Gets whether or not mp3 are supported by your browser.\r\n */\r\n public isMP3supported: boolean = false;\r\n\r\n /**\r\n * Gets whether or not ogg are supported by your browser.\r\n */\r\n public isOGGsupported: boolean = false;\r\n\r\n /**\r\n * Gets whether audio has been unlocked on the device.\r\n * Some Browsers have strong restrictions about Audio and won't autoplay unless\r\n * a user interaction has happened.\r\n */\r\n public unlocked: boolean = false;\r\n\r\n /**\r\n * Defines if the audio engine relies on a custom unlocked button.\r\n * In this case, the embedded button will not be displayed.\r\n */\r\n public get useCustomUnlockedButton(): boolean {\r\n return this._useCustomUnlockedButton;\r\n }\r\n\r\n public set useCustomUnlockedButton(value: boolean) {\r\n this._useCustomUnlockedButton = value;\r\n this._v2._unmuteUIEnabled = !value;\r\n }\r\n\r\n /**\r\n * Event raised when audio has been unlocked on the browser.\r\n */\r\n public onAudioUnlockedObservable = new Observable<IAudioEngine>();\r\n\r\n /**\r\n * Event raised when audio has been locked on the browser.\r\n */\r\n public onAudioLockedObservable = new Observable<IAudioEngine>();\r\n\r\n /** @internal */\r\n public _v2: _WebAudioEngine;\r\n\r\n /**\r\n * Gets the current AudioContext if available.\r\n */\r\n public get audioContext(): Nullable<AudioContext> {\r\n if (this._v2.state === \"running\") {\r\n // Do not wait for the promise to unlock.\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this._triggerRunningStateAsync();\r\n }\r\n return this._v2._audioContext;\r\n }\r\n\r\n private _connectedAnalyser: Nullable<Analyser>;\r\n\r\n /**\r\n * Instantiates a new audio engine.\r\n *\r\n * @param hostElement defines the host element where to display the mute icon if necessary\r\n * @param audioContext defines the audio context to be used by the audio engine\r\n * @param audioDestination defines the audio destination node to be used by audio engine\r\n */\r\n constructor(\r\n hostElement: Nullable<HTMLElement> = null,\r\n audioContext: Nullable<AudioContext> = null,\r\n audioDestination: Nullable<AudioDestinationNode | MediaStreamAudioDestinationNode> = null\r\n ) {\r\n const v2 = new _WebAudioEngine({\r\n audioContext: audioContext ? audioContext : undefined,\r\n defaultUIParentElement: hostElement?.parentElement ? hostElement.parentElement : undefined,\r\n });\r\n\r\n // Historically the unmute button is disabled until a sound tries to play and can't, which results in a call\r\n // to `AudioEngine.lock()`, which is where the unmute button is enabled if no custom UI is requested.\r\n v2._unmuteUIEnabled = false;\r\n\r\n this._masterGain = new GainNode(v2._audioContext);\r\n v2._audioDestination = audioDestination;\r\n\r\n v2.stateChangedObservable.add((state) => {\r\n if (state === \"running\") {\r\n this.unlocked = true;\r\n this.onAudioUnlockedObservable.notifyObservers(this);\r\n } else {\r\n this.unlocked = false;\r\n this.onAudioLockedObservable.notifyObservers(this);\r\n }\r\n });\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\r\n v2._initAsync({ resumeOnInteraction: false }).then(() => {\r\n const mainBusOutNode = (v2.defaultMainBus as _WebAudioMainBus)._outNode;\r\n if (mainBusOutNode) {\r\n mainBusOutNode.disconnect(v2.mainOut._inNode);\r\n mainBusOutNode.connect(this._masterGain);\r\n }\r\n\r\n v2.mainOut._inNode = this._masterGain;\r\n v2.stateChangedObservable.notifyObservers(v2.state);\r\n });\r\n\r\n this.isMP3supported = v2.isFormatValid(\"mp3\");\r\n this.isOGGsupported = v2.isFormatValid(\"ogg\");\r\n\r\n this._v2 = v2;\r\n }\r\n\r\n /**\r\n * Flags the audio engine in Locked state.\r\n * This happens due to new browser policies preventing audio to autoplay.\r\n */\r\n public lock() {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this._v2._audioContext.suspend();\r\n\r\n if (!this._useCustomUnlockedButton) {\r\n this._v2._unmuteUIEnabled = true;\r\n }\r\n }\r\n\r\n /**\r\n * Unlocks the audio engine once a user action has been done on the dom.\r\n * This is helpful to resume play once browser policies have been satisfied.\r\n */\r\n public unlock() {\r\n if (this._v2._audioContext?.state === \"running\") {\r\n if (!this.unlocked) {\r\n // Notify users that the audio stack is unlocked/unmuted\r\n this.unlocked = true;\r\n this.onAudioUnlockedObservable.notifyObservers(this);\r\n }\r\n\r\n return;\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this._triggerRunningStateAsync();\r\n }\r\n\r\n /** @internal */\r\n public _resumeAudioContextOnStateChange(): void {\r\n this._v2._audioContext?.addEventListener(\r\n \"statechange\",\r\n () => {\r\n if (this.unlocked && this._v2._audioContext?.state !== \"running\") {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this._resumeAudioContextAsync();\r\n }\r\n },\r\n {\r\n once: true,\r\n passive: true,\r\n signal: AbortSignal.timeout(3000),\r\n }\r\n );\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\r\n private _resumeAudioContextAsync(): Promise<void> {\r\n if (this._v2._isUsingOfflineAudioContext) {\r\n return Promise.resolve();\r\n }\r\n\r\n if (this._v2._audioContext.state === \"suspended\" && !this._useCustomUnlockedButton) {\r\n this._v2._unmuteUIEnabled = true;\r\n }\r\n\r\n return this._v2._audioContext.resume();\r\n }\r\n\r\n /**\r\n * Destroy and release the resources associated with the audio context.\r\n */\r\n public dispose(): void {\r\n this._v2.dispose();\r\n\r\n this.onAudioUnlockedObservable.clear();\r\n this.onAudioLockedObservable.clear();\r\n }\r\n\r\n /**\r\n * Gets the global volume sets on the master gain.\r\n * @returns the global volume if set or -1 otherwise\r\n */\r\n public getGlobalVolume(): number {\r\n return this.masterGain.gain.value;\r\n }\r\n\r\n /**\r\n * Sets the global volume of your experience (sets on the master gain).\r\n * @param newVolume Defines the new global volume of the application\r\n */\r\n public setGlobalVolume(newVolume: number): void {\r\n this.masterGain.gain.value = newVolume;\r\n }\r\n\r\n /**\r\n * Connect the audio engine 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/features/featuresDeepDive/audio/playingSoundsMusic#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\r\n this._connectedAnalyser = analyser;\r\n this.masterGain.disconnect();\r\n this._connectedAnalyser.connectAudioNodes(this.masterGain, this._v2._audioContext.destination);\r\n }\r\n\r\n private async _triggerRunningStateAsync() {\r\n if (this._tryToRun) {\r\n void this._v2._audioContext.resume();\r\n return;\r\n }\r\n this._tryToRun = true;\r\n\r\n await this._resumeAudioContextAsync();\r\n\r\n this._tryToRun = false;\r\n this.unlocked = true;\r\n\r\n this.onAudioUnlockedObservable.notifyObservers(this);\r\n }\r\n}\r\n"]}
|
package/Audio/sound.d.ts
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import { Observable } from "../Misc/observable.js";
|
|
2
1
|
import { Vector3 } from "../Maths/math.vector.js";
|
|
3
|
-
import type { Nullable } from "../types.js";
|
|
4
|
-
import type { Scene } from "../scene.js";
|
|
5
2
|
import type { TransformNode } from "../Meshes/transformNode.js";
|
|
3
|
+
import { Observable } from "../Misc/observable.js";
|
|
4
|
+
import type { Scene } from "../scene.js";
|
|
5
|
+
import type { Nullable } from "../types.js";
|
|
6
6
|
import type { ISoundOptions } from "./Interfaces/ISoundOptions.js";
|
|
7
7
|
/**
|
|
8
8
|
* Defines a sound that can be played in the application.
|
|
9
9
|
* The sound can either be an ambient track or a simple sound played in reaction to a user action.
|
|
10
|
-
* @see https://doc.babylonjs.com/
|
|
10
|
+
* @see https://doc.babylonjs.com/legacy/audio
|
|
11
11
|
*/
|
|
12
12
|
export declare class Sound {
|
|
13
13
|
/**
|
|
14
14
|
* The name of the sound in the scene.
|
|
15
15
|
*/
|
|
16
|
-
name: string;
|
|
16
|
+
get name(): string;
|
|
17
|
+
set name(value: string);
|
|
17
18
|
/**
|
|
18
19
|
* Does the sound autoplay once loaded.
|
|
19
20
|
*/
|
|
20
|
-
autoplay: boolean;
|
|
21
|
-
|
|
21
|
+
get autoplay(): boolean;
|
|
22
|
+
set autoplay(value: boolean);
|
|
22
23
|
/**
|
|
23
24
|
* Does the sound loop after it finishes playing once.
|
|
24
25
|
*/
|
|
@@ -27,7 +28,7 @@ export declare class Sound {
|
|
|
27
28
|
/**
|
|
28
29
|
* Does the sound use a custom attenuation curve to simulate the falloff
|
|
29
30
|
* happening when the source gets further away from the camera.
|
|
30
|
-
* @see https://doc.babylonjs.com/
|
|
31
|
+
* @see https://doc.babylonjs.com/legacy/audio#creating-your-own-custom-attenuation-function
|
|
31
32
|
*/
|
|
32
33
|
useCustomAttenuation: boolean;
|
|
33
34
|
/**
|
|
@@ -37,31 +38,33 @@ export declare class Sound {
|
|
|
37
38
|
/**
|
|
38
39
|
* Is this sound currently played.
|
|
39
40
|
*/
|
|
40
|
-
isPlaying: boolean;
|
|
41
|
+
get isPlaying(): boolean;
|
|
41
42
|
/**
|
|
42
43
|
* Is this sound currently paused.
|
|
43
44
|
*/
|
|
44
|
-
isPaused: boolean;
|
|
45
|
+
get isPaused(): boolean;
|
|
45
46
|
/**
|
|
46
47
|
* Define the reference distance the sound should be heard perfectly.
|
|
47
|
-
* @see https://doc.babylonjs.com/
|
|
48
|
+
* @see https://doc.babylonjs.com/legacy/audio#creating-a-spatial-3d-sound
|
|
48
49
|
*/
|
|
49
50
|
refDistance: number;
|
|
50
51
|
/**
|
|
51
52
|
* Define the roll off factor of spatial sounds.
|
|
52
|
-
* @see https://doc.babylonjs.com/
|
|
53
|
+
* @see https://doc.babylonjs.com/legacy/audio#creating-a-spatial-3d-sound
|
|
53
54
|
*/
|
|
54
55
|
rolloffFactor: number;
|
|
55
56
|
/**
|
|
56
57
|
* Define the max distance the sound should be heard (intensity just became 0 at this point).
|
|
57
|
-
* @see https://doc.babylonjs.com/
|
|
58
|
+
* @see https://doc.babylonjs.com/legacy/audio#creating-a-spatial-3d-sound
|
|
58
59
|
*/
|
|
59
|
-
maxDistance: number;
|
|
60
|
+
get maxDistance(): number;
|
|
61
|
+
set maxDistance(value: number);
|
|
60
62
|
/**
|
|
61
63
|
* Define the distance attenuation model the sound will follow.
|
|
62
|
-
* @see https://doc.babylonjs.com/
|
|
64
|
+
* @see https://doc.babylonjs.com/legacy/audio#creating-a-spatial-3d-sound
|
|
63
65
|
*/
|
|
64
|
-
distanceModel:
|
|
66
|
+
get distanceModel(): "linear" | "inverse" | "exponential";
|
|
67
|
+
set distanceModel(value: "linear" | "inverse" | "exponential");
|
|
65
68
|
/**
|
|
66
69
|
* @internal
|
|
67
70
|
* Back Compat
|
|
@@ -81,48 +84,29 @@ export declare class Sound {
|
|
|
81
84
|
get currentTime(): number;
|
|
82
85
|
/**
|
|
83
86
|
* Does this sound enables spatial sound.
|
|
84
|
-
* @see https://doc.babylonjs.com/
|
|
87
|
+
* @see https://doc.babylonjs.com/legacy/audio#creating-a-spatial-3d-sound
|
|
85
88
|
*/
|
|
86
89
|
get spatialSound(): boolean;
|
|
87
90
|
/**
|
|
88
91
|
* Does this sound enables spatial sound.
|
|
89
|
-
* @see https://doc.babylonjs.com/
|
|
92
|
+
* @see https://doc.babylonjs.com/legacy/audio#creating-a-spatial-3d-sound
|
|
90
93
|
*/
|
|
91
94
|
set spatialSound(newValue: boolean);
|
|
92
|
-
private _spatialSound;
|
|
93
|
-
private _panningModel;
|
|
94
|
-
private _playbackRate;
|
|
95
|
-
private _streaming;
|
|
96
|
-
private _startTime;
|
|
97
|
-
private _currentTime;
|
|
98
|
-
private _position;
|
|
99
95
|
private _localDirection;
|
|
100
96
|
private _volume;
|
|
101
97
|
private _isReadyToPlay;
|
|
102
98
|
private _isDirectional;
|
|
103
99
|
private _readyToPlayCallback;
|
|
104
|
-
private _audioBuffer;
|
|
105
|
-
private _soundSource;
|
|
106
|
-
private _streamingSource;
|
|
107
|
-
private _soundPanner;
|
|
108
|
-
private _soundGain;
|
|
109
|
-
private _inputAudioNode;
|
|
110
|
-
private _outputAudioNode;
|
|
111
|
-
private _coneInnerAngle;
|
|
112
|
-
private _coneOuterAngle;
|
|
113
|
-
private _coneOuterGain;
|
|
114
100
|
private _scene;
|
|
115
101
|
private _connectedTransformNode;
|
|
116
102
|
private _customAttenuationFunction;
|
|
117
103
|
private _registerFunc;
|
|
118
104
|
private _isOutputConnected;
|
|
119
|
-
private
|
|
120
|
-
private
|
|
121
|
-
private
|
|
122
|
-
private
|
|
123
|
-
private
|
|
124
|
-
private _audioUnlockedObserver?;
|
|
125
|
-
private _url?;
|
|
105
|
+
private _url;
|
|
106
|
+
private readonly _optionsV2;
|
|
107
|
+
private readonly _soundV2;
|
|
108
|
+
private _onReadyObservable;
|
|
109
|
+
private get _onReady();
|
|
126
110
|
/**
|
|
127
111
|
* @internal
|
|
128
112
|
*/
|
|
@@ -136,6 +120,7 @@ export declare class Sound {
|
|
|
136
120
|
* @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
|
|
137
121
|
*/
|
|
138
122
|
constructor(name: string, urlOrArrayBuffer: any, scene?: Nullable<Scene>, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
|
|
123
|
+
private _onReadyToPlay;
|
|
139
124
|
/**
|
|
140
125
|
* Release the sound and its associated resources
|
|
141
126
|
*/
|
|
@@ -150,8 +135,6 @@ export declare class Sound {
|
|
|
150
135
|
* @returns current class name
|
|
151
136
|
*/
|
|
152
137
|
getClassName(): string;
|
|
153
|
-
private _audioBufferLoaded;
|
|
154
|
-
private _soundLoaded;
|
|
155
138
|
/**
|
|
156
139
|
* Sets the data of the sound from an audiobuffer
|
|
157
140
|
* @param audioBuffer The audioBuffer containing the data
|
|
@@ -162,22 +145,19 @@ export declare class Sound {
|
|
|
162
145
|
* @param options A JSON object containing values named as the object properties
|
|
163
146
|
*/
|
|
164
147
|
updateOptions(options: ISoundOptions): void;
|
|
165
|
-
private _createSpatialParameters;
|
|
166
|
-
private _disableSpatialSound;
|
|
167
148
|
private _updateSpatialParameters;
|
|
168
149
|
/**
|
|
169
150
|
* Switch the panning model to HRTF:
|
|
170
151
|
* Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
|
|
171
|
-
* @see https://doc.babylonjs.com/
|
|
152
|
+
* @see https://doc.babylonjs.com/legacy/audio#creating-a-spatial-3d-sound
|
|
172
153
|
*/
|
|
173
154
|
switchPanningModelToHRTF(): void;
|
|
174
155
|
/**
|
|
175
156
|
* Switch the panning model to Equal Power:
|
|
176
157
|
* Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
|
|
177
|
-
* @see https://doc.babylonjs.com/
|
|
158
|
+
* @see https://doc.babylonjs.com/legacy/audio#creating-a-spatial-3d-sound
|
|
178
159
|
*/
|
|
179
160
|
switchPanningModelToEqualPower(): void;
|
|
180
|
-
private _switchPanningModel;
|
|
181
161
|
/**
|
|
182
162
|
* Connect this sound to a sound track audio node like gain...
|
|
183
163
|
* @param soundTrackAudioNode the sound track audio node to connect to
|
|
@@ -217,12 +197,13 @@ export declare class Sound {
|
|
|
217
197
|
*/
|
|
218
198
|
setLocalDirectionToMesh(newLocalDirection: Vector3): void;
|
|
219
199
|
private _updateDirection;
|
|
200
|
+
private _initSpatial;
|
|
220
201
|
/** @internal */
|
|
221
202
|
updateDistanceFromListener(): void;
|
|
222
203
|
/**
|
|
223
204
|
* Sets a new custom attenuation function for the sound.
|
|
224
205
|
* @param callback Defines the function used for the attenuation
|
|
225
|
-
* @see https://doc.babylonjs.com/
|
|
206
|
+
* @see https://doc.babylonjs.com/legacy/audio#creating-your-own-custom-attenuation-function
|
|
226
207
|
*/
|
|
227
208
|
setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
|
|
228
209
|
/**
|
|
@@ -266,12 +247,12 @@ export declare class Sound {
|
|
|
266
247
|
/**
|
|
267
248
|
* Attach the sound to a dedicated mesh
|
|
268
249
|
* @param transformNode The transform node to connect the sound with
|
|
269
|
-
* @see https://doc.babylonjs.com/
|
|
250
|
+
* @see https://doc.babylonjs.com/legacy/audio#attaching-a-sound-to-a-mesh
|
|
270
251
|
*/
|
|
271
252
|
attachToMesh(transformNode: TransformNode): void;
|
|
272
253
|
/**
|
|
273
254
|
* Detach the sound from the previously attached mesh
|
|
274
|
-
* @see https://doc.babylonjs.com/
|
|
255
|
+
* @see https://doc.babylonjs.com/legacy/audio#attaching-a-sound-to-a-mesh
|
|
275
256
|
*/
|
|
276
257
|
detachFromMesh(): void;
|
|
277
258
|
private _onRegisterAfterWorldMatrixUpdate;
|
|
@@ -309,6 +290,4 @@ export declare class Sound {
|
|
|
309
290
|
* @returns the newly parsed sound
|
|
310
291
|
*/
|
|
311
292
|
static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
|
|
312
|
-
private _setOffset;
|
|
313
|
-
private _clearTimeoutsAndObservers;
|
|
314
293
|
}
|