mirror of
https://github.com/overte-org/overte.git
synced 2025-07-23 16:24:09 +02:00
make the HMD away overlay 3d
This commit is contained in:
parent
501d23021f
commit
52c38e56a4
1 changed files with 23 additions and 17 deletions
|
@ -22,6 +22,19 @@ var OVERLAY_DATA = {
|
||||||
alpha: 1
|
alpha: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var OVERLAY_DATA_HMD = {
|
||||||
|
position: { x: 0, y: 0, z: 0},
|
||||||
|
width: OVERLAY_WIDTH,
|
||||||
|
height: OVERLAY_HEIGHT,
|
||||||
|
url: "http://hifi-content.s3.amazonaws.com/alan/production/images/images/Overlay-Viz-blank.png",
|
||||||
|
color: {red: 255, green: 255, blue: 255},
|
||||||
|
alpha: 1,
|
||||||
|
scale: 2,
|
||||||
|
isFacingAvatar: true,
|
||||||
|
drawInFront: true
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// ANIMATION
|
// ANIMATION
|
||||||
// We currently don't have play/stopAnimation integrated with the animation graph, but we can get the same effect
|
// We currently don't have play/stopAnimation integrated with the animation graph, but we can get the same effect
|
||||||
// using an animation graph with a state that we turn on and off through the animation var defined with that state.
|
// using an animation graph with a state that we turn on and off through the animation var defined with that state.
|
||||||
|
@ -66,19 +79,17 @@ function stopAwayAnimation() {
|
||||||
|
|
||||||
// OVERLAY
|
// OVERLAY
|
||||||
var overlay = Overlays.addOverlay("image", OVERLAY_DATA);
|
var overlay = Overlays.addOverlay("image", OVERLAY_DATA);
|
||||||
|
var overlayHMD = Overlays.addOverlay("image3d", OVERLAY_DATA_HMD);
|
||||||
function showOverlay() {
|
function showOverlay() {
|
||||||
var properties = {visible: true},
|
var properties = {visible: true};
|
||||||
// Update for current screen size, keeping overlay proportions constant.
|
|
||||||
screen = Controller.getViewportDimensions(),
|
|
||||||
screenRatio = screen.x / screen.y;
|
|
||||||
|
|
||||||
if (HMD.active) {
|
if (HMD.active) {
|
||||||
var lookAt = HMD.getHUDLookAtPosition2D();
|
Overlays.editOverlay(overlayHMD, { visible: true, position : HMD.getHUDLookAtPosition3D() });
|
||||||
properties.width = OVERLAY_WIDTH;
|
|
||||||
properties.height = OVERLAY_HEIGHT;
|
|
||||||
properties.x = lookAt.x - OVERLAY_WIDTH / 2;
|
|
||||||
properties.y = lookAt.y - OVERLAY_HEIGHT / 2;
|
|
||||||
} else {
|
} else {
|
||||||
|
// Update for current screen size, keeping overlay proportions constant.
|
||||||
|
var screen = Controller.getViewportDimensions(),
|
||||||
|
screenRatio = screen.x / screen.y;
|
||||||
|
|
||||||
if (screenRatio < OVERLAY_RATIO) {
|
if (screenRatio < OVERLAY_RATIO) {
|
||||||
properties.width = screen.x;
|
properties.width = screen.x;
|
||||||
properties.height = screen.x / OVERLAY_RATIO;
|
properties.height = screen.x / OVERLAY_RATIO;
|
||||||
|
@ -90,23 +101,18 @@ function showOverlay() {
|
||||||
properties.y = 0;
|
properties.y = 0;
|
||||||
properties.x = (screen.x - properties.width) / 2;
|
properties.x = (screen.x - properties.width) / 2;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Overlays.editOverlay(overlay, properties);
|
Overlays.editOverlay(overlay, properties);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
function hideOverlay() {
|
function hideOverlay() {
|
||||||
Overlays.editOverlay(overlay, {visible: false});
|
Overlays.editOverlay(overlay, {visible: false});
|
||||||
|
Overlays.editOverlay(overlayHMD, {visible: false});
|
||||||
}
|
}
|
||||||
hideOverlay();
|
hideOverlay();
|
||||||
|
|
||||||
function maybeMoveOverlay() {
|
function maybeMoveOverlay() {
|
||||||
if (HMD.active && isAway) {
|
if (HMD.active && isAway) {
|
||||||
var lookAt = HMD.getHUDLookAtPosition2D();
|
Overlays.editOverlay(overlayHMD, { position : HMD.getHUDLookAtPosition3D() });
|
||||||
var properties = {visible: true};
|
|
||||||
properties.width = OVERLAY_WIDTH;
|
|
||||||
properties.height = OVERLAY_HEIGHT;
|
|
||||||
properties.x = lookAt.x - OVERLAY_WIDTH / 2;
|
|
||||||
properties.y = lookAt.y - OVERLAY_HEIGHT / 2;
|
|
||||||
Overlays.editOverlay(overlay, properties);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue