Skip to content
Permalink
Browse files

Better responsiveness.

  • Loading branch information...
jdeurt committed Oct 3, 2019
1 parent 52a9e8a commit 1906fcc06dd808a98533740692a33ff005d09379
Showing with 0 additions and 19 deletions.
  1. +0 −19 stuff/cube-visualizer/js/script.js
@@ -194,14 +194,12 @@ document.getElementById("audio-file").addEventListener("change", function () {
let cubeShadowExpanding = false;
let cubeShadow = {};

/* Experimental */
let cubeShadows = [];

function animate() {
requestAnimationFrame(animate);

const fData = metro.getFrequencyData();
fData.loudness.bass = ( (fData.avg.bass - 128) / 2 + 128 ) / 128;

if (fData.loudness.bass > 1.1) {
setCubeColor(RAINBOW[6]);
@@ -231,32 +229,15 @@ document.getElementById("audio-file").addEventListener("change", function () {

if (fData.loudness.sub > 1.3) {
if (!cubeShadowExpanding) {
// cubeShadowExpanding = true;
cubeShadow = cube.clone();
cubeShadow.material = cubeShadow.material.clone();

/* Experimental */
cubeShadows.push(cubeShadow);

scene.add(cubeShadow);
}
}

/*
if (cubeShadowExpanding) {
if (cubeShadow.scale.x > 3) {
scene.remove(cubeShadow);
cubeShadow = {};
cubeShadowExpanding = false;
} else {
cubeShadow.scale.x += 0.1;
cubeShadow.scale.y += 0.1;
cubeShadow.scale.z += 0.1;
cubeShadow.material.opacity -= 0.03333333;
}
}
*/

if (cubeShadows.length > 0) {
let removedShadows = cubeShadows.filter(shadow => {
return shadow.material.opacity <= 0;

0 comments on commit 1906fcc

Please sign in to comment.
You can’t perform that action at this time.