What is the best way to get the time difference between "window.requestAnimationFrame" callback in javascript?
I have tried:
// create the best .requestAnimationFrame callback for each browser
window.FPS = (function() {
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame ||
function(callback) {window.setTimeout(callback, 1000 / 60);};
})();
// start animation loop
var dt, stamp = (new Date()).getTime();
function loop() {
window.FPS(loop);
var now = (new Date()).getTime();
var dt = now - stamp;
stamp = now;
}
// has "dt" the best accuracy?