Reference camera()

camera()

Sets the position and orientation of the camera.

myCamera.camera() allows objects to be viewed from different angles. It has nine parameters that are all optional.

The first three parameters, x, y, and z, are the coordinates of the camera’s position in "world" space. For example, calling myCamera.camera(0, 0, 0) places the camera at the origin (0, 0, 0). By default, the camera is placed at (0, 0, 800).

The next three parameters, centerX, centerY, and centerZ are the coordinates of the point where the camera faces in "world" space. For example, calling myCamera.camera(0, 0, 0, 10, 20, 30) places the camera at the origin (0, 0, 0) and points it at (10, 20, 30). By default, the camera points at the origin (0, 0, 0).

The last three parameters, upX, upY, and upZ are the components of the "up" vector in "local" space. The "up" vector orients the camera’s y-axis. For example, calling myCamera.camera(0, 0, 0, 10, 20, 30, 0, -1, 0) places the camera at the origin (0, 0, 0), points it at (10, 20, 30), and sets the "up" vector to (0, -1, 0) which is like holding it upside-down. By default, the "up" vector is (0, 1, 0).

Examples

Syntax

camera([x], [y], [z], [centerX], [centerY], [centerZ], [upX], [upY], [upZ])

Parameters

x

x-coordinate of the camera. Defaults to 0.

y

y-coordinate of the camera. Defaults to 0.

z

z-coordinate of the camera. Defaults to 800.

centerX

x-coordinate of the point the camera faces. Defaults to 0.

centerY

y-coordinate of the point the camera faces. Defaults to 0.

centerZ

z-coordinate of the point the camera faces. Defaults to 0.

upX

x-component of the camera’s "up" vector. Defaults to 0.

upY

x-component of the camera’s "up" vector. Defaults to 1.

upZ

z-component of the camera’s "up" vector. Defaults to 0.

Notice any errors or typos? Please let us know. Please feel free to edit src/webgl/p5.Camera.js and open a pull request!

Related References