PerspectiveCamera

Camera that uses perspective projection. This projection mode is designed to mimic the way the human eye sees. It is the most common projection mode used for rendering a 3D scene.

Core Class

Camera that uses perspective projection. This projection mode is designed to mimic the way the human eye sees. It is the most common projection mode used for rendering a 3D scene.

Hierarchy

Constructors

Properties

DefaultUp: Vector3

Every objects in 3D space must have a default up direction.

id: number

Unique number for each object3D instance.

categoryId: string

Reserved attribute

sourceType: string

Record the object rendered as instance or other type.

scene: Nullable<Scene3D>

The scene which this object belong to.

updateDirtyId: number

The number is the frame id which this object is changed or participates change of scene graph. If this value equals to frame id - 1,

name: string

The name of this object, it is empty if useless.

isObject3D: boolean

Used to check type of this or extended instance. This value should not be changed by user.

parent: Nullable<Object3D>

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

children: Object3D[]

Array with object's children.

See Group| Group for information on manually grouping objects.

This is used by the lookAt method, for example, to determine the orientation of the result. Default is DefaultUp .

worldMatrixUpdateTimestamp: number

Record when this object's world matrix last updated.

transformChanged: boolean

Record whether the object's any attribute| attribute is updated.

visibleChanged: boolean
matrixWorld: Matrix4

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

matrixWorldNeedsUpdate: boolean

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

netVisibility: boolean

Record if the object is really visible in rendering process. If the Object3D has no parent, it would be set by visible ;

localMatrixNeedUpdate: boolean

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

enableFrustumCulling: boolean
enableDetailCulling: boolean
isCamera3D: boolean

Check the type whether it belongs to Camera3D. This value should not be changed by user.

type: string

The type of this Object3D.

matrixWorldInverse: Matrix4

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

worldRotation: Matrix4
worldPosition: Vector3
projectionMatrix: Matrix4

This matrix decides the method of projection such as perspective and orthographic.

projectionMatrixInverse: Matrix4

The inverse matrix of projectionMatrix .

bounds: Vector4

This is used to adapt the bounds of camera to canvas.

isPerspectiveCamera: true

Check the type whether it belongs to PerspectiveCamera. This value should not be changed by user.

view: Nullable<CameraView>

Frustum window specification or null. This is set using the setViewOffset method and cleared using clearViewOffset .

filmGauge: number

Film size used for the larger axis. Default is 35 (millimeters). This parameter does not influence the projection matrix unless filmOffset is set to a nonzero value.

filmOffset: number

Horizontal off-center offset in the same unit as filmGauge .

userData: Record<keyof any, any>
_uuid: any
uuid: string
_listeners: Map<Symbol, Listener<never>[]>

Accessors

  • get layers(): Layers

    Returns Layers

  • set layers(v: Layers): void

    Parameters

    Returns void

  • get interactionLayers(): Layers | undefined

    Returns Layers | undefined

  • set interactionLayers(v: Layers | undefined): void

    Parameters

    Returns void

  • get groupLayer(): Layers | undefined

    Returns Layers | undefined

  • set groupLayer(v: Layers | undefined): void

    Parameters

    Returns void

  • get position(): Vector3

    Returns Vector3

  • set position(_position: Vector3): void

    A vector representing the object's local position.

    Parameters

    Returns void

  • get rotation(): Euler

    Returns Euler

  • set rotation(rotation: Euler): void

    Object's local rotation, in radians.

    Parameters

    Returns void

  • get quaternion(): Quaternion

    Returns Quaternion

  • set quaternion(_quaternion: Quaternion): void

    Object's local rotation as a Quaternion.

    Parameters

    Returns void

    See Quaternion for more details.

  • get scale(): Vector3

    Returns Vector3

  • set scale(_scale: Vector3): void

    The object's local scale.

    Parameters

    Returns void

  • get matrix(): Matrix4

    The local transform matrix.

    Returns Matrix4

  • set matrix(value: Matrix4): void

    Parameters

    Returns void

  • get visible(): boolean

    Object gets rendered if true.

    Returns boolean

  • set visible(value: boolean): void

    Parameters

    • value: boolean

    Returns void

  • get isTwoPointPerspectiveViewEnabled(): boolean

    This effect can elongate models when camera looks up or down.

    Returns boolean

  • set isTwoPointPerspectiveViewEnabled(v: boolean): void

    Parameters

    • v: boolean

    Returns void

  • get fov(): number

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

    Returns number

  • set fov(v: number): void

    Parameters

    • v: number

    Returns void

  • get zoom(): number

    Scale width and height of view frustum.

    Returns number

  • set zoom(v: number): void

    Parameters

    • v: number

    Returns void

  • get near(): number

    Distance from camera position to small plane of view frustum.

    Returns number

  • set near(v: number): void

    Parameters

    • v: number

    Returns void

  • get far(): number

    Distance from camera position to big plane of view frustum.

    Returns number

  • set far(v: number): void

    Parameters

    • v: number

    Returns void

  • get focus(): number

    Object distance used for stereoscopy and depth-of-field effects.

    Returns number

  • set focus(v: number): void

    Parameters

    • v: number

    Returns void

  • get aspect(): number

    Full screen width divided by its height in case of more view, this value equals to fov when there was only one viewer.

    Returns number

  • set aspect(v: number): void

    Parameters

    • v: number

    Returns void

  • get businessTag(): string

    Returns string

  • set businessTag(v: string): void

    Parameters

    • v: string

    Returns void

