Methods
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
oldpos* THREE.Vector3 | existing camera position |
oldcoi* THREE.Vector3 | existing camera look at point |
fov* number | field of view (in degrees) to use for fit calculation in degrees |
bounds* THREE.Box3 | bounding box to fit |
aspect* number | optional aspect ratio of window, horizontal/vertical |
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
pos* THREE.Vector3 | view position |
coi* THREE.Vector3 | center of interest (view look at point) |
Returns
Type | Description |
---|---|
THREE.Vector3 | up direction orthogonal to the given view |
dollyFromPoint(distance,point)
Dolly the camera a distance along the vector from a given point to its current position. The dolly distance is clamped to not go past the point.
Parameters
distance* number | World space distance to move the camera by. |
point* THREE.Vector3 | World space position used to define the dolly direction. |
fitBounds(immediate,bounds,reorient)
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* THREE.Box3 | bounding box to fit |
reorient* boolean | if true the camera up direction will be reoriented with the world up. |
Returns
Type | Description |
---|---|
Object | Object with properties “position” and “target”. |
fl2fov(fl)
Convert a 35mm camera focal length value to a vertical field of view angle in degrees.
Parameters
fl* number | focal length in millimeters |
Returns
Type | Description |
---|---|
number | vertical field of view in degrees |
fov2fl(fov)
Convert a vertical field of view angle in degrees to a 35mm camera focal length value.
Parameters
fov* number | vertical field of view in degrees |
Returns
Type | Description |
---|---|
number | focal length in millimeters |
getAlignedUpVector()
Get the world space vector which is the orthogonal to the view direction and aligned with the world up direction.
Returns
Type | Description |
---|---|
THREE.Vector3 | the current camera up direction (normalized) |
getCamera()
Returns
Type | Description |
---|---|
THREE.Camera |
|
getCameraRightVector(worldAligned)
Get the world space vector which is the right side direction of the current camera.
Parameters
worldAligned* boolean | if true get the right vector aligned with the world up, otherwise use the current camera’s up direction. |
Returns
Type | Description |
---|---|
THREE.Vector3 | the current camera right direction, orthogonal to view and up (normalized) |
getCameraUpVector()
Get the world space vector which is the current cameras up direction.
Returns
Type | Description |
---|---|
THREE.Vector3 | the current camera up direction (normalized) |
getEyeToCenterOfBoundsVec(bounds)
Get a vector from the camera location to the center of the input bounding box.
Parameters
bounds* THREE.Box3 | Bounding box. |
Returns
Type | Description |
---|---|
THREE.Vector3 |
|
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 |
---|---|
THREE.Vector3 | the current camera view vector in world space. |
getFocalLength()
Returns
Type | Description |
---|---|
number | the current camera focal length based on a 35mm camera lens model |
getFovMax()
Returns
Type | Description |
---|---|
number | the maximum allowed vertical field of view in degrees. |
getFovMin()
Returns
Type | Description |
---|---|
number | the minimum allowed vertical field of view in degrees. |
getHorizontalFov()
Returns
Type | Description |
---|---|
number | the current camera horizontal field of view in degrees |
getIsLocked()
Get the state of the current view modification lock. For a more granular control of locked operations, see setLockSettings.
Returns
Type | Description |
---|---|
boolean |
|
getLockSettings()
Get the availability of specific camera actions when navigation is locked using setIsLocked.
Returns
Type | Description |
---|---|
object | Map of : pairs specifying whether the given camera action is enabled even when the navigation is locked. |
getOrbitPastWorldPoles()
Get the state of the view navigation option that allows orbit controls to continue past the world up/down direction.
Not applicable to 2D.
Returns
Type | Description |
---|---|
boolean |
|
getPivotPlaneDistance()
Returns
Type | Description |
---|---|
number |
|
getPivotPoint()
Returns
Type | Description |
---|---|
THREE.Vector3 | the world space position of the pivot point for orbit navigation. |
getPivotSetFlag()
Get the state of the view navigation option that indicates the pivot is set.
Returns
Type | Description |
---|---|
boolean |
|
getPosition()
Returns
Type | Description |
---|---|
THREE.Vector3 | the world space position of the camera. |
getRequestFitToView()
Get the state of the view navigation option requesting a camera repositioning to fit the active model data. Value will be false if a request has not been made or if having been made has been received and acted upon.
Returns
Type | Description |
---|---|
boolean |
|
getRequestHomeView()
Get the state of the view navigation option requesting a camera change to the current “home” view. Value will be false if a request has not been made or if having been made has been received and acted upon.
Returns
Type | Description |
---|---|
boolean |
|
getRequestTransition()
Get the state of the view navigation option requesting a camera transition to a new view.
Returns
Type | Description |
---|---|
Object |
|
See
- setRequestTransitionWithUp
getReverseHorizontalLookDirection()
Get the state of the view navigation option which requests the reversal of the default horizontal look direction
Not applicable to 2D.
Returns
Type | Description |
---|---|
boolean | value of the option, true for reverse, false for default |
getReverseVerticalLookDirection()
Get the state of the view navigation option which requests the reversal of the default vertical look direction
Not applicable to 2D.
Returns
Type | Description |
---|---|
boolean | value of the option, true for reverse, false for default |
getReverseZoomDirection()
Get the state of the view navigation option which requests the reversal of the default direction for camera dolly (zoom) operations.
Returns
Type | Description |
---|---|
boolean |
|
getScreenViewport()
Get the current canvas viewport in screen coordinates.
Returns
Type | Description |
---|---|
Object | with properties left, top, width, height. |
getTarget()
Returns
Type | Description |
---|---|
THREE.Vector3 | the world space position towards which the camera is pointing. |
getTransitionActive()
Check the status of a view transition request.
Returns
Type | Description |
---|---|
boolean |
|
getUseLeftHandedInput()
Get the state of the view navigation option that requests mouse button reversal.
Returns
Type | Description |
---|---|
boolean |
|
getUsePivotAlways()
Get the state of the view navigation option that requests full use of the pivot point.
Returns
Type | Description |
---|---|
boolean |
|
getVerticalFov()
Returns
Type | Description |
---|---|
number | the current camera vertical field of view in degrees |
getWorldPoint(x,y)
Get a world point from normalized screen coordinates by projecting to the plane at the pivot point.
Parameters
x* number | Normalized screen X coordinate in [0, 1] range (left == 0) |
y* number | Normalized screen Y coordinate in [0, 1] range (top == 0) |
Returns
Type | Description |
---|---|
THREE.Vector3 |
|
getWorldRightVector()
Compute a world right direction based on the current world up direction. This will return the normalized cross product of the current up direction with one of the major axes to provide a usable world right direction.
Returns
Type | Description |
---|---|
THREE.Vector3 | the computed world right direction |
getWorldSize(atDistance)
Parameters
atDistance* number | Distance from the camera at which to compute the view frustum size. |
Returns
Type | Description |
---|---|
THREE.Vector2 | The size of the view frustum at this distance from the camera. |
getWorldUpVector()
Get the current world up direction.
Returns
Type | Description |
---|---|
THREE.Vector3 | the current world up direction (normalized) |
getZoomTowardsPivot()
Get the state of the view navigation option that requests the default direction for camera dolly (zoom) operations to be towards the camera pivot point.
Returns
Type | Description |
---|---|
boolean |
|
isActionEnabled(action)
Check the availability of a camera action.
Parameters
action* string | Camera action. |
Returns
Type | Description |
---|---|
boolean | True if the camera action is currently enabled. |
isPointVisible(point)
Returns true if the point is visible.
Parameters
point* THREE.Vector3 | The point in world coordinates. |
Returns
Type | Description |
---|---|
boolean |
|
orientCameraUp()
Orient the camera’s up direction with the current world up direction
panRelative(deltaX,deltaY,atDistance)
Pan the camera a relative distance up/down or left/right.
Parameters
deltaX* number | Normalized X distance to pan left/right (negative/positive). |
deltaY* number | Normalized Y distance to pan down/up (negative/positive). |
atDistance* number | Pan distance is scaled by the size of the view frustum at this distance from the camera. |
setCamera(camera)
Set or unset the current camera used for navigation. Normally set via the constructor. The camera should be of type Autodesk.Viewing.UnifiedCamera.
Parameters
camera* Autodesk.Viewing.UnifiedCamera | the current camera object. |
setCameraUpVector(up)
Set the up direction for the camera. The given vector should be orthogonal to the current view direction.
Parameters
up* THREE.Vector3 | the new up direction vector |
setConstraints2D(viewRegion,maxPixelPerUnit)
Applies zooming and panning restrictions when viewing 2D models. Invoke without parameters to clear any previous setting.
Parameters
viewRegion THREE.Box3 | 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. |
setFocalLength(millimeters,adjustPosition)
Set the current cameras field of view using a 35mm camera focal length value
Parameters
millimeters* number | focal length in millimeters |
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. |
setIsLocked(state)
Lock or unlock view modification operations. For a more granular control of locked operations, see setLockSettings.
Parameters
state* boolean | when true changes to the current camera parameters are not allowed. |
setLockSettings(settings)
Set the availability of specific camera actions when navigation is locked using setIsLocked.
Parameters
settings* object | Map of : pairs specifying whether the given camera action is enabled even when the navigation is locked. The configurable actions are ‘orbit’, ‘pan’, ‘zoom’, ‘roll’, ‘fov’, or ‘gotoview’. By default, none of the camera actions are available when the navigation is locked. |
setOrbitPastWorldPoles(state)
Set or unset a view navigation option to allow the orbit controls to move the camera beyond the north and south poles (world up/down direction). In other words, when set the orbit control will allow the camera to rotate into an upside down orientation. When unset orbit navigation should stop when the camera view direction reaches the up/down direction.
Not applicable to 2D.
Parameters
state* boolean | value of the option, true to allow orbiting past the poles. |
setPivotPoint(pivot)
Sets the Vector3 world space position of the pivot point for orbit navigation.
Parameters
pivot* THREE.Vector3 | the new pivot position. |
setPivotSetFlag(state)
Set or unset a view navigation option which indicates that the pivot camera parameter is set and can be used for orbit and zoom controls.
Parameters
state* boolean | value of the option. When not set orbit and zoom operations should occur at the look at position in the center of the current view. |
setPosition(pos)
Sets the Vector3 world space position of camera.
Parameters
pos* THREE.Vector3 | the new camera position. |
setRequestFitToView(state)
Issue a request to change the current cameras view position to fit the active model data into the current view frustum.
Parameters
state* boolean | value of the requst. Set to true in order to request the change of view. |
setRequestHomeView(state)
Issue a request to change the current cameras view to the current “home” view. The home view includes position, view direction, world up direction and field of view.
Parameters
state* boolean | value of the requst. Set to true in order to request the change of view. |
setRequestTransition(state,pos,coi,fov,reorient,pivot)
Issue a request to transition the current cameras view to that specified by the parameters.
Parameters
state* boolean | value of the requst. Set to true in order to request the change of view. |
pos* THREE.Vector3 | the new camera position in world space |
coi* THREE.Vector3 | the point in world space that the camera should look towards. |
fov* number | vertical field of view in degrees |
reorient* boolean | set to true to recalculate up vector |
pivot* THREE.Vector3 | the new pivot point |
setRequestTransitionWithUp(state,pos,coi,fov,up,worldUp,pivot)
Issue a request to transition the current cameras view to that specified by the parameters which inlude both the camera up direction and optionally the world up direction.
Parameters
state* boolean | value of the requst. Set to true in order to request the change of view. |
pos* THREE.Vector3 | the new camera position in world space |
coi* THREE.Vector3 | the point in world space that the camera should look towards. |
fov* number | vertical field of view in degrees |
up* THREE.Vector3 | use this as the target camera up direction |
worldUp* THREE.Vector3 | (optional) use this as the target world up direction |
pivot* THREE.Vector3 | the new pivot point |
setReverseHorizontalLookDirection(state)
Set or unset a view navigation option to reverse the default direction for horizontal look operations.
Not applicable to 2D.
Parameters
state* boolean | value of the option, true for reverse, false for default |
setReverseVerticalLookDirection(state)
Set or unset a view navigation option to reverse the default direction for vertical look operations.
Not applicable to 2D.
Parameters
state* boolean | value of the option, true for reverse, false for default |
setReverseZoomDirection(state)
Set or unset a view navigation option to reverse the default direction for camera dolly (zoom) operations.
Parameters
state* boolean | value of the option, true for reverse, false for default |
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. |
setTarget(target)
Sets the Vector3 world space position towards which the camera should be pointing.
Parameters
target* THREE.Vector3 | the new camera look at point. |
setTransitionActive(state)
Set a status indicating that the current camera view is in a transitioning state. Used internally to indicate that a transition is active.
Parameters
state* boolean | value of the transtion status |
setUseLeftHandedInput(state)
Set or unset a view navigation option which requests that mouse buttons be reversed from their default assignment. i.e. Left mouse operation becomes right mouse and vice versa.
Parameters
state* boolean | value of the option, true to request reversal of mouse button assignments. |
setUsePivotAlways(state)
Set or unset a view navigation option which requests that orbit controls always orbit around the currently set pivot point.
Parameters
state* boolean | value of the option, true to request use of the pivot point. When false some controls may pivot around the center of the view. (Currently applies only to the view-cube orbit controls.) |
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. |
setView(position,target)
Sets the cameras position and view direction.
Parameters
position* THREE.Vector3 | the new position for the camera in world space. |
target* THREE.Vector3 | the point in world space that the camera should look towards. |
setWorldUpVector(up,reorient)
Change the current world up direction.
Parameters
up* THREE.Vector3 | the new world up direction |
reorient* boolean | if true, make sure the camera up is oriented towards the world up direction. |
setZoomTowardsPivot(state)
Set or unset a view navigation option to request the default direction for camera dolly (zoom) operations to be towards the camera pivot point. If unset the default direction would normally be towards the cursor position.
Parameters
state* boolean | value of the option, true for towards the pivot, false for default |
snapToAxis(v)
Helper method that snaps a Vector3 to one of the 3 main orthogonal axis.
Parameters
v* THREE.Vector3 | vector to snap, it gets modified. |
toOrthographic()
Change current camera to orthographic camera
toPerspective()
Change current camera to perspective camera.
Not applicable to 2D.
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.