Camera
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
new Camera(options: CameraOptions): Camera
Parameters
Camera options
Properties
animation
animationnull | CameraAnimation
Active camera animation, null
if there isn't.
fov
fovnumber
Camera's horizontal FOV(Field of View) value
initialPitch
initialPitchnumber
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.
const viewer = new View360("#el_id", {
initialPitch: 60
});
viewer.on("ready", () => {
console.log(viewer.camera.pitch); // 60
});
initialYaw
initialYawnumber
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.
const viewer = new View360("#el_id", {
initialYaw: 30
});
viewer.on("ready", () => {
console.log(viewer.camera.yaw); // 30
});
initialZoom
initialZoomnumber
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.
const viewer = new View360("#el_id", {
initialPitch: 60
});
viewer.on("ready", () => {
console.log(viewer.camera.pitch); // 60
});
pitch
pitchnumber
Current pitch(x-axis rotation) value
position
positionvec3
Current camera position
projectionMatrix
projectionMatrixmat4
Camera's projection matrix
quaternion
quaternionquat
Current camera quaternion
viewMatrix
viewMatrixmat4
Camera's view matrix
yaw
yawnumber
Current yaw(y-axis rotation) value
zoom
zoomnumber
Current zoom value
aspect
aspectnumber
Camera's width / height ratio
changed
changedboolean
Whether the camera's rotation changed from the last frame.
pitchRange
pitchRangenull | Range
Restrict pitch(x-axis rotation) range. (in degrees, °)
yawRange
yawRangenull | Range
Restrict yaw(y-axis rotation) range. (in degrees, °)
zoomRange
zoomRangenull | Range
Restrict camera zoom range.
If null
, a default zoom range from 0.6
to 10
will be used.
Methods
animateTo
animateToPromise<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
Partial<{ duration: number; easing: ((x: number) => number); pitch: number; yaw: number; zoom: number }>
{}
Animation parameters
destroy
destroyvoid
destroy(): void
Destroy instance and detach all event listeners
fovToZoom
fovToZoomnumber
fovToZoom(fov: number): number
Calculate zoom value for the given fov.
Parameters
number
horizontal fov (in degrees, °)
getHorizontalFov
getHorizontalFovnumber
getHorizontalFov(zoom: number): number
Return horizontal fov value when the given zoom is applied. (in degrees, °)
Parameters
number
...
Returns
Zoomed horizontal FOV
getPitchRange
getPitchRangeReadonly<Range>
getPitchRange(zoom: number): Readonly<Range>
Get actual pitch range by the given zoom value.
Parameters
number
getVerticalFov
getVerticalFovnumber
getVerticalFov(zoom: number): number
Return vertical fov value when the given zoom is applied. (in degrees, °)
Parameters
number
...
Returns
Zoomed vertical FOV
getYawRange
getYawRangeReadonly<Range>
getYawRange(zoom: number): Readonly<Range>
Get actual yaw range by the given zoom value.
Parameters
number
getZoomRange
getZoomRange{ current: number; max: number; min: number }
getZoomRange(): { current: number; max: number; min: number }
Get actual zoom range in fov degrees.
hasOn
hasOnboolean
hasOn<K>(eventName: K): boolean
Parameters
K
lookAt
lookAtvoid
lookAt(rotation: Partial<{ pitch: number; yaw: number; zoom: number }>): void
Change camera's rotation with euler values.
Parameters
Partial<{ pitch: number; yaw: number; zoom: number }>
Rotation values
off
off
off<K>(eventName: K, handlerToDetach: EventCallback<CameraEvents, K, Camera>): Camera
Parameters
K
EventCallback<CameraEvents, K, Camera>
on
on
on(eventHash: Partial<{ animationEnd: ((event: { animation: CameraAnimation }) => any) }>): Camera
Parameters
Partial<{ animationEnd: ((event: { animation: CameraAnimation }) => any) }>
once
once
once(eventHash: Partial<{ animationEnd: ((event: { animation: CameraAnimation }) => any) }>): Camera
Parameters
Partial<{ animationEnd: ((event: { animation: CameraAnimation }) => any) }>
resize
resizevoid
resize(width: number, height: number): void
Refresh internal size value.
Parameters
number
New width
number
New height
rotate
rotatevoid
rotate(rotation: quat, zoom: number): void
Change camera's rotation with quaternion.
Parameters
quat
Quaternion to apply
number
...
zoom value to apply
trigger
trigger
trigger<K>(event: K, ...params: EventTriggerParams<CameraEvents, K>): Camera
Parameters
K
EventTriggerParams<CameraEvents, K>
updateMatrix
updateMatrixvoid
updateMatrix(): void
Update inner matrixes.
Events
animationEnd
animationEnd{ animation: CameraAnimation }
An event that fires when camera's animation stops