Rotating cube with with fixed camera

Software: Away3D 4.x

Vivo, Newbie
Posted: 31 March 2013 10:19 PM   Total Posts: 1

Hi,

I’m new to this 3d scene… but one has to evolve… smile

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(cube0.3{ rotationX:"-90"})
     break;
    case 
Keyboard.DOWN:
    case 
Keyboard.S:
      
TweenLite.to(cube0.3{ rotationX:"90"})
     break;
    case 
Keyboard.LEFT:
    case 
Keyboard.A:
      
TweenLite.to(cube0.3{ rotationY:"90"})
     break;
    case 
Keyboard.RIGHT:
    case 
Keyboard.D:
      
TweenLite.to(cube0.3{ rotationY:"-90"}}
     
break;
    case 
Keyboard.Z:
      
TweenLite.to(cube0.3,  {rotationZ:"-90"})
     break;
    case 
Keyboard.X:
      
TweenLite.to(cube0.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

 

   

Lexcuk, Newbie
Posted: 02 April 2013 03:32 PM   Total Posts: 17   [ # 1 ]

You can try use for cube Matrix3D.interpolate and it will be set animation rotation to the finish on target rotation position of cube

//http://swf-flash.blogspot.com/2013/04/understanding-3d-animation-of-cube.html
Matrix3D.interpolate(cubeRotationStartMatrixcubeRotationTagertMatrixanimationCount); 
   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X