Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Loop = {
- run: function(scene, fps) {
- this.scene = scene;
- this.frameInterval = 1000 / fps;
- this.lastTime = new Date().getTime();
- this.loop();
- },
- loop: function() {
- var now = new Date().getTime();
- var elapsed = now - this.lastTime;
- if (elapsed >= this.frameInterval) {
- this.scene();
- this.lastTime = now;
- }
- window.requestAnimationFrame(this.loop.bind(this));
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement