瀏覽代碼

Updating the gamepad to add more control checking for some specific joystick following bug: https://github.com/BabylonJS/Babylon.js/issues/2008

davrous 8 年之前
父節點
當前提交
0310227f21

File diff suppressed because it is too large
+ 2512 - 2512
dist/preview release/babylon.d.ts


File diff suppressed because it is too large
+ 1 - 1
dist/preview release/babylon.js


+ 21 - 14
dist/preview release/babylon.max.js

@@ -45315,10 +45315,15 @@ var BABYLON;
                 LSValues.x = Math.abs(normalizedLX) > 0.005 ? 0 + normalizedLX : 0;
                 LSValues.y = Math.abs(normalizedLY) > 0.005 ? 0 + normalizedLY : 0;
                 var RSValues = this.gamepad.rightStick;
-                var normalizedRX = RSValues.x / this.gamepadAngularSensibility;
-                var normalizedRY = RSValues.y / this.gamepadAngularSensibility;
-                RSValues.x = Math.abs(normalizedRX) > 0.001 ? 0 + normalizedRX : 0;
-                RSValues.y = Math.abs(normalizedRY) > 0.001 ? 0 + normalizedRY : 0;
+                if (RSValues) {
+                    var normalizedRX = RSValues.x / this.gamepadAngularSensibility;
+                    var normalizedRY = RSValues.y / this.gamepadAngularSensibility;
+                    RSValues.x = Math.abs(normalizedRX) > 0.001 ? 0 + normalizedRX : 0;
+                    RSValues.y = Math.abs(normalizedRY) > 0.001 ? 0 + normalizedRY : 0;
+                }
+                else {
+                    RSValues = { x: 0, y: 0 };
+                }
                 if (!camera.rotationQuaternion) {
                     BABYLON.Matrix.RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, this._cameraTransform);
                 }
@@ -45384,20 +45389,22 @@ var BABYLON;
             if (this.gamepad) {
                 var camera = this.camera;
                 var RSValues = this.gamepad.rightStick;
-                if (RSValues.x != 0) {
-                    var normalizedRX = RSValues.x / this.gamepadRotationSensibility;
-                    if (normalizedRX != 0 && Math.abs(normalizedRX) > 0.005) {
-                        camera.inertialAlphaOffset += normalizedRX;
+                if (RSValues) {
+                    if (RSValues.x != 0) {
+                        var normalizedRX = RSValues.x / this.gamepadRotationSensibility;
+                        if (normalizedRX != 0 && Math.abs(normalizedRX) > 0.005) {
+                            camera.inertialAlphaOffset += normalizedRX;
+                        }
                     }
-                }
-                if (RSValues.y != 0) {
-                    var normalizedRY = RSValues.y / this.gamepadRotationSensibility;
-                    if (normalizedRY != 0 && Math.abs(normalizedRY) > 0.005) {
-                        camera.inertialBetaOffset += normalizedRY;
+                    if (RSValues.y != 0) {
+                        var normalizedRY = RSValues.y / this.gamepadRotationSensibility;
+                        if (normalizedRY != 0 && Math.abs(normalizedRY) > 0.005) {
+                            camera.inertialBetaOffset += normalizedRY;
+                        }
                     }
                 }
                 var LSValues = this.gamepad.leftStick;
-                if (LSValues.y != 0) {
+                if (LSValues && LSValues.y != 0) {
                     var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
                     if (normalizedLY != 0 && Math.abs(normalizedLY) > 0.005) {
                         this.camera.inertialRadiusOffset -= normalizedLY;

File diff suppressed because it is too large
+ 2512 - 2512
dist/preview release/babylon.module.d.ts


File diff suppressed because it is too large
+ 1 - 1
dist/preview release/babylon.worker.js


+ 12 - 10
src/Cameras/Inputs/babylon.arcRotateCameraGamepadInput.ts

@@ -27,22 +27,24 @@ module BABYLON {
                 var camera = this.camera;
                 var RSValues = this.gamepad.rightStick;
 
-                if (RSValues.x != 0) {
-                    var normalizedRX = RSValues.x / this.gamepadRotationSensibility;
-                    if (normalizedRX != 0 && Math.abs(normalizedRX) > 0.005) {
-                        camera.inertialAlphaOffset += normalizedRX;
+                if (RSValues) {
+                    if (RSValues.x != 0) {
+                        var normalizedRX = RSValues.x / this.gamepadRotationSensibility;
+                        if (normalizedRX != 0 && Math.abs(normalizedRX) > 0.005) {
+                            camera.inertialAlphaOffset += normalizedRX;
+                        }
                     }
-                }
 
-                if (RSValues.y != 0) {
-                    var normalizedRY = RSValues.y / this.gamepadRotationSensibility;
-                    if (normalizedRY != 0 && Math.abs(normalizedRY) > 0.005) {
-                        camera.inertialBetaOffset += normalizedRY;
+                    if (RSValues.y != 0) {
+                        var normalizedRY = RSValues.y / this.gamepadRotationSensibility;
+                        if (normalizedRY != 0 && Math.abs(normalizedRY) > 0.005) {
+                            camera.inertialBetaOffset += normalizedRY;
+                        }
                     }
                 }
 
                 var LSValues = this.gamepad.leftStick;
-                if (LSValues.y != 0) {
+                if (LSValues && LSValues.y != 0) {
                     var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
                     if (normalizedLY != 0 && Math.abs(normalizedLY) > 0.005) {
                         this.camera.inertialRadiusOffset -= normalizedLY;

+ 9 - 4
src/Cameras/Inputs/babylon.freeCameraGamepadInput.ts

@@ -38,10 +38,15 @@ module BABYLON {
                 LSValues.y = Math.abs(normalizedLY) > 0.005 ? 0 + normalizedLY : 0;
 
                 var RSValues = this.gamepad.rightStick;
-                var normalizedRX = RSValues.x / this.gamepadAngularSensibility;
-                var normalizedRY = RSValues.y / this.gamepadAngularSensibility;
-                RSValues.x = Math.abs(normalizedRX) > 0.001 ? 0 + normalizedRX : 0;
-                RSValues.y = Math.abs(normalizedRY) > 0.001 ? 0 + normalizedRY : 0;
+                if (RSValues) {
+                    var normalizedRX = RSValues.x / this.gamepadAngularSensibility;
+                    var normalizedRY = RSValues.y / this.gamepadAngularSensibility;
+                    RSValues.x = Math.abs(normalizedRX) > 0.001 ? 0 + normalizedRX : 0;
+                    RSValues.y = Math.abs(normalizedRY) > 0.001 ? 0 + normalizedRY : 0;
+                }
+                else {
+                    RSValues = {x:0, y:0};
+                }
 
                 if (!camera.rotationQuaternion) {
                     Matrix.RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, this._cameraTransform);