소스 검색

Fix for Web Audio for GearVR in VR mode

David Rousset 8 년 전
부모
커밋
6223c35210

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 2858 - 2855
dist/preview release/babylon.d.ts


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 38 - 38
dist/preview release/babylon.js


+ 62 - 6
dist/preview release/babylon.max.js

@@ -5344,7 +5344,10 @@ var BABYLON;
         };
         SmartArray.prototype.dispose = function () {
             this.reset();
-            this.data.length = 0;
+            if (this.data) {
+                this.data.length = 0;
+                this.data = null;
+            }
         };
         SmartArray.prototype.concat = function (array) {
             if (array.length === 0) {
@@ -10702,7 +10705,7 @@ var BABYLON;
             // Events
             window.removeEventListener("blur", this._onBlur);
             window.removeEventListener("focus", this._onFocus);
-            this._renderingCanvas.removeEventListener("blur", this._onCanvasBlur);
+            this._renderingCanvas.removeEventListener("pointerout", this._onCanvasBlur);
             document.removeEventListener("fullscreenchange", this._onFullscreenChange);
             document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
             document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
@@ -10716,6 +10719,14 @@ var BABYLON;
             if (index >= 0) {
                 Engine.Instances.splice(index, 1);
             }
+            this._workingCanvas = null;
+            this._workingContext = null;
+            this._currentBufferPointers = null;
+            this._renderingCanvas = null;
+            this._currentProgram = null;
+            this.onResizeObservable.clear();
+            this.onCanvasBlurObservable.clear();
+            BABYLON.Effect.ResetCache();
         };
         // Loading screen
         Engine.prototype.displayLoadingUI = function () {
@@ -14807,6 +14818,14 @@ var BABYLON;
             while (--i >= 0) {
                 this._postProcesses[i].dispose(this);
             }
+            // Render targets
+            var i = this.customRenderTargets.length;
+            while (--i >= 0) {
+                this.customRenderTargets[i].dispose();
+            }
+            this.customRenderTargets = [];
+            // Active Meshes
+            this._activeMeshes.dispose();
             _super.prototype.dispose.call(this);
         };
         Object.defineProperty(Camera.prototype, "leftCamera", {
@@ -18346,7 +18365,10 @@ var BABYLON;
                 var mat = BABYLON.Matrix.Invert(listeningCamera.getViewMatrix());
                 var cameraDirection = BABYLON.Vector3.TransformNormal(new BABYLON.Vector3(0, 0, -1), mat);
                 cameraDirection.normalize();
-                audioEngine.audioContext.listener.setOrientation(cameraDirection.x, cameraDirection.y, cameraDirection.z, 0, 1, 0);
+                // To avoid some errors on GearVR
+                if (!isNaN(cameraDirection.x) && !isNaN(cameraDirection.y) && !isNaN(cameraDirection.z)) {
+                    audioEngine.audioContext.listener.setOrientation(cameraDirection.x, cameraDirection.y, cameraDirection.z, 0, 1, 0);
+                }
                 var i;
                 for (i = 0; i < this.mainSoundTrack.soundCollection.length; i++) {
                     var sound = this.mainSoundTrack.soundCollection[i];
@@ -18502,6 +18524,7 @@ var BABYLON;
             this._activeParticleSystems.dispose();
             this._activeSkeletons.dispose();
             this._softwareSkinnedMeshes.dispose();
+            this._renderTargets.dispose();
             if (this._boundingBoxRenderer) {
                 this._boundingBoxRenderer.dispose();
             }
@@ -18540,6 +18563,12 @@ var BABYLON;
                 this.cameras[0].dispose();
             }
             // Release materials
+            if (this.defaultMaterial) {
+                this.defaultMaterial.dispose();
+            }
+            while (this.multiMaterials.length) {
+                this.multiMaterials[0].dispose();
+            }
             while (this.materials.length) {
                 this.materials[0].dispose();
             }
@@ -18577,6 +18606,9 @@ var BABYLON;
             }
             this._engine.wipeCaches();
             this._engine = null;
+            this.defaultMaterial = null;
+            this.multiMaterials = null;
+            this.materials = null;
         };
         Object.defineProperty(Scene.prototype, "isDisposed", {
             get: function () {
@@ -20030,6 +20062,15 @@ var BABYLON;
         Texture.prototype.getClassName = function () {
             return "Texture";
         };
+        Texture.prototype.dispose = function () {
+            _super.prototype.dispose.call(this);
+            if (this.onLoadObservable) {
+                this.onLoadObservable.clear();
+                this._onLoadObservable = null;
+            }
+            this._delayedOnLoad = null;
+            this._delayedOnError = null;
+        };
         // Statics
         Texture.CreateFromBase64String = function (data, name, scene, noMipmap, invertY, samplingMode, onLoad, onError, format) {
             if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
@@ -24077,6 +24118,9 @@ var BABYLON;
             // Recombine
             return this._recombineShader(root);
         };
+        Effect.ResetCache = function () {
+            Effect._baseCache = {};
+        };
         return Effect;
     }());
     Effect._uniqueIdSeed = 0;
@@ -34326,6 +34370,9 @@ var BABYLON;
             ]);
         };
         ArcRotateCameraPointersInput.prototype.detachControl = function (element) {
+            BABYLON.Tools.UnregisterTopRootEvents([
+                { name: "blur", handler: this._onLostFocus }
+            ]);
             if (element && this._observer) {
                 this.camera.getScene().onPointerObservable.remove(this._observer);
                 this._observer = null;
@@ -34342,9 +34389,7 @@ var BABYLON;
                 this._onLostFocus = null;
                 this._onContextMenu = null;
             }
-            BABYLON.Tools.UnregisterTopRootEvents([
-                { name: "blur", handler: this._onLostFocus }
-            ]);
+            this.camera = null;
         };
         ArcRotateCameraPointersInput.prototype.getClassName = function () {
             return "ArcRotateCameraPointersInput";
@@ -49047,6 +49092,17 @@ var BABYLON;
             }
             return serializationObject;
         };
