Cant't get faces of a Rubik's cube to rotate properly

Hello everyone,
I am trying to simulate a Rubik’s cube and i can’t get it to rotate properly because of the following problems:

  1. At first rotation of any face when animation is applied, the face make a double rotation at once, but is rotating as expected subsequently.
  2. I am still unable to rotate other faces properly after the first rotation is successfull(not minding the face)

Please can you help me figure out what i’m doing wrong?

use “u”, “d”, “l”, “r”, “e”, “f”, “b” to interact with the cube.

Hello :slight_smile:

I didn’t go too deep into your code, but still there is one point which for sure is problematic : you are using euler rotations on your cubes, instead of Quaternion. If you need to rotate meshes of 90° in 3 axis, then forget about Euler Rotation, and go 100% Quaternion. Otherwise you will hit the gymbal lock issue. I would even say your project is the perfect example of a place where Quaternions are needed :grin:


Have a look at this topic in which I had explained a bit the problem :

3 Likes

Okay, lemmee read through.
I’ll get back to you soon

In case you didn’t see them, these threads could help:

2 Likes

I fixed the playground I originally posted in your other thread:

Edit: added smooth rotation:

Edit2: added engine and scene anti-aliasing (at some cost in fps dipping to 100 on my machine)
and added easing function so it’s not so robotic. Still seeing some edges jump a pixel during some rotations. added a light from the bottom as well. For better performance, I could implement object rotation instead of Arc Camera and going back to a single light, but it works well for now.

Edit3: and maybe final edit. This uses a persistant animation on the sideNode object that is updated and started each tap.

3 Likes

Thank you @HiGreg

But with just 190 lines of code? :flushed:
i sure do have a lot more learning to do :sob: