Oooh. I thought the distance was a radius thing. 'You have the pan the camera this much in some direction' kind of thing.
However, it looks like distance calculate is coming up short.
Now ignoring that the panning is wrong, the box should fit the screen, or at worse, spill past either the top or bottom of the screen due to bad/no panning. The distance calculation seems fine.
bottom size = half map x * absolute(x-axis • bottom normal) + half map y * absolute(y-axis • bottom normal) + half map z * absolute(z-axis • bottom normal) left size = half map x * absolute(x-axis • left normal) + half map y * absolute(y-axis • left normal) + half map z * absolute(z-axis • left normal) and etc.. vertical distance = (top size + bottom size) / (2 * sin(vertical FoV / 2)) horizontal distance = (leftSize + rightSize) / (2 * sin(horizontal FoV / 2)) distance = max(vertical distance, horizontal distance) camera position = normalized camera direction * distance