HI,
First of all - great 3d package! I’ve managed to add it to my current Flex project with only minor problems (my mistakes) and I’ve been very impressed so far.
On to the problem - I have 64 cubes contained in an ObjectContainer3D and I’d like them to rotate 90 degrees on a different axis when I press a button. It kind-of-works (the gimbal lock threw me for a bit) but I’m hoping there’s a better way. My hope for this is to develop something similar to a Rubik’s cube - like a number puzzle.
Here’s what I’ve done so far in order to make the container rotate:
public function rotateCube(axis:String, deg:int = 90):void
{
if (!Tweener.isTweening(cubeContainer)) {
var mat:Matrix3D = dummyCube.transform.clone();
switch (axis) {
case 'x':
mat.appendRotation(deg, new Vector3D(1, 0, 0));
break;
case 'y':
mat.appendRotation(deg, new Vector3D(0, 1, 0));
break;
case 'z':
mat.appendRotation(deg, new Vector3D(0, 0, 1));
break;
}
dummyCube.transform = mat;
// Tween it!
Tweener.addTween(cubeContainer, { rotationX: dummyCube.rotationX, rotationY: dummyCube.rotationY, rotationZ: dummyCube.rotationZ, time: 0.7, transition:'easeOutBack' });
}
}
A matrix transformation is applied to a dummy cube, then the Tweener rotates the container to match the rotationX/Y/Z of the dummy. It has potential, but I think I’m doing it wrong and would welcome some advice.
Cheers