Make 3D progress bar match up with notifications

This commit is contained in:
David Rowe 2015-02-03 10:39:07 -08:00
parent fdf4aeaeab
commit 46352d34ce

View file

@ -13,17 +13,17 @@
(function () {
var progress = 100, // %
var progress = 100, // %
alpha = 0.0,
alphaDelta = 0.0, // > 0 if fading in; < 0 if fading out/
alphaDelta = 0.0, // > 0 if fading in; < 0 if fading out/
ALPHA_DELTA_IN = 0.15,
ALPHA_DELTA_OUT = -0.02,
fadeTimer = null,
FADE_INTERVAL = 30, // ms between changes in alpha.
FADE_INTERVAL = 30, // ms between changes in alpha.
fadeWaitTimer = null,
FADE_OUT_WAIT = 1000, // Wait before starting to fade out after progress 100%.
FADE_OUT_WAIT = 1000, // Wait before starting to fade out after progress 100%.
visible = false,
BAR_WIDTH = 320, // Nominal dimension of SVG in pixels of visible portion (half) of the bar.
BAR_WIDTH = 320, // Nominal dimension of SVG in pixels of visible portion (half) of the bar.
BAR_HEIGHT = 20,
BAR_URL = "http://ctrlaltstudio.com/hifi/progress-bar.svg",
BACKGROUND_WIDTH = 360,
@ -34,16 +34,19 @@
windowHeight = 0,
background2D = {},
bar2D = {},
SCALE_2D = 0.5, // Scale the SVGs for 2D display.
SCALE_2D = 0.5, // Scale the SVGs for 2D display.
background3D = {},
bar3D = {},
ENABLE_VR_MODE_MENU_ITEM = "Enable VR Mode",
PROGRESS_3D_DIRECTION = 0.0, // Degrees from avatar orientation.
PROGRESS_3D_DISTANCE = 0.63, // Horizontal distance from avatar position.
PROGRESS_3D_ELEVATION = -0.783, // Height of top middle of top notification relative to avatar eyes.
PROGRESS_3D_YAW = 0.0, // Degrees relative to notifications direction.
PROGRESS_3D_PITCH = -60.0, // Degrees from vertical.
SCALE_3D = 0.0021; // Scale the SVGs for 3D display.
PROGRESS_3D_DIRECTION = 0.0, // Degrees from avatar orientation.
PROGRESS_3D_DISTANCE = 0.602, // Horizontal distance from avatar position.
PROGRESS_3D_ELEVATION = -0.8, // Height of top middle of top notification relative to avatar eyes.
PROGRESS_3D_YAW = 0.0, // Degrees relative to notifications direction.
PROGRESS_3D_PITCH = -60.0, // Degrees from vertical.
SCALE_3D = 0.0017, // Scale the bar SVG for 3D display.
BACKGROUND_3D_SIZE = { x: 0.76, y: 0.08 }, // Match up with the 3D background with those of notifications.js notices.
BACKGROUND_3D_COLOR = { red: 2, green: 2, blue: 2 },
BACKGROUND_3D_ALPHA = 0.7;
function fade() {
@ -66,10 +69,17 @@
visible = false;
}
Overlays.editOverlay(isOnHMD ? background3D.overlay : background2D.overlay, {
alpha: alpha,
visible: visible
});
if (isOnHMD) {
Overlays.editOverlay(background3D.overlay, {
backgroundAlpha: alpha * BACKGROUND_3D_ALPHA,
visible: visible
});
} else {
Overlays.editOverlay(background2D.overlay, {
alpha: alpha,
visible: visible
});
}
Overlays.editOverlay(isOnHMD ? bar3D.overlay : bar2D.overlay, {
alpha: alpha,
visible: visible
@ -135,12 +145,14 @@
function createOverlays() {
if (isOnHMD) {
background3D.overlay = Overlays.addOverlay("billboard", {
url: BACKGROUND_URL,
scale: SCALE_3D * BACKGROUND_WIDTH,
background3D.overlay = Overlays.addOverlay("rectangle3d", {
size: BACKGROUND_3D_SIZE,
color: BACKGROUND_3D_COLOR,
alpha: BACKGROUND_3D_ALPHA,
solid: true,
isFacingAvatar: false,
visible: false,
alpha: 0.0
ignoreRayIntersection: true
});
bar3D.overlay = Overlays.addOverlay("billboard", {
url: BAR_URL,
@ -148,7 +160,8 @@
scale: SCALE_3D * BAR_WIDTH,
isFacingAvatar: false,
visible: false,
alpha: 0.0
alpha: 0.0,
ignoreRayIntersection: true
});
} else {