Add minor tweaks to progress.js

This commit is contained in:
Ryan Huffman 2016-07-29 10:11:12 -07:00
parent 91f847a7f0
commit 6279b96223

View file

@ -28,10 +28,10 @@
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, visible = false,
BAR_WIDTH = 480, // Dimension of SVG in pixels of visible portion (half) of the bar. BAR_WIDTH = 480, // Dimension of SVG in pixels of visible portion (half) of the bar.
BAR_HEIGHT = 30, BAR_HEIGHT = 10,
BAR_URL = Script.resolvePath("assets/images/progress-bar.svg"), BAR_URL = Script.resolvePath("assets/images/progress-bar.svg"),
BACKGROUND_WIDTH = 540, BACKGROUND_WIDTH = 520,
BACKGROUND_HEIGHT = 90, BACKGROUND_HEIGHT = 50,
BACKGROUND_URL = Script.resolvePath("assets/images/progress-bar-background.svg"), BACKGROUND_URL = Script.resolvePath("assets/images/progress-bar-background.svg"),
isOnHMD = false, isOnHMD = false,
windowWidth = 0, windowWidth = 0,
@ -45,8 +45,9 @@
PROGRESS_3D_DIRECTION = 0.0, // Degrees from avatar orientation. PROGRESS_3D_DIRECTION = 0.0, // Degrees from avatar orientation.
PROGRESS_3D_DISTANCE = 0.602, // Horizontal distance from avatar position. 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_ELEVATION = -0.8, // Height of top middle of top notification relative to avatar eyes.
PROGRESS_3D_ELEVATION = -0.0, // Height of top middle of top notification relative to avatar eyes.
PROGRESS_3D_YAW = 0.0, // Degrees relative to notifications direction. PROGRESS_3D_YAW = 0.0, // Degrees relative to notifications direction.
PROGRESS_3D_PITCH = -60.0, // Degrees from vertical. PROGRESS_3D_PITCH = -0.0, // Degrees from vertical.
SCALE_3D = 0.0011, // Scale the bar SVG for 3D display. SCALE_3D = 0.0011, // Scale the bar SVG for 3D display.
BACKGROUND_3D_SIZE = { BACKGROUND_3D_SIZE = {
x: 0.76, x: 0.76,
@ -57,7 +58,7 @@
green: 2, green: 2,
blue: 2 blue: 2
}, },
BACKGROUND_3D_ALPHA = 0.7; BACKGROUND_3D_ALPHA = 1.0;
function fade() { function fade() {
@ -119,6 +120,7 @@
wasActive = false; wasActive = false;
rawProgress = 100; rawProgress = 100;
bestRawProgress = 100; bestRawProgress = 100;
cooldown = 0;
} else { } else {
var count = info.downloading.length + info.pending; var count = info.downloading.length + info.pending;
if (!wasActive) { if (!wasActive) {
@ -128,17 +130,8 @@
if (count > maxSeen) { if (count > maxSeen) {
maxSeen = count; maxSeen = count;
} }
if (cooldown < 0) { if (cooldown <= 0) {
print("PROGRESS: OUT OF COOLDOWN");
//for (i = 0; i < info.downloading.length; i += 1) {
//rawProgress += info.downloading[i];
//}
//rawProgress = rawProgress / (info.downloading.length + info.pending);
rawProgress = ((maxSeen - count) / maxSeen) * 100; rawProgress = ((maxSeen - count) / maxSeen) * 100;
//rawProgress += 1;
//if (rawProgress > 90) {
//rawProgress = 20
//}
if (rawProgress > bestRawProgress) { if (rawProgress > bestRawProgress) {
bestRawProgress = rawProgress; bestRawProgress = rawProgress;
@ -208,46 +201,23 @@
var b = 0; var b = 0;
function update() { function update() {
cooldown -= 16; cooldown -= 16;
/*
maxSeen = 100;
b++;
rawProgress = b;
if (rawProgress == 100) {
b = 0
}
bestRawProgress = rawProgress;
print(rawProgress, bestRawProgress);
*/
//print(rawProgress, bestRawProgress, maxSeen);
var viewport, var viewport,
eyePosition, eyePosition,
avatarOrientation; avatarOrientation;
hmdActive = HMD.active; hmdActive = HMD.active;
//if (isOnHMD !== HMD.active) { // if (isOnHMD !== HMD.active) {
//deleteOverlays(); // deleteOverlays();
//isOnHMD = !isOnHMD; // isOnHMD = !isOnHMD;
//createOverlays(); // createOverlays();
//} // }
/*
// Calculate progress value to display
if (rawProgress === 0 && displayProgress <= DISPLAY_PROGRESS_MINOR_MAXIMUM) {
displayProgress = Math.min(displayProgress + DISPLAY_PROGRESS_MINOR_INCREMENT, DISPLAY_PROGRESS_MINOR_MAXIMUM);
} else if (rawProgress < displayProgress) {
displayProgress = rawProgress;
} else if (rawProgress > displayProgress) {
displayProgress = Math.min(rawProgress, displayProgress + DISPLAY_PROGRESS_MAJOR_INCREMENT);
} // else (rawProgress === displayProgress); do nothing.
//displayProgress = bestRawProgress;
//*/
if (displayProgress < rawProgress) { if (displayProgress < rawProgress) {
var diff = rawProgress - displayProgress; var diff = rawProgress - displayProgress;
if (diff < 0.1) { if (diff < 0.1) {
displayProgress = rawProgress; displayProgress = rawProgress;
} else { } else {
displayProgress += diff * 0.1; displayProgress += diff * 0.05;
} }
} }
//print('PROGRESS:', displayProgress); //print('PROGRESS:', displayProgress);
@ -323,7 +293,7 @@
windowWidth = viewport.x; windowWidth = viewport.x;
windowHeight = viewport.y; windowHeight = viewport.y;
var yOffset = hmdActive ? -300 : 0; var yOffset = hmdActive ? -300 : -10;
Overlays.editOverlay(background2D.overlay, { Overlays.editOverlay(background2D.overlay, {
x: windowWidth / 2 - background2D.width / 2, x: windowWidth / 2 - background2D.width / 2,