The extension automatically binds to:
ViewerEvent.ObjectClicked for selection detection.
ViewerEvent.ObjectDoubleClicked for focusing on objects
InputEvent.PointerMove for hover detection
This extension requires and active CameraController extension implementation.
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
get enabled(): boolean
set enabled(value: boolean)
Enables/disables the extension.
Returns: boolean
options
get options(): SelectionExtensionOptions
set options(value: SelectionExtensionOptions)
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;
}
Options for configuring how the visual selection looks. If hoverMaterialData is not specified, there will be no hover effect.
- 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,
},
};