Class PerspectiveCamera

Camera with perspective projection.

example

var camera = new THREE.PerspectiveCamera( 45, width / height, 1, 1000 );
scene.add( camera );
source

https://github.com/mrdoob/three.js/blob/master/src/cameras/PerspectiveCamera.js

Hierarchy

Index

Constructor methods

Properties

Methods

Constructor methods

constructor(fov?: number, aspect?: number, near?: number, far?: number): PerspectiveCamera

Parameters

  • fov?: number optional

    Camera frustum vertical field of view. Default value is 50.

  • aspect?: number optional

    Camera frustum aspect ratio. Default value is 1.

  • near?: number optional

    Camera frustum near plane. Default value is 0.1.

  • far?: number optional

    Camera frustum far plane. Default value is 2000.

Returns

PerspectiveCamera

Properties

public aspect: number

Camera frustum aspect ratio, window width divided by window height.

public castShadow: boolean

Gets rendered into shadow map.

public children: Object3D[]

Array with object's children.

public eulerOrder: string

Order of axis for Euler angles.

public far: number

Camera frustum far plane.

public fov: number

Camera frustum vertical field of view, from bottom to top of view, in degrees.

public frustumCulled: boolean

When this is set, it checks every frame if the object is in the frustum of the camera. Otherwise the object gets drawn every frame even if it isn't visible.

public id: number

Unique number of this object instance.

public matrix: Matrix4

Local transform.

public matrixAutoUpdate: boolean

When this is set, it calculates the matrix of position, (rotation or quaternion) and scale every frame and also recalculates the matrixWorld property.

public matrixWorld: Matrix4

The global transform of the object. If the Object3d has no parent, then it's identical to the local transform.

public matrixWorldInverse: Matrix4

This is the inverse of matrixWorld. MatrixWorld contains the Matrix which has the world transform of the Camera.

public matrixWorldNeedsUpdate: boolean

When this is set, it calculates the matrixWorld in that frame and resets this property to false.

public name: string

Optional name of the object (doesn't need to be unique).

public near: number

Camera frustum near plane.

public parent: Object3D

Object's parent in the scene graph.

public position: Vector3

Object's local position.

public projectionMatrix: Matrix4

This is the matrix which contains the projection.

public quaternion: Quaternion

Global rotation.

public receiveShadow: boolean

Material gets baked in shadow receiving.

public renderDepth: number

Override depth-sorting order if non null.

public rotation: Euler

Object's local rotation (Euler angles), in radians.

public rotationAutoUpdate: boolean

When this is set, then the rotationMatrix gets calculated every frame.

public scale: Vector3

Object's local scale.

public up: Vector3

Up direction.

public useQuaternion: boolean

Use quaternion instead of Euler angles for specifying local rotation.

public userData: any

An object that can be used to store custom data about the Object3d. It should not hold references to functions as these will not be cloned.

public visible: boolean

Object gets rendered if true.

Methods

public add(object: Object3D)

Adds object as child of this object.

Parameters

public applyMatrix(matrix: Matrix4)

This updates the position, rotation and scale with the matrix.

Parameters

public clone(): PerspectiveCamera

Returns

PerspectiveCamera

public getDescendants(array?: Object3D[]): Object3D[]

Searches whole subgraph recursively to add all objects in the array.

Parameters

  • array?: Object3D[] optional

    optional argument that returns the the array with descendants.

Returns

Object3D[]

public getObjectById(id: string, recursive: boolean): Object3D

Searches through the object's children and returns the first with a matching id, optionally recursive.

Parameters

  • id: string

    Unique number of the object instance

  • recursive: boolean

    Boolean whether to search through the children's children. Default is false.

Returns

Object3D

public getObjectByName(name: string, recursive: boolean): Object3D

Searches through the object's children and returns the first with a matching name, optionally recursive.

Parameters

  • name: string

    String to match to the children's Object3d.name property.

  • recursive: boolean

    Boolean whether to search through the children's children. Default is false.

Returns

Object3D

public localToWorld(vector: Vector3): Vector3

Updates the vector from local space to world space.

Parameters

Returns

Vector3

public lookAt(vector: Vector3)

This make the camera look at the vector position in local space.

Parameters

public remove(object: Object3D)

Removes object as child of this object.

Parameters

public rotateOnAxis(axis: Vector3, angle: number): Object3D

Rotate an object along an axis in object space. The axis is assumed to be normalized.

Parameters

  • axis: Vector3

    A normalized vector in object space.

  • angle: number

    The angle in radians.

Returns

Object3D

public setLens(focalLength: number, frameHeight?: number)

Uses focal length (in mm) to estimate and set FOV 35mm (fullframe) camera is used if frame size is not specified. Formula based on http://www.bobatkins.com/photography/technical/field_of_view.html

Parameters

  • focalLength: number

    focal length

  • frameHeight?: number optional

    frame size. Default value is 24.

public setViewOffset(fullWidth: number, fullHeight: number, x: number, y: number, width: number, height: number)

Sets an offset in a larger frustum. This is useful for multi-window or multi-monitor/multi-machine setups. For example, if you have 3x2 monitors and each monitor is 1920x1080 and the monitors are in grid like this:

+---+---+---+
| A | B | C |
+---+---+---+
| D | E | F |
+---+---+---+

then for each monitor you would call it like this:

var w = 1920;
var h = 1080;
var fullWidth = w * 3;
var fullHeight = h * 2;

// A
camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h );
// B
camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 0, w, h );
// C
camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 0, w, h );
// D
camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 1, w, h );
// E
camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h );
// F
camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h ); Note there is no reason monitors have to be the same size or in a grid.

Parameters

  • fullWidth: number

    full width of multiview setup

  • fullHeight: number

    full height of multiview setup

  • x: number

    horizontal offset of subcamera

  • y: number

    vertical offset of subcamera

  • width: number

    width of subcamera

  • height: number

    height of subcamera

public translateOnAxis(axis: Vector3, distance: number): Object3D

Parameters

  • axis: Vector3

    A normalized vector in object space.

  • distance: number

    The distance to translate.

Returns

Object3D

public translateX(distance: number)

Translates object along x axis by distance.

Parameters

  • distance: number

    Distance.

public translateY(distance: number)

Translates object along y axis by distance.

Parameters

  • distance: number

    Distance.

public translateZ(distance: number)

Translates object along z axis by distance.

Parameters

  • distance: number

    Distance.

public traverse(callback: (object: THREE.Object3D) => any)

Translates object along arbitrary axis by distance.

Parameters

  • callback: (object: THREE.Object3D) => any

public updateMatrix()

Updates local transform.

public updateMatrixWorld(force: boolean)

Updates global transform of the object and its children.

Parameters

  • force: boolean

public updateProjectionMatrix()

Updates the camera projection matrix. Must be called after change of parameters.

public worldToLocal(vector: Vector3): Vector3

Updates the vector from world space to local space.

Parameters

Returns

Vector3