# How to tell which face of a cube is most visible to the camera?

Imagine a camera that shows a randomly rotated cube at an arbitrary position: The cube's pivot is in the center of the cube. This way its six faces could be referred as positive/negative X, Y or Z.

How can you tell which of the faces is most visible to the camera? What's the math to calculate this? Your help is very much appreciated.

Thank you!

public enum CubeFace {
Left,
Bottom,
Back,
Right,
Top,
Front
}

public static GetFaceToward(Transform cube, Vector3 observerPosition) {
var toObserver = cube.InverseTransformPoint(observerPosition);

var absolute = new Vector3(
Mathf.Abs(toObserver.x),
Mathf.Abs(toObserver.y),
Mathf.Abs(toObserver.z),
);

if (absolute.x >= absolute.y) {
if (absolute.x >= absolute.z) {
} else {