add text entity editing to editModels and entityPropertyDialogBox

This commit is contained in:
ZappoMan 2014-11-14 16:28:47 -08:00
parent dd349ebfd1
commit 9657e7a469
2 changed files with 75 additions and 0 deletions

View file

@ -48,6 +48,9 @@ var RIGHT = 1;
var SPAWN_DISTANCE = 1;
var DEFAULT_DIMENSION = 0.20;
var DEFAULT_TEXT_DIMENSION_X = 1.0;
var DEFAULT_TEXT_DIMENSION_Y = 1.0;
var DEFAULT_TEXT_DIMENSION_Z = 0.01;
var modelURLs = [
HIFI_PUBLIC_BUCKET + "models/entities/2-Terrain:%20Alder.fbx",
@ -1122,6 +1125,7 @@ var toolBar = (function () {
newModelButton,
newCubeButton,
newSphereButton,
newTextButton,
browseModelsButton,
loadURLMenuItem,
loadFileMenuItem,
@ -1208,6 +1212,18 @@ var toolBar = (function () {
alpha: 0.9,
visible: true
});
print(toolIconUrl + "add-text.svg");
newTextButton = toolBar.addTool({
imageURL: toolIconUrl + "add-text.svg",
subImage: { x: 0, y: Tool.IMAGE_WIDTH, width: Tool.IMAGE_WIDTH, height: Tool.IMAGE_HEIGHT },
width: toolWidth,
height: toolHeight,
alpha: 0.9,
visible: true
});
}
@ -1372,6 +1388,25 @@ var toolBar = (function () {
}
if (newTextButton === toolBar.clicked(clickedOverlay)) {
var position = Vec3.sum(MyAvatar.position, Vec3.multiply(Quat.getFront(MyAvatar.orientation), SPAWN_DISTANCE));
if (position.x > 0 && position.y > 0 && position.z > 0) {
Entities.addEntity({
type: "Text",
position: position,
dimensions: { x: DEFAULT_TEXT_DIMENSION_X, y: DEFAULT_TEXT_DIMENSION_Y, z: DEFAULT_TEXT_DIMENSION_Z },
backgroundColor: { red: 255, green: 0, blue: 0 },
textColor: { red: 255, green: 255, blue: 255 },
text: "some text",
lineHight: "0.1"
});
} else {
print("Can't create box: Text would be out of bounds.");
}
return true;
}
return false;
};

View file

@ -65,6 +65,30 @@ EntityPropertyDialogBox = (function () {
array.push({ label: "Original Textures:\n" + properties.originalTextures, type: "header" });
index++;
}
if (properties.type == "Text") {
array.push({ label: "Text:", value: properties.text });
index++;
array.push({ label: "Line Height:", value: properties.lineHeight });
index++;
array.push({ label: "Text Color:", type: "header" });
index++;
array.push({ label: "Red:", value: properties.textColor.red });
index++;
array.push({ label: "Green:", value: properties.textColor.green });
index++;
array.push({ label: "Blue:", value: properties.textColor.blue });
index++;
array.push({ label: "Background Color:", type: "header" });
index++;
array.push({ label: "Red:", value: properties.backgroundColor.red });
index++;
array.push({ label: "Green:", value: properties.backgroundColor.green });
index++;
array.push({ label: "Blue:", value: properties.backgroundColor.blue });
index++;
}
array.push({ label: "Position:", type: "header" });
index++;
array.push({ label: "X:", value: properties.position.x.toFixed(decimals) });
@ -271,6 +295,22 @@ EntityPropertyDialogBox = (function () {
properties.textures = array[index++].value;
index++; // skip textureNames label
}
if (properties.type == "Text") {
properties.text = array[index++].value;
properties.lineHeight = array[index++].value;
index++; // skip header
properties.textColor.red = array[index++].value;
properties.textColor.green = array[index++].value;
properties.textColor.blue = array[index++].value;
index++; // skip header
properties.backgroundColor.red = array[index++].value;
properties.backgroundColor.green = array[index++].value;
properties.backgroundColor.blue = array[index++].value;
}
index++; // skip header
properties.position.x = array[index++].value;
properties.position.y = array[index++].value;