In Chapter 1, Building Your First Away3D Application, we briefly touched on the Camera3D
class. Just like a real life camera, the Camera3D
class has a number of properties that can be modified, such as focus, zoom, and field of view. In this chapter, we will see how these properties affect the camera, and how they can be used in conjunction with the various lens classes that are included with Away3D.
Away3D also includes a number of additional camera classes that provide an easy way to trail a moving 3D object, always keep a particular 3D object in view, or to view a 3D object from a variety of different angles.
In this chapter, we will cover the following topics:
In photography, adjusting the focal length of a camera lens modifies its angle of view (also known as field of view, or FOV). You can see how this works in the following diagram:
As you can see, a short focal length increases the cameras FOV, while a long focal length decreases it. The greater the FOV, the more of a scene is captured by the camera. Because the physical size of a photograph does not change, this necessarily means that each object in the scene will appear smaller on the photograph. As the FOV decreases, so too does the area of a scene that is captured by the camera, which in turn increases the size of the objects that appear in the photograph.
The Camera3D
class includes a property called focus
, which has similar properties to the focal length. As the focus
property is increased, the FOV (represented by the fov
property) decreases, reducing the scene's visible area, and enlarging the size on the screen of those 3D objects that are visible. Conversely, decreasing the focus
property will increase the FOV, which will make more of the scene visible, thus reducing the size on the screen of any visible 3D objects.
The Camera3D
class also includes a property called zoom
. As you would imagine, increasing the zoom
property will "zoom-in" the camera. Zooming in is achieved by reducing the FOV, and this is exactly how the zoom
property works in the Camera3D
class too: increasing the zoom
property will decrease the camera's FOV, while decreasing the zoom
property will increase the camera's FOV.
The fov
property itself can be modified directly, and doing so will also modify the zoom
property accordingly that is, increasing the fov
property will decrease the zoom
property, and decreasing the fov
property will increase the zoom
property.
The zoom
or focus
properties can be used interchangeably when using the PerspectiveLens
, OrthogonalLens
, and SphericalLens
classes (discussed in the following Camera lenses section). The ZoomFocusLens
class will render the scene differently depending on the values assigned to the zoom
or focus
properties, although generally speaking the variation is minor.
The CameraPropertiesDemo
application, available on the Packt website, allows you to modify the focus
, zoom
, and fov
properties of a camera viewing a scene filled with cubes. This allows you to see the relationship between the three properties on a live Camera3D
object.