提交 0e3d73d3 编写于 作者: M Mr.doob

WebGLRenderer: Refactored animation loop code.

上级 f5fa63a8
...@@ -1004,22 +1004,34 @@ function WebGLRenderer( parameters ) { ...@@ -1004,22 +1004,34 @@ function WebGLRenderer( parameters ) {
}; };
// Rendering // Animation Loop
this.animate = function ( callback ) { var isAnimating = false;
var onAnimationFrame = null;
function start() {
function onFrame() { if ( isAnimating ) return;
( vr.getDevice() || window ).requestAnimationFrame( loop );
callback(); }
( vr.getDevice() || window ).requestAnimationFrame( onFrame ); function loop( time ) {
} if ( onAnimationFrame !== null ) onAnimationFrame( time );
( vr.getDevice() || window ).requestAnimationFrame( loop );
( vr.getDevice() || window ).requestAnimationFrame( onFrame ); }
this.animate = function ( callback ) {
onAnimationFrame = callback;
start();
}; };
// Rendering
this.render = function ( scene, camera, renderTarget, forceClear ) { this.render = function ( scene, camera, renderTarget, forceClear ) {
if ( ! ( camera && camera.isCamera ) ) { if ( ! ( camera && camera.isCamera ) ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册