Apply color to entities when click them

This commit is contained in:
David Rowe 2017-08-04 18:07:42 +12:00
parent 75b481adab
commit ceba5769e0
2 changed files with 14 additions and 4 deletions

View file

@ -327,6 +327,15 @@ Selection = function (side) {
rootEntityID = selection[0].id;
}
function applyColor(color) {
// Entities without a color property simply ignore the edit.
for (i = 0, length = selection.length; i < length; i += 1) {
Entities.editEntity(selection[i].id, {
color: color
});
}
}
function clear() {
selection = [];
selectedEntityID = null;
@ -361,6 +370,7 @@ Selection = function (side) {
finishHandleScaling: finishHandleScaling,
finishEditing: finishEditing,
cloneEntities: cloneEntities,
applyColor: applyColor,
deleteEntities: deleteEntities,
clear: clear,
destroy: destroy

View file

@ -29,6 +29,7 @@
TOOL_COLOR = 4,
TOOL_DELETE = 5,
toolSelected = TOOL_NONE,
colorToolColor = { red: 128, green: 128, blue: 128 },
// Primary objects
Inputs,
@ -854,8 +855,7 @@
} else if (toolSelected === TOOL_GROUP) {
setState(EDITOR_GROUPING);
} else if (toolSelected === TOOL_COLOR) {
// TODO
print("$$$$$$$ apply color");
selection.applyColor(colorToolColor);
} else if (toolSelected === TOOL_DELETE) {
setState(EDITOR_HIGHLIGHTING);
selection.deleteEntities();
@ -912,8 +912,7 @@
} else if (toolSelected === TOOL_GROUP) {
setState(EDITOR_GROUPING);
} else if (toolSelected === TOOL_COLOR) {
// TODO
print("$$$$$$$ apply color");
selection.applyColor(colorToolColor);
} else if (toolSelected === TOOL_DELETE) {
selection.deleteEntities();
setState(EDITOR_SEARCHING);
@ -1278,6 +1277,7 @@
break;
case "setColor":
ui.setToolColor(parameter);
colorToolColor = parameter;
break;
default:
debug("ERROR: Unexpected command in onUICommand()!");