Methods
setCamera(camera)
Set or unset the current camera used for navigation. Normally set via the constructor.
Parameters
| camera* | the current camera object. |
getCamera()
Returns
| type | description |
|---|---|
| Camera |
|
setScreenViewport(viewport)
Set the current canvas viewport in screen coordinates. Invoked internally on canvas resize.
Parameters
| viewport* object | Rectangle with properties left, top, width, height. |
getScreenViewport()
Get the current canvas viewport in screen coordinates.
Returns
| type | description |
|---|---|
| object | with properties left, top, width, height. |
setView(from, to, up)
Sets the current view to the given LookAt, while keeping other camera properties as is. Jumps to the new location, without camera path animation.
Parameters
orientCameraUp(force)
Orient the camera’s up direction with the current world up direction
Parameters
| force* boolean | if true, will orient camera up direction regardless of navigation lock |
getPivotPoint()
Returns
| type | description |
|---|---|
| Vector3 | the world space position of the pivot point for orbit navigation. |
setPivotPoint(pivot)
Sets the Vector3 world space position of the pivot point for orbit navigation.
Parameters
| pivot* | the new pivot position. |
getPosition()
Returns
| type | description |
|---|---|
| Vector3 | the world space position of the camera. |
setPosition(pos)
Sets the Vector3 world space position of camera.
Parameters
| pos* | the new camera position. |
setTarget(target)
Sets the Vector3 world space position towards which the camera should be pointing.
Parameters
| target* | the new camera look at point. |
getTarget()
Returns
| type | description |
|---|---|
| Vector3 | the world space position towards which the camera is pointing. |
getEyeVector()
Get the current camera view vector. This vector is not normalized and its length is the distance between the camera position and the camera look at point.
Returns
| type | description |
|---|---|
| Vector3 | the current camera view vector in world space. |
getEyeToCenterOfBoundsVec(bounds)
Get a vector from the camera location to the center of the input bounding box.
Parameters
| bounds* | Bounding box. |
Returns
| type | description |
|---|---|
| Vector3 |
|
getFovMin()
Returns
| type | description |
|---|---|
| number | the minimum allowed vertical field of view in degrees. |
getFovMax()
Returns
| type | description |
|---|---|
| number | the maximum allowed vertical field of view in degrees. |
setZoomInLimitFactor(factor)
Limits zoom in to show 1/factor-th of the entire 2D page. Applies only on 2D vectorized models.
Parameters
| factor* number |
getZoomInLimitFactor()
Returns
| type | description |
|---|---|
| number | the current limit when zooming into 2D vectorized models. |
setZoomOutLimitFactor(factor)
Limits zoom out to a multiplier of the model’s bounding box dimensions. Applies only on 2D vectorized models.
Parameters
| factor* number |
getZoomOutLimitFactor()
Returns
| type | description |
|---|---|
| number | the current limit when zooming out 2D vectorized models. |
isPointVisible(point)
Returns true if the point is visible.
Parameters
| point* | The point in world coordinates. |
Returns
| type | description |
|---|---|
| boolean |
|
setVerticalFov(fov, adjustPosition)
Set the current vertical field of view.
Parameters
| fov* number | the new field of view in degrees (value is clamped to the minimum and maximum field of view values). |
| adjustPosition* boolean | If true, the camera position will be modified to keep either the world space area of the view at the pivot point unchanged (if it is set and visible) or the world space area of view at the camera look at point unchanged. |
applyRotation(point, angle, pivot, viewVec)
Applies a rotation on a single point
Parameters
getSignedAngle(v1, v2, viewVec)
Computes a signed angle between two vectors
Parameters
Returns
| type | description |
|---|---|
| number | Signed angle between two vectors |
computeFit(oldpos, oldcoi, fov, bounds, aspect)
Compute camera position and look at point which will fit the given bounding box in the view frustum at the given field of view angle.
Parameters
Returns
| type | description |
|---|---|
| object | Object with properties “position” and “target”. |
computeOrthogonalUp(pos, coi)
Compute a vector which is orthogonal to the given view and aligned with the world up direction.
Parameters
Returns
| type | description |
|---|---|
| Vector3 | up direction orthogonal to the given view |
fitBounds(immediate, bounds, reorient, force)
Causes the current camera position to be changed in order to fit the given bounds into the current view frustum.
Parameters
| immediate* boolean | if false the camera position will animate to the new location. |
| bounds* | bounding box to fit |
| reorient* boolean | if true the camera up direction will be reoriented with the world up. |
| force* boolean | if true will perform regardless of gotoview enabled or not. |
Returns
| type | description |
|---|---|
| object | Object with properties “position” and “target”. |
updateCamera()
Update the current camera projection matrix and orient the camera to the current look at point. Invoked internally prior to rendering a new frame with the current camera.
setConstraints2D(viewRegion, maxPixelPerUnit)
Applies zooming and panning restrictions when viewing 2D models. Invoke without parameters to clear any previous setting.
Parameters
| viewRegion | in world space. If specified, navigation is restricted so that this region always spans >= half of the screen extent in x and y. |
| maxPixelPerUnit number | Restrict zoom-In, so that a single unit in world-space never exceeds maxPixelPerUnit on screen. |