disable far-trigger and grab if using hand tracker

This commit is contained in:
Seth Alves 2019-10-01 14:52:33 -07:00
parent 1c926db2db
commit fa4d055ab1
5 changed files with 22 additions and 13 deletions

View file

@ -14,7 +14,7 @@
TRIGGER_OFF_VALUE, TRIGGER_ON_VALUE, ZERO_VEC, ensureDynamic, TRIGGER_OFF_VALUE, TRIGGER_ON_VALUE, ZERO_VEC, ensureDynamic,
getControllerWorldLocation, projectOntoEntityXYPlane, ContextOverlay, HMD, getControllerWorldLocation, projectOntoEntityXYPlane, ContextOverlay, HMD,
Picks, makeLaserLockInfo, makeLaserParams, AddressManager, getEntityParents, Selection, DISPATCHER_HOVERING_LIST, Picks, makeLaserLockInfo, makeLaserParams, AddressManager, getEntityParents, Selection, DISPATCHER_HOVERING_LIST,
worldPositionToRegistrationFrameMatrix, DISPATCHER_PROPERTIES, Uuid, Picks worldPositionToRegistrationFrameMatrix, DISPATCHER_PROPERTIES, Uuid, Picks, handsAreTracked, Messages
*/ */
Script.include("/~/system/libraries/controllerDispatcherUtils.js"); Script.include("/~/system/libraries/controllerDispatcherUtils.js");
@ -374,6 +374,9 @@ Script.include("/~/system/libraries/controllers.js");
this.isReady = function (controllerData) { this.isReady = function (controllerData) {
if (HMD.active) { if (HMD.active) {
if (handsAreTracked()) {
return makeRunningValues(false, [], []);
}
if (this.notPointingAtEntity(controllerData)) { if (this.notPointingAtEntity(controllerData)) {
return makeRunningValues(false, [], []); return makeRunningValues(false, [], []);
} }

View file

@ -12,7 +12,7 @@
HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, TRIGGER_OFF_VALUE, TRIGGER_ON_VALUE, ZERO_VEC, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, TRIGGER_OFF_VALUE, TRIGGER_ON_VALUE, ZERO_VEC,
projectOntoEntityXYPlane, ContextOverlay, HMD, Picks, makeLaserLockInfo, makeLaserParams, AddressManager, projectOntoEntityXYPlane, ContextOverlay, HMD, Picks, makeLaserLockInfo, makeLaserParams, AddressManager,
getEntityParents, Selection, DISPATCHER_HOVERING_LIST, unhighlightTargetEntity, Messages, findGrabbableGroupParent, getEntityParents, Selection, DISPATCHER_HOVERING_LIST, unhighlightTargetEntity, Messages, findGrabbableGroupParent,
worldPositionToRegistrationFrameMatrix, DISPATCHER_PROPERTIES worldPositionToRegistrationFrameMatrix, DISPATCHER_PROPERTIES, handsAreTracked
*/ */
Script.include("/~/system/libraries/controllerDispatcherUtils.js"); Script.include("/~/system/libraries/controllerDispatcherUtils.js");
@ -63,7 +63,6 @@ Script.include("/~/system/libraries/controllers.js");
this.endedGrab = 0; this.endedGrab = 0;
this.MIN_HAPTIC_PULSE_INTERVAL = 500; // ms this.MIN_HAPTIC_PULSE_INTERVAL = 500; // ms
this.disabled = false; this.disabled = false;
var _this = this;
this.initialControllerRotation = Quat.IDENTITY; this.initialControllerRotation = Quat.IDENTITY;
this.currentControllerRotation = Quat.IDENTITY; this.currentControllerRotation = Quat.IDENTITY;
this.manipulating = false; this.manipulating = false;
@ -99,7 +98,7 @@ Script.include("/~/system/libraries/controllers.js");
this.getOffhand = function () { this.getOffhand = function () {
return (this.hand === RIGHT_HAND ? LEFT_HAND : RIGHT_HAND); return (this.hand === RIGHT_HAND ? LEFT_HAND : RIGHT_HAND);
} };
// Activation criteria for rotating a fargrabbed entity. If we're changing the mapping, this is where to do it. // Activation criteria for rotating a fargrabbed entity. If we're changing the mapping, this is where to do it.
this.shouldManipulateTarget = function (controllerData) { this.shouldManipulateTarget = function (controllerData) {
@ -406,6 +405,9 @@ Script.include("/~/system/libraries/controllers.js");
this.isReady = function (controllerData) { this.isReady = function (controllerData) {
if (HMD.active) { if (HMD.active) {
if (handsAreTracked()) {
return makeRunningValues(false, [], []);
}
if (this.notPointingAtEntity(controllerData)) { if (this.notPointingAtEntity(controllerData)) {
return makeRunningValues(false, [], []); return makeRunningValues(false, [], []);
} }

View file

@ -8,7 +8,7 @@
/* global Script, RIGHT_HAND, LEFT_HAND, MyAvatar, /* global Script, RIGHT_HAND, LEFT_HAND, MyAvatar,
makeRunningValues, Entities, enableDispatcherModule, disableDispatcherModule, makeDispatcherModuleParameters, makeRunningValues, Entities, enableDispatcherModule, disableDispatcherModule, makeDispatcherModuleParameters,
getGrabbableData, makeLaserParams, DISPATCHER_PROPERTIES getGrabbableData, makeLaserParams, DISPATCHER_PROPERTIES, RayPick, handsAreTracked
*/ */
Script.include("/~/system/libraries/controllerDispatcherUtils.js"); Script.include("/~/system/libraries/controllerDispatcherUtils.js");
@ -63,6 +63,9 @@ Script.include("/~/system/libraries/controllers.js");
this.isReady = function (controllerData) { this.isReady = function (controllerData) {
this.targetEntityID = null; this.targetEntityID = null;
if (handsAreTracked()) {
return makeRunningValues(false, [], []);
}
if (controllerData.triggerClicks[this.hand] === 0) { if (controllerData.triggerClicks[this.hand] === 0) {
return makeRunningValues(false, [], []); return makeRunningValues(false, [], []);
} }

View file

@ -63,7 +63,8 @@
clearHighlightedEntities:true, clearHighlightedEntities:true,
unhighlightTargetEntity:true, unhighlightTargetEntity:true,
distanceBetweenEntityLocalPositionAndBoundingBox: true, distanceBetweenEntityLocalPositionAndBoundingBox: true,
worldPositionToRegistrationFrameMatrix: true worldPositionToRegistrationFrameMatrix: true,
handsAreTracked: true
*/ */
MSECS_PER_SEC = 1000.0; MSECS_PER_SEC = 1000.0;
@ -600,6 +601,10 @@ worldPositionToRegistrationFrameMatrix = function(wptrProps, pos) {
return offsetMat; return offsetMat;
}; };
handsAreTracked = function () {
return Controller.getPoseValue(Controller.Standard.LeftHandIndex3).valid ||
Controller.getPoseValue(Controller.Standard.RightHandIndex3).valid;
}
if (typeof module !== 'undefined') { if (typeof module !== 'undefined') {
module.exports = { module.exports = {
@ -624,6 +629,7 @@ if (typeof module !== 'undefined') {
TRIGGER_OFF_VALUE: TRIGGER_OFF_VALUE, TRIGGER_OFF_VALUE: TRIGGER_OFF_VALUE,
TRIGGER_ON_VALUE: TRIGGER_ON_VALUE, TRIGGER_ON_VALUE: TRIGGER_ON_VALUE,
DISPATCHER_HOVERING_LIST: DISPATCHER_HOVERING_LIST, DISPATCHER_HOVERING_LIST: DISPATCHER_HOVERING_LIST,
worldPositionToRegistrationFrameMatrix: worldPositionToRegistrationFrameMatrix worldPositionToRegistrationFrameMatrix: worldPositionToRegistrationFrameMatrix,
handsAreTracked: handsAreTracked
}; };
} }

View file

@ -8,7 +8,7 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
/* global getTabletWidthFromSettings, TRIGGER_OFF_VALUE, Controller, Script, Camera, Tablet, MyAvatar, /* global getTabletWidthFromSettings, handsAreTracked, TRIGGER_OFF_VALUE, Controller, Script, Camera, Tablet, MyAvatar,
Quat, SoundCache, HMD, Overlays, Vec3, Uuid, Messages */ Quat, SoundCache, HMD, Overlays, Vec3, Uuid, Messages */
(function () { (function () {
@ -81,11 +81,6 @@
return hand === LEFT_HAND ? RIGHT_HAND : LEFT_HAND; return hand === LEFT_HAND ? RIGHT_HAND : LEFT_HAND;
} }
function handsAreTracked() {
return Controller.getPoseValue(Controller.Standard.LeftHandIndex3).valid ||
Controller.getPoseValue(Controller.Standard.RightHandIndex3).valid;
}
UI = function () { UI = function () {
if (!(this instanceof UI)) { if (!(this instanceof UI)) {