yomotsu / camera-controls

A camera control for three.js, similar to THREE.OrbitControls yet supports smooth transitions and more features.
https://yomotsu.github.io/camera-controls/
MIT License
2.05k stars 256 forks source link

Method to stop transitions? #530

Open diemildefreude opened 4 months ago

diemildefreude commented 4 months ago

Is your feature request related to a problem? Please describe.

I have an automatic movement setup for when the user is idle. If the user inputs movement (drag, scroll/pinch), I can cancel any subsequent movements, but any current rotate() or dolly/dollyTo() method-call continues until it's done. I'd like the auto-transition to immediately stop, ceding complete control to the user.

Describe the solution you'd like

There was a similar feature request here before for a cameraControls.cancelAllTransitions() method, but the user rescinded it. In their case, they mistakenly thought that multiple transitions were fighting with each other, but it was an error on their end. However, my request is related to the auto-transition fighting with live user inpt.

So yes, something like cancelAllTransitions() would be nice...

Describe alternatives you've considered

I've been trying workarounds like calling a new dollyInFixed(0, false) followed by cameraControls.update(0), but no success yet. If I set smoothTIme = 0, it jumps to the destination of the previous dollyInFixed call.

Additional context

The problem is easy to see in the infinite dolly example if you change the dollyInFixed values to 10/-10 and set cameraControls.smoothTime = 10.

yomotsu commented 3 months ago

Sorry for the delay. I just added a new method called stop().

cameraControls.stop();
diemildefreude commented 1 month ago

Sorry for the delay. I just added a new method called stop().

cameraControls.stop();

Hi, thanks for adding this- just getting to test it now. It works fine for rotating, but when I use it to interrupt an InfiniteDolly motion started by cameraControls.dollyInFixed(distance, true), it suddenly jumps in the direction of the transition instead of staying where it is.