Skip to main content

Camera

Since version 4.0.0

Camera for View360

class Camera extends Component<CameraEvents>

Extends

Properties

Active camera animation, null if there isn't.

Camera's horizontal FOV(Field of View) value

Initial pitch (x-axis rotation) value for camera. (in degrees, °)
As View360 uses right-handed coordinate system internally, positive value will make camera to look upside, while negative value will look down.

Initial yaw (y-axis rotation) value for camera. (in degrees, °)
As View360 uses right-handed coordinate system internally, camera will rotate counter-clockwise by this value.

Initial pitch (x-axis rotation) value for camera. (in degrees, °)
As View360 uses right-handed coordinate system internally, positive value will make camera to look upside, while negative value will look down.

Current pitch(x-axis rotation) value

Current camera position

Camera's projection matrix

Current camera quaternion

Camera's view matrix

Current yaw(y-axis rotation) value

Current zoom value

Camera's width / height ratio

Whether the camera's rotation changed from the last frame.

Restrict pitch(x-axis rotation) range. (in degrees, °)

Restrict yaw(y-axis rotation) range. (in degrees, °)

Restrict camera zoom range.
If null, a default zoom range from 0.6 to 10 will be used.

Methods

Change camera's rotation to given euler values by the given duration.

Destroy instance and detach all event listeners

Calculate zoom value for the given fov.

Return horizontal fov value when the given zoom is applied. (in degrees, °)

Get actual pitch range by the given zoom value.

Return vertical fov value when the given zoom is applied. (in degrees, °)

Get actual yaw range by the given zoom value.

Get actual zoom range in fov degrees.

Change camera's rotation with euler values.

Refresh internal size value.

Change camera's rotation with quaternion.

Update inner matrixes.

Events

An event that fires when camera's animation stops

Constructor

Create new instance of Camera
new Camera(options: CameraOptions): Camera

Parameters

Camera options

Properties

animation

>=4.0.0
animation

null | CameraAnimation

Active camera animation, null if there isn't.

fov

>=4.0.0
fov

number

Camera's horizontal FOV(Field of View) value

initialPitch

>=4.0.0
initialPitch

number

0

Initial pitch (x-axis rotation) value for camera. (in degrees, °)
As View360 uses right-handed coordinate system internally, positive value will make camera to look upside, while negative value will look down.

Example
const viewer = new View360("#el_id", {
initialPitch: 60
});

viewer.on("ready", () => {
console.log(viewer.camera.pitch); // 60
});

initialYaw

>=4.0.0
initialYaw

number

0

Initial yaw (y-axis rotation) value for camera. (in degrees, °)
As View360 uses right-handed coordinate system internally, camera will rotate counter-clockwise by this value.

Example
const viewer = new View360("#el_id", {
initialYaw: 30
});

viewer.on("ready", () => {
console.log(viewer.camera.yaw); // 30
});

initialZoom

>=4.0.0
initialZoom

number

0

Initial pitch (x-axis rotation) value for camera. (in degrees, °)
As View360 uses right-handed coordinate system internally, positive value will make camera to look upside, while negative value will look down.

Example
const viewer = new View360("#el_id", {
initialPitch: 60
});

viewer.on("ready", () => {
console.log(viewer.camera.pitch); // 60
});

pitch

>=4.0.0
pitch

number

Current pitch(x-axis rotation) value

position

>=4.0.0
position

vec3

Current camera position

projectionMatrix

>=4.0.0
projectionMatrix

mat4

Camera's projection matrix

quaternion

>=4.0.0
quaternion

quat

Current camera quaternion

viewMatrix

>=4.0.0
viewMatrix

mat4

Camera's view matrix

yaw

>=4.0.0
yaw

number

Current yaw(y-axis rotation) value

zoom

>=4.0.0
zoom

number

Current zoom value

aspect

readonly
aspect

number

Camera's width / height ratio

changed

readonly
changed

boolean

Whether the camera's rotation changed from the last frame.

pitchRange

pitchRange

null | Range

Restrict pitch(x-axis rotation) range. (in degrees, °)

