Options
All
  • Public
  • Public/Protected
  • All
Menu

Creates a camera that you can use instead of a perspective camera.

The camera provides a Camera.backgroundTexture property containing the camera feed.

The ZapparThree library needs to use your WebGL context in order to process camera frames. You can set it when your page loads using glContextSet.

see

https://docs.zap.works/universal-ar/web-libraries/threejs/camera-setup/

Hierarchy

  • Camera
    • Camera

Index

Constructors

constructor

  • new Camera(opts?: Pipeline | (Partial<{ pipeline: Pipeline; zFar: number; zNear: number }> & SourceOptions)): Camera
  • Constructs a new Camera.

    property

    pipeline - The pipeline that this tracker will operate within.

    property

    zNear - The near clipping plane.

    property

    zFar - The far clipping plane.

    property

    rearCameraSource? - The camera source which will be used for the rear camera.

    property

    userCameraSource? - The camera source which will be used for the user camera.

    Parameters

    • Optional opts: Pipeline | (Partial<{ pipeline: Pipeline; zFar: number; zNear: number }> & SourceOptions)

    Returns Camera

Properties

animations

animations: AnimationClip[]

Array with animation clips.

default

[]

backgroundTexture

backgroundTexture: BackgroundTexture = ...

The camera feed texture.

You can use this texture however you wish but the easiest way to show the camera feed behind your content is to set it as your scene's background.

castShadow

castShadow: boolean

Gets rendered into shadow map.

default

false

children

children: Object3D<Event>[]

Array with object's children.

default

[]

customDepthMaterial

customDepthMaterial: Material

Custom depth material to be used when rendering to the depth map. Can only be used in context of meshes. When shadow-casting with a DirectionalLight or SpotLight, if you are (a) modifying vertex positions in the vertex shader, (b) using a displacement map, (c) using an alpha map with alphaTest, or (d) using a transparent texture with alphaTest, you must specify a customDepthMaterial for proper shadows.

customDistanceMaterial

customDistanceMaterial: Material

Same as customDepthMaterial, but used with PointLight.

frustumCulled

frustumCulled: boolean

When this is set, it checks every frame if the object is in the frustum of the camera before rendering the object. If set to false the object gets rendered every frame even if it is not in the frustum of the camera.

default

true

id

id: number

Unique number of this object instance.

Readonly isCamera

isCamera: true

Readonly isObject3D

isObject3D: true

Used to check whether this or derived classes are Object3Ds. Default is true. You should not change this, as it is used internally for optimisation.

layers

layers: Layers
default

new THREE.Layers()

matrix

matrix: Matrix4

Local transform.

default

new THREE.Matrix4()

matrixAutoUpdate

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.

default

THREE.Object3D.DefaultMatrixAutoUpdate

matrixWorld

matrixWorld: Matrix4

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

default

new THREE.Matrix4()

matrixWorldInverse

matrixWorldInverse: Matrix4

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

default

new THREE.Matrix4()

matrixWorldNeedsUpdate

matrixWorldNeedsUpdate: boolean

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

default

false

Readonly modelViewMatrix

modelViewMatrix: Matrix4
default

new THREE.Matrix4()

name

name: string

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

default

''

Readonly normalMatrix

normalMatrix: Matrix3
default

new THREE.Matrix3()

onAfterRender

onAfterRender: (renderer: WebGLRenderer, scene: Scene, camera: Camera, geometry: BufferGeometry, material: Material, group: Group) => void

Calls after rendering object

Type declaration

    • (renderer: WebGLRenderer, scene: Scene, camera: Camera, geometry: BufferGeometry, material: Material, group: Group): void
    • Parameters

      • renderer: WebGLRenderer
      • scene: Scene
      • camera: Camera
      • geometry: BufferGeometry
      • material: Material
      • group: Group

      Returns void

onBeforeRender

onBeforeRender: (renderer: WebGLRenderer, scene: Scene, camera: Camera, geometry: BufferGeometry, material: Material, group: Group) => void

Calls before rendering object

Type declaration

    • (renderer: WebGLRenderer, scene: Scene, camera: Camera, geometry: BufferGeometry, material: Material, group: Group): void
    • Parameters

      • renderer: WebGLRenderer
      • scene: Scene
      • camera: Camera
      • geometry: BufferGeometry
      • material: Material
      • group: Group

      Returns void

parent

parent: null | Object3D<Event>

Object's parent in the scene graph.

default

null

pipeline

pipeline: Pipeline

poseAnchorOrigin

poseAnchorOrigin: undefined | ImageAnchor | FaceAnchor | InstantWorldAnchor

The transformation with the (camera-relative) origin specified by the anchor.

poseMode

poseMode: CameraPoseMode = ...

The pose mode that determines how the camera moves in the scene.

Readonly position

position: Vector3

Object's local position.

default

new THREE.Vector3()

projectionMatrix

projectionMatrix: Matrix4

This is the matrix which contains the projection.

default

new THREE.Matrix4()

projectionMatrixInverse

projectionMatrixInverse: Matrix4

This is the inverse of projectionMatrix.

default

new THREE.Matrix4()

Readonly quaternion

quaternion: Quaternion

Object's local rotation as a Quaternion.

default

new THREE.Quaternion()

rawPose

rawPose: Float32Array

A 4x4 column-major transformation matrix where the camera sits.

rearCameraMirrorMode

rearCameraMirrorMode: CameraMirrorMode = ...

The mirror mode that is used for the rear camera.

rearCameraSource

rearCameraSource: CameraSource | HTMLElementSource

The camera source which is used for the rear camera.

receiveShadow

receiveShadow: boolean

Material gets baked in shadow receiving.

default

false

renderOrder

renderOrder: number

Overrides the default rendering order of scene graph objects, from lowest to highest renderOrder. Opaque and transparent objects remain sorted independently though. When this property is set for an instance of Group, all descendants objects will be sorted and rendered together.

default

0

Readonly rotation

rotation: Euler

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

default

new THREE.Euler()

Readonly scale

scale: Vector3

Object's local scale.

default

new THREE.Vector3()

type

type: string
default

'Object3D'

up

up: Vector3

Up direction.

default

THREE.Object3D.DefaultUp.clone()

userCameraMirrorMode

userCameraMirrorMode: CameraMirrorMode = ...

The mirror mode that is used for the user camera.

userCameraSource

userCameraSource: CameraSource | HTMLElementSource

The camera source which is used for the user camera.

userData

userData: {}

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.

default

{}

Type declaration

  • [key: string]: any

uuid

uuid: string

visible

visible: boolean

Object gets rendered if true.

default

true

Static DefaultMatrixAutoUpdate

DefaultMatrixAutoUpdate: boolean

Static DefaultUp

DefaultUp: Vector3

Accessors

currentMirrorMode

Methods

_updateProjectionMatrix

  • _updateProjectionMatrix(): void

add

  • add(...object: Object3D<Event>[]): Camera
  • Adds object as child of this object.

    Parameters

    • Rest ...object: Object3D<Event>[]

    Returns Camera

addEventListener

  • addEventListener<T>(type: T, listener: EventListener<Event, T, Camera>): void
  • Adds a listener to an event type.

    Type parameters

    • T: string

    Parameters

    • type: T

      The type of event to listen to.

    • listener: EventListener<Event, T, Camera>

      The function that gets called when the event is fired.

    Returns void

applyMatrix4

  • applyMatrix4(matrix: Matrix4): void
  • This updates the position, rotation and scale with the matrix.

    Parameters

    • matrix: Matrix4

    Returns void

applyQuaternion

  • applyQuaternion(quaternion: Quaternion): Camera
  • Parameters

    • quaternion: Quaternion

    Returns Camera

attach

  • attach(object: Object3D<Event>): Camera
  • Adds object as a child of this, while maintaining the object's world transform.

    Parameters

    • object: Object3D<Event>

    Returns Camera

clear

  • Removes all child objects.

    Returns Camera

clone

  • clone(recursive?: boolean): Camera
  • Parameters

    • Optional recursive: boolean

    Returns Camera

copy

  • Parameters

    • source: Camera
    • Optional recursive: boolean

    Returns Camera

dispatchEvent

  • dispatchEvent(event: Event): void
  • Fire an event type.

    Parameters

    • event: Event

    Returns void

dispose

  • dispose(): void

getObjectById

  • getObjectById(id: number): undefined | Object3D<Event>
  • Searches through the object's children and returns the first with a matching id.

    Parameters

    • id: number

      Unique number of the object instance

    Returns undefined | Object3D<Event>

getObjectByName

  • getObjectByName(name: string): undefined | Object3D<Event>
  • Searches through the object's children and returns the first with a matching name.

    Parameters

    • name: string

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

    Returns undefined | Object3D<Event>

getObjectByProperty

  • getObjectByProperty(name: string, value: string): undefined | Object3D<Event>
  • Parameters

    • name: string
    • value: string

    Returns undefined | Object3D<Event>

getWorldDirection

  • getWorldDirection(target: Vector3): Vector3
  • Parameters

    • target: Vector3

    Returns Vector3

getWorldPosition

  • getWorldPosition(target: Vector3): Vector3
  • Parameters

    • target: Vector3

    Returns Vector3

getWorldQuaternion

  • getWorldQuaternion(target: Quaternion): Quaternion
  • Parameters

    • target: Quaternion

    Returns Quaternion

getWorldScale

  • getWorldScale(target: Vector3): Vector3
  • Parameters

    • target: Vector3

    Returns Vector3

hasEventListener

  • hasEventListener<T>(type: T, listener: EventListener<Event, T, Camera>): boolean
  • Checks if listener is added to an event type.

    Type parameters

    • T: string

    Parameters

    • type: T

      The type of event to listen to.

    • listener: EventListener<Event, T, Camera>

      The function that gets called when the event is fired.

    Returns boolean

localToWorld

  • localToWorld(vector: Vector3): Vector3
  • Updates the vector from local space to world space.

    Parameters

    • vector: Vector3

      A local vector.

    Returns Vector3

lookAt

  • lookAt(vector: number | Vector3, y?: number, z?: number): void
  • Rotates object to face point in space.

    Parameters

    • vector: number | Vector3

      A world vector to look at.

    • Optional y: number
    • Optional z: number

    Returns void

raycast

  • raycast(raycaster: Raycaster, intersects: Intersection[]): void
  • Parameters

    • raycaster: Raycaster
    • intersects: Intersection[]

    Returns void

remove

  • remove(...object: Object3D<Event>[]): Camera
  • Removes object as child of this object.

    Parameters

    • Rest ...object: Object3D<Event>[]

    Returns Camera

removeEventListener

  • removeEventListener<T>(type: T, listener: EventListener<Event, T, Camera>): void
  • Removes a listener from an event type.

    Type parameters

    • T: string

    Parameters

    • type: T

      The type of the listener that gets removed.

    • listener: EventListener<Event, T, Camera>

      The listener function that gets removed.

    Returns void

removeFromParent

  • Removes this object from its current parent.

    Returns Camera

rotateOnAxis

  • rotateOnAxis(axis: Vector3, angle: number): Camera
  • 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 Camera

rotateOnWorldAxis

  • rotateOnWorldAxis(axis: Vector3, angle: number): Camera
  • 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

      The angle in radians.

    Returns Camera

rotateX

  • rotateX(angle: number): Camera
  • Parameters

    • angle: number

    Returns Camera

rotateY

  • rotateY(angle: number): Camera
  • Parameters

    • angle: number

    Returns Camera

rotateZ

  • rotateZ(angle: number): Camera
  • Parameters

    • angle: number

    Returns Camera

setPoseModeAnchorOrigin

  • setPoseModeAnchorOrigin(anchor: Anchor): void
  • Sets the pose mode to 'Anchor Origin'.

    In this case the camera moves and rotates in world space around the anchor at the origin.

    Parameters

    • anchor: Anchor

      The anchor that defines the origin.

    Returns void

setRotationFromAxisAngle

  • setRotationFromAxisAngle(axis: Vector3, angle: number): void
  • Parameters

    • axis: Vector3
    • angle: number

    Returns void

setRotationFromEuler

  • setRotationFromEuler(euler: Euler): void
  • Parameters

    • euler: Euler

    Returns void

setRotationFromMatrix

  • setRotationFromMatrix(m: Matrix4): void
  • Parameters

    • m: Matrix4

    Returns void

setRotationFromQuaternion

  • setRotationFromQuaternion(q: Quaternion): void
  • Parameters

    • q: Quaternion

    Returns void

start

  • start(userFacing?: boolean): void
  • Starts the camera source.

    Parameters

    • Optional userFacing: boolean

      If true, starts the user facing camera. (i.e selfie).

    Returns void

stop

  • stop(): void

toJSON

  • toJSON(meta?: { geometries: any; images: any; materials: any; textures: any }): any
  • Parameters

    • Optional meta: { geometries: any; images: any; materials: any; textures: any }
      • geometries: any
      • images: any
      • materials: any
      • textures: any

    Returns any

translateOnAxis

  • translateOnAxis(axis: Vector3, distance: number): Camera
  • Parameters

    • axis: Vector3

      A normalized vector in object space.

    • distance: number

      The distance to translate.

    Returns Camera

translateX

  • translateX(distance: number): Camera
  • Translates object along x axis by distance.

    Parameters

    • distance: number

      Distance.

    Returns Camera

translateY

  • translateY(distance: number): Camera
  • Translates object along y axis by distance.

    Parameters

    • distance: number

      Distance.

    Returns Camera

translateZ

  • translateZ(distance: number): Camera
  • Translates object along z axis by distance.

    Parameters

    • distance: number

      Distance.

    Returns Camera

traverse

  • traverse(callback: (object: Object3D<Event>) => any): void
  • Parameters

    • callback: (object: Object3D<Event>) => any
        • (object: Object3D<Event>): any
        • Parameters

          • object: Object3D<Event>

          Returns any

    Returns void

traverseAncestors

  • traverseAncestors(callback: (object: Object3D<Event>) => any): void
  • Parameters

    • callback: (object: Object3D<Event>) => any
        • (object: Object3D<Event>): any
        • Parameters

          • object: Object3D<Event>

          Returns any

    Returns void

traverseVisible

  • traverseVisible(callback: (object: Object3D<Event>) => any): void
  • Parameters

    • callback: (object: Object3D<Event>) => any
        • (object: Object3D<Event>): any
        • Parameters

          • object: Object3D<Event>

          Returns any

    Returns void

updateFrame

  • updateFrame(renderer: WebGLRenderer): void
  • Processes camera frames and updates backgroundTexture. Call this function on your pipeline once an animation frame (e.g. during your requestAnimationFrame function).

    Parameters

    • renderer: WebGLRenderer

      The Three.js WebGL renderer.

    Returns void

updateMatrix

  • updateMatrix(): void
  • Updates local transform.

    Returns void

updateMatrixWorld

  • updateMatrixWorld(force?: boolean): void
  • Parameters

    • Optional force: boolean

    Returns void

updateWorldMatrix

  • updateWorldMatrix(updateParents: boolean, updateChildren: boolean): void
  • Parameters

    • updateParents: boolean
    • updateChildren: boolean

    Returns void

worldToLocal

  • worldToLocal(vector: Vector3): Vector3
  • Updates the vector from world space to local space.

    Parameters

    • vector: Vector3

      A world vector.

    Returns Vector3

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property

Generated using TypeDoc