Reference·JavaScript · @bimworks/viewercommonJavaScript ObjectStateListener
Interface in @bimworks/viewercommon.
API catalogue · @bimworks/viewercommon · Interface
What an ObjectStateManager calls on its listeners, usually viewers: one interface for every
ObjectStateListenerType, so one object can listen to all of them (ObjectStateManager.addListenerForAll).
Every method is optional; a listener implements those of the types it registers for. Viewer3D-Next implements the
same methods as the Viewer3d (see there).
Returned Promises: the ObjectStateManager calls all listeners of a type at once and resolves the call that caused
the change when every returned Promise has resolved; the resolved values are ignored.
Arguments: a @bimworks/jssdk!QidSet is one the manager made for this call (the objects whose state changed);
an Iterable is the objects the caller gave, which can also be a plain Set. Read them during the call and do not
change them. The set methods all have the same parameters:
force: the caller's force flag, true to apply the state even to objects that already had it
type: the origin of the change as the caller gave it, "BIM" by default
originalQueryList: the query texts the caller passed along with the objects, mostly undefined (null in replays)
options: StateChangeOptions, only in replays for streamed-in geometry
Inheritance and interfaces#
Members#
| Member |
Kind |
Description |
| addAnnotation |
Method |
An annotation was added (ObjectStateManager.addAnnotation, ObjectStateManager.addAnnotations) |
| addedToEndcapsSet |
Method |
Objects that get section end caps (the filled cut faces) |
| addedToGhostSet |
Method |
The ghosts, see ObjectStateManager.addToGhostSet: the objects a viewer draws only with its x-ray overlay. Only the objects ghosting hid are passed; the Objec… |
| addedToNoShadowSet |
Method |
The no-shadow set, see ObjectStateManager.addToNoShadowSet |
| addedToObbVisibleSet |
Method |
Objects whose oriented bounding box is drawn |
| addedToOnTopSet |
Method |
The on-top set, see ObjectStateManager.addToOnTopSet |
| addedToPickableSet |
Method |
Objects that can be picked (only while pickability is enabled, ObjectStateManager.isPickabilityEnabled) |
| addedToSectionableSet |
Method |
Objects that section planes cut |
| addedToSelectionSet |
Method |
Objects were added to the selection |
| addedToSoftOccluderSet |
Method |
Soft occluders, see ObjectStateManager.addToSoftOccluderSet |
| addedToVisibleSet |
Method |
Objects were made visible |
| addedToXRaySet |
Method |
The x-ray set, see ObjectStateManager.addToXRaySet; setXRaySet receives only the objects that were added and removed |
| annotationLayerAdded |
Method |
A layer of template annotations was added; also called for every existing layer when the listener registers with addAnnotationListener |
| annotationLayerRemoved |
Method |
A layer of template annotations was removed |
| cameraPoseUpdated |
Method |
The pose (eye, pivot, target) of a camera has been updated (ObjectStateManager.setCameraPose) |
| clearAnnotations |
Method |
All annotations were removed (ObjectStateManager.clearAnnotations; the layers have been removed with annotationLayerRemoved first) |
| colorChangedMulti |
Method |
The colours of objects have changed, by ObjectStateManager.changeColorMulti or ObjectStateManager.changeColor |
| colorReset |
Method |
The colour of the given objects has been reset to their own |
| hoverOff |
Method |
Called when the given object is not being hovered on anymore |
| hoverOn |
Method |
Called when the given object is being hovered on |
| pickabilityEnabledChanged |
Method |
Pickability was switched on or off (ObjectStateManager.setPickabilityEnabled): picking honours the pickable set only while it is on |
| primarySelectionChanged |
Method |
The primary selection has changed (only with settings.managePrimarySelection) |
| removeAnnotation |
Method |
An annotation was removed |
| removedFromEndcapsSet |
Method |
|
| removedFromGhostSet |
Method |
|
| removedFromNoShadowSet |
Method |
|
| removedFromObbVisibleSet |
Method |
|
| removedFromOnTopSet |
Method |
|
| removedFromPickableSet |
Method |
|
| removedFromSectionableSet |
Method |
|
| removedFromSelectionSet |
Method |
Objects were removed from the selection |
| removedFromSoftOccluderSet |
Method |
|
| removedFromVisibleSet |
Method |
Objects were hidden. Any of them that were selected have been deselected first |
| removedFromXRaySet |
Method |
|
| setBuildingStoreysVisibleExclusive |
Method |
Show only the objects of these building storeys, without their openings when hideOpenings |
| setBuildingStoreyVisibleExclusive |
Method |
Show only the objects of one building storey (ObjectStateManager.setBuildingStoreyVisibleExclusive with one storey) |
| setLabels |
Method |
The labels of objects have changed (ObjectStateManager.setLabels); ObjectStateManager.resetLabels passes an empty list of lines for every object that had labels |
| setObbVisibleSet |
Method |
|
| setPickableSet |
Method |
|
| setSectionableSet |
Method |
|
| setSectionEndCapsSet |
Method |
|
| setSoftOccluderSet |
Method |
|
| setToSelectionSet |
Method |
The selection was replaced (also by a click in single-select mode) |
| setVisibleSet |
Method |
The set of visible objects was replaced |
| setXRaySet |
Method |
|
| transitionStep |
Method |
For viewers: animates a step of ObjectStateManager.transition instead of receiving it through the visibility, ghost, selection, x-ray, colour and viewFit met… |
| transitionStopped |
Method |
For viewers: a running transition was stopped (Transition.stop); the listener ends its camera track as how says. For "start" and "current" the manager foll… |
| unloaded |
Method |
Objects were unloaded with their model: forget them |
| viewerAdded |
Method |
inheritedFrom: ViewerListener.viewerAdded |
| viewerRemoved |
Method |
inheritedFrom: ViewerListener.viewerRemoved |
| viewFit |
Method |
Fit the given objects into view (ObjectStateManager.viewFit) |
| viewFitModels |
Method |
Fit the given models into view (ObjectStateManager.viewFitModels) |
| wireframesReset |
Method |
Called when BVL/resetAll restores the default object wireframe styles. |
addAnnotation#
addAnnotation?(annotation: Annotation): void | Promise<unknown>
An annotation was added (ObjectStateManager.addAnnotation, ObjectStateManager.addAnnotations)
Parameters#
addedToEndcapsSet#
addedToEndcapsSet?(qids: QidSet, force: boolean, type: string, originalQueryList?: (string)[] | null, options?: StateChangeOptions): void | Promise<unknown>
Objects that get section end caps (the filled cut faces)
Parameters#
| Name |
Type |
Description |
qids |
QidSet |
|
force |
boolean |
|
type |
string |
|
originalQueryList |
(string)[] | null |
|
options |
StateChangeOptions |
|
addedToGhostSet#
The ghosts, see ObjectStateManager.addToGhostSet: the objects a viewer draws only with its x-ray overlay. Only the
objects ghosting hid are passed; the ObjectStateManager hides them through the visible set right after addedToGhostSet,
and shows them right before removedFromGhostSet
Parameters#
addedToNoShadowSet#
addedToNoShadowSet?(qids: QidSet, force: boolean, type: string, originalQueryList?: (string)[] | null, options?: StateChangeOptions): void | Promise<unknown>
The no-shadow set, see ObjectStateManager.addToNoShadowSet
Parameters#
| Name |
Type |
Description |
qids |
QidSet |
|
force |
boolean |
|
type |
string |
|
originalQueryList |
(string)[] | null |
|
options |
StateChangeOptions |
|
addedToObbVisibleSet#
addedToObbVisibleSet?(qids: QidSet, force: boolean, type: string, originalQueryList?: (string)[] | null, options?: StateChangeOptions): void | Promise<unknown>
Objects whose oriented bounding box is drawn
Parameters#
| Name |
Type |
Description |
qids |
QidSet |
|
force |
boolean |
|
type |
string |
|
originalQueryList |
(string)[] | null |
|
options |
StateChangeOptions |
|
addedToOnTopSet#
addedToOnTopSet?(qids: QidSet, force: boolean, type: string, originalQueryList?: (string)[] | null, options?: StateChangeOptions): void | Promise<unknown>
The on-top set, see ObjectStateManager.addToOnTopSet
Parameters#
| Name |
Type |
Description |
qids |
QidSet |
|
force |
boolean |
|
type |
string |
|
originalQueryList |
(string)[] | null |
|
options |
StateChangeOptions |
|
addedToPickableSet#
addedToPickableSet?(qids: QidSet, force: boolean, type: string, originalQueryList?: (string)[] | null, options?: StateChangeOptions): void | Promise<unknown>
Objects that can be picked (only while pickability is enabled, ObjectStateManager.isPickabilityEnabled)
Parameters#
| Name |
Type |
Description |
qids |
QidSet |
|
force |
boolean |
|
type |
string |
|
originalQueryList |
(string)[] | null |
|
options |
StateChangeOptions |
|
addedToSectionableSet#
addedToSectionableSet?(qids: QidSet, force: boolean, type: string, originalQueryList?: (string)[] | null, options?: StateChangeOptions): void | Promise<unknown>
Objects that section planes cut
Parameters#
| Name |
Type |
Description |
qids |
QidSet |
|
force |
boolean |
|
type |
string |
|
originalQueryList |
(string)[] | null |
|
options |
StateChangeOptions |
|
addedToSelectionSet#
addedToSelectionSet?(qids: Iterable<Qid>, type: string): void | Promise<unknown>
Objects were added to the selection
Parameters#
| Name |
Type |
Description |
qids |
Iterable<Qid> |
The objects added |
type |
string |
The origin of the change |
addedToSoftOccluderSet#
addedToSoftOccluderSet?(qids: QidSet, force: boolean, type: string, originalQueryList?: (string)[] | null, options?: StateChangeOptions): void | Promise<unknown>
Soft occluders, see ObjectStateManager.addToSoftOccluderSet
Parameters#
| Name |
Type |
Description |
qids |
QidSet |
|
force |
boolean |
|
type |
string |
|
originalQueryList |
(string)[] | null |
|
options |
StateChangeOptions |
|
addedToVisibleSet#
addedToVisibleSet?(qids: QidSet, force: boolean, type: string, originalQueryList?: (string)[] | null, options?: StateChangeOptions): void | Promise<unknown>
Objects were made visible
Parameters#
| Name |
Type |
Description |
qids |
QidSet |
|
force |
boolean |
|
type |
string |
|
originalQueryList |
(string)[] | null |
|
options |
StateChangeOptions |
|
addedToXRaySet#
addedToXRaySet?(qids: QidSet, force: boolean, type: string, originalQueryList?: (string)[] | null, options?: StateChangeOptions): void | Promise<unknown>
The x-ray set, see ObjectStateManager.addToXRaySet; setXRaySet receives only the objects that were added and removed
Parameters#
| Name |
Type |
Description |
qids |
QidSet |
|
force |
boolean |
|
type |
string |
|
originalQueryList |
(string)[] | null |
|
options |
StateChangeOptions |
|
annotationLayerAdded#
A layer of template annotations was added; also called for every existing layer when the listener registers with addAnnotationListener
Parameters#
| Name |
Type |
Description |
layer |
AnnotationLayer<unknown> |
|
annotationLayerRemoved#
A layer of template annotations was removed
Parameters#
| Name |
Type |
Description |
layer |
AnnotationLayer<unknown> |
|
cameraPoseUpdated#
cameraPoseUpdated?(sourceViewer: unknown, pose: Pose): void
The pose (eye, pivot, target) of a camera has been updated (ObjectStateManager.setCameraPose)
Parameters#
| Name |
Type |
Description |
sourceViewer |
unknown |
The tag the pose was set with, to recognise one's own updates: "viewer3d" from the Viewer3d, null from the application; compare it, do not use it as an object |
pose |
Pose |
The new camera pose, in the 3D viewer's render frame |
clearAnnotations#
clearAnnotations?(options?: unknown): void | Promise<unknown>
All annotations were removed (ObjectStateManager.clearAnnotations; the layers have been removed with
annotationLayerRemoved first)
Parameters#
| Name |
Type |
Description |
options |
unknown |
What the caller passed to clearAnnotations, passed through; no caller passes anything today |
colorChangedMulti#
colorChangedMulti?(changes: ColorChanges, colorQueries?: Map<string, unknown> | null): void | Promise<unknown>
The colours of objects have changed, by ObjectStateManager.changeColorMulti or ObjectStateManager.changeColor
Parameters#
| Name |
Type |
Description |
changes |
ColorChanges |
The objects whose colour changed, per colour |
colorQueries |
Map<string, unknown> | null |
The queries behind the colours as the caller of changeColorMulti gave them (hex8 colour → query), mostly undefined or null |
colorReset#
colorReset?(qids: Iterable<Qid>, originalQueryList?: (string)[] | null): void | Promise<unknown>
The colour of the given objects has been reset to their own
Parameters#
| Name |
Type |
Description |
qids |
Iterable<Qid> |
The objects whose colour was reset |
originalQueryList |
(string)[] | null |
The query texts the caller passed along, mostly undefined |
hoverOff#
hoverOff?(qid: Qid): void
Called when the given object is not being hovered on anymore
Parameters#
| Name |
Type |
Description |
qid |
Qid |
The Qid of the object that is not being hovered over anymore |
hoverOn#
hoverOn?(qid: Qid, previousQid: Qid | null | undefined, screenspaceLocation?: vec2): void
Called when the given object is being hovered on
Parameters#
| Name |
Type |
Description |
qid |
Qid |
The Qid of the object being hovered over |
previousQid |
Qid | null | undefined |
The object hovered before, null or undefined for none |
screenspaceLocation |
vec2 |
The screenspace location of the hover event, when the caller gave one. This can be useful to for example place a popup/tooltip at that location. Screenspace location is x, y coordinate between 0, 0 and canvas width,height |
pickabilityEnabledChanged#
pickabilityEnabledChanged?(enabled: boolean): void | Promise<unknown>
Pickability was switched on or off (ObjectStateManager.setPickabilityEnabled): picking honours the pickable set only while it is on
Parameters#
| Name |
Type |
Description |
enabled |
boolean |
|
primarySelectionChanged#
primarySelectionChanged?(qid: Qid | null | undefined): void | Promise<unknown>
The primary selection has changed (only with settings.managePrimarySelection)
Parameters#
| Name |
Type |
Description |
qid |
Qid | null | undefined |
The newly selected primary object, null or undefined when the primary selection was cleared |
removeAnnotation#
removeAnnotation?(annotation: Annotation): void | Promise<unknown>
An annotation was removed
Parameters#
removedFromEndcapsSet#
removedFromEndcapsSet?(qids: QidSet, type: string, originalQueryList?: (string)[] | null): void | Promise<unknown>
Parameters#
| Name |
Type |
Description |
qids |
QidSet |
|
type |
string |
|
originalQueryList |
(string)[] | null |
|
removedFromGhostSet#
removedFromGhostSet?(qids: QidSet, type: string): void | Promise<unknown>
Parameters#
| Name |
Type |
Description |
qids |
QidSet |
|
type |
string |
|
removedFromNoShadowSet#
removedFromNoShadowSet?(qids: QidSet, type: string, originalQueryList?: (string)[] | null): void | Promise<unknown>
Parameters#
| Name |
Type |
Description |
qids |
QidSet |
|
type |
string |
|
originalQueryList |
(string)[] | null |
|
removedFromObbVisibleSet#
removedFromObbVisibleSet?(qids: QidSet, type: string, originalQueryList?: (string)[] | null): void | Promise<unknown>
Parameters#
| Name |
Type |
Description |
qids |
QidSet |
|
type |
string |
|
originalQueryList |
(string)[] | null |
|
removedFromOnTopSet#
removedFromOnTopSet?(qids: QidSet, type: string, originalQueryList?: (string)[] | null): void | Promise<unknown>
Parameters#
| Name |
Type |
Description |
qids |
QidSet |
|
type |
string |
|
originalQueryList |
(string)[] | null |
|
removedFromPickableSet#
removedFromPickableSet?(qids: QidSet, type: string, originalQueryList?: (string)[] | null): void | Promise<unknown>
Parameters#
| Name |
Type |
Description |
qids |
QidSet |
|
type |
string |
|
originalQueryList |
(string)[] | null |
|
removedFromSectionableSet#
removedFromSectionableSet?(qids: QidSet, type: string, originalQueryList?: (string)[] | null): void | Promise<unknown>
Parameters#
| Name |
Type |
Description |
qids |
QidSet |
|
type |
string |
|
originalQueryList |
(string)[] | null |
|
removedFromSelectionSet#
removedFromSelectionSet?(qids: QidSet, type: string): void | Promise<unknown>
Objects were removed from the selection
Parameters#
| Name |
Type |
Description |
qids |
QidSet |
The objects that are no longer selected |
type |
string |
The origin of the change |
removedFromSoftOccluderSet#
removedFromSoftOccluderSet?(qids: QidSet, type: string, originalQueryList?: (string)[] | null): void | Promise<unknown>
Parameters#
| Name |
Type |
Description |
qids |
QidSet |
|
type |
string |
|
originalQueryList |
(string)[] | null |
|
removedFromVisibleSet#
removedFromVisibleSet?(qids: QidSet, type: string, originalQueryList?: (string)[] | null): void | Promise<unknown>
Objects were hidden. Any of them that were selected have been deselected first
Parameters#
| Name |
Type |
Description |
qids |
QidSet |
|
type |
string |
|
originalQueryList |
(string)[] | null |
|
removedFromXRaySet#
removedFromXRaySet?(qids: QidSet, type: string, originalQueryList?: (string)[] | null): void | Promise<unknown>
Parameters#
| Name |
Type |
Description |
qids |
QidSet |
|
type |
string |
|
originalQueryList |
(string)[] | null |
|
setBuildingStoreysVisibleExclusive#
setBuildingStoreysVisibleExclusive?(buildingStoreyQids: Iterable<Qid>, hideOpenings: boolean): void | Promise<unknown>
Show only the objects of these building storeys, without their openings when hideOpenings
Parameters#
| Name |
Type |
Description |
buildingStoreyQids |
Iterable<Qid> |
|
hideOpenings |
boolean |
|
setBuildingStoreyVisibleExclusive#
setBuildingStoreyVisibleExclusive?(qid: Qid): void | Promise<unknown>
Show only the objects of one building storey (ObjectStateManager.setBuildingStoreyVisibleExclusive with one storey)
Parameters#
| Name |
Type |
Description |
qid |
Qid |
|
setLabels#
setLabels?(labels: (Label)[]): void | Promise<unknown>
The labels of objects have changed (ObjectStateManager.setLabels); ObjectStateManager.resetLabels
passes an empty list of lines for every object that had labels
Parameters#
| Name |
Type |
Description |
labels |
(Label)[] |
|
setObbVisibleSet#
setObbVisibleSet?(shown: QidSet, hidden: QidSet, force: boolean, type: string, originalQueryList?: (string)[] | null): void | Promise<unknown>
Parameters#
| Name |
Type |
Description |
shown |
QidSet |
|
hidden |
QidSet |
|
force |
boolean |
|
type |
string |
|
originalQueryList |
(string)[] | null |
|
setPickableSet#
setPickableSet?(madePickable: QidSet, madeUnpickable: QidSet, force: boolean, type: string, originalQueryList?: (string)[] | null): void | Promise<unknown>
Parameters#
| Name |
Type |
Description |
madePickable |
QidSet |
|
madeUnpickable |
QidSet |
|
force |
boolean |
|
type |
string |
|
originalQueryList |
(string)[] | null |
|
setSectionableSet#
setSectionableSet?(madeSectionable: QidSet, madeUnsectionable: QidSet, force: boolean, type: string, originalQueryList?: (string)[] | null): void | Promise<unknown>
Parameters#
| Name |
Type |
Description |
madeSectionable |
QidSet |
|
madeUnsectionable |
QidSet |
|
force |
boolean |
|
type |
string |
|
originalQueryList |
(string)[] | null |
|
setSectionEndCapsSet#
setSectionEndCapsSet?(on: QidSet, off: QidSet, force: boolean, type: string, originalQueryList?: (string)[] | null): void | Promise<unknown>
Parameters#
| Name |
Type |
Description |
on |
QidSet |
|
off |
QidSet |
|
force |
boolean |
|
type |
string |
|
originalQueryList |
(string)[] | null |
|
setSoftOccluderSet#
setSoftOccluderSet?(added: QidSet, removed: QidSet, force: boolean, type: string, originalQueryList?: (string)[] | null): void | Promise<unknown>
Parameters#
| Name |
Type |
Description |
added |
QidSet |
|
removed |
QidSet |
|
force |
boolean |
|
type |
string |
|
originalQueryList |
(string)[] | null |
|
setToSelectionSet#
setToSelectionSet?(qids: Iterable<Qid>, qidsToUnselect: Iterable<Qid>, type: string, data?: unknown): void | Promise<unknown>
The selection was replaced (also by a click in single-select mode)
Parameters#
| Name |
Type |
Description |
qids |
Iterable<Qid> |
The objects selected now |
qidsToUnselect |
Iterable<Qid> |
The objects no longer selected |
type |
string |
The origin of the change |
data |
unknown |
What the caller passed as the third argument of ObjectStateManager.setToSelectionSet |
setVisibleSet#
setVisibleSet?(shown: QidSet, hidden: QidSet, force: boolean, type: string, originalQueryList?: (string)[] | null): void | Promise<unknown>
The set of visible objects was replaced
Parameters#
| Name |
Type |
Description |
shown |
QidSet |
The objects that have been made visible |
hidden |
QidSet |
The objects that have been made invisible |
force |
boolean |
true: the caller forced the change, apply the whole visible/invisible state, not only the difference |
type |
string |
|
originalQueryList |
(string)[] | null |
|
setXRaySet#
setXRaySet?(added: QidSet, removed: QidSet, force: boolean, type: string, originalQueryList?: (string)[] | null): void | Promise<unknown>
Parameters#
| Name |
Type |
Description |
added |
QidSet |
|
removed |
QidSet |
|
force |
boolean |
|
type |
string |
|
originalQueryList |
(string)[] | null |
|
transitionStep#
For viewers: animates a step of ObjectStateManager.transition instead of receiving it through the
visibility, ghost, selection, x-ray, colour and viewFit methods. Called only on a listener registered for
all of those types (as ObjectStateManager.addListenerForAll does); one registered for only some
receives the regular calls. The step's changes are in the manager's sets already
(docs/viewer-state-transitions-design.md §5.2)
Parameters#
Returns#
Settles once this listener has drawn the step's end, or the step was stopped or taken over
transitionStopped#
For viewers: a running transition was stopped (Transition.stop); the listener ends its camera track
as how says. For "start" and "current" the manager follows, in the same task, with a 0 ms step that sets
the objects' state
Parameters#
unloaded#
unloaded?(qids: QidSet): void | Promise<unknown>
Objects were unloaded with their model: forget them
Parameters#
| Name |
Type |
Description |
qids |
QidSet |
|
viewerAdded#
viewerAdded?(viewer: object): void
inheritedFrom: ViewerListener.viewerAdded
Parameters#
| Name |
Type |
Description |
viewer |
object |
The viewer that announced itself (a Viewer2d today), to compare by identity |
viewerRemoved#
viewerRemoved?(viewer: object): void
inheritedFrom: ViewerListener.viewerRemoved
Parameters#
| Name |
Type |
Description |
viewer |
object |
|
viewFit#
Fit the given objects into view (ObjectStateManager.viewFit)
Parameters#
| Name |
Type |
Description |
qids |
Iterable<Qid> |
The objects to fit |
options |
ViewFitOptions |
How to fit, as the caller gave them |
viewFitModels#
viewFitModels?(versionUuids: Iterable<string>, options?: ViewFitOptions): void | Promise<unknown>
Fit the given models into view (ObjectStateManager.viewFitModels)
Parameters#
| Name |
Type |
Description |
versionUuids |
Iterable<string> |
The models to fit |
options |
ViewFitOptions |
How to fit, as the caller gave them |
wireframesReset#
wireframesReset?(): void | Promise<unknown>
Called when BVL/resetAll restores the default object wireframe styles.