If you placed a row of boxes across the screen and give all of them a rotationY of 90, you might have expected to not see anything on screen because all the boxes would be perpendicular to the screen. Instead, this is what you get:
The PerspectiveProjection class has 3 public properties that you can modify:
- projectionCenter - a Point that determines the vanishing point. It is at the center of the stage by default. For objects to have the same rotation results, set the projectionCenter relative to the object. (all objects have their own perspective projection where the projection center is dependent on location of the object)
- fieldOfView - an angle between 0 and 180. This value determines the strength of the perspective transformation and distortion.
- focalLength - z distance between viewpoint and display object. This is calculated automatically so you generally don't need to mess with it.
import flash.geom.PerspectiveProjection; import flash.geom.Point; var pp:PerspectiveProjection=new PerspectiveProjection(); pp.fieldOfView=90; pp.projectionCenter=new Point(0,0); displayobject.transform.perspectiveProjection=pp;
Here's a tool to explore the effects of PerspectiveProjection. Click on the stage to move the projectionCenter (vanishing point) around. Use the sliders to apply 3D rotations to the boxes. Field of View can also be altered with the slider. Tick the check box to apply the same projection to all the boxes. Untick it to apply individual projections with the vanishing point at the location of each box.
p.s. Depth ordering was ordered via distance from vanishing point. Boxes closer to the point are above boxes further away.
Had quite some fun with the above app that I also made it into an interesting animation.