• 3D
  • Frame a 3D object so that it fills the viewport

It is fairly simple to calculate this based on the angle of the offset vector once normalised. However, something that is important is to understand that a node with an extreme size along one axis will still be a problem. In my case, this won't be an issue but for some, it will. An example would be a long pipe that has a narrow radius but extends off down the z-axis by 100 units. If the camera is viewing this looking directly down the z axis the camera would only see the end, but Mersey-Viking's algorithm would position the camera way too far back accounting for the maximum extent i.e. the length.

I have found another article in the Unity docs: https://docs.unity3d.com/Manual/FrustumSizeAtDistance.html This looks to be more accurate when I finish work I am going to have a play with this and see what it produces.

Also, a shout out to Mersey-Viking for the algorithm should he/she ever stray into these here parts.

I don't understand the math in that code, as long as it works it's fine =)