mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 19:53:11 +02:00
Detect button press
This commit is contained in:
parent
3566609173
commit
d4b872d9e1
3 changed files with 33 additions and 7 deletions
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue