I was programming a puzzle game _editor_ with cubes, and, there I used a different entity for each _side_ of a cube.
Maybe, this helps you to find a way to identify which color looks to which side.

Nonetheless, this is not a trivial task. I wish you good concepts to get this managed!