0

I have a THREE.js animation loop:

function animation() {
    //Do stuff at 120fps
}
renderer.setAnimationLoop( animation );

I also have a large For loop:

for (var i = 0; i < 100; i++) {
    for (var j = 0; j < 100; j++) {
        //Do stuff with i and j
    }
}

The for loop takes ~50ms to execute. How would I be able to partially defer execution of the for statement, prefering the animation loop, so that the animation loop does not freeze for the execution time of the for loop? Moving the for loop to a webworker is not acceptable, although the animation loop fps dropping is acceptable, as long as it is not completely frozen. Note: I have tried making the for loop async using setTimeout, this did not work. I am not using any other libraries besides THREE.js

0 Answers0