Is there a way to rotate my globe to a specific location every x seconds without running the whole process at once? I've tried putting render() into a for loop with a setTimeout, but it doesn't work as expected. It seems to be related to the recursive nature of render(). Has anyone encountered this issue before and figured out how to solve it?
Any insights or solutions would be greatly appreciated! Thank you in advance.
var lat=41.9028;
var long=12.4964;
var requestId = 0;
var targetx=lat * ( Math.PI / 180 );
var targety=(270 - long ) * ( Math.PI / 180 );
//I want to repeat this periodically every x seconds
render(targetx,targety);
function render(tx,ty) {
controls.update();
sphere.rotation.x += (targetx - sphere.rotation.x) * 0.1;
sphere.rotation.y += (targety - sphere.rotation.y) * 0.1;
clouds.rotation.x += (targetx - clouds.rotation.x) * 0.1;
clouds.rotation.y += (targety - clouds.rotation.y) * 0.1;
var verticalOffset = 0.1;
renderer.render(scene, camera);
camera.lookAt( scene.position );
requestAnimationFrame(function(tx,ty){render(tx,ty)});
}