Readonly
customThe custom projection.
The Camera uses this while Camera.projectionType equals @xeokit/constants!CustomProjectionType.
True once this Component has been destroyed.
Don't use this Component if this is true
.
Protected
dirtyReadonly
frustumThe frustum projection.
The Camera uses this while Camera.projectionType equals @xeokit/constants!FrustumProjectionType.
Unique ID of this Component.
Readonly
orthoThe orthographic projection.
The Camera uses this while Camera.projectionType equals @xeokit/constants!OrthoProjectionType.
Readonly
perspectiveThe perspective projection.
The Camera uses this while Camera.projectionType equals PerspectiveProjectionType.
Readonly
viewThe View to which this Camera belongs.
Gets whether to prevent camera from being pitched upside down.
The camera is upside down when the angle between Camera.up and Camera.worldUp is less than one degree.
Default value is false
.
true
if pitch rotation is currently constrained.
Sets whether to prevent camera from being pitched upside down.
The camera is upside down when the angle between Camera.up and Camera.worldUp is less than one degree.
Default value is false
.
Set true
to contrain pitch rotation.
Gets an optional matrix to premultiply into Camera.projMatrix matrix.
The matrix.
Sets an optional matrix to premultiply into Camera.projMatrix matrix.
This is intended to be used for stereo rendering with WebVR etc.
The matrix.
Gets the position of the Camera's eye.
Default vale is [0,0,10]
.
Sets the position of the Camera's eye.
Default value is [0,0,10]
.
"eye" event on change, with the value of this property.
Gets distance from Camera.look to Camera.eye.
The distance.
Gets the Camera's 3D World-space viewing frustum.
The frustum.
Gets whether to lock yaw rotation to pivot about the World-space "up" axis.
Returns true
if gimbal is locked.
Sets whether to lock yaw rotation to pivot about the World-space "up" axis.
gimbalLock Set true to lock gimbal.
Gets the inverse of the Camera's viewing transform matrix.
The inverse viewing transform matrix.
Gets the position of this Camera's point-of-interest.
Default value is [0,0,0]
.
Camera look position.
Sets the position of this Camera's point-of-interest.
Default value is [0,0,0]
.
Camera look position.
Gets the Camera's projection transformation projMatrix.
The projection matrix.
Gets the currently active projection for this Camera.
The currently active project is selected with Camera.projectionType.
The currently active projection is active.
Gets the active projection type.
Possible values are PerspectiveProjectionType
, OrthoProjectionType
, "frustum"
and "customProjection"
.
Default value is PerspectiveProjectionType
.
Identifies the active projection type.
Sets the active projection type.
Accepted values are PerspectiveProjectionType
, OrthoProjectionType
, "frustum"
and "customProjection"
.
Default value is PerspectiveProjectionType
.
Identifies the active projection type.
Gets the Camera's viewing transformation matrix.
The viewing transform matrix.
Gets the up, right and forward axis of the World coordinate system.
Has format: [rightX, rightY, rightZ, upX, upY, upZ, forwardX, forwardY, forwardZ]
Default axis is [1, 0, 0, 0, 1, 0, 0, 0, 1]
The current World coordinate axis.
Sets the up, right and forward axis of the World coordinate system.
Has format: [rightX, rightY, rightZ, upX, upY, upZ, forwardX, forwardY, forwardZ]
Default axis is [1, 0, 0, 0, 1, 0, 0, 0, 1]
The new Wworld coordinate axis.
Gets the direction of World-space "forwards".
This is set by Camera.worldAxis.
Default value is [0,0,1]
.
The "up" vector.
Gets the direction of World-space "right".
This is set by Camera.worldAxis.
Default value is [1,0,0]
.
The "up" vector.
The "up" vector.
Gets if the World-space X-axis is "up".
Gets if the World-space Y-axis is "up".
Gets if the World-space Z-axis is "up".
Protected
cleanProtected
errorProtected
logRotates Camera.eye about Camera.look around the right axis (orthogonal to Camera.up and "look").
Angle of rotation in degrees
Rotates Camera.eye about Camera.look, around the Camera.up vector
Angle of rotation in degrees
Rotates Camera.look about Camera.eye, around the right axis (orthogonal to Camera.up and "look").
Angle of rotation in degrees
Protected
warnRotates Camera.look about Camera.eye, around the Camera.up vector.
Angle of rotation in degrees
Increments/decrements the Camera's zoom factor, which is the distance between Camera.eye and Camera.look.
Zoom factor increment.
Emits an event when the Component has been destroyed.
Readonly
onEmits an event each time Camera.frustum updates.
myView.camera.onFrustum.subscribe((camera, frustum) => { ... });
Readonly
onEmits an event each time Camera.projMatrix updates.
myView.camera.onProjMatrix.subscribe((camera, projMatrix) => { ... });
Readonly
onEmits an event each time Camera.projectionType updates.
myView.camera.onProjectionType.subscribe((camera, projType) => { ... });
Readonly
onEmits an event each time Camera.viewMatrix updates.
myView.camera.onViewMatrix.subscribe((camera, viewMatrix) => { ... });
Readonly
onEmits an event each time Camera.worldAxis updates.
myView.camera.onWorldAxis.subscribe((camera, worldAxis) => { ... });
Controls the viewpoint and projection for a @xeokit/viewer!View.
Summary
Getting a View's Camera
Let's create a Viewer with a single @xeokit/viewer!View, from which we'll get a Camera:
Setting the Camera Position
Get and set the Camera's absolute position:
Camera View and Projection Matrices
The Camera's view matrix transforms coordinates from World-space to View-space:
Camera.onViewMatrix fires whenever Camera.viewMatrix updates:
Rotating the Camera
Orbiting the Camera.look position:
Perform a first-person rotation, in which we rotate Camera.look and Camera.up about Camera.eye:
Panning the Camera
Pan along the Camera's local axis (ie. left/right, up/down, forward/backward):
Zooming the Camera
Zoom to vary distance between Camera.eye and Camera.look:
Get the current distance between Camera.eye and Camera.look:
Projection
The Camera has a Component to manage each projection type, which are: PerspectiveProjection, OrthoProjection and FrustumProjection and CustomProjection.
You can configure those components at any time, regardless of which is currently active:
The Camera has a PerspectiveProjection to manage perspective
Camera provides the projection matrix for the currently active projection in Camera.projMatrix.
Get the projection matrix:
Listen for projection matrix updates:
Configuring World up direction
We can dynamically configure the directions of the World-space coordinate system.
Setting the +Y axis as World "up", +X as right and -Z as forwards (convention in some modeling software):
Setting the +Z axis as World "up", +X as right and -Y as "up" (convention in most CAD and BIM viewers):
The Camera has read-only convenience properties that provide each axis individually:
Gimbal locking
By default, the Camera locks yaw rotation to pivot about the World-space "up" axis. We can dynamically lock and unlock that at any time:
See: https://en.wikipedia.org/wiki/Gimbal_lock