I'm struggling with handling an array of 8 cubes, each only 1 pixel tall. When a button is pressed, I want them to smoothly animate to a new height using a while loop. Here's my current implementation:
if (buttonPressed) {
console.log('button pressed')
for (i in cubeArray) {
while (Math.abs(cubeArray[i].size.y - targetSizes[i].value) > 5) {
console.log(cubeArray[3].size.y)
cubeArray[i].size.y += .3
}
}
buttonPressed = false;
}
However, the console repeatedly shows that cubeArray[3] size remains at 1 pixel for 1215 iterations before suddenly jumping to the target height. Is it possible that the while loop is not functioning correctly within the render() function?