Created
October 16, 2011 22:02
-
-
Save cjcliffe/1291486 to your computer and use it in GitHub Desktop.
Manual mainloop setInterval with locked framerate step
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var interval; | |
// finishes when time-stepped 30fps reaches a virtual 20 seconds (600/30 = 20) | |
var ml = new CubicVR.MainLoop(function(timer,gl) { | |
// ... | |
if (timer.getNumUpdates()===600) { | |
clearInterval(interval); | |
finished(); | |
} | |
}, true, true); // true 3rd param prevents mainloop from starting.. | |
// step at 30fps exactly | |
var ml.timer.lockFramerate(30); | |
// run at 60fps max | |
interval = setInterval(1000/60,function() { ml.runOnce(); }); | |
function finished() { | |
// do stuff here.. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment