With the aid of the Papervision3D class org.papervision3d.events.InteractiveScene3DEvent it’s easy to create an interactive papervision 3D primitive such as this Cube (click on it’s sides):
The cube uses the BitmapMaterial class (the sides are embedded jpg’s) and all we need to do to make them interactive is to remember to set interactive to true:
1 2 | bitmapMaterial6.name = "6"; bitmapMaterial6.interactive = true; |
Once we created our cube the last bit is just to add the event listener to the InteractiveScene3DEvent which is dispatched by the Cube. And we can use the event property evt.face3d.material.name of the current material side clicked to retrieve the name of the same:
1 2 3 4 5 6 7 | // create a cube based on the list primitive = new Cube(materiallist, 400, 400, 400, 3, 3, 3); primitive.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK, handleClick); //.../ private function handleClick (evt:InteractiveScene3DEvent) :void { testText.text = "__side clicked : " +evt.face3d.material.name; } |
The InteractiveScene3DEvent is not limited to click events however, the documentation at http://papervision3d.googlecode.com/svn/trunk/as3/trunk/docs/org/papervision3d/events/InteractiveScene3DEvent.html – shows that we can also listen for MOVE, OVER, OUT, etc. Nice.
If you would like to get hold of the full code for this example then you can download it here (Flashdevelop project).
Theres some great Papervision tutorials over at http://www.madvertices.com where I’ve taken several myself!
0 Responses to “Papervision3D, interactive material”