How to calculate direction vector of camera looking from aerial view?

Software: Away3D 4.x

Rajneesh, Jr. Member
Posted: 27 June 2014 12:09 PM   Total Posts: 34

I have camera looking at an object from aerial view.

I want to go nearer to that object as I rotate mouse wheel. I tried it using lens like so,

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

But it is binocular effect. I need that camera change it position along its viewing direction vector.

How to get this vector. Help please.

   

Avatar
Fabrice Closier, Administrator
Posted: 27 June 2014 12:20 PM   Total Posts: 1265   [ # 1 ]

Use camera.forward vector and multiply each components by a value extrapolated from your onMouseWheelEvent delta value. Like camera.x = camera.x+(someDistanceExtrapolatedFromMouseDelta*forwardVector.x);

   

Rajneesh, Jr. Member
Posted: 27 June 2014 12:48 PM   Total Posts: 34   [ # 2 ]

Thanks Fabrice for your quick help.

It worked. I did it like so,

view.camera.view.camera.x+(e.delta*view.camera.forwardVector.x);
view.camera.view.camera.y+(e.delta*view.camera.forwardVector.y);
view.camera.view.camera.z+(e.delta*view.camera.forwardVector.z); 
   

Avatar
Fabrice Closier, Administrator
Posted: 27 June 2014 01:35 PM   Total Posts: 1265   [ # 3 ]

Glad it helped, tho I’ve used “someDistanceExtrapolatedFromMouseDelta” in my example, because depending on platform and your scenery scale, you probably need to adjust the increase (you do not want force your users to scroll a lot to move a little or vice versa).

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X