
######
Camera
######

.. js:class:: cee.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 :js:meth:`setFromLookAt <cee.Camera.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 :js:func:`View.camera <cee.View.camera>` property.
   
   
   Index
   =====
   
   .. rubric:: Accessors
   
   
   .. rst-class:: api-xref-list
   
   
   * :js:func:`~cee.Camera.farPlane`
   * :js:func:`~cee.Camera.fieldOfViewYDeg`
   * :js:func:`~cee.Camera.frontPlaneFrustumHeight`
   * :js:func:`~cee.Camera.nearPlane`
   * :js:func:`~cee.Camera.projectionType`
   * :js:func:`~cee.Camera.viewMatrix`
   * :js:func:`~cee.Camera.viewport`
   
   .. rubric:: Methods
   
   
   .. rst-class:: api-xref-list
   
   
   * :js:meth:`~cee.Camera.applyCameraConfig`
   * :js:meth:`~cee.Camera.computeFitViewEyePosition`
   * :js:meth:`~cee.Camera.disableAutoClip`
   * :js:meth:`~cee.Camera.enableAutoClipFixedNearDistance`
   * :js:meth:`~cee.Camera.enableAutoClipMinimumNearDistance`
   * :js:meth:`~cee.Camera.fitView`
   * :js:meth:`~cee.Camera.fitViewOrtho`
   * :js:meth:`~cee.Camera.getDirection`
   * :js:meth:`~cee.Camera.getPosition`
   * :js:meth:`~cee.Camera.getUp`
   * :js:meth:`~cee.Camera.project`
   * :js:meth:`~cee.Camera.resetCamera`
   * :js:meth:`~cee.Camera.setClipPlanesFromBoundingBox`
   * :js:meth:`~cee.Camera.setFromLookAt`
   * :js:meth:`~cee.Camera.setProjectionAsOrtho`
   * :js:meth:`~cee.Camera.setProjectionAsPerspective`
   * :js:meth:`~cee.Camera.setViewChangeHandler`
   * :js:meth:`~cee.Camera.setViewMatrix`
   * :js:meth:`~cee.Camera.setViewpoint`
   * :js:meth:`~cee.Camera.unproject`
   * :js:meth:`~cee.Camera.zoomToBoundingBox`
   
   



.. rst-class:: kind-group kind-accessors

.. rubric:: Accessors
   :class: kind-group-title


.. js:method:: cee.Camera.farPlane

      .. rst-class:: sig-pretty-signature
      
         | *get* farPlane(): *number*
      
      Returns the far clipping plane
      
      **Returns**\ : *number*
      



.. js:method:: cee.Camera.fieldOfViewYDeg

      .. rst-class:: sig-pretty-signature
      
         | *get* fieldOfViewYDeg(): *number*
      
      Returns the total field of view in the Y direction in degrees.
      
      Returns undefined if parallel (orthographic) projection
      
      **Returns**\ : *number*
      



.. js:method:: cee.Camera.frontPlaneFrustumHeight

      .. rst-class:: sig-pretty-signature
      
         | *get* frontPlaneFrustumHeight(): *number*
      
      Get height of the view frustum in the front plane in world coordinates.
      
      **Returns**\ : *number*
      



.. js:method:: cee.Camera.nearPlane

      .. rst-class:: sig-pretty-signature
      
         | *get* nearPlane(): *number*
      
      Returns the near clipping plane
      
      **Returns**\ : *number*
      



.. js:method:: cee.Camera.projectionType

      .. rst-class:: sig-pretty-signature
      
         | *get* projectionType(): :js:data:`ProjectionType <cee.ProjectionType>`
      
      Returns the current projection type (perspective/ortho)
      
      **Returns**\ : :js:data:`ProjectionType <cee.ProjectionType>`
      



.. js:method:: cee.Camera.viewMatrix

      .. rst-class:: sig-pretty-signature
      
         | *get* viewMatrix(): :js:class:`Mat4 <cee.Mat4>`
      
      Returns the current view matrix
      
      **Returns**\ : :js:class:`Mat4 <cee.Mat4>`
      



.. js:method:: cee.Camera.viewport

      .. rst-class:: sig-pretty-signature
      
         | *get* viewport(): { height: *number*\ , width: *number*\ , x: *number*\ , y: *number* }
      
      Returns the viewport of the camera
      
      **Returns**\ : { height: *number*\ , width: *number*\ , x: *number*\ , y: *number* }
      



.. rst-class:: kind-group kind-methods

.. rubric:: Methods
   :class: kind-group-title


.. js:method:: cee.Camera.applyCameraConfig

      .. rst-class:: sig-pretty-signature
      
         | applyCameraConfig(**config**\ : :js:class:`CameraConfig <cee.CameraConfig>`\ , **allowChangeOfProjectionType**\ : *boolean*\ ): *void*
      
      Helper that applies a camera config to the camera
      
      **Parameters**
      
      
         **config**\ : :js:class:`CameraConfig <cee.CameraConfig>`
      
         **allowChangeOfProjectionType**\ : *boolean*
      
      
      **Returns**\ : *void*
      



.. js:method:: cee.Camera.computeFitViewEyePosition

      .. rst-class:: sig-pretty-signature
      
         | computeFitViewEyePosition(**boundingBox**\ : :js:class:`BoundingBox <cee.BoundingBox>`\ , **dir**\ : :js:class:`Vec3 <cee.Vec3>`\ , **up**\ : :js:class:`Vec3 <cee.Vec3>`\ , **coverageFactor**\ : *number*\ ?): :js:class:`Vec3 <cee.Vec3>`
      
      Calculate the camera position required to fit the given bounding box in the view when the camera is orientated with the given direction and up vectors.
      
      **Parameters**
      
      
         **boundingBox**\ : :js:class:`BoundingBox <cee.BoundingBox>`
      
         **dir**\ : :js:class:`Vec3 <cee.Vec3>`
      
         **up**\ : :js:class:`Vec3 <cee.Vec3>`
      
         **coverageFactor**\ : *number* = 0.9
      
      
      **Returns**\ : :js:class:`Vec3 <cee.Vec3>`
      



.. js:method:: cee.Camera.disableAutoClip

      .. rst-class:: sig-pretty-signature
      
         | disableAutoClip(): *void*
      
      Disables the auto clipping feature
      
      **Returns**\ : *void*
      



.. js:method:: cee.Camera.enableAutoClipFixedNearDistance

      .. rst-class:: sig-pretty-signature
      
         | enableAutoClipFixedNearDistance(**fixedNearDistance**\ : *number*\ ): *void*
      
      Enables the auto clipping feature and sets a fixed near distance
      
      **Parameters**
      
      
         **fixedNearDistance**\ : *number*
      
      
      **Returns**\ : *void*
      



.. js:method:: cee.Camera.enableAutoClipMinimumNearDistance

      .. rst-class:: sig-pretty-signature
      
         | enableAutoClipMinimumNearDistance(**minNearDistance**\ : *number*\ ): *void*
      
      Enables the auto clipping feature and sets a minimum near distance
      
      **Parameters**
      
      
         **minNearDistance**\ : *number*
      
      
      **Returns**\ : *void*
      



.. js:method:: cee.Camera.fitView

      .. rst-class:: sig-pretty-signature
      
         | fitView(**boundingBox**\ : :js:class:`BoundingBox <cee.BoundingBox>`\ , **dir**\ : :js:class:`Vec3Like <cee.Vec3Like>`\ , **up**\ : :js:class:`Vec3Like <cee.Vec3Like>`\ , **coverageFactor**\ : *number*\ ?): *void*
      
      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**
      
      
         **boundingBox**\ : :js:class:`BoundingBox <cee.BoundingBox>`
      
         **dir**\ : :js:class:`Vec3Like <cee.Vec3Like>`
      
         **up**\ : :js:class:`Vec3Like <cee.Vec3Like>`
      
         **coverageFactor**\ : *number* = 0.9
      
      
      **Returns**\ : *void*
      



.. js:method:: cee.Camera.fitViewOrtho

      .. rst-class:: sig-pretty-signature
      
         | fitViewOrtho(**boundingBox**\ : :js:class:`BoundingBox <cee.BoundingBox>`\ , **eyeDist**\ : *number*\ , **dir**\ : :js:class:`Vec3Like <cee.Vec3Like>`\ , **up**\ : :js:class:`Vec3Like <cee.Vec3Like>`\ , **coverageFactor**\ : *number*\ ?): *void*
      
      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**
      
      
         **boundingBox**\ : :js:class:`BoundingBox <cee.BoundingBox>`
      
         **eyeDist**\ : *number*
      
         **dir**\ : :js:class:`Vec3Like <cee.Vec3Like>`
      
         **up**\ : :js:class:`Vec3Like <cee.Vec3Like>`
      
         **coverageFactor**\ : *number* = 0.9
      
      
      **Returns**\ : *void*
      



.. js:method:: cee.Camera.getDirection

      .. rst-class:: sig-pretty-signature
      
         | getDirection(): :js:class:`Vec3 <cee.Vec3>`
      
      Returns camera's forward direction vector. The returned vector is normalized.
      
      **Returns**\ : :js:class:`Vec3 <cee.Vec3>`
      



.. js:method:: cee.Camera.getPosition

      .. rst-class:: sig-pretty-signature
      
         | getPosition(): :js:class:`Vec3 <cee.Vec3>`
      
      Returns the camera's position (eye point)
      
      **Returns**\ : :js:class:`Vec3 <cee.Vec3>`
      



.. js:method:: cee.Camera.getUp

      .. rst-class:: sig-pretty-signature
      
         | getUp(): :js:class:`Vec3 <cee.Vec3>`
      
      Returns the camera's up vector. The returned vector is normalized.
      
      **Returns**\ : :js:class:`Vec3 <cee.Vec3>`
      



.. js:method:: cee.Camera.project

      .. rst-class:: sig-pretty-signature
      
         | project(**point**\ : :js:class:`Vec3Like <cee.Vec3Like>`\ ): :js:class:`Vec3 <cee.Vec3>`
      
      Maps world (3d) coordinates to window coordinates
      
      Returns null if the specified point cannot be projected.
      
      The returned window coordinates '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**
      
      
         **point**\ : :js:class:`Vec3Like <cee.Vec3Like>`
      
      
      **Returns**\ : :js:class:`Vec3 <cee.Vec3>`
      



.. js:method:: cee.Camera.resetCamera

      .. rst-class:: sig-pretty-signature
      
         | resetCamera(): *void*
      
      Resets the camera to its initial state as it appeared upon creation of its containing view
      
      **Returns**\ : *void*
      



.. js:method:: cee.Camera.setClipPlanesFromBoundingBox

      .. rst-class:: sig-pretty-signature
      
         | setClipPlanesFromBoundingBox(**boundingBox**\ : :js:class:`BoundingBox <cee.BoundingBox>`\ , **minNearPlaneDistance**\ : *number*\ ): *void*
      
      Sets the front and back clipping planes close to the given bounding box
      
      **Parameters**
      
      
         **boundingBox**\ : :js:class:`BoundingBox <cee.BoundingBox>`
      
         **minNearPlaneDistance**\ : *number*
      
      
      **Returns**\ : *void*
      



.. js:method:: cee.Camera.setFromLookAt

      .. rst-class:: sig-pretty-signature
      
         | setFromLookAt(**eye**\ : :js:class:`Vec3Like <cee.Vec3Like>`\ , **center**\ : :js:class:`Vec3Like <cee.Vec3Like>`\ , **up**\ : :js:class:`Vec3Like <cee.Vec3Like>`\ ): *void*
      
      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**
      
      
         **eye**\ : :js:class:`Vec3Like <cee.Vec3Like>`
      
         **center**\ : :js:class:`Vec3Like <cee.Vec3Like>`
      
         **up**\ : :js:class:`Vec3Like <cee.Vec3Like>`
      
      
      **Returns**\ : *void*
      



.. js:method:: cee.Camera.setProjectionAsOrtho

      .. rst-class:: sig-pretty-signature
      
         | setProjectionAsOrtho(**height**\ : *number*\ , **nearPlane**\ : *number*\ , **farPlane**\ : *number*\ ): *void*
      
      Sets up an 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*
      



.. js:method:: cee.Camera.setProjectionAsPerspective

      .. rst-class:: sig-pretty-signature
      
         | 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*
      



.. js:method:: cee.Camera.setViewChangeHandler

      .. rst-class:: sig-pretty-signature
      
         | setViewChangeHandler(**handler**\ : :js:class:`CameraViewChangeHandler <cee.CameraViewChangeHandler>`\ , **waitForIdle**\ : *boolean*\ ): *void*
      
      Sets a handler to be invoked each time the camera view changes
      
      **Parameters**
      
      
         **handler**\ : :js:class:`CameraViewChangeHandler <cee.CameraViewChangeHandler>`
      
      
            The handler to invoke on change
      
      
         **waitForIdle**\ : *boolean*
      
      
            If true, the handler will only be invoked after any ongoing mouse operations or camera animations have completed. Note that setting this to false will result in a large number of handler invocations, while setting this to true and then starting a never-ending camera animation will result in no invocations.
      
      
      
      **Returns**\ : *void*
      



.. js:method:: cee.Camera.setViewMatrix

      .. rst-class:: sig-pretty-signature
      
         | setViewMatrix(**viewMatrix**\ : :js:class:`Mat4 <cee.Mat4>`\ ): *void*
      
      Sets the view matrix of the camera.
      
      **Parameters**
      
      
         **viewMatrix**\ : :js:class:`Mat4 <cee.Mat4>`
      
      
      **Returns**\ : *void*
      



.. js:method:: cee.Camera.setViewpoint

      .. rst-class:: sig-pretty-signature
      
         | setViewpoint(**eye**\ : :js:class:`Vec3Like <cee.Vec3Like>`\ , **direction**\ : :js:class:`Vec3Like <cee.Vec3Like>`\ , **up**\ : :js:class:`Vec3Like <cee.Vec3Like>`\ ): *void*
      
      Sets the viewpoint from the eye point position, direction and up vectors.
      
      **Parameters**
      
      
         **eye**\ : :js:class:`Vec3Like <cee.Vec3Like>`
      
         **direction**\ : :js:class:`Vec3Like <cee.Vec3Like>`
      
         **up**\ : :js:class:`Vec3Like <cee.Vec3Like>`
      
      
      **Returns**\ : *void*
      



.. js:method:: cee.Camera.unproject

      .. rst-class:: sig-pretty-signature
      
         | unproject(**coord**\ : :js:class:`Vec3Like <cee.Vec3Like>`\ ): :js:class:`Vec3 <cee.Vec3>`
      
      Maps window coordinates to world (3d) coordinates
      
      Returns null if the specified coordinate cannot be unprojected.
      
      The input (window) coordinates '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 :js:meth:`Viewer.oglWinPosFromClientCoord <cee.Viewer.oglWinPosFromClientCoord>` to convert client coordinates into WebGL style coordinates
      
      **Parameters**
      
      
         **coord**\ : :js:class:`Vec3Like <cee.Vec3Like>`
      
      
      **Returns**\ : :js:class:`Vec3 <cee.Vec3>`
      



.. js:method:: cee.Camera.zoomToBoundingBox

      .. rst-class:: sig-pretty-signature
      
         | zoomToBoundingBox(**boundingBox**\ : :js:class:`BoundingBox <cee.BoundingBox>`\ ): *void*
      
      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**
      
      
         **boundingBox**\ : :js:class:`BoundingBox <cee.BoundingBox>`
      
      
      **Returns**\ : *void*
      




