Tuesday, January 12, 2010

How to change 3D perspective (camera POV) in Actionscript 3

In Actionscript 3 for Flash CS4 (Flex SDK 3.2 or newer) Adobe added some new features for simple 3D DisplayObject manipulation. You can rotate display objects in 3D space, but if you need to add your component to other display container your 3D perspective probably will be changed. The biggest problem is that for all 3D views default camera position is center of main scene, not of your display object.

So if you need to specify concret position of camera just for your display object you need to specify PerspectiveProjection and set it to your transform property. This is code:

var perspective:PerspectiveProjection;
perspective = new PerspectiveProjection();
perspective.projectionCenter = new Point(400, 300);
transform.perspectiveProjection = perspective;

No comments: