From 82e5d6ad29693b278c9f003d604c27e925ebab14 Mon Sep 17 00:00:00 2001 From: David Back Date: Thu, 26 Jul 2018 16:38:25 -0700 Subject: [PATCH] use triggerClicks from controllers for edit handles --- .../controllerModules/inEditMode.js | 11 +++++++++++ .../system/libraries/entitySelectionTool.js | 18 +++++++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/scripts/system/controllers/controllerModules/inEditMode.js b/scripts/system/controllers/controllerModules/inEditMode.js index 377167d7bf..e9b83bbcbb 100644 --- a/scripts/system/controllers/controllerModules/inEditMode.js +++ b/scripts/system/controllers/controllerModules/inEditMode.js @@ -73,6 +73,9 @@ Script.include("/~/system/libraries/utils.js"); method: "clearSelection" })); } + Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({ + method: "triggerClicked" + })); } if (this.selectedTarget.type === Picks.INTERSECTED_ENTITY) { if (!this.isTabletMaterialEntity(this.selectedTarget.objectID)) { @@ -89,6 +92,14 @@ Script.include("/~/system/libraries/utils.js"); } this.triggerClicked = true; + } else { + if (this.triggerClicked) { + Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({ + method: "triggerUnClicked" + })); + } + + this.triggerClicked = false; } this.sendPointingAtData(controllerData); diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 091d431502..4a5eb9afca 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -14,13 +14,14 @@ // /* global SelectionManager, SelectionDisplay, grid, rayPlaneIntersection, rayPlaneIntersection2, pushCommandForSelections, - getMainTabletIDs, getControllerWorldLocation */ + getMainTabletIDs, getControllerWorldLocation, TRIGGER_ON_VALUE, TRIGGER_OFF_VALUE */ var SPACE_LOCAL = "local"; var SPACE_WORLD = "world"; var HIGHLIGHT_LIST_NAME = "editHandleHighlightList"; Script.include([ + "./controllerDispatcherUtils.js", "./controllers.js", "./utils.js" ]); @@ -67,6 +68,10 @@ SelectionManager = (function() { that.pointingAtDesktopWindowLeft = messageParsed.desktopWindow; that.pointingAtTabletLeft = messageParsed.tablet; } + } else if (messageParsed.method === "triggerClicked") { + that.triggerClicked = true; + } else if (messageParsed.method === "triggerUnClicked") { + that.triggerClicked = false; } } @@ -109,6 +114,8 @@ SelectionManager = (function() { that.pointingAtDesktopWindowRight = false; that.pointingAtTabletLeft = false; that.pointingAtTabletRight = false; + + that.triggerClicked = false; that.saveProperties = function() { that.savedProperties = {}; @@ -751,14 +758,11 @@ SelectionDisplay = (function() { // But we dont' get mousePressEvents. that.triggerMapping = Controller.newMapping(Script.resolvePath('') + '-click'); Script.scriptEnding.connect(that.triggerMapping.disable); - that.TRIGGER_GRAB_VALUE = 0.85; // From handControllerGrab/Pointer.js. Should refactor. - that.TRIGGER_ON_VALUE = 0.4; - that.TRIGGER_OFF_VALUE = 0.15; that.triggered = false; var activeHand = Controller.Standard.RightHand; function makeTriggerHandler(hand) { - return function (value) { - if (!that.triggered && (value > that.TRIGGER_GRAB_VALUE)) { // should we smooth? + return function () { + if (!that.triggered && SelectionManager.triggerClicked) { that.triggered = true; if (activeHand !== hand) { // No switching while the other is already triggered, so no need to release. @@ -775,7 +779,7 @@ SelectionDisplay = (function() { return; } that.mousePressEvent({}); - } else if (that.triggered && (value < that.TRIGGER_OFF_VALUE)) { + } else if (that.triggered && !SelectionManager.triggerClicked) { that.triggered = false; that.mouseReleaseEvent({}); }