Bläddra i källkod

handle vr controller not marked left or right

Trevor Baron 7 år sedan
förälder
incheckning
ac4367c04b
1 ändrade filer med 6 tillägg och 0 borttagningar
  1. 6 0
      src/Gamepad/Controllers/babylon.webVRController.ts

+ 6 - 0
src/Gamepad/Controllers/babylon.webVRController.ts

@@ -13,6 +13,8 @@ module BABYLON {
 
         protected _buttons: Array<MutableGamepadButton>;
 
+        private static handCounter = 0;
+
         private _onButtonStateChange: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void;
 
         public onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void) {
@@ -31,6 +33,10 @@ module BABYLON {
             super(vrGamepad);
             this._buttons = new Array<ExtendedGamepadButton>(vrGamepad.buttons.length);
             this.hand = vrGamepad.hand;
+            if(!this.hand){
+                this.hand = (WebVRController.handCounter % 2 == 0) ? "left" : "right";
+                WebVRController.handCounter++;
+            }
         }
 
         public update() {