CADmium-Co / CADmium

A CAD program that runs in the browser
https://cadmium-co.github.io/CADmium/
Other
1.35k stars 50 forks source link

Gradual Transitions when resetting View #75

Open MattFerraro opened 1 month ago

MattFerraro commented 1 month ago

Currently you can reset the view in two ways:

  1. For any Plane in the history, hit the magnifying glass
  2. Use the Gizmo in the upper right corner to hit a plane

In both cases the view is reset, but it can be disorienting because it happens instantly. It would be much better if the effect was gradual, easing your viewport into the new location.

sebsebmc commented 6 days ago

I see that there were attempts to do this with gsap and camera-controls in the past, any reasons that those were removed or didn't work?

I see that Threlte has theater that is their recommended way of introducing animations, but feels potentially overkill if its just for camera easing.

MattFerraro commented 5 days ago

I was able to make the gsap version work in the past and I think that's a viable path. I removed it because I didn't know how to do the quaternion linear interpolation to get from wherever you were to the correct final orientation--I just linearly interpolated the camera position and angle directly. That works okay in some scenarios but leads to really weird visual effects in others. If you can figure out how to handle the quaternions properly, I think it's a good approach!

The attempts with camera-controls worked well but we no longer use camera-controls because camera-controls is completely built around an OrbitControl of the camera instead of a TrackballControl of the camera and there was no obvious way to change it. I wouldn't recommend going down that rabbit hole.

I agree theater is probably overkill, but I could be convinced otherwise!