From 813c58a1fb23d90a35d82e680ac0dce558510cd9 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Tue, 17 Jul 2018 11:53:55 -0700 Subject: [PATCH 01/24] adding check to see if near grabbing is ready --- .../controllerModules/webSurfaceLaserInput.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js index a2fe0bfcd4..1706fadbb7 100644 --- a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js +++ b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js @@ -42,6 +42,16 @@ Script.include("/~/system/libraries/controllers.js"); return true; } } + nearGrabName = this.hand === RIGHT_HAND ? "RightNearParentingGrabEntity" : "LeftNearParentingGrabEntity"; + nearGrabModule = getEnabledModuleByName(nearGrabName); + if (nearGrabModule) { + return nearGrabModule.isReady(controllerData).active; + } + nearGrabName = this.hand === RIGHT_HAND ? "RightNearActionGrabEntity" : "LeftNearActionGrabEntity"; + nearGrabModule = getEnabledModuleByName(nearGrabName); + if (nearGrabModule) { + return nearGrabModule.isReady(controllerData).active; + } } return false; }; From eb7bde1bfca86eecf2ef8d291313f9dfe61c3603 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Tue, 17 Jul 2018 15:38:56 -0700 Subject: [PATCH 02/24] switching near grab priority to be before web surface laser --- .../highlightNearbyEntities.js | 2 +- .../controllerModules/inEditMode.js | 2 +- .../controllerModules/inVREditMode.js | 2 +- .../controllerModules/nearActionGrabEntity.js | 2 +- .../nearGrabHyperLinkEntity.js | 2 +- .../controllerModules/nearParentGrabEntity.js | 2 +- .../controllerModules/nearTrigger.js | 2 +- .../controllerModules/webSurfaceLaserInput.js | 32 +++++++++++++++++-- 8 files changed, 36 insertions(+), 10 deletions(-) diff --git a/scripts/system/controllers/controllerModules/highlightNearbyEntities.js b/scripts/system/controllers/controllerModules/highlightNearbyEntities.js index bc09ebee7a..3a33082f64 100644 --- a/scripts/system/controllers/controllerModules/highlightNearbyEntities.js +++ b/scripts/system/controllers/controllerModules/highlightNearbyEntities.js @@ -37,7 +37,7 @@ this.highlightedEntities = []; this.parameters = dispatcherUtils.makeDispatcherModuleParameters( - 480, + 120, this.hand === dispatcherUtils.RIGHT_HAND ? ["rightHand"] : ["leftHand"], [], 100); diff --git a/scripts/system/controllers/controllerModules/inEditMode.js b/scripts/system/controllers/controllerModules/inEditMode.js index a724c2037b..0c24e64af7 100644 --- a/scripts/system/controllers/controllerModules/inEditMode.js +++ b/scripts/system/controllers/controllerModules/inEditMode.js @@ -30,7 +30,7 @@ Script.include("/~/system/libraries/utils.js"); this.reticleMaxY; this.parameters = makeDispatcherModuleParameters( - 160, + 200, this.hand === RIGHT_HAND ? ["rightHand", "rightHandEquip", "rightHandTrigger"] : ["leftHand", "leftHandEquip", "leftHandTrigger"], [], 100, diff --git a/scripts/system/controllers/controllerModules/inVREditMode.js b/scripts/system/controllers/controllerModules/inVREditMode.js index 7b78d5e1c4..02863cf935 100644 --- a/scripts/system/controllers/controllerModules/inVREditMode.js +++ b/scripts/system/controllers/controllerModules/inVREditMode.js @@ -21,7 +21,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); this.disableModules = false; var NO_HAND_LASER = -1; // Invalid hand parameter so that default laser is not displayed. this.parameters = makeDispatcherModuleParameters( - 200, // Not too high otherwise the tablet laser doesn't work. + 240, // Not too high otherwise the tablet laser doesn't work. this.hand === RIGHT_HAND ? ["rightHand", "rightHandEquip", "rightHandTrigger"] : ["leftHand", "leftHandEquip", "leftHandTrigger"], diff --git a/scripts/system/controllers/controllerModules/nearActionGrabEntity.js b/scripts/system/controllers/controllerModules/nearActionGrabEntity.js index f528c6f80f..f3574c668f 100644 --- a/scripts/system/controllers/controllerModules/nearActionGrabEntity.js +++ b/scripts/system/controllers/controllerModules/nearActionGrabEntity.js @@ -26,7 +26,7 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); this.hapticTargetID = null; this.parameters = makeDispatcherModuleParameters( - 500, + 140, this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"], [], 100); diff --git a/scripts/system/controllers/controllerModules/nearGrabHyperLinkEntity.js b/scripts/system/controllers/controllerModules/nearGrabHyperLinkEntity.js index 962ae89bb9..366fcd3032 100644 --- a/scripts/system/controllers/controllerModules/nearGrabHyperLinkEntity.js +++ b/scripts/system/controllers/controllerModules/nearGrabHyperLinkEntity.js @@ -21,7 +21,7 @@ this.hyperlink = ""; this.parameters = makeDispatcherModuleParameters( - 485, + 125, this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"], [], 100); diff --git a/scripts/system/controllers/controllerModules/nearParentGrabEntity.js b/scripts/system/controllers/controllerModules/nearParentGrabEntity.js index 38334f5523..ea55ee33f9 100644 --- a/scripts/system/controllers/controllerModules/nearParentGrabEntity.js +++ b/scripts/system/controllers/controllerModules/nearParentGrabEntity.js @@ -39,7 +39,7 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); this.cloneAllowed = true; this.parameters = makeDispatcherModuleParameters( - 500, + 140, this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"], [], 100); diff --git a/scripts/system/controllers/controllerModules/nearTrigger.js b/scripts/system/controllers/controllerModules/nearTrigger.js index 6a9cd9fbcd..f1126dedc3 100644 --- a/scripts/system/controllers/controllerModules/nearTrigger.js +++ b/scripts/system/controllers/controllerModules/nearTrigger.js @@ -29,7 +29,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); this.startSent = false; this.parameters = makeDispatcherModuleParameters( - 480, + 120, this.hand === RIGHT_HAND ? ["rightHandTrigger", "rightHand"] : ["leftHandTrigger", "leftHand"], [], 100); diff --git a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js index 1706fadbb7..527ba0bd2f 100644 --- a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js +++ b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js @@ -22,7 +22,7 @@ Script.include("/~/system/libraries/controllers.js"); this.running = false; this.parameters = makeDispatcherModuleParameters( - 120, + 160, this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"], [], 100, @@ -60,6 +60,30 @@ Script.include("/~/system/libraries/controllers.js"); return this.hand === RIGHT_HAND ? leftOverlayLaserInput : rightOverlayLaserInput; }; + this.isPointingAtGrabbableEntity = function(controllerData, triggerPressed) { + // we are searching for an entity that is not a web entity. We want to be able to + // grab a non-web entity if the ray-pick intersects one. + var intersection = controllerData.rayPicks[this.hand]; + if(intersection.type === Picks.INTERSECTED_ENTITY) { + // is pointing at an entity. + var entityProperty = Entities.getEntityProperties(intersection.objectID); + var entityType = entityProperty.type; + var isGrabbable = entityIsGrabbable(entityProperty); + return (isGrabbable && triggerPressed && entityType !== "Web"); + } else if (intersection.type === Picks.INTERSECTED_OVERLAY) { + var objectID = intersection.objectID; + if ((HMD.tabletID && objectID === HMD.tabletID) || + (HMD.tabletScreenID && objectID === HMD.tabletScreenID) || + (HMD.homeButtonID && objectID === HMD.homeButtonID)) { + return true; + } else { + var overlayType = Overlays.getOverlayType(objectID); + return overlayType === "web3d" || triggerPressed; + } + } + return false; + } + this.isPointingAtTriggerable = function(controllerData, triggerPressed) { // allow pointing at tablet, unlocked web entities, or web overlays automatically without pressing trigger, // but for pointing at locked web entities or non-web overlays user must be pressing trigger @@ -113,7 +137,8 @@ Script.include("/~/system/libraries/controllers.js"); var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE && controllerData.triggerValues[this.otherHand] <= TRIGGER_OFF_VALUE; var allowThisModule = !otherModuleRunning || isTriggerPressed; - if (allowThisModule && this.isPointingAtTriggerable(controllerData, isTriggerPressed)) { + if (allowThisModule && this.isPointingAtTriggerable(controllerData, isTriggerPressed)) { + //this.isPointingAtGrabbableEntity(controllerData, isTriggerPressed)) { this.updateAllwaysOn(); if (isTriggerPressed) { this.dominantHandOverride = true; // Override dominant hand. @@ -134,7 +159,8 @@ Script.include("/~/system/libraries/controllers.js"); var allowThisModule = !otherModuleRunning && !grabModuleNeedsToRun; var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE; var laserOn = isTriggerPressed || this.parameters.handLaser.allwaysOn; - if (allowThisModule && (laserOn && this.isPointingAtTriggerable(controllerData, isTriggerPressed))) { + if (allowThisModule && (laserOn && this.isPointingAtTriggerable(controllerData, isTriggerPressed)) && + this.isPointingAtGrabbableEntity(controllerData, isTriggerPressed)) { this.running = true; return makeRunningValues(true, [], []); } From 30ca5a8cbd08a7fb440ea4baaf336c74c7a3e770 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Tue, 17 Jul 2018 16:44:49 -0700 Subject: [PATCH 03/24] code cleanup to use web laser if laser is not pointing at grabbable entity --- .../controllerModules/webSurfaceLaserInput.js | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js index 527ba0bd2f..9e07e125e7 100644 --- a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js +++ b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js @@ -64,25 +64,15 @@ Script.include("/~/system/libraries/controllers.js"); // we are searching for an entity that is not a web entity. We want to be able to // grab a non-web entity if the ray-pick intersects one. var intersection = controllerData.rayPicks[this.hand]; - if(intersection.type === Picks.INTERSECTED_ENTITY) { + if (intersection.type === Picks.INTERSECTED_ENTITY) { // is pointing at an entity. var entityProperty = Entities.getEntityProperties(intersection.objectID); var entityType = entityProperty.type; var isGrabbable = entityIsGrabbable(entityProperty); return (isGrabbable && triggerPressed && entityType !== "Web"); - } else if (intersection.type === Picks.INTERSECTED_OVERLAY) { - var objectID = intersection.objectID; - if ((HMD.tabletID && objectID === HMD.tabletID) || - (HMD.tabletScreenID && objectID === HMD.tabletScreenID) || - (HMD.homeButtonID && objectID === HMD.homeButtonID)) { - return true; - } else { - var overlayType = Overlays.getOverlayType(objectID); - return overlayType === "web3d" || triggerPressed; - } } return false; - } + }; this.isPointingAtTriggerable = function(controllerData, triggerPressed) { // allow pointing at tablet, unlocked web entities, or web overlays automatically without pressing trigger, @@ -137,8 +127,8 @@ Script.include("/~/system/libraries/controllers.js"); var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE && controllerData.triggerValues[this.otherHand] <= TRIGGER_OFF_VALUE; var allowThisModule = !otherModuleRunning || isTriggerPressed; - if (allowThisModule && this.isPointingAtTriggerable(controllerData, isTriggerPressed)) { - //this.isPointingAtGrabbableEntity(controllerData, isTriggerPressed)) { + if (allowThisModule && this.isPointingAtTriggerable(controllerData, isTriggerPressed) && + !this.isPointingAtGrabbableEntity(controllerData, isTriggerPressed)) { this.updateAllwaysOn(); if (isTriggerPressed) { this.dominantHandOverride = true; // Override dominant hand. @@ -159,8 +149,8 @@ Script.include("/~/system/libraries/controllers.js"); var allowThisModule = !otherModuleRunning && !grabModuleNeedsToRun; var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE; var laserOn = isTriggerPressed || this.parameters.handLaser.allwaysOn; - if (allowThisModule && (laserOn && this.isPointingAtTriggerable(controllerData, isTriggerPressed)) && - this.isPointingAtGrabbableEntity(controllerData, isTriggerPressed)) { + if (allowThisModule && (laserOn && this.isPointingAtTriggerable(controllerData, isTriggerPressed)) && + !this.isPointingAtGrabbableEntity(controllerData, isTriggerPressed)) { this.running = true; return makeRunningValues(true, [], []); } From ac642f126a02ebb66303fee75f8dc3bf7ff06922 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Tue, 17 Jul 2018 20:52:50 -0700 Subject: [PATCH 04/24] adding extra conditional to ensure all modules are checked --- .../controllers/controllerModules/webSurfaceLaserInput.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js index 9e07e125e7..03c8a65637 100644 --- a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js +++ b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js @@ -44,12 +44,12 @@ Script.include("/~/system/libraries/controllers.js"); } nearGrabName = this.hand === RIGHT_HAND ? "RightNearParentingGrabEntity" : "LeftNearParentingGrabEntity"; nearGrabModule = getEnabledModuleByName(nearGrabName); - if (nearGrabModule) { + if (nearGrabModule && nearGrabModule.isReady(controllerData)) { return nearGrabModule.isReady(controllerData).active; } nearGrabName = this.hand === RIGHT_HAND ? "RightNearActionGrabEntity" : "LeftNearActionGrabEntity"; nearGrabModule = getEnabledModuleByName(nearGrabName); - if (nearGrabModule) { + if (nearGrabModule && nearGrabModule.isReady(controllerData)) { return nearGrabModule.isReady(controllerData).active; } } From 5276d84aa5ccbb75f19f640cf60af794dba7d516 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Thu, 19 Jul 2018 17:08:12 -0700 Subject: [PATCH 05/24] pushing what i coded out loud - it broke the way grabbing works --- .../controllers/controllerDispatcher.js | 1 + .../controllerModules/webSurfaceLaserInput.js | 56 +++++++++++++------ 2 files changed, 40 insertions(+), 17 deletions(-) diff --git a/scripts/system/controllers/controllerDispatcher.js b/scripts/system/controllers/controllerDispatcher.js index 4002fd297b..09d09248fc 100644 --- a/scripts/system/controllers/controllerDispatcher.js +++ b/scripts/system/controllers/controllerDispatcher.js @@ -298,6 +298,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); triggerValues: [_this.leftTriggerValue, _this.rightTriggerValue], triggerClicks: [_this.leftTriggerClicked, _this.rightTriggerClicked], secondaryValues: [_this.leftSecondaryValue, _this.rightSecondaryValue], + pointers: [_this.leftPointer, _this.rightPointer ], controllerLocations: controllerLocations, nearbyEntityProperties: nearbyEntityProperties, nearbyEntityPropertiesByID: nearbyEntityPropertiesByID, diff --git a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js index 03c8a65637..3ee50d0f75 100644 --- a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js +++ b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js @@ -5,11 +5,12 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -/* global Script, Entities, Controller, RIGHT_HAND, LEFT_HAND, enableDispatcherModule, disableDispatcherModule, - makeRunningValues, Messages, Quat, Vec3, makeDispatcherModuleParameters, Overlays, ZERO_VEC, HMD, - INCHES_TO_METERS, DEFAULT_REGISTRATION_POINT, getGrabPointSphereOffset, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, - COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD, DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_ON_VALUE, - TRIGGER_OFF_VALUE, getEnabledModuleByName, PICK_MAX_DISTANCE, ContextOverlay, Picks, makeLaserParams +/* global Script, Entities, Controller, RIGHT_HAND, LEFT_HAND, getControllerWorldLocation, + enableDispatcherModule, disableDispatcherModule, makeRunningValues, Messages, Quat, Vec3, + makeDispatcherModuleParameters, Overlays, ZERO_VEC, HMD, INCHES_TO_METERS, DEFAULT_REGISTRATION_POINT, + getGrabPointSphereOffset, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, + COLORS_GRAB_DISTANCE_HOLD, DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_ON_VALUE, TRIGGER_OFF_VALUE, + getEnabledModuleByName, PICK_MAX_DISTANCE, ContextOverlay, Picks, makeLaserParams */ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); @@ -19,6 +20,8 @@ Script.include("/~/system/libraries/controllers.js"); function WebSurfaceLaserInput(hand) { this.hand = hand; this.otherHand = this.hand === RIGHT_HAND ? LEFT_HAND : RIGHT_HAND; + this.ignoredEntities = []; + this.lastObjectID = null; this.running = false; this.parameters = makeDispatcherModuleParameters( @@ -60,16 +63,20 @@ Script.include("/~/system/libraries/controllers.js"); return this.hand === RIGHT_HAND ? leftOverlayLaserInput : rightOverlayLaserInput; }; - this.isPointingAtGrabbableEntity = function(controllerData, triggerPressed) { + this.isPointingAtNearGrabbableEntity = function(controllerData, triggerPressed) { // we are searching for an entity that is not a web entity. We want to be able to // grab a non-web entity if the ray-pick intersects one. var intersection = controllerData.rayPicks[this.hand]; if (intersection.type === Picks.INTERSECTED_ENTITY) { // is pointing at an entity. - var entityProperty = Entities.getEntityProperties(intersection.objectID); - var entityType = entityProperty.type; - var isGrabbable = entityIsGrabbable(entityProperty); - return (isGrabbable && triggerPressed && entityType !== "Web"); + var entityProperties = Entities.getEntityProperties(intersection.objectID); + var entityType = entityProperties.type; + if (entityIsGrabbable(entityProperties)) { + // check if entity is near grabbable. + var distance = Vec3.distance(entityProperties.position, controllerData.controllerLocations[this.hand].position); + if (distance <= NEAR_GRAB_RADIUS * MyAvatar.sensorToWorldScale) + return (triggerPressed && entityType !== "Web"); + } } return false; }; @@ -78,21 +85,30 @@ Script.include("/~/system/libraries/controllers.js"); // allow pointing at tablet, unlocked web entities, or web overlays automatically without pressing trigger, // but for pointing at locked web entities or non-web overlays user must be pressing trigger var intersection = controllerData.rayPicks[this.hand]; + var objectID = intersection.objectID; if (intersection.type === Picks.INTERSECTED_OVERLAY) { - var objectID = intersection.objectID; if ((HMD.tabletID && objectID === HMD.tabletID) || (HMD.tabletScreenID && objectID === HMD.tabletScreenID) || (HMD.homeButtonID && objectID === HMD.homeButtonID)) { + this.lastObjectID = objectID; return true; } else { var overlayType = Overlays.getOverlayType(objectID); + this.lastObjectID = objectID; return overlayType === "web3d" || triggerPressed; } } else if (intersection.type === Picks.INTERSECTED_ENTITY) { - var entityProperty = Entities.getEntityProperties(intersection.objectID); - var entityType = entityProperty.type; - var isLocked = entityProperty.locked; - return entityType === "Web" && (!isLocked || triggerPressed); + var entityProperty = Entities.getEntityProperties(objectID); + if (entityProperty.type === "Web") { + var isLocked = entityProperty.locked; + this.lastObjectID = objectID; + return (!isLocked || triggerPressed); + } else if (this.ignoredEntities.indexOf(objectID) === -1 && triggerPressed && this.lastObjectID !== objectID) { + // ignore, preserve whether it's running or not. + console.log("I'm here"); + Pointers.setIgnoreItems(controllerData.pointers[this.hand], [objectID]); + this.ignoredEntities.push(objectID); + } } return false; }; @@ -110,6 +126,11 @@ Script.include("/~/system/libraries/controllers.js"); } }; + this.reAddIgnoredEntities = function(controllerData) { + Pointers.setIncludeItems(controllerData.pointers[this.hand], this.ignoredEntities); + this.ignoredEntities = []; + } + this.updateAllwaysOn = function() { var PREFER_STYLUS_OVER_LASER = "preferStylusOverLaser"; this.parameters.handLaser.allwaysOn = !Settings.getValue(PREFER_STYLUS_OVER_LASER, false); @@ -128,7 +149,7 @@ Script.include("/~/system/libraries/controllers.js"); controllerData.triggerValues[this.otherHand] <= TRIGGER_OFF_VALUE; var allowThisModule = !otherModuleRunning || isTriggerPressed; if (allowThisModule && this.isPointingAtTriggerable(controllerData, isTriggerPressed) && - !this.isPointingAtGrabbableEntity(controllerData, isTriggerPressed)) { + !this.isPointingAtNearGrabbableEntity(controllerData, isTriggerPressed)) { this.updateAllwaysOn(); if (isTriggerPressed) { this.dominantHandOverride = true; // Override dominant hand. @@ -150,11 +171,12 @@ Script.include("/~/system/libraries/controllers.js"); var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE; var laserOn = isTriggerPressed || this.parameters.handLaser.allwaysOn; if (allowThisModule && (laserOn && this.isPointingAtTriggerable(controllerData, isTriggerPressed)) && - !this.isPointingAtGrabbableEntity(controllerData, isTriggerPressed)) { + !this.isPointingAtNearGrabbableEntity(controllerData, isTriggerPressed)) { this.running = true; return makeRunningValues(true, [], []); } this.deleteContextOverlay(); + this.reAddIgnoredEntities(controllerData); this.running = false; this.dominantHandOverride = false; return makeRunningValues(false, [], []); From 4e3a6cb320b8ea8507512c8d5a7ab54a52cf737f Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Fri, 20 Jul 2018 11:18:20 -0700 Subject: [PATCH 06/24] adding ignore for far-/near- grabbable entities when operating on web surface --- .../controllerModules/webSurfaceLaserInput.js | 35 ++++++------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js index 3ee50d0f75..16e2c1a4f7 100644 --- a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js +++ b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js @@ -20,8 +20,6 @@ Script.include("/~/system/libraries/controllers.js"); function WebSurfaceLaserInput(hand) { this.hand = hand; this.otherHand = this.hand === RIGHT_HAND ? LEFT_HAND : RIGHT_HAND; - this.ignoredEntities = []; - this.lastObjectID = null; this.running = false; this.parameters = makeDispatcherModuleParameters( @@ -71,11 +69,15 @@ Script.include("/~/system/libraries/controllers.js"); // is pointing at an entity. var entityProperties = Entities.getEntityProperties(intersection.objectID); var entityType = entityProperties.type; - if (entityIsGrabbable(entityProperties)) { + if (entityIsGrabbable(entityProperties) && entityType !== "Web") { // check if entity is near grabbable. var distance = Vec3.distance(entityProperties.position, controllerData.controllerLocations[this.hand].position); - if (distance <= NEAR_GRAB_RADIUS * MyAvatar.sensorToWorldScale) - return (triggerPressed && entityType !== "Web"); + if (distance <= NEAR_GRAB_RADIUS * MyAvatar.sensorToWorldScale) { + return triggerPressed; + } else { + // far-grabbable, but still return it as true anyway + return false; + } } } return false; @@ -90,25 +92,15 @@ Script.include("/~/system/libraries/controllers.js"); if ((HMD.tabletID && objectID === HMD.tabletID) || (HMD.tabletScreenID && objectID === HMD.tabletScreenID) || (HMD.homeButtonID && objectID === HMD.homeButtonID)) { - this.lastObjectID = objectID; return true; } else { var overlayType = Overlays.getOverlayType(objectID); - this.lastObjectID = objectID; return overlayType === "web3d" || triggerPressed; } } else if (intersection.type === Picks.INTERSECTED_ENTITY) { var entityProperty = Entities.getEntityProperties(objectID); - if (entityProperty.type === "Web") { - var isLocked = entityProperty.locked; - this.lastObjectID = objectID; - return (!isLocked || triggerPressed); - } else if (this.ignoredEntities.indexOf(objectID) === -1 && triggerPressed && this.lastObjectID !== objectID) { - // ignore, preserve whether it's running or not. - console.log("I'm here"); - Pointers.setIgnoreItems(controllerData.pointers[this.hand], [objectID]); - this.ignoredEntities.push(objectID); - } + var isLocked = entityProperty.locked; + return (!isLocked || triggerPressed || entityProperty.type === "Web"); } return false; }; @@ -126,11 +118,6 @@ Script.include("/~/system/libraries/controllers.js"); } }; - this.reAddIgnoredEntities = function(controllerData) { - Pointers.setIncludeItems(controllerData.pointers[this.hand], this.ignoredEntities); - this.ignoredEntities = []; - } - this.updateAllwaysOn = function() { var PREFER_STYLUS_OVER_LASER = "preferStylusOverLaser"; this.parameters.handLaser.allwaysOn = !Settings.getValue(PREFER_STYLUS_OVER_LASER, false); @@ -148,8 +135,7 @@ Script.include("/~/system/libraries/controllers.js"); var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE && controllerData.triggerValues[this.otherHand] <= TRIGGER_OFF_VALUE; var allowThisModule = !otherModuleRunning || isTriggerPressed; - if (allowThisModule && this.isPointingAtTriggerable(controllerData, isTriggerPressed) && - !this.isPointingAtNearGrabbableEntity(controllerData, isTriggerPressed)) { + if (allowThisModule && this.isPointingAtTriggerable(controllerData, isTriggerPressed)) { this.updateAllwaysOn(); if (isTriggerPressed) { this.dominantHandOverride = true; // Override dominant hand. @@ -176,7 +162,6 @@ Script.include("/~/system/libraries/controllers.js"); return makeRunningValues(true, [], []); } this.deleteContextOverlay(); - this.reAddIgnoredEntities(controllerData); this.running = false; this.dominantHandOverride = false; return makeRunningValues(false, [], []); From be5fdef974c66ec7a4525acddb07d48870b5adba Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Fri, 20 Jul 2018 15:26:55 -0700 Subject: [PATCH 07/24] adding check in isReady for grabbing non-web entitys --- .../controllers/controllerDispatcher.js | 48 ++++++++++++++++++- .../controllerModules/webSurfaceLaserInput.js | 19 ++++---- 2 files changed, 57 insertions(+), 10 deletions(-) diff --git a/scripts/system/controllers/controllerDispatcher.js b/scripts/system/controllers/controllerDispatcher.js index 09d09248fc..8dbf4a6789 100644 --- a/scripts/system/controllers/controllerDispatcher.js +++ b/scripts/system/controllers/controllerDispatcher.js @@ -31,6 +31,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); var PROFILE = false; var DEBUG = false; + var DEBUG_OVERLAY = true; if (typeof Test !== "undefined") { PROFILE = true; @@ -48,6 +49,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); this.tabletID = null; this.blacklist = []; this.pointerManager = new PointerManager(); + this.debugOverlayID = null; // a module can occupy one or more "activity" slots while it's running. If all the required slots for a module are // not set to false (not in use), a module cannot start. When a module is using a slot, that module's name @@ -298,7 +300,6 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); triggerValues: [_this.leftTriggerValue, _this.rightTriggerValue], triggerClicks: [_this.leftTriggerClicked, _this.rightTriggerClicked], secondaryValues: [_this.leftSecondaryValue, _this.rightSecondaryValue], - pointers: [_this.leftPointer, _this.rightPointer ], controllerLocations: controllerLocations, nearbyEntityProperties: nearbyEntityProperties, nearbyEntityPropertiesByID: nearbyEntityPropertiesByID, @@ -378,6 +379,48 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); } } _this.pointerManager.updatePointersRenderState(controllerData.triggerClicks, controllerData.triggerValues); + + if (DEBUG_OVERLAY) { + if (!_this.debugOverlayID) { + + var textWidth = 0.4; + var textHeight = 0.3; + var numberOfLines = 15; + var textMargin = 0.02; + var lineHeight = (textHeight - (2 * textMargin)) / numberOfLines; + + _this.debugOverlayID = Overlays.addOverlay("text3d", { + localPosition: { x: 0.3, y: 0.2, z: 1.1 }, + localRotation: { x: 0.0, y: 0.0, z: 0.0, w: 1.0 }, + parentID: MyAvatar.sessionUUID, + parentJointIndex: MyAvatar.getJointIndex("Head"), + dimensions: { x: textWidth, y: textHeight }, + backgroundColor: { red: 0, green: 0, blue: 0 }, + color: { red: 255, green: 255, blue: 255 }, + topMargin: textMargin, + leftMargin: textMargin, + bottomMargin: textMargin, + rightMargin: textMargin, + text: "", + lineHeight: lineHeight, + alpha: 0.9, + backgroundAlpha: 0.9, + ignoreRayIntersection: true, + visible: true, + isFacingAvatar: true + }); + } + + var debugText = ""; + Object.keys(_this.runningPluginNames).forEach(function (pluginName) { + if (_this.runningPluginNames[pluginName]) { + var plugin = controllerDispatcherPlugins[pluginName]; + debugText += pluginName + ": " + plugin.parameters.priority + "\n"; + } + }); + Overlays.editOverlay(_this.debugOverlayID, { text: debugText }); + } + if (PROFILE) { Script.endProfileRange("dispatch.run"); } @@ -481,6 +524,9 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); this.cleanup = function () { Controller.disableMapping(MAPPING_NAME); _this.pointerManager.removePointers(); + if (_this.debugOverlayID) { + Overlays.deleteOverlay(_this.debugOverlayID); + } Pointers.removePointer(this.mouseRayPick); Selection.disableListHighlight(DISPATCHER_HOVERING_LIST); }; diff --git a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js index 16e2c1a4f7..16cf2eef5c 100644 --- a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js +++ b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js @@ -5,12 +5,11 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -/* global Script, Entities, Controller, RIGHT_HAND, LEFT_HAND, getControllerWorldLocation, - enableDispatcherModule, disableDispatcherModule, makeRunningValues, Messages, Quat, Vec3, - makeDispatcherModuleParameters, Overlays, ZERO_VEC, HMD, INCHES_TO_METERS, DEFAULT_REGISTRATION_POINT, - getGrabPointSphereOffset, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, - COLORS_GRAB_DISTANCE_HOLD, DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_ON_VALUE, TRIGGER_OFF_VALUE, - getEnabledModuleByName, PICK_MAX_DISTANCE, ContextOverlay, Picks, makeLaserParams +/* global Script, Entities, Controller, RIGHT_HAND, LEFT_HAND, enableDispatcherModule, disableDispatcherModule, + makeRunningValues, Messages, Quat, Vec3, makeDispatcherModuleParameters, Overlays, ZERO_VEC, HMD, + INCHES_TO_METERS, DEFAULT_REGISTRATION_POINT, getGrabPointSphereOffset, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, + COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD, DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_ON_VALUE, + TRIGGER_OFF_VALUE, getEnabledModuleByName, PICK_MAX_DISTANCE, ContextOverlay, Picks, makeLaserParams */ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); @@ -76,7 +75,7 @@ Script.include("/~/system/libraries/controllers.js"); return triggerPressed; } else { // far-grabbable, but still return it as true anyway - return false; + return true; } } } @@ -99,8 +98,9 @@ Script.include("/~/system/libraries/controllers.js"); } } else if (intersection.type === Picks.INTERSECTED_ENTITY) { var entityProperty = Entities.getEntityProperties(objectID); + var entityType = entityProperty.type; var isLocked = entityProperty.locked; - return (!isLocked || triggerPressed || entityProperty.type === "Web"); + return (!isLocked || triggerPressed || entityType === "Web"); } return false; }; @@ -135,7 +135,8 @@ Script.include("/~/system/libraries/controllers.js"); var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE && controllerData.triggerValues[this.otherHand] <= TRIGGER_OFF_VALUE; var allowThisModule = !otherModuleRunning || isTriggerPressed; - if (allowThisModule && this.isPointingAtTriggerable(controllerData, isTriggerPressed)) { + if (allowThisModule && this.isPointingAtTriggerable(controllerData, isTriggerPressed) && + !this.isPointingAtNearGrabbableEntity(controllerData, isTriggerPressed)) { this.updateAllwaysOn(); if (isTriggerPressed) { this.dominantHandOverride = true; // Override dominant hand. From 32886d67d98b7d2b964b25e39ce1a821a05593fe Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Fri, 20 Jul 2018 17:17:36 -0700 Subject: [PATCH 08/24] optimizing near-/far- grabbable entities a bit --- .../controllers/controllerDispatcher.js | 74 +++---- .../system/controllers/controllerModules/' | 181 ++++++++++++++++++ .../controllerModules/webSurfaceLaserInput.js | 12 +- 3 files changed, 223 insertions(+), 44 deletions(-) create mode 100644 scripts/system/controllers/controllerModules/' diff --git a/scripts/system/controllers/controllerDispatcher.js b/scripts/system/controllers/controllerDispatcher.js index 8dbf4a6789..399ccf0ba3 100644 --- a/scripts/system/controllers/controllerDispatcher.js +++ b/scripts/system/controllers/controllerDispatcher.js @@ -380,46 +380,46 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); } _this.pointerManager.updatePointersRenderState(controllerData.triggerClicks, controllerData.triggerValues); - if (DEBUG_OVERLAY) { - if (!_this.debugOverlayID) { +/* if (DEBUG_OVERLAY) {*/ + //if (!_this.debugOverlayID) { - var textWidth = 0.4; - var textHeight = 0.3; - var numberOfLines = 15; - var textMargin = 0.02; - var lineHeight = (textHeight - (2 * textMargin)) / numberOfLines; + //var textWidth = 0.4; + //var textHeight = 0.3; + //var numberOfLines = 15; + //var textMargin = 0.02; + //var lineHeight = (textHeight - (2 * textMargin)) / numberOfLines; - _this.debugOverlayID = Overlays.addOverlay("text3d", { - localPosition: { x: 0.3, y: 0.2, z: 1.1 }, - localRotation: { x: 0.0, y: 0.0, z: 0.0, w: 1.0 }, - parentID: MyAvatar.sessionUUID, - parentJointIndex: MyAvatar.getJointIndex("Head"), - dimensions: { x: textWidth, y: textHeight }, - backgroundColor: { red: 0, green: 0, blue: 0 }, - color: { red: 255, green: 255, blue: 255 }, - topMargin: textMargin, - leftMargin: textMargin, - bottomMargin: textMargin, - rightMargin: textMargin, - text: "", - lineHeight: lineHeight, - alpha: 0.9, - backgroundAlpha: 0.9, - ignoreRayIntersection: true, - visible: true, - isFacingAvatar: true - }); - } + //_this.debugOverlayID = Overlays.addOverlay("text3d", { + //localPosition: { x: 0.3, y: 0.2, z: 1.1 }, + //localRotation: { x: 0.0, y: 0.0, z: 0.0, w: 1.0 }, + //parentID: MyAvatar.sessionUUID, + //parentJointIndex: MyAvatar.getJointIndex("Head"), + //dimensions: { x: textWidth, y: textHeight }, + //backgroundColor: { red: 0, green: 0, blue: 0 }, + //color: { red: 255, green: 255, blue: 255 }, + //topMargin: textMargin, + //leftMargin: textMargin, + //bottomMargin: textMargin, + //rightMargin: textMargin, + //text: "", + //lineHeight: lineHeight, + //alpha: 0.9, + //backgroundAlpha: 0.9, + //ignoreRayIntersection: true, + //visible: true, + //isFacingAvatar: true + //}); + //} - var debugText = ""; - Object.keys(_this.runningPluginNames).forEach(function (pluginName) { - if (_this.runningPluginNames[pluginName]) { - var plugin = controllerDispatcherPlugins[pluginName]; - debugText += pluginName + ": " + plugin.parameters.priority + "\n"; - } - }); - Overlays.editOverlay(_this.debugOverlayID, { text: debugText }); - } + //var debugText = ""; + //Object.keys(_this.runningPluginNames).forEach(function (pluginName) { + //if (_this.runningPluginNames[pluginName]) { + //var plugin = controllerDispatcherPlugins[pluginName]; + //debugText += pluginName + ": " + plugin.parameters.priority + "\n"; + //} + //}); + //Overlays.editOverlay(_this.debugOverlayID, { text: debugText }); + /*}*/ if (PROFILE) { Script.endProfileRange("dispatch.run"); diff --git a/scripts/system/controllers/controllerModules/' b/scripts/system/controllers/controllerModules/' new file mode 100644 index 0000000000..8217e0d022 --- /dev/null +++ b/scripts/system/controllers/controllerModules/' @@ -0,0 +1,181 @@ +"use strict"; + +// webSurfaceLaserInput.js +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html + +/* global Script, Entities, Controller, RIGHT_HAND, LEFT_HAND, enableDispatcherModule, disableDispatcherModule, + makeRunningValues, Messages, Quat, Vec3, makeDispatcherModuleParameters, Overlays, ZERO_VEC, HMD, + INCHES_TO_METERS, DEFAULT_REGISTRATION_POINT, getGrabPointSphereOffset, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, + COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD, DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_ON_VALUE, + TRIGGER_OFF_VALUE, getEnabledModuleByName, PICK_MAX_DISTANCE, ContextOverlay, Picks, makeLaserParams +*/ + +Script.include("/~/system/libraries/controllerDispatcherUtils.js"); +Script.include("/~/system/libraries/controllers.js"); + +(function() { + function WebSurfaceLaserInput(hand) { + this.hand = hand; + this.otherHand = this.hand === RIGHT_HAND ? LEFT_HAND : RIGHT_HAND; + this.running = false; + + this.parameters = makeDispatcherModuleParameters( + 160, + this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"], + [], + 100, + makeLaserParams(hand, true)); + + this.grabModuleWantsNearbyOverlay = function(controllerData) { + if (controllerData.triggerValues[this.hand] > TRIGGER_ON_VALUE) { + var nearGrabName = this.hand === RIGHT_HAND ? "RightNearParentingGrabOverlay" : "LeftNearParentingGrabOverlay"; + var nearGrabModule = getEnabledModuleByName(nearGrabName); + if (nearGrabModule) { + var candidateOverlays = controllerData.nearbyOverlayIDs[this.hand]; + var grabbableOverlays = candidateOverlays.filter(function(overlayID) { + return Overlays.getProperty(overlayID, "grabbable"); + }); + var target = nearGrabModule.getTargetID(grabbableOverlays, controllerData); + if (target) { + return true; + } + } + nearGrabName = this.hand === RIGHT_HAND ? "RightNearParentingGrabEntity" : "LeftNearParentingGrabEntity"; + nearGrabModule = getEnabledModuleByName(nearGrabName); + if (nearGrabModule && nearGrabModule.isReady(controllerData)) { + return nearGrabModule.isReady(controllerData).active; + } + nearGrabName = this.hand === RIGHT_HAND ? "RightNearActionGrabEntity" : "LeftNearActionGrabEntity"; + nearGrabModule = getEnabledModuleByName(nearGrabName); + if (nearGrabModule && nearGrabModule.isReady(controllerData)) { + return nearGrabModule.isReady(controllerData).active; + } + } + return false; + }; + + this.getOtherModule = function() { + return this.hand === RIGHT_HAND ? leftOverlayLaserInput : rightOverlayLaserInput; + }; + + this.isPointingAtNearGrabbableEntity = function(controllerData, triggerPressed) { + // we are searching for an entity that is not a web entity. We want to be able to + // grab a non-web entity if the ray-pick intersects one. + var intersection = controllerData.rayPicks[this.hand]; + if (intersection.type === Picks.INTERSECTED_ENTITY) { + // is pointing at an entity. + var entityProperties = Entities.getEntityProperties(intersection.objectID); + var entityType = entityProperties.type; + if (entityIsGrabbable(entityProperties) && entityType !== "Web") { + // check if entity is near grabbable. + var distance = Vec3.distance(entityProperties.position, controllerData.controllerLocations[this.hand].position); + if (distance >= NEAR_GRAB_RADIUS * MyAvatar.sensorToWorldScale) { + // far-grabbable, but still return it as true anyway + return true; + } + } + } + return false; + }; + + this.isPointingAtTriggerable = function(controllerData, triggerPressed) { + // allow pointing at tablet, unlocked web entities, or web overlays automatically without pressing trigger, + // but for pointing at locked web entities or non-web overlays user must be pressing trigger + var intersection = controllerData.rayPicks[this.hand]; + var objectID = intersection.objectID; + if (intersection.type === Picks.INTERSECTED_OVERLAY) { + if ((HMD.tabletID && objectID === HMD.tabletID) || + (HMD.tabletScreenID && objectID === HMD.tabletScreenID) || + (HMD.homeButtonID && objectID === HMD.homeButtonID)) { + return true; + } else { + var overlayType = Overlays.getOverlayType(objectID); + return overlayType === "web3d" || triggerPressed; + } + } else if (intersection.type === Picks.INTERSECTED_ENTITY) { + var entityProperty = Entities.getEntityProperties(objectID); + var entityType = entityProperty.type; + var isLocked = entityProperty.locked; + return (!isLocked || triggerPressed || entityType === "Web"); + } + return false; + }; + + this.deleteContextOverlay = function() { + var farGrabModule = getEnabledModuleByName(this.hand === RIGHT_HAND + ? "RightFarActionGrabEntity" : "LeftFarActionGrabEntity"); + if (farGrabModule) { + var entityWithContextOverlay = farGrabModule.entityWithContextOverlay; + + if (entityWithContextOverlay) { + ContextOverlay.destroyContextOverlay(entityWithContextOverlay); + farGrabModule.entityWithContextOverlay = false; + } + } + }; + + this.updateAllwaysOn = function() { + var PREFER_STYLUS_OVER_LASER = "preferStylusOverLaser"; + this.parameters.handLaser.allwaysOn = !Settings.getValue(PREFER_STYLUS_OVER_LASER, false); + }; + + this.getDominantHand = function() { + return MyAvatar.getDominantHand() === "right" ? 1 : 0; + }; + + this.dominantHandOverride = false; + + this.isReady = function(controllerData) { + var otherModuleRunning = this.getOtherModule().running; + otherModuleRunning = otherModuleRunning && this.getDominantHand() !== this.hand; // Auto-swap to dominant hand. + var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE && + controllerData.triggerValues[this.otherHand] <= TRIGGER_OFF_VALUE; + var allowThisModule = !otherModuleRunning || isTriggerPressed; + if (allowThisModule && this.isPointingAtTriggerable(controllerData, isTriggerPressed) && + (controllerData.nearbyEntityProperties[this.hand] !== [])) { + this.updateAllwaysOn(); + if (isTriggerPressed) { + this.dominantHandOverride = true; // Override dominant hand. + this.getOtherModule().dominantHandOverride = false; + } + if (this.parameters.handLaser.allwaysOn || isTriggerPressed) { + return makeRunningValues(true, [], []); + } + } + return makeRunningValues(false, [], []); + }; + + this.run = function(controllerData, deltaTime) { + var otherModuleRunning = this.getOtherModule().running; + otherModuleRunning = otherModuleRunning && this.getDominantHand() !== this.hand; // Auto-swap to dominant hand. + otherModuleRunning = otherModuleRunning || this.getOtherModule().dominantHandOverride; // Override dominant hand. + var grabModuleNeedsToRun = this.grabModuleWantsNearbyOverlay(controllerData); + var allowThisModule = !otherModuleRunning && !grabModuleNeedsToRun; + var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE; + var laserOn = isTriggerPressed || this.parameters.handLaser.allwaysOn; + if (allowThisModule && (laserOn && this.isPointingAtTriggerable(controllerData, isTriggerPressed)) && + (controllerData.nearbyEntityProperties[this.hand] !== [] || (this.isPointingAtNearGrabbableEntity(controllerData, isTriggerPressed)))) { + this.running = true; + return makeRunningValues(true, [], []); + } + this.deleteContextOverlay(); + this.running = false; + this.dominantHandOverride = false; + return makeRunningValues(false, [], []); + }; + } + + var leftOverlayLaserInput = new WebSurfaceLaserInput(LEFT_HAND); + var rightOverlayLaserInput = new WebSurfaceLaserInput(RIGHT_HAND); + + enableDispatcherModule("LeftWebSurfaceLaserInput", leftOverlayLaserInput); + enableDispatcherModule("RightWebSurfaceLaserInput", rightOverlayLaserInput); + + function cleanup() { + disableDispatcherModule("LeftWebSurfaceLaserInput"); + disableDispatcherModule("RightWebSurfaceLaserInput"); + } + Script.scriptEnding.connect(cleanup); +}()); diff --git a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js index 16cf2eef5c..dd7bccf667 100644 --- a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js +++ b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js @@ -60,7 +60,7 @@ Script.include("/~/system/libraries/controllers.js"); return this.hand === RIGHT_HAND ? leftOverlayLaserInput : rightOverlayLaserInput; }; - this.isPointingAtNearGrabbableEntity = function(controllerData, triggerPressed) { + this.isPointingAtFarGrabbableEntity = function(controllerData, triggerPressed) { // we are searching for an entity that is not a web entity. We want to be able to // grab a non-web entity if the ray-pick intersects one. var intersection = controllerData.rayPicks[this.hand]; @@ -71,9 +71,7 @@ Script.include("/~/system/libraries/controllers.js"); if (entityIsGrabbable(entityProperties) && entityType !== "Web") { // check if entity is near grabbable. var distance = Vec3.distance(entityProperties.position, controllerData.controllerLocations[this.hand].position); - if (distance <= NEAR_GRAB_RADIUS * MyAvatar.sensorToWorldScale) { - return triggerPressed; - } else { + if (distance >= NEAR_GRAB_RADIUS * MyAvatar.sensorToWorldScale) { // far-grabbable, but still return it as true anyway return true; } @@ -135,8 +133,8 @@ Script.include("/~/system/libraries/controllers.js"); var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE && controllerData.triggerValues[this.otherHand] <= TRIGGER_OFF_VALUE; var allowThisModule = !otherModuleRunning || isTriggerPressed; - if (allowThisModule && this.isPointingAtTriggerable(controllerData, isTriggerPressed) && - !this.isPointingAtNearGrabbableEntity(controllerData, isTriggerPressed)) { + if (allowThisModule && this.isPointingAtTriggerable(controllerData, isTriggerPressed) && + (controllerData.nearbyEntityProperties[this.hand] !== [])) { this.updateAllwaysOn(); if (isTriggerPressed) { this.dominantHandOverride = true; // Override dominant hand. @@ -158,7 +156,7 @@ Script.include("/~/system/libraries/controllers.js"); var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE; var laserOn = isTriggerPressed || this.parameters.handLaser.allwaysOn; if (allowThisModule && (laserOn && this.isPointingAtTriggerable(controllerData, isTriggerPressed)) && - !this.isPointingAtNearGrabbableEntity(controllerData, isTriggerPressed)) { + (controllerData.nearbyEntityProperties[this.hand] !== [] || !(this.isPointingAtFarGrabbableEntity(controllerData, isTriggerPressed)))) { this.running = true; return makeRunningValues(true, [], []); } From 1880c49d0358b535156d00671499f14fddab2979 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Fri, 20 Jul 2018 17:18:58 -0700 Subject: [PATCH 09/24] removing garbage file --- .../system/controllers/controllerModules/' | 181 ------------------ 1 file changed, 181 deletions(-) delete mode 100644 scripts/system/controllers/controllerModules/' diff --git a/scripts/system/controllers/controllerModules/' b/scripts/system/controllers/controllerModules/' deleted file mode 100644 index 8217e0d022..0000000000 --- a/scripts/system/controllers/controllerModules/' +++ /dev/null @@ -1,181 +0,0 @@ -"use strict"; - -// webSurfaceLaserInput.js -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html - -/* global Script, Entities, Controller, RIGHT_HAND, LEFT_HAND, enableDispatcherModule, disableDispatcherModule, - makeRunningValues, Messages, Quat, Vec3, makeDispatcherModuleParameters, Overlays, ZERO_VEC, HMD, - INCHES_TO_METERS, DEFAULT_REGISTRATION_POINT, getGrabPointSphereOffset, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, - COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD, DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_ON_VALUE, - TRIGGER_OFF_VALUE, getEnabledModuleByName, PICK_MAX_DISTANCE, ContextOverlay, Picks, makeLaserParams -*/ - -Script.include("/~/system/libraries/controllerDispatcherUtils.js"); -Script.include("/~/system/libraries/controllers.js"); - -(function() { - function WebSurfaceLaserInput(hand) { - this.hand = hand; - this.otherHand = this.hand === RIGHT_HAND ? LEFT_HAND : RIGHT_HAND; - this.running = false; - - this.parameters = makeDispatcherModuleParameters( - 160, - this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"], - [], - 100, - makeLaserParams(hand, true)); - - this.grabModuleWantsNearbyOverlay = function(controllerData) { - if (controllerData.triggerValues[this.hand] > TRIGGER_ON_VALUE) { - var nearGrabName = this.hand === RIGHT_HAND ? "RightNearParentingGrabOverlay" : "LeftNearParentingGrabOverlay"; - var nearGrabModule = getEnabledModuleByName(nearGrabName); - if (nearGrabModule) { - var candidateOverlays = controllerData.nearbyOverlayIDs[this.hand]; - var grabbableOverlays = candidateOverlays.filter(function(overlayID) { - return Overlays.getProperty(overlayID, "grabbable"); - }); - var target = nearGrabModule.getTargetID(grabbableOverlays, controllerData); - if (target) { - return true; - } - } - nearGrabName = this.hand === RIGHT_HAND ? "RightNearParentingGrabEntity" : "LeftNearParentingGrabEntity"; - nearGrabModule = getEnabledModuleByName(nearGrabName); - if (nearGrabModule && nearGrabModule.isReady(controllerData)) { - return nearGrabModule.isReady(controllerData).active; - } - nearGrabName = this.hand === RIGHT_HAND ? "RightNearActionGrabEntity" : "LeftNearActionGrabEntity"; - nearGrabModule = getEnabledModuleByName(nearGrabName); - if (nearGrabModule && nearGrabModule.isReady(controllerData)) { - return nearGrabModule.isReady(controllerData).active; - } - } - return false; - }; - - this.getOtherModule = function() { - return this.hand === RIGHT_HAND ? leftOverlayLaserInput : rightOverlayLaserInput; - }; - - this.isPointingAtNearGrabbableEntity = function(controllerData, triggerPressed) { - // we are searching for an entity that is not a web entity. We want to be able to - // grab a non-web entity if the ray-pick intersects one. - var intersection = controllerData.rayPicks[this.hand]; - if (intersection.type === Picks.INTERSECTED_ENTITY) { - // is pointing at an entity. - var entityProperties = Entities.getEntityProperties(intersection.objectID); - var entityType = entityProperties.type; - if (entityIsGrabbable(entityProperties) && entityType !== "Web") { - // check if entity is near grabbable. - var distance = Vec3.distance(entityProperties.position, controllerData.controllerLocations[this.hand].position); - if (distance >= NEAR_GRAB_RADIUS * MyAvatar.sensorToWorldScale) { - // far-grabbable, but still return it as true anyway - return true; - } - } - } - return false; - }; - - this.isPointingAtTriggerable = function(controllerData, triggerPressed) { - // allow pointing at tablet, unlocked web entities, or web overlays automatically without pressing trigger, - // but for pointing at locked web entities or non-web overlays user must be pressing trigger - var intersection = controllerData.rayPicks[this.hand]; - var objectID = intersection.objectID; - if (intersection.type === Picks.INTERSECTED_OVERLAY) { - if ((HMD.tabletID && objectID === HMD.tabletID) || - (HMD.tabletScreenID && objectID === HMD.tabletScreenID) || - (HMD.homeButtonID && objectID === HMD.homeButtonID)) { - return true; - } else { - var overlayType = Overlays.getOverlayType(objectID); - return overlayType === "web3d" || triggerPressed; - } - } else if (intersection.type === Picks.INTERSECTED_ENTITY) { - var entityProperty = Entities.getEntityProperties(objectID); - var entityType = entityProperty.type; - var isLocked = entityProperty.locked; - return (!isLocked || triggerPressed || entityType === "Web"); - } - return false; - }; - - this.deleteContextOverlay = function() { - var farGrabModule = getEnabledModuleByName(this.hand === RIGHT_HAND - ? "RightFarActionGrabEntity" : "LeftFarActionGrabEntity"); - if (farGrabModule) { - var entityWithContextOverlay = farGrabModule.entityWithContextOverlay; - - if (entityWithContextOverlay) { - ContextOverlay.destroyContextOverlay(entityWithContextOverlay); - farGrabModule.entityWithContextOverlay = false; - } - } - }; - - this.updateAllwaysOn = function() { - var PREFER_STYLUS_OVER_LASER = "preferStylusOverLaser"; - this.parameters.handLaser.allwaysOn = !Settings.getValue(PREFER_STYLUS_OVER_LASER, false); - }; - - this.getDominantHand = function() { - return MyAvatar.getDominantHand() === "right" ? 1 : 0; - }; - - this.dominantHandOverride = false; - - this.isReady = function(controllerData) { - var otherModuleRunning = this.getOtherModule().running; - otherModuleRunning = otherModuleRunning && this.getDominantHand() !== this.hand; // Auto-swap to dominant hand. - var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE && - controllerData.triggerValues[this.otherHand] <= TRIGGER_OFF_VALUE; - var allowThisModule = !otherModuleRunning || isTriggerPressed; - if (allowThisModule && this.isPointingAtTriggerable(controllerData, isTriggerPressed) && - (controllerData.nearbyEntityProperties[this.hand] !== [])) { - this.updateAllwaysOn(); - if (isTriggerPressed) { - this.dominantHandOverride = true; // Override dominant hand. - this.getOtherModule().dominantHandOverride = false; - } - if (this.parameters.handLaser.allwaysOn || isTriggerPressed) { - return makeRunningValues(true, [], []); - } - } - return makeRunningValues(false, [], []); - }; - - this.run = function(controllerData, deltaTime) { - var otherModuleRunning = this.getOtherModule().running; - otherModuleRunning = otherModuleRunning && this.getDominantHand() !== this.hand; // Auto-swap to dominant hand. - otherModuleRunning = otherModuleRunning || this.getOtherModule().dominantHandOverride; // Override dominant hand. - var grabModuleNeedsToRun = this.grabModuleWantsNearbyOverlay(controllerData); - var allowThisModule = !otherModuleRunning && !grabModuleNeedsToRun; - var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE; - var laserOn = isTriggerPressed || this.parameters.handLaser.allwaysOn; - if (allowThisModule && (laserOn && this.isPointingAtTriggerable(controllerData, isTriggerPressed)) && - (controllerData.nearbyEntityProperties[this.hand] !== [] || (this.isPointingAtNearGrabbableEntity(controllerData, isTriggerPressed)))) { - this.running = true; - return makeRunningValues(true, [], []); - } - this.deleteContextOverlay(); - this.running = false; - this.dominantHandOverride = false; - return makeRunningValues(false, [], []); - }; - } - - var leftOverlayLaserInput = new WebSurfaceLaserInput(LEFT_HAND); - var rightOverlayLaserInput = new WebSurfaceLaserInput(RIGHT_HAND); - - enableDispatcherModule("LeftWebSurfaceLaserInput", leftOverlayLaserInput); - enableDispatcherModule("RightWebSurfaceLaserInput", rightOverlayLaserInput); - - function cleanup() { - disableDispatcherModule("LeftWebSurfaceLaserInput"); - disableDispatcherModule("RightWebSurfaceLaserInput"); - } - Script.scriptEnding.connect(cleanup); -}()); From a2aeacab649d77acc8399291f719ea7b0f16c758 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Mon, 23 Jul 2018 12:17:19 -0700 Subject: [PATCH 10/24] adding fix for near grabbing with web entity --- .../controllerModules/webSurfaceLaserInput.js | 25 ++++++------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js index dd7bccf667..5009bec0f5 100644 --- a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js +++ b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js @@ -60,25 +60,14 @@ Script.include("/~/system/libraries/controllers.js"); return this.hand === RIGHT_HAND ? leftOverlayLaserInput : rightOverlayLaserInput; }; - this.isPointingAtFarGrabbableEntity = function(controllerData, triggerPressed) { - // we are searching for an entity that is not a web entity. We want to be able to - // grab a non-web entity if the ray-pick intersects one. + this.isPointingAtNearGrabbableEntity = function(controllerData, triggerPressed) { var intersection = controllerData.rayPicks[this.hand]; - if (intersection.type === Picks.INTERSECTED_ENTITY) { - // is pointing at an entity. - var entityProperties = Entities.getEntityProperties(intersection.objectID); - var entityType = entityProperties.type; - if (entityIsGrabbable(entityProperties) && entityType !== "Web") { - // check if entity is near grabbable. - var distance = Vec3.distance(entityProperties.position, controllerData.controllerLocations[this.hand].position); - if (distance >= NEAR_GRAB_RADIUS * MyAvatar.sensorToWorldScale) { - // far-grabbable, but still return it as true anyway - return true; - } - } + var objectID = intersection.objectID; + if(intersection.type === Picks.INTERSECTED_ENTITY) { + return (controllerData.nearbyEntityPropertiesByID[objectID] !== null && triggerPressed); } return false; - }; + } this.isPointingAtTriggerable = function(controllerData, triggerPressed) { // allow pointing at tablet, unlocked web entities, or web overlays automatically without pressing trigger, @@ -98,7 +87,7 @@ Script.include("/~/system/libraries/controllers.js"); var entityProperty = Entities.getEntityProperties(objectID); var entityType = entityProperty.type; var isLocked = entityProperty.locked; - return (!isLocked || triggerPressed || entityType === "Web"); + return entityType === "Web" && (!isLocked || triggerPressed); } return false; }; @@ -156,7 +145,7 @@ Script.include("/~/system/libraries/controllers.js"); var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE; var laserOn = isTriggerPressed || this.parameters.handLaser.allwaysOn; if (allowThisModule && (laserOn && this.isPointingAtTriggerable(controllerData, isTriggerPressed)) && - (controllerData.nearbyEntityProperties[this.hand] !== [] || !(this.isPointingAtFarGrabbableEntity(controllerData, isTriggerPressed)))) { + (controllerData.nearbyEntityProperties[this.hand] !== [])) { this.running = true; return makeRunningValues(true, [], []); } From 1ec136a19c04a3f9e39ee7f691667a3713eb1231 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Mon, 23 Jul 2018 12:18:26 -0700 Subject: [PATCH 11/24] removing debug overlay statements --- .../controllers/controllerDispatcher.js | 45 ------------------- 1 file changed, 45 deletions(-) diff --git a/scripts/system/controllers/controllerDispatcher.js b/scripts/system/controllers/controllerDispatcher.js index 399ccf0ba3..91ab824a54 100644 --- a/scripts/system/controllers/controllerDispatcher.js +++ b/scripts/system/controllers/controllerDispatcher.js @@ -31,7 +31,6 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); var PROFILE = false; var DEBUG = false; - var DEBUG_OVERLAY = true; if (typeof Test !== "undefined") { PROFILE = true; @@ -380,47 +379,6 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); } _this.pointerManager.updatePointersRenderState(controllerData.triggerClicks, controllerData.triggerValues); -/* if (DEBUG_OVERLAY) {*/ - //if (!_this.debugOverlayID) { - - //var textWidth = 0.4; - //var textHeight = 0.3; - //var numberOfLines = 15; - //var textMargin = 0.02; - //var lineHeight = (textHeight - (2 * textMargin)) / numberOfLines; - - //_this.debugOverlayID = Overlays.addOverlay("text3d", { - //localPosition: { x: 0.3, y: 0.2, z: 1.1 }, - //localRotation: { x: 0.0, y: 0.0, z: 0.0, w: 1.0 }, - //parentID: MyAvatar.sessionUUID, - //parentJointIndex: MyAvatar.getJointIndex("Head"), - //dimensions: { x: textWidth, y: textHeight }, - //backgroundColor: { red: 0, green: 0, blue: 0 }, - //color: { red: 255, green: 255, blue: 255 }, - //topMargin: textMargin, - //leftMargin: textMargin, - //bottomMargin: textMargin, - //rightMargin: textMargin, - //text: "", - //lineHeight: lineHeight, - //alpha: 0.9, - //backgroundAlpha: 0.9, - //ignoreRayIntersection: true, - //visible: true, - //isFacingAvatar: true - //}); - //} - - //var debugText = ""; - //Object.keys(_this.runningPluginNames).forEach(function (pluginName) { - //if (_this.runningPluginNames[pluginName]) { - //var plugin = controllerDispatcherPlugins[pluginName]; - //debugText += pluginName + ": " + plugin.parameters.priority + "\n"; - //} - //}); - //Overlays.editOverlay(_this.debugOverlayID, { text: debugText }); - /*}*/ - if (PROFILE) { Script.endProfileRange("dispatch.run"); } @@ -524,9 +482,6 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); this.cleanup = function () { Controller.disableMapping(MAPPING_NAME); _this.pointerManager.removePointers(); - if (_this.debugOverlayID) { - Overlays.deleteOverlay(_this.debugOverlayID); - } Pointers.removePointer(this.mouseRayPick); Selection.disableListHighlight(DISPATCHER_HOVERING_LIST); }; From e4a5be668a15aa603e3210b2053c2bc62ad2536a Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Mon, 23 Jul 2018 12:29:01 -0700 Subject: [PATCH 12/24] adding check function for pointing at near grabbable entity --- scripts/system/controllers/controllerDispatcher.js | 2 -- .../controllers/controllerModules/webSurfaceLaserInput.js | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts/system/controllers/controllerDispatcher.js b/scripts/system/controllers/controllerDispatcher.js index 91ab824a54..4002fd297b 100644 --- a/scripts/system/controllers/controllerDispatcher.js +++ b/scripts/system/controllers/controllerDispatcher.js @@ -48,7 +48,6 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); this.tabletID = null; this.blacklist = []; this.pointerManager = new PointerManager(); - this.debugOverlayID = null; // a module can occupy one or more "activity" slots while it's running. If all the required slots for a module are // not set to false (not in use), a module cannot start. When a module is using a slot, that module's name @@ -378,7 +377,6 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); } } _this.pointerManager.updatePointersRenderState(controllerData.triggerClicks, controllerData.triggerValues); - if (PROFILE) { Script.endProfileRange("dispatch.run"); } diff --git a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js index 5009bec0f5..92423f0670 100644 --- a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js +++ b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js @@ -123,7 +123,7 @@ Script.include("/~/system/libraries/controllers.js"); controllerData.triggerValues[this.otherHand] <= TRIGGER_OFF_VALUE; var allowThisModule = !otherModuleRunning || isTriggerPressed; if (allowThisModule && this.isPointingAtTriggerable(controllerData, isTriggerPressed) && - (controllerData.nearbyEntityProperties[this.hand] !== [])) { + !this.isPointingAtNearGrabbableEntity(controllerData, isTriggerPressed)) { this.updateAllwaysOn(); if (isTriggerPressed) { this.dominantHandOverride = true; // Override dominant hand. @@ -145,7 +145,7 @@ Script.include("/~/system/libraries/controllers.js"); var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE; var laserOn = isTriggerPressed || this.parameters.handLaser.allwaysOn; if (allowThisModule && (laserOn && this.isPointingAtTriggerable(controllerData, isTriggerPressed)) && - (controllerData.nearbyEntityProperties[this.hand] !== [])) { + !this.isPointingAtNearGrabbableEntity(controllerData, isTriggerPressed)) { this.running = true; return makeRunningValues(true, [], []); } From c0dfbac480ab9cbed8f7d2e90197a903439639ce Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Tue, 24 Jul 2018 10:04:51 -0700 Subject: [PATCH 13/24] adding comment for possible solution - still WIP --- .../controllers/controllerModules/webSurfaceLaserInput.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js index 92423f0670..ef9ff0c6ae 100644 --- a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js +++ b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js @@ -124,6 +124,7 @@ Script.include("/~/system/libraries/controllers.js"); var allowThisModule = !otherModuleRunning || isTriggerPressed; if (allowThisModule && this.isPointingAtTriggerable(controllerData, isTriggerPressed) && !this.isPointingAtNearGrabbableEntity(controllerData, isTriggerPressed)) { + //(controllerData.nearbyEntityProperties[this.hand] !== [])) { this.updateAllwaysOn(); if (isTriggerPressed) { this.dominantHandOverride = true; // Override dominant hand. @@ -146,6 +147,7 @@ Script.include("/~/system/libraries/controllers.js"); var laserOn = isTriggerPressed || this.parameters.handLaser.allwaysOn; if (allowThisModule && (laserOn && this.isPointingAtTriggerable(controllerData, isTriggerPressed)) && !this.isPointingAtNearGrabbableEntity(controllerData, isTriggerPressed)) { + //(controllerData.nearbyEntityProperties[this.hand] !== [])) { this.running = true; return makeRunningValues(true, [], []); } From 5b4eb922818917a81603b898d019fa8625506f20 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Tue, 21 Aug 2018 14:04:29 -0700 Subject: [PATCH 14/24] adding fix --- .../controllers/controllerModules/webSurfaceLaserInput.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js index ef9ff0c6ae..4077d07c38 100644 --- a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js +++ b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js @@ -76,7 +76,7 @@ Script.include("/~/system/libraries/controllers.js"); var objectID = intersection.objectID; if (intersection.type === Picks.INTERSECTED_OVERLAY) { if ((HMD.tabletID && objectID === HMD.tabletID) || - (HMD.tabletScreenID && objectID === HMD.tabletScreenID) || + (HMD.tabletScreenID && objectID === HMD.tabletScreenID) || (HMD.homeButtonID && objectID === HMD.homeButtonID)) { return true; } else { @@ -122,9 +122,9 @@ Script.include("/~/system/libraries/controllers.js"); var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE && controllerData.triggerValues[this.otherHand] <= TRIGGER_OFF_VALUE; var allowThisModule = !otherModuleRunning || isTriggerPressed; + if (allowThisModule && this.isPointingAtTriggerable(controllerData, isTriggerPressed) && !this.isPointingAtNearGrabbableEntity(controllerData, isTriggerPressed)) { - //(controllerData.nearbyEntityProperties[this.hand] !== [])) { this.updateAllwaysOn(); if (isTriggerPressed) { this.dominantHandOverride = true; // Override dominant hand. @@ -147,7 +147,6 @@ Script.include("/~/system/libraries/controllers.js"); var laserOn = isTriggerPressed || this.parameters.handLaser.allwaysOn; if (allowThisModule && (laserOn && this.isPointingAtTriggerable(controllerData, isTriggerPressed)) && !this.isPointingAtNearGrabbableEntity(controllerData, isTriggerPressed)) { - //(controllerData.nearbyEntityProperties[this.hand] !== [])) { this.running = true; return makeRunningValues(true, [], []); } From 7360629d31b452e295ead23e38b9f46fbf231a30 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Tue, 21 Aug 2018 14:13:55 -0700 Subject: [PATCH 15/24] modifying variable naming to fit convention --- .../controllers/controllerModules/webSurfaceLaserInput.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js index 4077d07c38..de3eb26086 100644 --- a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js +++ b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js @@ -84,9 +84,9 @@ Script.include("/~/system/libraries/controllers.js"); return overlayType === "web3d" || triggerPressed; } } else if (intersection.type === Picks.INTERSECTED_ENTITY) { - var entityProperty = Entities.getEntityProperties(objectID); - var entityType = entityProperty.type; - var isLocked = entityProperty.locked; + var entityProperties = Entities.getEntityProperties(objectID); + var entityType = entityProperties.type; + var isLocked = entityProperties.locked; return entityType === "Web" && (!isLocked || triggerPressed); } return false; From 7aae5366246c0799a04a320a4cf12c6ac45101a5 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Tue, 11 Sep 2018 11:41:24 -0700 Subject: [PATCH 16/24] adding fix to allow web scroll --- .../controllers/controllerModules/nearParentGrabEntity.js | 3 +++ .../controllers/controllerModules/webSurfaceLaserInput.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/system/controllers/controllerModules/nearParentGrabEntity.js b/scripts/system/controllers/controllerModules/nearParentGrabEntity.js index 6bbd19550b..2c0c668a42 100644 --- a/scripts/system/controllers/controllerModules/nearParentGrabEntity.js +++ b/scripts/system/controllers/controllerModules/nearParentGrabEntity.js @@ -24,6 +24,9 @@ Script.include("/~/system/libraries/controllers.js"); // XXX this.ignoreIK = (grabbableData.ignoreIK !== undefined) ? grabbableData.ignoreIK : true; // XXX this.kinematicGrab = (grabbableData.kinematic !== undefined) ? grabbableData.kinematic : NEAR_GRABBING_KINEMATIC; + // this offset needs to match the one in libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp:378 + //var GRAB_POINT_SPHERE_OFFSET = { x: 0.04, y: 0.13, z: 0.039 }; // x = upward, y = forward, z = lateral + function getGrabOffset(handController) { var offset = GRAB_POINT_SPHERE_OFFSET; if (handController === Controller.Standard.LeftHand) { diff --git a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js index de3eb26086..dd0af0ba8f 100644 --- a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js +++ b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js @@ -146,7 +146,7 @@ Script.include("/~/system/libraries/controllers.js"); var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE; var laserOn = isTriggerPressed || this.parameters.handLaser.allwaysOn; if (allowThisModule && (laserOn && this.isPointingAtTriggerable(controllerData, isTriggerPressed)) && - !this.isPointingAtNearGrabbableEntity(controllerData, isTriggerPressed)) { + (controllerData.nearbyEntityProperties[this.hand] !== [])) { this.running = true; return makeRunningValues(true, [], []); } From d9e0352028bdb6ffed215bf6ee301885bdd44893 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Tue, 11 Sep 2018 11:44:32 -0700 Subject: [PATCH 17/24] removing debug comments --- .../controllers/controllerModules/nearParentGrabEntity.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/system/controllers/controllerModules/nearParentGrabEntity.js b/scripts/system/controllers/controllerModules/nearParentGrabEntity.js index 2c0c668a42..6bbd19550b 100644 --- a/scripts/system/controllers/controllerModules/nearParentGrabEntity.js +++ b/scripts/system/controllers/controllerModules/nearParentGrabEntity.js @@ -24,9 +24,6 @@ Script.include("/~/system/libraries/controllers.js"); // XXX this.ignoreIK = (grabbableData.ignoreIK !== undefined) ? grabbableData.ignoreIK : true; // XXX this.kinematicGrab = (grabbableData.kinematic !== undefined) ? grabbableData.kinematic : NEAR_GRABBING_KINEMATIC; - // this offset needs to match the one in libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp:378 - //var GRAB_POINT_SPHERE_OFFSET = { x: 0.04, y: 0.13, z: 0.039 }; // x = upward, y = forward, z = lateral - function getGrabOffset(handController) { var offset = GRAB_POINT_SPHERE_OFFSET; if (handController === Controller.Standard.LeftHand) { From b6c5ae2a688527cdaf5a58a64f05ce61dc9a2345 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Tue, 11 Sep 2018 15:23:40 -0700 Subject: [PATCH 18/24] staging changes --- .../controllers/controllerDispatcher.js | 2 +- .../controllerModules/nearParentGrabEntity.js | 3 ++ .../controllerModules/webSurfaceLaserInput.js | 42 ++++++++++++------- 3 files changed, 30 insertions(+), 17 deletions(-) diff --git a/scripts/system/controllers/controllerDispatcher.js b/scripts/system/controllers/controllerDispatcher.js index 7a916392b9..c7a8de87b9 100644 --- a/scripts/system/controllers/controllerDispatcher.js +++ b/scripts/system/controllers/controllerDispatcher.js @@ -31,7 +31,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); var BASIC_TIMER_INTERVAL_MS = 1000 / TARGET_UPDATE_HZ; var PROFILE = false; - var DEBUG = false; + var DEBUG = true; if (typeof Test !== "undefined") { PROFILE = true; diff --git a/scripts/system/controllers/controllerModules/nearParentGrabEntity.js b/scripts/system/controllers/controllerModules/nearParentGrabEntity.js index 6bbd19550b..f805dbf60e 100644 --- a/scripts/system/controllers/controllerModules/nearParentGrabEntity.js +++ b/scripts/system/controllers/controllerModules/nearParentGrabEntity.js @@ -24,6 +24,9 @@ Script.include("/~/system/libraries/controllers.js"); // XXX this.ignoreIK = (grabbableData.ignoreIK !== undefined) ? grabbableData.ignoreIK : true; // XXX this.kinematicGrab = (grabbableData.kinematic !== undefined) ? grabbableData.kinematic : NEAR_GRABBING_KINEMATIC; + // this offset needs to match the one in libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp:378 + var GRAB_POINT_SPHERE_OFFSET = { x: 0.04, y: 0.13, z: 0.039 }; // x = upward, y = forward, z = lateral + function getGrabOffset(handController) { var offset = GRAB_POINT_SPHERE_OFFSET; if (handController === Controller.Standard.LeftHand) { diff --git a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js index dd0af0ba8f..e4978884d0 100644 --- a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js +++ b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js @@ -21,6 +21,10 @@ Script.include("/~/system/libraries/controllers.js"); this.otherHand = this.hand === RIGHT_HAND ? LEFT_HAND : RIGHT_HAND; this.running = false; + // parameters for things to be working on + this.isObjectEntity = false; + this.objectID = null; + this.parameters = makeDispatcherModuleParameters( 160, this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"], @@ -60,15 +64,6 @@ Script.include("/~/system/libraries/controllers.js"); return this.hand === RIGHT_HAND ? leftOverlayLaserInput : rightOverlayLaserInput; }; - this.isPointingAtNearGrabbableEntity = function(controllerData, triggerPressed) { - var intersection = controllerData.rayPicks[this.hand]; - var objectID = intersection.objectID; - if(intersection.type === Picks.INTERSECTED_ENTITY) { - return (controllerData.nearbyEntityPropertiesByID[objectID] !== null && triggerPressed); - } - return false; - } - this.isPointingAtTriggerable = function(controllerData, triggerPressed) { // allow pointing at tablet, unlocked web entities, or web overlays automatically without pressing trigger, // but for pointing at locked web entities or non-web overlays user must be pressing trigger @@ -123,14 +118,17 @@ Script.include("/~/system/libraries/controllers.js"); controllerData.triggerValues[this.otherHand] <= TRIGGER_OFF_VALUE; var allowThisModule = !otherModuleRunning || isTriggerPressed; - if (allowThisModule && this.isPointingAtTriggerable(controllerData, isTriggerPressed) && - !this.isPointingAtNearGrabbableEntity(controllerData, isTriggerPressed)) { + if (allowThisModule && this.isPointingAtTriggerable(controllerData, isTriggerPressed)) { this.updateAllwaysOn(); if (isTriggerPressed) { this.dominantHandOverride = true; // Override dominant hand. this.getOtherModule().dominantHandOverride = false; } if (this.parameters.handLaser.allwaysOn || isTriggerPressed) { + var intersection = controllerData.rayPicks[this.hand]; + // the object is either an entity or an overlay. + this.isObjectEntity = (intersection.type === Picks.INTERSECTED_ENTITY); + this.objectID = intersection.objectID; return makeRunningValues(true, [], []); } } @@ -142,17 +140,29 @@ Script.include("/~/system/libraries/controllers.js"); otherModuleRunning = otherModuleRunning && this.getDominantHand() !== this.hand; // Auto-swap to dominant hand. otherModuleRunning = otherModuleRunning || this.getOtherModule().dominantHandOverride; // Override dominant hand. var grabModuleNeedsToRun = this.grabModuleWantsNearbyOverlay(controllerData); - var allowThisModule = !otherModuleRunning && !grabModuleNeedsToRun; + // only allow for non-near grab + var allowThisModule = !otherModuleRunning && !(grabModuleNeedsToRun && controllerData.secondaryValues[this.hand] > BUMPER_ON_VALUE); var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE; var laserOn = isTriggerPressed || this.parameters.handLaser.allwaysOn; - if (allowThisModule && (laserOn && this.isPointingAtTriggerable(controllerData, isTriggerPressed)) && - (controllerData.nearbyEntityProperties[this.hand] !== [])) { - this.running = true; - return makeRunningValues(true, [], []); + if (allowThisModule) { + if (laserOn && this.isPointingAtTriggerable(controllerData, isTriggerPressed)) { + this.running = true; + return makeRunningValues(true, [], []); + } else { + this.deleteContextOverlay(); + this.running = false; + this.dominantHandOverride = false; + return makeRunningValues(false, [], []); + } } this.deleteContextOverlay(); this.running = false; this.dominantHandOverride = false; + this.objectID = null; + if (this.hand === LEFT_HAND) { + print("allowThisModule = " + allowThisModule); + print("isPointingAtTriggerable = " + (laserOn || this.isPointingAtTriggerable(controllerData, isTriggerPressed))); + } return makeRunningValues(false, [], []); }; } From 045ac4cb0d8e38517a2f996ebd8f3209ff5566f0 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Tue, 11 Sep 2018 17:43:03 -0700 Subject: [PATCH 19/24] allowing grip button for interrupting web scroll --- .../controllerModules/webSurfaceLaserInput.js | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js index e4978884d0..3ae971cf70 100644 --- a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js +++ b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js @@ -33,7 +33,7 @@ Script.include("/~/system/libraries/controllers.js"); makeLaserParams(hand, true)); this.grabModuleWantsNearbyOverlay = function(controllerData) { - if (controllerData.triggerValues[this.hand] > TRIGGER_ON_VALUE) { + if (controllerData.triggerValues[this.hand] > TRIGGER_ON_VALUE || controllerData.secondaryValues[this.hand] > BUMPER_ON_VALUE) { var nearGrabName = this.hand === RIGHT_HAND ? "RightNearParentingGrabOverlay" : "LeftNearParentingGrabOverlay"; var nearGrabModule = getEnabledModuleByName(nearGrabName); if (nearGrabModule) { @@ -64,12 +64,12 @@ Script.include("/~/system/libraries/controllers.js"); return this.hand === RIGHT_HAND ? leftOverlayLaserInput : rightOverlayLaserInput; }; - this.isPointingAtTriggerable = function(controllerData, triggerPressed) { + this.isPointingAtTriggerable = function(controllerData, triggerPressed, checkEntitiesOnly) { // allow pointing at tablet, unlocked web entities, or web overlays automatically without pressing trigger, // but for pointing at locked web entities or non-web overlays user must be pressing trigger var intersection = controllerData.rayPicks[this.hand]; var objectID = intersection.objectID; - if (intersection.type === Picks.INTERSECTED_OVERLAY) { + if (intersection.type === Picks.INTERSECTED_OVERLAY && !checkEntitiesOnly) { if ((HMD.tabletID && objectID === HMD.tabletID) || (HMD.tabletScreenID && objectID === HMD.tabletScreenID) || (HMD.homeButtonID && objectID === HMD.homeButtonID)) { @@ -118,7 +118,7 @@ Script.include("/~/system/libraries/controllers.js"); controllerData.triggerValues[this.otherHand] <= TRIGGER_OFF_VALUE; var allowThisModule = !otherModuleRunning || isTriggerPressed; - if (allowThisModule && this.isPointingAtTriggerable(controllerData, isTriggerPressed)) { + if (allowThisModule && this.isPointingAtTriggerable(controllerData, isTriggerPressed, false)) { this.updateAllwaysOn(); if (isTriggerPressed) { this.dominantHandOverride = true; // Override dominant hand. @@ -141,11 +141,16 @@ Script.include("/~/system/libraries/controllers.js"); otherModuleRunning = otherModuleRunning || this.getOtherModule().dominantHandOverride; // Override dominant hand. var grabModuleNeedsToRun = this.grabModuleWantsNearbyOverlay(controllerData); // only allow for non-near grab - var allowThisModule = !otherModuleRunning && !(grabModuleNeedsToRun && controllerData.secondaryValues[this.hand] > BUMPER_ON_VALUE); + var allowThisModule = !otherModuleRunning && !grabModuleNeedsToRun; var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE; var laserOn = isTriggerPressed || this.parameters.handLaser.allwaysOn; if (allowThisModule) { - if (laserOn && this.isPointingAtTriggerable(controllerData, isTriggerPressed)) { + // if trigger is down + not pointing at a web entity, keep running web surface laser + if (isTriggerPressed && !this.isPointingAtTriggerable(controllerData, isTriggerPressed, true)) { + this.running = true; + return makeRunningValues(true, [], []); + // if trigger is down + pointing at a web entity/overlay, keep running web surface laser + } else if (laserOn && this.isPointingAtTriggerable(controllerData, isTriggerPressed, false)) { this.running = true; return makeRunningValues(true, [], []); } else { @@ -155,14 +160,11 @@ Script.include("/~/system/libraries/controllers.js"); return makeRunningValues(false, [], []); } } + // if module needs to stop from near grabs or other modules are running, stop it. this.deleteContextOverlay(); this.running = false; this.dominantHandOverride = false; this.objectID = null; - if (this.hand === LEFT_HAND) { - print("allowThisModule = " + allowThisModule); - print("isPointingAtTriggerable = " + (laserOn || this.isPointingAtTriggerable(controllerData, isTriggerPressed))); - } return makeRunningValues(false, [], []); }; } From b9f0af63e1e52837cd2e692bade3084b1c71a0c5 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Wed, 12 Sep 2018 10:38:21 -0700 Subject: [PATCH 20/24] changing check for near grabbing modules - fixes grabbing for dynamic --- .../controllerModules/webSurfaceLaserInput.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js index 3ae971cf70..bd9d5f97e4 100644 --- a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js +++ b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js @@ -49,12 +49,19 @@ Script.include("/~/system/libraries/controllers.js"); nearGrabName = this.hand === RIGHT_HAND ? "RightNearParentingGrabEntity" : "LeftNearParentingGrabEntity"; nearGrabModule = getEnabledModuleByName(nearGrabName); if (nearGrabModule && nearGrabModule.isReady(controllerData)) { - return nearGrabModule.isReady(controllerData).active; - } - nearGrabName = this.hand === RIGHT_HAND ? "RightNearActionGrabEntity" : "LeftNearActionGrabEntity"; - nearGrabModule = getEnabledModuleByName(nearGrabName); - if (nearGrabModule && nearGrabModule.isReady(controllerData)) { - return nearGrabModule.isReady(controllerData).active; + // check for if near parent module is active. + var isNearGrabModuleActive = nearGrabModule.isReady(controllerData).active; + if (isNearGrabModuleActive) { + // if true, return true. + return isNearGrabModuleActive; + } else { + // check near action grab entity as a second pass. + nearGrabName = this.hand === RIGHT_HAND ? "RightNearActionGrabEntity" : "LeftNearActionGrabEntity"; + nearGrabModule = getEnabledModuleByName(nearGrabName); + if (nearGrabModule && nearGrabModule.isReady(controllerData)) { + return nearGrabModule.isReady(controllerData).active; + } + } } } return false; From a96e78c72d1c1e6963fc992da7346c39b6cbbad6 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Wed, 12 Sep 2018 10:54:38 -0700 Subject: [PATCH 21/24] removing debug --- scripts/system/controllers/controllerDispatcher.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/controllers/controllerDispatcher.js b/scripts/system/controllers/controllerDispatcher.js index c7a8de87b9..7a916392b9 100644 --- a/scripts/system/controllers/controllerDispatcher.js +++ b/scripts/system/controllers/controllerDispatcher.js @@ -31,7 +31,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); var BASIC_TIMER_INTERVAL_MS = 1000 / TARGET_UPDATE_HZ; var PROFILE = false; - var DEBUG = true; + var DEBUG = false; if (typeof Test !== "undefined") { PROFILE = true; From 8bef0d0de4c05644e6f24ae641b85c76051f6d97 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Wed, 12 Sep 2018 10:55:40 -0700 Subject: [PATCH 22/24] removing unused variables --- .../controllers/controllerModules/webSurfaceLaserInput.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js index bd9d5f97e4..9a022409fb 100644 --- a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js +++ b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js @@ -21,10 +21,6 @@ Script.include("/~/system/libraries/controllers.js"); this.otherHand = this.hand === RIGHT_HAND ? LEFT_HAND : RIGHT_HAND; this.running = false; - // parameters for things to be working on - this.isObjectEntity = false; - this.objectID = null; - this.parameters = makeDispatcherModuleParameters( 160, this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"], @@ -133,9 +129,6 @@ Script.include("/~/system/libraries/controllers.js"); } if (this.parameters.handLaser.allwaysOn || isTriggerPressed) { var intersection = controllerData.rayPicks[this.hand]; - // the object is either an entity or an overlay. - this.isObjectEntity = (intersection.type === Picks.INTERSECTED_ENTITY); - this.objectID = intersection.objectID; return makeRunningValues(true, [], []); } } @@ -171,7 +164,6 @@ Script.include("/~/system/libraries/controllers.js"); this.deleteContextOverlay(); this.running = false; this.dominantHandOverride = false; - this.objectID = null; return makeRunningValues(false, [], []); }; } From acf34dcfdf7fff5379946f9a57d87258edf2d85b Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Wed, 12 Sep 2018 10:58:05 -0700 Subject: [PATCH 23/24] one more unused variable --- .../system/controllers/controllerModules/webSurfaceLaserInput.js | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js index 9a022409fb..45a6064d17 100644 --- a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js +++ b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js @@ -128,7 +128,6 @@ Script.include("/~/system/libraries/controllers.js"); this.getOtherModule().dominantHandOverride = false; } if (this.parameters.handLaser.allwaysOn || isTriggerPressed) { - var intersection = controllerData.rayPicks[this.hand]; return makeRunningValues(true, [], []); } } From 521361293a55643fb32eea7a7aa4cb1967864e2a Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Wed, 12 Sep 2018 11:03:00 -0700 Subject: [PATCH 24/24] moving comment locations inside conditionals --- .../controllers/controllerModules/webSurfaceLaserInput.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js index 45a6064d17..4e36355621 100644 --- a/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js +++ b/scripts/system/controllers/controllerModules/webSurfaceLaserInput.js @@ -144,12 +144,12 @@ Script.include("/~/system/libraries/controllers.js"); var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE; var laserOn = isTriggerPressed || this.parameters.handLaser.allwaysOn; if (allowThisModule) { - // if trigger is down + not pointing at a web entity, keep running web surface laser if (isTriggerPressed && !this.isPointingAtTriggerable(controllerData, isTriggerPressed, true)) { + // if trigger is down + not pointing at a web entity, keep running web surface laser this.running = true; return makeRunningValues(true, [], []); - // if trigger is down + pointing at a web entity/overlay, keep running web surface laser } else if (laserOn && this.isPointingAtTriggerable(controllerData, isTriggerPressed, false)) { + // if trigger is down + pointing at a web entity/overlay, keep running web surface laser this.running = true; return makeRunningValues(true, [], []); } else {