.. role:: ts-api-decorator

####
View
####

.. js:module:: cee
   :noindex:

.. container:: ts-api-section

   .. js:class:: View

      A View represents a viewport where you can show models and overlay items.

      A view has a collection of models that are shown in the view. You add a model to a view
      with the ``addModel`` function and remove it with the ``removeModel`` function.

      You can access the ``Camera`` from the View with the ``camera`` property. The camera can be
      used to manually control the view point, projection and other view related settings.

      A viewer can have one or more views. The views can operate independently or be set up for synchronized viewing. 
      Changes to a model object shared between multiple views will be reflected in all views.
      The ``MultipleViews`` example project shows how you can create, manage, and synchronize multiple views.

      You can manage overlay items (legends, text boxes, navigation cube, etc) with the ``overlay`` object.



.. container:: api-index-section

   .. rubric:: Accessors

   .. rst-class:: api-index-list-item api-kind-accessor api-parent-kind-class

   * :js:attr:`~cee.View.ambientOcclusion`
   * :js:attr:`~cee.View.background`
   * :js:attr:`~cee.View.camera`
   * :js:attr:`~cee.View.clipping`
   * :js:attr:`~cee.View.haloHighlightColor`
   * :js:attr:`~cee.View.modelCount`
   * :js:attr:`~cee.View.name`
   * :js:attr:`~cee.View.navigation`
   * :js:attr:`~cee.View.nonHighlightedDimFactor`
   * :js:attr:`~cee.View.operators`
   * :js:attr:`~cee.View.overlay`
   * :js:attr:`~cee.View.ownerViewer`



.. container:: api-index-section

   .. rubric:: Methods

   .. rst-class:: api-index-list-item api-kind-method api-parent-kind-class

   * :js:meth:`~cee.View.addModel`
   * :js:meth:`~cee.View.getBoundingBox`
   * :js:meth:`~cee.View.getIndexOfModel`
   * :js:meth:`~cee.View.getModelArray`
   * :js:meth:`~cee.View.getModelAt`
   * :js:meth:`~cee.View.getRayThroughPoint`
   * :js:meth:`~cee.View.rayIntersect`
   * :js:meth:`~cee.View.removeAllModels`
   * :js:meth:`~cee.View.removeModel`
   * :js:meth:`~cee.View.removeModelAt`
   * :js:meth:`~cee.View.requestRedraw`
   * :js:meth:`~cee.View.setViewport`





------------

Accessors
=========

.. container:: ts-api-section

   .. js:function:: View.ambientOcclusion()



      The ambient occlusion configuration object for the view


      :rtype: AmbientOcclusion



.. container:: ts-api-section

   .. js:function:: View.background()



      The background config of the view


      :rtype: Background



.. container:: ts-api-section

   .. js:function:: View.camera()



      The ``Camera`` used in the View.

      The camera can be used to specify the View's viewpoint, orientation, direction, projection, clipping,
      and other viewport related properties.

      **Note**:

      This returns a reference to the real object, not a copy, so any changes to the returned object will be applied 
      to the 3D view.


      :rtype: Camera



.. container:: ts-api-section

   .. js:function:: View.clipping()



      The clipping controller for the view


      :rtype: Clipping



.. container:: ts-api-section

   .. js:function:: View.haloHighlightColor()



      The color used to draw the halo around highlighted parts in the view.


      :rtype: Color3Like

   .. js:function:: View.haloHighlightColor( highlightColor)

      :param highlightColor: None
      :type highlightColor: Color3Like


      :rtype: void



.. container:: ts-api-section

   .. js:function:: View.modelCount()



      The number of models in the view.


      :rtype: number



.. container:: ts-api-section

   .. js:function:: View.name()



      The name of the view (used for debugging)


      :rtype: string

   .. js:function:: View.name( name)

      :param name: None
      :type name: string


      :rtype: void



.. container:: ts-api-section

   .. js:function:: View.navigation()





      :deprecated:


      :rtype: Navigation



.. container:: ts-api-section

   .. js:function:: View.nonHighlightedDimFactor()



      The amount to dim the areas of the screen that does not contain highlighted parts. 
      Default value is 0.5. Setting a value of 0 disables dimming.


      :rtype: number

   .. js:function:: View.nonHighlightedDimFactor( factor)

      :param factor: None
      :type factor: number


      :rtype: void



