From ace4546dec1a5fcbb064baefbd52d266febba836 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Mon, 4 Apr 2016 12:49:03 -0700 Subject: [PATCH] make handGrabController search ray follow controller rather than IK driven hand --- examples/controllers/handControllerGrab.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/examples/controllers/handControllerGrab.js b/examples/controllers/handControllerGrab.js index a3bed0a256..d8795341bb 100644 --- a/examples/controllers/handControllerGrab.js +++ b/examples/controllers/handControllerGrab.js @@ -495,7 +495,8 @@ function MyController(hand) { } }; - this.searchIndicatorOn = function(handPosition, distantPickRay) { + this.searchIndicatorOn = function(distantPickRay) { + var handPosition = distantPickRay.origin; var SEARCH_SPHERE_SIZE = 0.011; var SEARCH_SPHERE_FOLLOW_RATE = 0.50; @@ -857,7 +858,9 @@ function MyController(hand) { var controllerHandInput = (this.hand === RIGHT_HAND) ? Controller.Standard.RightHand : Controller.Standard.LeftHand; var currentHandRotation = Controller.getPoseValue(controllerHandInput).rotation; - var currentControllerPosition = Controller.getPoseValue(controllerHandInput).position; + var currentControllerPosition = Vec3.sum(Vec3.multiplyQbyV(MyAvatar.orientation, + Controller.getPoseValue(controllerHandInput).translation), + MyAvatar.position); var handDeltaRotation = Quat.multiply(currentHandRotation, Quat.inverse(this.startingHandRotation)); var avatarControllerPose = Controller.getPoseValue((this.hand === RIGHT_HAND) ? @@ -865,19 +868,13 @@ function MyController(hand) { var controllerRotation = Quat.multiply(MyAvatar.orientation, avatarControllerPose.rotation); var distantPickRay = { - origin: PICK_WITH_HAND_RAY ? handPosition : Camera.position, + origin: PICK_WITH_HAND_RAY ? currentControllerPosition : Camera.position, direction: PICK_WITH_HAND_RAY ? Quat.getUp(controllerRotation) : Vec3.mix(Quat.getUp(controllerRotation), Quat.getFront(Camera.orientation), HAND_HEAD_MIX_RATIO), length: PICK_MAX_DISTANCE }; - var searchVisualizationPickRay = { - origin: currentControllerPosition, - direction: Quat.getUp(this.getHandRotation()), - length: PICK_MAX_DISTANCE - }; - // Pick at some maximum rate, not always var pickRays = []; var now = Date.now(); @@ -1086,7 +1083,7 @@ function MyController(hand) { this.lineOn(distantPickRay.origin, Vec3.multiply(distantPickRay.direction, LINE_LENGTH), NO_INTERSECT_COLOR); } - this.searchIndicatorOn(handPosition, distantPickRay); + this.searchIndicatorOn(distantPickRay); Reticle.setVisible(false); }; @@ -1668,7 +1665,7 @@ function MyController(hand) { if (intersection.intersects) { this.intersectionDistance = Vec3.distance(pickRay.origin, intersection.intersection); } - this.searchIndicatorOn(handPosition, pickRay); + this.searchIndicatorOn(pickRay); } }