Hacker News new | ask | show | jobs
by phoboslab 4989 days ago
You can't use a busy wait for animations in JavaScript.

three.js schedules frames with the requestAnimationFrame or setTimout method. (Edit: actually you have to schedule frames yourself via these methods as bd's comment point out). There's no other way to flush the Canvas' drawing buffer than ending the currently running function and giving control back to the browser. If you'd implement a busy wait in JavaScript, the screen would never update and the browser will kill the script after a few seconds.

three.js knows nothing about the animation that is running and thus just attempts to draw at 60fps - whether or not there's anything new to show. You could pause the animation if there's no user inupt (and the animation wouldn't update on its own), but that's your obligation.