Detect face normal

Hello,
how do we can detect face normal.
For example, I want to change material of face of a cube (through raycast) when my mouse is over it.

cheers…

Off the top of my head, you can use the Oriented Box Shape and using the vector from the entities origin to the collision point, you can work out which face was clicked on.

This would work for a cube but not box though.

https://developer.playcanvas.com/en/api/pc.OrientedBox.html

You can use the 3D physics which will give you a surface normal at the point of intersection but adds some bloat to the application download size.