Hi,
I’m new to this 3d scene… but one has to evolve…
Anyways, I am developing a simple cube app. I wish to rotate the cube using simple gestures \ key strokes. Each rotation is a simple 90 degrees tween between to two fixed positions. (i.e press LEFT and the cube will rotate 90 degrees CW against the Y Axis.
I tried something like this:
switch (event.keyCode) {
case Keyboard.UP:
case Keyboard.W:
TweenLite.to(cube, 0.3, { rotationX:"-90"})
break;
case Keyboard.DOWN:
case Keyboard.S:
TweenLite.to(cube, 0.3, { rotationX:"90"})
break;
case Keyboard.LEFT:
case Keyboard.A:
TweenLite.to(cube, 0.3, { rotationY:"90"})
break;
case Keyboard.RIGHT:
case Keyboard.D:
TweenLite.to(cube, 0.3, { rotationY:"-90"}}
break;
case Keyboard.Z:
TweenLite.to(cube, 0.3, {rotationZ:"-90"})
break;
case Keyboard.X:
TweenLite.to(cube, 0.3, { rotationZ:"90"})
break;
}
...which kinda worked.. but since the rotation axis are relative to the cube, once the cube is turned up side down and I press LEFT (for instance) the cube can just about rotate to another direction.
Any simple solution?
Vivo