Smooth zoom

Software: Away3D 4.x

u6792345, Newbie
Posted: 24 August 2013 10:32 AM   Total Posts: 12

Hi, this is my scripts, is there anyway to smooth zoom ?

private function onMouseWheel(event:MouseEvent) : void
  {
  cameraController.distance -= event.delta*5;
 
  if (cameraController.distance < 300)
  cameraController.distance = 300;
  else if (cameraController.distance > 1000)
  cameraController.distance = 1000;
  }

   

Mario M., Newbie
Posted: 24 August 2013 06:23 PM   Total Posts: 12   [ # 1 ]

try this (not tested but its math stuff, must work):

var distance:Number;
var zoomSpeed:Number = 2; //1..N Higher will be smoother

...
//initialize somewhere
distance = cameraController.distance;
...

private function onMouseWheel(event:MouseEvent) : void
{
  distance -= event.delta*5;
  if (distance < 300)
  distance = 300;
  else if (distance > 1000)
  distance = 1000;

  cameraController.distance += (distance - cameraController.distance) / zoomSpeed;

}

   

u6792345, Newbie
Posted: 25 August 2013 03:41 AM   Total Posts: 12   [ # 2 ]

Thanks but it doesn’t work, it just change speed of zoom, can someone make the zoom smooth like this demo http://www.nissan.co.uk/GB/en/vehicles/crossovers/juke/personalisation.html

   

GrokDD, Newbie
Posted: 25 August 2013 08:20 PM   Total Posts: 28   [ # 3 ]

I looked at the link. The zoom isn’t all that smooth on my i7 tablet. You must have a better video card

1) increase your framerate
[SWF(width = “640”, height = “480”, frameRate = “60”, backgroundColor = “#dddddd”)]

2)  decrease the step increment
you have -= event.delta*5
Lower the 5. However, it will take longer to get the min-max.

one or the other will smooth the zoom. Added together, would be even more effective.

   

Avatar
alihm, Jr. Member
Posted: 01 September 2013 01:28 PM   Total Posts: 49   [ # 4 ]

It’s better to use lens.fieldOfView for zooming instead of moving the camera back and forth.

_camFOV your_desired_zoom;

(
_camera.lens as PerspectiveLens).fieldOfView += (_camFOV - (_camera.lens as PerspectiveLens).fieldOfView)/_zoomSpeed
   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X