I'm making a 3d dice game and came to one issue I can't wrap my head around so I'm turning to you for help.
In the scene/world (using threejs with cannonjs) I have a plane and one die, which I'm throwing on the plane (screenshots here pre-roll http://prntscr.com/l9rat5, result http://prntscr.com/l9rdeb). All works fine, until I want to throw some specific value on a die like 1 for example.
Since I'm using loaded models instead of texture images for faces of the cube, I cannot handle this just by changing faces of the cube in threejs (since model has 100s of them). Therefore I was hoping I can achieve this by somehow changing the initial quaternion of the body (kind of pre-rotate it) so the die falls on a specific side. The die mesh is just following the body position and quaternion.
I have these questions:
Is this even possible to do? Maybe when I change quaternion pre throw it will result always in different final quaternion, which I can not determine? If it is not possible to do with quaternions, any tips?
If it is possible, how do I figure out by which quaternion do I need to multiply my initial one to get desired result value 1? I have available the final quaternion and I know which values are on each face from emulated throw so I was trying to play with quaternion inverse but no luck.
If I just rotate the initial body so that face 1 rotates to the result face (eg. 6) it works in some cases (i throw 1 when emulated result was 6), but when the throw gets more complicated (more rotations) it is not working of course since I'm not counting on all possible rotations.
If it is not clear what I mean let me know pls.
Thanks a lot m
For the note, I solved it by rotating just the geometry (not mesh) in threejs and not touching the quaternion of the body at all.