Skip to content

Camera ​

Introduction ​

vtkCamera is a virtual camera for 3D rendering. It provides methods to position and orient the view point and focal point. Convenience methods for moving about the focal point also are provided. More complex methods allow the manipulation of the computer graphics model including view up vector, clipping planes, and camera perspective.

Methods ​

applyTransform ​

Apply a transform to the camera. The camera position, focal-point, and view-up are re-calculated using the transform's matrix to multiply the old points by the new transform.

ArgumentTypeRequiredDescription
transformMat4mat4YesTransform matrix.

azimuth ​

Rotate the camera about the view up vector centered at the focal point.

ArgumentTypeRequiredDescription
angleNumberYesThe angle value.

computeCameraLightTransform ​

computeClippingRange ​

ArgumentTypeRequiredDescription
boundsBoundsYesThe bounds value.

computeDistance ​

This method must be called when the focal point or camera position changes

computeViewParametersFromPhysicalMatrix ​

the provided matrix should include translation and orientation only mat is physical to view

ArgumentTypeRequiredDescription
matmat4YesThe physical matrix.

computeViewParametersFromViewMatrix ​

ArgumentTypeRequiredDescription
vmatmat4YesThe view matrix.

deepCopy ​

Not implemented yet

ArgumentTypeRequiredDescription
sourceCameravtkCameraYesThe camera source.

dolly ​

Move the position of the camera along the view plane normal. Moving towards the focal point (e.g., > 1) is a dolly-in, moving away from the focal point (e.g., < 1) is a dolly-out.

ArgumentTypeRequiredDescription
amountNumberYesThe amount value.

elevation ​

Rotate the camera about the cross product of the negative of the direction of projection and the view up vector, using the focal point as the center of rotation.

ArgumentTypeRequiredDescription
angleNumberYesThe angle value.

extend ​

Method use to decorate a given object (publicAPI+model) with vtkRenderer characteristics.

ArgumentTypeRequiredDescription
publicAPIYesobject on which methods will be bounds (public)
modelYesobject on which data structure will be bounds (protected)
initialValuesICameraInitialValuesNo(default: {})

getCameraLightTransformMatrix ​

Not implemented yet

getClippingRange ​

Get the location of the near and far clipping planes along the direction of projection.

getClippingRangeByReference ​

Get the location of the near and far clipping planes along the direction of projection.

getCompositeProjectionMatrix ​

ArgumentTypeRequiredDescription
aspectNumberYesCamera frustum aspect ratio.
nearzNumberYesCamera frustum near plane.
farzNumberYesCamera frustum far plane.

getDirectionOfProjection ​

Get the vector in the direction from the camera position to the focal point.

getDirectionOfProjectionByReference ​

Get the vector in the direction from the camera position to the focal point.

getDistance ​

Get the distance from the camera position to the focal point.

getExplicitProjectionMatrix ​

Get the explicit projection matrix, or null when the camera computes its projection from its standard parameters.

getFocalPoint ​

Get the focal of the camera in world coordinates.

getFocalPointByReference ​

Get the focal of the camera in world coordinates.

getFreezeFocalPoint ​

Get the value of the FreezeDolly instance variable.

getFrustumPlanes ​

Get the plane equations that bound the view frustum.

ArgumentTypeRequiredDescription
aspectNumberNoCamera frustum aspect ratio (default: 1.0).
planesFloat64ArrayNoOptional array to fill with the plane equations.

getModelTransformMatrix ​

Get the model transform matrix for the camera. This matrix could be used for model related transformations such as scale, shear, rotations and translations.

Returns ​

TypeDescription
mat4mat The value of the model transform matrix.

getOrientation ​

Not implemented yet Get the orientation of the camera.

getOrientationWXYZ ​

Not implemented yet Get the orientation of the camera.

getParallelProjection ​

Get the value of the ParallelProjection instance variable. This determines if the camera should do a perspective or parallel projection.

getParallelScale ​

Get the scaling used for a parallel projection.

getPhysicalScale ​

getPhysicalToWorldMatrix ​

ArgumentTypeRequiredDescription
resultmat4YesThe world matrix.

getPhysicalTranslation ​

getPhysicalTranslationByReference ​

getPhysicalViewNorth ​

getPhysicalViewNorthByReference ​

getPhysicalViewUp ​

getPhysicalViewUpByReference ​

getPosition ​

Get the position of the camera in world coordinates.

getPositionByReference ​

Get the position of the camera in world coordinates.

getProjectionMatrix ​

Get the projection matrix.

ArgumentTypeRequiredDescription
aspectNumberYesCamera frustum aspect ratio.
nearzNumberYesCamera frustum near plane.
farzNumberYesCamera frustum far plane.
outmat4NoOptional output matrix to mutate and return, instead of allocating a new one.

getRoll ​

Not implemented yet Get the roll angle of the camera about the direction of projection.

getScreenBottomLeft ​

Get top left corner point of the screen.

getScreenBottomLeftByReference ​

getScreenBottomRight ​

Get bottom left corner point of the screen

getScreenBottomRightByReference ​

getScreenTopRight ​

getScreenTopRightByReference ​

getThickness ​

Get the center of the window in viewport coordinates.

getUseHorizontalViewAngle ​

Get the value of the UseHorizontalViewAngle.

getUseOffAxisProjection ​

Get use offaxis frustum.

getViewAngle ​

Get the camera view angle.

getViewMatrix ​

Get the view transform

getViewPlaneNormal ​

Get the ViewPlaneNormal. This vector will point opposite to the direction of projection, unless you have created a sheared output view using SetViewShear/SetObliqueAngles.

getViewPlaneNormalByReference ​

Get the ViewPlaneNormal by reference.

getViewUp ​

Get ViewUp vector.

getViewUpByReference ​

Get ViewUp vector by reference.

getWindowCenter ​

Get the center of the window in viewport coordinates. The viewport coordinate range is ([-1,+1],[-1,+1]).

getWindowCenterByReference ​

getWorldToPhysicalMatrix ​

ArgumentTypeRequiredDescription
resultmat4Yes

newInstance ​

Method use to create a new instance of vtkCamera with its focal point at the origin, and position=(0,0,1). The view up is along the y-axis, view angle is 30 degrees, and the clipping range is (.1,1000).

ArgumentTypeRequiredDescription
initialValuesICameraInitialValuesNofor pre-setting some of its content

orthogonalizeViewUp ​

Recompute the ViewUp vector to force it to be perpendicular to camera.focalpoint vector.

physicalOrientationToWorldDirection ​

ArgumentTypeRequiredDescription
oriArray[Number]Yes

pitch ​

Rotate the focal point about the cross product of the view up vector and the direction of projection, using the camera's position as the center of rotation.

ArgumentTypeRequiredDescription
angleNumberYesThe value of the angle.

roll ​

Rotate the camera about the direction of projection.

ArgumentTypeRequiredDescription
angleNumberYesThe value of the angle.

setClippingRange ​

Set the location of the near and far clipping planes along the direction of projection.

ArgumentTypeRequiredDescription
clippingRangeRangeYes

setClippingRange ​

Set the location of the near and far clipping planes along the direction of projection.

ArgumentTypeRequiredDescription
nearNumberYesThe near clipping planes.
farNumberYesThe far clipping planes.

setClippingRangeFrom ​

Set the location of the near and far clipping planes along the direction of projection.

ArgumentTypeRequiredDescription
clippingRangeRangeYes

setDeviceAngles ​

Used to handle convert js device orientation angles when you use this method the camera will adjust to the device orientation such that the physicalViewUp you set in world coordinates looks up, and the physicalViewNorth you set in world coorindates will (maybe) point north

NOTE WARNING - much of the documentation out there on how orientation works is seriously wrong. Even worse the Chrome device orientation simulator is completely wrong and should never be used. OMG it is so messed up.

how it seems to work on iOS is that the device orientation is specified in extrinsic angles with a alpha, beta, gamma convention with axes of Z, X, Y (the code below substitutes the physical coordinate system for these axes to get the right modified coordinate system.

ArgumentTypeRequiredDescription
alphaNumberYesThe value of the alpha.
betaNumberYesThe value of the beta.
gammaNumberYesThe value of the gamma.
screenNumberYesThe value of the screen.

setDirectionOfProjection ​

Set the direction of projection.

ArgumentTypeRequiredDescription
xNumberYesThe x coordinate.
yNumberYesThe y coordinate.
zNumberYesThe z coordinate.

setDistance ​

Move the focal point so that it is the specified distance from the camera position.

This distance must be positive.

ArgumentTypeRequiredDescription
distanceNumberYesThe value of the distance.

setExplicitProjectionMatrix ​

Set the explicit projection matrix, or null to use a projection computed from the camera's standard parameters.

setFocalPoint ​

Set the focal of the camera in world coordinates.

ArgumentTypeRequiredDescription
xNumberYesThe x coordinate.
yNumberYesThe y coordinate.
zNumberYesThe z coordinate.

setFocalPointFrom ​

Set the focal of the camera in world coordinates.

ArgumentTypeRequiredDescription
focalPointVector3Yes

setFreezeFocalPoint ​

Set the value of the FreezeDolly instance variable.

ArgumentTypeRequiredDescription
freezeFocalPointBooleanYes

setModelTransformMatrix ​

Set the model transform matrix for the camera. This matrix could be used for model related transformations such as scale, shear, rotations and translations. It is applied to world coordinates before the camera transform, so the resulting view matrix is view * modelTransform. A common use is a global vertical exaggeration, e.g. a scale of (1, 1, 10) on world Z.

The matrix is in gl-matrix column-major order, like userMatrix on vtkProp3D, so a matrix from vtkTransform or vtkMatrixBuilder can be passed directly.

Note the camera pose (position, focalPoint, viewUp, clippingRange) is interpreted after this transform is applied, so it is expressed in transformed space rather than world space.

ArgumentTypeRequiredDescription
matmat4YesThe value of the model transform matrix.

setObliqueAngles ​

Not implement yet Set the oblique viewing angles. The first angle, alpha, is the angle (measured from the horizontal) that rays along the direction of projection will follow once projected onto the 2D screen. The second angle, beta, is the angle between the view plane and the direction of projection. This creates a shear transform x' = x + dzcos(alpha)/tan(beta), y' = dzsin(alpha)/tan(beta) where dz is the distance of the point from the focal plane. The angles are (45,90) by default. Oblique projections commonly use (30,63.435).

ArgumentTypeRequiredDescription
alphaNumberYesThe aplha angle value.
betaNumberYesThe beta angle value.

setOrientationWXYZ ​

Set the value of the OrientationWXYZ.

ArgumentTypeRequiredDescription
degreesNumberYes
xNumberYesThe x coordinate.
yNumberYesThe y coordinate.
zNumberYesThe z coordinate.

setParallelProjection ​

Set the value of the ParallelProjection.

ArgumentTypeRequiredDescription
parallelProjectionBooleanYesThe value of the parallelProjection.

setParallelScale ​

Set the value of the parallelScale.

ArgumentTypeRequiredDescription
parallelScaleNumberYesThe value of the parallelScale.

setPhysicalScale ​

Set the value of the physicalScale.

ArgumentTypeRequiredDescription
physicalScaleNumberYesThe value of the the physicalScale.

setPhysicalTranslation ​

Set the value of the physicalTranslation.

ArgumentTypeRequiredDescription
xNumberYesThe x coordinate.
yNumberYesThe y coordinate.
zNumberYesThe z coordinate.

setPhysicalTranslationFrom ​

Set the value of the physicalTranslation.

ArgumentTypeRequiredDescription
physicalTranslationArray[Number]YesThe value of the physicalTranslation.

setPhysicalViewNorth ​

ArgumentTypeRequiredDescription
xNumberYesThe x coordinate.
yNumberYesThe y coordinate.
zNumberYesThe z coordinate.

setPhysicalViewNorthFrom ​

ArgumentTypeRequiredDescription
physicalViewNorthArray[Number]Yes

setPhysicalViewUp ​

ArgumentTypeRequiredDescription
xNumberYesThe x coordinate.
yNumberYesThe y coordinate.
zNumberYesThe z coordinate.

setPhysicalViewUpFrom ​

ArgumentTypeRequiredDescription
physicalViewUpArray[Number]Yes

setPosition ​

Set the position of the camera in world coordinates.

ArgumentTypeRequiredDescription
xNumberYesThe x coordinate.
yNumberYesThe y coordinate.
zNumberYesThe z coordinate.

setPositionAndFocalPoint ​

Set the camera's position and focal point in world coordinates.

ArgumentTypeRequiredDescription
positionArray[Number]YesThe position.
focalPointArray[Number]YesThe focal point.

setRoll ​

Set the roll angle of the camera about the direction of projection.

ArgumentTypeRequiredDescription
angleNumberYesThe value of the roll angle.

setScreenBottomLeft ​

Set top left corner point of the screen.

This will be used only for offaxis frustum calculation.

ArgumentTypeRequiredDescription
screenBottomLeftVector3YesThe screenBottomLeft coordiante.

setScreenBottomLeft ​

Set top left corner point of the screen.

This will be used only for offaxis frustum calculation.

ArgumentTypeRequiredDescription
xNumberYesThe x coordinate.
yNumberYesThe y coordinate.
zNumberYesThe z coordinate.

setScreenBottomLeftFrom ​

Set top left corner point of the screen.

ArgumentTypeRequiredDescription
screenBottomLeftVector3YesThe screenBottomLeft coordiante.

setScreenBottomRight ​

Set bottom right corner point of the screen.

ArgumentTypeRequiredDescription
screenBottomRightVector3YesThe screenBottomRight coordiante.

setScreenBottomRight ​

ArgumentTypeRequiredDescription
xNumberYesThe x coordinate.
yNumberYesThe y coordinate.
zNumberYesThe z coordinate.

setScreenBottomRightFrom ​

Set bottom right corner point of the screen.

ArgumentTypeRequiredDescription
screenBottomRightVector3YesThe screenBottomRight coordiante.

setScreenTopRight ​

Set top right corner point of the screen.

This will be used only for offaxis frustum calculation.

ArgumentTypeRequiredDescription
screenTopRightVector3YesThe screenTopRight coordiante.

setScreenTopRight ​

Set top right corner point of the screen.

This will be used only for offaxis frustum calculation.

ArgumentTypeRequiredDescription
xNumberYesThe x coordinate.
yNumberYesThe y coordinate.
zNumberYesThe z coordinate.

setScreenTopRightFrom ​

Set top right corner point of the screen.

ArgumentTypeRequiredDescription
screenTopRightVector3YesThe screenTopRight coordiante.

setThickness ​

Set the distance between clipping planes.

This method adjusts the far clipping plane to be set a distance 'thickness' beyond the near clipping plane.

ArgumentTypeRequiredDescription
thicknessNumberYes

setThicknessFromFocalPoint ​

ArgumentTypeRequiredDescription
thicknessNumberYesThe value of the thickness.

setUseHorizontalViewAngle ​

Set the value of the useHorizontalViewAngle.

ArgumentTypeRequiredDescription
useHorizontalViewAngleBooleanYesThe value of the useHorizontalViewAngle.

setUseOffAxisProjection ​

Set use offaxis frustum.

OffAxis frustum is used for off-axis frustum calculations specifically for stereo rendering. For reference see "High Resolution Virtual Reality", in Proc. SIGGRAPH '92, Computer Graphics, pages 195-202, 1992.

ArgumentTypeRequiredDescription
useOffAxisProjectionBooleanYesThe value of the useOffAxisProjection.

setViewAngle ​

Set the camera view angle, which is the angular height of the camera view measured in degrees.

ArgumentTypeRequiredDescription
viewAngleNumberYesThe value of the viewAngle.

setViewMatrix ​

Set the view matrix for the camera.

ArgumentTypeRequiredDescription
matmat4YesThe value of the view matrix.

setViewUp ​

Set the view up direction for the camera.

ArgumentTypeRequiredDescription
viewUpVector3YesThe viewUp coordinate.

setViewUp ​

Set the view up direction for the camera.

ArgumentTypeRequiredDescription
xNumberYesThe x coordinate.
yNumberYesThe y coordinate.
zNumberYesThe z coordinate.

setViewUpFrom ​

Set the view up direction for the camera.

ArgumentTypeRequiredDescription
viewUpVector3YesThe viewUp coordinate.

setWindowCenter ​

Set the center of the window in viewport coordinates.

The viewport coordinate range is ([-1,+1],[-1,+1]).

This method is for if you have one window which consists of several viewports, or if you have several screens which you want to act together as one large screen.

ArgumentTypeRequiredDescription
xNumberYesThe x coordinate.
yNumberYesThe y coordinate.

setWindowCenterFrom ​

Set the center of the window in viewport coordinates from an array.

ArgumentTypeRequiredDescription
windowCenterRangeYes

translate ​

ArgumentTypeRequiredDescription
xNumberYesThe x coordinate.
yNumberYesThe y coordinate.
zNumberYesThe z coordinate.

yaw ​

Rotate the focal point about the view up vector, using the camera's position as the center of rotation.

ArgumentTypeRequiredDescription
angleNumberYesThe value of the angle.

zoom ​

In perspective mode, decrease the view angle by the specified factor.

ArgumentTypeRequiredDescription
factorNumberYesThe value of the zoom factor.