, Jr. Member
Hi all,
it seems quite complicated to solve this. I know that it is a lot easier to rotate the camera around an object without gimbal lock.
But this doesn´t solve my situation because i have a few objects in a row and i want to handle each of them seperatly.
So i found this post 360 Camera rotation which moves the camera. (not good for me)
but i also got this solution (which worked until 3.5) with MatrixAway3D
import away3d.core.base.Object3D;
import away3d.core.math.Matrix3D;
import away3d.containers.View3D;
import away3d.primitives.Cone;
import away3d.materials.WireframeMaterial;
//mouse
var mDown:Boolean=false;
var mDownPos:Point=new Point();
//setup scene
var myObject:Object3D = new Cone({name:"Cone1",
segmentsH:5,
segmentsW:20,
height:250,
material:new WireframeMaterial(0xff000000)});
//setup view
var view:View3D=new View3D();
view.scene.addChild(myObject);
view.camera.transform.tz=-2000;
view.x=stage.stageWidth/2;
view.y=stage.stageHeight/2;
//setup stage
this.addChild(view);
stage.frameRate=120;
stage.addEventListener(MouseEvent.MOUSE_DOWN,mousehandler);
stage.addEventListener(MouseEvent.MOUSE_UP,mousehandler);
stage.addEventListener(Event.ENTER_FRAME, mainloop);
//watch mouse up/down
function mousehandler(event:MouseEvent){
mDown=(event.type==MouseEvent.MOUSE_DOWN);
mDownPos=getMousePos();
}
//get current mouse position
function getMousePos():Point{
return new Point(this.mouseX,this.mouseY);
}
//mainloop
function mainloop(event:Event){
var mdiff:Point=getMousePos().subtract(mDownPos);
if(mDown)rotateMatrix(myObject,-(mdiff.x)/4000,-(mdiff.y)/4000);
view.render();
}
//dolly rotation
function rotateMatrix(object:Object3D, x:Number, y:Number):void{
var rot1:Matrix3D=new Matrix3D();
var rot2:Matrix3D=new Matrix3D();
rot1.rotationMatrix(0,1,0,x);
rot2.rotationMatrix(1,0,0,y);
rot1.multiply(rot1, rot2);
rot1.multiply(rot1,object.transform);
object.transform = rot1;
}
Noone has an idea how to make it work in Away 3.6 or even in 4.0 ?