OrbitControls auto rotate stop when interactive?
Asked Answered
D

2

6

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

Doggone answered 21/11, 2013 at 3:46 Comment(0)
T
7
controls.autoRotate = false;

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

if (controls.AutoRotate)
  controls.autoRotate = false;
Trix answered 21/11, 2013 at 8:38 Comment(0)
I
16

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);
});
Incantatory answered 22/9, 2015 at 14:27 Comment(0)
T
7
controls.autoRotate = false;

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

if (controls.AutoRotate)
  controls.autoRotate = false;
Trix answered 21/11, 2013 at 8:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.