ソースを参照

Fixing engine.dispose

David Catuhe 11 年 前
コミット
90f831552e

+ 6 - 8
Babylon/Cameras/babylon.arcRotateCamera.js

@@ -247,10 +247,9 @@ var BABYLON;
             element.addEventListener('mousewheel', this._wheel, false);
             element.addEventListener('mousewheel', this._wheel, false);
             element.addEventListener('DOMMouseScroll', this._wheel, false);
             element.addEventListener('DOMMouseScroll', this._wheel, false);
 
 
-            var root = window.parent || window;
-            root.addEventListener("keydown", this._onKeyDown, false);
-            root.addEventListener("keyup", this._onKeyUp, false);
-            root.addEventListener("blur", this._onLostFocus, false);
+            window.addEventListener("keydown", this._onKeyDown, false);
+            window.addEventListener("keyup", this._onKeyUp, false);
+            window.addEventListener("blur", this._onLostFocus, false);
         };
         };
 
 
         ArcRotateCamera.prototype.detachControl = function (element) {
         ArcRotateCamera.prototype.detachControl = function (element) {
@@ -268,10 +267,9 @@ var BABYLON;
             element.removeEventListener('mousewheel', this._wheel);
             element.removeEventListener('mousewheel', this._wheel);
             element.removeEventListener('DOMMouseScroll', this._wheel);
             element.removeEventListener('DOMMouseScroll', this._wheel);
 
 
-            var root = window.parent || window;
-            root.removeEventListener("keydown", this._onKeyDown);
-            root.removeEventListener("keyup", this._onKeyUp);
-            root.removeEventListener("blur", this._onLostFocus);
+            window.removeEventListener("keydown", this._onKeyDown);
+            window.removeEventListener("keyup", this._onKeyUp);
+            window.removeEventListener("blur", this._onLostFocus);
 
 
             this._MSGestureHandler = null;
             this._MSGestureHandler = null;
             this._attachedElement = null;
             this._attachedElement = null;

+ 6 - 8
Babylon/Cameras/babylon.arcRotateCamera.ts

@@ -263,10 +263,9 @@
             element.addEventListener('mousewheel', this._wheel, false);
             element.addEventListener('mousewheel', this._wheel, false);
             element.addEventListener('DOMMouseScroll', this._wheel, false);
             element.addEventListener('DOMMouseScroll', this._wheel, false);
 
 
-            var root = window.parent || window;
-            root.addEventListener("keydown", this._onKeyDown, false);
-            root.addEventListener("keyup", this._onKeyUp, false);
-            root.addEventListener("blur", this._onLostFocus, false);
+            window.addEventListener("keydown", this._onKeyDown, false);
+            window.addEventListener("keyup", this._onKeyUp, false);
+            window.addEventListener("blur", this._onLostFocus, false);
         }
         }
 
 
         public detachControl(element: HTMLElement): void {
         public detachControl(element: HTMLElement): void {
@@ -284,10 +283,9 @@
             element.removeEventListener('mousewheel', this._wheel);
             element.removeEventListener('mousewheel', this._wheel);
             element.removeEventListener('DOMMouseScroll', this._wheel);
             element.removeEventListener('DOMMouseScroll', this._wheel);
 
 
-            var root = window.parent || window;
-            root.removeEventListener("keydown", this._onKeyDown);
-            root.removeEventListener("keyup", this._onKeyUp);
-            root.removeEventListener("blur", this._onLostFocus);
+            window.removeEventListener("keydown", this._onKeyDown);
+            window.removeEventListener("keyup", this._onKeyUp);
+            window.removeEventListener("blur", this._onLostFocus);
 
 
             this._MSGestureHandler = null;
             this._MSGestureHandler = null;
             this._attachedElement = null;
             this._attachedElement = null;

+ 6 - 8
Babylon/Cameras/babylon.freeCamera.js

@@ -236,10 +236,9 @@ var BABYLON;
             element.addEventListener("mouseout", this._onMouseOut, false);
             element.addEventListener("mouseout", this._onMouseOut, false);
             element.addEventListener("mousemove", this._onMouseMove, false);
             element.addEventListener("mousemove", this._onMouseMove, false);
 
 
-            var root = window.parent || window;
-            root.addEventListener("keydown", this._onKeyDown, false);
-            root.addEventListener("keyup", this._onKeyUp, false);
-            root.addEventListener("blur", this._onLostFocus, false);
+            window.addEventListener("keydown", this._onKeyDown, false);
+            window.addEventListener("keyup", this._onKeyUp, false);
+            window.addEventListener("blur", this._onLostFocus, false);
         };
         };
 
 
         FreeCamera.prototype.detachControl = function (element) {
         FreeCamera.prototype.detachControl = function (element) {
@@ -252,10 +251,9 @@ var BABYLON;
             element.removeEventListener("mouseout", this._onMouseOut);
             element.removeEventListener("mouseout", this._onMouseOut);
             element.removeEventListener("mousemove", this._onMouseMove);
             element.removeEventListener("mousemove", this._onMouseMove);
 
 
-            var root = window.parent || window;
-            root.removeEventListener("keydown", this._onKeyDown);
-            root.removeEventListener("keyup", this._onKeyUp);
-            root.removeEventListener("blur", this._onLostFocus);
+            window.removeEventListener("keydown", this._onKeyDown);
+            window.removeEventListener("keyup", this._onKeyUp);
+            window.removeEventListener("blur", this._onLostFocus);
 
 
             this._attachedElement = null;
             this._attachedElement = null;
             if (this._reset) {
             if (this._reset) {

+ 6 - 8
Babylon/Cameras/babylon.freeCamera.ts

@@ -251,10 +251,9 @@
             element.addEventListener("mouseout", this._onMouseOut, false);
             element.addEventListener("mouseout", this._onMouseOut, false);
             element.addEventListener("mousemove", this._onMouseMove, false);
             element.addEventListener("mousemove", this._onMouseMove, false);
 
 
-            var root = window.parent || window;
-            root.addEventListener("keydown", this._onKeyDown, false);
-            root.addEventListener("keyup", this._onKeyUp, false);
-            root.addEventListener("blur", this._onLostFocus, false);
+            window.addEventListener("keydown", this._onKeyDown, false);
+            window.addEventListener("keyup", this._onKeyUp, false);
+            window.addEventListener("blur", this._onLostFocus, false);
         }
         }
 
 
         public detachControl(element: HTMLElement): void {
         public detachControl(element: HTMLElement): void {
@@ -267,10 +266,9 @@
             element.removeEventListener("mouseout", this._onMouseOut);
             element.removeEventListener("mouseout", this._onMouseOut);
             element.removeEventListener("mousemove", this._onMouseMove);
             element.removeEventListener("mousemove", this._onMouseMove);
 
 
-            var root = window.parent || window;
-            root.removeEventListener("keydown", this._onKeyDown);
-            root.removeEventListener("keyup", this._onKeyUp);
-            root.removeEventListener("blur", this._onLostFocus);
+            window.removeEventListener("keydown", this._onKeyDown);
+            window.removeEventListener("keyup", this._onKeyUp);
+            window.removeEventListener("blur", this._onLostFocus);
 
 
             this._attachedElement = null;
             this._attachedElement = null;
             if (this._reset) {
             if (this._reset) {

+ 2 - 4
Babylon/Cameras/babylon.touchCamera.js

@@ -99,8 +99,7 @@ var BABYLON = BABYLON || {};
         canvas.addEventListener("pointerout", this._onPointerUp);
         canvas.addEventListener("pointerout", this._onPointerUp);
         canvas.addEventListener("pointermove", this._onPointerMove);
         canvas.addEventListener("pointermove", this._onPointerMove);
 
 
-        var root = window.parent || window;
-        root.addEventListener("blur", this._onLostFocus);
+        window.addEventListener("blur", this._onLostFocus);
     };
     };
 
 
     BABYLON.TouchCamera.prototype.detachControl = function (canvas) {
     BABYLON.TouchCamera.prototype.detachControl = function (canvas) {
@@ -113,8 +112,7 @@ var BABYLON = BABYLON || {};
         canvas.removeEventListener("pointerout", this._onPointerUp);
         canvas.removeEventListener("pointerout", this._onPointerUp);
         canvas.removeEventListener("pointermove", this._onPointerMove);
         canvas.removeEventListener("pointermove", this._onPointerMove);
 
 
-        var root = window.parent || window;
-        root.removeEventListener("blur", this._onLostFocus);
+        window.removeEventListener("blur", this._onLostFocus);
         
         
         this._attachedCanvas = null;
         this._attachedCanvas = null;
     };
     };

+ 2 - 0
Babylon/babylon.engine.js

@@ -1129,6 +1129,8 @@
 
 
         // Dispose
         // Dispose
         Engine.prototype.dispose = function () {
         Engine.prototype.dispose = function () {
+            this.stopRenderLoop();
+
             while (this.scenes.length) {
             while (this.scenes.length) {
                 this.scenes[0].dispose();
                 this.scenes[0].dispose();
             }
             }

+ 2 - 0
Babylon/babylon.engine.ts

@@ -1184,6 +1184,8 @@
 
 
         // Dispose
         // Dispose
         public dispose(): void {
         public dispose(): void {
+            this.stopRenderLoop();
+
             // Release scenes
             // Release scenes
             while (this.scenes.length) {
             while (this.scenes.length) {
                 this.scenes[0].dispose();
                 this.scenes[0].dispose();

ファイルの差分が大きいため隠しています
+ 1 - 1
babylon.1.12-beta.js