From 0eceb7b382425c897657cf7e7a3b978bc162051c Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Fri, 25 Aug 2017 17:40:30 -0700 Subject: [PATCH] unviersial web3d vs laser --- .../controllers/controllerDispatcher.js | 12 ++++++ .../controllerModules/farActionGrabEntity.js | 13 ++++--- ...aserInput.js => web3DOverlayLaserInput.js} | 38 +++++++------------ .../system/controllers/controllerScripts.js | 2 +- 4 files changed, 33 insertions(+), 32 deletions(-) rename scripts/system/controllers/controllerModules/{tabletLaserInput.js => web3DOverlayLaserInput.js} (93%) diff --git a/scripts/system/controllers/controllerDispatcher.js b/scripts/system/controllers/controllerDispatcher.js index b5681fef3f..18b4c287c0 100644 --- a/scripts/system/controllers/controllerDispatcher.js +++ b/scripts/system/controllers/controllerDispatcher.js @@ -33,6 +33,7 @@ Script.include("/~/system/controllers/controllerDispatcherUtils.js"); var totalVariance = 0; var highVarianceCount = 0; var veryhighVarianceCount = 0; + this.tabletID = 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 @@ -126,8 +127,17 @@ Script.include("/~/system/controllers/controllerDispatcherUtils.js"); return deltaTime; }; + this.setIgnoreTablet = function() { + if (HMD.tabletID !== _this.tabletID) { + RayPick.setIgnoreOverlays(_this.leftControllerRayPick, [HMD.tabletID]); + RayPick.setIgnoreOverlays(_this.rightControllerRayPick, [HMD.tabletID]); + tabletIgnored = true + } + } + this.update = function () { var deltaTime = this.updateTimings(); + this.setIgnoreTablet() if (controllerDispatcherPluginsNeedSort) { this.orderedPluginNames = []; @@ -336,6 +346,8 @@ Script.include("/~/system/controllers/controllerDispatcherUtils.js"); }); + + this.cleanup = function () { Script.update.disconnect(_this.update); Controller.disableMapping(MAPPING_NAME); diff --git a/scripts/system/controllers/controllerModules/farActionGrabEntity.js b/scripts/system/controllers/controllerModules/farActionGrabEntity.js index 3c8fba6c24..44bb500605 100644 --- a/scripts/system/controllers/controllerModules/farActionGrabEntity.js +++ b/scripts/system/controllers/controllerModules/farActionGrabEntity.js @@ -317,17 +317,18 @@ Script.include("/~/system/libraries/controllers.js"); this.grabbedThingID = null; }; - this.pointingOnTablet = function(controllerData) { - var target = controllerData.rayPicks[this.hand].objectID; - - if (target === HMD.homeButtonID || target === HMD.tabletScreenID) { + this.pointingAtWebOverlay = function(controllerData) { + var intersection = controllerData.rayPicks[this.hand]; + var overlayType = Overlays.getOverlayType(intersection.objectID); + print(JSON.stringify(Entities.getEntityProperties(intersection.objectID))); + if ((intersection.type === RayPick.INTERSECTED_OVERLAY && overlayType === "web3d") || intersection.objectID === HMD.tabletButtonID) { return true; } return false }; this.isReady = function (controllerData) { - if (this.pointingOnTablet(controllerData)) { + if (this.pointingAtWebOverlay(controllerData)) { return makeRunningValues(false, [], []); } @@ -343,7 +344,7 @@ Script.include("/~/system/libraries/controllers.js"); }; this.run = function (controllerData) { - if (controllerData.triggerValues[this.hand] < TRIGGER_OFF_VALUE || this.pointingOnTablet(controllerData)) { + if (controllerData.triggerValues[this.hand] < TRIGGER_OFF_VALUE || this.pointingAtWebOverlay(controllerData)) { this.endNearGrabAction(); this.laserPointerOff(); return makeRunningValues(false, [], []); diff --git a/scripts/system/controllers/controllerModules/tabletLaserInput.js b/scripts/system/controllers/controllerModules/web3DOverlayLaserInput.js similarity index 93% rename from scripts/system/controllers/controllerModules/tabletLaserInput.js rename to scripts/system/controllers/controllerModules/web3DOverlayLaserInput.js index 27bfae9b2e..501c37fd35 100644 --- a/scripts/system/controllers/controllerModules/tabletLaserInput.js +++ b/scripts/system/controllers/controllerModules/web3DOverlayLaserInput.js @@ -275,7 +275,7 @@ Script.include("/~/system/libraries/controllers.js"); this.active = false; this.previousLaserClikcedTarget = false; this.laserPressingTarget = false; - this.tabletScreenID = HMD.tabletScreenID; + this.tabletScreenID = null; this.mode = "none"; this.laserTargetID = null; this.laserTarget = null; @@ -361,9 +361,10 @@ Script.include("/~/system/libraries/controllers.js"); }; this.hovering = function() { - if (this.hasTouchFocus(this.laserTargetID)) { - sendHoverOverEventToLaserTarget(this.hand, this.laserTarget); + if (!laserTargetHasKeyboardFocus(this.laserTagetID)) { + setKeyboardFocusOnLaserTarget(this.laserTargetID); } + sendHoverOverEventToLaserTarget(this.hand, this.laserTarget); }; this.laserPressEnter = function () { @@ -412,33 +413,21 @@ Script.include("/~/system/libraries/controllers.js"); } }; - this.pointingAtTablet = function(target) { - return (target === HMD.tabletID); - }; - - this.pointingAtTabletScreen = function(target) { - return (target === HMD.tabletScreenID); - } - - this.pointingAtHomeButton = function(target) { - return (target === HMD.homeButtonID); - } - this.releaseTouchEvent = function() { sendTouchEndEventToLaserTarget(this.hand, this.pressEnterLaserTarget); } - this.updateLaserTargets = function() { - var intersection = LaserPointers.getPrevRayPickResult(this.laserPointer); + this.updateLaserTargets = function(controllerData) { + var intersection = controllerData.rayPicks[this.hand]; this.laserTargetID = intersection.objectID; this.laserTarget = calculateLaserTargetFromOverlay(intersection.intersection, intersection.objectID); }; this.shouldExit = function(controllerData) { - var target = controllerData.rayPicks[this.hand].objectID; - var isLaserOffTablet = (!this.pointingAtTabletScreen(target) && !this.pointingAtHomeButton(target) && !this.pointingAtTablet(target)); - return isLaserOffTablet; + var intersection = controllerData.rayPicks[this.hand]; + var offOverlay = (intersection.type !== RayPick.INTERSECTED_OVERLAY) + return offOverlay; } this.exitModule = function() { @@ -461,10 +450,9 @@ Script.include("/~/system/libraries/controllers.js"); }; this.isReady = function (controllerData) { - var target = controllerData.rayPicks[this.hand].objectID; - if (this.pointingAtTabletScreen(target) || this.pointingAtHomeButton(target) || this.pointingAtTablet(target)) { + var intersection = controllerData.rayPicks[this.hand]; + if (intersection.type === RayPick.INTERSECTED_OVERLAY) { if (controllerData.triggerValues[this.hand] > TRIGGER_ON_VALUE && !this.getOtherModule().active) { - this.tabletScrenID = HMD.tabletScreenID; this.active = true; return makeRunningValues(true, [], []); } @@ -480,7 +468,7 @@ Script.include("/~/system/libraries/controllers.js"); return makeRunningValues(false, [], []); } - this.updateLaserTargets(); + this.updateLaserTargets(controllerData); this.processControllerTriggers(controllerData); this.updateLaserPointer(controllerData); @@ -511,7 +499,7 @@ Script.include("/~/system/libraries/controllers.js"); this.halfEnd = halfEnd; this.fullEnd = fullEnd; this.laserPointer = LaserPointers.createLaserPointer({ - joint: (this.hand == RIGHT_HAND) ? "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND" : "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND", + joint: (this.hand == RIGHT_HAND) ? "_CONTROLLER_RIGHTHAND" : "_CONTROLLER_LEFTHAND", filter: RayPick.PICK_OVERLAYS, maxDistance: PICK_MAX_DISTANCE, posOffset: getGrabPointSphereOffset(this.handToController()), diff --git a/scripts/system/controllers/controllerScripts.js b/scripts/system/controllers/controllerScripts.js index 65d63b7bec..9e6fd0c745 100644 --- a/scripts/system/controllers/controllerScripts.js +++ b/scripts/system/controllers/controllerScripts.js @@ -26,7 +26,7 @@ var CONTOLLER_SCRIPTS = [ "controllerModules/equipEntity.js", "controllerModules/nearTrigger.js", "controllerModules/cloneEntity.js", - "controllerModules/tabletLaserInput.js", + "controllerModules/web3DOverlayLaserInput.js", "teleport.js" ];