Home Reference Source
import {Camera} from 'bimsurfer3/viewer/camera.js'
public class | source

Camera

A Camera defines viewing and projection transforms for its Viewer.

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public set
public get

center: *

public set

constrainPitch(constrainPitch: Boolean)

Sets whether its currently possible to pitch the camera to look at the model upside-down.

public get

Gets whether its currently possible to pitch the camera to look at the model upside-down.

public set

Sets the position of the camera.

public get

Gets the position of the camera.

public set

gimbalLock(gimbalLock: Boolean)

Sets whether camera rotation is gimbal locked.

public get

Sets whether camera rotation is gimbal locked.

public

listeners: *[]

public
public set
public get
public
public
public get

Gets the current projection transform matrix.

public get

Gets the component that represents the current projection type.

public set

projectionType(projectionType: String)

Selects the current projection type.

public get

Gets the current projection type.

public set

target(target: Float32Array)

Sets the point the camera is looking at.

public get

Gets the point tha camera is looking at.

public
public
public
public
public
public
public
public
public
public set

Sets the camera's "up" direction.

public get

Gets the camera's "up" direction.

public get

Gets the current viewing transform matrix.

public get
public get

Gets the current viewing transform matrix for normals.

public get

Gets the current view projection matrix.

public get

Gets the current inverted view projection matrix.

public

viewer: *

public set

Indicates the up, right and forward axis of the World coordinate system.

public get

Indicates the up, right and forward axis of the World coordinate system.

public get

Direction of World-space "forwards".

public get

Direction of World-space "right".

public get

worldUp: *

Direction of World-space "up".

public
Private Members
private

_center: *

private
private
private

_eye: *

private
private
private
private
private
private
private

_target: *

private
private
private
private
private
private
private
private
private
private
private

_up: *

private
private
private
private
private
private
private
private
private

Method Summary

Public Methods
public

calcViewFit(aabb: *, fitFOV: *, eye: *, target: *)

public
public

interpolateView(newEye: *, newTarget: *)

public

lock()

public

orbitPitch(degrees: Number)

Rotates the eye position about the target position, pivoting around the right axis (orthogonal to up vector and eye->target vector).

public

orbitYaw(degrees: Number)

Rotates the eye position about the target position, pivoting around the up vector.

public

pan(pan: Array)

Pans the camera along the camera's local X, Y and Z axis.

public

pitch(degrees: Number)

Rotates the target position about the eye, pivoting around the right axis (orthogonal to up vector and eye->target vector).

public

restore(params: *)

public

setModelBounds(bounds: *)

public

unlock()

public
public

viewFit(aabb: Float32Array, fitFOV: Number)

Jumps the camera to look at the given axis-aligned World-space bounding box.

public

zoom(delta: Number, canvasPos: *)

Moves the camera along a ray through unprojected mouse coordinates

Private Methods
private

_build()

private

Public Constructors

public constructor() source

Public Members

public set center source

public get center: * source

public set constrainPitch(constrainPitch: Boolean) source

Sets whether its currently possible to pitch the camera to look at the model upside-down.

When this is true, camera will ignore attempts to orbit (camera or model) about the horizontal axis that would result in the model being viewed upside-down.

public get constrainPitch: Boolean: * source

Gets whether its currently possible to pitch the camera to look at the model upside-down.

Return:

Boolean

public set eye(eye: Float32Array) source

Sets the position of the camera.

public get eye: Float32Array: * source

Gets the position of the camera.

Return:

Float32Array

3D position of the camera in World space.

public set gimbalLock(gimbalLock: Boolean) source

Sets whether camera rotation is gimbal locked.

When true, yaw rotation will always pivot about the World-space "up" axis.

public get gimbalLock: Boolean: * source

Sets whether camera rotation is gimbal locked.

When true, yaw rotation will always pivot about the World-space "up" axis.

Return:

Boolean

True if gimbal locking is enabled.

public listeners: *[] source

public lowVolumeListeners: *[] source

public set orbitting source

public get orbitting: * source

public orthographic: * source

public perspective: * source

public get projMatrix: Float32Array: * source

Gets the current projection transform matrix.

Return:

Float32Array

4x4 column-order matrix as an array of 16 contiguous floats.

public get projection: Perspective | Orthographic: * source

Gets the component that represents the current projection type.

public set projectionType(projectionType: String) source

Selects the current projection type.

public get projectionType: String: * source

Gets the current projection type.

Return:

String

projectionType "persp" or "ortho".

public set target(target: Float32Array) source

Sets the point the camera is looking at.

public get target: Float32Array: * source

Gets the point tha camera is looking at.

Return:

Float32Array

3D position of the point of interest in World space.

public tempMat3b: * source

public tempMat4: * source

public tempVec3: * source

public tempVec3b: * source

public tempVec3c: * source

public tempVec3d: * source

public tempVec3e: * source

public tempVecBuild: * source

