use triggerClicks from controllers for edit handles

This commit is contained in:
David Back 2018-07-26 16:38:25 -07:00
parent 6c92949aed
commit 82e5d6ad29
2 changed files with 22 additions and 7 deletions

View file

@ -73,6 +73,9 @@ Script.include("/~/system/libraries/utils.js");
method: "clearSelection" method: "clearSelection"
})); }));
} }
Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({
method: "triggerClicked"
}));
} }
if (this.selectedTarget.type === Picks.INTERSECTED_ENTITY) { if (this.selectedTarget.type === Picks.INTERSECTED_ENTITY) {
if (!this.isTabletMaterialEntity(this.selectedTarget.objectID)) { if (!this.isTabletMaterialEntity(this.selectedTarget.objectID)) {
@ -89,6 +92,14 @@ Script.include("/~/system/libraries/utils.js");
} }
this.triggerClicked = true; this.triggerClicked = true;
} else {
if (this.triggerClicked) {
Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({
method: "triggerUnClicked"
}));
}
this.triggerClicked = false;
} }
this.sendPointingAtData(controllerData); this.sendPointingAtData(controllerData);

View file

@ -14,13 +14,14 @@
// //
/* global SelectionManager, SelectionDisplay, grid, rayPlaneIntersection, rayPlaneIntersection2, pushCommandForSelections, /* global SelectionManager, SelectionDisplay, grid, rayPlaneIntersection, rayPlaneIntersection2, pushCommandForSelections,
getMainTabletIDs, getControllerWorldLocation */ getMainTabletIDs, getControllerWorldLocation, TRIGGER_ON_VALUE, TRIGGER_OFF_VALUE */
var SPACE_LOCAL = "local"; var SPACE_LOCAL = "local";
var SPACE_WORLD = "world"; var SPACE_WORLD = "world";
var HIGHLIGHT_LIST_NAME = "editHandleHighlightList"; var HIGHLIGHT_LIST_NAME = "editHandleHighlightList";
Script.include([ Script.include([
"./controllerDispatcherUtils.js",
"./controllers.js", "./controllers.js",
"./utils.js" "./utils.js"
]); ]);
@ -67,6 +68,10 @@ SelectionManager = (function() {
that.pointingAtDesktopWindowLeft = messageParsed.desktopWindow; that.pointingAtDesktopWindowLeft = messageParsed.desktopWindow;
that.pointingAtTabletLeft = messageParsed.tablet; that.pointingAtTabletLeft = messageParsed.tablet;
} }
} else if (messageParsed.method === "triggerClicked") {
that.triggerClicked = true;
} else if (messageParsed.method === "triggerUnClicked") {
that.triggerClicked = false;
} }
} }
@ -110,6 +115,8 @@ SelectionManager = (function() {
that.pointingAtTabletLeft = false; that.pointingAtTabletLeft = false;
that.pointingAtTabletRight = false; that.pointingAtTabletRight = false;
that.triggerClicked = false;
that.saveProperties = function() { that.saveProperties = function() {
that.savedProperties = {}; that.savedProperties = {};
for (var i = 0; i < that.selections.length; i++) { for (var i = 0; i < that.selections.length; i++) {
@ -751,14 +758,11 @@ SelectionDisplay = (function() {
// But we dont' get mousePressEvents. // But we dont' get mousePressEvents.
that.triggerMapping = Controller.newMapping(Script.resolvePath('') + '-click'); that.triggerMapping = Controller.newMapping(Script.resolvePath('') + '-click');
Script.scriptEnding.connect(that.triggerMapping.disable); 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; that.triggered = false;
var activeHand = Controller.Standard.RightHand; var activeHand = Controller.Standard.RightHand;
function makeTriggerHandler(hand) { function makeTriggerHandler(hand) {
return function (value) { return function () {
if (!that.triggered && (value > that.TRIGGER_GRAB_VALUE)) { // should we smooth? if (!that.triggered && SelectionManager.triggerClicked) {
that.triggered = true; that.triggered = true;
if (activeHand !== hand) { if (activeHand !== hand) {
// No switching while the other is already triggered, so no need to release. // No switching while the other is already triggered, so no need to release.
@ -775,7 +779,7 @@ SelectionDisplay = (function() {
return; return;
} }
that.mousePressEvent({}); that.mousePressEvent({});
} else if (that.triggered && (value < that.TRIGGER_OFF_VALUE)) { } else if (that.triggered && !SelectionManager.triggerClicked) {
that.triggered = false; that.triggered = false;
that.mouseReleaseEvent({}); that.mouseReleaseEvent({});
} }