Hi i am reading Learning Three.js,i think jos misuse the requestAnimationFrame

wrong:
// controll time by render
requestAnimationFrame(render)
correct:
// controll time by setTimeout
function render(){
setTimeout(()=>{ requestAnimationFrame(render) },1000/60)
}

You shouldn’t be using setTimeout with a requestAnimationFrame inside of it. That’s probably delaying your rendering because you’re waiting for 1 frame before requesting the next frame.

Just use the standard setup demonstrated in the Getting Started page:

function animate() {
	requestAnimationFrame( animate );
	renderer.render( scene, camera );
}
animate();
2 Likes