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.cameraproperty.Index
Accessors
Methods
applyCameraConfigcomputeFitViewEyePositiondisableAutoClipenableAutoClipFixedNearDistanceenableAutoClipMinimumNearDistancefitViewfitViewOrthogetDirectiongetPositiongetUpprojectresetCamerasetClipPlanesFromBoundingBoxsetFromLookAtsetProjectionAsOrthosetProjectionAsPerspectivesetViewChangeHandlersetViewMatrixsetViewpointunprojectzoomToBoundingBox
Accessors
-
cee.Camera.farPlane() - get farPlane(): number
Returns the far clipping plane
Returns: number
-
cee.Camera.fieldOfViewYDeg() - get fieldOfViewYDeg(): number
Returns the total field of view in the Y direction in degrees.
Returns undefined if parallel (orthographic) projection
Returns: number
-
cee.Camera.frontPlaneFrustumHeight() - get frontPlaneFrustumHeight(): number
Get height of the view frustum in the front plane in world coordinates.
Returns: number
-
cee.Camera.nearPlane() - get nearPlane(): number
Returns the near clipping plane
Returns: number
-
cee.Camera.projectionType() - get projectionType():
ProjectionTypeReturns the current projection type (perspective/ortho)
Returns:
ProjectionType
-
cee.Camera.viewport() - get viewport(): { height: number, width: number, x: number, y: number }
Returns the viewport of the camera
Returns: { height: number, width: number, x: number, y: number }
Methods
-
cee.Camera.applyCameraConfig() - applyCameraConfig(config:
CameraConfig, allowChangeOfProjectionType: boolean): voidHelper that applies a camera config to the camera
Parameters
config:
CameraConfigallowChangeOfProjectionType: boolean
Returns: void
-
cee.Camera.computeFitViewEyePosition() - computeFitViewEyePosition(boundingBox:
BoundingBox, dir:Vec3, up:Vec3, coverageFactor: number?):Vec3Calculate 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.
Parameters
Returns:
Vec3
-
cee.Camera.disableAutoClip() - disableAutoClip(): void
Disables the auto clipping feature
Returns: void
-
cee.Camera.enableAutoClipFixedNearDistance() - enableAutoClipFixedNearDistance(fixedNearDistance: number): void
Enables the auto clipping feature and sets a fixed near distance
Parameters
fixedNearDistance: numberReturns: void
-
cee.Camera.enableAutoClipMinimumNearDistance() - enableAutoClipMinimumNearDistance(minNearDistance: number): void
Enables the auto clipping feature and sets a minimum near distance
Parameters
minNearDistance: numberReturns: void
-
cee.Camera.fitView() 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.
Parameters
Returns: void
-
cee.Camera.fitViewOrtho() - fitViewOrtho(boundingBox:
BoundingBox, eyeDist: number, dir:Vec3Like, up:Vec3Like, coverageFactor: number?): voidSets 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.
Parameters
Returns: void
-
cee.Camera.getDirection() - getDirection():
Vec3Returns camera’s forward direction vector. The returned vector is normalized.
Returns:
Vec3
-
cee.Camera.getPosition() - getPosition():
Vec3Returns the camera’s position (eye point)
Returns:
Vec3
-
cee.Camera.getUp() - getUp():
Vec3Returns the camera’s up vector. The returned vector is normalized.
Returns:
Vec3
-
cee.Camera.project() -
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.
Parameters
point:Vec3LikeReturns:
Vec3
-
cee.Camera.resetCamera() - resetCamera(): void
Resets the camera to its initial state as it appeared upon creation of its containing view
Returns: void
-
cee.Camera.setClipPlanesFromBoundingBox() - setClipPlanesFromBoundingBox(boundingBox:
BoundingBox, minNearPlaneDistance: number): voidSets the front and back clipping planes close to the given bounding box
Parameters
boundingBox:
BoundingBoxminNearPlaneDistance: number
Returns: void
-
cee.Camera.setFromLookAt() -
Sets the view matrix from the standard OpenGL ‘lookat’ (eye, center, vup) specification.
View direction will be (center - eye). Center is not stored in this class.
Parameters
Returns: void
-
cee.Camera.setProjectionAsOrtho() - setProjectionAsOrtho(height: number, nearPlane: number, farPlane: number): void
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.
Parameters
height: number
nearPlane: number
farPlane: number
Returns: void
-
cee.Camera.setProjectionAsPerspective() - setProjectionAsPerspective(fieldOfViewYDeg: number, nearPlane: number, farPlane: number): void
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().
Parameters
fieldOfViewYDeg: number
nearPlane: number
farPlane: number
Returns: void
-
cee.Camera.setViewChangeHandler() - setViewChangeHandler(handler:
CameraViewChangeHandler, waitForIdle: boolean): voidSets a handler to be invoked each time the camera view changes
Parameters
handler:
CameraViewChangeHandlerThe handler to invoke on changewaitForIdle: 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.Returns: void
-
cee.Camera.setViewMatrix() - setViewMatrix(viewMatrix:
Mat4): voidSets the view matrix of the camera.
Parameters
viewMatrix:Mat4Returns: void
-
cee.Camera.setViewpoint() -
Sets the viewpoint from the eye point position, direction and up vectors.
Parameters
Returns: void
-
cee.Camera.unproject() -
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.oglWinPosFromClientCoordto convert client coordinates into WebGL style coordinatesParameters
coord:Vec3LikeReturns:
Vec3
-
cee.Camera.zoomToBoundingBox() - zoomToBoundingBox(boundingBox:
BoundingBox): voidZoom 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.
Parameters
boundingBox:BoundingBoxReturns: void