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/)
OrbitControls auto rotate stop when interactive?
Asked Answered
controls.autoRotate = false;
Just start it on init with 'true', then onMouseMove, do something like:
if (controls.AutoRotate)
controls.autoRotate = false;
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;
© 2022 - 2024 — McMap. All rights reserved.