
#####################
HoopsLayerTreeElement
#####################

.. js:class:: wvc.HoopsLayerTreeElement

   Provides a tree view for displaying and managing model layers.
   
   This component renders a list of layers with lazy loading support. It handles layer selection, visibility toggling, and node management within layers.
   
   .. rubric:: Examples
   
   
   .. code-block:: html
   
      <hoops-layer-tree></hoops-layer-tree>
      
      <script>
        const layerTree = document.getElementsByTagName('hoops-layer-tree')[0];
        layerTree.layersContainer = webviewer.model;
        layerTree.addEventListener('hoops-layer-tree-node-selected', (event) => {
          console.log('Selected nodes:', event.detail.nodeIds);
        });
      </script>
   
   .. rubric:: Custom Element
   
   
   ``hoops-layer-tree``
   
   .. rubric:: Events
   
   
   **hoops-layer-tree-node-selected**
   
   
      Emitted when layer nodes are selected
   
   
   **hoops-layer-tree-visibility-changed**
   
   
      Emitted when layer visibility changes
   
   
   .. rubric:: Since
   
   
   ``2025.8.0``
   
   
   Index
   =====
   
   .. rubric:: Constructors
   
   
   .. rst-class:: api-xref-list
   
   
   * :js:func:`~wvc.HoopsLayerTreeElement.constructor`
   
   .. rubric:: Accessors
   
   
   .. rst-class:: api-xref-list
   
   
   * :js:func:`~wvc.HoopsLayerTreeElement.layerAdapter`
   * :js:func:`~wvc.HoopsLayerTreeElement.layersContainer`
   * :js:func:`~wvc.HoopsLayerTreeElement.layerTreeDomElement`
   
   .. rubric:: Methods
   
   
   .. rst-class:: api-xref-list
   
   
   * :js:meth:`~wvc.HoopsLayerTreeElement.getElementData`
   * :js:meth:`~wvc.HoopsLayerTreeElement.selectElements`
   * :js:meth:`~wvc.HoopsLayerTreeElement.selectNodes`
   * :js:meth:`~wvc.HoopsLayerTreeElement.setLayerData`
   * :js:meth:`~wvc.HoopsLayerTreeElement.updateLayerData`
   * :js:meth:`~wvc.HoopsLayerTreeElement.updateVisibility`
   
   



.. rst-class:: kind-group kind-constructors

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


.. js:method:: wvc.HoopsLayerTreeElement.constructor

      .. rst-class:: sig-pretty-signature
      
         | HoopsLayerTreeElement(): :js:class:`HoopsLayerTreeElement <wvc.HoopsLayerTreeElement>`
      
      **Returns**\ : :js:class:`HoopsLayerTreeElement <wvc.HoopsLayerTreeElement>`
      



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

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


.. js:method:: wvc.HoopsLayerTreeElement.layerAdapter

      .. rst-class:: sig-pretty-signature
      
         | *get* layerAdapter(): (*undefined* | *LayerAdapter*\ )
      
      Gets or sets the layer adapter that supplies data to the list.
      
      This is a syntactic sugar to access list.context. If the List is not set it returns undefined.
      
      Reassigning the layerAdapter will trigger an update.
      
      **Returns**\ : (*undefined* \| *LayerAdapter*\ )
      
      .. rubric:: Throws
      
      
      When setting layerAdapater without an initialized list element. This should not happen in normal use since the list is added to the layer list at initialization.
      
      .. rst-class:: sig-pretty-signature
      
         | *set* layerAdapter(**newLayerAdapter**\ : *LayerAdapter*\ ): *void*
      
      **Parameters**
      
      
         **newLayerAdapter**\ : *LayerAdapter*
      
      
      **Returns**\ : *void*
      



.. js:method:: wvc.HoopsLayerTreeElement.layersContainer

      .. rst-class:: sig-pretty-signature
      
         | *get* layersContainer(): (*undefined* | *ILayersContainer*\ )
      
      Gets or sets the layers container that represents the available layers in the model.
      
      This is a syntactic sugar to access LayerTree.layerAdapter.layersContainer. If the LayerAdapter is not set it returns undefined.
      
      Reassigning the layersContainer will trigger an update.
      
      **Returns**\ : (*undefined* \| *ILayersContainer*\ )
      
      .. rubric:: Throws
      
      
      When setting layersContainer without an initialized layer adapter. This should not happen in normal use since the layerAdapter is added to the layer list at initialization.
      
      .. rst-class:: sig-pretty-signature
      
         | *set* layersContainer(**layersContainer**\ : (*undefined* | *ILayersContainer*\ )): *void*
      
      **Parameters**
      
      
         **layersContainer**\ : (*undefined* \| *ILayersContainer*\ )
      
      
      **Returns**\ : *void*
      



