Add basic element of slider

This commit is contained in:
David Rowe 2017-08-09 12:06:35 +12:00
parent 28f9f9e4d0
commit c79931106d
4 changed files with 47 additions and 3 deletions

View file

@ -365,6 +365,10 @@ Selection = function (side) {
return properties.color;
}
function applyPhysics() {
// TODO
}
function clear() {
selection = [];
selectedEntityID = null;
@ -401,6 +405,7 @@ Selection = function (side) {
cloneEntities: cloneEntities,
applyColor: applyColor,
getColor: getColor,
applyPhysics: applyPhysics,
deleteEntities: deleteEntities,
clear: clear,
destroy: destroy

View file

@ -20,7 +20,8 @@ ToolIcon = function (side) {
GROUP_TOOL = 2,
COLOR_TOOL = 3,
PICK_COLOR_TOOL = 4,
DELETE_TOOL = 5,
PHYSICS_TOOL = 5,
DELETE_TOOL = 6,
ICON_COLORS = [
{ red: 0, green: 240, blue: 240 },
@ -28,6 +29,7 @@ ToolIcon = function (side) {
{ red: 220, green: 60, blue: 220 },
{ red: 220, green: 220, blue: 220 },
{ red: 0, green: 0, blue: 0 },
{ red: 60, green: 60, blue: 240 },
{ red: 240, green: 60, blue: 60 }
],
@ -114,6 +116,7 @@ ToolIcon = function (side) {
GROUP_TOOL: GROUP_TOOL,
COLOR_TOOL: COLOR_TOOL,
PICK_COLOR_TOOL: PICK_COLOR_TOOL,
PHYSICS_TOOL: PHYSICS_TOOL,
DELETE_TOOL: DELETE_TOOL,
setHand: setHand,
update: update,

View file

@ -126,6 +126,18 @@ ToolMenu = function (side, leftInputs, rightInputs, uiCommandCallback) {
ignoreRayIntersection: true,
visible: true
}
},
"slider": {
overlay: "cube",
properties: {
dimensions: { x: 0.03, y: 0.1, z: 0.01 },
localRotation: Quat.ZERO,
color: { red: 128, green: 128, blue: 255 },
alpha: 0.1,
solid: true,
ignoreRayIntersection: false,
visible: true
}
}
},
@ -298,6 +310,16 @@ ToolMenu = function (side, leftInputs, rightInputs, uiCommandCallback) {
properties: {
localPosition: { x: 0.055, y: 0.0, z: -0.005 }
}
},
{
id: "physicsSlider",
type: "slider",
properties: {
localPosition: { x: -0.02, y: 0.0, z: -0.005 }
},
callback: {
method: "setSliderValue"
}
}
]
},

View file

@ -28,7 +28,8 @@
TOOL_GROUP = 3,
TOOL_COLOR = 4,
TOOL_PICK_COLOR = 5,
TOOL_DELETE = 6,
TOOL_PHYSICS = 6,
TOOL_DELETE = 7,
toolSelected = TOOL_NONE,
colorToolColor = { red: 128, green: 128, blue: 128 },
@ -283,6 +284,7 @@
GROUP_TOOL: toolIcon.GROUP_TOOL,
COLOR_TOOL: toolIcon.COLOR_TOOL,
PICK_COLOR_TOOL: toolIcon.PICK_COLOR_TOOL,
PHYSICS_TOOL: toolIcon.PHYSICS_TOOL,
DELETE_TOOL: toolIcon.DELETE_TOOL,
display: display,
updateUIEntities: setUIEntities,
@ -882,6 +884,8 @@
toolSelected = TOOL_COLOR;
ui.setToolIcon(ui.COLOR_TOOL);
ui.setToolColor(colorToolColor);
} else if (toolSelected === TOOL_PHYSICS) {
selection.applyPhysics();
} else if (toolSelected === TOOL_DELETE) {
setState(EDITOR_HIGHLIGHTING);
selection.deleteEntities();
@ -949,6 +953,8 @@
toolSelected = TOOL_COLOR;
ui.setToolIcon(ui.COLOR_TOOL);
ui.setToolColor(colorToolColor);
} else if (toolSelected === TOOL_PHYSICS) {
selection.applyPhysics();
} else if (toolSelected === TOOL_DELETE) {
selection.deleteEntities();
setState(EDITOR_SEARCHING);
@ -1308,6 +1314,11 @@
ui.setToolIcon(ui.PICK_COLOR_TOOL);
ui.updateUIEntities();
break;
case "physicsTool":
toolSelected = TOOL_PHYSICS;
ui.setToolIcon(ui.PHYSICS_TOOL);
ui.updateUIEntities();
break;
case "deleteTool":
grouping.clear();
toolSelected = TOOL_DELETE;
@ -1332,8 +1343,11 @@
editors[LEFT_HAND].enableAutoGrab();
editors[RIGHT_HAND].enableAutoGrab();
break;
case "setSliderValue":
print("$$$$$$$ setSliderValue = " + JSON.stringify(parameter));
break;
default:
debug("ERROR: Unexpected command in onUICommand()!");
debug("ERROR: Unexpected command in onUICommand()! " + command);
}
}