Could you explain this line please:
let cameraZ = Math.abs( maxDim / 4 * Math.tan( fov * 2 ) );
I’d write something like this:
let cameraZ = maxDim / 2 / Math.tan( fov / 2 );
and then
camera.position.z = center.z + cameraZ;
Or I missed something?
P.S. I used the following logic:
tan(x) = a / b. a – opposite size. Where x = fov/2, a = size/2 and b = z that we’d like to calc.