I have an SCNBox
in an SCNScene. Once the scene animates the SCNBox
changes is orientation which can be seen by checking its presentationNode.ori
node.orientation will give you a quaternion. You can also use node.eulerAngles or node.rotation (axis angle) if that makes your maths easier.
In all cases I think you need to apply the inverse rotation to the vector [0, 1, 0] (up vector). The result vector (V) will give you the direction of the up face. To then find the up face, compare the dot products of the box faces and V. The highest dot product is the one of the face that is facing up.
(An alternative way is to rotate the box's faces instead and do the dot products with [0,1,0].)