BIM.works SDKs - v3.0.0-b.115
    Preparing search index...

    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.

    Index

    Constructors

    Properties

    Methods

    addAnnotation addAnnotationLayer addAnnotationListener addAnnotations addBuildingStoreyExclusiveVisibilityListener addCameraPoseListener addColorListener addColorMultiListener addGhostListener addHoverListener addListener addListenerForAll addLoadedListener addNoShadowListener addObbVisibilityListener addOnTopListener addPickabilityListener addSectionabilityListener addSectionEndcapListener addSelectionListener addSetLabelsListener addSoftOccluderListener addToEndcapsSet addToGhostSet addToNoShadowSet addToObbVisibleSet addToOnTopSet addToPickableSet addToSectionableSet addToSelectionSet addToSoftOccluderSet addToVisibleSet addToXRaySet addViewer addViewerListener addViewFitListener addViewFitModelsListener addVisibilityListener addWireframeListener addXRayListener captureObjectState castsShadow changeColor changeColorMulti clearAnnotations clearGhostSet clearOnTopSet clearSelection clearXRaySet getAnnotationLayers getColor getColorOverrides getEndcapsQids getGhostSet getInvisibleObbQids getInvisibleQids getLabels getLastCameraPose getModelManager getNoShadowQids getOnTopQids getPickableQids getSectionableQids getSelectedQids getVisibleObbQids getVisibleQids getXRayQids highlightQuery hoverOff hoverOn inverseOfVisible isGhosted isOnTop isPickabilityEnabled isSoftOccluder isVisible isXRayed pushState queryToQids removeAnnotation removeAnnotationLayer removeBuildingStoreyExclusiveVisibilityListener removeCameraPoseListener removeColorListener removeColorMultiListener removeFromEndcapsSet removeFromGhostSet removeFromNoShadowSet removeFromObbVisibleSet removeFromOnTopSet removeFromPickableSet removeFromSectionableSet removeFromSelectionSet removeFromSoftOccluderSet removeFromVisibleSet removeFromXRaySet removeGhostListener removeHoverListener removeListener removeListenerForAll removeNoShadowListener removeObbVisibilityListener removeOnTopListener removeSelectionListener removeSetLabelsListener removeSoftOccluderListener removeViewer removeViewerListener removeViewFitListener removeViewFitModelsListener removeVisibilityListener removeWireframeListener removeXRayListener replayState resetAll resetColor resetLabels restoreObjectState setBuildingStoreysVisibility setBuildingStoreysVisibleExclusive setCameraPose setGhostSet setLabels setNoBuildingStoreysVisibility setObbVisibleSet setPickabilityEnabled setPickableSet setPrimarySelected setSectionableSet setSectionEndCapsSet setSoftOccluderSet setToSelectionSet setVisibleSet setXRaySet unregisterListener viewFit viewFitModels

    Constructors

    Properties

    modelManager: ModelManager

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

    Methods

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

      Parameters

      Returns void

    • 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

      • D = Record<string, unknown>

      Parameters

      Returns AnnotationLayer<D>

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

      Parameters

      Returns void

    • Add multiple annotations.

      Parameters

      • annotations: Iterable<Annotation>

        An Iterable of the annotations to add

      Returns void

    • Register a listener for camera pose changes

      Parameters

      Returns void

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

      Parameters

      Returns void

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

      Parameters

      • query: string | Iterable<Qid, any, any>
      • Optionalforce: boolean
      • Optionaltype: string

      Returns 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

      • query: string | Iterable<Qid, any, any>

        Either a query or Iterable of Qid

      • Optionaltype: string

        Always "BIM"

      Returns 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

      • query: string | Iterable<Qid, any, any>

        Either a query or Iterable of Qid

      • Optionalforce: boolean

        Notify listeners even for objects that were already in the set

      • Optionaltype: string

        Always "BIM"

      Returns Promise<void>

    • Parameters

      • query: string | Iterable<Qid, any, any>
      • Optionalforce: boolean
      • Optionaltype: string

      Returns 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

      • query: string | Iterable<Qid, any, any>

        Either a query or Iterable of Qid

      • Optionalforce: boolean

        Notify listeners even for objects that were already in the set

      • Optionaltype: string

        Always "BIM"

      Returns Promise<void>

    • Add the provided objects to the currently pickable set of objects

      Parameters

      • query: string | Iterable<Qid, any, any>

        Either a query or Iterable of Qid

      • Optionalforce: boolean

        Whether to force this change, when forced, any viewer-specific settings are overruled

      • Optionaltype: string

        Always "BIM"

      Returns Promise<void>

    • Objects whose geometry section planes cut (all objects are by default)

      Parameters

      • query: string | Iterable<Qid, any, any>
      • Optionalforce: boolean
      • Optionaltype: string

      Returns Promise<void>

    • Add a set of objects to the selected set

      Parameters

      • query: string | Iterable<Qid, any, any>
      • Optionaltype: string

      Returns 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

      • query: string | Iterable<Qid, any, any>

        Either a query or Iterable of Qid

      • Optionalforce: boolean

        Whether to force this change, when forced, any viewer-specific settings are overruled

      • Optionaltype: string

        Always "BIM"

      Returns Promise<void>

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

      Parameters

      • query: string | Iterable<Qid, any, any>

        Either a query or Iterable of Qid *

      • Optionalforce: boolean

        Whether to force this change, when forced, any viewer-specific settings are overruled *

      • Optionaltype: string

        Always "BIM"

      Returns 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

      • query: string | Iterable<Qid, any, any>

        Either a query or Iterable of Qid

      • Optionalforce: boolean

        Notify listeners even for objects that were already in the set

      • Optionaltype: string

        Always "BIM"

      Returns Promise<void>

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

      Parameters

      • viewer: object

      Returns void

    • Registers for viewers announcing themselves (addViewer)

      Parameters

      Returns void

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

      Parameters

      Returns void

    • 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 ObjectStateSnapshot

      A new value: copies, not the live sets

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

      Parameters

      Returns boolean

    • 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

      • 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 Promise<void>

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

    • Change the colors of a given set of objects.

      Parameters

      • changes: ColorChangeMap

        A ColorChangeMap that contains color change information potentialle for many different colors/qids

      • OptionalcolorQueries: Map<string, unknown> | null

        The queries behind the colours (hex8 colour → query), passed on to the listeners' colorChangedMulti

      • OptionalautoDispose: boolean

        Whether to dispose changes once applied, default true

      Returns Promise<void>

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

    • Removes all annotations and annotation layers, in every viewer

      Parameters

      • Optionaloptions: unknown

      Returns Promise<void>

    • Empties the ghost set, bringing back the visibility ghosting took

      Parameters

      • Optionaltype: string

      Returns Promise<void>

    • Empty the on-top set

      Parameters

      • Optionaltype: string

      Returns Promise<void>

    • Clear the current selection

      Parameters

      • Optionaltype: string

      Returns Promise<void>

    • Empty the x-ray set

      Parameters

      • Optionaltype: string

      Returns Promise<void>

    • The annotation layers, in the order they were added

      Returns AnnotationLayer<unknown>[]

    • Parameters

      Returns TinyColor | undefined

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

    • Returns QidMap<TinyColor>

      A copy of all colour overrides, qid → colour

    • Returns QidSet

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

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

      Returns QidSet

    • Returns QidSet

    • Returns QidSet

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

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

      Parameters

      Returns string[] | null

    • A copy of the last pose set with setCameraPose

      Returns Pose

    • Returns ModelManager

      The ModelManager connected to this ObjectStateManager

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

      Returns QidSet

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

      Returns QidSet

    • Returns QidSet

      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.

    • Returns QidSet

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

    • Returns QidSet

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

    • Returns QidSet

    • Returns QidSet

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

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

      Returns QidSet

    • Highlight certain objects

      Parameters

      • query: string | Iterable<Qid, any, any>
      • highlightColor: Color
      • backgroundColor: Color

      Returns Promise<unknown>

      This will be removed in the future, as it is to opinionated and can easily be constructed using the changeColorMulti 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.

      Parameters

      • qid: Qid

        The Qid of the object not being hovered over anymore

      Returns void

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

      Parameters

      • qid: Qid

        The Qid of the object being hovered over

      • OptionalscreenspaceLocation: vec2

        The screen space location of the hover event. This is not relevant/available in all situations and can be null

      Returns void

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

      Parameters

      • qids: { has(qid: Qid): boolean } | null

      Returns QidSet

    • Whether the given object is part of the ghost set

      Parameters

      Returns boolean

    • Whether the given object is drawn on top

      Parameters

      Returns boolean

    • Whether picking honours the pickable set (settings.pickability)

      Returns boolean

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

      Parameters

      Returns boolean

    • Parameters

      Returns boolean

      Whether the given Qid is visible

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

      Parameters

      Returns boolean

    • 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

      • vid: string

        The model the geometry belongs to

      • oids: Iterable<number>

        The objects whose geometry arrived

      Returns Promise<void>

    • Parameters

      • query: string | Iterable<Qid, any, any>

      Returns Promise<QidSet>

    • Parameters

      Returns Promise<void>

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

      Parameters

      Returns void

    • Stops a listener added with addColorMultiListener

      Parameters

      Returns void

    • Parameters

      • query: string | Iterable<Qid, any, any>
      • Optionalforce: boolean
      • Optionaltype: string

      Returns 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

      • query: string | Iterable<Qid, any, any>
      • Optionaltype: string

      Returns Promise<void>

    • Let objects cast sun shadows again

      Parameters

      • query: string | Iterable<Qid, any, any>
      • Optionalforce: boolean
      • Optionaltype: string

      Returns Promise<void>

    • Parameters

      • query: string | Iterable<Qid, any, any>
      • Optionalforce: boolean
      • Optionaltype: string

      Returns Promise<void>

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

      Parameters

      • query: string | Iterable<Qid, any, any>
      • Optionalforce: boolean
      • Optionaltype: string

      Returns Promise<void>

    • Remove objects from the set of pickable objects

      Parameters

      • query: string | Iterable<Qid, any, any>

        Either a query or Iterable of Qid

      • Optionalforce: boolean

        Whether to force this change, when forced, any viewer-specific settings are overruled

      • Optionaltype: string

        Always "BIM"

      Returns Promise<void>

    • Parameters

      • query: string | Iterable<Qid, any, any>
      • Optionalforce: boolean
      • Optionaltype: string

      Returns Promise<void>

    • Remove the provided objects from the current selection

      Parameters

      • query: string | Iterable<Qid, any, any>
      • Optionaltype: string

      Returns Promise<void>

    • Remove objects from the soft-occluder set

      Parameters

      • query: string | Iterable<Qid, any, any>

        Either a query or Iterable of Qid

      • Optionalforce: boolean

        Whether to force this change, when forced, any viewer-specific settings are overruled

      • Optionaltype: string

        Always "BIM"

      Returns 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

      • query: string | Iterable<Qid, any, any>

        Either a query or Iterable of Qid

      • Optionalforce: boolean

        Whether to force this change, when forced, any viewer-specific settings are overruled

      • Optionaltype: string

        Always "BIM"

      Returns Promise<void>

    • Remove objects from the x-ray set

      Parameters

      • query: string | Iterable<Qid, any, any>

        Either a query or Iterable of Qid

      • Optionalforce: boolean

        Notify listeners even for objects that were not in the set

      • Optionaltype: string

        Always "BIM"

      Returns Promise<void>

    • Parameters

      • viewer: object

      Returns void

    • Parameters

      Returns 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

      Returns 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.

      Returns Promise<void>

    • Parameters

      • query: string | Iterable<Qid, any, any>

        A query or iterable of Qids, the objects to reset color

      Returns Promise<void>

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

    • Removes all labels set with ObjectStateManager.setLabels

      Returns 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

      • snapshot: ObjectStateSnapshot
      • Optionaloptions: { 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 Promise<void>

      Resolves when the listeners have applied the changes

    • Parameters

      • buildingStoreyQids: Iterable<Qid>
      • visible: boolean

      Returns Promise<void>

    • Parameters

      • query: string | Iterable<Qid, any, any>
      • OptionalhideOpenings: boolean

      Returns Promise<unknown>

    • 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

      • sourceViewer: unknown
      • pose: Pose

      Returns void

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

      Parameters

      • query: string | Iterable<Qid, any, any>
      • Optionaltype: string

      Returns Promise<void>

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

      Parameters

      • labels: Label[]

        An array of Label

      Returns Promise<void>

    • Parameters

      • visible: boolean

      Returns Promise<void>

    • Parameters

      • query: string | Iterable<Qid, any, any>
      • Optionalforce: boolean
      • Optionaltype: string

      Returns 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

      • enabled: boolean

      Returns Promise<void>

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

      Parameters

      • query: string | Iterable<Qid, any, any>

        Either a query or Iterable of Qid

      • Optionalforce: boolean

        Whether to force this change, when forced, any viewer-specific settings are overruled

      • Optionaltype: string

        Always "BIM"

      Returns Promise<void>

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

      Parameters

      • qid: Qid | null

      Returns Promise<void>

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

      Parameters

      • query: string | Iterable<Qid, any, any>
      • Optionalforce: boolean
      • Optionaltype: string

      Returns Promise<void>

    • End caps on exactly these objects, on no other object

      Parameters

      • query: string | Iterable<Qid, any, any>
      • Optionalforce: boolean
      • Optionaltype: string

      Returns Promise<void>

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

      Parameters

      • query: string | Iterable<Qid, any, any>

        Either a query or Iterable of Qid

      • Optionalforce: boolean

        Whether to force this change, when forced, any viewer-specific settings are overruled

      • Optionaltype: string

        Always "BIM"

      Returns Promise<void>

    • Replace the currently selected set by the provided set of objects

      Parameters

      • query: string | Iterable<Qid, any, any>
      • Optionaltype: string
      • Optionaldata: unknown

      Returns 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

      • query: string | Iterable<Qid, any, any>

        Either a query or Iterable of Qid

      • Optionalforce: boolean

        Whether to force this change, when forced, any viewer-specific settings are overruled

      • Optionaltype: string

        Always "BIM"

      Returns Promise<void>

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

      Parameters

      • query: string | Iterable<Qid, any, any>

        Either a query or Iterable of Qid

      • Optionalforce: boolean

        Notify listeners even when nothing changed

      • Optionaltype: string

        Always "BIM"

      Returns Promise<void>

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

      Parameters

      Returns 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

      • query: string | Iterable<Qid, any, any>

        A query or iterable of Qids, the objects to reset color

      • options: ViewFitOptions

      Returns Promise<void>

    • Fits the viewers' cameras on the given models

      Parameters

      Returns Promise<void>