A small workaround I often suggest/have used was to make sure your rotation
never reaches 0 or 180..etc...
So instead of something like
rotationY*=5
try
rotationY*=5.00001
might help it never reach exactly 0.
Hope it helps you out
-Pete
On Wed, Dec 3, 2008 at 2:04 PM, solpyro <[EMAIL PROTECTED]> wrote:
>
> I am having trouble spinning objects about the z axis when theey have
> already been rotated.
>
> In my code I am working with a cube which I can rotate horizontally or
> vertically. I have the code working to select the correct axis for
> rotation, however if I have rotated the cube about the Y-axis, so that
> the Z and X axes have swapped places, rotating with cube.rotationZ
> results in exaxtly the same effect as cube.rotationX, ie. rotating
> around the 'depth' axis as the user sees it.
>
> Below is the code for the rotations. targetX, targetY and targetZ are
> defined numbers containing the rotations we are trying to achieve. It
> is only possible for one if the three rotations to occur at any one
> time ('spinning' controls this).
>
> function onEnterFrame( e:Event ):void {
> //rotate cube about x-axis
> if (targetX != cube.rotationX) {
> trace("rotationg about X");
> cube.rotationX*=5;
> cube.rotationX+=targetX;
> cube.rotationX/=6;
> //snap to position when close
> if
> (cube.rotationX<(targetX+accuracy)&&cube.rotationX>(targetX-
> accuracy)) {
> cube.rotationX = targetX;
> spinning = false;
> }
> }
> //rotate cube about y-axis
> if (targetY != cube.rotationY) {
> trace("rotationg about Y");
> cube.rotationY*=5;
> cube.rotationY+=targetY;
> cube.rotationY/=6;
> //snap to position when close
> if
> (cube.rotationY<(targetY+accuracy)&&cube.rotationY>(targetY-
> accuracy)) {
> cube.rotationY = targetY;
> spinning = false;
> }
> }
> //rotate cube about z-axis
> if (targetZ != cube.rotationZ) {
> trace("rotationg about Z");
> cube.rotationZ*=5;
> cube.rotationZ+=targetZ;
> cube.rotationZ/=6;
> //snap to position when close
> if
> (cube.rotationZ<(targetZ+accuracy)&&cube.rotationZ>(targetZ-
> accuracy)) {
> cube.rotationZ = targetZ;
> spinning = false;
> }
> }
>
> view.render();
> }
>
> In an effort to debug this, I have removed this code from my
> enterFrmae event, and replaced it with a simple cube.rotationZ += 2;
> This works fine when the cube hasn't been modified in any way, but if
> i first apply a y-rotation of 90, the same issue described above
> occurs.
--
___________________
Actionscript 3.0 Flash 3D Graphics Engine
HTTP://AWAY3D.COM