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
farPlane
fieldOfViewYDeg
frontPlaneFrustumHeight
nearPlane
projectionType
viewMatrix
Methods
Accessors
- cee.farPlane()
Returns the far clipping plane
- Return type:
number
- cee.fieldOfViewYDeg()
Returns the total field of view in the Y direction in degrees.
Returns undefined if parallel (orthographic) projection
- Return type:
number
- cee.frontPlaneFrustumHeight()
Get height of the view frustum in the front plane in world coordinates.
- Return type:
number
- cee.nearPlane()
Returns the near clipping plane
- Return type:
number
- cee.projectionType()
Returns the current projection type (perspective/ortho)
- Return type:
ProjectionType
- cee.viewMatrix()
Returns the current view matrix
- Return type:
Mat4
Methods
applyCameraConfig
- Camera.applyCameraConfig(config, allowChangeOfProjectionType)
- Arguments:
config (
CameraConfig
) – NoneallowChangeOfProjectionType (
boolean
) – None
Helper that applies a camera config to the camera
- Return type:
void
computeFitViewEyePosition
- Camera.computeFitViewEyePosition(boundingBox, dir, up, coverageFactor)
- Arguments:
boundingBox (
BoundingBox
) – Nonedir (
Vec3
) – Noneup (
Vec3
) – NonecoverageFactor (
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
disableAutoClip
- Camera.disableAutoClip()
Disables the auto clipping feature
- Return type:
void
enableAutoClipFixedNearDistance
- Camera.enableAutoClipFixedNearDistance(fixedNearDistance)
- Arguments:
fixedNearDistance (
number
) – None
Enables the auto clipping feature and sets a fixed near distance
- Return type:
void
enableAutoClipMinimumNearDistance
- Camera.enableAutoClipMinimumNearDistance(minNearDistance)
- Arguments:
minNearDistance (
number
) – None
Enables the auto clipping feature and sets a minimum near distance
- Return type:
void
fitView
- Camera.fitView(boundingBox, dir, up, coverageFactor)
- Arguments:
boundingBox (
BoundingBox
) – Nonedir (
Vec3Like
) – Noneup (
Vec3Like
) – NonecoverageFactor (
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
fitViewOrtho
- Camera.fitViewOrtho(boundingBox, eyeDist, dir, up, coverageFactor)
- Arguments:
boundingBox (
BoundingBox
) – NoneeyeDist (
number
) – Nonedir (
Vec3Like
) – Noneup (
Vec3Like
) – NonecoverageFactor (
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
getDirection
- Camera.getDirection()
Returns camera’s forward direction vector. The returned vector is normalized.
- Return type:
Vec3
getPosition
- Camera.getPosition()
Returns the camera’s position (eye point)
- 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
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
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
) – NoneminNearPlaneDistance (
number
) – None
Sets the front and back clipping planes close to the given bounding box
- Return type:
void
setFromLookAt
setProjectionAsOrtho
- Camera.setProjectionAsOrtho(height, nearPlane, farPlane)
- Arguments:
height (
number
) – NonenearPlane (
number
) – NonefarPlane (
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
setProjectionAsPerspective
- Camera.setProjectionAsPerspective(fieldOfViewYDeg, nearPlane, farPlane)
- Arguments:
fieldOfViewYDeg (
number
) – NonenearPlane (
number
) – NonefarPlane (
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
setViewChangeHandler
- Camera.setViewChangeHandler(handler, waitForIdle)
- Arguments:
handler (
CameraViewChangeHandler
) – The 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.
Sets a handler to be invoked each time the camera view changes
- Return type:
void
setViewMatrix
setViewpoint
unproject
- Camera.unproject(coord)
- Arguments:
coord (
Vec3Like
) – None
Maps window coordinates to world (3d) coordinates
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 coordinates- Return type:
Vec3
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