Discussion:
Camera Orbit with "Back" ease
Kevin Burke
2010-10-13 17:18:50 UTC
Permalink
I submitted a Papervision scene to my client yesterday with a mouse-draggable
camera orbit.

They came back with the following comment:

· When dragging do an ease out of the motion on release of the mouse.
Similar to scrolling of menus on an iPhone, you should keep track of the
acceleration and continue motion after the mouse release.

I am currently using the following code to drag my camera in orbit with an
ease:


private var isOrbiting:Boolean;
private var previousMouseX:Number;
private var previousMouseY:Number;
private var easePitch:Number = 90;
private var easeYaw:Number = 270;
private var easeOut:Number = 0.2;
private var camPitch:Number = 90;
private var camYaw:Number = 270;

private function downHandler(event:MouseEvent):void
{
isOrbiting = true;
previousMouseX = event.stageX;
previousMouseY = event.stageY;
}

private function upHandler(event:MouseEvent):void
{
isOrbiting = false;
}

private function moveHandler(event:MouseEvent):void
{
var differenceX:Number = event.stageX - previousMouseX;
var differenceY:Number = event.stageY - previousMouseY;

if(isOrbiting)
{
camPitch += differenceY;
camYaw += differenceX;

previousMouseX = event.stageX;
previousMouseY = event.stageY;

easePitch += (camPitch - easePitch) * easeOut;
easeYaw+= (camYaw - easeYaw) * easeOut;
}
}

private function render(e:Event):void {
camera.orbit(easePitch, easeYaw);
renderer.renderScene(scene, camera, viewport);
}


This would obviously be easier if I were using TweenLite's "Back" ease to
overshoot the event.stageX & Y as in the iPhone menu. I need help to either
get this code working with TweenLite OR code an ENTER_FRAME "Back" ease
formula. Anything to get me started would be fantastic.

They also asked for the orbit to be more elliptical than circular, but
that's for another post.
--
View this message in context: http://papervision3d.758870.n4.nabble.com/Camera-Orbit-with-Back-ease-tp2994066p2994066.html
Sent from the Papervision3D mailing list archive at Nabble.com.
Kevin Burke
2010-10-13 19:41:50 UTC
Permalink
Okay, I found a solution! It is based on a class from Jozef Chúťka:

http://blog.yoz.sk/2010/04/smooth-orbiting-camera-in-papervision-3d/
http://blog.yoz.sk/2010/04/smooth-orbiting-camera-in-papervision-3d/

I customized the code for TweenMax by replacing the Tweener call with this:

TweenMax.to(this, 2, {onUpdate:updateCamera, cameraYaw:cameraYaw +
calc(dxList, dx), cameraPitch:cameraPitch + calc(dyList, dy),
ease:Back.easeOut, overwrite:true});

Hope this helps someone who has the same problem I did.
--
View this message in context: http://papervision3d.758870.n4.nabble.com/Camera-Orbit-with-Back-ease-tp2994066p2994328.html
Sent from the Papervision3D mailing list archive at Nabble.com.
Continue reading on narkive:
Loading...