In this tutorial we will learn about the basic camera operations and also about the different types of cameras available in voxelent. Let’s get started

How to get a handle of the active camera

a) Using

The fastest way to access the active camera is through voxelent current namespace. Let’s take a quick look again to voxelent namespaces (taken from Intro to Voxelent):

Voxelent Namespaces

 The current namespace contains objects that are being currently used: The current view, the current scene and the current camera are among these. To access the current camera all we have to do regardless of where we are in the code is to simply refer to it using For example:

var cam =; // cam now holds a reference to the current camera

In applications where there is only one view, we most likely will be using this method.

b) Through the camera manager

We can also access the current camera using the camera manager which is the object that manages all the cameras connected to a view. More information about the vxlCameraManager in the managing multiple cameras tutorial. camera_manager We can obtain a reference to the active camera for a new view like this:

var view = new vxlView('canvas-id'); //the HTML5 canvas id
var cam =;

or if we want to refer to the current view:

var view = vxl.c.view;
var cam =;

c) Through the public API

There is a third method that you can use to obtain a reference to the current camera. In this case through the public API:

var cam = vxl.api.getCurrentCamera();

Remember that the public API is one of the 5 different voxelent namespaces (vxl.api).

Basic Camera Operations

There are a bunch of operations that a voxelent camera can perform. Let’s take a look at some of them:

Moves the camera in the 3D world. This method can work with scalars or vectors. For example:

var cam =;
cam.setPosition(2,3,4);  //scalars
cam.setPosition([-10,3,4]); //vectors

Aims the camera to a given point in the 3D world: the focal point. Like setPosition, this method can also work with vectors

Moves the camera towards/from the focal point

Changes the field of view available to the camera. The fov parameter is an angle in degrees, (0<fov<=360). [Check Angle of view on wikipedia]

verifies that the actor given by actorName in the current scene exists and if so, it changes the focal point of the camera to match the actor’s position. The result is the camera looking at the actor.

Moves the camera away to capture all the objects contained by the current scene bounding box. This method is executed when you double click on the canvas (as long as you haven’t changed the default view interactor)

Rotates the camera. The parameters azimuth, elevation, and roll correspond to relative increments rather than absolute angles. All the angles are in degrees (instead of radians)
[Check horizontal coordinate system]

Updates the camera azimuth. The parameter a reflects an absolute angle

Updates the camera elevation. The parameter e reflects an absolute angle

Rotates the camera with respect to its forward axis. The parameter r reflects an absolute angle

Similar to the previous methods but work with incremental instead of absolute angles

Type of Cameras

There are three different types of cameras in Voxelent (up to version 0.89.7). These are: orbiting, tracking and exploring. These types are defined in the vxl.def namespace under the camera.type entry. We use the vxlCamera method setType to establish the type of camera that we want:

var cam =;
cam.setType(; //rotates around the focal point
cam.setType(; //rotates around the camera axis
cam.setType(; //special type of non-restricted orbiting.

An orbiting camera performs all the rotational operations with respect to the focal point instead of using the camera position. This type of camera is useful in applications where 3D objects are being designed or explored.

In contrast, a tracking camera performs all the rotational operations with respect to the camera position. A good example of using a tracking camera occurs in first person shooting games, where the main character moves and looks around the world.

The following diagram explains the differences between orbiting and tracking cameras:

Camera Types