I am building a rubik cube simulation based the great work of others I found here Animate rotateOnWorldAxis - #5 by PavelBoytchev.
However, I am trying to generalize the logic to an n-sized rubik cube and not just 3 sided.
I have got almost everything except for even sided cubes the rotation seems to cause a weird shift in position of the layer. I suspect this is due to the assymetry around origin. I tried a few tricks to try to translate to get it to come back to the correct position but it does not seem to work.
Before rotation:
After rotation:
Note: When building the cube I am trying to center it to the scene so it starts with (- size / 2) and goes till ((size / 2) - 1), so for even 4 sided one this would be from -2 to 1.