Camera

The camera used for rendering a 3D scene. The camera's direction is defined as the 3-vector (0.0, 0,0, -1.0), that is, an untransformed camera points down the -Z axis.

Constructor

new Camera()

Create a camera.

Extends

Members

castShadow :boolean

Whether the object gets rendered into shadow map.

Type:
  • boolean
Default Value
  • false

children :Array.<Object3D>

Object's parent in the scene graph. An object can have at most one parent.

Type:

euler :Euler

Object's local rotation as an Euler, in radians.

Type:
Default Value
  • Euler(0, 0, 0)

frustum :Frustum

The frustum of the camera.

Type:

frustumCulled :boolean

When this is set, it checks every frame if objects are in the frustum of the camera before rendering objects. Otherwise objects gets rendered every frame even if it isn't visible.

Type:
  • boolean
Default Value
  • true

gammaFactor :number

The factor of gamma.

Type:
  • number
Default Value
  • 2.0

(readonly) id :number

Unique number for this object instance.

Type:
  • number
Overrides

(readonly) isCamera :boolean

Type:
  • boolean
Default Value
  • true

matrix :Matrix4

The local transform matrix.

Type:

matrixAutoUpdate :boolean

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

Type:
  • boolean
Default Value
  • true

matrixNeedsUpdate :boolean

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

Type:
  • boolean
Default Value
  • true

name :string

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

Type:
  • string
Overrides
Default Value
  • ""

outputEncoding :TEXEL_ENCODING_TYPE

Output pixel encoding.

Default Value
  • TEXEL_ENCODING_TYPE.LINEAR

parent :Object3D

Object's parent in the scene graph. An object can have at most one parent.

position :Vector3

A Vector3 representing the object's local position.

Type:
Default Value
  • Vector3(0, 0, 0)

projectionMatrix :Matrix4

This is the matrix which contains the projection.

Type:

projectionMatrixInverse :Matrix4

This is the matrix which contains the projection.

Type:

projectionViewMatrix :Matrix4

This is the matrix which contains the projection and view matrix. The matrix may be different from the value passed in the shader, scene.anchorMatrix is not considered here.

Type:

quaternion :Quaternion

Object's local rotation as a Quaternion.

Default Value
  • Quaternion(0, 0, 0, 1)

receiveShadow :boolean

Whether the material receives shadows.

Type:
  • boolean
Default Value
  • false

rect :Vector4

Where on the screen is the camera rendered in normalized coordinates. The values in rect range from zero (left/bottom) to one (right/top).

Type:
Default Value
  • Vector4(0, 0, 1, 1)

renderLayer :number

Render layer of this object. RenderQueue will dispatch all renderable objects to the corresponding RenderQueueLayer according to object.renderLayer.

Type:
  • number
Default Value
  • 0

renderOrder :number

This value allows the default rendering order of scene graph objects to be overridden although opaque and transparent objects remain sorted independently. Sorting is from lowest to highest renderOrder.

Type:
  • number
Default Value
  • 0

renderable :boolean

Whether it can be collected into the Render Queue.

Type:
  • boolean
Default Value
  • true

scale :Vector3

The object's local scale.

Type:
Default Value
  • Vector3(1, 1, 1)

shadowType :SHADOW_TYPE

Defines shadow map type. Note: In webgl1 or Scene#disableShadowSampler is true, soft shadow types will fallback to POISSON_SOFT without warning. Note: Point light only support POISSON_SOFT for now.

Default Value
  • SHADOW_TYPE.PCF3_SOFT

userData :object

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.

Type:
  • object
Default Value
  • {}

uuid :string

UUID of this object instance. This gets automatically assigned, so this shouldn't be edited.

Type:
  • string
Overrides

viewMatrix :Matrix4

This is the inverse of worldMatrix. The matrix may be different from the value passed in the shader, scene.anchorMatrix is not considered here.

Type:

visible :boolean

Object gets rendered if true.

Type:
  • boolean
Default Value
  • true

worldMatrix :Matrix4

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

Type:

worldMatrixNeedsUpdate :boolean

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

Type:
  • boolean
Default Value
  • true

Methods

add(object)

Add object as child of this object.

Parameters:
NameTypeDescription
objectObject3D
Overrides

clone(recursiveopt) → {Object3D}

Returns a clone of this object and optionally all descendants.

Parameters:
NameTypeAttributesDefaultDescription
recursivefunction<optional>
true

if true, descendants of the object are also cloned.

Returns:
Type: 
Object3D

copy(source, recursiveopt) → {Object3D}

Copy the given object into this object.

Parameters:
NameTypeAttributesDefaultDescription
sourceObject3D

The object to be copied.

recursiveboolean<optional>
true

if true, descendants of the object are also copied.

Overrides
Returns:
Type: 
Object3D

getObjectByName(name) → {Object3D}

Searches through the object's children and returns the first with a matching name. Note that for most objects the name is an empty string by default. You will have to set it manually to make use of this method.

Parameters:
NameTypeDescription
namestring

String to match to the children's Object3D#name property.

Returns:
Type: 
Object3D

getObjectByProperty(name, value) → {Object3D}

Searches through the object's children and returns the first with a property that matches the value given.

Parameters:
NameTypeDescription
namestring

the property name to search for.

valuenumber

value of the given property.

Returns:
Type: 
Object3D

getWorldDirection(optionalTargetopt) → {Vector3}

Returns a vector representing the direction of object's positive z-axis in world space. This call must be after Object3D#updateMatrix.

Parameters:
NameTypeAttributesDescription
optionalTargetVector3<optional>

— the result will be copied into this Vector3.

Returns:
  • the result.
Type: 
Vector3

lookAt(target, up)

Set view by look at, this func will set quaternion of this camera.

Parameters:
NameTypeDescription
targetVector3

The target that the camera look at.

upVector3

The up direction of the camera.

onAfterRender()

An optional callback that is executed immediately after the Object3D is rendered.

onBeforeRender()

An optional callback that is executed immediately before the Object3D is rendered.

(abstract) raycast(ray, intersects)

Method to get intersections between a casted ray and this object.

Parameters:
NameTypeDescription
rayRay

The Ray instance.

intersectsArray

output intersects array.

remove(object)

Remove object as child of this object.

Parameters:
NameTypeDescription
objectObject3D

setOrtho(left, right, bottom, top, near, far)

Set orthographic projection matrix.

Parameters:
NameTypeDescription
leftnumber

— Camera frustum left plane.

rightnumber

— Camera frustum right plane.

bottomnumber

— Camera frustum bottom plane.

topnumber

— Camera frustum top plane.

nearnumber

— Camera frustum near plane.

farnumber

— Camera frustum far plane.

setPerspective(fov, aspect, near, far)

Set perspective projection matrix.

Parameters:
NameTypeDescription
fovnumber

— Camera frustum vertical field of view.

aspectnumber

— Camera frustum aspect ratio.

nearnumber

— Camera frustum near plane.

farnumber

— Camera frustum far plane.

traverse(callback)

Executes the callback on this object and all descendants.

Parameters:
NameTypeDescription
callbackfunction

A function with as first argument an object3D object.

updateMatrix(force)

Update the local transform.

Parameters:
NameTypeDescription
forceboolean