So I have a running loop:
var FRAME_TIME = 1000 / 60;
var lastTime = 0;
var fpsTime = 0;
var fps = 0;
function mainLoop(timestamp) {
if (timestamp - lastTime >= FRAME_TIME) {
fps++;
lastTime = timestamp;
}
if (timestamp - fpsTime >= 1000) {
console.log(fps);
fps = 0;
fpsTime = timestamp;
}
requestAnimationFrame(mainLoop);
}
Now, when running with monitor refresh at 60, I get "60" printed in console as expected. But, when running with resfresh at 144, I get "48" = 1/3 of the refresh.
Why? Time is time, right...?