I am very sorry to bother you with a question I suspect to be trivial for anyone but myself. I tried my best to find an answer on my own, but was unable to.
For you to understand what I lack understanding of, I will provide you with an example taken from an answer to another question asked here.
My question in the context of this example: What is the behavior of newtime
? Why is it required to be defined as a paremeter for this function to work? Where does it get its value?
startAnimating(5);
function startAnimating(fps) {
fpsInterval = 1000 / fps;
then = window.performance.now();
startTime = then;
console.log(startTime);
animate();
}
function animate(newtime) {
// (...)
requestAnimationFrame(animate);
now = newtime;
elapsed = now - then;
if (elapsed > fpsInterval) {
then = now - (elapsed % fpsInterval);
// (...)
}
}
I will greatly appreciate any response. Thank you.