Die!! (3d) Test 5

Alternative content

Get Adobe Flash player

Hold CTRL and click-drag the mouse in the scene. The die will rotate around the Y-axis.
Hold ALT and click-drag. The die will rotate around it's own center.
Hold CTRL and click-drag. The die still rotates around the Y-axis.
Oh, my brother (and/or sister), this problem has had me worried about my brain. I wasn't able to rotate the die around some axis defined in terms of the absolute axes of the scene (x,y,z). The rotate() method of the 3d object asks for the axis of rotation as a line drawn from the center of the die to a point defined by a vector (x,y,z), but the values of x,y,z were being translated according to how the die was already pitched, yawed, or rolled. I need the die to rotate around an axis according to where it's going, and then when it bounces off something, I need to change the axis according to the angle of the collision.