HoopsLayerTreeElement

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.

Examples

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

Custom Element

hoops-layer-tree

Events

hoops-layer-tree-node-selected

Emitted when layer nodes are selected

hoops-layer-tree-visibility-changed

Emitted when layer visibility changes

Since

2025.8.0

Constructors

wvc.HoopsLayerTreeElement.constructor()
HoopsLayerTreeElement(): HoopsLayerTreeElement

Returns: HoopsLayerTreeElement

Accessors

wvc.HoopsLayerTreeElement.layerAdapter()
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)

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.

set layerAdapter(newLayerAdapter: LayerAdapter): void

Parameters

newLayerAdapter: LayerAdapter

Returns: void

wvc.HoopsLayerTreeElement.layersContainer()
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)

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.

set layersContainer(layersContainer: (undefined | ILayersContainer)): void

Parameters

layersContainer: (undefined | ILayersContainer)

Returns: void

wvc.HoopsLayerTreeElement.layerTreeDomElement()
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

Methods

wvc.HoopsLayerTreeElement.getElementData()
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

Throws

When the layer adapter is not initialized

wvc.HoopsLayerTreeElement.selectElements()
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

Throws

When the layer tree element is not initialized

wvc.HoopsLayerTreeElement.selectNodes()
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

Throws

When the tree dom element is not initialized

wvc.HoopsLayerTreeElement.setLayerData()
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

Throws

When the layer adapter or tree element is not initialized

wvc.HoopsLayerTreeElement.updateLayerData()
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

Throws

When the layer adapter or tree element is not initialized

wvc.HoopsLayerTreeElement.updateVisibility()
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