Camera
-
class
cee.
Camera
() Camera settings (view point and projection) for a View.
Use this class to get a View’s current eye point, view direction and up vector.
Setup the camera by providing the eye, view reference point (center) and up vector to
setFromLookAt
.You can also use this class to setup the projection and control the front and back clipping planes.
You can access a View’s camera with the
View.camera
property.
Accessors
Methods
applyCameraConfig
computeFitViewEyePosition
disableAutoClip
enableAutoClipFixedNearDistance
enableAutoClipMinimumNearDistance
fitView
fitViewOrtho
getDirection
getPosition
getUp
project
resetCamera
setClipPlanesFromBoundingBox
setFromLookAt
setProjectionAsOrtho
setProjectionAsPerspective
setViewChangeHandler
setViewMatrix
setViewpoint
unproject
zoomToBoundingBox
Accessors
-
Camera.
farPlane
() Returns the far clipping plane
Return type: number
-
Camera.
fieldOfViewYDeg
() Returns the total field of view in the Y direction in degrees.
Returns undefined if parallel (orthographic) projection
Return type: number
-
Camera.
frontPlaneFrustumHeight
() Get height of the view frustum in the front plane in world coordinates.
Return type: number
-
Camera.
nearPlane
() Returns the near clipping plane
Return type: number
-
Camera.
projectionType
() Returns the current projection type (perspective/ortho)
Return type: ProjectionType
-
Camera.
viewMatrix
() Returns the current view matrix
Return type: Mat4
-
Camera.
viewport
() Returns the viewport of the camera
Return type: function
Methods
applyCameraConfig
-
Camera.
applyCameraConfig
(config, allowChangeOfProjectionType) Arguments: - config (
CameraConfig
) – None - allowChangeOfProjectionType (
boolean
) – None
Helper that applies a camera config to the camera
Return type: void - config (
computeFitViewEyePosition
-
Camera.
computeFitViewEyePosition
(boundingBox, dir, up, coverageFactor) Arguments: - boundingBox (
BoundingBox
) – None - dir (
Vec3
) – None - up (
Vec3
) – None - coverageFactor (
number
) – None
Calculate the camera position required to fit the given bounding box in the view when the camera is orientated with the given direction and up vectors.
Return type: Vec3 - boundingBox (
enableAutoClipFixedNearDistance
-
Camera.
enableAutoClipFixedNearDistance
(fixedNearDistance) Arguments: - fixedNearDistance (
number
) – None
Enables the auto clipping feature and sets a fixed near distance
Return type: void - fixedNearDistance (
enableAutoClipMinimumNearDistance
-
Camera.
enableAutoClipMinimumNearDistance
(minNearDistance) Arguments: - minNearDistance (
number
) – None
Enables the auto clipping feature and sets a minimum near distance
Return type: void - minNearDistance (
fitView
-
Camera.
fitView
(boundingBox, dir, up, coverageFactor) Arguments: - boundingBox (
BoundingBox
) – None - dir (
Vec3Like
) – None - up (
Vec3Like
) – None - coverageFactor (
number
) – None
Sets up the view to contain the passed bounding box, with the camera looking from the given direction (dir) and with the given up vector (up).
The passed boundingBox should be the bounding box of the object/model you would like to fit the view to.
The relativeDistance parameter specifies the distance from the camera to the center of the bounding box.
Note: This only works for perspective projection. For orthographic (parallel) projections, use the fitViewOrtho method.
Return type: void - boundingBox (
fitViewOrtho
-
Camera.
fitViewOrtho
(boundingBox, eyeDist, dir, up, coverageFactor) Arguments: - boundingBox (
BoundingBox
) – None - eyeDist (
number
) – None - dir (
Vec3Like
) – None - up (
Vec3Like
) – None - coverageFactor (
number
) – None
Sets up the view to contain the passed bounding box, with the camera looking from the given direction ‘dir’, at the give distance ‘eyeDist’ and with the given up vector ‘up’.
We recommend to set the ‘eyeDist’ to boundingBox.radius()*2.0
The passed boundingBox should be the bounding box of the object/model you would like to fit the view to.
Note: This only works for orthographic (parallel) projection. For perspective projections, use the fitView method.
Return type: void - boundingBox (
getDirection
-
Camera.
getDirection
() Returns camera’s forward direction vector. The returned vector is normalized.
Return type: Vec3
getUp
-
Camera.
getUp
() Returns the camera’s up vector. The returned vector is normalized.
Return type: Vec3
project
-
Camera.
project
(point) Arguments: - point (
Vec3Like
) – None
Maps world (3d) coordinates to window coordinates
Returns null if the specified point cannot be projected.
The returned window coordinates ‘out’ are in WebGL/OpenGL style coordinates, which means a right handed coordinate system with the origin in the lower left corner of the window.
OpenGL like project.
Return type: Vec3 - point (
resetCamera
-
Camera.
resetCamera
() Resets the camera to its initial state as it appeared upon creation of its containing view
Return type: void
setClipPlanesFromBoundingBox
-
Camera.
setClipPlanesFromBoundingBox
(boundingBox, minNearPlaneDistance) Arguments: - boundingBox (
BoundingBox
) – None - minNearPlaneDistance (
number
) – None
Sets the front and back clipping planes close to the given bounding box
Return type: void - boundingBox (
setFromLookAt
setProjectionAsOrtho
-
Camera.
setProjectionAsOrtho
(height, nearPlane, farPlane) Arguments: - height (
number
) – None - nearPlane (
number
) – None - farPlane (
number
) – None
Sets up an orthographic (parallel) projection.
The height parameter is the height of the frustum. A good default is the length of the extent of the current bounding box.
Return type: void - height (
setProjectionAsPerspective
-
Camera.
setProjectionAsPerspective
(fieldOfViewYDeg, nearPlane, farPlane) Arguments: - fieldOfViewYDeg (
number
) – None - nearPlane (
number
) – None - farPlane (
number
) – None
Sets up a perspective projection.
The fieldOfViewYDeg parameter is the total field of view angle (in degrees) in the Y direction. Works similar to gluPerspective().
Return type: void - fieldOfViewYDeg (
setViewChangeHandler
-
Camera.
setViewChangeHandler
(handler, waitForIdle) Arguments: - handler (
CameraViewChangeHandler
) – The handler to invoke on change - waitForIdle (
boolean
) – If true, the handler will only be invoked after any ongoing mouse operations or camera animations have completed. Note that setting this to false will result in a large number of handler invocations, while setting this to true and then starting a never-ending camera animation will result in no invocations.
Sets a handler to be invoked each time the camera view changes
Return type: void - handler (
setViewMatrix
setViewpoint
unproject
-
Camera.
unproject
(coord) Arguments: - coord (
Vec3Like
) – None
Maps window coordinates to world (3d) coordinates
Returns null if the specified coordinate cannot be unprojected.
The input (window) coordinates ‘coord’ must be specified in WebGL/OpenGL style coordinates, which means a right handed coordinate system with the origin in the lower left corner of the window.
OpenGL like unproject.
Use
Viewer.oglWinPosFromClientCoord
to convert client coordinates into WebGL style coordinatesReturn type: Vec3 - coord (
zoomToBoundingBox
-
Camera.
zoomToBoundingBox
(boundingBox) Arguments: - boundingBox (
BoundingBox
) – None
Zoom in/out so the given bounding box will fill the view.
This is done without changing the current camera position. It works for both for PERSPECTIVE and ORTHO projection types.
Note: Works best with ZOOM navigation. Combining zoom (changing FOV) and walk navigation can give distorted views.
Return type: void - boundingBox (