.. js:method:: wvc.HoopsLayerTreeElement.layerTreeDomElement

      .. rst-class:: sig-pretty-signature
      
         | *get* layerTreeDomElement(): (*undefined* | *List*\ )
      
      Gets the internal list component instance.
      
      This is a syntactic sugar to simplify getting the list element and expose it externally.
      
      **Returns**\ : (*undefined* \| *List*\ )
      
      
         The list element instance or undefined if not initialized
      
      



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

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


.. js:method:: wvc.HoopsLayerTreeElement.getElementData

      .. rst-class:: sig-pretty-signature
      
         | getElementData(**layerId**\ : *number*\ ): T
      
      Retrieves custom data associated with a layer.
      
      This is a shorthand to allow users to attach reactive data to layers.
      
      **Parameters**
      
      
         **layerId**\ : *number*
      
      
            The ID of the layer that owns the data
      
      
      
      **Returns**\ : T
      
      
         The stored custom data or undefined if no data exists
      
      
      .. rubric:: Throws
      
      
      When the layer adapter is not initialized
      



.. js:method:: wvc.HoopsLayerTreeElement.selectElements

      .. rst-class:: sig-pretty-signature
      
         | selectElements(**layerIds**\ : *number*\ [], **selected**\ : *boolean*\ ): *void*
      
      Selects or deselects layers in the list.
      
      Reassigning the selected layers will trigger an update.
      
      **Parameters**
      
      
         **layerIds**\ : *number*\ []
      
      
            Array of layer IDs to update
      
      
         **selected**\ : *boolean*
      
      
            Whether to select (true) or deselect (false) the layers
      
      
      
      **Returns**\ : *void*
      
      
      
      .. rubric:: Throws
      
      
      When the layer tree element is not initialized
      



.. js:method:: wvc.HoopsLayerTreeElement.selectNodes

      .. rst-class:: sig-pretty-signature
      
         | selectNodes(**nodeIds**\ : *number*\ [], **selected**\ : *boolean*\ ): *void*
      
      Selects or deselects nodes in the layer sublists.
      
      Clears existing selection and applies the new selection to all layer tree elements.
      
      **Parameters**
      
      
         **nodeIds**\ : *number*\ []
      
      
            Array of node IDs to update
      
      
         **selected**\ : *boolean*
      
      
            Whether to select (true) or deselect (false) the nodes
      
      
      
      **Returns**\ : *void*
      
      
      
      .. rubric:: Throws
      
      
      When the tree dom element is not initialized
      



.. js:method:: wvc.HoopsLayerTreeElement.setLayerData

      .. rst-class:: sig-pretty-signature
      
         | setLayerData(**layerId**\ : *number*\ , **data**\ : *unknown*\ ): *void*
      
      Stores custom data for a layer, replacing any existing value.
      
      If the layer had already a value it is erased. Setting layer data will trigger an update.
      
      **Parameters**
      
      
         **layerId**\ : *number*
      
      
            The ID of the layer that owns the data
      
      
         **data**\ : *unknown*
      
      
            The data to store
      
      
      
      **Returns**\ : *void*
      
      
      
      .. rubric:: Throws
      
      
      When the layer adapter or tree element is not initialized
      



.. js:method:: wvc.HoopsLayerTreeElement.updateLayerData

      .. rst-class:: sig-pretty-signature
      
         | updateLayerData(**layerId**\ : *number*\ , **data**\ : *unknown*\ ): *void*
      
      Merges custom data into an existing layer entry.
      
      If the layer did not have data, it is added to the context. If the given data is an array and the context layer data is an array, the data passed as argument are appended to the context data. If both are objects, then the objects are merged using Object.assign, with the data argument being the last object of the merge. Otherwise it is equivalent to setLayerData.
      
      Updating layer data will trigger an update.
      
      **Parameters**
      
      
         **layerId**\ : *number*
      
      
            The ID of the layer that owns the data
      
      
         **data**\ : *unknown*
      
      
            The data to merge into the layer entry
      
      
      
      **Returns**\ : *void*
      
      
      
      .. rubric:: Throws
      
      
      When the layer adapter or tree element is not initialized
      



.. js:method:: wvc.HoopsLayerTreeElement.updateVisibility

      .. rst-class:: sig-pretty-signature
      
         | updateVisibility(**shownBodyIds**\ : *number*\ [], **hiddenBodyIds**\ : *number*\ []): *void*
      
      Updates visibility icons for layers based on shown and hidden body IDs.
      
      This method propagates visibility changes to affected layer tree elements.
      
      **Parameters**
      
      
         **shownBodyIds**\ : *number*\ []
      
      
            Array of body IDs that are now visible
      
      
         **hiddenBodyIds**\ : *number*\ []
      
      
            Array of body IDs that are now hidden
      
      
      
      **Returns**\ : *void*
      
      
      




