I have a mesh that has been arbitrarily rotated. I would like to rotate it so that it is flat on the ground. My idea is to find the closest normal to the y-axis and then align that normal to the axis. I’m using a widely accepted answer on Stackoverflow as a basis: math - Finding quaternion representing the rotation from one vector to another - Stack Overflow
However, I am getting a weird skewed result instead of the rotation that I would expect. After the rotation, I would expect the normal of the blue face to be (0, 1, 0) (aligned to the y-axis). If you comment out line 50, you can see what the box looks like before applying the quaternion.
Does anyone have experience with this? I’m afraid there is likely just something I don’t understand about quaternion rotations happening here.