mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 05:57:29 +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 = [];
|
var avatarLoudnessPool = [];
|
||||||
|
|
||||||
function average(a) {
|
function average(a) {
|
||||||
|
|
||||||
var sum = 0;
|
var sum = 0;
|
||||||
var total = a.length;
|
var total = a.length;
|
||||||
for (var i = 0; i < total; i++) {
|
for (var i = 0; i < total; i++) {
|
||||||
sum += a[i];
|
sum += a[i];
|
||||||
}
|
}
|
||||||
|
return Math.round(sum / total);
|
||||||
return Math.round(sum / total)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function audioClamp(input) {
|
function audioClamp(input) {
|
||||||
|
@ -41,7 +39,6 @@
|
||||||
avatars.forEach(function (id) {
|
avatars.forEach(function (id) {
|
||||||
var avatar = AvatarList.getAvatar(id);
|
var avatar = AvatarList.getAvatar(id);
|
||||||
avatarLoudnessPool.push(audioClamp(Math.round(avatar.audioLoudness)));
|
avatarLoudnessPool.push(audioClamp(Math.round(avatar.audioLoudness)));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,7 +49,7 @@
|
||||||
|
|
||||||
function normalizedAverage(a) {
|
function normalizedAverage(a) {
|
||||||
a = a.map(function (v) {
|
a = a.map(function (v) {
|
||||||
return Math.round(( 100 / MAX_AUDIO_THRESHOLD ) * v)
|
return Math.round(( 100 / MAX_AUDIO_THRESHOLD ) * v);
|
||||||
});
|
});
|
||||||
return average(a);
|
return average(a);
|
||||||
}
|
}
|
||||||
|
@ -62,13 +59,13 @@
|
||||||
|
|
||||||
var barProperties = Entities.getEntityProperties(barID);
|
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 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;
|
var halfShift = xShift / 2;
|
||||||
Entities.editEntity(barID, {
|
Entities.editEntity(barID, {
|
||||||
dimensions: {x: xShift, y: barProperties.dimensions.y, z: barProperties.dimensions.z},
|
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}
|
color: {red: colorShift, green: barProperties.color.green, blue: barProperties.color.blue}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
var childZeroUserData = JSON.parse(Entities.getEntityProperties(children[0]).userData);
|
var childZeroUserData = JSON.parse(Entities.getEntityProperties(children[0]).userData);
|
||||||
|
|
||||||
if (childZeroUserData.name === "bar") {
|
if (childZeroUserData.name === "bar") {
|
||||||
|
|
||||||
barID = childZero.id;
|
barID = childZero.id;
|
||||||
textID = childOne.id;
|
textID = childOne.id;
|
||||||
} else {
|
} else {
|
||||||
|
@ -32,13 +31,11 @@
|
||||||
var avatarLoudnessPool = [];
|
var avatarLoudnessPool = [];
|
||||||
|
|
||||||
function average(a) {
|
function average(a) {
|
||||||
|
|
||||||
var sum = 0;
|
var sum = 0;
|
||||||
var total = a.length;
|
var total = a.length;
|
||||||
for (var i = 0; i < total; i++) {
|
for (var i = 0; i < total; i++) {
|
||||||
sum += a[i];
|
sum += a[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
return Math.round(sum / total)
|
return Math.round(sum / total)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,21 +60,21 @@
|
||||||
|
|
||||||
function normalizedAverage(a) {
|
function normalizedAverage(a) {
|
||||||
a = a.map(function (v) {
|
a = a.map(function (v) {
|
||||||
return Math.round(( 100 / MAX_AUDIO_THRESHOLD ) * v)
|
return Math.round(( 100 / MAX_AUDIO_THRESHOLD ) * v);
|
||||||
});
|
});
|
||||||
return average(a);
|
return average(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
var norm = normalizedAverage(framePool) ;
|
var norm = normalizedAverage(framePool);
|
||||||
|
|
||||||
Entities.editEntity(textID, {text: "Loudness: % " + norm});
|
Entities.editEntity(textID, {text: "Loudness: % " + norm});
|
||||||
|
|
||||||
var barProperties = Entities.getEntityProperties(barID);
|
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 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 ;
|
var halfShift = xShift / 2 ;
|
||||||
Entities.editEntity(barID, {
|
Entities.editEntity(barID, {
|
||||||
dimensions: {x: xShift, y: barProperties.dimensions.y, z: barProperties.dimensions.z},
|
dimensions: {x: xShift, y: barProperties.dimensions.y, z: barProperties.dimensions.z},
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
var childZeroUserData = JSON.parse(Entities.getEntityProperties(children[0]).userData);
|
var childZeroUserData = JSON.parse(Entities.getEntityProperties(children[0]).userData);
|
||||||
|
|
||||||
if (childZeroUserData.name === "bar") {
|
if (childZeroUserData.name === "bar") {
|
||||||
|
|
||||||
barID = childZero.id;
|
barID = childZero.id;
|
||||||
textID = childOne.id;
|
textID = childOne.id;
|
||||||
originalText = childOne.text
|
originalText = childOne.text
|
||||||
|
@ -34,14 +33,12 @@
|
||||||
var avatarLoudnessPool = [];
|
var avatarLoudnessPool = [];
|
||||||
|
|
||||||
function average(a) {
|
function average(a) {
|
||||||
|
|
||||||
var sum = 0;
|
var sum = 0;
|
||||||
var total = a.length;
|
var total = a.length;
|
||||||
for (var i = 0; i < total; i++) {
|
for (var i = 0; i < total; i++) {
|
||||||
sum += a[i];
|
sum += a[i];
|
||||||
}
|
}
|
||||||
|
return Math.round(sum / total);
|
||||||
return Math.round(sum / total)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function audioClamp(input) {
|
function audioClamp(input) {
|
||||||
|
@ -54,7 +51,6 @@
|
||||||
avatars.forEach(function (id) {
|
avatars.forEach(function (id) {
|
||||||
var avatar = AvatarList.getAvatar(id);
|
var avatar = AvatarList.getAvatar(id);
|
||||||
avatarLoudnessPool.push(audioClamp(Math.round(avatar.audioLoudness)));
|
avatarLoudnessPool.push(audioClamp(Math.round(avatar.audioLoudness)));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,7 +61,7 @@
|
||||||
|
|
||||||
function normalizedAverage(a) {
|
function normalizedAverage(a) {
|
||||||
a = a.map(function (v) {
|
a = a.map(function (v) {
|
||||||
return Math.round(( 100 / MAX_AUDIO_THRESHOLD ) * v)
|
return Math.round(( 100 / MAX_AUDIO_THRESHOLD ) * v);
|
||||||
});
|
});
|
||||||
return average(a);
|
return average(a);
|
||||||
}
|
}
|
||||||
|
@ -75,9 +71,9 @@
|
||||||
|
|
||||||
var barProperties = Entities.getEntityProperties(barID);
|
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 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;
|
var halfShift = xShift / 2;
|
||||||
Entities.editEntity(barID, {
|
Entities.editEntity(barID, {
|
||||||
dimensions: {x: xShift, y: barProperties.dimensions.y, z: barProperties.dimensions.z},
|
dimensions: {x: xShift, y: barProperties.dimensions.y, z: barProperties.dimensions.z},
|
||||||
|
|
Loading…
Reference in a new issue