.. container:: ts-api-section

   .. js:function:: View.operators()



      The operator stack for the view.


      :rtype: OperatorStack



.. container:: ts-api-section

   .. js:function:: View.overlay()



      The 2d overlay controller for the view.


      :rtype: Overlay



.. container:: ts-api-section

   .. js:function:: View.ownerViewer()



      The owner ``Viewer``.

      A View can only be in one Viewer. The Viewer creates and manages the View.


      :rtype: Viewer



Methods
=======

.. rst-class:: ts-api-section

addModel
--------

.. js:method:: View.addModel( model)

   :param model: None
   :type model: Model


   Adds a model to the view. 

   While a model can be shown in any number of views, it can only be added to a particular view once.


   :rtype: void

.. rst-class:: ts-api-section

getBoundingBox
--------------

.. js:method:: View.getBoundingBox([ modelBoundingBoxOptions])

   :param modelBoundingBoxOptions: :ts-api-decorator:`optional` None
   :type modelBoundingBoxOptions: ModelBoundingBoxOptions


   Returns the combined bounding box of all models in the view

   See ``Model.getBoundingBox`` and ``ModelBoundingBoxOptions`` for more information on how
   the bounding box is calculated and what options are available.


   :rtype: BoundingBox

.. rst-class:: ts-api-section

getIndexOfModel
---------------

.. js:method:: View.getIndexOfModel( model)

   :param model: None
   :type model: Model


   Returns the zero-based index of the given model


   :rtype: number

.. rst-class:: ts-api-section

getModelArray
-------------

.. js:method:: View.getModelArray()



   Returns a read only array with all models in the view


   :rtype: unknown

.. rst-class:: ts-api-section

getModelAt
----------

.. js:method:: View.getModelAt( index)

   :param index: None
   :type index: number


   Returns the model at the given zero-based index


   :rtype: Model

.. rst-class:: ts-api-section

getRayThroughPoint
------------------

.. js:method:: View.getRayThroughPoint( point)

   :param point: None
   :type point: Vec3


   Returns a ray that intersects the given point (in world coordinates) and starts at the 
   point's projection onto the screen.

   Returns null if no ray can be found.


   :rtype: Ray

.. rst-class:: ts-api-section

rayIntersect
------------

.. js:method:: View.rayIntersect( ray, ignoreLabels)

   :param ray: None
   :type ray: Ray
   :param ignoreLabels: None
   :type ignoreLabels: boolean


   Do a ray intersect with all the models in the view.

   Returns the intersection point if there was a hit, and null if there was not a hit.

   Labels have a "special treatment" ray intersect where hitting the label will cause a hit on the label attachment point.
   This is not always what is intended, e.g. when doing zoom to cursor. Set ignoreLabels to true to skip
   labels when doing ray intersect. This only applies to PartLabels in the MarkupModel


   :rtype: Vec3

.. rst-class:: ts-api-section

removeAllModels
---------------

.. js:method:: View.removeAllModels()



   Removes all models from the view.


   :rtype: void

.. rst-class:: ts-api-section

removeModel
-----------

.. js:method:: View.removeModel( model)

   :param model: None
   :type model: Model


   Removes the given model from the view.


   :rtype: void

.. rst-class:: ts-api-section

removeModelAt
-------------

.. js:method:: View.removeModelAt( modelIndex)

   :param modelIndex: None
   :type modelIndex: number


   Removes the model at the given index from the view.

   The index must be zero-based and between 0 and modelCount - 1


   :rtype: void

.. rst-class:: ts-api-section

requestRedraw
-------------

.. js:method:: View.requestRedraw()



   Requests a redraw of the viewer. This will force a redraw on the next 
   ``CloudSession.handleAnimationFrameCallback`` event.


   :rtype: void

.. rst-class:: ts-api-section

setViewport
-----------

.. js:method:: View.setViewport( x, y, width, height)

   :param x: None
   :type x: number
   :param y: None
   :type y: number
   :param width: None
   :type width: number
   :param height: None
   :type height: number


   Sets the viewport to the given position and size in OpenGL window coordinates.

   This method cannot be called when ``ownerViewer``.``viewLayoutMode`` is set to ``ViewLayoutMode.Auto``.


   :rtype: void

