mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 03:17:02 +02:00
Lay out Create palette entity items
This commit is contained in:
parent
5a4ebbd54d
commit
f542c54e6c
2 changed files with 50 additions and 25 deletions
|
@ -22,6 +22,7 @@ CreatePalette = function (side, leftInputs, rightInputs, uiCommandCallback) {
|
||||||
palettePanelOverlay,
|
palettePanelOverlay,
|
||||||
highlightOverlay,
|
highlightOverlay,
|
||||||
paletteItemOverlays = [],
|
paletteItemOverlays = [],
|
||||||
|
paletteItemPositions = [],
|
||||||
|
|
||||||
LEFT_HAND = 0,
|
LEFT_HAND = 0,
|
||||||
|
|
||||||
|
@ -112,15 +113,19 @@ CreatePalette = function (side, leftInputs, rightInputs, uiCommandCallback) {
|
||||||
visible: false
|
visible: false
|
||||||
},
|
},
|
||||||
|
|
||||||
|
PALETTE_ENTITY_DIMENSIONS = { x: 0.024, y: 0.024, z: 0.024 },
|
||||||
|
PALETTE_ENTITY_COLOR = UIT.colors.faintGray,
|
||||||
|
ENTITY_CREATION_DIMENSIONS = { x: 0.2, y: 0.2, z: 0.2 },
|
||||||
|
ENTITY_CREATION_COLOR = { red: 192, green: 192, blue: 192 },
|
||||||
|
|
||||||
PALETTE_ITEMS = [
|
PALETTE_ITEMS = [
|
||||||
{
|
{
|
||||||
overlay: {
|
overlay: {
|
||||||
type: "cube",
|
type: "cube",
|
||||||
properties: {
|
properties: {
|
||||||
dimensions: { x: 0.03, y: 0.03, z: 0.03 },
|
dimensions: PALETTE_ENTITY_DIMENSIONS,
|
||||||
localPosition: { x: -0.04, y: 0.04, z: 0.03 },
|
|
||||||
localRotation: Quat.ZERO,
|
localRotation: Quat.ZERO,
|
||||||
color: { red: 240, green: 0, blue: 0 },
|
color: PALETTE_ENTITY_COLOR,
|
||||||
alpha: 1.0,
|
alpha: 1.0,
|
||||||
solid: true,
|
solid: true,
|
||||||
ignoreRayIntersection: false,
|
ignoreRayIntersection: false,
|
||||||
|
@ -129,8 +134,8 @@ CreatePalette = function (side, leftInputs, rightInputs, uiCommandCallback) {
|
||||||
},
|
},
|
||||||
entity: {
|
entity: {
|
||||||
type: "Box",
|
type: "Box",
|
||||||
dimensions: { x: 0.2, y: 0.2, z: 0.2 },
|
dimensions: ENTITY_CREATION_DIMENSIONS,
|
||||||
color: { red: 192, green: 192, blue: 192 }
|
color: ENTITY_CREATION_COLOR
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -138,10 +143,9 @@ CreatePalette = function (side, leftInputs, rightInputs, uiCommandCallback) {
|
||||||
type: "shape",
|
type: "shape",
|
||||||
properties: {
|
properties: {
|
||||||
shape: "Cylinder",
|
shape: "Cylinder",
|
||||||
dimensions: { x: 0.03, y: 0.03, z: 0.03 },
|
dimensions: PALETTE_ENTITY_DIMENSIONS,
|
||||||
localPosition: { x: 0.0, y: 0.04, z: 0.03 },
|
|
||||||
localRotation: Quat.fromVec3Degrees({ x: -90, y: 0, z: 0 }),
|
localRotation: Quat.fromVec3Degrees({ x: -90, y: 0, z: 0 }),
|
||||||
color: { red: 240, green: 0, blue: 0 },
|
color: PALETTE_ENTITY_COLOR,
|
||||||
alpha: 1.0,
|
alpha: 1.0,
|
||||||
solid: true,
|
solid: true,
|
||||||
ignoreRayIntersection: false,
|
ignoreRayIntersection: false,
|
||||||
|
@ -151,8 +155,8 @@ CreatePalette = function (side, leftInputs, rightInputs, uiCommandCallback) {
|
||||||
entity: {
|
entity: {
|
||||||
type: "Shape",
|
type: "Shape",
|
||||||
shape: "Cylinder",
|
shape: "Cylinder",
|
||||||
dimensions: { x: 0.2, y: 0.2, z: 0.2 },
|
dimensions: ENTITY_CREATION_DIMENSIONS,
|
||||||
color: { red: 192, green: 192, blue: 192 }
|
color: ENTITY_CREATION_COLOR
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -160,10 +164,9 @@ CreatePalette = function (side, leftInputs, rightInputs, uiCommandCallback) {
|
||||||
type: "shape",
|
type: "shape",
|
||||||
properties: {
|
properties: {
|
||||||
shape: "Cone",
|
shape: "Cone",
|
||||||
dimensions: { x: 0.03, y: 0.03, z: 0.03 },
|
dimensions: PALETTE_ENTITY_DIMENSIONS,
|
||||||
localPosition: { x: 0.04, y: 0.04, z: 0.03 },
|
|
||||||
localRotation: Quat.fromVec3Degrees({ x: 90, y: 0, z: 0 }),
|
localRotation: Quat.fromVec3Degrees({ x: 90, y: 0, z: 0 }),
|
||||||
color: { red: 240, green: 0, blue: 0 },
|
color: PALETTE_ENTITY_COLOR,
|
||||||
alpha: 1.0,
|
alpha: 1.0,
|
||||||
solid: true,
|
solid: true,
|
||||||
ignoreRayIntersection: false,
|
ignoreRayIntersection: false,
|
||||||
|
@ -173,18 +176,17 @@ CreatePalette = function (side, leftInputs, rightInputs, uiCommandCallback) {
|
||||||
entity: {
|
entity: {
|
||||||
type: "Shape",
|
type: "Shape",
|
||||||
shape: "Cone",
|
shape: "Cone",
|
||||||
dimensions: { x: 0.2, y: 0.2, z: 0.2 },
|
dimensions: ENTITY_CREATION_DIMENSIONS,
|
||||||
color: { red: 192, green: 192, blue: 192 }
|
color: ENTITY_CREATION_COLOR
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
overlay: {
|
overlay: {
|
||||||
type: "sphere",
|
type: "sphere",
|
||||||
properties: {
|
properties: {
|
||||||
dimensions: { x: 0.03, y: 0.03, z: 0.03 },
|
dimensions: PALETTE_ENTITY_DIMENSIONS,
|
||||||
localPosition: { x: -0.04, y: 0.0, z: 0.03 },
|
|
||||||
localRotation: Quat.ZERO,
|
localRotation: Quat.ZERO,
|
||||||
color: { red: 240, green: 0, blue: 0 },
|
color: PALETTE_ENTITY_COLOR,
|
||||||
alpha: 1.0,
|
alpha: 1.0,
|
||||||
solid: true,
|
solid: true,
|
||||||
ignoreRayIntersection: false,
|
ignoreRayIntersection: false,
|
||||||
|
@ -193,8 +195,8 @@ CreatePalette = function (side, leftInputs, rightInputs, uiCommandCallback) {
|
||||||
},
|
},
|
||||||
entity: {
|
entity: {
|
||||||
type: "Sphere",
|
type: "Sphere",
|
||||||
dimensions: { x: 0.2, y: 0.2, z: 0.2 },
|
dimensions: ENTITY_CREATION_DIMENSIONS,
|
||||||
color: { red: 192, green: 192, blue: 192 }
|
color: ENTITY_CREATION_COLOR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -257,7 +259,7 @@ CreatePalette = function (side, leftInputs, rightInputs, uiCommandCallback) {
|
||||||
// Unpress currently pressed item.
|
// Unpress currently pressed item.
|
||||||
if (pressedItem !== NONE && pressedItem !== itemIndex) {
|
if (pressedItem !== NONE && pressedItem !== itemIndex) {
|
||||||
Overlays.editOverlay(paletteItemOverlays[pressedItem], {
|
Overlays.editOverlay(paletteItemOverlays[pressedItem], {
|
||||||
localPosition: PALETTE_ITEMS[pressedItem].overlay.properties.localPosition
|
localPosition: paletteItemPositions[pressedItem]
|
||||||
});
|
});
|
||||||
pressedItem = NONE;
|
pressedItem = NONE;
|
||||||
}
|
}
|
||||||
|
@ -266,7 +268,7 @@ CreatePalette = function (side, leftInputs, rightInputs, uiCommandCallback) {
|
||||||
isTriggerClicked = controlHand.triggerClicked();
|
isTriggerClicked = controlHand.triggerClicked();
|
||||||
if (highlightedItem !== NONE && pressedItem === NONE && isTriggerClicked && !wasTriggerClicked) {
|
if (highlightedItem !== NONE && pressedItem === NONE && isTriggerClicked && !wasTriggerClicked) {
|
||||||
Overlays.editOverlay(paletteItemOverlays[itemIndex], {
|
Overlays.editOverlay(paletteItemOverlays[itemIndex], {
|
||||||
localPosition: Vec3.sum(PALETTE_ITEMS[itemIndex].overlay.properties.localPosition, PRESS_DELTA)
|
localPosition: Vec3.sum(paletteItemPositions[itemIndex], PRESS_DELTA)
|
||||||
});
|
});
|
||||||
pressedItem = itemIndex;
|
pressedItem = itemIndex;
|
||||||
|
|
||||||
|
@ -283,6 +285,26 @@ CreatePalette = function (side, leftInputs, rightInputs, uiCommandCallback) {
|
||||||
wasTriggerClicked = isTriggerClicked;
|
wasTriggerClicked = isTriggerClicked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function itemPosition(index) {
|
||||||
|
// Position relative to palette panel.
|
||||||
|
var ITEMS_PER_ROW = 3,
|
||||||
|
ROW_ZERO_Y_OFFSET = 0.0580,
|
||||||
|
ROW_SPACING = 0.0560,
|
||||||
|
COLUMN_ZERO_OFFSET = -0.08415,
|
||||||
|
COLUMN_SPACING = 0.0561,
|
||||||
|
row,
|
||||||
|
column;
|
||||||
|
|
||||||
|
row = Math.floor(index / ITEMS_PER_ROW);
|
||||||
|
column = index % ITEMS_PER_ROW;
|
||||||
|
|
||||||
|
return {
|
||||||
|
x: COLUMN_ZERO_OFFSET + column * COLUMN_SPACING,
|
||||||
|
y: ROW_ZERO_Y_OFFSET - row * ROW_SPACING,
|
||||||
|
z: UIT.dimensions.panel.z + PALETTE_ENTITY_DIMENSIONS.z / 2
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function display() {
|
function display() {
|
||||||
// Creates and shows menu entities.
|
// Creates and shows menu entities.
|
||||||
var handJointIndex,
|
var handJointIndex,
|
||||||
|
@ -329,8 +351,10 @@ CreatePalette = function (side, leftInputs, rightInputs, uiCommandCallback) {
|
||||||
|
|
||||||
for (i = 0, length = PALETTE_ITEMS.length; i < length; i += 1) {
|
for (i = 0, length = PALETTE_ITEMS.length; i < length; i += 1) {
|
||||||
properties = Object.clone(PALETTE_ITEMS[i].overlay.properties);
|
properties = Object.clone(PALETTE_ITEMS[i].overlay.properties);
|
||||||
properties.parentID = paletteOriginOverlay;
|
properties.parentID = palettePanelOverlay;
|
||||||
|
properties.localPosition = itemPosition(i);
|
||||||
paletteItemOverlays[i] = Overlays.addOverlay(PALETTE_ITEMS[i].overlay.type, properties);
|
paletteItemOverlays[i] = Overlays.addOverlay(PALETTE_ITEMS[i].overlay.type, properties);
|
||||||
|
paletteItemPositions[i] = properties.localPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare cube highlight overlay.
|
// Prepare cube highlight overlay.
|
||||||
|
|
|
@ -15,9 +15,10 @@ UIT = (function () {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
colors: {
|
colors: {
|
||||||
|
white: { red: 0xff, green: 0xff, blue: 0xff },
|
||||||
|
faintGray: { red: 0xe3, green: 0xe3, blue: 0xe3 },
|
||||||
baseGray: { red: 0x40, green: 0x40, blue: 0x40 },
|
baseGray: { red: 0x40, green: 0x40, blue: 0x40 },
|
||||||
blueHighlight: { red: 0x00, green: 0xbf, blue: 0xef },
|
blueHighlight: { red: 0x00, green: 0xbf, blue: 0xef }
|
||||||
white: { red: 0xff, green: 0xff, blue: 0xff }
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Coordinate system: UI lies in x-y plane with the front surface being +z.
|
// Coordinate system: UI lies in x-y plane with the front surface being +z.
|
||||||
|
|
Loading…
Reference in a new issue