Search code examples
actionscript-3away3d

Away3d move camera in viewing direction?


I have Away3D camera looking at an object from aerial view.

Now, I want to get closer to that object as I rotate mouse wheel.

I did it using camera lens but it is like adjusting binocular and not actually getting closer to that object,

private function onMouseWheelEvent(e:MouseEvent):void
{
      PerspectiveLens(view.camera.lens).fieldOfView -= e.delta;         
}

Is there any easy solution to this or I will have to write such controller of my own?


Solution

  • I did it using camera.forwardVector like so,

    private function onMouseWheelEvent(e:MouseEvent):void
    {
        view.camera.x = view.camera.x + (e.delta * view.camera.forwardVector.x);
        view.camera.y = view.camera.y + (e.delta * view.camera.forwardVector.y);
        view.camera.z = view.camera.z + (e.delta * view.camera.forwardVector.z);
    }