Papvervision 3D programming tutorial - Photo Cloud
65In 3D applications mouse picking refers to the process of determining the object that lies directly underneath the mouse cursor. In a 2D environment this is a very simple task as the 2D coordinates of the mouse map directly to the 2D coordinates of the 2D elements. However in a 3D environment translating the 2D mouse coordinates into a position in a 3D world can be quite involved.
Fortunately for us the Papervision Viewport3D object has a nifty little function called hitTestPoint2D, which allows us to pass in the mouse coordinates and get the DisplayObject3D (if any) that lies directly underneath.
This sample application makes use of this functionality to allow the user to select a plane (which represents a photo) that is rotating slowly around a central point. Once selected the photo is brought to the front and displayed.
Most of the work is done in the PickableObjectManager onMouseDown function, and the Picture enterFrame function. When the mouse is pressed the PickableObjectManager uses the hitTestPoint2D function to see if any of the registered PickableObject’s (the Picture class extends the PickableObject class) were selected. If so that PickableObject’s mousePicked function is called, while the otherPicked function is called on all other PickableObject’s. Once picked, a Picture will move to the front of the scene. When another Picture is selected it moves back into the rotating cloud.
Check out the demo here, and get the source code here.
Find more Flash tutorials here.
PrintShare it! — Rate it: up down flag this hub
Comments
Thank you SO much. I have been looking everywhere for how this is done. There's a stellar example on photographer Lee Crum's website (by Ourvice.com). This is a beautiful way to display a portfolio.










Research Analyst says:
12 months ago
What a cool feature of how the pickableobjects feature creates the effect of how a picture moves in a scene.