Methods

  • If the local matrix is changed, use this method to manually refresh data in scene graph.

    Returns void

    It's better to use notifySceneChange() as an alternative.

  • Use this method to manually refresh data in scene graph and draw again. The engine may not notify every change of the scene. If any effect is not changed with the parameters, use this may solve.

    Returns void

  • If there are zero or two negative numbers in xyz, return false, otherwise return true.

    Returns boolean

  • Applies the matrix transform to the object and updates the object's position, rotation and scale.

    Parameters

    • matrix: Matrix4

      A matrix represents the information of transform.

    Returns void

  • Applies the rotation represented by the quaternion to the object.

    Parameters

    • q: Quaternion

      A Quaternion represents the information of rotation.

    Returns this

  • Calls Quaternion.setRotationFromEuler| setRotationFromEuler(euler, true) on the Quaternion.

    Parameters

    • euler: Euler

      Euler angle specifying rotation amount.

    Returns void

  • 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

      Angle in radians.

    Returns this

  • Rotate an object along an axis in world space. The axis is assumed to be normalized. Method Assumes no rotated parent.

    Parameters

    • axis: Vector3

      A normalized vector in object space.

    • angle: number

      Angle in radians.

    Returns this

  • Rotates the object around x axis in local space.

    Parameters

    • angle: number

      The angle to rotate in radians.

    Returns this

  • Rotates the object around x axis in local space.

    Parameters

    • angle: number

      The angle to rotate in radians.

    Returns this

  • Rotates the object around x axis in local space.

    Parameters

    • angle: number

      The angle to rotate in radians.

    Returns this

  • Translate an object by distance along an axis in object space. The axis is assumed to be normalized.

    Parameters

    • axis: Vector3

      A normalized vector in object space.

    • distance: number

      The distance to translate.

    Returns this

  • Translates object along x axis in object space by distance units.

    Parameters

    • distance: number

      The distance to translate.

    Returns this

  • Translates object along y axis in object space by distance units.

    Parameters

    • distance: number

      The distance to translate.

    Returns this

  • Translates object along z axis in object space by distance units.

    Parameters

    • distance: number

      The distance to translate.

    Returns this

  • Rotates the object to face to a point in world space. This method does not support objects having non-uniformly-scaled parent(s)

    Parameters

    • _x: Vector3

      A vector representing position of target in world space.

    Returns void

  • Rotates the object to face a point in local space.

    Parameters

    • _x: Vector3

      A vector representing position of target in local space.

    Returns void

  • Adds object as child of this object. An arbitrary number of objects may be added. Any current parent on an object passed in here will be removed, since an object can have at most one parent. The scene graph change will be immediately notify by engine after adding nodes.

    Parameters

    • o: Object3D | Object3D[]

      Parameter can be one object or objects array, all of them is added to this object.

    Returns this

  • Remove the specified object form children.

    Parameters

    • object: Object3D

      The object which needs to be removed.

    Returns this

  • Remove all children in specified objects from this objects. Migrate from tools common

    Parameters

    • objects: Object3D[]

      An array of objects which need to be removed.

    Returns this

  • Searches through an object and its children, starting with the object itself, and returns the first with a matching id. Note that ids are assigned in chronological order: 1, 2, 3, ..., incrementing by one for each new object.

    Parameters

    • id: number

      Unique number of the object instance.

    Returns Object3D

  • Searches through an object and its children, starting with the object itself, 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

    • name: string

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

    Returns Object3D

  • Searches through an object and its children, starting with the object itself, and returns the first with a property that matches the value given.

    Parameters

    • name: string

      The property name to search for.

    • value: any

      Value of the given property.

    Returns Object3D

  • Return a vector of the scaling factors applied to the object for each axis in world space.

    Parameters

    • target: Vector3

      the result will be copied into this Vector3.

    Returns Vector3

  • Execute the callback on this object and all descendants.

    Parameters

    • callback: (object: Object3D) => any

      A function with as first argument an object3D object.

    Returns void

  • Execute the callback when return is false, stop traverse the object's descendants.

    Parameters

    • callback: (object: Object3D) => boolean

      A function with as first argument an object3D object, return boolean.

    Returns void

  • Execute the callback on this object and all descendants which is visible.

    Parameters

    • callback: (object: Object3D) => any

      A function with as first argument an object3D object.

    Returns void

  • Execute the callback on this object and all ancestors.

    Parameters

    • callback: (object: Object3D) => any

      A function with as first argument an object3D object.

    Returns void

  • Update the matrix local transform.

    Returns void

  • Get the whole bounding box of current object cover all children's.

    Parameters

    • localBox: Box3

      If this is not undefined, result will be stored to it.

    Returns Box3

  • Get UUID of this object instance. This value is automatically assigned, so this shouldn't be edited.

    Returns string

  • Set the value of camera's faced direction to given vector.

    Parameters

    • target: Vector3

      this vector representing the world space direction in which the camera is looking.

    Returns Vector3

  • Update the camera's matrixWorld and matrixWorldInverse .

    Parameters

    • updateParents: boolean

      if true, it also updates all the parents.

    • updateChildren: boolean

      if true, it also updates all the children.

    • force: boolean

      Whether or not force to updates the matrix.

    Returns void

  • Returns Readonly<
    Pick<
    ReadonlyMarked,
    | "_readonly_mark"
    | "cloneReadonly"
    | "clone"
    | "equals"
    | "getSerializeData"
    | "x"
    | "y"
    | "getNumberCount"
    | "toArray"
    | "width"
    | "height"
    | "isVector2"
    | "dot"
    | "cross"
    | "lengthSq"
    | "length"
    | "angle"
    | "manhattanLength"
    | "distanceTo"
    | "distanceToSquared"
    | "manhattanDistanceTo"
    | "intoSize",
    >,
    >

  • return a function that compute pixelsPerUnit

    Parameters

    • viewHeight: number

    Returns (distance: number) => number

  • Calculate a scale value that keep one object's screen unit size match it's world unit size

    Parameters

    • distance: number

      the distance from camera to object.

    • viewHeight: number

      the hight of view window.

    Returns number

  • Update the camera's Object3D.matrixWorld| matrixWorld and matrixWorldInverse .

    Parameters

    • force: boolean

      Whether or not force to updates the matrix.

    Returns void

  • The name of instance's class.

    Returns string

  • Copy the data to this camera instance from source. This method need override in derived classes to copy extended data.

    Parameters

    • source: PerspectiveCamera

      the data source.

    • recursive: boolean

      if true, descendants of the object are also cloned. Default is true.

    Returns this

  • The tangent value of camera frustum's vertical angle.

    Returns number

  • As name says

    Parameters

    • viewHeight: number

    Returns number

  • Calculate how many screen pixel match one world unit at given distance.

    Parameters

    • distance: number

      the distance from camera to object.

    • viewHeight: number

      the hight of view window.

    Returns number

  • Set the origin and direction for ray.

    Parameters

    • ray: Ray

      the calculate result will be set to this.

    • coords: Vector2

      the position of window where the ray through out.

    Returns void

  • Sets the FOV by focal length in respect to the current filmGauge . Values for focal length and film gauge must have the same unit.

    Parameters

    • focalLength: number

    Returns void

  • Calculates the focal length from the current fov and filmGauge .

    Returns number

  • Returns the current vertical field of view angle in degrees considering zoom .

    Returns number

  • Returns the width of the image on the film. If .aspect is greater than or equal to one (landscape format), the result equals filmGauge .

    Returns number

  • Returns the height of the image on the film. If .aspect is less than or equal to one (portrait format), the result equals filmGauge .

    Returns 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: let w = 1920; let h = 1080; let fullWidth = w * 3; let fullHeight = h * 2; // A camera.setOffset( fullWidth, fullHeight, w * 0, h * 0, w, h ); // B camera.setOffset( fullWidth, fullHeight, w * 1, h * 0, w, h ); // C camera.setOffset( fullWidth, fullHeight, w * 2, h * 0, w, h ); // D camera.setOffset( fullWidth, fullHeight, w * 0, h * 1, w, h ); // E camera.setOffset( fullWidth, fullHeight, w * 1, h * 1, w, h ); // F camera.setOffset( fullWidth, fullHeight, w * 2, h * 1, w, h );

    Parameters

    • fullWidth: number

      full width of multi-view setup.

    • fullHeight: number

      full height of multi-view setup.

    • x: number

      horizontal offset of sub-camera.

    • y: number

      vertical offset of sub-camera.

    • width: number

      width of sub-camera.

    • height: number

      height of sub-camera.

    Returns void

    there is no reason monitors have to be the same size or in a grid.

  • Removes any offset set by the setViewOffset method.

    Returns void

  • Store the attributes of this class into string as serializing format.

    Parameters

    • ctx: Serializer

      an instance used to store the data of scene objects.

    Returns void

  • Parse the data for this class from string according to serializing format.

    Parameters

    • ctx: Deserializer

      an instance give the method to take the data for attribute.

    Returns void

  • Adds a listener to an event type.

    Type Parameters

    • T

    Parameters

    • _type: EventType<T>
    • _listener: Listener<T>

    Returns void

  • Only active the listener one times and then off it| it.

    Type Parameters

    • T

    Parameters

    • _type: EventType<T>
    • _listener: Listener<T>

    Returns void

  • Checks if listener is added to an event type.

    Type Parameters

    • T

    Parameters

    • _type: EventType<T>
    • _listener: Listener<T>

    Returns boolean

  • Removes a listener from listening list.

    Type Parameters

    • T

    Parameters

    • _type: EventType<T>
    • _listener: Listener<T>

    Returns void

  • Active the event and call the registered listener.

    Parameters

    • type: EventType<never>

    Returns void

  • Type Parameters

    • T

    Parameters

    • type: EventType<T>
    • payload: T

    Returns void