From 8cbe63f2960d83eef20e6519f44d84f48b00de93 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Tue, 18 Jul 2017 22:45:54 +0100 Subject: [PATCH 1/2] removed search laser in edit mode for 2d mode --- scripts/system/controllers/handControllerGrab.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index 78c4b2960e..fe4904c599 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -1801,7 +1801,7 @@ function MyController(hand) { this.processStylus(); - if (isInEditMode() && !this.isNearStylusTarget && HMD.isHandControllerAvailable()) { + if (isInEditMode() && !this.isNearStylusTarget && HMD.isHandControllerAvailable() && HMD.active) { // Always showing lasers while in edit mode and hands/stylus is not active. var rayPickInfo = this.calcRayPickInfo(this.hand); this.intersectionDistance = (rayPickInfo.entityID || rayPickInfo.overlayID) ? rayPickInfo.distance : 0; From b3ec306063469eea47ee1efbbac3fab5140df74e Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Tue, 18 Jul 2017 23:48:21 +0100 Subject: [PATCH 2/2] better version --- scripts/system/controllers/handControllerGrab.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index fe4904c599..e2de13d4b1 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -1801,11 +1801,16 @@ function MyController(hand) { this.processStylus(); - if (isInEditMode() && !this.isNearStylusTarget && HMD.isHandControllerAvailable() && HMD.active) { + if (isInEditMode() && !this.isNearStylusTarget && HMD.isHandControllerAvailable()) { // Always showing lasers while in edit mode and hands/stylus is not active. + var rayPickInfo = this.calcRayPickInfo(this.hand); - this.intersectionDistance = (rayPickInfo.entityID || rayPickInfo.overlayID) ? rayPickInfo.distance : 0; - this.searchIndicatorOn(rayPickInfo.searchRay); + if (rayPickInfo.isValid) { + this.intersectionDistance = (rayPickInfo.entityID || rayPickInfo.overlayID) ? rayPickInfo.distance : 0; + this.searchIndicatorOn(rayPickInfo.searchRay); + } else { + this.searchIndicatorOff(); + } } else { this.searchIndicatorOff(); } @@ -1854,12 +1859,14 @@ function MyController(hand) { this.calcRayPickInfo = function(hand, pickRayOverride) { var pickRay; + var valid = true if (pickRayOverride) { pickRay = pickRayOverride; } else { var controllerLocation = getControllerWorldLocation(this.handToController(), true); var worldHandPosition = controllerLocation.position; var worldHandRotation = controllerLocation.orientation; + valid = !(worldHandPosition === undefined); pickRay = { origin: PICK_WITH_HAND_RAY ? worldHandPosition : Camera.position, @@ -1874,7 +1881,8 @@ function MyController(hand) { entityID: null, overlayID: null, searchRay: pickRay, - distance: PICK_MAX_DISTANCE + distance: PICK_MAX_DISTANCE, + isValid: valid }; var now = Date.now();