Trying to understand some modified code from this stackoverflow answer. The part that doesn't make sense to me is where does timestamp come from in the function update(timestamp)? I don't see it defined anywhere.... but the code still works. Just looking for an explanation to better understand things, thanks.
const log = console.log.bind(console);
const perfectFrameTime = 1000 / 60;
let deltaTime = 0;
let lastTimestamp = 0;
let timerState = true;
function start() {
requestAnimationFrame(update);
}
function update(timestamp) {
if (timerState){
requestAnimationFrame(update);
}
deltaTime = (timestamp - lastTimestamp) / perfectFrameTime;
lastTimestamp = timestamp;
log(deltaTime);
// YOUR FRAME CODE HERE!
}
setTimeout(()=> {timerState = false;}, 1000);
start();