Dynamically set controls.minDistance

Basically, I have this function that moves the camera on the X axis so that the object is always in view no matter the canvas size.

However, this also means that the camera isn’t always in the same place, so I can’t have a constant minDistance on the orbitControls.

If you zoom in the edges of the canvas become visible, which is unwanted.

I tried using cameraToFarEdge, but it’s a constant.

camera offset is saved in offset
camera minDistance is set in fitCameraToCenteredObject()

if the sandbox fails to load, refresh from here
image