Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

134
Views
Javascript how to defer active script

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

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!