Переглянути джерело

handle vr controller not marked left or right

Trevor Baron 7 роки тому
батько
коміт
ac4367c04b
1 змінених файлів з 6 додано та 0 видалено
  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() {