WebGLRenderer: animate() → setRenderLoop()?

While working on a new WebVR project, it somehow felt that setRenderLoop() would be a better name than animate() but I’m unsure.

var renderer = new THREE.WebGLRenderer();
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setRenderLoop( render );
document.body.appendChild( renderer.domElement );

function render( timestamp ) {

    renderer.render( scene, camera );

}

Thoughts?

Author: Fantashit

3 thoughts on “WebGLRenderer: animate() → setRenderLoop()?

  1. But I don’t understand why there is this function on a WebglRenderer ?

    Because the WebVR API has its own requestAnimationFrame and renders black if you use window.requestAnimationFrame.

  2. Ended up going with setAnimationLoop().

    With the current implementation you can do this:

    renderer.setAnimationLoop( renderLoop );
    renderer.vr.setAnimationLoop( vrRenderLoop ); // optional, it'll use renderLoop otherwise

Comments are closed.