I am using react-three-fiber and would like to use the Bounds component to automatically align the camera with my object. I noticed that here comes to problems when you choose min-max values for OrbitControls.
For example maxDistance is overwritten and with certain minDistance, maxPolarAngle, etc. the camera alignment does not work at all.
Is there a way that the limits can be controlled by during camera alignment, but reset after successful alignment?
This may be a better question for the react-fiber community, but I’m happy to look at a fiddle if you can create one! Typically you need to call controls.update() after a manual change of a camera.
looking at the code it will calculate clipping when you do <Bounds clip ...drei/Bounds.tsx at 0ba64bb78edc4469fd7eb3620370663b8f97bafa · pmndrs/drei · GitHub so omitting that should allow you to set clipping yourself. otherwise i would suggest you make changes to the component and pr it. this thing cost my all my nerves as i had to scrape through all of discourse and stackoverflow to make it, lacking all deeper understanding of the math involved. i wish someone would comb over it and polish it.
Yes, the clip parameter was my problem. That solved the issues with control limitation.
My initial problem was something different though. The perspective was changing even though I was using an orthographic camera. I had a look in the code and in my case the problem was that the direction is also included in the orthographic camera. I extended fit() by the lines so that the camera always keeps the same orientation.
if (isOrthographic(camera)) {
direction.x = 0
direction.z = 0
}
But that only fits my particular case, I would say.