mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 07:17:43 +02:00
Merge pull request #7564 from sethalves/search-ray-follows-controller
make handGrabController search ray follow controller
This commit is contained in:
commit
f3d948e20f
1 changed files with 8 additions and 11 deletions
|
@ -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_SIZE = 0.011;
|
||||||
var SEARCH_SPHERE_FOLLOW_RATE = 0.50;
|
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 controllerHandInput = (this.hand === RIGHT_HAND) ? Controller.Standard.RightHand : Controller.Standard.LeftHand;
|
||||||
var currentHandRotation = Controller.getPoseValue(controllerHandInput).rotation;
|
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 handDeltaRotation = Quat.multiply(currentHandRotation, Quat.inverse(this.startingHandRotation));
|
||||||
|
|
||||||
var avatarControllerPose = Controller.getPoseValue((this.hand === RIGHT_HAND) ?
|
var avatarControllerPose = Controller.getPoseValue((this.hand === RIGHT_HAND) ?
|
||||||
|
@ -865,19 +868,13 @@ function MyController(hand) {
|
||||||
var controllerRotation = Quat.multiply(MyAvatar.orientation, avatarControllerPose.rotation);
|
var controllerRotation = Quat.multiply(MyAvatar.orientation, avatarControllerPose.rotation);
|
||||||
|
|
||||||
var distantPickRay = {
|
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),
|
direction: PICK_WITH_HAND_RAY ? Quat.getUp(controllerRotation) : Vec3.mix(Quat.getUp(controllerRotation),
|
||||||
Quat.getFront(Camera.orientation),
|
Quat.getFront(Camera.orientation),
|
||||||
HAND_HEAD_MIX_RATIO),
|
HAND_HEAD_MIX_RATIO),
|
||||||
length: PICK_MAX_DISTANCE
|
length: PICK_MAX_DISTANCE
|
||||||
};
|
};
|
||||||
|
|
||||||
var searchVisualizationPickRay = {
|
|
||||||
origin: currentControllerPosition,
|
|
||||||
direction: Quat.getUp(this.getHandRotation()),
|
|
||||||
length: PICK_MAX_DISTANCE
|
|
||||||
};
|
|
||||||
|
|
||||||
// Pick at some maximum rate, not always
|
// Pick at some maximum rate, not always
|
||||||
var pickRays = [];
|
var pickRays = [];
|
||||||
var now = Date.now();
|
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.lineOn(distantPickRay.origin, Vec3.multiply(distantPickRay.direction, LINE_LENGTH), NO_INTERSECT_COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.searchIndicatorOn(handPosition, distantPickRay);
|
this.searchIndicatorOn(distantPickRay);
|
||||||
Reticle.setVisible(false);
|
Reticle.setVisible(false);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -1668,7 +1665,7 @@ function MyController(hand) {
|
||||||
if (intersection.intersects) {
|
if (intersection.intersects) {
|
||||||
this.intersectionDistance = Vec3.distance(pickRay.origin, intersection.intersection);
|
this.intersectionDistance = Vec3.distance(pickRay.origin, intersection.intersection);
|
||||||
}
|
}
|
||||||
this.searchIndicatorOn(handPosition, pickRay);
|
this.searchIndicatorOn(pickRay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue