HoverController with infinite tilt

Software: Away3D 4.x

amcc, Newbie
Posted: 12 December 2011 12:40 AM   Total Posts: 10

I’m working with away3d 4. I want to create a hovercontroller with infinite tilt so i can freely rotate around an object

the bits of code below allow me to do this but when the tilt goes beyond -90 or +90 the object flips (ie appears to do an instant 180 degree rotation)

cameraController = new HoverController(cameranull150102000);
cameraController.minTiltAngle = -Infinity;
cameraController.maxTiltAngle Infinity

then the mouse control is done like this

private function onEnterFrame(ev Event) : void
{
  
// Handle hover camera
    
if (move{
      cameraController
.panAngle 0.3 * (stage.mouseX lastMouseX) + lastPanAngle;
      
cameraController.tiltAngle 0.3 * (stage.mouseY lastMouseY) + lastTiltAngle;
    
}   
    _view
.render();
}
private function mouseDownHandler(e:MouseEvent):void
  {
    stage
.addEventListener(Event.MOUSE_LEAVEonStageMouseLeave);
      
lastPanAngle cameraController.panAngle;
      
lastTiltAngle cameraController.tiltAngle;
      
lastMouseX stage.mouseX;
      
lastMouseY stage.mouseY;
      
move true;
  

 

   

John Brookes, Moderator
Posted: 12 December 2011 11:49 AM   Total Posts: 732   [ # 1 ]

Stick this in the same folder as HoverController

It has easing on the distance and allows for an infinite tilt.
eg
camController.noFlip = true;

   

amcc, Newbie
Posted: 12 December 2011 01:05 PM   Total Posts: 10   [ # 2 ]

thats for the help
I cant download that file - is there a problem with file attachments or am i being stupid

   

John Brookes, Moderator
Posted: 12 December 2011 01:08 PM   Total Posts: 732   [ # 3 ]

Sorry I thought the forum could now handle .as files

   

inSertCodE, Sr. Member
Posted: 12 December 2011 02:04 PM   Total Posts: 105   [ # 4 ]

“-Infinity;” ???

The default values of maximum and minimum tilt are infinite. So when declaring the Hover Controler “new HoverController(camera…);” leave the max and min pan and tilt angle empty or see whats the default value (i can’t remember what it was and I don’t have away3d at this moment).

   

John Brookes, Moderator
Posted: 12 December 2011 03:00 PM   Total Posts: 732   [ # 5 ]

Nope the max min tilt defalut is -90 90.

To have the camera rotate without restriction then you need to set to Infinity.
The next issue is flipping at the poles, which is solved by flipping the up axis thats passed to lookAt.
Hence the little editted class above wink

   

amcc, Newbie
Posted: 12 December 2011 03:17 PM   Total Posts: 10   [ # 6 ]

that would be the solution, thanks john - again i can’t download that file.

Are you able to download these? I’m on a mac and i’ve tried chrome and safari - the link opens a new blank window but nothing downloads. Perhaps this forum has some issues, i was getting mysql errors when searching this morning (though that seems ok now).

   

John Brookes, Moderator
Posted: 12 December 2011 03:23 PM   Total Posts: 732   [ # 7 ]

[REMOVED LINK]

Just noticed
Theres an unnecessary import in that
import flash.geom.Matrix3D;
Just delete it

   

amcc, Newbie
Posted: 12 December 2011 03:33 PM   Total Posts: 10   [ # 8 ]

Thanks so much John, just got all that working. Its a beauty!

Perhaps this code should be integrated into core, its seems so useful as spinning a camera all around a model seems a pretty useful thing to do.

   

careca, Newbie
Posted: 16 September 2013 12:27 PM   Total Posts: 14   [ # 9 ]

Hi

I get this errors:
“lib\away3d\controllers\HoverControllerJB.as(310): col: 28 Error: Incompatible override”

so I change:
public override function update():void
to
public override function update(interpolate:Boolean = true):void


but now I Have this error:

[Fault] exception, information=TypeError: Error #1009: Cannot access a property or method of a null object reference. on the line 340 because the “lookAtObject” are null.

any help ?

   

John Brookes, Moderator
Posted: 16 September 2013 01:32 PM   Total Posts: 732   [ # 10 ]

Old post for an older version of Away so don’t use.

   

careca, Newbie
Posted: 16 September 2013 02:03 PM   Total Posts: 14   [ # 11 ]

Tanks for the reply.
I need to rotate my camera so infinite. Is there any way?

   

careca, Newbie
Posted: 16 September 2013 02:44 PM   Total Posts: 14   [ # 12 ]

problem solved! grin

   

baxterKC, Newbie
Posted: 31 March 2014 11:01 AM   Total Posts: 2   [ # 13 ]

Hello!

I tried the HoverControllerJB.as as well but it doesn’t seem to work with infinite tiltangle and I was wondering how careca solved this or is there a more simple ways of achieving this?

Thanks

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X