diff --git a/scripts/vr-edit/modules/hand.js b/scripts/vr-edit/modules/hand.js index c4f5a6efc9..48e44069ed 100644 --- a/scripts/vr-edit/modules/hand.js +++ b/scripts/vr-edit/modules/hand.js @@ -28,6 +28,7 @@ Hand = function (side) { isTriggerClicked, TRIGGER_ON_VALUE = 0.15, // Per handControllerGrab.js. TRIGGER_OFF_VALUE = 0.1, // Per handControllerGrab.js. + TRIGGER_CLICKED_VALUE = 1.0, NEAR_GRAB_RADIUS = 0.1, // Per handControllerGrab.js. NEAR_HOVER_RADIUS = 0.025, @@ -108,7 +109,7 @@ Hand = function (side) { // Controller trigger. isTriggerPressed = Controller.getValue(controllerTrigger) > (isTriggerPressed ? TRIGGER_OFF_VALUE : TRIGGER_ON_VALUE); - isTriggerClicked = Controller.getValue(controllerTriggerClicked); + isTriggerClicked = Controller.getValue(controllerTriggerClicked) === TRIGGER_CLICKED_VALUE; // Controller grip. gripValue = Controller.getValue(controllerGrip); diff --git a/scripts/vr-edit/modules/toolMenu.js b/scripts/vr-edit/modules/toolMenu.js index 2ffb044e3a..089fb3f3e3 100644 --- a/scripts/vr-edit/modules/toolMenu.js +++ b/scripts/vr-edit/modules/toolMenu.js @@ -70,12 +70,25 @@ ToolMenu = function (side, scaleModeChangedCallback) { isDisplaying = false, isHighlightingButton = false, + isButtonPressed = false, SCALE_MODE_DIRECT = 0, - SCALE_MODE_HANDLES = 1; + SCALE_MODE_HANDLES = 1, - function setHand(hand) { - side = hand; + // References. + leftInputs, + rightInputs, + controlHand; + + function setReferences(left, right) { + leftInputs = left; + rightInputs = right; + controlHand = side === LEFT_HAND ? rightInputs.hand() : leftInputs.hand(); + } + + function setHand(uiSide) { + side = uiSide; + controlHand = side === LEFT_HAND ? rightInputs.hand() : leftInputs.hand(); if (isDisplaying) { // TODO: Move UI to other hand. @@ -92,6 +105,11 @@ ToolMenu = function (side, scaleModeChangedCallback) { isHighlightingButton = !isHighlightingButton; Overlays.editOverlay(buttonHighlightOverlay, { visible: isHighlightingButton }); } + + // Button click. + if (isHighlightingButton && controlHand.triggerClicked() !== isButtonPressed) { + isButtonPressed = controlHand.triggerClicked(); + } } function display() { @@ -153,6 +171,7 @@ ToolMenu = function (side, scaleModeChangedCallback) { } return { + setReferences: setReferences, setHand: setHand, getEntityIDs: getEntityIDs, update: update, diff --git a/scripts/vr-edit/vr-edit.js b/scripts/vr-edit/vr-edit.js index 7cff8fc9f6..c8fa86fcad 100644 --- a/scripts/vr-edit/vr-edit.js +++ b/scripts/vr-edit/vr-edit.js @@ -155,7 +155,7 @@ }; - UI = function (side) { + UI = function (side, setAppScaleWithHandlesCallback) { // Tool menu and Create palette. var // Primary objects. @@ -170,13 +170,15 @@ getIntersection, // Function. intersection; - toolMenu = new ToolMenu(side); + toolMenu = new ToolMenu(side, setAppScaleWithHandlesCallback); function setReferences(left, right) { leftInputs = left; rightInputs = right; getIntersection = side === LEFT_HAND ? rightInputs.getIntersection : leftInputs.getIntersection; + + toolMenu.setReferences(left, right); } function setHand(side) { @@ -959,6 +961,10 @@ Settings.setValue(VR_EDIT_SETTING, isAppActive); } + function setAppScaleWithHandles(appScaleWithHandles) { + isAppScaleWithHandles = appScaleWithHandles; + } + function onAppButtonClicked() { // Application tablet/toolbar button clicked. isAppActive = !isAppActive; @@ -1023,7 +1029,7 @@ inputs[RIGHT_HAND] = new Inputs(RIGHT_HAND); // UI object. - ui = new UI(otherHand(dominantHand)); + ui = new UI(otherHand(dominantHand), setAppScaleWithHandles); ui.setReferences(inputs[LEFT_HAND], inputs[RIGHT_HAND]); // Editor objects.