only handle trigger events when overlays are shown

This commit is contained in:
Stephen Birarda 2016-07-13 16:21:12 -07:00
parent 61975fe33a
commit 946c7d4644

View file

@ -168,28 +168,30 @@ function controllerComputePickRay() {
MyAvatar.position); MyAvatar.position);
// This gets point direction right, but if you want general quaternion it would be more complicated: // This gets point direction right, but if you want general quaternion it would be more complicated:
var controllerDirection = Quat.getUp(Quat.multiply(MyAvatar.orientation, controllerPose.rotation)); var controllerDirection = Quat.getUp(Quat.multiply(MyAvatar.orientation, controllerPose.rotation));
return {origin: controllerPosition, direction: controllerDirection}; return { origin: controllerPosition, direction: controllerDirection };
} }
} }
function makeTriggerHandler(hand) { function makeTriggerHandler(hand) {
return function (value) { return function (value) {
if (!triggered && (value > TRIGGER_GRAB_VALUE)) { // should we smooth? if (isShowingOverlays) {
triggered = true; if (!triggered && (value > TRIGGER_GRAB_VALUE)) { // should we smooth?
if (activeHand !== hand) { triggered = true;
// No switching while the other is already triggered, so no need to release. if (activeHand !== hand) {
activeHand = (activeHand === Controller.Standard.RightHand) ? Controller.Standard.LeftHand : Controller.Standard.RightHand; // No switching while the other is already triggered, so no need to release.
} activeHand = (activeHand === Controller.Standard.RightHand) ? Controller.Standard.LeftHand : Controller.Standard.RightHand;
var pickRay = controllerComputePickRay();
if (pickRay) {
var overlayIntersection = Overlays.findRayIntersection(pickRay);
if (overlayIntersection.intersects) {
handleSelectedOverlay(overlayIntersection);
} }
var pickRay = controllerComputePickRay();
if (pickRay) {
var overlayIntersection = Overlays.findRayIntersection(pickRay);
if (overlayIntersection.intersects) {
handleSelectedOverlay(overlayIntersection);
}
}
} else if (triggered && (value < TRIGGER_OFF_VALUE)) {
triggered = false;
} }
} else if (triggered && (value < TRIGGER_OFF_VALUE)) {
triggered = false;
} }
}; };
} }