Browse Source

Check if audioEngine exists on Engine

Check if audioEngine exists on Engine - when using NullEngine, the audioEngine does not seem to exist on Engine.

```
 Error: Uncaught [TypeError: Cannot read property 'audioContext' of undefined]
 at AudioSceneComponent._afterRender (REDACTED/node_modules/@babylonjs/core/Audio/audioSceneComponent.js:394:25)
 at Scene.render (REDACTED/node_modules/@babylonjs/core/scene.js:3430:18)
```
Fox Hound 4 years ago
parent
commit
e42d396c15
1 changed files with 4 additions and 0 deletions
  1. 4 0
      src/Audio/audioSceneComponent.ts

+ 4 - 0
src/Audio/audioSceneComponent.ts

@@ -495,6 +495,10 @@ export class AudioSceneComponent implements ISceneSerializableComponent {
         }
 
         var audioEngine = Engine.audioEngine;
+        
+        if (!audioEngine) {
+            return;
+        }
 
         if (audioEngine.audioContext) {
             // A custom listener position provider was set