public tmp_modelBounds: * source

public set up(up: Float32Array) source

Sets the camera's "up" direction.

public get up: Float32Array: * source

Gets the camera's "up" direction.

Return:

Float32Array

3D vector indicating the camera's "up" direction in World-space.

public get viewMatrix: Float32Array: * source

Gets the current viewing transform matrix.

Return:

Float32Array

4x4 column-order matrix as an array of 16 contiguous floats.

public get viewMatrixInverted: * source

public get viewNormalMatrix: Float32Array: * source

Gets the current viewing transform matrix for normals.

This is the transposed inverse of the view matrix.

Return:

Float32Array

4x4 column-order matrix as an array of 16 contiguous floats.

public get viewProjMatrix: Float32Array: * source

Gets the current view projection matrix.

Return:

Float32Array

4x4 column-order matrix as an array of 16 contiguous floats.

public get viewProjMatrixInverted: Float32Array: * source

Gets the current inverted view projection matrix.

Return:

Float32Array

4x4 column-order matrix as an array of 16 contiguous floats.

public viewer: * source

public set worldAxis: Float32Array source

Indicates the up, right and forward axis of the World coordinate system.

This is used for deriving rotation axis for yaw orbiting, and for moving camera to axis-aligned positions.

Has format: [rightX, rightY, rightZ, upX, upY, upZ, forwardX, forwardY, forwardZ]

public get worldAxis: Float32Array source

Indicates the up, right and forward axis of the World coordinate system.

This is used for deriving rotation axis for yaw orbiting, and for moving camera to axis-aligned positions.

Has format: [rightX, rightY, rightZ, upX, upY, upZ, forwardX, forwardY, forwardZ]

public get worldForward: * source

Direction of World-space "forwards".

public get worldRight: * source

Direction of World-space "right".

public get worldUp: * source

Direction of World-space "up".

public yawMatrix: * source

Private Members

private _center: * source

private _constrainPitch: boolean source

private _dirty: boolean source

private _eye: * source

private _gimbalLock: boolean source

private _locked: boolean source

private _modelBounds: * source

private _negatedCenter: * source

private _orbitting: boolean source

private _projection: * source

private _target: * source

private _tmp_eye: * source

private _tmp_interpolate_a: * source

private _tmp_interpolate_b: * source

private _tmp_interpolate_c: * source

private _tmp_interpolate_current_dir: * source

private _tmp_interpolate_d: * source

private _tmp_interpolate_e: * source

private _tmp_interpolate_f: * source

private _tmp_interpolate_new_dir: * source

private _tmp_target: * source

private _up: * source

private _viewMatrix: * source

private _viewMatrixInverted: * source

private _viewNormalMatrix: * source

private _viewProjMatrix: * source

private _viewProjMatrixInverted: * source

private _worldAxis: * source

private _worldForward: * source

private _worldRight: * source

private _worldUp: * source

Public Methods

public calcViewFit(aabb: *, fitFOV: *, eye: *, target: *) source

Params:

NameTypeAttributeDescription
aabb *
fitFOV *
eye *
target *

public forceBuild() source

public interpolateView(newEye: *, newTarget: *) source

Params:

NameTypeAttributeDescription
newEye *
newTarget *

public lock() source

public orbitPitch(degrees: Number) source

Rotates the eye position about the target position, pivoting around the right axis (orthogonal to up vector and eye->target vector).

Params:

NameTypeAttributeDescription
degrees Number

Angle of rotation in degrees

public orbitYaw(degrees: Number) source

Rotates the eye position about the target position, pivoting around the up vector.

Params:

NameTypeAttributeDescription
degrees Number

Angle of rotation in degrees

public pan(pan: Array) source

Pans the camera along the camera's local X, Y and Z axis.

Params:

NameTypeAttributeDescription
pan Array

The pan vector

public pitch(degrees: Number) source

Rotates the target position about the eye, pivoting around the right axis (orthogonal to up vector and eye->target vector).

Params:

NameTypeAttributeDescription
degrees Number

Angle of rotation in degrees

public restore(params: *) source

Params:

NameTypeAttributeDescription
params *

public setModelBounds(bounds: *) source

Params:

NameTypeAttributeDescription
bounds *

public unlock() source

public updateLowVolumeListeners() source

public viewFit(aabb: Float32Array, fitFOV: Number) source

Jumps the camera to look at the given axis-aligned World-space bounding box.

Params:

NameTypeAttributeDescription
aabb Float32Array

The axis-aligned World-space bounding box (AABB).

fitFOV Number

Field-of-view occupied by the AABB when the camera has fitted it to view.

public zoom(delta: Number, canvasPos: *) source

Moves the camera along a ray through unprojected mouse coordinates

Params:

NameTypeAttributeDescription
delta Number

Zoom increment

canvasPos *

Mouse position relative to canvas to determine ray along which to move

Private Methods

private _build() source

private _setDirty() source