Reference·JavaScript · @bimworks/viewercommonJavaScript

ModelListener

Interface in @bimworks/viewercommon.

API catalogue · @bimworks/viewercommon · Interface

TypeScript#
interface ModelListener

What a ModelManager calls on a listener added with ModelManager.addListener, for example a viewer. Every method is optional. Listeners are called one at a time, in the order they were added (ModelManager.prioritizeOver): when a method returns a Promise, the next listener is called once it has resolved, and a rejection rejects the ModelManager call that caused it. The resolved value is ignored.

Members#

Member Kind Description
supportsGeometryOverlays Property False on a listener that shows geometry and cannot load a geometry overlay in place of what it shows: a ModelManager.swapVersion with a geometry overlay then…
addModels Method Models were loaded: their object data is in the ModelManager already
removeModels Method Models were unloaded
swapVersion Method A loaded version was replaced by its successor after a commit (ModelManager.swapVersion): the same objects (oids) and geometry, apart from the objects the co…

supportsGeometryOverlays#

TypeScript#
readonly supportsGeometryOverlays?: boolean

False on a listener that shows geometry and cannot load a geometry overlay in place of what it shows: a ModelManager.swapVersion with a geometry overlay then unloads the old version and loads the new one

addModels#

TypeScript#
addModels?(newVersions: (Version)[], allVersions: Iterable<Version>): void | Promise<unknown>

Models were loaded: their object data is in the ModelManager already

Parameters#

Name Type Description
newVersions (Version)[] The versions that were added
allVersions Iterable<Version> Every loaded version, the new ones included

removeModels#

TypeScript#
removeModels?(versions: (Version)[], allVersions: (Version)[], managerIndex: number): void | Promise<unknown>

Models were unloaded

Parameters#

Name Type Description
versions (Version)[] The versions that were removed
allVersions (Version)[] The versions that are loaded after the removal
managerIndex number The ModelManager's ModelManagerSettings.index

swapVersion#

TypeScript#
swapVersion?(oldVersion: Version, newVersion: Version, deleted: DeletedObjects | null, changed?: ChangedGeometry | null): void | Promise<unknown>

A loaded version was replaced by its successor after a commit (ModelManager.swapVersion): the same objects (oids) and geometry, apart from the objects the commit deleted, so a viewer rebinds in place instead of reloading. The ObjectStateManagers have rebound their state to the new version already. A listener without this method gets removeModels([oldVersion]) and then addModels([newVersion]).

Parameters#

Name Type Description
oldVersion Version
newVersion Version
deleted DeletedObjects | null The objects the commit deleted, null when it deleted none
changed ChangedGeometry | null Set when the commit changed the geometry of some objects and the new version has them in a geometry overlay: a viewer loads those objects in place of the ones it shows