浏览代码

Audio scene component instantiation

sebastien 7 年之前
父节点
当前提交
4b9334f7fa
共有 1 个文件被更改,包括 6 次插入0 次删除
  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) => {