Just like a real camera, the Away3D camera classes can view the scene through a variety of different lenses. There are four lens classes available in Away3D, each from the away3d.cameras.lenses
package:
ZoomFocusLens
PerspectiveLens
OrthogonalLens
SphericalLens
Applying an instance of these lens classes to a camera object is as simple as assigning it to the Camera3D
lens
property, like so:
camera.lens = new SphericalLens();
The ZoomFocusLens
class is the default class that is assigned to the Camera3D
lens
property. This lens will render a scene much like your own eyes perceive the real world. While the ZoomFocusLens
class will render the scene appropriately in most situations, the class itself is a legacy from earlier code. The PerspectiveLens
class will project the scene in a way that is more common amongst modern 3D authoring applications. The difference between the two classes is subtle, but as we will see in Chapter 8, Mouse Interactivity, there are occasions where it is necessary to use the PerspectiveLens
class.
The following screenshot shows you how a scene will appear when viewed with the ZoomFocusLens
and PerspectiveLens
classes.
The projection method used by the FocusZoomLens
and PerspectiveLens
classes results in a more distorted view as the FOV increases. You can see this in the following screenshot, which shows a scene viewed through a PerspectiveLens
with a large FOV. Notice how the cubes shown at the bottom of the screen have been skewed.
The SphericalLens
class can be used for situations like this. This class is used to replicate a wide-angle lens, sometimes referred to as a fish-eye lens. It views the scene as if it were being reflected in the surface of a glass sphere, and it avoids the distortion as shown in the following screenshot:
Part of the way the lens classes ZoomFocusLens
, PerspectiveLens
, and SphericalLens
create a 3D perspective is by scaling down 3D objects as they increase in distance from the camera. This effect is similar to how our own eyes perceive the world, but there are situations where this effect is not desirable. Isometric projection can be used as an alternative to render 3D objects with a consistent size and maintain the spacing between parallel lines. Isometric projection is used by a number of real-time strategy and adventure games, and also in Computer Aided Design (CAD).
The OrthogonalLens
class is used in Away3D to render an isometric view. As you can see in the following screenshot, the size of the cubes remain consistent despite their distance from the camera, and all of their parallel edges remain parallel when rendered to the screen.