How to make auto rotate of OrbitControls stop when mouse interactive, and after few second it start like P3D.in does here with their logo (http://p3d.in/)
For people googling, if you want to stop the autorotate after the first interaction; you can hook up an event listener on one of the 3 events OrbitControls emits:
// stop autorotate after the first interaction
controls.addEventListener('start', function(){
controls.autoRotate = false;
});
Or even more advanced, restart the autorotate after the user has ended the last interaction, with a timeout of 1000 milliseconds:
// stop autorotate after the first interaction
controls.addEventListener('start', function(){
clearTimeout(autorotateTimeout);
controls.autoRotate = false;
});
// restart autorotate after the last interaction & an idle time has passed
this.controls.addEventListener('end', function(){
autorotateTimeout = setTimeout(function(){
controls.autoRotate = true;
}, 1000);
});
controls.autoRotate = false;
Just start it on init with 'true', then onMouseMove, do something like:
if (controls.AutoRotate)
controls.autoRotate = false;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With