This only stops the controls from further rotation. But if my camera is still rotating and decelerating as a result of a recent mouse drag, it still continues to rotate until fully decelerated.
What I need is a way to instantly stop the rotation exactly where it is, the moment I call the function. I thought setting rotateSpeed to 0 would help, but it doesn’t.
You can set the controls orbit autoRotate boolean to false using an event listener when starting the interaction with the orbit controls.
To make it more fancy you can start the autoRotate again after a certain time.
Don’t forget to call the controls update function in the animation loop.
See this code:
controls.autoRotate = true;
controls.autoRotateSpeed = 4.0;
let timeoutID = undefined;
controls.addEventListener("start",()=>
{
//Clean an existing timeout first
if(timeoutID != undefined)
{
clearTimeout(timeoutID);
timeoutID = undefined;
}
//Stop the auto rotation
controls.autoRotate = false;
//Start the auto rotation again after 3 seconds
timeoutID = setTimeout(function()
{
controls.autoRotate = true;
}, 3000);
});