Director 3D > 3D Cameras

Moving/changing camera viewpoints

Tutorials on the subject of cameras in Director 3D can be found at Macromedia’s tutorial pages and here.

Here we'll show you how to view the action from different perspectives by having different cameras (including a moving camera following an object. Here is the sample. You can download the source file from here. Try moving the box around with the arrow keys. Then, switch to camera 2 (either click the button or press "2" on your keyboard) to see it from above. Finally, switch to camera 3 ("Camera 3" button or press "3") to get the view from behind the box (additionally this camera moves to follow the box as you move it around):

How is this done?

First of all we set up the scene:

createBox(me) refers to the following custom handler:

This creates the box in the scene and moves it to position.

createPlane(me) calls another custom handler to build the 3D plane - here is the code:

We then create the 2 extra cameras (cameras "2" and "3") in the scene with the following handler - createCameras(me):

The default camera for a 3D member is 250 units in front of the center of the world. We start by creating a second camera that is 200 units above the center of the world, looking straight down. We then add another camera and move it 50 units behind the box. Finally, we make this camera a "child" of the box - that means it will follow the box wherever it goes, always 50 units directly behind it.

The exitFrame handler uses the left and right arrow keys to rotate the box model, and the up and down arrows to move forwards and backwards. Additionally it adds some keyboard controls to switch to different cameras. Here is the code:

<< Previous | Next >>

July 2003