Browse Source

Fixed issue with detachElement

David Catuhe 9 năm trước cách đây
mục cha
commit
a3faaf26d3

+ 3 - 1
src/Cameras/Inputs/babylon.freecamera.input.gamepad.js

@@ -16,7 +16,9 @@ var BABYLON;
             this._gamepads = new BABYLON.Gamepads(function (gamepad) { _this._onNewGameConnected(gamepad); });
         };
         FreeCameraGamepadInput.prototype.detachControl = function (element) {
-            this._gamepads.dispose();
+            if (this._gamepads) {
+                this._gamepads.dispose();
+            }
             this.gamepad = null;
         };
         FreeCameraGamepadInput.prototype.checkInputs = function () {

+ 3 - 1
src/Cameras/babylon.cameraInputsManager.js

@@ -72,7 +72,9 @@ var BABYLON;
             }
         };
         CameraInputsManager.prototype.clear = function () {
-            this.detachElement(this.attachedElement);
+            if (this.attachedElement) {
+                this.detachElement(this.attachedElement);
+            }
             this.attached = {};
             this.attachedElement = null;
             this.checkInputs = function () { };

+ 3 - 1
src/Cameras/babylon.cameraInputsManager.ts

@@ -104,7 +104,9 @@ module BABYLON {
         }
 
         public clear() {
-            this.detachElement(this.attachedElement);
+            if (this.attachedElement) {
+                this.detachElement(this.attachedElement);
+            }
             this.attached = {};
             this.attachedElement = null;
             this.checkInputs = () => { };