Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OrbitControls auto rotate stop when interactive?

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/)

like image 975
n2g6t1q1 Avatar asked Nov 21 '13 03:11

n2g6t1q1


2 Answers

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);
});
like image 134
polyclick Avatar answered Nov 20 '22 05:11

polyclick


controls.autoRotate = false;

Just start it on init with 'true', then onMouseMove, do something like:

if (controls.AutoRotate)
  controls.autoRotate = false;
like image 7
GuyGood Avatar answered Nov 20 '22 06:11

GuyGood