Open and Close a box in Papervision3D 2.0
December 31, 2007 – 1:12 pm Tags: actionscript 3, Cube, flash, Great White, Open and Shut Box, papervision3d, PlanesHere is a quick example of contructing a cube using Planes instead of the Cube primitive in Papervision3D. Click the picture to view the opening and shutting cube.
-Once the cube is open, click the bottom of the inside in order to close it again.
This technique makes it possible to open and close the cube, so you can hide little goodies inside of it.
The rotation of the top plane makes it all a little more difficult.
You’d think you would be able to easily rotate a plane to create this effect, but because objects rotate from their center, you have to make a little work-around to rotate a plane from its edge.
Basically, you’ve got to create an empty DisplayObject3D, and place its center on the edge you want to rotate from. Then you create the plane you want to rotate, and attach it to the empty DisplayObject3D.
So then when you want to rotate the plane, you simply rotate the empty DisplayObject3D instead of the plane itself, and, tada.. it works.
Happy New Year, here’s the source!




4 Responses to “Open and Close a box in Papervision3D 2.0”
Really nice.
Was working on something “simialar” last week, but I was using the cube class, excluding a face and setting a plane to that position.
The rotation was handled the same way then.
But with all sides being planes you can do some nifty stuff of course. Thanks for posting!
By Marcel on Jan 2, 2008
Hi!
great example, unfortunately the class “CubeFront” is missing…
By niklas wörmann on Jan 11, 2008
Hi Niklas,
Was the .fla file included in the source? I can’t quite remember.
I think it was a 300×300 movie clip with an export name as “CubeFront”. That’s the one with the text on it. You could just replace it with a flatShadeMaterial instead.
Let me know-
Thomas
By Thomas on Jan 11, 2008
Hi!
Ok, I was just trying to compile it in Flex, since i, wrongly, assumed there was nothing but a pointer to the document class in the fla.
i´ll try to get it to work in flex now when i know what is going on.
thanks
niklas
By niklas wörmann on Jan 11, 2008