Skip to main content

Highlighter

This component allows highlighting and selecting fragments in a 3D scene. 📕 Tutorial. 📘 API.

Extends

  • Component

Implements

  • Disposable

Properties

autoToggle

autoToggle: Set<string>

Styles with auto toggle will be unselected when selected twice.


backupColor

backupColor: null | Color = null

Stores the backup color before selection.


colors

colors: Map<string, Color>

Stores the colors used for highlighting selections.


config

config: Required <HighlighterConfig>

Stores the configuration options for the Highlighter.


enabled

enabled: boolean = true

OBC.Component.enabled

Overrides

OBC.Component.enabled


events

events: HighlightEvents = {}

Stores the events triggered by the Highlighter.


isSetup

isSetup: boolean = false

Indicates whether the Highlighter is setup.


multiple

multiple: "none" | "ctrlKey" | "shiftKey" = "ctrlKey"

Determines the multiple selection behavior.


onAfterUpdate

readonly onAfterUpdate: Event <Highlighter>

OBC.Updateable.onAfterUpdate


onBeforeUpdate

readonly onBeforeUpdate: Event <Highlighter>

OBC.Updateable.onBeforeUpdate


onDisposed

readonly onDisposed: Event<unknown>

OBC.Disposable.onDisposed

Implementation of

OBC.Disposable.onDisposed


onSetup

readonly onSetup: Event <Highlighter>

Event triggered when the Highlighter is setup.


selectable

selectable: object = {}

If defined, only the specified elements will be selected by the specified style.

Index signature

[name: string]: FragmentIdMap


selection

selection: object = {}

Stores the current selection.

Index signature

[selectionID: string]: FRAGS.FragmentIdMap


zoomFactor

zoomFactor: number = 1.5

Zoom factor applied when zooming to selection.


zoomToSelection

zoomToSelection: boolean = false

Indicates whether to zoom to the selection when highlighting.


uuid

static readonly uuid: "cb8a76f2-654a-4b50-80c6-66fd83cafd77"

A unique identifier for the component. This UUID is used to register the component within the Components system.

Methods

add()

add(name, color): void

Adds a new selection with the given name and color. Throws an error if a selection with the same name already exists.

Parameters

ParameterTypeDescription
namestringThe name of the new selection.
colorColorThe color to be used for highlighting the selection.

Returns

void

Throws

Will throw an error if a selection with the same name already exists.


clear()

clear(name?): void

Clears the selection for the given name or all selections if no name is provided.

Parameters

ParameterTypeDescription
name?stringThe name of the selection to clear. If not provided, clears all selections.

Returns

void

Throws

Will throw an error if the FragmentsManager is not found.

Throws

Will throw an error if the fragment or its geometry is not found.

Throws

Will throw an error if the item ID is not found.

Throws

Will throw an error if the fragment does not belong to a FragmentsGroup.


dispose()

dispose(): Promise<void>

Disposable.dispose

Returns

Promise<void>

Implementation of

OBC.Disposable.dispose


highlight()

highlight(name, removePrevious, zoomToSelection, exclude): Promise<null | object>

Highlights a fragment based on a raycast from the mouse position.

Parameters

ParameterTypeDefault valueDescription
namestringundefinedThe name of the selection.
removePreviousbooleantrueWhether to remove previous highlights.
zoomToSelectionbooleanundefinedWhether to zoom to the highlighted selection.
excludeFragmentIdMap{}Fragments to exclude from the highlight.

Returns

Promise<null | object>

The highlighted fragment and its ID, or null if no fragment was highlighted.

Throws

Will throw an error if the world or a required component is not found.

Throws

Will throw an error if the selection does not exist.

Throws

Will throw an error if the fragment or its geometry is not found.

Throws

Will throw an error if the item ID is not found.

Throws

Will throw an error if the fragment does not belong to a FragmentsGroup.


highlightByID()

highlightByID(name, fragmentIdMap, removePrevious, zoomToSelection, exclude, fillMesh, isPicking): Promise<void>

Highlights a fragment based on a given fragment ID map.

Parameters

ParameterTypeDefault valueDescription
namestringundefinedThe name of the selection.
fragmentIdMapFragmentIdMapundefinedThe fragment ID map to highlight.
removePreviousbooleantrueWhether to remove previous highlights.
zoomToSelectionbooleanundefinedWhether to zoom to the highlighted selection.
excludeFragmentIdMap{}Fragments to exclude from the highlight.
fillMeshundefined | Mesh<BufferGeometry<NormalBufferAttributes>, Material | Material[], Object3DEventMap>undefinedThe fill mesh to also highlight, if any.
isPickingbooleanfalseWhether this function is called when picking with the mouse.

Returns

Promise<void>

Promise that resolves when the highlighting is complete.

Throws

Will throw an error if the selection does not exist.

Throws

Will throw an error if the fragment or its geometry is not found.

Throws

Will throw an error if the item ID is not found.

Throws

Will throw an error if the fragment does not belong to a FragmentsGroup.


setup()

setup(config?): void

Sets up the Highlighter with the provided configuration.

Parameters

ParameterTypeDescription
config?Partial <HighlighterConfig>Optional configuration for the Highlighter.
If not provided, the Highlighter will use the default configuration.

Returns

void

Throws

Will throw an error if the world or a required component is not found.

Throws

Will throw an error if the selection already exists.

Throws

Will throw an error if the fragment or its geometry is not found.

Throws

Will throw an error if the item ID is not found.

Throws

Will throw an error if the fragment does not belong to a FragmentsGroup.


updateFragments()

updateFragments(fragments): void

Applies all the existing styles to the given fragments. Useful when combining the highlighter with streaming.

Parameters

ParameterTypeDescription
fragmentsIterable<Fragment>The list of fragment to update.

Returns

void