.. role:: ts-api-decorator

##############
OverlayManager
##############

.. js:module:: Overlay
   :noindex:

.. container:: ts-api-section

   .. js:class:: OverlayManager

      The OverlayManager exposes functionality for creating overlays that are layered on top of the 3d scene. More
      information can be found [here](https://docs.techsoft3d.com/communicator/latest/prog_guide/viewing/scene_attributes/overlays.html).
      An overlay defines a viewport on the screen with an associated camera.
      These overlays are useful for creating axis triads, navigational cubes, or similar elements.
      The overlays are not designed to create multiple views of a model. Therefore, inserting large amounts of
      geometry into overlays isn't recommended. Add directly additional views from the webviewer instead.



.. container:: api-index-section

   .. rubric:: Methods

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

   * :js:meth:`~Overlay.OverlayManager.addNodes`
   * :js:meth:`~Overlay.OverlayManager.destroy`
   * :js:meth:`~Overlay.OverlayManager.getViewportAnchor`
   * :js:meth:`~Overlay.OverlayManager.getViewportPixelOffsetInCanvas`
   * :js:meth:`~Overlay.OverlayManager.getViewportPixelPosition`
   * :js:meth:`~Overlay.OverlayManager.getViewportPixelSize`
   * :js:meth:`~Overlay.OverlayManager.maxIndex`
   * :js:meth:`~Overlay.OverlayManager.setCamera`
   * :js:meth:`~Overlay.OverlayManager.setViewport`
   * :js:meth:`~Overlay.OverlayManager.setVisibility`





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

Methods
=======

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

addNodes
--------

.. js:method:: OverlayManager.addNodes( index, nodes)

   :param index: the overlay index to add nodes into.
   :type index: number
   :param nodes: the nodes to add into the overlay.
   :type nodes: [number]


   Adds nodes into the overlay at the given index. They will no longer be rendered in the main window or any other overlay.
   This method should not be called before the model structure ready callback has been triggered.


   :rtype: Promise <void>

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

destroy
-------

.. js:method:: OverlayManager.destroy( index)

   :param index: the index of the overlay to destroy.
   :type index: number


   Removes an overlay from the system. All nodes that have been assigned to this overlay will be returned to the default view.


   :rtype: Promise <void>

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

getViewportAnchor
-----------------

.. js:method:: OverlayManager.getViewportAnchor( index)

   :param index: The index of the overlay to get the anchor of.
   :type index: number


   Get the anchor point of the viewport with the supplied index, or ``null`` if none has been set.


   :rtype: null | OverlayAnchor

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

getViewportPixelOffsetInCanvas
------------------------------

.. js:method:: OverlayManager.getViewportPixelOffsetInCanvas( index)

   :param index: The index of the overlay to get the offset of
   :type index: number


   Gets the calculated position of the upper-left corner of the viewport with the supplied index, or ``null``
   if none has been set.


   :rtype: null | Point2

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

getViewportPixelPosition
------------------------

.. js:method:: OverlayManager.getViewportPixelPosition( index)

   :param index: The index of the overlay to get the position of.
   :type index: number


   Gets position in pixels of the viewport with the supplied index, or ``null`` if none has been set.
   Note: This does not take the anchor point into account


   :rtype: null | Point2

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

getViewportPixelSize
--------------------

.. js:method:: OverlayManager.getViewportPixelSize( index)

   :param index: The index of the overlay to get the size of.
   :type index: number


   Gets size in pixels of the viewport with the supplied index, or ``null`` if none has been set.


   :rtype: null | Point2

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

maxIndex
--------

.. js:method:: OverlayManager.maxIndex()



   Gets the maximum index value that can be used for indexing overlays.

   :returns: the maximum index value.


   :rtype: number

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

setCamera
---------

.. js:method:: OverlayManager.setCamera( index, camera)

   :param index: None
   :type index: number
   :param camera: None
   :type camera: Camera


   Sets the camera for the given index.


   :rtype: Promise <void>

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

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

.. js:method:: OverlayManager.setViewport( index, anchor, x, xUnit, y, yUnit, width, widthUnit, height, heightUnit)

   :param index: the index of the overlay. This value may be any number between 1 and maxIndex(). If No overlay exists for this index one will be created.
   :type index: number
   :param anchor: the anchor point for the viewport.
   :type anchor: OverlayAnchor
   :param x: the x value of the viewport location.
   :type x: number
   :param xUnit: the unit type of the x parameter.
   :type xUnit: OverlayUnit
   :param y: the y value of the viewport location.
   :type y: number
   :param yUnit: the unit type of the y parameter.
   :type yUnit: OverlayUnit
   :param width: the width of the viewport.
   :type width: number
   :param widthUnit: the unit type of the width parameter.
   :type widthUnit: OverlayUnit
   :param height: the height of the viewport.
   :type height: number
   :param heightUnit: the unit type of the height parameter.
   :type heightUnit: OverlayUnit


   Creates an overlay or updates an existing one.


   :rtype: Promise <void>

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

setVisibility
-------------

.. js:method:: OverlayManager.setVisibility( index, visibility)

   :param index: the overlay index.
   :type index: number
   :param visibility: boolean value indicating whether the overlay should be rendered.
   :type visibility: boolean


   Sets the visibility state for the given viewport.


   :rtype: Promise <void>

