Camera
The viewer camera. It can be switched between perspective and orthographic projection.
The active camera is obtained via Viewer3D#getCamera. Client implementations should not normally instantiate this class directly. To change the active camera, use the methods of Navigation, e.g. Navigation#setView or Navigation#setPivotPoint. Modifying the properties of the active camera directly is not guaranteed to take effect.
Properties
| position | (readonly) Camera position in world space. To change it for the active camera, use Navigation#setView. |
| target | (readonly) Point in world space the camera is looking at. To change it for the active camera, use Navigation#setView. |
| up | (readonly) Up vector of the camera in world space. To change it for the active camera, use Navigation#setView. |
| isPerspective boolean | (readonly) True if the camera uses a perspective projection, false for an orthographic projection. For orthographic projection, the height of the visible area equals the distance between position and target. |
| pivot Vector3, undefined | (readonly) Optional pivot point in world space, used by orbit-style navigation tools. |
| matrixWorld | (readonly) Camera-to-world transform. Updated by the viewer before rendering or by Camera#updateCameraMatrices. |
| matrixWorldInverse | (readonly) World-to-camera (view) transform. Updated by the viewer before rendering or by Camera#updateCameraMatrices. |
| projectionMatrix | (readonly) Projection matrix of the current projection. Updated by the viewer before rendering or by Camera#updateCameraMatrices. |
| fov number | (readonly) Vertical field of view in degrees. For orthographic projection, this is a fixed internal value. To change the field of view of the active camera, use Viewer3D#setFOV. |
| near number | (readonly) Distance of the near clipping plane. Automatically adjusted by the viewer to the visible scene. |
| far number | (readonly) Distance of the far clipping plane. Automatically adjusted by the viewer to the visible scene. |
| aspect number | (readonly) Aspect ratio of the viewport (width / height). |
Methods
clone(camera)
Creates a copy of this camera. Changes to the copy don’t affect the viewer.
Parameters
| camera | Optional camera to copy into. If not provided, a new camera is created. |
Returns
| type | description |
|---|---|
| Autodesk.Viewing.Camera | The copied camera. |
updateCameraMatrices()
Updates all camera matrices from the current camera properties. For the active camera, this happens automatically before rendering. When modifying a separate camera (e.g. a clone) and using its matrices for computations, call this function first to get correct results.
setView(viewParams)
Sets the view from the given view parameters and updates the camera matrices. Parameters that are not specified remain unchanged. Note that fov is ignored. To change the field of view of the active camera, use Viewer3D#setFOV. To change the view of the active camera, prefer Navigation#setView.
Parameters
| viewParams* | The view parameters to apply. |
pixelsPerUnitAtDistance(dist)
Computes the pixel-per-unit scale at a given distance from the camera, i.e. the projected screen-space length of a line of length 1.0 parallel to the view plane at that distance. For orthographic projection, the result is independent of the distance.
Parameters
| dist* number | Distance from the camera in world units. |
Returns
| type | description |
|---|---|
| number | Number of pixels per world unit. |