소스 검색

Adding code control for Vive weird behavior around .hand property filling

davrous 8 년 전
부모
커밋
0da467fc1b

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 826 - 826
dist/preview release/babylon.d.ts


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 29 - 29
dist/preview release/babylon.js


+ 15 - 0
dist/preview release/babylon.max.js

@@ -62712,6 +62712,21 @@ var BABYLON;
                         _this.controllers.push(webVrController);
                         //did we find enough controllers? Great! let the developer know.
                         if (_this._onControllersAttached && _this.controllers.length >= 2) {
+                            // Forced to add some control code for Vive as it doesn't always fill properly the "hand" property
+                            // Sometimes, both controllers are set correctly (left and right), sometimes none, sometimes only one of them...
+                            // So we're overriding setting left & right manually to be sure
+                            var firstViveWandDetected = false;
+                            for (var i = 0; i < _this.controllers.length; i++) {
+                                if (_this.controllers[i].controllerType === BABYLON.PoseEnabledControllerType.VIVE) {
+                                    if (!firstViveWandDetected) {
+                                        firstViveWandDetected = true;
+                                        _this.controllers[i].hand = "left";
+                                    }
+                                    else {
+                                        _this.controllers[i].hand = "right";
+                                    }
+                                }
+                            }
                             _this._onControllersAttached(_this.controllers);
                         }
                     }

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 826 - 826
dist/preview release/babylon.module.d.ts


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 30 - 30
dist/preview release/babylon.worker.js


+ 17 - 3
src/Cameras/VR/babylon.webVRCamera.ts

@@ -3,7 +3,6 @@ declare var VRDisplay;
 declare var VRFrameData;
 
 module BABYLON {
-
     /**
      * This is a copy of VRPose.
      * IMPORTANT!! The data is right-hand data.
@@ -247,7 +246,6 @@ module BABYLON {
             }
         }
 
-
         /**
          * WebVR's attach control will start broadcasting frames to the device.
          * Note that in certain browsers (chrome for example) this function must be called
@@ -347,7 +345,6 @@ module BABYLON {
                 this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
             }
 
-
             let parentCamera: WebVRFreeCamera = this._cameraRigParams["parentCamera"];
 
             // should the view matrix be updated with scale and position offset?
@@ -412,6 +409,23 @@ module BABYLON {
 
                         //did we find enough controllers? Great! let the developer know.
                         if (this._onControllersAttached && this.controllers.length >= 2) {
+                            // Forced to add some control code for Vive as it doesn't always fill properly the "hand" property
+                            // Sometimes, both controllers are set correctly (left and right), sometimes none, sometimes only one of them...
+                            // So we're overriding setting left & right manually to be sure
+                            let firstViveWandDetected = false;
+
+                            for (let i=0; i<this.controllers.length; i++) {
+                                if (this.controllers[i].controllerType === PoseEnabledControllerType.VIVE) {
+                                    if (!firstViveWandDetected) {
+                                        firstViveWandDetected = true;
+                                        this.controllers[i].hand = "left";
+                                    }
+                                    else {
+                                        this.controllers[i].hand = "right";
+                                    }
+                                }
+                            }
+
                             this._onControllersAttached(this.controllers);
                         }
                     }