# 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 objectsInputEvent.PointerMove
for hover detection
WARNING
This extension requires and active CameraController extension implementation.
# Accessors
enabled | options |
---|
# Methods
getSelectedObjects | getSelectedNodes | selectObjects | unselectObjects |
---|
# Typedefs
SelectionExtensionOptions |
---|
# Constants
DefaultSelectionExtensionOptions |
---|
# Accessors
# enabled
get enabled(): boolean
set enabled(value: boolean)
2
Enables/disables the extension.
Returns: boolean
# options
get options(): SelectionExtensionOptions
set options(value: SelectionExtensionOptions)
2
Gets and sets the extension options.
Returns: SelectionExtensionOptions
# Methods
# getSelectedObjects
getSelectedObjects(): Array<Record<string, unknown>>
Gets the currently selected raw objects.
Returns: Array< Record< string, unknown > >
# getSelectedNodes
getSelectedNodes(): Array<TreeNode>
Gets the currently selected nodes.
Returns: Array< TreeNode >
# selectObjects
selectObjects(ids: Array<string>, multiSelect = false): void
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
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;
}
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,
},
};
2
3
4
5
6
7
8
9
10
11
12
13