yawRange

yawRange

null | Range

Restrict yaw(y-axis rotation) range. (in degrees, °)

zoomRange

zoomRange

null | Range

Restrict camera zoom range.
If null, a default zoom range from 0.6 to 10 will be used.

Methods

animateTo

animateTo

Promise<void>

animateTo(options: Partial<{ duration: number; easing: ((x: number) => number); pitch: number; yaw: number; zoom: number }>): Promise<void>

Change camera's rotation to given euler values by the given duration.

Parameters

options

Partial<{ duration: number; easing: ((x: number) => number); pitch: number; yaw: number; zoom: number }>

{}

Animation parameters

destroy

>=4.0.0
destroy

void

destroy(): void

Destroy instance and detach all event listeners

fovToZoom

>=4.0.0
fovToZoom

number

fovToZoom(fov: number): number

Calculate zoom value for the given fov.

Parameters

fov

number

horizontal fov (in degrees, °)

getHorizontalFov

>=4.0.0
getHorizontalFov

number

getHorizontalFov(zoom: number): number

Return horizontal fov value when the given zoom is applied. (in degrees, °)

Parameters

zoom

number

...

Returns

Zoomed horizontal FOV

getPitchRange

>=4.0.0
getPitchRange

Readonly<Range>

getPitchRange(zoom: number): Readonly<Range>

Get actual pitch range by the given zoom value.

Parameters

zoom

number

getVerticalFov

>=4.0.0
getVerticalFov

number

getVerticalFov(zoom: number): number

Return vertical fov value when the given zoom is applied. (in degrees, °)

Parameters

zoom

number

...

Returns

Zoomed vertical FOV

getYawRange

>=4.0.0
getYawRange

Readonly<Range>

getYawRange(zoom: number): Readonly<Range>

Get actual yaw range by the given zoom value.

Parameters

zoom

number

getZoomRange

>=4.0.0
getZoomRange

{ current: number;   max: number;   min: number }

getZoomRange(): { current: number; max: number; min: number }

Get actual zoom range in fov degrees.

hasOn

inherited
hasOn

boolean

hasOn<K>(eventName: K): boolean

Parameters

eventName

K

lookAt

>=4.0.0
lookAt

void

lookAt(rotation: Partial<{ pitch: number; yaw: number; zoom: number }>): void

Change camera's rotation with euler values.

Parameters

rotation

Partial<{ pitch: number; yaw: number; zoom: number }>

Rotation values

off

inherited
off

Camera

off<K>(eventName: K, handlerToDetach: EventCallback<CameraEvents, K, Camera>): Camera

Parameters

eventName

K

handlerToDetach

EventCallback<CameraEvents, K, Camera>

on

inherited
on

Camera

on(eventHash: Partial<{ animationEnd: ((event: { animation: CameraAnimation }) => any) }>): Camera

Parameters

eventHash

Partial<{ animationEnd: ((event: { animation: CameraAnimation }) => any) }>

once

inherited
once

Camera

once(eventHash: Partial<{ animationEnd: ((event: { animation: CameraAnimation }) => any) }>): Camera

Parameters

eventHash

Partial<{ animationEnd: ((event: { animation: CameraAnimation }) => any) }>

resize

>=4.0.0
resize

void

resize(width: number, height: number): void

Refresh internal size value.

Parameters

width

number

New width

height

number

New height

rotate

>=4.0.0
rotate

void

rotate(rotation: quat, zoom: number): void

Change camera's rotation with quaternion.

Parameters

rotation

quat

Quaternion to apply

zoom

number

...

zoom value to apply

trigger

inherited
trigger

Camera

trigger<K>(event: K, ...params: EventTriggerParams<CameraEvents, K>): Camera

Parameters

event

K

params

EventTriggerParams<CameraEvents, K>

updateMatrix

>=4.0.0
updateMatrix

void

updateMatrix(): void

Update inner matrixes.

Events

animationEnd

>=4.0.0
animationEnd

{ animation: CameraAnimation }

An event that fires when camera's animation stops