+        MultiMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
+            var scene = this.getScene();
+            if (!scene) {
+                return;
+            }
+            var index = scene.multiMaterials.indexOf(this);
+            if (index >= 0) {
+                scene.multiMaterials.splice(index, 1);
+            }
+            _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
+        };
         return MultiMaterial;
     }(BABYLON.Material));
     BABYLON.MultiMaterial = MultiMaterial;

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 2858 - 2855
dist/preview release/babylon.module.d.ts


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 38 - 38
dist/preview release/babylon.worker.js


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 3206 - 3206
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1 - 1
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js


+ 4 - 1
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js

@@ -18365,7 +18365,10 @@ var BABYLON;
                 var mat = BABYLON.Matrix.Invert(listeningCamera.getViewMatrix());
                 var cameraDirection = BABYLON.Vector3.TransformNormal(new BABYLON.Vector3(0, 0, -1), mat);
                 cameraDirection.normalize();
-                audioEngine.audioContext.listener.setOrientation(cameraDirection.x, cameraDirection.y, cameraDirection.z, 0, 1, 0);
+                // To avoid some errors on GearVR
+                if (!isNaN(cameraDirection.x) && !isNaN(cameraDirection.y) && !isNaN(cameraDirection.z)) {
+                    audioEngine.audioContext.listener.setOrientation(cameraDirection.x, cameraDirection.y, cameraDirection.z, 0, 1, 0);
+                }
                 var i;
                 for (i = 0; i < this.mainSoundTrack.soundCollection.length; i++) {
                     var sound = this.mainSoundTrack.soundCollection[i];

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 3206 - 3206
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.module.d.ts


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1 - 1
dist/preview release/loaders/babylon.objFileLoader.min.js


+ 4 - 1
src/babylon.scene.ts

@@ -3102,7 +3102,10 @@
                 var mat = Matrix.Invert(listeningCamera.getViewMatrix());
                 var cameraDirection = Vector3.TransformNormal(new Vector3(0, 0, -1), mat);
                 cameraDirection.normalize();
-                audioEngine.audioContext.listener.setOrientation(cameraDirection.x, cameraDirection.y, cameraDirection.z, 0, 1, 0);
+                // To avoid some errors on GearVR
+                if (!isNaN(cameraDirection.x) && !isNaN(cameraDirection.y) && !isNaN(cameraDirection.z)) {
+                    audioEngine.audioContext.listener.setOrientation(cameraDirection.x, cameraDirection.y, cameraDirection.z, 0, 1, 0);
+                }
                 var i: number;
                 for (i = 0; i < this.mainSoundTrack.soundCollection.length; i++) {
                     var sound = this.mainSoundTrack.soundCollection[i];