Sets the camera's frustum.
In a frustum projection, shapes that are further from the camera appear smaller than shapes that are near the camera. This technique, called foreshortening, creates realistic 3D scenes.
myCamera.frustum()
changes the camera’s perspective by changing its viewing frustum. The frustum is the volume of space that’s visible to the camera. The frustum’s shape is a pyramid with its top cut off. The camera is placed where the top of the pyramid should be and points towards the base of the pyramid. It views everything within the frustum.
The first four parameters, left
, right
, bottom
, and top
, set the coordinates of the frustum’s sides, bottom, and top. For example, calling myCamera.frustum(-100, 100, 200, -200)
creates a frustum that’s 200 pixels wide and 400 pixels tall. By default, these coordinates are set based on the sketch’s width and height, as in myCamera.frustum(-width / 20, width / 20, height / 20, -height / 20)
.
The last two parameters, near
and far
, set the distance of the frustum’s near and far plane from the camera. For example, calling myCamera.frustum(-100, 100, 200, -200, 50, 1000)
creates a frustum that’s 200 pixels wide, 400 pixels tall, starts 50 pixels from the camera, and ends 1,000 pixels from the camera. By default, near is set to 0.1 * 800
, which is 1/10th the default distance between the camera and the origin. far
is set to 10 * 800
, which is 10 times the default distance between the camera and the origin.
Examples
Syntax
frustum([left], [right], [bottom], [top], [near], [far])
Parameters
x-coordinate of the frustum’s left plane. Defaults to -width / 20
.
x-coordinate of the frustum’s right plane. Defaults to width / 20
.
y-coordinate of the frustum’s bottom plane. Defaults to height / 20
.
y-coordinate of the frustum’s top plane. Defaults to -height / 20
.
z-coordinate of the frustum’s near plane. Defaults to 0.1 * 800
.
z-coordinate of the frustum’s far plane. Defaults to 10 * 800
.