mirror of
https://github.com/lubosz/overte.git
synced 2025-04-07 09:22:42 +02:00
formatted code
This commit is contained in:
parent
29d086d390
commit
d805f75d55
3 changed files with 14 additions and 24 deletions
|
@ -21,14 +21,12 @@
|
|||
var avatarLoudnessPool = [];
|
||||
|
||||
function average(a) {
|
||||
|
||||
var sum = 0;
|
||||
var total = a.length;
|
||||
for (var i = 0; i < total; i++) {
|
||||
sum += a[i];
|
||||
}
|
||||
|
||||
return Math.round(sum / total)
|
||||
return Math.round(sum / total);
|
||||
}
|
||||
|
||||
function audioClamp(input) {
|
||||
|
@ -41,7 +39,6 @@
|
|||
avatars.forEach(function (id) {
|
||||
var avatar = AvatarList.getAvatar(id);
|
||||
avatarLoudnessPool.push(audioClamp(Math.round(avatar.audioLoudness)));
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
@ -52,7 +49,7 @@
|
|||
|
||||
function normalizedAverage(a) {
|
||||
a = a.map(function (v) {
|
||||
return Math.round(( 100 / MAX_AUDIO_THRESHOLD ) * v)
|
||||
return Math.round(( 100 / MAX_AUDIO_THRESHOLD ) * v);
|
||||
});
|
||||
return average(a);
|
||||
}
|
||||
|
@ -62,13 +59,13 @@
|
|||
|
||||
var barProperties = Entities.getEntityProperties(barID);
|
||||
|
||||
var colorShift = 2.55 * norm; //shifiting the scale to 0 - 255
|
||||
var colorShift = 2.55 * norm; //shifting the scale to 0 - 255
|
||||
var xShift = norm / 52; // changing scale from 0-100 to 0-1.9 ish
|
||||
var normShift = xShift - 0.88; //shifitg local displacement (-0.90)
|
||||
var normShift = xShift - 0.88; //shifting local displacement (-0.88)
|
||||
var halfShift = xShift / 2;
|
||||
Entities.editEntity(barID, {
|
||||
dimensions: {x: xShift, y: barProperties.dimensions.y, z: barProperties.dimensions.z},
|
||||
localPosition: {x: normShift - ( halfShift ), y: -0.0625, z: -0.015},
|
||||
localPosition: {x: normShift - (halfShift), y: -0.0625, z: -0.015},
|
||||
color: {red: colorShift, green: barProperties.color.green, blue: barProperties.color.blue}
|
||||
});
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
var childZeroUserData = JSON.parse(Entities.getEntityProperties(children[0]).userData);
|
||||
|
||||
if (childZeroUserData.name === "bar") {
|
||||
|
||||
barID = childZero.id;
|
||||
textID = childOne.id;
|
||||
} else {
|
||||
|
@ -32,13 +31,11 @@
|
|||
var avatarLoudnessPool = [];
|
||||
|
||||
function average(a) {
|
||||
|
||||
var sum = 0;
|
||||
var total = a.length;
|
||||
for (var i = 0; i < total; i++) {
|
||||
sum += a[i];
|
||||
}
|
||||
|
||||
return Math.round(sum / total)
|
||||
}
|
||||
|
||||
|
@ -63,21 +60,21 @@
|
|||
|
||||
function normalizedAverage(a) {
|
||||
a = a.map(function (v) {
|
||||
return Math.round(( 100 / MAX_AUDIO_THRESHOLD ) * v)
|
||||
return Math.round(( 100 / MAX_AUDIO_THRESHOLD ) * v);
|
||||
});
|
||||
return average(a);
|
||||
}
|
||||
|
||||
var norm = normalizedAverage(framePool) ;
|
||||
var norm = normalizedAverage(framePool);
|
||||
|
||||
Entities.editEntity(textID, {text: "Loudness: % " + norm});
|
||||
|
||||
var barProperties = Entities.getEntityProperties(barID);
|
||||
JSON.stringify(barProperties) ;
|
||||
|
||||
var colorShift = 2.55 * norm; //shifiting the scale to 0 - 255
|
||||
|
||||
var colorShift = 2.55 * norm; //shifting the scale to 0 - 255
|
||||
var xShift = norm / 100; // changing scale from 0-100 to 0-1
|
||||
var normShift = xShift - .5; //shifitg scale form 0-1 to -.5 to .5
|
||||
var normShift = xShift - .5; //shifting scale form 0-1 to -.5 to .5
|
||||
var halfShift = xShift / 2 ;
|
||||
Entities.editEntity(barID, {
|
||||
dimensions: {x: xShift, y: barProperties.dimensions.y, z: barProperties.dimensions.z},
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
var childZeroUserData = JSON.parse(Entities.getEntityProperties(children[0]).userData);
|
||||
|
||||
if (childZeroUserData.name === "bar") {
|
||||
|
||||
barID = childZero.id;
|
||||
textID = childOne.id;
|
||||
originalText = childOne.text
|
||||
|
@ -34,14 +33,12 @@
|
|||
var avatarLoudnessPool = [];
|
||||
|
||||
function average(a) {
|
||||
|
||||
var sum = 0;
|
||||
var total = a.length;
|
||||
for (var i = 0; i < total; i++) {
|
||||
sum += a[i];
|
||||
}
|
||||
|
||||
return Math.round(sum / total)
|
||||
return Math.round(sum / total);
|
||||
}
|
||||
|
||||
function audioClamp(input) {
|
||||
|
@ -54,7 +51,6 @@
|
|||
avatars.forEach(function (id) {
|
||||
var avatar = AvatarList.getAvatar(id);
|
||||
avatarLoudnessPool.push(audioClamp(Math.round(avatar.audioLoudness)));
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
@ -65,7 +61,7 @@
|
|||
|
||||
function normalizedAverage(a) {
|
||||
a = a.map(function (v) {
|
||||
return Math.round(( 100 / MAX_AUDIO_THRESHOLD ) * v)
|
||||
return Math.round(( 100 / MAX_AUDIO_THRESHOLD ) * v);
|
||||
});
|
||||
return average(a);
|
||||
}
|
||||
|
@ -75,9 +71,9 @@
|
|||
|
||||
var barProperties = Entities.getEntityProperties(barID);
|
||||
|
||||
var colorShift = 2.55 * norm; //shifiting the scale to 0 - 255
|
||||
var colorShift = 2.55 * norm; //shifting the scale to 0 - 255
|
||||
var xShift = norm / 52; // changing scale from 0-100 to 0-1.9 ish
|
||||
var normShift = xShift - 0.88; //shifitg local displacement (-0.88)
|
||||
var normShift = xShift - 0.88; //shifting local displacement (-0.88)
|
||||
var halfShift = xShift / 2;
|
||||
Entities.editEntity(barID, {
|
||||
dimensions: {x: xShift, y: barProperties.dimensions.y, z: barProperties.dimensions.z},
|
||||
|
|
Loading…
Reference in a new issue