ReadonlycustomThe custom projection.
The Camera uses this while Camera.projectionType equals constants!CustomProjectionType.
ReadonlyfrustumThe frustum projection.
The Camera uses this while Camera.projectionType equals constants!FrustumProjectionType.
ReadonlyorthoThe orthographic projection.
The Camera uses this while Camera.projectionType equals constants!OrthoProjectionType.
ReadonlyperspectiveThe perspective projection.
The Camera uses this while Camera.projectionType equals PerspectiveProjectionType.
ReadonlyviewThe 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,-10,0].
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.
Set true to lock gimbal.
Gets the inverse of the Camera's viewing transform matrix.
The inverse viewing transform 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.
Rotates 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
Gets the configuration of this Camera.
Rotates 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.
Controls the viewpoint and projection for a View.
Getting a View's Camera
Let's create a Viewer with a single 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:
ViewerEvents.onCameraViewMatrixUpdated 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