Advertisement
Guest User

Untitled

a guest
Jun 30th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. var Loop = {
  2. run: function(scene, fps) {
  3. this.scene = scene;
  4. this.frameInterval = 1000 / fps;
  5. this.lastTime = new Date().getTime();
  6.  
  7. this.loop();
  8. },
  9. loop: function() {
  10. var now = new Date().getTime();
  11. var elapsed = now - this.lastTime;
  12. if (elapsed >= this.frameInterval) {
  13.  
  14. this.scene();
  15. this.lastTime = now;
  16. }
  17. window.requestAnimationFrame(this.loop.bind(this));
  18. }
  19. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement