소스 검색

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) => {