Browse Source

Add: Ray length as a Web VR option (default is 100)
Update: Mesh predicate for scene.pickWithRay(). _meshSelectionPredicate would ideally call a user configurable predicate (like public meshSelectionPredicate). Needs to be a way to pickWithRay beyond hidden/non-pickable meshes.

Brian Zinn 7 years ago
parent
commit
23a8cdace1

+ 9 - 4
src/Cameras/VR/babylon.vrExperienceHelper.ts

@@ -35,6 +35,7 @@ module BABYLON {
         public onExitingVR: () => void;
         public onControllerMeshLoaded: (controller: WebVRController) => void;
 
+        private _rayLength: number;
         private _useCustomVRButton: boolean = false;
         private _teleportationRequested: boolean = false;
         private _teleportationEnabledOnLeftController: boolean = false;
@@ -117,6 +118,10 @@ module BABYLON {
                         this._btnVR = webVROptions.customVRButton;
                     }
                 }
+
+                if (webVROptions.rayLength) {
+                    this._rayLength = webVROptions.rayLength
+                }
             }
 
             if (!this._useCustomVRButton) {
@@ -414,7 +419,7 @@ module BABYLON {
                         && mesh.name.indexOf("teleportationCircle") === -1
                         && mesh.name.indexOf("torusTeleportation") === -1
                         && mesh.name.indexOf("laserPointer") === -1)) {
-                    return true;
+                    return (mesh.isEnabled() && mesh.isVisible && mesh.isPickable);
                 }
                 return false;
             }
@@ -906,14 +911,14 @@ module BABYLON {
                 (this._leftLaserPointer && !this._leftLaserPointer.isVisible && !this._rightLaserPointer) || 
                 (this._rightLaserPointer && !this._rightLaserPointer.isVisible && !this._leftLaserPointer) || 
                 (this._rightLaserPointer && this._leftLaserPointer && !this._rightLaserPointer.isVisible && !this._leftLaserPointer.isVisible)) {
-                    ray = this.currentVRCamera.getForwardRay();
+                    ray = this.currentVRCamera.getForwardRay(this._rayLength);
                 
             } else {
                 if (this._leftLaserPointer && this._leftLaserPointer.isVisible) {
-                    ray = (<any>this.currentVRCamera).leftController.getForwardRay();
+                    ray = (<any>this.currentVRCamera).leftController.getForwardRay(this._rayLength);
                 }
                 else {
-                    ray = (<any>this.currentVRCamera).rightController.getForwardRay();
+                    ray = (<any>this.currentVRCamera).rightController.getForwardRay(this._rayLength);
                 }
             }
         

+ 1 - 0
src/Cameras/VR/babylon.webVRCamera.ts

@@ -37,6 +37,7 @@ module BABYLON {
         defaultLightingOnControllers?: boolean; // creating a default HemiLight only on controllers
         useCustomVRButton?: boolean; // if you don't want to use the default VR button of the helper
         customVRButton?: HTMLButtonElement; //if you'd like to provide your own button to the VRHelper
+        rayLength?: number; // to change the length of the ray for gaze/controllers.
     }
 
     export class WebVRFreeCamera extends FreeCamera implements PoseControlled {