Browse Source

invert vive controller y axis

Trevor Baron 7 years ago
parent
commit
99a0bbd605

+ 1 - 0
src/Gamepad/Controllers/babylon.viveController.ts

@@ -7,6 +7,7 @@ module BABYLON {
         constructor(vrGamepad: any) {
             super(vrGamepad);
             this.controllerType = PoseEnabledControllerType.VIVE;
+            this._invertLeftStickY = true;
         }
 
         public initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void) {

+ 5 - 0
src/Gamepad/babylon.gamepad.ts

@@ -33,6 +33,8 @@
         public static XBOX = 2;
         public static POSE_ENABLED = 3;
 
+        protected _invertLeftStickY:boolean = false;
+
         public get isConnected(): boolean {
             return this._isConnected;
         }
@@ -81,6 +83,9 @@
         public update() {
             if (this._leftStick) {
                 this.leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
+                if(this._invertLeftStickY){
+                    this.leftStick.y *= -1;
+                }
             }
             if (this._rightStick) {
                 this.rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };