mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-08 06:32:35 +02:00
remove whitespace and fix formatting
This commit is contained in:
parent
e436c355a1
commit
e87b06657c
8 changed files with 139 additions and 72 deletions
|
@ -11,44 +11,51 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
(function () {
|
||||
(function() {
|
||||
|
||||
var rawProgress = 100, // % raw value.
|
||||
displayProgress = 100, // % smoothed value to display.
|
||||
DISPLAY_PROGRESS_MINOR_MAXIMUM = 8, // % displayed progress bar goes up to while 0% raw progress.
|
||||
DISPLAY_PROGRESS_MINOR_INCREMENT = 0.1, // % amount to increment display value each update when 0% raw progress.
|
||||
DISPLAY_PROGRESS_MAJOR_INCREMENT = 5, // % maximum amount to increment display value when >0% raw progress.
|
||||
var rawProgress = 100, // % raw value.
|
||||
displayProgress = 100, // % smoothed value to display.
|
||||
DISPLAY_PROGRESS_MINOR_MAXIMUM = 8, // % displayed progress bar goes up to while 0% raw progress.
|
||||
DISPLAY_PROGRESS_MINOR_INCREMENT = 0.1, // % amount to increment display value each update when 0% raw progress.
|
||||
DISPLAY_PROGRESS_MAJOR_INCREMENT = 5, // % maximum amount to increment display value when >0% raw progress.
|
||||
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 = 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_URL = "http://hifi-public.s3.amazonaws.com/images/progress-bar.svg",
|
||||
BAR_URL = Script.resolvePath("assets/images/progress-bar.svg"),
|
||||
BACKGROUND_WIDTH = 540,
|
||||
BACKGROUND_HEIGHT = 90,
|
||||
BACKGROUND_URL = "http://hifi-public.s3.amazonaws.com/images/progress-bar-background.svg",
|
||||
BACKGROUND_URL = Script.resolvePath("assets/images/progress-bar-background.svg"),
|
||||
isOnHMD = false,
|
||||
windowWidth = 0,
|
||||
windowHeight = 0,
|
||||
background2D = {},
|
||||
bar2D = {},
|
||||
SCALE_2D = 0.35, // Scale the SVGs for 2D display.
|
||||
SCALE_2D = 0.35, // Scale the SVGs for 2D display.
|
||||
background3D = {},
|
||||
bar3D = {},
|
||||
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.0011, // 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 },
|
||||
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.0011, // 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() {
|
||||
|
@ -63,12 +70,12 @@
|
|||
alpha = 1;
|
||||
}
|
||||
|
||||
if (alpha === 0 || alpha === 1) { // Finished fading in or out
|
||||
if (alpha === 0 || alpha === 1) { // Finished fading in or out
|
||||
alphaDelta = 0;
|
||||
Script.clearInterval(fadeTimer);
|
||||
}
|
||||
|
||||
if (alpha === 0) { // Finished fading out
|
||||
if (alpha === 0) { // Finished fading out
|
||||
visible = false;
|
||||
}
|
||||
|
||||
|
@ -118,7 +125,12 @@
|
|||
});
|
||||
bar3D.overlay = Overlays.addOverlay("image3d", {
|
||||
url: BAR_URL,
|
||||
subImage: { x: BAR_WIDTH, y: 0, width: BAR_WIDTH, height: BAR_HEIGHT },
|
||||
subImage: {
|
||||
x: BAR_WIDTH,
|
||||
y: 0,
|
||||
width: BAR_WIDTH,
|
||||
height: BAR_HEIGHT
|
||||
},
|
||||
scale: SCALE_3D * BAR_WIDTH,
|
||||
isFacingAvatar: false,
|
||||
visible: false,
|
||||
|
@ -137,7 +149,12 @@
|
|||
});
|
||||
bar2D.overlay = Overlays.addOverlay("image", {
|
||||
imageURL: BAR_URL,
|
||||
subImage: { x: BAR_WIDTH, y: 0, width: BAR_WIDTH, height: BAR_HEIGHT },
|
||||
subImage: {
|
||||
x: BAR_WIDTH,
|
||||
y: 0,
|
||||
width: BAR_WIDTH,
|
||||
height: BAR_HEIGHT
|
||||
},
|
||||
width: bar2D.width,
|
||||
height: bar2D.height,
|
||||
visible: false,
|
||||
|
@ -169,36 +186,36 @@
|
|||
displayProgress = rawProgress;
|
||||
} else if (rawProgress > displayProgress) {
|
||||
displayProgress = Math.min(rawProgress, displayProgress + DISPLAY_PROGRESS_MAJOR_INCREMENT);
|
||||
} // else (rawProgress === displayProgress); do nothing.
|
||||
} // else (rawProgress === displayProgress); do nothing.
|
||||
|
||||
// Update state
|
||||
if (!visible) { // Not visible because no recent downloads
|
||||
if (displayProgress < 100) { // Have started downloading so fade in
|
||||
if (!visible) { // Not visible because no recent downloads
|
||||
if (displayProgress < 100) { // Have started downloading so fade in
|
||||
visible = true;
|
||||
alphaDelta = ALPHA_DELTA_IN;
|
||||
fadeTimer = Script.setInterval(fade, FADE_INTERVAL);
|
||||
}
|
||||
} else if (alphaDelta !== 0.0) { // Fading in or out
|
||||
} else if (alphaDelta !== 0.0) { // Fading in or out
|
||||
if (alphaDelta > 0) {
|
||||
if (displayProgress === 100) { // Was downloading but now have finished so fade out
|
||||
if (displayProgress === 100) { // Was downloading but now have finished so fade out
|
||||
alphaDelta = ALPHA_DELTA_OUT;
|
||||
}
|
||||
} else {
|
||||
if (displayProgress < 100) { // Was finished downloading but have resumed so fade in
|
||||
if (displayProgress < 100) { // Was finished downloading but have resumed so fade in
|
||||
alphaDelta = ALPHA_DELTA_IN;
|
||||
}
|
||||
}
|
||||
} else { // Fully visible because downloading or recently so
|
||||
} else { // Fully visible because downloading or recently so
|
||||
if (fadeWaitTimer === null) {
|
||||
if (displayProgress === 100) { // Was downloading but have finished so fade out soon
|
||||
fadeWaitTimer = Script.setTimeout(function () {
|
||||
if (displayProgress === 100) { // Was downloading but have finished so fade out soon
|
||||
fadeWaitTimer = Script.setTimeout(function() {
|
||||
alphaDelta = ALPHA_DELTA_OUT;
|
||||
fadeTimer = Script.setInterval(fade, FADE_INTERVAL);
|
||||
fadeWaitTimer = null;
|
||||
}, FADE_OUT_WAIT);
|
||||
}
|
||||
} else {
|
||||
if (displayProgress < 100) { // Was finished and waiting to fade out but have resumed so don't fade out
|
||||
if (displayProgress < 100) { // Was finished and waiting to fade out but have resumed so don't fade out
|
||||
Script.clearInterval(fadeWaitTimer);
|
||||
fadeWaitTimer = null;
|
||||
}
|
||||
|
@ -210,7 +227,12 @@
|
|||
// Update progress bar
|
||||
Overlays.editOverlay(isOnHMD ? bar3D.overlay : bar2D.overlay, {
|
||||
visible: visible,
|
||||
subImage: { x: BAR_WIDTH * (1 - displayProgress / 100), y: 0, width: BAR_WIDTH, height: BAR_HEIGHT }
|
||||
subImage: {
|
||||
x: BAR_WIDTH * (1 - displayProgress / 100),
|
||||
y: 0,
|
||||
width: BAR_WIDTH,
|
||||
height: BAR_HEIGHT
|
||||
}
|
||||
});
|
||||
|
||||
// Update position
|
||||
|
@ -256,11 +278,18 @@
|
|||
bar2D.width = SCALE_2D * BAR_WIDTH;
|
||||
bar2D.height = SCALE_2D * BAR_HEIGHT;
|
||||
|
||||
background3D.offset = Vec3.multiplyQbyV(Quat.fromPitchYawRollDegrees(0, PROGRESS_3D_DIRECTION, 0),
|
||||
{ x: 0, y: 0, z: -PROGRESS_3D_DISTANCE });
|
||||
background3D.offset = Vec3.multiplyQbyV(Quat.fromPitchYawRollDegrees(0, PROGRESS_3D_DIRECTION, 0), {
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: -PROGRESS_3D_DISTANCE
|
||||
});
|
||||
background3D.offset.y += PROGRESS_3D_ELEVATION;
|
||||
background3D.orientation = Quat.fromPitchYawRollDegrees(PROGRESS_3D_PITCH, PROGRESS_3D_DIRECTION + PROGRESS_3D_YAW, 0);
|
||||
bar3D.offset = Vec3.sum(background3D.offset, { x: 0, y: 0, z: 0.001 }); // Just in front of background
|
||||
bar3D.offset = Vec3.sum(background3D.offset, {
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0.001
|
||||
}); // Just in front of background
|
||||
bar3D.orientation = background3D.orientation;
|
||||
|
||||
createOverlays();
|
||||
|
@ -275,4 +304,4 @@
|
|||
GlobalServices.updateDownloadInfo();
|
||||
Script.update.connect(update);
|
||||
Script.scriptEnding.connect(tearDown);
|
||||
}());
|
||||
}());
|
|
@ -17,7 +17,7 @@ var overlays = {};
|
|||
|
||||
|
||||
var toType = function(obj) {
|
||||
return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase()
|
||||
return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase()
|
||||
}
|
||||
|
||||
|
||||
|
@ -50,7 +50,11 @@ function actionArgumentsToString(actionArguments) {
|
|||
|
||||
function updateOverlay(entityID, actionText) {
|
||||
var properties = Entities.getEntityProperties(entityID, ["position", "dimensions"]);
|
||||
var position = Vec3.sum(properties.position, {x:0, y:properties.dimensions.y, z:0});
|
||||
var position = Vec3.sum(properties.position, {
|
||||
x: 0,
|
||||
y: properties.dimensions.y,
|
||||
z: 0
|
||||
});
|
||||
// print("position: " + vec3toStr(position) + " " + actionText);
|
||||
if (entityID in overlays) {
|
||||
var overlay = overlays[entityID];
|
||||
|
@ -76,9 +80,20 @@ function updateOverlay(entityID, actionText) {
|
|||
|
||||
overlays[entityID] = Overlays.addOverlay("text3d", {
|
||||
position: position,
|
||||
dimensions: { x: textWidth, y: textHeight },
|
||||
backgroundColor: { red: 0, green: 0, blue: 0},
|
||||
color: { red: 255, green: 255, blue: 255},
|
||||
dimensions: {
|
||||
x: textWidth,
|
||||
y: textHeight
|
||||
},
|
||||
backgroundColor: {
|
||||
red: 0,
|
||||
green: 0,
|
||||
blue: 0
|
||||
},
|
||||
color: {
|
||||
red: 255,
|
||||
green: 255,
|
||||
blue: 255
|
||||
},
|
||||
topMargin: textMargin,
|
||||
leftMargin: textMargin,
|
||||
bottomMargin: textMargin,
|
||||
|
@ -143,4 +158,4 @@ Script.setInterval(function() {
|
|||
}, 100);
|
||||
|
||||
|
||||
Script.scriptEnding.connect(cleanup);
|
||||
Script.scriptEnding.connect(cleanup);
|
|
@ -37,7 +37,7 @@ function grabDataToString(grabData) {
|
|||
argString = arg.toFixed(2);
|
||||
}
|
||||
result += argumentName + ": "
|
||||
// + toType(arg) + " -- "
|
||||
// + toType(arg) + " -- "
|
||||
+ argString + "\n";
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,11 @@ function grabDataToString(grabData) {
|
|||
|
||||
function updateOverlay(entityID, grabText) {
|
||||
var properties = Entities.getEntityProperties(entityID, ["position", "dimensions"]);
|
||||
var position = Vec3.sum(properties.position, {x:0, y:properties.dimensions.y, z:0});
|
||||
var position = Vec3.sum(properties.position, {
|
||||
x: 0,
|
||||
y: properties.dimensions.y,
|
||||
z: 0
|
||||
});
|
||||
if (entityID in overlays) {
|
||||
var overlay = overlays[entityID];
|
||||
Overlays.editOverlay(overlay, {
|
||||
|
@ -74,9 +78,20 @@ function updateOverlay(entityID, grabText) {
|
|||
|
||||
overlays[entityID] = Overlays.addOverlay("text3d", {
|
||||
position: position,
|
||||
dimensions: { x: textWidth, y: textHeight },
|
||||
backgroundColor: { red: 0, green: 0, blue: 0},
|
||||
color: { red: 255, green: 255, blue: 255},
|
||||
dimensions: {
|
||||
x: textWidth,
|
||||
y: textHeight
|
||||
},
|
||||
backgroundColor: {
|
||||
red: 0,
|
||||
green: 0,
|
||||
blue: 0
|
||||
},
|
||||
color: {
|
||||
red: 255,
|
||||
green: 255,
|
||||
blue: 255
|
||||
},
|
||||
topMargin: textMargin,
|
||||
leftMargin: textMargin,
|
||||
bottomMargin: textMargin,
|
||||
|
@ -134,4 +149,4 @@ Script.setInterval(function() {
|
|||
}, 100);
|
||||
|
||||
|
||||
Script.scriptEnding.connect(cleanup);
|
||||
Script.scriptEnding.connect(cleanup);
|
|
@ -18,9 +18,11 @@ var INSPECT_RADIUS = 10;
|
|||
var overlays = {};
|
||||
|
||||
function updateOverlay(entityID, queryAACube) {
|
||||
var cubeCenter = {x: queryAACube.x + queryAACube.scale / 2.0,
|
||||
y: queryAACube.y + queryAACube.scale / 2.0,
|
||||
z: queryAACube.z + queryAACube.scale / 2.0};
|
||||
var cubeCenter = {
|
||||
x: queryAACube.x + queryAACube.scale / 2.0,
|
||||
y: queryAACube.y + queryAACube.scale / 2.0,
|
||||
z: queryAACube.z + queryAACube.scale / 2.0
|
||||
};
|
||||
|
||||
if (entityID in overlays) {
|
||||
var overlay = overlays[entityID];
|
||||
|
@ -32,7 +34,11 @@ function updateOverlay(entityID, queryAACube) {
|
|||
overlays[entityID] = Overlays.addOverlay("cube", {
|
||||
position: cubeCenter,
|
||||
size: queryAACube.scale,
|
||||
color: { red: 0, green: 0, blue: 255},
|
||||
color: {
|
||||
red: 0,
|
||||
green: 0,
|
||||
blue: 255
|
||||
},
|
||||
alpha: 1,
|
||||
// borderSize: ...,
|
||||
solid: false
|
||||
|
@ -55,4 +61,4 @@ function cleanup() {
|
|||
}
|
||||
}
|
||||
|
||||
Script.scriptEnding.connect(cleanup);
|
||||
Script.scriptEnding.connect(cleanup);
|
|
@ -1,22 +1,21 @@
|
|||
|
||||
(function() {
|
||||
|
||||
var _this;
|
||||
|
||||
MyEntity = function() {
|
||||
_this = this;
|
||||
|
||||
|
||||
};
|
||||
|
||||
MyEntity.prototype = {
|
||||
|
||||
|
||||
preload: function(entityID) {
|
||||
this.entityID = entityID;
|
||||
var randNum = Math.random().toFixed(3);
|
||||
print("EBL PRELOAD ENTITY SCRIPT!!!", randNum)
|
||||
print("PRELOAD ENTITY SCRIPT!!!", randNum)
|
||||
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
||||
// entity scripts always need to return a newly constructed object of our type
|
||||
|
|
|
@ -1,24 +1,26 @@
|
|||
(function () {
|
||||
(function() {
|
||||
// The attached entity will move away from you if you are too close, checking at distanceRate.
|
||||
// See tests/performance/simpleKeepAway.js
|
||||
var entityID,
|
||||
distanceRate = 1, // hertz
|
||||
distanceAllowance = 3, // meters
|
||||
distanceScale = 0.5, // meters/second
|
||||
distanceRate = 1, // hertz
|
||||
distanceAllowance = 3, // meters
|
||||
distanceScale = 0.5, // meters/second
|
||||
distanceTimer;
|
||||
|
||||
function moveDistance() { // every user checks their distance and tries to claim if close enough.
|
||||
function moveDistance() { // every user checks their distance and tries to claim if close enough.
|
||||
var me = MyAvatar.position,
|
||||
ball = Entities.getEntityProperties(entityID, ['position']).position;
|
||||
ball.y = me.y;
|
||||
var vector = Vec3.subtract(ball, me);
|
||||
|
||||
if (Vec3.length(vector) < distanceAllowance) {
|
||||
Entities.editEntity(entityID, {velocity: Vec3.multiply(distanceScale, Vec3.normalize(vector))});
|
||||
Entities.editEntity(entityID, {
|
||||
velocity: Vec3.multiply(distanceScale, Vec3.normalize(vector))
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
this.preload = function (givenEntityID) {
|
||||
this.preload = function(givenEntityID) {
|
||||
var properties = Entities.getEntityProperties(givenEntityID, ['userData']),
|
||||
userData = properties.userData && JSON.parse(properties.userData);
|
||||
entityID = givenEntityID;
|
||||
|
@ -31,7 +33,7 @@
|
|||
// run all the time by everyone:
|
||||
distanceTimer = Script.setInterval(moveDistance, distanceRate);
|
||||
};
|
||||
this.unload = function () {
|
||||
this.unload = function() {
|
||||
Script.clearTimeout(distanceTimer);
|
||||
};
|
||||
})
|
||||
})
|
|
@ -220,4 +220,3 @@ Rectangle {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -243,4 +243,6 @@ Item {
|
|||
]
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue