Browse Source

Editor/App: Use renderer animation loop.

Mr.doob 8 years ago
parent
commit
650775f43d
1 changed files with 5 additions and 6 deletions
  1. 5 6
      editor/js/libs/app.js

+ 5 - 6
editor/js/libs/app.js

@@ -175,12 +175,10 @@ var APP = {
 
 		}
 
-		var prevTime, request;
+		var prevTime;
 
 		function animate( time ) {
 
-			request = requestAnimationFrame( animate );
-
 			try {
 
 				dispatch( events.update, { time: time, delta: time - prevTime } );
@@ -199,6 +197,8 @@ var APP = {
 
 		this.play = function () {
 
+			prevTime = performance.now();
+
 			document.addEventListener( 'keydown', onDocumentKeyDown );
 			document.addEventListener( 'keyup', onDocumentKeyUp );
 			document.addEventListener( 'mousedown', onDocumentMouseDown );
@@ -210,8 +210,7 @@ var APP = {
 
 			dispatch( events.start, arguments );
 
-			request = requestAnimationFrame( animate );
-			prevTime = performance.now();
+			renderer.animate( animate );
 
 		};
 
@@ -228,7 +227,7 @@ var APP = {
 
 			dispatch( events.stop, arguments );
 
-			cancelAnimationFrame( request );
+			renderer.animate( null );
 
 		};