[Papervision3D] Camera around / following object

Javier España | javierespana.com info at javierespana.com
Mon Jul 20 12:27:38 PDT 2009


Hi there,

I've managed to load an object I want to display, and have a camera that is
controlled by the mouse movement and wheel that circles around it and zooms
in and out... Using this:

*Listeners:*

stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoving);
stage.addEventListener(MouseEvent.MOUSE_WHEEL, mouseWheel);

*Functions:*

private function mouseWheel(event:MouseEvent):void{
        ///
        camera.moveForward(10 * event.delta);
}

private function mouseMoving(event:MouseEvent):void{
        ///
        var differenceX:Number = event.stageX - previousMouseX;
        var differenceY:Number = event.stageY - previousMouseY;
        ///
        cameraPitch += differenceY;
        cameraYaw += differenceX;
        ///
        previousMouseX = event.stageX;
        previousMouseY = event.stageY;
}

*onEnterFrame:*

cameraPitch %= 360;
cameraYaw %= 360;
///
cameraPitch = cameraPitch > 45 ? cameraPitch : 45.0001;
cameraPitch = cameraPitch < 90 ? cameraPitch : 89.9999;
///
camera.orbit(cameraPitch, cameraYaw);
///
renderer.renderScene(scene, camera, viewport);

-------------

The thing is that I now added some code to be able to move the object using
some keys... And the camera seems to be stuck on the same place and not
follow the object... I need the user to move the object with the keys, but
that the camera still circles the object pointing at it all the time...

Any help? I've searched the list but couldn't find an answer that worked for
me...

Thanks,

Javier
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://osflash.org/pipermail/papervision3d_osflash.org/attachments/20090720/929aba46/attachment.html>


More information about the Papervision3D mailing list