# SelectionExtension

Defalt selection helper extension. Handles object selection automatically, both visually and data wise. Optionally can highlight on hover. The extension automatically binds to:

  • ViewerEvent.ObjectClicked for selection detection.
  • ViewerEvent.ObjectDoubleClicked for focusing on objects
  • InputEvent.PointerMove for hover detection

WARNING

This extension requires and active CameraController extension implementation.

WARNING

Note that this extension will automatically remember the last material for each material that you select and automatically apply it upon deselection. This might affect the end result if you are combining selection with other operations like isolating, hiding or coloring.

#

Accessors

enabled options

#

Methods

getSelectedObjects getSelectedNodes selectObjects unselectObjects

#

Typedefs

SelectionExtensionOptions

#

Constants

DefaultSelectionExtensionOptions

#

Accessors

# enabled

get enabled(): boolean
set enabled(value: boolean)
1
2

Enables/disables the extension.

Returns: boolean

# options

get options(): SelectionExtensionOptions
set options(value: SelectionExtensionOptions)
1
2

Gets and sets the extension options.

Returns: SelectionExtensionOptions

#

Methods

# getSelectedObjects

getSelectedObjects(): Array<Record<string, unknown>>
1

Gets the currently selected raw objects.

Returns: Array< Record< string, unknown > >

# getSelectedNodes

getSelectedNodes(): Array<TreeNode>
1

Gets the currently selected nodes.

Returns: Array< TreeNode >

# selectObjects

selectObjects(ids: Array<string>, multiSelect = false): void
1

Programatically selects objects by ids.

Parameters

  • ids: Array< string >
  • optional multiSelect: Signals if this select needs to clear previous one or not

Returns: void

# unselectObjects

unselectObjects(ids?: Array<string>): void
1

Programatically un-selects objects by ids.

Parameters

  • optional ids: Array< string >. If not specified everything gets unselected

Returns: void

#

Typedefs

# SelectionExtensionOptions

interface SelectionExtensionOptions {
  selectionMaterialData: RenderMaterial & DisplayStyle & MaterialOptions;
  hoverMaterialData?: RenderMaterial & DisplayStyle & MaterialOptions;
}
1
2
3
4

Options for configuring how the visual selection looks. If hoverMaterialData is not specified, there will be no hover effect.

TIP

The selection/hover material data is provided as an intersection between a RenderMaterial, a DisplayStyle and a MaterialOptions in order to accomodate all renderable types: triangles, lines and points.

  • selectionMaterialData: The material data for selection effect
  • hoverMaterialData: The material data for hover effect. If not specified, hover will not be enabled

#

Constants

# DefaultSelectionExtensionOptions

const DefaultSelectionExtensionOptions: SelectionExtensionOptions = {
  selectionMaterialData: {
    id: MathUtils.generateUUID(),
    color: 0x047efb,
    opacity: 1,
    roughness: 1,
    metalness: 0,
    vertexColors: false,
    lineWeight: 1,
    stencilOutlines: true,
    pointSize: 4,
  },
};
1
2
3
4
5
6
7
8
9
10
11
12
13