11import { Scene } from "@babylonjs/core/scene" ;
22import { AssetContainer } from "@babylonjs/core/assetContainer" ;
3- import { SceneComponentConstants } from "@babylonjs/core/sceneComponent" ;
4- import { GetParser , AddParser } from "@babylonjs/core/Loading/Plugins/babylonFileParser.function" ;
3+ import { AddParser } from "@babylonjs/core/Loading/Plugins/babylonFileParser.function" ;
54
65let registered = false ;
76
@@ -12,16 +11,25 @@ export function registerAudioParser() {
1211
1312 registered = true ;
1413
15- const audioParser = GetParser ( SceneComponentConstants . NAME_AUDIO ) ;
14+ // const audioParser = GetParser(SceneComponentConstants.NAME_AUDIO);
1615
17- AddParser ( "AudioEditorPlugin" , ( parsedData : any , scene : Scene , container : AssetContainer , rootUrl : string ) => {
18- audioParser ?.( parsedData , scene , container , rootUrl ) ;
16+ AddParser ( "AudioEditorPlugin" , ( parsedData : any , scene : Scene , container : AssetContainer , _rootUrl : string ) => {
17+ // audioParser?.(parsedData, scene, container, rootUrl);
1918
2019 parsedData . sounds ?. forEach ( ( sound ) => {
2120 const instance = container . sounds ?. find ( ( s ) => s . name === sound . name ) ;
2221 if ( instance ) {
2322 instance . id = sound . id ;
2423 instance . uniqueId = sound . uniqueId ;
24+
25+ scene . onBeforeRenderObservable . addOnce ( ( ) => {
26+ // Backward compatibility, check if "spatialSound" is not getter only
27+ try {
28+ instance . spatialSound = sound . spatialSound ;
29+ } catch ( e ) {
30+ // Catch silently.
31+ }
32+ } ) ;
2533 }
2634 } ) ;
2735 } ) ;
0 commit comments