Hi,
I want to animate an object in a while loop, can someone help me?
I want samething similar as:
while( currentDistance < distance ) {
object.position.x += 0.01
}
Cheers
Hi,
I want to animate an object in a while loop, can someone help me?
I want samething similar as:
while( currentDistance < distance ) {
object.position.x += 0.01
}
Cheers
The problem with using a while
loop like that is that you shouldn’t move the object continuously — just once every frame. To do that you can use requestAnimationFrame, or renderer.setAnimationLoop
. For example:
renderer.setAnimationLoop( function () {
if ( currentDistance < distance) {
object.position.x += 0.01;
}
renderer.render( scene, camera );
} );
Thanks mate