[Papervision3D] Animating camera to target

xero xero.nu at gmail.com
Tue Jun 23 09:07:29 PDT 2009


i think you can achieve this w/ interactiveScene3DEvents.

when you click on a plane, you have a function that gets called.
that function takes a parameter of the InteractiveScene3DEvent type. lets
call it "e".

from "e" you can get all kinds of info about the object your
interacting w/ (eg, x/y/z position, rotation, name, material, etc, etc, etc)

i think it would be easy to use the X/Y/Z pos of the plane clicked as a  target
for your camera. just decrease the Z value so the camera will not fly
thought the target plane.

this code is untested!

[code]

function constructor() {
    var thePlane = new Plane(...);
    thePlane.addEventListener(InteractiveScene3DEvent.CLICK, onClick);
    scene.addChild(thePlane);
}
function onClick(e:InteractiveScene3DEvent):void {
    //create a temp object
    var target:DisplayObject3D = new DisplayObject3D();

    //set is positions equal to the clicked object's
    target.x = e.displayObject3D.x;
    target.y = e.displayObject3D.y;
     //offset the z depth
    target.z = e.displayObject3D.z - 300;

    //you can manually move camera position with:
    //cam.copyPosition(target);

    //but honestly, this would look better w/ a tween
    Tweener.addTween(cam, {
          x: target.x,
          y:target.y,
          z:target.z,
          time: 10,
          transision: easeOutSine
     });
}
[code]

like i said, this code is untested (wrote in gmail).
but the core concept is there.

hope that helps!
____  ___
\   \/  /___________  ____
.\     // __ \_  __ \/ _  \
./     \  ___/ | | \( <_>  )
/___/\  \___  >__|---\____/
|     \_/   \/        |
| xero harrison       |
| xero.nu at gmail.com   |
| http://xero.nu      |
| http://fontvir.us   |
| http://hexarray.nu  |
| http://xero.owns.us |
`---------------------'

 ---------- Forwarded message ----------
> From: montey <e_account at mac.com>
> To: papervision3D at osflash.org
> Date: Tue, 23 Jun 2009 08:41:52 -0700 (PDT)
> Subject: Re: [Papervision3D] Animating camera to target
>
> The code you suggested doesn't seem to give the effect I'm looking for.
> Maybe
> I can try and explain this a little better.
> I have 20 planes all moving back in z depth. All I want to do is move my
> camera through them as I click on the next plane. So if I click on plane 2
> the camera will fly through plane 1 and show plane 2 and as I click on the
> next it flys through the next plane.
>
>
>
> gordee wrote:
> >
> >
> > If I have understood what you are trying to do, then try this;
> > interactiveScene3DEvent.target is the plane clicked on;
> >
> > var xpos:Number = iS3DEvent.target.x - iS3DEvent.target.width/2;var
> > ypos:Number = iScene3DEvent.target.y - iS3DEvent.target.height/2;
> > zpos:Number = iScene3DEvent.target.z - 100;
> >
> > Tweener.addTween(camera, {x:xpos, y:ypos, :z:zpos, time:1});
> > hth
> >
> > Regards
> > Gordon Everett
> >
> > My preferred email address: gordon.everett2 at gmail.com
> >
> >  My Blog: http://flashgordonmedia.blogspot.com/
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >> Date: Mon, 22 Jun 2009 22:18:15 -0700
> >> From: e_account at mac.com
> >> To: papervision3D at osflash.org
> >> Subject: [Papervision3D]  Animating camera to target
> >>
> >>
> >> I have 20 planes positioned with z spacing what I'm trying to do is move
> >> the
> >> camera through all my planes as the user clicks on each plane. I'm
> trying
> >> to
> >> figure out how to do that. I tried setting the camera target to the
> >> clicked
> >> plane but that didn't work. I just want to tween the camera through each
> >> plane like a fly through.
> >>
> >> Any ideas please.
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/Animating-camera-to-target-tp24158838p24158838.html
> >> Sent from the Papervision3D mailing list archive at Nabble.com.
> >>
> >>
> >> _______________________________________________
> >> Papervision3D mailing list
> >> Papervision3D at osflash.org
> >> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
> >
> > _________________________________________________________________
> > Get the best of MSN on your mobile
> > http://clk.atdmt.com/UKM/go/147991039/direct/01/
> > _______________________________________________
> > Papervision3D mailing list
> > Papervision3D at osflash.org
> > http://osflash.org/mailman/listinfo/papervision3d_osflash.org
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Animating-camera-to-target-tp24158838p24167340.html
> Sent from the Papervision3D mailing list archive at Nabble.com.
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://osflash.org/pipermail/papervision3d_osflash.org/attachments/20090623/2fc10b2a/attachment.html>


More information about the Papervision3D mailing list