Browse Source

Audio scene component instantiation

sebastien 7 năm trước cách đây
mục cha
commit
4b9334f7fa
1 tập tin đã thay đổi với 6 bổ sung0 xóa
  1. 6 0
      src/Audio/babylon.sound.ts

+ 6 - 0
src/Audio/babylon.sound.ts

@@ -60,6 +60,12 @@ module BABYLON {
         constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback: Nullable<() => void> = null, options?: any) {
             this.name = name;
             this._scene = scene;
+            let compo = scene._getComponent(SceneComponentConstants.NAME_AUDIO);
+            if (!compo) {
+                compo = new AudioSceneComponent(scene);
+                scene._addComponent(compo);
+            }
+
             this._readyToPlayCallback = readyToPlayCallback;
             // Default custom attenuation function is a linear attenuation
             this._customAttenuationFunction = (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => {