Options
All
  • Public
  • Public/Protected
  • All
Menu

Class 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.

Hierarchy

  • Camera

Index

Accessors

Readonly farPlane

farPlane: number

Returns the far clipping plane

Readonly fieldOfViewYDeg

fieldOfViewYDeg: number

Returns the total field of view in the Y direction in degrees.

Returns undefined if parallel (orthographic) projection

Readonly frontPlaneFrustumHeight

frontPlaneFrustumHeight: number

Get height of the view frustum in the front plane in world coordinates.

Readonly nearPlane

nearPlane: number

Returns the near clipping plane

Readonly projectionType

projectionType: ProjectionType

Returns the current projection type (perspective/ortho)

Readonly viewMatrix

viewMatrix: Mat4

Returns the current view matrix

Methods

disableAutoClip

  • disableAutoClip(): void
  • Disables the auto clipping feature

    Returns void

enableAutoClipFixedNearDistance

  • enableAutoClipFixedNearDistance(fixedNearDistance: number): void
  • Enables the auto clipping feature and sets a fixed near distance

    Parameters

    • fixedNearDistance: number

    Returns void

enableAutoClipMinimumNearDistance

  • enableAutoClipMinimumNearDistance(minNearDistance: number): void
  • Enables the auto clipping feature and sets a minimum near distance

    Parameters

    • minNearDistance: number

    Returns void

fitView

  • 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.

    Parameters

    Returns void

fitViewOrtho

  • 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.

    Parameters

    Returns void

getDirection

  • getDirection(): Vec3
  • Returns camera's forward direction vector. The returned vector is normalized.

    Returns Vec3

getPosition

  • getPosition(): Vec3
  • Returns the camera's position (eye point)

    Returns Vec3

getUp

  • Returns the camera's up vector. The returned vector is normalized.

    Returns Vec3

project

  • Maps world (3d) coordinates to window coordinates

    The returned window coordinates \a 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.

    Parameters

    Returns Vec3 | undefined

setClipPlanesFromBoundingBox

  • setClipPlanesFromBoundingBox(boundingBox: BoundingBox, minNearPlaneDistance: number): void
  • Sets the front and back clipping planes close to the given bounding box

    Parameters

    • boundingBox: BoundingBox
    • minNearPlaneDistance: number

    Returns void

setFromLookAt

  • Sets the view matrix from the standard OpenGL 'lookat' (eye, center, vup) specification.

    View direction will be (center - eye). Center is not stored in this class.

    Parameters

    Returns void

setProjectionAsOrtho

  • setProjectionAsOrtho(height: number, nearPlane: number, farPlane: number): void
  • Sets up a 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.

    Parameters

    • height: number
    • nearPlane: number
    • farPlane: number

    Returns void

setProjectionAsPerspective

  • setProjectionAsPerspective(fieldOfViewYDeg: number, nearPlane: number, farPlane: number): void
  • 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().

    Parameters

    • fieldOfViewYDeg: number
    • nearPlane: number
    • farPlane: number

    Returns void

setViewMatrix

  • setViewMatrix(viewMatrix: Mat4): void
  • Sets the view matrix of the camera.

    Parameters

    Returns void

setViewpoint

  • Sets the viewpoint from the eye point position, direction and up vectors.

    Parameters

    Returns void

unproject

  • Maps window coordinates to world (3d) coordinates

    The input (window) coordinates \a 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

    Parameters

    Returns Vec3

zoomToBoundingBox

  • 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.

    Parameters

    Returns void

Generated using TypeDoc