mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 10:37:56 +02:00
Clear swatch with grip click
This commit is contained in:
parent
f88191b7b3
commit
0b8ea29193
2 changed files with 62 additions and 7 deletions
|
@ -21,6 +21,7 @@ Hand = function (side) {
|
||||||
controllerGrip,
|
controllerGrip,
|
||||||
|
|
||||||
isGripClicked = false,
|
isGripClicked = false,
|
||||||
|
isGripClickedHandled = false,
|
||||||
GRIP_ON_VALUE = 0.99,
|
GRIP_ON_VALUE = 0.99,
|
||||||
GRIP_OFF_VALUE = 0.95,
|
GRIP_OFF_VALUE = 0.95,
|
||||||
|
|
||||||
|
@ -87,6 +88,11 @@ Hand = function (side) {
|
||||||
return isGripClicked;
|
return isGripClicked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setGripClickedHandled() {
|
||||||
|
isGripClicked = false;
|
||||||
|
isGripClickedHandled = true;
|
||||||
|
}
|
||||||
|
|
||||||
function getIntersection() {
|
function getIntersection() {
|
||||||
return intersection;
|
return intersection;
|
||||||
}
|
}
|
||||||
|
@ -126,6 +132,12 @@ Hand = function (side) {
|
||||||
} else {
|
} else {
|
||||||
isGripClicked = gripValue > GRIP_ON_VALUE;
|
isGripClicked = gripValue > GRIP_ON_VALUE;
|
||||||
}
|
}
|
||||||
|
// Grip clicked may be being handled by UI.
|
||||||
|
if (isGripClicked) {
|
||||||
|
isGripClicked = !isGripClickedHandled;
|
||||||
|
} else {
|
||||||
|
isGripClickedHandled = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Hand-overlay intersection, if any.
|
// Hand-overlay intersection, if any.
|
||||||
overlayID = null;
|
overlayID = null;
|
||||||
|
@ -199,6 +211,7 @@ Hand = function (side) {
|
||||||
triggerPressed: triggerPressed,
|
triggerPressed: triggerPressed,
|
||||||
triggerClicked: triggerClicked,
|
triggerClicked: triggerClicked,
|
||||||
gripClicked: gripClicked,
|
gripClicked: gripClicked,
|
||||||
|
setGripClickedHandled: setGripClickedHandled,
|
||||||
intersection: getIntersection,
|
intersection: getIntersection,
|
||||||
update: update,
|
update: update,
|
||||||
clear: clear,
|
clear: clear,
|
||||||
|
|
|
@ -58,6 +58,8 @@ ToolMenu = function (side, leftInputs, rightInputs, doCallback) {
|
||||||
visible: true
|
visible: true
|
||||||
},
|
},
|
||||||
|
|
||||||
|
NO_SWATCH_COLOR = { red: 128, green: 128, blue: 128 },
|
||||||
|
|
||||||
UI_ELEMENTS = {
|
UI_ELEMENTS = {
|
||||||
"panel": {
|
"panel": {
|
||||||
overlay: "cube",
|
overlay: "cube",
|
||||||
|
@ -87,8 +89,9 @@ ToolMenu = function (side, leftInputs, rightInputs, doCallback) {
|
||||||
properties: {
|
properties: {
|
||||||
dimensions: { x: 0.03, y: 0.03, z: 0.01 },
|
dimensions: { x: 0.03, y: 0.03, z: 0.01 },
|
||||||
localRotation: Quat.ZERO,
|
localRotation: Quat.ZERO,
|
||||||
|
color: NO_SWATCH_COLOR,
|
||||||
alpha: 1.0,
|
alpha: 1.0,
|
||||||
solid: false, // False indicates "no color assigned"
|
solid: false, // False indicates "no swatch color assigned"
|
||||||
ignoreRayIntersection: false,
|
ignoreRayIntersection: false,
|
||||||
visible: true
|
visible: true
|
||||||
}
|
}
|
||||||
|
@ -184,6 +187,10 @@ ToolMenu = function (side, leftInputs, rightInputs, doCallback) {
|
||||||
command: {
|
command: {
|
||||||
method: "setColorPerSwatch",
|
method: "setColorPerSwatch",
|
||||||
parameter: "colorSwatch1.color"
|
parameter: "colorSwatch1.color"
|
||||||
|
},
|
||||||
|
onGripClicked: {
|
||||||
|
method: "clearSwatch",
|
||||||
|
parameter: "colorSwatch1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -198,6 +205,10 @@ ToolMenu = function (side, leftInputs, rightInputs, doCallback) {
|
||||||
command: {
|
command: {
|
||||||
method: "setColorPerSwatch",
|
method: "setColorPerSwatch",
|
||||||
parameter: "colorSwatch2.color"
|
parameter: "colorSwatch2.color"
|
||||||
|
},
|
||||||
|
onGripClicked: {
|
||||||
|
method: "clearSwatch",
|
||||||
|
parameter: "colorSwatch2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -205,13 +216,15 @@ ToolMenu = function (side, leftInputs, rightInputs, doCallback) {
|
||||||
type: "swatch",
|
type: "swatch",
|
||||||
properties: {
|
properties: {
|
||||||
dimensions: { x: 0.02, y: 0.02, z: 0.01 },
|
dimensions: { x: 0.02, y: 0.02, z: 0.01 },
|
||||||
localPosition: { x: -0.035, y: 0.045, z: -0.005 },
|
localPosition: { x: -0.035, y: 0.045, z: -0.005 }
|
||||||
color: { red: 128, green: 128, blue: 128 },
|
|
||||||
solid: false
|
|
||||||
},
|
},
|
||||||
command: {
|
command: {
|
||||||
method: "setColorPerSwatch",
|
method: "setColorPerSwatch",
|
||||||
parameter: "colorSwatch3.color"
|
parameter: "colorSwatch3.color"
|
||||||
|
},
|
||||||
|
onGripClicked: {
|
||||||
|
method: "clearSwatch",
|
||||||
|
parameter: "colorSwatch3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -219,13 +232,15 @@ ToolMenu = function (side, leftInputs, rightInputs, doCallback) {
|
||||||
type: "swatch",
|
type: "swatch",
|
||||||
properties: {
|
properties: {
|
||||||
dimensions: { x: 0.02, y: 0.02, z: 0.01 },
|
dimensions: { x: 0.02, y: 0.02, z: 0.01 },
|
||||||
localPosition: { x: -0.01, y: 0.045, z: -0.005 },
|
localPosition: { x: -0.01, y: 0.045, z: -0.005 }
|
||||||
color: { red: 128, green: 128, blue: 128 },
|
|
||||||
solid: false
|
|
||||||
},
|
},
|
||||||
command: {
|
command: {
|
||||||
method: "setColorPerSwatch",
|
method: "setColorPerSwatch",
|
||||||
parameter: "colorSwatch4.color"
|
parameter: "colorSwatch4.color"
|
||||||
|
},
|
||||||
|
onGripClicked: {
|
||||||
|
method: "clearSwatch",
|
||||||
|
parameter: "colorSwatch4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -356,6 +371,7 @@ ToolMenu = function (side, leftInputs, rightInputs, doCallback) {
|
||||||
pressedItem = null,
|
pressedItem = null,
|
||||||
pressedSource,
|
pressedSource,
|
||||||
isButtonPressed,
|
isButtonPressed,
|
||||||
|
isGripClicked,
|
||||||
|
|
||||||
isGroupButtonEnabled,
|
isGroupButtonEnabled,
|
||||||
isUngroupButtonEnabled,
|
isUngroupButtonEnabled,
|
||||||
|
@ -501,6 +517,19 @@ ToolMenu = function (side, leftInputs, rightInputs, doCallback) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function doGripClicked(command, parameter) {
|
||||||
|
switch (command) {
|
||||||
|
case "clearSwatch":
|
||||||
|
Overlays.editOverlay(optionsOverlays[optionsOverlaysIDs.indexOf(parameter)], {
|
||||||
|
color: NO_SWATCH_COLOR,
|
||||||
|
solid: false
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// TODO: Log error.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function update(intersectionOverlayID, groupsCount, entitiesCount) {
|
function update(intersectionOverlayID, groupsCount, entitiesCount) {
|
||||||
var intersectedItem = -1,
|
var intersectedItem = -1,
|
||||||
intersectionItems,
|
intersectionItems,
|
||||||
|
@ -606,6 +635,18 @@ ToolMenu = function (side, leftInputs, rightInputs, doCallback) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Grip click.
|
||||||
|
if (controlHand.gripClicked() !== isGripClicked) {
|
||||||
|
isGripClicked = !isGripClicked;
|
||||||
|
if (isGripClicked && intersectionItems && intersectedItem && intersectionItems[intersectedItem].onGripClicked) {
|
||||||
|
controlHand.setGripClickedHandled();
|
||||||
|
if (intersectionItems[intersectedItem].onGripClicked.parameter) {
|
||||||
|
parameter = intersectionItems[intersectedItem].onGripClicked.parameter;
|
||||||
|
}
|
||||||
|
doGripClicked(intersectionItems[intersectedItem].onGripClicked.method, parameter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Special handling for Group options.
|
// Special handling for Group options.
|
||||||
if (optionsItems && optionsItems === OPTONS_PANELS.groupOptions) {
|
if (optionsItems && optionsItems === OPTONS_PANELS.groupOptions) {
|
||||||
enableGroupButton = groupsCount > 1;
|
enableGroupButton = groupsCount > 1;
|
||||||
|
@ -696,6 +737,7 @@ ToolMenu = function (side, leftInputs, rightInputs, doCallback) {
|
||||||
pressedItem = null;
|
pressedItem = null;
|
||||||
pressedSource = null;
|
pressedSource = null;
|
||||||
isButtonPressed = false;
|
isButtonPressed = false;
|
||||||
|
isGripClicked = false;
|
||||||
isGroupButtonEnabled = false;
|
isGroupButtonEnabled = false;
|
||||||
isUngroupButtonEnabled = false;
|
isUngroupButtonEnabled = false;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue