Interface ICamera<E, ET>

interface ICamera<
    E extends ICameraEvent = ICameraEvent,
    ET extends ICameraEventTypes = ICameraEventTypes,
> {
    _currentGeometry?: null | IGeometry;
    _currentMaterial?: null | IMaterial | IMaterial[];
    _onGeometryUpdate?: (e: IGeometryEvent<"geometryUpdate">) => void;
    aspect: number;
    assetType: "camera";
    autoAspect: boolean;
    autoNearFar: boolean;
    cameraObject: ICamera<E, ET>;
    canUserInteract: boolean;
    children: IObject3D[];
    controls: undefined | ICameraControls;
    controlsMode?: string;
    far: number;
    fov?: number;
    geometry?: IGeometry;
    interactionsEnabled: boolean;
    isActiveCamera: boolean;
    isCamera: true;
    isLight?: boolean;
    isLine?: boolean;
    isLineSegments?: boolean;
    isMainCamera: boolean;
    isMesh?: boolean;
    isOrthographicCamera?: boolean;
    isPerspectiveCamera?: boolean;
    isScene?: boolean;
    isWidget?: boolean;
    material?: IMaterial | IMaterial[];
    materials?: IMaterial[];
    maxFarPlane: number;
    minNearPlane: number;
    modelObject: ICamera<E, ET>;
    morphTargetDictionary?: Record<string, number>;
    morphTargetInfluences?: number[];
    near: number;
    objectProcessor?: IObjectProcessor;
    parent: null | IObject3D;
    parentRoot?: null | IObject3D;
    position: Vector3;
    target: Vector3;
    uiConfig?: UiObjectConfig;
    userData: ICameraUserData;
    zoom: number;
    activateMain(
        options?: Partial<ICameraEvent>,
        _internal?: boolean,
        _refresh?: boolean,
    ): void;
    add(...object: IObject3D[]): this;
    autoCenter(setDirty?: boolean, undo?: boolean): this;
    autoScale(
        autoScaleRadius?: number,
        isCentered?: boolean,
        setDirty?: boolean,
        undo?: boolean,
    ): this;
    clone(recursive?: boolean): this;
    copy(
        source: this,
        recursive?: boolean,
        distanceFromTarget?: number,
        worldSpace?: boolean,
        ...args: any[],
    ): this;
    deactivateMain(
        options?: Partial<ICameraEvent>,
        _internal?: boolean,
        _refresh?: boolean,
    ): void;
    dispose(removeFromParent?: boolean): void;
    getObjectById<T extends IObject3D = IObject3D>(id: number): undefined | T;
    getObjectByName<T extends IObject3D = IObject3D>(
        name: string,
    ): undefined | T;
    getObjectByProperty<T extends IObject3D = IObject3D>(
        name: string,
        value: string,
    ): undefined | T;
    getView<T extends ICameraView = CameraView>(
        worldSpace?: boolean,
        cameraView?: T,
    ): T;
    pivotToBoundsCenter(setDirty?: boolean): () => void;
    pivotToPoint(point: Vector3, setDirty?: boolean): this;
    refreshAspect(setDirty?: boolean): void;
    refreshCameraControls(setDirty?: boolean): void;
    refreshTarget(): void;
    refreshUi(): void;
    remove(...object: IObject3D[]): this;
    removeControlsCtor(key: string): void;
    setControlsCtor(key: string, ctor: TControlsCtor, replace?: boolean): void;
    setDirty(options?: IObjectSetDirtyOptions): void;
    setInteractions(enabled: boolean, by: string): void;
    setView(view: ICameraView): void;
    setViewFromCamera(
        camera: Camera | ICamera,
        distanceFromTarget?: number,
        worldSpace?: boolean,
    ): void;
    setViewToMain(eventOptions: Partial<ICameraEvent>): void;
    traverse(callback: (object: IObject3D) => void): void;
    traverseAncestors(callback: (object: IObject3D) => void): void;
    traverseVisible(callback: (object: IObject3D) => void): void;
    updateMorphTargets(): void;
    updateProjectionMatrix(): void;
    updateShaderProperties(
        material: {
            defines: Record<string, undefined | string | number>;
            uniforms: { [name: string]: IUniform };
        },
    ): this;
}

Type Parameters

Hierarchy (View Summary)

Implemented by

Properties

_currentGeometry?: null | IGeometry
_currentMaterial?: null | IMaterial | IMaterial[]
_onGeometryUpdate?: (e: IGeometryEvent<"geometryUpdate">) => void
aspect: number

Camera frustum aspect ratio, window width divided by window height. It can be managed internally if autoAspect is true.

1
assetType: "camera"
autoAspect: boolean

Automatically manage aspect ratio based on window/canvas size.

autoNearFar: boolean
cameraObject: ICamera<E, ET>

use this instead

canUserInteract: boolean

Check whether user can interact with this camera. Interactions can be enabled/disabled in a variety of ways, like setInteractions, controlsMode, isMainCamera property

children: IObject3D[]

Array with object's children.

THREE.Object3DGroup | Group for info on manually grouping objects.

[]

controls: undefined | ICameraControls
controlsMode?: string
far: number

Automatically managed when autoNearFar is true. See also maxFarPlane

fov?: number
geometry?: IGeometry
interactionsEnabled: boolean
isActiveCamera: boolean

use isMainCamera instead

isCamera: true

Read-only flag to check if a given object is of type Camera.

This is a constant value

true

isLight?: boolean
isLine?: boolean
isLineSegments?: boolean
isMainCamera: boolean
isMesh?: boolean
isOrthographicCamera?: boolean
isPerspectiveCamera?: boolean
isScene?: boolean
isWidget?: boolean
material?: IMaterial | IMaterial[]
materials?: IMaterial[]

Same as material but always returns an array. To set, just set material property

maxFarPlane: number
minNearPlane: number
modelObject: ICamera<E, ET>

use object directly

morphTargetDictionary?: Record<string, number>
morphTargetInfluences?: number[]
near: number

Automatically managed when autoNearFar is true. See also minNearPlane

objectProcessor?: IObjectProcessor
parent: null | IObject3D

Object's parent in the scene graph.

An object can have at most one parent.

null

parentRoot?: null | IObject3D

Parent/Ancestor of this object to bubble events to. This is set internally by setupObject3D.

position: Vector3

Local position of camera.

target: Vector3

Target of camera, in world(global) coordinates.

uiConfig?: UiObjectConfig
userData: ICameraUserData

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.

{}

zoom: number

Methods

  • Parameters

    • Optionaloptions: Partial<ICameraEvent>
    • Optional_internal: boolean
    • Optional_refresh: boolean

    Returns void

  • Moves the bounding box center of the object to the center of the world

    Parameters

    • OptionalsetDirty: boolean

      calls setDirty

    • Optionalundo: boolean

      undo any previous autoCenter operation

    Returns this

    true
    
  • Scales the object to fit the given radius.

    Parameters

    • OptionalautoScaleRadius: number

      optional (taken from userData.autoScaleRadius by default)

    • OptionalisCentered: boolean

      optional (taken from userData.isCentered by default)

    • OptionalsetDirty: boolean

      true by default

    • Optionalundo: boolean

      undo any previous autoScale operation

    Returns this

  • Returns a clone of this object and optionally all descendants.

    Parameters

    • Optionalrecursive: boolean

      If true, descendants of the object are also cloned. Default true

    Returns this

  • Copy the given object into this object

    Parameters

    • source: this
    • Optionalrecursive: boolean

      If true, descendants of the object are also copied. Default true

    • OptionaldistanceFromTarget: number
    • OptionalworldSpace: boolean
    • ...args: any[]

    Returns this

    Note: event listeners and user-defined callbacks (.onAfterRender and .onBeforeRender) are not copied.

  • Parameters

    • Optionaloptions: Partial<ICameraEvent>
    • Optional_internal: boolean
    • Optional_refresh: boolean

    Returns void

  • Parameters

    • OptionalremoveFromParent: boolean

      remove from parent. Default true

    Returns void

  • Searches through an object and its children, starting with the object itself, and returns the first with a matching id.

    Type Parameters

    Parameters

    • id: number

      Unique number of the object instance. Expects a Integer

    Returns undefined | T

    Note that ids are assigned in chronological order: 1, 2, 3, ..., incrementing by one for each new object.

    id

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

    Type Parameters

    Parameters

    • name: string

      the property name to search for.

    • value: string

      value of the given property.

    Returns undefined | T

  • Moves the object pivot to the center of the bounding box.

    The object will rotate around the new pivot.

    Parameters

    • OptionalsetDirty: boolean

      calls setDirty

    Returns () => void

    undo function

    true
    
  • Moves the object pivot to the given point

    The object will rotate around the new pivot.

    Parameters

    • point: Vector3

      point to move the pivot to

    • OptionalsetDirty: boolean

      calls setDirty

    Returns this

    undo function

    true
    
  • Parameters

    • OptionalsetDirty: boolean

    Returns void

  • Parameters

    • OptionalsetDirty: boolean

    Returns void

  • Parameters

    • enabled: boolean
    • by: string

    Returns void

  • Set camera view from another camera.

    Parameters

    • camera: Camera | ICamera
    • OptionaldistanceFromTarget: number

      default = 4

    • OptionalworldSpace: boolean

      default = true

    Returns void

  • Dispatches the setView event which triggers the main camera to set its view to this camera's view.

    Parameters

    Returns void

  • Executes the callback on this object and all descendants.

    Parameters

    • callback: (object: IObject3D) => void

      A function with as first argument an Object3D object.

    Returns void

    Note: Modifying the scene graph inside the callback is discouraged.

  • Like traverse, but the callback will only be executed for visible objects

    Parameters

    • callback: (object: IObject3D) => void

      A function with as first argument an Object3D object.

    Returns void

    Descendants of invisible objects are not traversed.