OrbitControls on damping end

Hey, is it possible to get notified as soon as OrbitControls has finished moving with damping enabled?

The end event does not take damping in account. It gets fired on pointerup.

https://jsfiddle.net/cLq6t4s7/6/

I, for sure, could check if mouse is up and the camera is moving in a certain frequency or sth like that, but that is too fragile. Or try to hack on the OrbitControls.js directly.

Judging by this - there’s probably no easy way to do it - most of the values and offsets are private, and there are no events fired just on movement.

What you mentioned at the end of your post may be actually a good way to achieve it though - when you receive end event from OrbitControls, just create a debounced event that’s not fired for as long as the camera is changing its position.

2 Likes

I think the change event fires every frame during the automatic move with damping, and stops when it’s still.

Edit : well that’s pretty much what @mjurczyk suggested above

3 Likes

I’d be very interested in this if it had mobile support, and most importantly, supported rotating and object as opposed to the current orbitControls which only supports a rotating camera. Having that as an option will make it a pretty solid contender upsers

Not sure what you mean, but to dampen object rotation (unrelated to orbit controls, which can affect only camera) you can use either a tween / animation library, or a simply a bit of math:

const targetRotation = object.rotation.y + Math.PI;

animate = () => {
  object.rotation.y = Three.MathUtils.lerp(object.rotation.y, targetRotation, 0.1);

  if (object.rotation.y - targetRotation < 0.1) {
    // Do something when rotation is nearing it's target
  }
};

the solution i found is to constantly take the azimuthal and polar angles values and check if they have changed