Reference·JavaScript · @bimworks/viewercommonJavaScript

ObjectStateManager

Class in @bimworks/viewercommon.

API catalogue · @bimworks/viewercommon · Class

TypeScript#
class ObjectStateManager

An instance of ObjectStateManager keeps track of all the viewer-related state and distributes this state to other components, usually viewers. This state includes:

  • Visibility of objects
  • User-changed colors of objects
  • Selection of objects
  • Object labelling
  • View fitting of objects

Most applications will have one ObjectStateManager, but you can have more. The most common scenatio is to have one ObjectStateManager, one Viewer3d and one Viewer2d. Both viewers being connected to the same ObjectStateManager so that the state is kept in sync.

Members#

Member Kind Description
constructor Method
modelManager Property The ModelManager this ObjectStateManager was created with, the same as ObjectStateManager.getModelManager
addAnnotation Method Add a single annotation. When adding large sets of annotations, use addAnnotations
addAnnotationLayer Method Add a layer of template annotations to every viewer of this object state manager: one BQL query fetched in one batch and/or rows of your own, drawn by a temp…
addAnnotationListener Method Registers for annotations and annotation layers; annotationLayerAdded is called at once for every existing layer
addAnnotations Method Add multiple annotations.
addBuildingStoreyExclusiveVisibilityListener Method
addCameraPoseListener Method Register a listener for camera pose changes
addColorListener Method
addColorMultiListener Method Listens to colour changes of several colours at once (changeColorMulti)
addGhostListener Method Listen to ghost set changes: addedToGhostSet and removedFromGhostSet of ObjectStateListener
addHoverListener Method
addListener Method
addListenerForAll Method Registers the listener for every ObjectStateListenerType
addLoadedListener Method
addNoShadowListener Method Listen to no-shadow set changes: addedToNoShadowSet and removedFromNoShadowSet of ObjectStateListener
addObbVisibilityListener Method
addOnTopListener Method Listen to on-top set changes: addedToOnTopSet and removedFromOnTopSet of ObjectStateListener
addPickabilityListener Method
addSectionabilityListener Method
addSectionEndcapListener Method
addSelectionListener Method
addSetLabelsListener Method
addSoftOccluderListener Method
addToEndcapsSet Method Objects whose cut surfaces section planes close with end caps (all objects are by default); resetAll does not change it
addToGhostSet Method Ghost objects (docs/clash-detection-ui-design.md §9.9 item 1): the viewers draw them only with the x-ray overlay (the current XRayVisualization), not in the …
addToNoShadowSet Method Add objects to the no-shadow set: the 3D viewer leaves them out of its sun shadows, even when shown. Viewer3d fills it with the non-physical types of the mod…
addToObbVisibleSet Method
addToOnTopSet Method Add objects to the on-top set (BVL ON_TOP). The 3D viewer draws them in front of every other object, in their own colours, and picks them first. Among each o…
addToPickableSet Method Add the provided objects to the currently pickable set of objects
addToSectionableSet Method Objects whose geometry section planes cut (every object of a model is by default, a GIS layer's object is not)
addToSelectionSet Method Add a set of objects to the selected set
addToSoftOccluderSet Method Add objects to the soft-occluder set. Soft occluders (typically walls, roofs and slabs) gradually fade out - and become pick-through - as the camera approach…
addToVisibleSet Method Add the provided objects to the currently visible set of objects *
addToXRaySet Method Add objects to the x-ray set. The 3D viewer draws these objects with the x-ray overlay: translucent faces and edges drawn through everything in front of them…
addViewer Method Announces a viewer to the ViewerListeners; the Viewer2d announces itself once its models are in
addViewerListener Method Registers for viewers announcing themselves (addViewer)
addViewFitListener Method
addViewFitModelsListener Method
addVisibilityListener Method
addWireframeListener Method Listen for wireframe resets when BVL results or resetAll restore defaults.
addXRayListener Method Listen to x-ray set changes: addedToXRaySet, removedFromXRaySet and setXRaySet of ObjectStateListener
captureObjectState Method The object state as it is now, as a value to give back to restoreObjectState later: the loaded models, which objects are visible, the colour overrides, the o…
castsShadow Method Whether the given object casts sun shadows (true unless it is in the no-shadow set)
changeColor Method Change the color of a given set of objects. When changing the colors of multiple sets of objects, use the more efficient changeColorMulti method.
changeColorMulti Method Change the colors of a given set of objects.
clearAnnotations Method Removes all annotations and annotation layers, in every viewer
clearGhostSet Method Empties the ghost set, bringing back the visibility ghosting took
clearOnTopSet Method Empty the on-top set
clearSelection Method Clear the current selection
clearXRaySet Method Empty the x-ray set
getAnnotationLayers Method The annotation layers, in the order they were added
getColor Method
getColorOverrides Method
getEndcapsQids Method
getGhostSet Method The objects in the ghost set (live, do not modify)
getInvisibleObbQids Method
getInvisibleQids Method
getLabels Method The labels set for an object with setLabels, a copy; null for an object without labels
getLastCameraPose Method A copy of the last pose set with setCameraPose
getModelManager Method
getNoShadowQids Method The objects that cast no sun shadow (live, do not modify)
getOnTopQids Method The objects in the on-top set (live, do not modify)
getPickableQids Method
getSectionableQids Method
getSelectedQids Method
getVisibleObbQids Method
getVisibleQids Method
getXRayQids Method The objects in the x-ray set (live, do not modify)
highlightQuery Method Highlight certain objects
hoverOff Method Change the state of the given qid to not being hovered on anymore. In the Viewer3d tis will fade out the green glow over time.
hoverOn Method Change the state of the given qid to being hovered on. In the Viewer3d this will give the object a green glow
inverseOfVisible Method All loaded objects except the given ones; objects of GIS layers are left out
isGhosted Method Whether the given object is part of the ghost set
isOnTop Method Whether the given object is drawn on top
isPickabilityEnabled Method Whether picking honours the pickable set (settings.pickability)
isSoftOccluder Method Whether the given object is part of the soft-occluder set
isVisible Method
isXRayed Method Whether the given object is part of the x-ray set
pushState Method Replays the object states (visible, sectionable, end caps, pickable, OBB, soft occluder, x-ray, on-top, no-shadow) of objects whose geometry just arrived to …
queryToQids Method
removeAnnotation Method
removeAnnotationLayer Method Remove a layer from every viewer; the same as layer.remove()
removeBuildingStoreyExclusiveVisibilityListener Method
removeCameraPoseListener Method
removeColorListener Method
removeColorMultiListener Method Stops a listener added with addColorMultiListener
removeFromEndcapsSet Method
removeFromGhostSet Method Takes objects out of the ghost set: the ones ghosting hid are shown again, so clearing the set brings back the visibility they had; the others keep theirs. A…
removeFromNoShadowSet Method Let objects cast sun shadows again
removeFromObbVisibleSet Method
removeFromOnTopSet Method Remove objects from the on-top set (BVL NOT_ON_TOP)
removeFromPickableSet Method Remove objects from the set of pickable objects
removeFromSectionableSet Method
removeFromSelectionSet Method Remove the provided objects from the current selection
removeFromSoftOccluderSet Method Remove objects from the soft-occluder set
removeFromVisibleSet Method Remove objects from the set of visible objects. Any of these objects that are currently selected are also deselected, before the visibility listeners are not…
removeFromXRaySet Method Remove objects from the x-ray set
removeGhostListener Method
removeHoverListener Method
removeListener Method
removeListenerForAll Method
removeNoShadowListener Method
removeObbVisibilityListener Method
removeOnTopListener Method
removeSelectionListener Method
removeSetLabelsListener Method
removeSoftOccluderListener Method
removeViewer Method
removeViewerListener Method
removeViewFitListener Method
removeViewFitModelsListener Method
removeVisibilityListener Method
removeWireframeListener Method
removeXRayListener Method
replayState Method For internal use by a viewer: the state of these objects of a loaded version (what pushState replays, plus the selection and the colour overrides), to `liste…
resetAll Method Resets the internal ObjectStateManager state to the default state, which means: - Visibility is reset to the original visibility, by default this leaves out …
resetColor Method
resetLabels Method Removes all labels set with ObjectStateManager.setLabels
restoreObjectState Method Brings a captured object state back, notifying the listeners of what changes only. Objects of models that were not loaded at the capture, or are not loaded n…
setBuildingStoreysVisibility Method
setBuildingStoreysVisibleExclusive Method
setCameraPose Method Tells the camera pose listeners (the 2D view's camera cone) about this pose; sourceViewer is the viewer the pose comes from. It does not move 3D cameras: l…
setGhostSet Method Makes the ghost set exactly these objects: the others leave it (removeFromGhostSet), the new ones are ghosted
setLabels Method Change the labels of objects. Depending on the viewer labels are visualized differently.
setNoBuildingStoreysVisibility Method
setObbVisibleSet Method
setPickabilityEnabled Method Switch pickability on or off at runtime. While it is off, every visible object is pickable and add/remove/setPickableSet are ignored. Switching off makes the…
setPickableSet Method Update the set of pickable objects, replacing any previous pickable state
setPrimarySelected Method Sets the primary selection, the object whose details the application shows
setSectionableSet Method Section planes cut exactly these objects, and leave every other object whole
setSectionEndCapsSet Method End caps on exactly these objects, on no other object
setSoftOccluderSet Method Update the soft-occluder set, replacing any previous soft-occluder state
setToSelectionSet Method Replace the currently selected set by the provided set of objects
setVisibleSet Method Update the set of visible objects, replacing any previous visibily state. Objects that become hidden as a result are also deselected, before the visibility l…
setXRaySet Method Replace the x-ray set; listeners receive only the objects that were added and removed
stopTransitions Method Stops every running and waiting transition; how: default each one's onStop
transition Method Changes visibility, ghosts, the selection, the x-ray set, colours and the camera in one go, animated: the steps play back to back. Returns at once; the queri…
unregisterListener Method Removes the listener from every type it is registered for, however it was added
viewFit Method Calling this method will update all connected viewers in a way that all of them are afterwards showing at least all of the queried objects.
viewFitModels Method Fits the viewers' cameras on the given models

constructor#

TypeScript#
constructor(modelManager: ModelManager, settings?: ObjectStateManagerSettings)

Parameters#

Name Type Description
modelManager ModelManager
settings ObjectStateManagerSettings

modelManager#

TypeScript#
public readonly modelManager: ModelManager

The ModelManager this ObjectStateManager was created with, the same as ObjectStateManager.getModelManager

addAnnotation#

TypeScript#
public addAnnotation(annotation: Annotation): void

Add a single annotation. When adding large sets of annotations, use addAnnotations

Parameters#

Name Type Description
annotation Annotation The annotation to add

addAnnotationLayer#

TypeScript#
public addAnnotationLayer<D = Record<string, unknown>>(options: AnnotationLayerOptions<D>): AnnotationLayer<D>

Add a layer of template annotations to every viewer of this object state manager: one BQL query fetched in one batch and/or rows of your own, drawn by a template (Viewer3D/docs/rich-annotations-design.md §5.3). Returns at once; AnnotationLayer.ready settles when the query's rows are in. clearAnnotations() removes layers too.

Type parameters#

Name Constraint Description
D ``

Parameters#

Name Type Description
options AnnotationLayerOptions<D>

addAnnotationListener#

TypeScript#
public addAnnotationListener(target: ObjectStateListener): void

Registers for annotations and annotation layers; annotationLayerAdded is called at once for every existing layer

Parameters#

Name Type Description
target ObjectStateListener

addAnnotations#

TypeScript#
public addAnnotations(annotations: Iterable<Annotation>): void

Add multiple annotations.

Parameters#

Name Type Description
annotations Iterable<Annotation> An Iterable of the annotations to add

addBuildingStoreyExclusiveVisibilityListener#

TypeScript#
public addBuildingStoreyExclusiveVisibilityListener(target: ObjectStateListener): void

Parameters#

Name Type Description
target ObjectStateListener

addCameraPoseListener#

TypeScript#
public addCameraPoseListener(target: ObjectStateListener): void

Register a listener for camera pose changes

Parameters#

Name Type Description
target ObjectStateListener

addColorListener#

TypeScript#
public addColorListener(target: ObjectStateListener): void

Parameters#

Name Type Description
target ObjectStateListener

addColorMultiListener#

TypeScript#
public addColorMultiListener(target: ObjectStateListener): void

Listens to colour changes of several colours at once (changeColorMulti)

Parameters#

Name Type Description
target ObjectStateListener

addGhostListener#

TypeScript#
public addGhostListener(listener: ObjectStateListener): void

Listen to ghost set changes: addedToGhostSet and removedFromGhostSet of ObjectStateListener

Parameters#

Name Type Description
listener ObjectStateListener

addHoverListener#

TypeScript#
public addHoverListener(target: ObjectStateListener): void

Parameters#

Name Type Description
target ObjectStateListener

addListener#

TypeScript#
public addListener(type: ObjectStateListenerType, target: ObjectStateListener): void

Parameters#

Name Type Description
type ObjectStateListenerType
target ObjectStateListener

addListenerForAll#

TypeScript#
public addListenerForAll(target: ObjectStateListener): void

Registers the listener for every ObjectStateListenerType

Parameters#

Name Type Description
target ObjectStateListener

addLoadedListener#

TypeScript#
public addLoadedListener(target: ObjectStateListener): void

Parameters#

Name Type Description
target ObjectStateListener

addNoShadowListener#

TypeScript#
public addNoShadowListener(listener: ObjectStateListener): void

Listen to no-shadow set changes: addedToNoShadowSet and removedFromNoShadowSet of ObjectStateListener

Parameters#

Name Type Description
listener ObjectStateListener

addObbVisibilityListener#

TypeScript#
public addObbVisibilityListener(target: ObjectStateListener): void

Parameters#

Name Type Description
target ObjectStateListener

addOnTopListener#

TypeScript#
public addOnTopListener(listener: ObjectStateListener): void

Listen to on-top set changes: addedToOnTopSet and removedFromOnTopSet of ObjectStateListener

Parameters#

Name Type Description
listener ObjectStateListener

addPickabilityListener#

TypeScript#
public addPickabilityListener(target: ObjectStateListener): void

Parameters#

Name Type Description
target ObjectStateListener

addSectionabilityListener#

TypeScript#
public addSectionabilityListener(target: ObjectStateListener): void

Parameters#

Name Type Description
target ObjectStateListener

addSectionEndcapListener#

TypeScript#
public addSectionEndcapListener(target: ObjectStateListener): void

Parameters#

Name Type Description
target ObjectStateListener

addSelectionListener#

TypeScript#
public addSelectionListener(target: ObjectStateListener): void

Parameters#

Name Type Description
target ObjectStateListener

addSetLabelsListener#

TypeScript#
public addSetLabelsListener(target: ObjectStateListener): void

Parameters#

Name Type Description
target ObjectStateListener

addSoftOccluderListener#

TypeScript#
public addSoftOccluderListener(target: ObjectStateListener): void

Parameters#

Name Type Description
target ObjectStateListener

addToEndcapsSet#

TypeScript#
public addToEndcapsSet(query: string | Iterable<Qid, any, any>, force?: boolean, type?: string): Promise<void>

Objects whose cut surfaces section planes close with end caps (all objects are by default); resetAll does not change it

Parameters#

Name Type Description
query string | Iterable<Qid, any, any>
force boolean
type string

addToGhostSet#

TypeScript#
public addToGhostSet(query: string | Iterable<Qid, any, any>, type?: string): Promise<void>

Ghost objects (docs/clash-detection-ui-design.md §9.9 item 1): the viewers draw them only with the x-ray overlay (the current XRayVisualization), not in the normal pass, so they show where they are without hiding what is behind them, and they cannot be picked. Ghosting hides the visible ones through the visible set (which deselects them); an object that was hidden already stays hidden and is not drawn as a ghost. Unlike the rest of the x-ray set, a ghost is drawn while hidden.

Parameters#

Name Type Description
query string | Iterable<Qid, any, any> Either a query or Iterable of Qid
type string Always "BIM"

addToNoShadowSet#

TypeScript#
public addToNoShadowSet(query: string | Iterable<Qid, any, any>, force?: boolean, type?: string): Promise<void>

Add objects to the no-shadow set: the 3D viewer leaves them out of its sun shadows, even when shown. Viewer3d fills it with the non-physical types of the models it loads (spaces, openings, virtual elements, spatial zones, annotations, grids).

Parameters#

Name Type Description
query string | Iterable<Qid, any, any> Either a query or Iterable of Qid
force boolean Notify listeners even for objects that were already in the set
type string Always "BIM"

addToObbVisibleSet#

TypeScript#
public addToObbVisibleSet(query: string | Iterable<Qid, any, any>, force?: boolean, type?: string): Promise<void>

Parameters#

Name Type Description
query string | Iterable<Qid, any, any>
force boolean
type string

addToOnTopSet#

TypeScript#
public addToOnTopSet(query: string | Iterable<Qid, any, any>, force?: boolean, type?: string): Promise<void>

Add objects to the on-top set (BVL ON_TOP). The 3D viewer draws them in front of every other object, in their own colours, and picks them first. Among each other they are still depth-tested, so their own shape reads normally. A hidden object stays in the set.

Parameters#

Name Type Description
query string | Iterable<Qid, any, any> Either a query or Iterable of Qid
force boolean Notify listeners even for objects that were already in the set
type string Always "BIM"

addToPickableSet#

TypeScript#
public addToPickableSet(query: string | Iterable<Qid, any, any>, force?: boolean, type?: string): Promise<void>

Add the provided objects to the currently pickable set of objects

Parameters#

Name Type Description
query string | Iterable<Qid, any, any> Either a query or Iterable of Qid
force boolean Whether to force this change, when forced, any viewer-specific settings are overruled
type string Always "BIM"

addToSectionableSet#

TypeScript#
public addToSectionableSet(query: string | Iterable<Qid, any, any>, force?: boolean, type?: string): Promise<void>

Objects whose geometry section planes cut (every object of a model is by default, a GIS layer's object is not)

Parameters#

Name Type Description
query string | Iterable<Qid, any, any>
force boolean
type string

addToSelectionSet#

TypeScript#
public addToSelectionSet(query: string | Iterable<Qid, any, any>, type?: string): Promise<void>

Add a set of objects to the selected set

Parameters#

Name Type Description
query string | Iterable<Qid, any, any>
type string

addToSoftOccluderSet#

TypeScript#
public addToSoftOccluderSet(query: string | Iterable<Qid, any, any>, force?: boolean, type?: string): Promise<void>

Add objects to the soft-occluder set. Soft occluders (typically walls, roofs and slabs) gradually fade out - and become pick-through - as the camera approaches them, so users can look inside a building without hiding objects manually.

Parameters#

Name Type Description
query string | Iterable<Qid, any, any> Either a query or Iterable of Qid
force boolean Whether to force this change, when forced, any viewer-specific settings are overruled
type string Always "BIM"

addToVisibleSet#

TypeScript#
public addToVisibleSet(query: string | Iterable<Qid, any, any>, force?: boolean, type?: string): Promise<void>

Add the provided objects to the currently visible set of objects *

Parameters#

Name Type Description
query string | Iterable<Qid, any, any> Either a query or Iterable of Qid *
force boolean Whether to force this change, when forced, any viewer-specific settings are overruled *
type string Always "BIM"

addToXRaySet#

TypeScript#
public addToXRaySet(query: string | Iterable<Qid, any, any>, force?: boolean, type?: string): Promise<void>

Add objects to the x-ray set. The 3D viewer draws these objects with the x-ray overlay: translucent faces and edges drawn through everything in front of them, so hidden interiors (a duct above a ceiling, a column inside a wall) show. The set is independent of selection. The objects keep their normal appearance underneath, keep their pickability, and are clipped by section planes. A hidden object stays in the set but is not drawn until it is shown again. The look is set with Viewer3d.setXRayVisualization. The 2D viewer ignores the set.

Parameters#

Name Type Description
query string | Iterable<Qid, any, any> Either a query or Iterable of Qid
force boolean Notify listeners even for objects that were already in the set
type string Always "BIM"

addViewer#

TypeScript#
public addViewer(viewer: object): void

Announces a viewer to the ViewerListeners; the Viewer2d announces itself once its models are in

Parameters#

Name Type Description
viewer object

addViewerListener#

TypeScript#
public addViewerListener(target: ViewerListener): void

Registers for viewers announcing themselves (addViewer)

Parameters#

Name Type Description
target ViewerListener

addViewFitListener#

TypeScript#
public addViewFitListener(target: ObjectStateListener): void

Parameters#

Name Type Description
target ObjectStateListener

addViewFitModelsListener#

TypeScript#
public addViewFitModelsListener(target: ObjectStateListener): void

Parameters#

Name Type Description
target ObjectStateListener

addVisibilityListener#

TypeScript#
public addVisibilityListener(target: ObjectStateListener): void

Parameters#

Name Type Description
target ObjectStateListener

addWireframeListener#

TypeScript#
public addWireframeListener(listener: ObjectStateListener): void

Listen for wireframe resets when BVL results or resetAll restore defaults.

Parameters#

Name Type Description
listener ObjectStateListener

addXRayListener#

TypeScript#
public addXRayListener(listener: ObjectStateListener): void

Listen to x-ray set changes: addedToXRaySet, removedFromXRaySet and setXRaySet of ObjectStateListener

Parameters#

Name Type Description
listener ObjectStateListener

captureObjectState#

TypeScript#
public captureObjectState(): ObjectStateSnapshot

The object state as it is now, as a value to give back to restoreObjectState later: the loaded models, which objects are visible, the colour overrides, the on-top set, the objects section planes do not cut and the objects that cannot be picked (with whether pickability is on), and the x-ray set. Not the selection, the labels or the annotations. A tool that takes the view over for a while (a check, the clash view) captures it when it starts and restores it when it ends.

Returns#

A new value: copies, not the live sets

castsShadow#

TypeScript#
public castsShadow(qid: Qid): boolean

Whether the given object casts sun shadows (true unless it is in the no-shadow set)

Parameters#

Name Type Description
qid Qid

changeColor#

TypeScript#
public changeColor(query: string | Iterable<Qid, any, any>, color: Color): Promise<void>

Change the color of a given set of objects. When changing the colors of multiple sets of objects, use the more efficient changeColorMulti method.

Parameters#

Name Type Description
query string | Iterable<Qid, any, any> A query or iterable of Qids, the objects to change color
color Color The new color, many representations are supported including "#00FF00", "#F0", "[r, g, b, a]" and "red"

Returns#

A Promise that triggers when all connected listeners have applied the change

changeColorMulti#

TypeScript#
public changeColorMulti(changes: ColorChangeMap, colorQueries?: Map<string, unknown> | null, autoDispose?: boolean): Promise<void>

Change the colors of a given set of objects.

Parameters#

Name Type Description
changes ColorChangeMap A ColorChangeMap that contains color change information potentialle for many different colors/qids
colorQueries Map<string, unknown> | null The queries behind the colours (hex8 colour → query), passed on to the listeners' colorChangedMulti
autoDispose boolean Whether to dispose changes once applied, default true

Returns#

A Promise that triggers when all connected listeners have applied the change

clearAnnotations#

TypeScript#
public clearAnnotations(options?: unknown): Promise<void>

Removes all annotations and annotation layers, in every viewer

Parameters#

Name Type Description
options unknown

clearGhostSet#

TypeScript#
public clearGhostSet(type?: string): Promise<void>

Empties the ghost set, bringing back the visibility ghosting took

Parameters#

Name Type Description
type string

clearOnTopSet#

TypeScript#
public clearOnTopSet(type?: string): Promise<void>

Empty the on-top set

Parameters#

Name Type Description
type string

clearSelection#

TypeScript#
public clearSelection(type?: string): Promise<void>

Clear the current selection

Parameters#

Name Type Description
type string

clearXRaySet#

TypeScript#
public clearXRaySet(type?: string): Promise<void>

Empty the x-ray set

Parameters#

Name Type Description
type string

getAnnotationLayers#

TypeScript#
public getAnnotationLayers(): (AnnotationLayer<unknown>)[]

The annotation layers, in the order they were added

getColor#

TypeScript#
public getColor(qid: Qid): TinyColor | undefined

Parameters#

Name Type Description
qid Qid

Returns#

The colour override of the object, undefined when it shows its own colour

getColorOverrides#

TypeScript#
public getColorOverrides(): QidMap<TinyColor>

Returns#

A copy of all colour overrides, qid → colour

getEndcapsQids#

TypeScript#
public getEndcapsQids(): QidSet

Returns#

The objects that get end caps. The returned Set must be treated as read-only.

getGhostSet#

TypeScript#
public getGhostSet(): QidSet

The objects in the ghost set (live, do not modify)

getInvisibleObbQids#

TypeScript#
public getInvisibleObbQids(): QidSet

getInvisibleQids#

TypeScript#
public getInvisibleQids(): QidSet

Returns#

A Set of the QIDS that are currently invisible. The returned Set must be treated as read-only.

getLabels#

TypeScript#
public getLabels(qid: Qid): (string)[] | null

The labels set for an object with setLabels, a copy; null for an object without labels

Parameters#

Name Type Description
qid Qid

getLastCameraPose#

TypeScript#
public getLastCameraPose(): Pose

A copy of the last pose set with setCameraPose

getModelManager#

TypeScript#
public getModelManager(): ModelManager

Returns#

The ModelManager connected to this ObjectStateManager

getNoShadowQids#

TypeScript#
public getNoShadowQids(): QidSet

The objects that cast no sun shadow (live, do not modify)

getOnTopQids#

TypeScript#
public getOnTopQids(): QidSet

The objects in the on-top set (live, do not modify)

getPickableQids#

TypeScript#
public getPickableQids(): QidSet

Returns#

The pickable objects, which picking honours only while pickability is on (while it is off every visible object is pickable). The returned Set must be treated as read-only.

getSectionableQids#

TypeScript#
public getSectionableQids(): QidSet

Returns#

The objects section planes cut. The returned Set must be treated as read-only.

getSelectedQids#

TypeScript#
public getSelectedQids(): QidSet

Returns#

A Set of the QIDS that are currently selected. The returned Set must be treated as read-only.

getVisibleObbQids#

TypeScript#
public getVisibleObbQids(): QidSet

getVisibleQids#

TypeScript#
public getVisibleQids(): QidSet

Returns#

A Set of the QIDS that are currently visible. The returned Set must be treated as read-only.

getXRayQids#

TypeScript#
public getXRayQids(): QidSet

The objects in the x-ray set (live, do not modify)

highlightQuery#

TypeScript#
public highlightQuery(query: string | Iterable<Qid, any, any>, highlightColor: Color, backgroundColor: Color): Promise<unknown>
Warning

Deprecated: This will be removed in the future, as it is to opinionated and can easily be constructed using the changeColorMulti method.

Highlight certain objects

Parameters#

Name Type Description
query string | Iterable<Qid, any, any>
highlightColor Color
backgroundColor Color

hoverOff#

TypeScript#
public hoverOff(qid: Qid): void

Change the state of the given qid to not being hovered on anymore. In the Viewer3d tis will fade out the green glow over time.

Parameters#

Name Type Description
qid Qid The Qid of the object not being hovered over anymore

hoverOn#

TypeScript#
public hoverOn(qid: Qid, screenspaceLocation?: vec2): void

Change the state of the given qid to being hovered on. In the Viewer3d this will give the object a green glow

Parameters#

Name Type Description
qid Qid The Qid of the object being hovered over
screenspaceLocation vec2 The screen space location of the hover event. This is not relevant/available in all situations and can be null

inverseOfVisible#

TypeScript#
public inverseOfVisible(qids: { has: (qid: Qid) => boolean } | null): QidSet

All loaded objects except the given ones; objects of GIS layers are left out

Parameters#

Name Type Description
qids { has: (qid: Qid) => boolean } | null

isGhosted#

TypeScript#
public isGhosted(qid: Qid): boolean

Whether the given object is part of the ghost set

Parameters#

Name Type Description
qid Qid

isOnTop#

TypeScript#
public isOnTop(qid: Qid): boolean

Whether the given object is drawn on top

Parameters#

Name Type Description
qid Qid

isPickabilityEnabled#

TypeScript#
public isPickabilityEnabled(): boolean

Whether picking honours the pickable set (settings.pickability)

isSoftOccluder#

TypeScript#
public isSoftOccluder(qid: Qid): boolean

Whether the given object is part of the soft-occluder set

Parameters#

Name Type Description
qid Qid

isVisible#

TypeScript#
public isVisible(qid: Qid): boolean

Parameters#

Name Type Description
qid Qid

Returns#

Whether the given Qid is visible

isXRayed#

TypeScript#
public isXRayed(qid: Qid): boolean

Whether the given object is part of the x-ray set

Parameters#

Name Type Description
qid Qid

pushState#

TypeScript#
public pushState(vid: string, oids: Iterable<number>): Promise<void>

Replays the object states (visible, sectionable, end caps, pickable, OBB, soft occluder, x-ray, on-top, no-shadow) of objects whose geometry just arrived to the listeners, with StateChangeOptions.streaming. A viewer calls it as a model's geometry streams in, so states set before the geometry was there are applied to it

Parameters#

Name Type Description
vid string The model the geometry belongs to
oids Iterable<number> The objects whose geometry arrived

queryToQids#

TypeScript#
public queryToQids(query: string | Iterable<Qid, any, any>): Promise<QidSet>

Parameters#

Name Type Description
query string | Iterable<Qid, any, any>

removeAnnotation#

TypeScript#
public removeAnnotation(annotation: Annotation): Promise<void>

Parameters#

Name Type Description
annotation Annotation

removeAnnotationLayer#

TypeScript#
public removeAnnotationLayer(layer: AnnotationLayer<unknown>): void

Remove a layer from every viewer; the same as layer.remove()

Parameters#

Name Type Description
layer AnnotationLayer<unknown>

removeBuildingStoreyExclusiveVisibilityListener#

TypeScript#
public removeBuildingStoreyExclusiveVisibilityListener(target: ObjectStateListener): void

Parameters#

Name Type Description
target ObjectStateListener

removeCameraPoseListener#

TypeScript#
public removeCameraPoseListener(target: ObjectStateListener): void

Parameters#

Name Type Description
target ObjectStateListener

removeColorListener#

TypeScript#
public removeColorListener(target: ObjectStateListener): void

Parameters#

Name Type Description
target ObjectStateListener

removeColorMultiListener#

TypeScript#
public removeColorMultiListener(target: ObjectStateListener): void

Stops a listener added with addColorMultiListener

Parameters#

Name Type Description
target ObjectStateListener

removeFromEndcapsSet#

TypeScript#
public removeFromEndcapsSet(query: string | Iterable<Qid, any, any>, force?: boolean, type?: string): Promise<void>

Parameters#

Name Type Description
query string | Iterable<Qid, any, any>
force boolean
type string

removeFromGhostSet#

TypeScript#
public removeFromGhostSet(query: string | Iterable<Qid, any, any>, type?: string): Promise<void>

Takes objects out of the ghost set: the ones ghosting hid are shown again, so clearing the set brings back the visibility they had; the others keep theirs. An object someone showed or hid meanwhile keeps that.

Parameters#

Name Type Description
query string | Iterable<Qid, any, any>
type string

removeFromNoShadowSet#

TypeScript#
public removeFromNoShadowSet(query: string | Iterable<Qid, any, any>, force?: boolean, type?: string): Promise<void>

Let objects cast sun shadows again

Parameters#

Name Type Description
query string | Iterable<Qid, any, any>
force boolean
type string

removeFromObbVisibleSet#

TypeScript#
public removeFromObbVisibleSet(query: string | Iterable<Qid, any, any>, force?: boolean, type?: string): Promise<void>

Parameters#

Name Type Description
query string | Iterable<Qid, any, any>
force boolean
type string

removeFromOnTopSet#

TypeScript#
public removeFromOnTopSet(query: string | Iterable<Qid, any, any>, force?: boolean, type?: string): Promise<void>

Remove objects from the on-top set (BVL NOT_ON_TOP)

Parameters#

Name Type Description
query string | Iterable<Qid, any, any>
force boolean
type string

removeFromPickableSet#

TypeScript#
public removeFromPickableSet(query: string | Iterable<Qid, any, any>, force?: boolean, type?: string): Promise<void>

Remove objects from the set of pickable objects

Parameters#

Name Type Description
query string | Iterable<Qid, any, any> Either a query or Iterable of Qid
force boolean Whether to force this change, when forced, any viewer-specific settings are overruled
type string Always "BIM"

removeFromSectionableSet#

TypeScript#
public removeFromSectionableSet(query: string | Iterable<Qid, any, any>, force?: boolean, type?: string): Promise<void>

Parameters#

Name Type Description
query string | Iterable<Qid, any, any>
force boolean
type string

removeFromSelectionSet#

TypeScript#
public removeFromSelectionSet(query: string | Iterable<Qid, any, any>, type?: string): Promise<void>

Remove the provided objects from the current selection

Parameters#

Name Type Description
query string | Iterable<Qid, any, any>
type string

removeFromSoftOccluderSet#

TypeScript#
public removeFromSoftOccluderSet(query: string | Iterable<Qid, any, any>, force?: boolean, type?: string): Promise<void>

Remove objects from the soft-occluder set

Parameters#

Name Type Description
query string | Iterable<Qid, any, any> Either a query or Iterable of Qid
force boolean Whether to force this change, when forced, any viewer-specific settings are overruled
type string Always "BIM"

removeFromVisibleSet#

TypeScript#
public removeFromVisibleSet(query: string | Iterable<Qid, any, any>, force?: boolean, type?: string): Promise<void>

Remove objects from the set of visible objects. Any of these objects that are currently selected are also deselected, before the visibility listeners are notified. The returned promise resolves after both have completed.

Parameters#

Name Type Description
query string | Iterable<Qid, any, any> Either a query or Iterable of Qid
force boolean Whether to force this change, when forced, any viewer-specific settings are overruled
type string Always "BIM"

removeFromXRaySet#

TypeScript#
public removeFromXRaySet(query: string | Iterable<Qid, any, any>, force?: boolean, type?: string): Promise<void>

Remove objects from the x-ray set

Parameters#

Name Type Description
query string | Iterable<Qid, any, any> Either a query or Iterable of Qid
force boolean Notify listeners even for objects that were not in the set
type string Always "BIM"

removeGhostListener#

TypeScript#
public removeGhostListener(listener: ObjectStateListener): void

Parameters#

Name Type Description
listener ObjectStateListener

removeHoverListener#

TypeScript#
public removeHoverListener(target: ObjectStateListener): void

Parameters#

Name Type Description
target ObjectStateListener

removeListener#

TypeScript#
public removeListener(type: ObjectStateListenerType, target: ObjectStateListener): void

Parameters#

Name Type Description
type ObjectStateListenerType
target ObjectStateListener

removeListenerForAll#

TypeScript#
public removeListenerForAll(target: ObjectStateListener): void

Parameters#

Name Type Description
target ObjectStateListener

removeNoShadowListener#

TypeScript#
public removeNoShadowListener(listener: ObjectStateListener): void

Parameters#

Name Type Description
listener ObjectStateListener

removeObbVisibilityListener#

TypeScript#
public removeObbVisibilityListener(target: ObjectStateListener): void

Parameters#

Name Type Description
target ObjectStateListener

removeOnTopListener#

TypeScript#
public removeOnTopListener(listener: ObjectStateListener): void

Parameters#

Name Type Description
listener ObjectStateListener

removeSelectionListener#

TypeScript#
public removeSelectionListener(target: ObjectStateListener): void

Parameters#

Name Type Description
target ObjectStateListener

removeSetLabelsListener#

TypeScript#
public removeSetLabelsListener(target: ObjectStateListener): void

Parameters#

Name Type Description
target ObjectStateListener

removeSoftOccluderListener#

TypeScript#
public removeSoftOccluderListener(target: ObjectStateListener): void

Parameters#

Name Type Description
target ObjectStateListener

removeViewer#

TypeScript#
public removeViewer(viewer: object): void

Parameters#

Name Type Description
viewer object

removeViewerListener#

TypeScript#
public removeViewerListener(target: ViewerListener): void

Parameters#

Name Type Description
target ViewerListener

removeViewFitListener#

TypeScript#
public removeViewFitListener(target: ObjectStateListener): void

Parameters#

Name Type Description
target ObjectStateListener

removeViewFitModelsListener#

TypeScript#
public removeViewFitModelsListener(target: ObjectStateListener): void

Parameters#

Name Type Description
target ObjectStateListener

removeVisibilityListener#

TypeScript#
public removeVisibilityListener(target: ObjectStateListener): void

Parameters#

Name Type Description
target ObjectStateListener

removeWireframeListener#

TypeScript#
public removeWireframeListener(listener: ObjectStateListener): void

Parameters#

Name Type Description
listener ObjectStateListener

removeXRayListener#

TypeScript#
public removeXRayListener(listener: ObjectStateListener): void

Parameters#

Name Type Description
listener ObjectStateListener

replayState#

TypeScript#
public replayState(listener: ObjectStateListener, vid: string, oids: Iterable<number>): Promise<void>

For internal use by a viewer: the state of these objects of a loaded version (what pushState replays, plus the selection and the colour overrides), to listener alone. A viewer that shows a model another viewer on the ModelManager loaded is brought up to date with it

Parameters#

Name Type Description
listener ObjectStateListener
vid string
oids Iterable<number>

resetAll#

TypeScript#
public resetAll(): Promise<void>

Resets the internal ObjectStateManager state to the default state, which means:

  • Visibility is reset to the original visibility, by default this leaves out the types IFCOPENINGELEMENT, IFCPROJECT, IFCBUILDING, IFCBUILDINGSTOREY and IFCZONE
  • Color, all objects are reset to their original color
  • Selection, any selected objects will be unselected

All of these changes trigger the regular listeners and therefore the connected viewers.

resetColor#

TypeScript#
public resetColor(query: string | Iterable<Qid, any, any>): Promise<void>

Parameters#

Name Type Description
query string | Iterable<Qid, any, any> A query or iterable of Qids, the objects to reset color

Returns#

A Promise that triggers when all connected listeners have applied the change

resetLabels#

TypeScript#
public resetLabels(): Promise<void>

Removes all labels set with ObjectStateManager.setLabels

restoreObjectState#

TypeScript#
public restoreObjectState(snapshot: ObjectStateSnapshot, options?: { keepColorsOf?: Iterable<Qid, any, any>; keepVisibility?: boolean }): Promise<void>

Brings a captured object state back, notifying the listeners of what changes only. Objects of models that were not loaded at the capture, or are not loaded now, are left alone: a model loaded since keeps its own state.

Parameters#

Name Type Description
snapshot ObjectStateSnapshot
options { keepColorsOf?: Iterable<Qid, any, any>; keepVisibility?: boolean } keepVisibility: leave the visible set as it is; keepColorsOf: leave the colours of these objects as they are (what a tool about to take over colours itself, so switching does not flash the model in between)

Returns#

Resolves when the listeners have applied the changes

setBuildingStoreysVisibility#

TypeScript#
public setBuildingStoreysVisibility(buildingStoreyQids: Iterable<Qid>, visible: boolean): Promise<void>

Parameters#

Name Type Description
buildingStoreyQids Iterable<Qid>
visible boolean

setBuildingStoreysVisibleExclusive#

TypeScript#
public setBuildingStoreysVisibleExclusive(query: string | Iterable<Qid, any, any>, hideOpenings?: boolean): Promise<unknown>

Parameters#

Name Type Description
query string | Iterable<Qid, any, any>
hideOpenings boolean

setCameraPose#

TypeScript#
public setCameraPose(sourceViewer: unknown, pose: Pose): void

Tells the camera pose listeners (the 2D view's camera cone) about this pose; sourceViewer is the viewer the pose comes from. It does not move 3D cameras: link those with Viewer3d.linkCamera

Parameters#

Name Type Description
sourceViewer unknown
pose Pose

setGhostSet#

TypeScript#
public setGhostSet(query: string | Iterable<Qid, any, any>, type?: string): Promise<void>

Makes the ghost set exactly these objects: the others leave it (removeFromGhostSet), the new ones are ghosted

Parameters#

Name Type Description
query string | Iterable<Qid, any, any>
type string

setLabels#

TypeScript#
public setLabels(labels: (Label)[]): Promise<void>

Change the labels of objects. Depending on the viewer labels are visualized differently.

Parameters#

Name Type Description
labels (Label)[] An array of Label

setNoBuildingStoreysVisibility#

TypeScript#
public setNoBuildingStoreysVisibility(visible: boolean): Promise<void>

Parameters#

Name Type Description
visible boolean

setObbVisibleSet#

TypeScript#
public setObbVisibleSet(query: string | Iterable<Qid, any, any>, force?: boolean, type?: string): Promise<void>

Parameters#

Name Type Description
query string | Iterable<Qid, any, any>
force boolean
type string

setPickabilityEnabled#

TypeScript#
public setPickabilityEnabled(enabled: boolean): Promise<void>

Switch pickability on or off at runtime. While it is off, every visible object is pickable and add/remove/setPickableSet are ignored. Switching off makes the unpickable objects pickable again. A BVL result with PICKABLE/UNPICKABLE switches it on by itself, until the next result is shown.

Parameters#

Name Type Description
enabled boolean

setPickableSet#

TypeScript#
public setPickableSet(query: string | Iterable<Qid, any, any>, force?: boolean, type?: string): Promise<void>

Update the set of pickable objects, replacing any previous pickable state

Parameters#

Name Type Description
query string | Iterable<Qid, any, any> Either a query or Iterable of Qid
force boolean Whether to force this change, when forced, any viewer-specific settings are overruled
type string Always "BIM"

setPrimarySelected#

TypeScript#
public setPrimarySelected(qid: Qid | null): Promise<void>

Sets the primary selection, the object whose details the application shows

Parameters#

Name Type Description
qid Qid | null

setSectionableSet#

TypeScript#
public setSectionableSet(query: string | Iterable<Qid, any, any>, force?: boolean, type?: string): Promise<void>

Section planes cut exactly these objects, and leave every other object whole

Parameters#

Name Type Description
query string | Iterable<Qid, any, any>
force boolean
type string

setSectionEndCapsSet#

TypeScript#
public setSectionEndCapsSet(query: string | Iterable<Qid, any, any>, force?: boolean, type?: string): Promise<void>

End caps on exactly these objects, on no other object

Parameters#

Name Type Description
query string | Iterable<Qid, any, any>
force boolean
type string

setSoftOccluderSet#

TypeScript#
public setSoftOccluderSet(query: string | Iterable<Qid, any, any>, force?: boolean, type?: string): Promise<void>

Update the soft-occluder set, replacing any previous soft-occluder state

Parameters#

Name Type Description
query string | Iterable<Qid, any, any> Either a query or Iterable of Qid
force boolean Whether to force this change, when forced, any viewer-specific settings are overruled
type string Always "BIM"

setToSelectionSet#

TypeScript#
public setToSelectionSet(query: string | Iterable<Qid, any, any>, type?: string, data?: unknown): Promise<void>

Replace the currently selected set by the provided set of objects

Parameters#

Name Type Description
query string | Iterable<Qid, any, any>
type string
data unknown

setVisibleSet#

TypeScript#
public setVisibleSet(query: string | Iterable<Qid, any, any>, force?: boolean, type?: string): Promise<void>

Update the set of visible objects, replacing any previous visibily state. Objects that become hidden as a result are also deselected, before the visibility listeners are notified. The returned promise resolves after both have completed.

Parameters#

Name Type Description
query string | Iterable<Qid, any, any> Either a query or Iterable of Qid
force boolean Whether to force this change, when forced, any viewer-specific settings are overruled
type string Always "BIM"

setXRaySet#

TypeScript#
public setXRaySet(query: string | Iterable<Qid, any, any>, force?: boolean, type?: string): Promise<void>

Replace the x-ray set; listeners receive only the objects that were added and removed

Parameters#

Name Type Description
query string | Iterable<Qid, any, any> Either a query or Iterable of Qid
force boolean Notify listeners even when nothing changed
type string Always "BIM"

stopTransitions#

TypeScript#
public stopTransitions(how?: TransitionEnd): void

Stops every running and waiting transition; how: default each one's onStop

Parameters#

Name Type Description
how TransitionEnd

transition#

TypeScript#
public transition(steps: TransitionStep | (TransitionStep)[], options?: TransitionOptions): Transition

Changes visibility, ghosts, the selection, the x-ray set, colours and the camera in one go, animated: the steps play back to back. Returns at once; the queries resolve first. The state changes in the manager when a step starts, the picture catches up over its duration. Viewers that do not animate (Viewer3D, Viewer2D) receive each step through their regular methods when it starts (docs/viewer-state-transitions-design.md)

JavaScript#
// Hide everything but the doors over 500 ms, then fly to one door in 1.2 s
const t = osm.transition([{visible: "type = IFCDOOR"}, {camera: {fit: [doorQid]}, duration: 1200}]);
await t.finished;

Parameters#

Name Type Description
steps TransitionStep | (TransitionStep)[]
options TransitionOptions

Exceptions#

  • TypeError for an unknown key or an invalid value in a step or the options

unregisterListener#

TypeScript#
public unregisterListener(target: ObjectStateListener): void

Removes the listener from every type it is registered for, however it was added

Parameters#

Name Type Description
target ObjectStateListener

viewFit#

TypeScript#
public viewFit(query: string | Iterable<Qid, any, any>, options: ViewFitOptions): Promise<void>

Calling this method will update all connected viewers in a way that all of them are afterwards showing at least all of the queried objects.

Parameters#

Name Type Description
query string | Iterable<Qid, any, any> A query or iterable of Qids, the objects to reset color
options ViewFitOptions

viewFitModels#

TypeScript#
public viewFitModels(versionUuids: Iterable<string>, options?: ViewFitOptions): Promise<void>

Fits the viewers' cameras on the given models

Parameters#

Name Type Description
versionUuids Iterable<string>
options ViewFitOptions