Reference·JavaScript · @bimworks/viewercommonJavaScript ObjectStateManager
Class in @bimworks/viewercommon.
API catalogue · @bimworks/viewercommon · Class
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#
Parameters#
modelManager#
The ModelManager this ObjectStateManager was created with, the same as ObjectStateManager.getModelManager
addAnnotation#
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#
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#
Registers for annotations and annotation layers; annotationLayerAdded is called at once for every existing layer
Parameters#
addAnnotations#
public addAnnotations(annotations: Iterable<Annotation>): void
Add multiple annotations.
Parameters#
| Name |
Type |
Description |
annotations |
Iterable<Annotation> |
An Iterable of the annotations to add |
addBuildingStoreyExclusiveVisibilityListener#
Parameters#
addCameraPoseListener#
Register a listener for camera pose changes
Parameters#
addColorListener#
Parameters#
addColorMultiListener#
Listens to colour changes of several colours at once (changeColorMulti)
Parameters#
addGhostListener#
Listen to ghost set changes: addedToGhostSet and removedFromGhostSet of ObjectStateListener
Parameters#
addHoverListener#
Parameters#
addListener#
Parameters#
addListenerForAll#
Registers the listener for every ObjectStateListenerType
Parameters#
addLoadedListener#
Parameters#
addNoShadowListener#
Listen to no-shadow set changes: addedToNoShadowSet and removedFromNoShadowSet of ObjectStateListener
Parameters#
addObbVisibilityListener#
Parameters#
addOnTopListener#
Listen to on-top set changes: addedToOnTopSet and removedFromOnTopSet of ObjectStateListener
Parameters#
addPickabilityListener#
Parameters#
addSectionabilityListener#
Parameters#
addSectionEndcapListener#
Parameters#
addSelectionListener#
Parameters#
addSetLabelsListener#
Parameters#
addSoftOccluderListener#
Parameters#
addToEndcapsSet#
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#
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#
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#
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#
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#
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#
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#
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#
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#
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#
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#
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#
Registers for viewers announcing themselves (addViewer)
Parameters#
addViewFitListener#
Parameters#
addViewFitModelsListener#
Parameters#
addVisibilityListener#
Parameters#
addWireframeListener#
Listen for wireframe resets when BVL results or resetAll restore defaults.
Parameters#
addXRayListener#
Listen to x-ray set changes: addedToXRaySet, removedFromXRaySet and setXRaySet of ObjectStateListener
Parameters#
captureObjectState#
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#
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#
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#
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#
public clearAnnotations(options?: unknown): Promise<void>
Removes all annotations and annotation layers, in every viewer
Parameters#
| Name |
Type |
Description |
options |
unknown |
|
clearGhostSet#
public clearGhostSet(type?: string): Promise<void>
Empties the ghost set, bringing back the visibility ghosting took
Parameters#
| Name |
Type |
Description |
type |
string |
|
clearOnTopSet#
public clearOnTopSet(type?: string): Promise<void>
Empty the on-top set
Parameters#
| Name |
Type |
Description |
type |
string |
|
clearSelection#
public clearSelection(type?: string): Promise<void>
Clear the current selection
Parameters#
| Name |
Type |
Description |
type |
string |
|
clearXRaySet#
public clearXRaySet(type?: string): Promise<void>
Empty the x-ray set
Parameters#
| Name |
Type |
Description |
type |
string |
|
getAnnotationLayers#
The annotation layers, in the order they were added
getColor#
Parameters#
| Name |
Type |
Description |
qid |
Qid |
|
Returns#
The colour override of the object, undefined when it shows its own colour
getColorOverrides#
Returns#
A copy of all colour overrides, qid → colour
getEndcapsQids#
public getEndcapsQids(): QidSet
Returns#
The objects that get end caps. The returned Set must be treated as read-only.
getGhostSet#
The objects in the ghost set (live, do not modify)
getInvisibleObbQids#
public getInvisibleObbQids(): QidSet
getInvisibleQids#
public getInvisibleQids(): QidSet
Returns#
A Set of the QIDS that are currently invisible. The returned Set must be treated as read-only.
getLabels#
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#
public getLastCameraPose(): Pose
A copy of the last pose set with setCameraPose
getModelManager#
Returns#
The ModelManager connected to this ObjectStateManager
getNoShadowQids#
public getNoShadowQids(): QidSet
The objects that cast no sun shadow (live, do not modify)
getOnTopQids#
The objects in the on-top set (live, do not modify)
getPickableQids#
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#
public getSectionableQids(): QidSet
Returns#
The objects section planes cut. The returned Set must be treated as read-only.
getSelectedQids#
public getSelectedQids(): QidSet
Returns#
A Set of the QIDS that are currently selected. The returned Set must be treated as read-only.
getVisibleObbQids#
public getVisibleObbQids(): QidSet
getVisibleQids#
public getVisibleQids(): QidSet
Returns#
A Set of the QIDS that are currently visible. The returned Set must be treated as read-only.
getXRayQids#
The objects in the x-ray set (live, do not modify)
highlightQuery#
public highlightQuery(query: string | Iterable<Qid, any, any>, highlightColor: Color, backgroundColor: Color): Promise<unknown>
WarningDeprecated: 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#
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#
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#
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#
public isGhosted(qid: Qid): boolean
Whether the given object is part of the ghost set
Parameters#
| Name |
Type |
Description |
qid |
Qid |
|
isOnTop#
public isOnTop(qid: Qid): boolean
Whether the given object is drawn on top
Parameters#
| Name |
Type |
Description |
qid |
Qid |
|
isPickabilityEnabled#
public isPickabilityEnabled(): boolean
Whether picking honours the pickable set (settings.pickability)
isSoftOccluder#
public isSoftOccluder(qid: Qid): boolean
Whether the given object is part of the soft-occluder set
Parameters#
| Name |
Type |
Description |
qid |
Qid |
|
isVisible#
public isVisible(qid: Qid): boolean
Parameters#
| Name |
Type |
Description |
qid |
Qid |
|
Returns#
Whether the given Qid is visible
isXRayed#
public isXRayed(qid: Qid): boolean
Whether the given object is part of the x-ray set
Parameters#
| Name |
Type |
Description |
qid |
Qid |
|
pushState#
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#
public queryToQids(query: string | Iterable<Qid, any, any>): Promise<QidSet>
Parameters#
| Name |
Type |
Description |
query |
string | Iterable<Qid, any, any> |
|
removeAnnotation#
public removeAnnotation(annotation: Annotation): Promise<void>
Parameters#
removeAnnotationLayer#
Remove a layer from every viewer; the same as layer.remove()
Parameters#
| Name |
Type |
Description |
layer |
AnnotationLayer<unknown> |
|
removeBuildingStoreyExclusiveVisibilityListener#
Parameters#
removeCameraPoseListener#
Parameters#
removeColorListener#
Parameters#
removeColorMultiListener#
Stops a listener added with addColorMultiListener
Parameters#
removeFromEndcapsSet#
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#
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#
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#
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#
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#
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#
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#
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#
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#
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#
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#
Parameters#
removeHoverListener#
Parameters#
removeListener#
Parameters#
removeListenerForAll#
Parameters#
removeNoShadowListener#
Parameters#
removeObbVisibilityListener#
Parameters#
removeOnTopListener#
Parameters#
removeSelectionListener#
Parameters#
removeSetLabelsListener#
Parameters#
removeSoftOccluderListener#
Parameters#
removeViewer#
public removeViewer(viewer: object): void
Parameters#
| Name |
Type |
Description |
viewer |
object |
|
removeViewerListener#
Parameters#
removeViewFitListener#
Parameters#
removeViewFitModelsListener#
Parameters#
removeVisibilityListener#
Parameters#
removeWireframeListener#
Parameters#
removeXRayListener#
Parameters#
replayState#
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#
resetAll#
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#
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#
public resetLabels(): Promise<void>
Removes all labels set with ObjectStateManager.setLabels
restoreObjectState#
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#
public setBuildingStoreysVisibility(buildingStoreyQids: Iterable<Qid>, visible: boolean): Promise<void>
Parameters#
| Name |
Type |
Description |
buildingStoreyQids |
Iterable<Qid> |
|
visible |
boolean |
|
setBuildingStoreysVisibleExclusive#
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#
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#
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#
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#
public setNoBuildingStoreysVisibility(visible: boolean): Promise<void>
Parameters#
| Name |
Type |
Description |
visible |
boolean |
|
setObbVisibleSet#
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#
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#
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#
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#
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#
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#
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#
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#
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#
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#
Stops every running and waiting transition; how: default each one's onStop
Parameters#
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)
// 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#
Removes the listener from every type it is registered for, however it was added
Parameters#
viewFit#
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#
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 |
|