Reference·JavaScript · @bimworks/viewer3dJavaScript

Viewer3d

Class in @bimworks/viewer3d.

API catalogue · @bimworks/viewer3d · Class

TypeScript#
class Viewer3d

A 3D BIM viewer. Minimal example:

Example#

JavaScript#
// Set up a connection with the repository
const factory = new BimWorksClientFactory("https://dev.bim.works");
// Create a new client, based on a pre-created API Token
const client = await factory.createClientWithApiToken("[YOUR API TOKEN]");
// The unique Version UUID of your model
const versionUuid = "[VERSION_UUID]";

// The ModelManager is responsible for keeping track of which models are loaded/unloaded
const modelManager = new ModelManager(client);

// The ObjectStateManager is responsible for keeping track of certain states of loaded objects such as visibility, color, selection
const objectStateManager = new ObjectStateManager(modelManager);
 
// Create a new Viewer3d
const viewer = new Viewer3d(objectStateManager);

// Initialize the new viewer, make sure to only continue after the returned Promise is resolved 
await viewer.initializeViewer();

// Add the canvas to the body of the page, so we can see it
document.body.appendChild(viewer.container);

// Load the required Version information from the server
const version = await client.fs.getNodeVersion(versionUuid);
// Load the model
await modelManager.addModels([version]);
// All models have now loaded successfully

The viewer registers itself with its ObjectStateManager and ModelManager and implements every method of @bimworks/viewercommon!ObjectStateListener except viewerRemoved, primarySelectionChanged and the transition methods (transitionStep, transitionStopped: the ObjectStateManager then shows a transition's steps through the other methods, without animation; cameraPoseUpdated, setLabels and hoverOn do nothing), and those of @bimworks/viewercommon!ModelListener and @bimworks/viewercommon!ModelVisibilityListener; Viewer3D-Next implements the same. The managers call them, not the application: only those the application also calls directly are declared below.

Inheritance and interfaces#

Members#

Member Kind Description
constructor Method Create a new Viewer3d. Every viewer loads its own copy of the models, also when its ObjectStateManager is on the same ModelManager as another viewer's (Viewe…
canvas Property The canvas the viewer renders on
client Property
container Property
figures Property Figure layers (docs/quantity-takeoff-design.md §8): many quantity figures at once - the parts of a sum - drawn as pickable overlays, one colour per entry sta…
fontScaling Property The font size of the plan labels in pixels, 15 by default (as Viewer2d.fontScaling)
frames Property Conversions between the render frame and a loaded version's own frame, @bimworks/viewercommon!VersionFrames
modelManager Property
objectStateManager Property
overlays Property Check overlays (docs/check-overlays-design.md): semantic geometry a check sends with its result, bound to one model version and drawn with that model's place…
settings Property
supportsGeometryOverlays Property Whether a commit that moved objects reaches the loaded model in place: @bimworks/viewercommon!ModelManager.swapVersion with a geometry overlay loads the move…
supportsLiveTransform Property Whether objects can be drawn moved in place (setTransformPreview, a live move/rotate): Viewer3D-Next
viewpoints Property Stored viewpoints: the view as a JSON value that outlives the session and loads in any order (@bimworks/viewercommon!Viewpoints.capture), and back (@bimworks…
measuring Method Get a reference to the Measuring component which can be used for measurements related actions
add2dModeListener Method listener(side) when the viewer enters 2D (set2dMode, or a flat scene by itself), looks from another side, or leaves 2D (side null): to keep a 2D/3D switch in…
addAnnotationLayer Method Add a layer of template annotations to every viewer of this viewer's object state manager: a shortcut for getObjectStateManager().addAnnotationLayer(options)…
addDwgSemanticsListener Method listener(versionUuid, semantics) is called when a DWG model's (or geometry PDF's) layouts load, before its sheets are hidden
addedToObbVisibleSet Method Objects whose oriented bounding box is drawn implementationOf: ObjectStateListener.addedToObbVisibleSet
addedToSelectionSet Method Objects were added to the selection implementationOf: ObjectStateListener.addedToSelectionSet
addedToVisibleSet Method Objects were made visible implementationOf: ObjectStateListener.addedToVisibleSet
addEngineFailureListener Method Called once when the viewer gives up on the GPU. Viewer3D: the WebGL context was lost, as when the browser's GPU process is killed ({engine: "webgl", reason:…
addGisLayer Method Adds a GIS layer definition to the viewer. It loads now only when visible is true; an invisible layer is only registered (a terrain known before the imager…
addKeyHandler Method handler(event, bindingType) runs on a key-up in the viewer before the viewer's own handling and returns true when it consumed the key (the takeoff editor's O…
addModeChangeListener Method Add a listener for mode updates
addModelClusterListener Method listener.modelClustersChanged(clusters) whenever the clusters were computed again (after models were loaded or unloaded)
addModels Method Models were loaded: their object data is in the ModelManager already implementationOf: ModelListener.addModels
addNavigationModeChangeListener Method Includes navigation exits initiated by Escape or loss of pointer lock.
addQuantityFigureAsMeasurements Method Turn a quantity figure into committed measurements: an area (with holes) per polygon, a path per polyline, a distance per dimension; a box is not convertible…
addRepaintListener Method fn() when the viewer wants a frame; once per request, not once per internal change
addResetListener Method listener() is called by every resetResults: whoever owns the shown result lets go of it
addShadowChangeListener Method Called with the new state whenever the shadow settings change.
addSunChangeListener Method Called with the new state whenever the sun changes: settings, mode, or the reference model.
addWalkStartListener Method Told every change of getWalkStart, and of getWalkPreparation
applyDiagnosticCamera Method Apply an explicit, validated camera probe without animation. Position/direction are metres.
cameraPoseUpdated Method The pose (eye, pivot, target) of a camera has been updated (ObjectStateManager.setCameraPose) implementationOf: ObjectStateListener.cameraPoseUpdated
cancelObjectSelection Method
captureViewState Method The view as it is now, as a value to give back to restoreViewState later: the object state (@bimworks/viewercommon!ObjectStateManager.captureObjectState: vis…
clearAnnotations Method Removes the annotations this viewer shows. Annotation layers stay; ObjectStateManager.clearAnnotations() removes those too, in every viewer implementationOf:…
clearClickHandler Method
clearDeletionPreview Method
clearPaths Method Removes all route polylines and stops any route playback.
clearQuantityFigures Method Remove every quantity figure
clearTransformPreview Method
colorReset Method The colour of the given objects has been reset to their own implementationOf: ObjectStateListener.colorReset
destroy Method Destroys the viewer and any (heavy) resources associated with it. As long as there is a reference to the Viewer3d instance it won't be completely destroyed.
disableSectionPlanes Method Disable any active sectionplanes
endPickTarget Method End setPickTarget: the object loses its highlight
ensureCurrentSpaceTracker Method The tracker that knows which IfcSpace / IfcZone the camera is in (docs/current-space-design.md): loads the server-generated space index of the loaded models …
focus Method Focus the viewer (keyboard focus on its canvas). Does not scroll the page.
followRoute Method Flies the camera along a route at constant walking speed (default 1.4 m/s), the look target running ahead - the interactive preview of the server-rendered fl…
frontView Method View the set of loaded models from the front
get2dSide Method The side 2D mode looks from, null in 3D; "top" for a flat scene that is in 2D by itself
getAnnotationGroups Method The group names (Annotation.group, an AnnotationLayer's group) of the annotations shown in this viewer
getAnnotationLayers Method The annotation layers of this viewer's object state manager
getAnnotationLimit Method At most how many annotations are shown, 0 for no limit.
getAnnotationScaleByDistance Method Whether annotations are drawn smaller further away, unless they say otherwise.
getBackgroundColor Method
getCamera Method
getCanvas Method
getCullingBudget Method
getCurrentSpaceTracker Method The current-space tracker if one exists and is not disposed; never creates one (use ensureCurrentSpaceTracker for that)
getDiagnostics Method Detached applied-state, renderer-membership and annotation-DOM diagnostics; not a pixel certificate.
getDrawingPaperUnitMm Method Paper millimetres per model millimetre of a loaded PDF (docs/drawing-scale-design.md §8.4): 1 for a geometry PDF, whose model unit converts to paper millimet…
getDwgSemanticsMap Method
getFocusAabb Method The main bounds of the visible models where they render (render frame, mm), the box the toolbar's fit uses with Camera.viewFit: outlying parts left out, as g…
getGeoFrameOrigin Method GEO mode: where the render frame sits on the globe. Its x/y origin is the reference model's georeference anchor, at the georeference's longitude/latitude (WG…
getGisLayer Method What the viewer knows about a GIS layer, a copy; null for an unknown id
getGisLayers Method Every GIS layer the viewer knows, as copies
getGridOptions Method
getGridSnapSpacing Method The grid line spacing that snapping is currently using, which follows the zoom level, so it can be shown in the UI as the active increment.
getHeight Method Get the height of the viewer in pixels
getMainBounds Method Get the Axis Aligned Bounding Box (AABB) of the main content. For most models (or model sets) these are just the bounds of all 3D geometry. In certain cases …
getMode Method
getModelAlignment Method The alignment in effect for a loaded model: a rigid transform of its model frame (mm, column-major), or null for none. A preview set with setModelAlignment w…
getModelBounds Method The bounds of the given models where they render, alignment and placement applied
getModelClusters Method The model clusters, as values: models more than ~10 km apart form separate clusters (setting clustering)
getModelFrameBounds Method A loaded model's main bounds (outlying parts left out, as getModelBounds) in its own model frame (raw model mm, the frame modelToMeasurementCoordinates takes…
getModelLengthUnitMm Method Millimetres per length unit of a loaded model (1 for a model in mm, 1000 for metres); null when it is not loaded
getModelsWithoutGeoReference Method The loaded models without a georeference, by version uuid: while there are any, setMode refuses GEO mode
getMovablePlanes Method Get a reference to the MovablePlanes component: planes with a drag icon that do not cut, in any number, with listeners
getMultiSelectMode Method The current multiselection mode
getNavigationMode Method
getNearPlane Method
getObjectsAabb Method One axis-aligned box around the objects in render space, as a value; null when none of them is loaded
getObjectsObb Method One oriented box around the objects (merged on the first object's axes), in render space; null when none of them is loaded
getOfflineModels Method
getOfflineVersions Method Get the stored Version objects for offline-prepared models. This is the offline replacement for client.fs.getNodeVersion(): use the returned Version object…
getPlanCut Method The height of the plan cut (setPlanCut), null without one
getPlanLabelsHeight Method The plane the plan labels lie in: "top" (the default) or "bottom", see setPlanLabelsHeight
getQuantityFigureBounds Method The bounding box of a quantity figure in render coordinates, null for an empty figure
getScanStations Method Where the scans of the loaded point clouds were taken, shown as markers in the view by Viewer3D-Next. Viewer3D keeps no stations: empty
getSectionPlanes Method Get a reference to the SectionPlanes component which can be used for creating/modifying/removing section planes and boxes
getSelectionMode Method
getSelectionVisualization Method Returns the current viewer-wide selection style. Reapply with setSelectionVisualization after editing.
getShadows Method
getSun Method
getTextAnnotationMode Method Current text annotation display mode.
getWalkableSurfaces Method The handle of the walkable-surfaces view that is shown, or null. Viewer3D-Next only: always null in Viewer3D.
getWalkPreparation Method While getWalkStart is "preparing": how many of the loaded models' walkable surfaces are there (ready, loaded or found to have none) of total; null otherw…
getWalkStart Method Where the start of a walk or game stands. Walk and game mode start where the camera is when the feet (the eye less the character's eye height) are at most 2 …
getWidth Method Get the width of the viewer in pixels
getWireframeRendering Method
getXRayVisualization Method Returns the current x-ray set style. Reapply with setXRayVisualization after editing.
hideDwgSheets Method Shows a DWG model's model space again and hides its sheets: the way back from showDwgLayout with a sheet
hideQuantityFigure Method Remove the quantity figure shown under the key, if any
hideTemporaryObb Method
hideTransformGhost Method
hideWalkableSurfaces Method Takes the walkable-surfaces view away, if one is shown.
hoverOff Method Called when the given object is not being hovered on anymore implementationOf: ObjectStateListener.hoverOff
hoverOn Method Called when the given object is being hovered on implementationOf: ObjectStateListener.hoverOn
initializeViewer Method Initializes the Viewer3d, it is important to wait for this async method to finish before calling any other methods on the viewer
is2dMode Method Whether the viewer is in 2D mode, by set2dMode or because the scene is flat
isAnimationEnabled Method Whether the default animation (the rotation along the Z-axis, toggleAnimationEnabled) runs
isAnnotationGroupVisible Method
isAnnotationsVisible Method
isBackgroundGradientEnabled Method
isCullingEnabled Method
isDoorOpeningRendering Method
isFaceRendering Method
isForceTwoSidedRendering Method
isFullScreen Method Whether the viewer is in full screen: the browser's, or the container's layout without the Fullscreen API
isGridEnabled Method
isIfcLineRendering Method
isObjectHoverEnabled Method
isOfflineMode Method
isPickTargetActive Method Whether a tool waits for an object click (selectObject, object distance, a click handler); the hovered object then gets the pick-target highlight.
isPlanLabelsEnabled Method Whether the plan labels are on
isPointerLocked Method
isRunning Method Whether the viewer drives its own frame loop (start/stop)
isScanStationsEnabled Method Whether the markers of the scanner stations show
isTriangleLineRendering Method
isVertexRendering Method
linkCamera Method Keeps this viewer's camera and other's together, in the measurement frame (so it works across different render frames): whichever camera the user moves or an…
measureFrames Method Draws frames while the camera orbits its target and times them, for a performance measurement. The render loop is stopped meanwhile and each frame is waited …
measurementToModelCoordinates Method A point in the measurement frame in the model frame of the given model, before its alignment (the inverse of modelToMeasurementCoordinates); null when the mo…
measurementToRenderCoordinates Method A point in the measurement frame in render space, with the current render offset. see: CoordinateFrame
modelsHidden Method @bimworks/viewercommon!ModelVisibilityListener: hides the models' geometry as a whole implementationOf: ModelVisibilityListener.modelsHidden
modelsShown Method @bimworks/viewercommon!ModelVisibilityListener: shows the models' geometry again implementationOf: ModelVisibilityListener.modelsShown
modelToMeasurementCoordinates Method A point in raw model millimetres of the given model in the measurement frame (render coordinates minus the global base translation), which is what the measur…
needsRepaint Method Whether the viewer wants another frame: data still to upload, an animation or a camera move under way
pick Method Find what is under a position on the canvas - the object, the point hit and the normal of the face there - without changing the selection. The `rightMouseCli…
prepareOfflineModels Method Make a set of model versions available for offline use. While online, the viewer downloads everything needed to later load these models without a server conn…
quantityFigureToViewer Method A quantity figure as viewer geometry: the flat metre coordinates in model space become points in millimetres in the measurement frame of the model vid (its p…
reloadCurrentSpaceTracker Method Drops the tracker (after models were added or removed) and loads a fresh one.
remove2dModeListener Method
removedFromObbVisibleSet Method @bimworks/viewercommon!ObjectStateListener.removedFromObbVisibleSet implementationOf: ObjectStateListener.removedFromObbVisibleSet
removedFromSelectionSet Method Objects were removed from the selection implementationOf: ObjectStateListener.removedFromSelectionSet
removedFromVisibleSet Method Objects were hidden. Any of them that were selected have been deselected first implementationOf: ObjectStateListener.removedFromVisibleSet
removeEngineFailureListener Method
removeGisLayer Method Forgets a GIS layer entirely, so that a layer whose definition changed is rebuilt on the next toggle
removeKeyHandler Method
removeModeChangeListener Method Remove listener for mode updates
removeModelClusterListener Method
removeModels Method Models were unloaded implementationOf: ModelListener.removeModels
removeNavigationModeChangeListener Method
removeOfflineModels Method Remove model versions from the offline set and delete their stored data. Removing a vid that is not in the offline set is a no-op.
removeRepaintListener Method
removeResetListener Method
removeShadowChangeListener Method
removeSunChangeListener Method
removeWalkStartListener Method
render Method Request the viewer to re-render the content
renderToMeasurementCoordinates Method A point in render space (a pick coordinate, the camera eye) in the measurement frame. see: CoordinateFrame
resetResults Method Takes away what the shown result drew - BVL and query shapes, routes, result overlays, figure layers, BVL annotation layers - and undoes the object states it…
resetToDefaultView Method Puts the camera back at the default view of the loaded models
resetWireframes Method Restore wireframe visibility and colour defaults for the supplied objects, or all objects when omitted.
resize Method Resize the viewer. This should only ever be called when autoresizing is off. It is higly recommended to let the Viewer3d manage it's own size based on it's p…
restoreViewState Method Brings a captured view back: the object state (@bimworks/viewercommon!ObjectStateManager.restoreObjectState, models loaded since the capture keep their own s…
saveScreenshot Method Save a PNG through Flutter's native save picker or a browser download. Embedded clients may supply their own handler; returning false means cancelled.
scaleView Method Scales the camera by factor about a point of the measurement frame: the eye and the target about it, and an orthographic view's window too. A model whose a…
screenshot Method Will take a screenshot of the contents of the Viewer3d.
selectObject Method Pick one object for a tool without changing the viewer's ordinary selection. An empty-space click supplies null; clients may retry or cancel the handle.
selectVertex Method Waits for one click on a model and calls back with the point clicked, snapped to a nearby vertex or edge. A click on nothing calls back with null and keeps w…
set2dMode Method Switches between 3D and 2D. 2D shows the scene straight on from one side, orthographic: a plan from "top" (the default) or "bottom", an elevation from `"…
setAnnotationGroupVisible Method Shows or hides one annotation group in this viewer; remembered for annotations added to it later
setAnnotationLimit Method Show at most this many annotations, those nearest to the camera; 0 (the default) shows them all. Annotations hidden behind other geometry take no place, and …
setAnnotationScaleByDistance Method Draw annotations smaller the further they are from the camera (never larger than their normal size), except those whose Annotation.scaleByDistance is set. Ap…
setAnnotationsVisible Method Shows or hides all annotations in this viewer (another viewer on the same ObjectStateManager keeps its own); remembered for annotations added later
setBackgroundColor Method Change the background color
setBackgroundGradientEnabled Method Switch between the default vertical stage gradient and the flat colour set with setBackgroundColor. The flat colour is kept while the gradient is on, so a ca…
setBuildingStoreysVisibleExclusive Method Show only the objects of these building storeys, without their openings when hideOpenings implementationOf: ObjectStateListener.setBuildingStoreysVisibleExcl…
setBuildingStoreyVisibleExclusive Method Show only the objects of one building storey (ObjectStateManager.setBuildingStoreyVisibleExclusive with one storey) implementationOf: ObjectStateListener.set…
setCapStyles Method Sets the section cap style of objects: the pattern of their caps with SectionPlanes.capStyles (docs/section-cap-patterns.md). embedded: they are embedded ele…
setClickHandler Method While set, a click in the viewer goes to the handler instead of changing the selection; qid is null for a click on nothing. A tool's one-shot selectObject st…
setCullingBudget Method Sets the triangle budget: automatic (measured from the frame rate, the default) or a fixed number of triangles. Only the given properties change
setDeletionPreview Method Shows a deletion before it is committed, until clearDeletionPreview(key): the objects out of sight whatever the visibility asks (a recorded DELETE OBJECT), o…
setGisLayerOpacity Method Sets a GIS layer's opacity, 0 (invisible) .. 1 (opaque); kept, so a later (re)build of the layer has it. Imagery layers show it
setGridEnabled Method Show or hide the infinite reference grid: a horizontal plane of metric grid lines that extends to the horizon, intended as a starting point when modelling fr…
setGridOptions Method Configure the reference grid. Only the given properties are changed, the rest keep their current value. Has no effect on whether the grid is shown, see setGr…
setHoverFaceColor Method Set the face color for hovering. This color is mixed with the current color of the object (either original or overridden by user). Using a transparency compo…
setHoverWireframeColor Method Set the wireframe color for hovering. This color is mixed with the default wireframe color. Using a transparency component is currently not supported and res…
setMode Method Set the current viewer mode, either LOCAL (Using local coordinates) or GEO (Using geo coordinates)
setModelAlignment Method Shows a loaded model with this alignment without storing it (store it with the server's SetAlignment); null puts back the version's stored alignment. The sce…
setModelVisible Method Shows or hides a whole loaded model without unloading it; the scene bounds and the view fit follow the visible models. A version hidden before it is loaded l…
setMultiSelectMode Method Change the way multiselection is done (only applicable when ObjectStateManager's multiSelect is on). The default mode is SHIFT
setNearPlane Method Configure the perspective near plane in meters, or set it to "auto" to let the viewer calculate it from the current model and camera state.
setObbVisibleSet Method @bimworks/viewercommon!ObjectStateListener.setObbVisibleSet implementationOf: ObjectStateListener.setObbVisibleSet
setObjectHoverEnabled Method Whether objects light up (and report hover) under the pointer; default true. A tool that waits for a precise click switches it off, as the measuring tools do…
setOfflineMode Method Enter or exit offline mode. In offline mode the viewer makes no server calls: only models prepared with Viewer3d.prepareOfflineModels can be loaded, and View…
setPickTarget Method Aim at an object without the viewer's pointer: files dragged in from the desktop send the viewer no pointer events, so the caller picks (pick) under the drag…
setPlanCut Method The plan cut: a horizontal cut at height z (mm, render frame: CoordinateFrame) that removes what is above it and closes the cut with end caps, as a floor p…
setPlanLabelsEnabled Method Text labels in plan views (2D mode, see Viewer3dSettings.planLabels): the labels of ObjectStateManager.setLabels and a default label on every space, inside t…
setPlanLabelsHeight Method The plane the plan labels lie in (Viewer3dSettings.planLabels height). "top" (the default): the top of what the section planes keep of each object, so the …
setProximityFadeConfig Method Configure the camera-proximity fade that is applied to soft-occluder objects (see ObjectStateManager#setSoftOccluderSet). All distances are in model units (u…
setScanStationsEnabled Method Shows or hides the markers of the scanner stations (getScanStations): the realtime setting pointCloudScanStations. On by default. Viewer3D draws no markers a…
setSelectionMode Method Set the selection mode. Currently there are 2 modes, the default mode is SELECTION_DIRECT_PICKING.
setSelectionVisualization Method Change how selection is visualized throughout this viewer, including already selected and subsequently loaded objects. Requests an immediate redraw. The defa…
setShadows Method Shadows. "ground": a soft shadow straight below the models on an invisible ground plane, under any lighting. "sun": the sun's shadows on the models, terrain …
setSun Method Light the scene with the sun instead of the headlight, and set where it stands. Only the given options change; the others keep their values. The sun is compu…
setTextAnnotationMode Method Show text annotations as full labels (default), or dots that expand on dot/object hover. Applies immediately.
setToSelectionSet Method The selection was replaced (also by a click in single-select mode) implementationOf: ObjectStateListener.setToSelectionSet
setTransformPreview Method Draws objects moved by a rigid change in their model's own frame, until clearTransformPreview(key): mm in the model's coordinates, as BUL TRANSFORM writes it…
setTriangleLineRendering Method Draws the edges of every triangle, a diagnostic view
setVisibleSet Method The set of visible objects was replaced implementationOf: ObjectStateListener.setVisibleSet
setWireframeColor Method Override per-object wireframe colour with a CSS colour string, or null to restore the fixed default.
setWireframeRendering Method Sets when wireframes are drawn: always, only once the camera stands still, or never
setWireframeVisibility Method Override wireframe visibility per object. true shows edges even with hidden faces, false hides edges, null restores following object visibility (the default)…
setXRayVisualization Method Change how the ObjectStateManager's x-ray set (addToXRaySet / setXRaySet) is drawn. The x-ray set is independent of selection: its objects are drawn with tra…
showDiagnostics Method Open the inspection panel (also Ctrl+Shift+F12 with the canvas focused).
showDwgLayout Method Shows exactly one layout of a DWG model and fits the camera on it from the top
showModelCluster Method Shows only the cluster's models (the other clusters' are hidden), in LOCAL mode, and fits the view to them: what the viewer does with the biggest cluster aft…
showQuantityFigure Method Draw a quantity figure - the verification geometry a calculated quantity was measured on, as GET calculated.quantity..figure returns it (metres, model coor…
showRoute Method Draws a walkable route (the polyline produced by the ComputeRoute API task) as a lifted polyline coloured by surface class, door crossings marked. Remove it …
showTemporaryObbFor Method Shows the box of the objects until hideTemporaryObb(key) is called with the same key and type
showTransformGhost Method
showWalkableSurfaces Method Shows what is walkable (docs/walkable-surfaces-visualization-design.md): every walkable surface of the loaded models as a translucent polygon a little above …
sideView Method View the set of loaded models from the side
start Method Starts the viewer. The viewer will only redraw when needed.
startDefaultNavigation Method Start default navigation mode. This controls mouse and keyboard camera interaction behavior.
startDroneNavigation Method Start drone navigation mode. If fullscreen is true, browser fullscreen is requested before navigation starts.
startExtrusionDrawing Method Draws a footprint on a face and extrudes it into a solid, or edits an extrusion (options.edit). Enter or a click places it (onCommit), Escape stops (`onC…
startGameNavigation Method Start game navigation mode. If fullscreen is true, browser fullscreen is requested before navigation starts.
startMeshPlacement Method Places a mesh that is not in the model yet with the move/rotate tool (docs/placement-controls-design.md §7.4): it follows the cursor onto the face under it u…
startNavigationMode Method Start a predefined navigation mode or a custom mode declared in settings.navigationModes.
startObjectTransform Method Move or rotate objects. In Viewer3D-Next the objects themselves move while a ghost stays where they were: a drag on them moves them along the floor, arrows m…
startWalkNavigation Method Start walk navigation mode. This controls mouse and keyboard camera interaction behavior.
stop Method Stops the viewer. When the viewer is stopped, the view is not updated anymore. Any changes to the viewer will be accumulated and become visible as soon as th…
toggleAnimationEnabled Method Toggles the default animation, which is an animation that continously rotates the building along the Z-Axis; returns whether it now runs
toggleDoorOpeningRendering Method Toggle whether (generated) door openings are rendered. This only works for models that have been processed when the repository setting `features.generate_doo…
toggleFaceRendering Method Toggle whether faces are rendered.
toggleForceTwoSidedRendering Method Toggle whether to force always rendering faces two-sided (e.a. no back face culling). This overrules whatever BIM.works Repository has decided should happen.
toggleFullScreen Method Toggle whether the viewer is in fullscreen mode; the element that goes full screen is the setting browserFullscreenElement, else the container
toggleGisLayer Method Toggle a specific GIS Layer on or off; resolves when it has loaded (or is hidden). Throws for an unknown id
toggleIfcLineRendering Method Toggle whether ifc lines are rendered. IFC Lines are all lines that have been defined in the original IFC file, such as Axis and FootPrint representations.
toggleVertexRendering Method Toggle whether vertices are rendered. Currently this does not have much use, in the future it will be used for snapping.
toggleWireframeRendering Method Toggle whether wireframes are rendered. Wireframes are usually drawn to emphesize the edges and generally make the model look better
topView Method View the set of loaded models from the top
unloaded Method Objects were unloaded with their model: forget them implementationOf: ObjectStateListener.unloaded
updateModel Method Update the internal information for the given Version. If the given Version is not loaded currently, it is silently ignored. Call it after changing the geore…
usesPointerLock Method
viewFit Method Fit the given objects into view (ObjectStateManager.viewFit) implementationOf: ObjectStateListener.viewFit
viewFitMeasurement Method Fit the camera to a finished measurement (the "Zoom to" action of the measurement list). The box around the measurement's points is padded to at least minHal…
viewFitModels Method Fit the given models into view (ObjectStateManager.viewFitModels) implementationOf: ObjectStateListener.viewFitModels
viewFitQuantityFigure Method Fit the camera to a quantity figure, animated
walkPhysicsAvailable Method
zoom Method Zooms the camera towards (negative value) or away from (positive) the scene at the canvas centre, animated. In perspective the eye moves |value| mm along the…
zoomSteps Method Zooms as steps mouse-wheel notches do (positive towards the scene; one notch covers half the remaining distance), towards canvasPosition (CSS pixels) or th…

constructor#

TypeScript#
constructor(objectStateManager: ObjectStateManager, loadProgressHandler?: LoadProgressHandler, settings?: Viewer3dSettings, canvas?: HTMLCanvasElement, container?: HTMLElement)

Create a new Viewer3d.

Every viewer loads its own copy of the models, also when its ObjectStateManager is on the same ModelManager as another viewer's (Viewer3D-Next shares them).

Parameters#

Name Type Description
objectStateManager ObjectStateManager The ObjectStateManager manages all object related state such as visibility, color and selection
loadProgressHandler LoadProgressHandler An object that get's specific methods called when there is progress to be reported
settings Viewer3dSettings Optional settings
canvas HTMLCanvasElement A canvas to render on instead of one the viewer creates
container HTMLElement The element the viewer's overlays go in, when a canvas is given

canvas#

TypeScript#
readonly canvas: HTMLCanvasElement

The canvas the viewer renders on

client#

TypeScript#
readonly client: BimWorksClient

container#

TypeScript#
readonly container: HTMLElement

figures#

TypeScript#
public readonly figures: FigureLayers

Figure layers (docs/quantity-takeoff-design.md §8): many quantity figures at once - the parts of a sum - drawn as pickable overlays, one colour per entry state. Every resetResults clears them, like the overlays they are drawn with.

fontScaling#

TypeScript#
public fontScaling: number

The font size of the plan labels in pixels, 15 by default (as Viewer2d.fontScaling)

frames#

TypeScript#
public readonly frames: VersionFrames

Conversions between the render frame and a loaded version's own frame, @bimworks/viewercommon!VersionFrames

modelManager#

TypeScript#
readonly modelManager: ModelManager

objectStateManager#

TypeScript#
readonly objectStateManager: ObjectStateManager

overlays#

TypeScript#
public readonly overlays: OverlayManager

Check overlays (docs/check-overlays-design.md): semantic geometry a check sends with its result, bound to one model version and drawn with that model's placement. An overlay whose model is not loaded yet appears when it is. Arrow, area, label, path, mesh and glTF items; other item types are skipped with a warning. Overlays are result geometry: resetResults removes them, except those added with persistent: true.

settings#

TypeScript#
readonly settings: Viewer3dSettings

supportsGeometryOverlays#

TypeScript#
public readonly supportsGeometryOverlays: boolean

Whether a commit that moved objects reaches the loaded model in place: @bimworks/viewercommon!ModelManager.swapVersion with a geometry overlay loads the moved objects over the model, which stays loaded with its camera and object state. Viewer3D-Next when it loads the server's NXG files; false in Viewer3D: there the new version is loaded anew

implementationOf: ModelListener.supportsGeometryOverlays

supportsLiveTransform#

TypeScript#
public readonly supportsLiveTransform: boolean

Whether objects can be drawn moved in place (setTransformPreview, a live move/rotate): Viewer3D-Next

viewpoints#

TypeScript#
public readonly viewpoints: Viewpoints

Stored viewpoints: the view as a JSON value that outlives the session and loads in any order (@bimworks/viewercommon!Viewpoints.capture), and back (@bimworks/viewercommon!Viewpoints.restore) (BimRepository/docs/viewpoint-contents-design.md). captureViewState is the in-memory counterpart

measuring#

TypeScript#
public measuring(): Measuring

Get a reference to the Measuring component which can be used for measurements related actions

add2dModeListener#

TypeScript#
public add2dModeListener(listener: (side: ViewSide | null) => void): void

listener(side) when the viewer enters 2D (set2dMode, or a flat scene by itself), looks from another side, or leaves 2D (side null): to keep a 2D/3D switch in a user interface right

Parameters#

Name Type Description
listener (side: ViewSide | null) => void

addAnnotationLayer#

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

Add a layer of template annotations to every viewer of this viewer's object state manager: a shortcut for getObjectStateManager().addAnnotationLayer(options) (Viewer3D/docs/rich-annotations-design.md §5.3)

Type parameters#

Name Constraint Description
D ``

Parameters#

Name Type Description
options AnnotationLayerOptions<D>

addDwgSemanticsListener#

TypeScript#
public addDwgSemanticsListener(listener: (versionUuid: string, semantics: DwgSemantics) => void): void

listener(versionUuid, semantics) is called when a DWG model's (or geometry PDF's) layouts load, before its sheets are hidden

Parameters#

Name Type Description
listener (versionUuid: string, semantics: DwgSemantics) => void

addedToObbVisibleSet#

TypeScript#
public addedToObbVisibleSet(qids: QidSet, force: boolean, type: string, originalQueryList?: (string)[] | null, options?: StateChangeOptions): void

Objects whose oriented bounding box is drawn

implementationOf: ObjectStateListener.addedToObbVisibleSet

Parameters#

Name Type Description
qids QidSet
force boolean
type string
originalQueryList (string)[] | null
options StateChangeOptions

addedToSelectionSet#

TypeScript#
public addedToSelectionSet(qids: Iterable<Qid>): Promise<void>

Objects were added to the selection

implementationOf: ObjectStateListener.addedToSelectionSet

Parameters#

Name Type Description
qids Iterable<Qid> The objects added

addedToVisibleSet#

TypeScript#
public addedToVisibleSet(qids: QidSet, force: boolean, type: string, originalQueryList?: (string)[] | null, options?: StateChangeOptions): void

Objects were made visible

implementationOf: ObjectStateListener.addedToVisibleSet

Parameters#

Name Type Description
qids QidSet
force boolean
type string
originalQueryList (string)[] | null
options StateChangeOptions

addEngineFailureListener#

TypeScript#
public addEngineFailureListener(listener: (failure: Viewer3dEngineFailure) => void): void

Called once when the viewer gives up on the GPU. Viewer3D: the WebGL context was lost, as when the browser's GPU process is killed ({engine: "webgl", reason: "context-lost"}). Viewer3D-Next: the device kept getting lost, or no new one could be made. The viewer draws and picks nothing any more and is not restored; destroy it and build a new one on the same ObjectStateManager (a Viewer3D after Viewer3D-Next), or reload the page.

Parameters#

Name Type Description
listener (failure: Viewer3dEngineFailure) => void

addGisLayer#

TypeScript#
public addGisLayer(id: string, gisLayer: GisLayer): void

Adds a GIS layer definition to the viewer. It loads now only when visible is true; an invisible layer is only registered (a terrain known before the imagery that drapes over it, a layer switched on later with toggleGisLayer)

Parameters#

Name Type Description
id string
gisLayer GisLayer

addKeyHandler#

TypeScript#
public addKeyHandler(handler: (event: KeyboardEvent, bindingType: string | undefined) => boolean): void

handler(event, bindingType) runs on a key-up in the viewer before the viewer's own handling and returns true when it consumed the key (the takeoff editor's O and Delete); a consumed key-up does not propagate to the host. bindingType is the key binding's name, e.g. "toggleAreaHoles" for O; undefined for an unbound key.

Parameters#

Name Type Description
handler (event: KeyboardEvent, bindingType: string | undefined) => boolean

addModeChangeListener#

TypeScript#
public addModeChangeListener(listener: (mode: ViewerMode) => void): void

Add a listener for mode updates

Parameters#

Name Type Description
listener (mode: ViewerMode) => void

addModelClusterListener#

TypeScript#
public addModelClusterListener(listener: ModelClusterListener): void

listener.modelClustersChanged(clusters) whenever the clusters were computed again (after models were loaded or unloaded)

Parameters#

Name Type Description
listener ModelClusterListener

addModels#

TypeScript#
public addModels(versions: (Version)[]): Promise<void>

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

implementationOf: ModelListener.addModels

Parameters#

Name Type Description
versions (Version)[] The versions that were added

addNavigationModeChangeListener#

TypeScript#
public addNavigationModeChangeListener(listener: (mode: string) => void): void

Includes navigation exits initiated by Escape or loss of pointer lock.

Parameters#

Name Type Description
listener (mode: string) => void

addQuantityFigureAsMeasurements#

TypeScript#
public addQuantityFigureAsMeasurements(figure: QuantityFigure, options?: QuantityFigureOptions): (Measurement)[]

Turn a quantity figure into committed measurements: an area (with holes) per polygon, a path per polyline, a distance per dimension; a box is not convertible. Their labels are recomputed by the viewer, so they can differ from the stored quantity on a curved or simplified figure.

Parameters#

Name Type Description
figure QuantityFigure
options QuantityFigureOptions

Returns#

The measurements added, at most 16

addRepaintListener#

TypeScript#
public addRepaintListener(fn: () => void): void

fn() when the viewer wants a frame; once per request, not once per internal change

Parameters#

Name Type Description
fn () => void

addResetListener#

TypeScript#
public addResetListener(listener: () => void): void

listener() is called by every resetResults: whoever owns the shown result lets go of it

Parameters#

Name Type Description
listener () => void

addShadowChangeListener#

TypeScript#
public addShadowChangeListener(listener: (shadows: ShadowState) => void): void

Called with the new state whenever the shadow settings change.

Parameters#

Name Type Description
listener (shadows: ShadowState) => void

addSunChangeListener#

TypeScript#
public addSunChangeListener(listener: (sun: SunState) => void): void

Called with the new state whenever the sun changes: settings, mode, or the reference model.

Parameters#

Name Type Description
listener (sun: SunState) => void

addWalkStartListener#

TypeScript#
public addWalkStartListener(listener: (state: WalkStart) => void): void

Told every change of getWalkStart, and of getWalkPreparation

Parameters#

Name Type Description
listener (state: WalkStart) => void

applyDiagnosticCamera#

TypeScript#
public applyDiagnosticCamera(camera: { direction: (number)[]; fov?: number; position: (number)[]; up: (number)[] }): Promise<void>

Apply an explicit, validated camera probe without animation. Position/direction are metres.

Parameters#

Name Type Description
camera { direction: (number)[]; fov?: number; position: (number)[]; up: (number)[] }

cameraPoseUpdated#

TypeScript#
cameraPoseUpdated(sourceViewer: unknown, pose: Pose): void

The pose (eye, pivot, target) of a camera has been updated (ObjectStateManager.setCameraPose)

implementationOf: ObjectStateListener.cameraPoseUpdated

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

cancelObjectSelection#

TypeScript#
public cancelObjectSelection(handle: object): void

Parameters#

Name Type Description
handle object

captureViewState#

TypeScript#
public captureViewState(): ViewStateSnapshot

The view as it is now, as a value to give back to restoreViewState later: the object state (@bimworks/viewercommon!ObjectStateManager.captureObjectState: visibility, colours, on-top, sectionable, pickable, x-ray), the camera (Camera.getViewpoint) and how section planes cut the model (SectionPlanes.getState). 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, instead of undoing each of its own changes.

Returns#

A new value, not live

clearAnnotations#

TypeScript#
public clearAnnotations(): void

Removes the annotations this viewer shows. Annotation layers stay; ObjectStateManager.clearAnnotations() removes those too, in every viewer

implementationOf: ObjectStateListener.clearAnnotations

clearClickHandler#

TypeScript#
public clearClickHandler(): void

clearDeletionPreview#

TypeScript#
public clearDeletionPreview(key: string, options?: { committed?: boolean }): void

Parameters#

Name Type Description
key string
options { committed?: boolean }

clearPaths#

TypeScript#
public clearPaths(): void

Removes all route polylines and stops any route playback.

clearQuantityFigures#

TypeScript#
public clearQuantityFigures(): void

Remove every quantity figure

clearTransformPreview#

TypeScript#
public clearTransformPreview(key: string): void

Parameters#

Name Type Description
key string

colorReset#

TypeScript#
public colorReset(qids: Iterable<Qid>): void | Promise<void>

The colour of the given objects has been reset to their own

implementationOf: ObjectStateListener.colorReset

Parameters#

Name Type Description
qids Iterable<Qid> The objects whose colour was reset

destroy#

TypeScript#
public destroy(): void

Destroys the viewer and any (heavy) resources associated with it. As long as there is a reference to the Viewer3d instance it won't be completely destroyed.

disableSectionPlanes#

TypeScript#
public disableSectionPlanes(): void

Disable any active sectionplanes

endPickTarget#

TypeScript#
public endPickTarget(): void

End setPickTarget: the object loses its highlight

ensureCurrentSpaceTracker#

TypeScript#
public ensureCurrentSpaceTracker(settings?: Partial<CurrentSpaceTrackerSettings>): Promise<CurrentSpaceTracker | null>

The tracker that knows which IfcSpace / IfcZone the camera is in (docs/current-space-design.md): loads the server-generated space index of the loaded models on first call, then locates the camera locally on every camera change and fires "current_space_changed" / "current_zone_changed". Resolves to null when no loaded model has a space index. With settings, a new tracker is created with them and an existing one is configured with them (CurrentSpaceTracker.configure).

Parameters#

Name Type Description
settings Partial<CurrentSpaceTrackerSettings>

focus#

TypeScript#
public focus(): void

Focus the viewer (keyboard focus on its canvas). Does not scroll the page.

followRoute#

TypeScript#
public followRoute(route: WalkableRoute, options?: FollowRouteOptions): PathFollowerHandle

Flies the camera along a route at constant walking speed (default 1.4 m/s), the look target running ahead - the interactive preview of the server-rendered flythrough video. Playback starts immediately unless options.autoplay === false.

Parameters#

Name Type Description
route WalkableRoute
options FollowRouteOptions

frontView#

TypeScript#
public frontView(): void

View the set of loaded models from the front

get2dSide#

TypeScript#
public get2dSide(): ViewSide | null

The side 2D mode looks from, null in 3D; "top" for a flat scene that is in 2D by itself

getAnnotationGroups#

TypeScript#
public getAnnotationGroups(): (string)[]

The group names (Annotation.group, an AnnotationLayer's group) of the annotations shown in this viewer

getAnnotationLayers#

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

The annotation layers of this viewer's object state manager

getAnnotationLimit#

TypeScript#
public getAnnotationLimit(): number

At most how many annotations are shown, 0 for no limit.

getAnnotationScaleByDistance#

TypeScript#
public getAnnotationScaleByDistance(): boolean

Whether annotations are drawn smaller further away, unless they say otherwise.

getBackgroundColor#

TypeScript#
public getBackgroundColor(): vec4

Returns#

The background colour, components 0..1

getCamera#

TypeScript#
public getCamera(): Camera

Returns#

The current Camera

getCanvas#

TypeScript#
public getCanvas(): HTMLCanvasElement

Returns#

The Canvas element used for rendering 3D content

getCullingBudget#

TypeScript#
public getCullingBudget(): { automatic: boolean; current: number; supported: boolean; triangles: number }

Returns#

The triangle budget culling keeps to while the camera moves: whether the running culler supports one, whether it is measured from the frame rate, the fixed number of triangles, and the budget in effect now

getCurrentSpaceTracker#

TypeScript#
public getCurrentSpaceTracker(): CurrentSpaceTracker | null

The current-space tracker if one exists and is not disposed; never creates one (use ensureCurrentSpaceTracker for that)

getDiagnostics#

TypeScript#
public getDiagnostics(): { annotations: (Record<string, unknown>)[]; camera: unknown; errors: ([string, string])[]; loading: boolean; models: (string)[]; objects: (Record<string, unknown>)[]; pending_models: (string)[]; schema: number }

Detached applied-state, renderer-membership and annotation-DOM diagnostics; not a pixel certificate.

getDrawingPaperUnitMm#

TypeScript#
public getDrawingPaperUnitMm(vid: string): number | null

Paper millimetres per model millimetre of a loaded PDF (docs/drawing-scale-design.md §8.4): 1 for a geometry PDF, whose model unit converts to paper millimetres, 25.4/72 for a raster PDF, whose model unit is the PDF point. A sheet scale 1:n is then an alignment scale of n times this. null for a DWG, any other model, or one not loaded

Parameters#

Name Type Description
vid string

getDwgSemanticsMap#

TypeScript#
public getDwgSemanticsMap(): ReadonlyMap<string, DwgSemantics>

Returns#

versionUuid → the layouts of every loaded DWG model (and geometry PDF) that has them; the viewer's own map, do not change it

getFocusAabb#

TypeScript#
public getFocusAabb(): AxisAlignedBoundingBox3D

The main bounds of the visible models where they render (render frame, mm), the box the toolbar's fit uses with Camera.viewFit: outlying parts left out, as getMainBounds. A new box on every call; empty (isEmpty()) while no model is visible

getGeoFrameOrigin#

TypeScript#
public getGeoFrameOrigin(): { anchorZ: number; elevation: number; latitude: number; longitude: number } | null

GEO mode: where the render frame sits on the globe. Its x/y origin is the reference model's georeference anchor, at the georeference's longitude/latitude (WGS84 degrees) and elevation (metres); anchorZ is the anchor's height in the render frame (mm). The frame's axes are east, north and up. Null while no georeferenced model is loaded

getGisLayer#

TypeScript#
public getGisLayer(id: string): GisLayerState | null

What the viewer knows about a GIS layer, a copy; null for an unknown id

Parameters#

Name Type Description
id string

getGisLayers#

TypeScript#
public getGisLayers(): (GisLayerState)[]

Every GIS layer the viewer knows, as copies

getGridOptions#

TypeScript#
public getGridOptions(): Required<GridOptions>

Returns#

The current reference grid configuration, with every property populated.

getGridSnapSpacing#

TypeScript#
public getGridSnapSpacing(): number | null

The grid line spacing that snapping is currently using, which follows the zoom level, so it can be shown in the UI as the active increment.

Returns#

The spacing in meters, or null when the grid is hidden, grid snapping is off, or the grid plane is not in view.

getHeight#

TypeScript#
public getHeight(): number

Get the height of the viewer in pixels

getMainBounds#

TypeScript#
public getMainBounds(): AxisAlignedBoundingBox3D

Get the Axis Aligned Bounding Box (AABB) of the main content. For most models (or model sets) these are just the bounds of all 3D geometry. In certain cases the "Main" bounds are smaller than the real bounds, for example in models that have line geometry that extends beyond the 3D geometry, als certain IFC types are generally regarded as not being part of the main bounds.

Returns#

An AxisAlignedBoundingBox3D object

getMode#

TypeScript#
public getMode(): ViewerMode

Returns#

The current viewer mode, either LOCAL (Using local coordinates) or GEO (Using geo coordinates)

getModelAlignment#

TypeScript#
public getModelAlignment(versionUuid: string): mat4 | null

The alignment in effect for a loaded model: a rigid transform of its model frame (mm, column-major), or null for none. A preview set with setModelAlignment wins over the version's stored alignment. A copy.

Parameters#

Name Type Description
versionUuid string

getModelBounds#

TypeScript#
public getModelBounds(versionUuids: Iterable<string>): AxisAlignedBoundingBox3D

The bounds of the given models where they render, alignment and placement applied

Parameters#

Name Type Description
versionUuids Iterable<string>

getModelClusters#

TypeScript#
public getModelClusters(): (ModelCluster)[]

The model clusters, as values: models more than ~10 km apart form separate clusters (setting clustering)

getModelFrameBounds#

TypeScript#
public getModelFrameBounds(versionUuid: string): { max: vec3; min: vec3 } | null

A loaded model's main bounds (outlying parts left out, as getModelBounds) in its own model frame (raw model mm, the frame modelToMeasurementCoordinates takes), before alignment and placement; null when it is not loaded. getModelBounds gives them where the model renders

Parameters#

Name Type Description
versionUuid string

getModelLengthUnitMm#

TypeScript#
public getModelLengthUnitMm(vid: string): number | null

Millimetres per length unit of a loaded model (1 for a model in mm, 1000 for metres); null when it is not loaded

Parameters#

Name Type Description
vid string

getModelsWithoutGeoReference#

TypeScript#
public getModelsWithoutGeoReference(): (string)[]

The loaded models without a georeference, by version uuid: while there are any, setMode refuses GEO mode

getMovablePlanes#

TypeScript#
public getMovablePlanes(): MovablePlanes

Get a reference to the MovablePlanes component: planes with a drag icon that do not cut, in any number, with listeners

getMultiSelectMode#

TypeScript#
public getMultiSelectMode(): MultiSelectMode

The current multiselection mode

getNavigationMode#

TypeScript#
public getNavigationMode(): string

Returns#

The current predefined navigation mode or custom navigation mode name.

getNearPlane#

TypeScript#
public getNearPlane(): NearPlane

Returns#

The configured near plane in meters, or "auto" when automatic near-plane calculation is enabled.

getObjectsAabb#

TypeScript#
public getObjectsAabb(qids: Iterable<Qid>): Promise<{ max: vec3; min: vec3 } | null>

One axis-aligned box around the objects in render space, as a value; null when none of them is loaded

Parameters#

Name Type Description
qids Iterable<Qid>

getObjectsObb#

TypeScript#
public getObjectsObb(qids: Iterable<Qid>): Promise<Obb | null>

One oriented box around the objects (merged on the first object's axes), in render space; null when none of them is loaded

Parameters#

Name Type Description
qids Iterable<Qid>

getOfflineModels#

TypeScript#
public getOfflineModels(): Promise<(OfflineModelInfo)[]>

Returns#

Information about all model versions currently available for offline use. Works both online and offline.

getOfflineVersions#

TypeScript#
public getOfflineVersions(vids: (string)[]): Promise<(Version)[]>

Get the stored Version objects for offline-prepared models. This is the offline replacement for client.fs.getNodeVersion(): use the returned Version objects with Viewer3d.addModels while in offline mode.

Parameters#

Name Type Description
vids (string)[] The version UUIDs

Exceptions#

  • ModelNotAvailableOfflineError when any vid is not available offline

getPlanCut#

TypeScript#
public getPlanCut(): number | null

The height of the plan cut (setPlanCut), null without one

getPlanLabelsHeight#

TypeScript#
public getPlanLabelsHeight(): "top" | "bottom"

The plane the plan labels lie in: "top" (the default) or "bottom", see setPlanLabelsHeight

getQuantityFigureBounds#

TypeScript#
public getQuantityFigureBounds(figure: QuantityFigure, options?: QuantityFigureOptions): AxisAlignedBoundingBox3D | null

The bounding box of a quantity figure in render coordinates, null for an empty figure

Parameters#

Name Type Description
figure QuantityFigure
options QuantityFigureOptions

getScanStations#

TypeScript#
public getScanStations(): (ScanStation)[]

Where the scans of the loaded point clouds were taken, shown as markers in the view by Viewer3D-Next. Viewer3D keeps no stations: empty

getSectionPlanes#

TypeScript#
public getSectionPlanes(): SectionPlanes

Get a reference to the SectionPlanes component which can be used for creating/modifying/removing section planes and boxes

getSelectionMode#

TypeScript#
public getSelectionMode(): SelectionMode

Returns#

The current selection mode

getSelectionVisualization#

TypeScript#
public getSelectionVisualization(): SelectionVisualization

Returns the current viewer-wide selection style. Reapply with setSelectionVisualization after editing.

getShadows#

TypeScript#
public getShadows(): ShadowState

Returns#

The shadow settings, whether shadows are drawn now, and the last shadow map's cost.

getSun#

TypeScript#
public getSun(): SunState

Returns#

The sun's settings and where it stands.

getTextAnnotationMode#

TypeScript#
public getTextAnnotationMode(): "label" | "dot"

Current text annotation display mode.

getWalkableSurfaces#

TypeScript#
public getWalkableSurfaces(): WalkableSurfacesViewHandle | null

The handle of the walkable-surfaces view that is shown, or null. Viewer3D-Next only: always null in Viewer3D.

getWalkPreparation#

TypeScript#
public getWalkPreparation(): { ready: number; total: number } | null

While getWalkStart is "preparing": how many of the loaded models' walkable surfaces are there (ready, loaded or found to have none) of total; null otherwise. Each change is told to the walk-start listeners.

getWalkStart#

TypeScript#
public getWalkStart(): WalkStart

Where the start of a walk or game stands. Walk and game mode start where the camera is when the feet (the eye less the character's eye height) are at most 2 m above a walkable surface: the walker drops onto it ("landing", movement, jumps and storey keys do nothing until it stands) and walks. Otherwise the user picks the start ("picking"): when the mode is entered from a level view outside the building (as every model opens), the camera first flies to a view of the building from 50° above; the view navigates as in the default mode, an avatar follows the cursor while it is over a face the walker can stand on (an up-facing face with a walkable surface at the picked point) and is hidden anywhere else, and a click on such a face starts the walk there; a click anywhere else does nothing (game mode captures the mouse only once the walk starts). Escape or another mode cancels. "none" while walking, and outside walk and game mode. Before any of that, "preparing" while the walkable surfaces of the loaded models load (getWalkPreparation): on the first walk of a model set the server may build them first, up to some seconds per model; the view navigates as in walk mode without collision meanwhile.

getWidth#

TypeScript#
public getWidth(): number

Get the width of the viewer in pixels

getWireframeRendering#

TypeScript#
public getWireframeRendering(): WireframeRendering

Returns#

What mode of wireframe rendering is in

getXRayVisualization#

TypeScript#
public getXRayVisualization(): XRayVisualization

Returns the current x-ray set style. Reapply with setXRayVisualization after editing.

hideDwgSheets#

TypeScript#
public hideDwgSheets(versionUuid: string): void

Shows a DWG model's model space again and hides its sheets: the way back from showDwgLayout with a sheet

Parameters#

Name Type Description
versionUuid string

hideQuantityFigure#

TypeScript#
public hideQuantityFigure(key: string): void

Remove the quantity figure shown under the key, if any

Parameters#

Name Type Description
key string

hideTemporaryObb#

TypeScript#
public hideTemporaryObb(key: string, type?: string): void

Parameters#

Name Type Description
key string
type string

hideTransformGhost#

TypeScript#
public hideTransformGhost(key: string): void

Parameters#

Name Type Description
key string

hideWalkableSurfaces#

TypeScript#
public hideWalkableSurfaces(): void

Takes the walkable-surfaces view away, if one is shown.

hoverOff#

TypeScript#
public hoverOff(qid: Qid): void

Called when the given object is not being hovered on anymore

implementationOf: ObjectStateListener.hoverOff

Parameters#

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

hoverOn#

TypeScript#
public hoverOn(qid: Qid, previousQid: Qid | null | undefined, screenspaceLocation?: vec2): void

Called when the given object is being hovered on

implementationOf: ObjectStateListener.hoverOn

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

initializeViewer#

TypeScript#
public initializeViewer(): Promise<void>

Initializes the Viewer3d, it is important to wait for this async method to finish before calling any other methods on the viewer

is2dMode#

TypeScript#
public is2dMode(): boolean

Whether the viewer is in 2D mode, by set2dMode or because the scene is flat

isAnimationEnabled#

TypeScript#
public isAnimationEnabled(): boolean

Whether the default animation (the rotation along the Z-axis, toggleAnimationEnabled) runs

isAnnotationGroupVisible#

TypeScript#
public isAnnotationGroupVisible(group: string): boolean

Parameters#

Name Type Description
group string

isAnnotationsVisible#

TypeScript#
public isAnnotationsVisible(): boolean

isBackgroundGradientEnabled#

TypeScript#
public isBackgroundGradientEnabled(): boolean

Returns#

Whether the background is currently painted as the default gradient rather than as the flat colour from setBackgroundColor.

isCullingEnabled#

TypeScript#
public isCullingEnabled(): boolean

Returns#

Whether this viewer culls while the camera moves. Fixed when the viewer is created (realtimeSettings.culling)

isDoorOpeningRendering#

TypeScript#
public isDoorOpeningRendering(): boolean

Returns#

Whether rendering of generated door opening directions is currently enabled

isFaceRendering#

TypeScript#
public isFaceRendering(): boolean

Returns#

Whether face rendering is currently enabled

isForceTwoSidedRendering#

TypeScript#
public isForceTwoSidedRendering(): boolean

Returns#

Whether forced two-sided rendering is currently enabled

isFullScreen#

TypeScript#
public isFullScreen(): boolean

Whether the viewer is in full screen: the browser's, or the container's layout without the Fullscreen API

isGridEnabled#

TypeScript#
public isGridEnabled(): boolean

Returns#

Whether the reference grid is currently shown.

isIfcLineRendering#

TypeScript#
public isIfcLineRendering(): boolean

Returns#

Whether IFC line rendering is currently enabled

isObjectHoverEnabled#

TypeScript#
public isObjectHoverEnabled(): boolean

isOfflineMode#

TypeScript#
public isOfflineMode(): boolean

Returns#

Whether the viewer is currently in offline mode

isPickTargetActive#

TypeScript#
public isPickTargetActive(): boolean

Whether a tool waits for an object click (selectObject, object distance, a click handler); the hovered object then gets the pick-target highlight.

isPlanLabelsEnabled#

TypeScript#
public isPlanLabelsEnabled(): boolean

Whether the plan labels are on

isPointerLocked#

TypeScript#
public isPointerLocked(): boolean

Returns#

Whether the view has captured the mouse right now

isRunning#

TypeScript#
public isRunning(): boolean

Whether the viewer drives its own frame loop (start/stop)

isScanStationsEnabled#

TypeScript#
public isScanStationsEnabled(): boolean

Whether the markers of the scanner stations show

isTriangleLineRendering#

TypeScript#
public isTriangleLineRendering(): boolean

Returns#

Whether the edges of every triangle are drawn (setTriangleLineRendering)

isVertexRendering#

TypeScript#
public isVertexRendering(): boolean

Returns#

Whether vertex rendering is currently enabled

linkCamera#

TypeScript#
public linkCamera(other: Viewer3d, options?: { bridge?: CameraLinkBridge }): CameraLink

Keeps this viewer's camera and other's together, in the measurement frame (so it works across different render frames): whichever camera the user moves or animates leads, and a press in the follower takes over at once. This viewer's camera is copied to other first. When both cameras are orthographic (two plans, two elevations) their zoom goes along too. Works before either viewer is initialized.

The link knows nothing of 2D mode: a 3D camera linked to a plan turns the plan with it. Link two viewers that look the same way (get2dSide the same), and drop the link while they do not.

Parameters#

Name Type Description
other Viewer3d
options { bridge?: CameraLinkBridge } bridge: converts between the two viewers' measurement frames when they differ, for example two viewers of the same model whose first loaded models (the GEO mode's reference) or alignments differ; without it the measurement frames are taken to be the same

Exceptions#

  • Error when bridge lacks toOther or fromOther

measureFrames#

TypeScript#
public measureFrames(options?: FrameMeasurementOptions): Promise<FrameMeasurement>

Draws frames while the camera orbits its target and times them, for a performance measurement. The render loop is stopped meanwhile and each frame is waited for on the GPU, so the frame rate is not capped by the display's; the camera and the render loop are put back afterwards. Load the models and let the camera come to rest first.

Parameters#

Name Type Description
options FrameMeasurementOptions

Example#

JavaScript#
const full = await viewer.measureFrames();
const moving = await viewer.measureFrames({navigating: true});
console.log(full.framesPerSecond, moving.framesPerSecond, full.frame.p95);

measurementToModelCoordinates#

TypeScript#
public measurementToModelCoordinates(vid: string, point: vec3): vec3 | null

A point in the measurement frame in the model frame of the given model, before its alignment (the inverse of modelToMeasurementCoordinates); null when the model is not loaded

see: CoordinateFrame

Parameters#

Name Type Description
vid string
point vec3

measurementToRenderCoordinates#

TypeScript#
public measurementToRenderCoordinates(point: vec3): vec3

A point in the measurement frame in render space, with the current render offset.

see: CoordinateFrame

Parameters#

Name Type Description
point vec3

modelsHidden#

TypeScript#
public modelsHidden(versionUuids: Iterable<string>): void

@bimworks/viewercommon!ModelVisibilityListener: hides the models' geometry as a whole

implementationOf: ModelVisibilityListener.modelsHidden

Parameters#

Name Type Description
versionUuids Iterable<string>

modelsShown#

TypeScript#
public modelsShown(versionUuids: Iterable<string>): void

@bimworks/viewercommon!ModelVisibilityListener: shows the models' geometry again

implementationOf: ModelVisibilityListener.modelsShown

Parameters#

Name Type Description
versionUuids Iterable<string>

modelToMeasurementCoordinates#

TypeScript#
public modelToMeasurementCoordinates(vid: string, pointMm: vec3): vec3

A point in raw model millimetres of the given model in the measurement frame (render coordinates minus the global base translation), which is what the measurement tools take

Parameters#

Name Type Description
vid string
pointMm vec3

needsRepaint#

TypeScript#
public needsRepaint(): boolean

Whether the viewer wants another frame: data still to upload, an animation or a camera move under way

pick#

TypeScript#
public pick(canvasX: number, canvasY: number): Promise<PickResult | null>

Find what is under a position on the canvas - the object, the point hit and the normal of the face there - without changing the selection. The rightMouseClick setting already receives this for the position of the right click; use this method when your UI picks at another moment, for example a tool that waits for the next click on a face.

Parameters#

Name Type Description
canvasX number CSS pixels from the left edge of the canvas, e.g. MouseEvent.offsetX of an event on the canvas
canvasY number CSS pixels from the top edge of the canvas, e.g. MouseEvent.offsetY

Returns#

What is under the position, or null when the viewer could not pick (before its first frame, or the camera moved while picking)

Example#

JavaScript#
const pick = await viewer.pick(event.offsetX, event.offsetY);
if (pick?.normal) {
    viewer.getSectionPlanes().startPlaneAt(pick.coordinate, pick.normal);
}

prepareOfflineModels#

TypeScript#
public prepareOfflineModels(vids: (string)[], options?: OfflinePrepareOptions): Promise<OfflinePrepareResult>

Make a set of model versions available for offline use. While online, the viewer downloads everything needed to later load these models without a server connection and stores it in the browser (IndexedDB).

IFC/BIM and PDF models are supported; point cloud and GLB versions are reported as skippedUnsupported in the result.

Preparing a vid that is already available offline refreshes it (re-downloads and replaces the stored data). Do this after the server has been updated/reindexed: reindexing on the server breaks offline-stored models (see the note at Viewer3d.setOfflineMode).

Parameters#

Name Type Description
vids (string)[] The version UUIDs to prepare
options OfflinePrepareOptions Optional progress callback

Returns#

A per-vid result: prepared, failed (with reason) or skippedUnsupported

Example#

JavaScript#
const result = await viewer.prepareOfflineModels([vid1, vid2], {
    progress: (vid, percentage) => console.log(vid, percentage)
});

quantityFigureToViewer#

TypeScript#
public quantityFigureToViewer(figure: QuantityFigure, vid: string): ViewerQuantityFigure | null

A quantity figure as viewer geometry: the flat metre coordinates in model space become points in millimetres in the measurement frame of the model vid (its placement applied, see modelToMeasurementCoordinates). Primitives with too few points are dropped

Parameters#

Name Type Description
figure QuantityFigure The figure JSON, as for showQuantityFigure
vid string The version uuid of the model the figure belongs to

Returns#

The converted figure, or null when the figure has no usable primitive

reloadCurrentSpaceTracker#

TypeScript#
public reloadCurrentSpaceTracker(settings?: Partial<CurrentSpaceTrackerSettings>): Promise<CurrentSpaceTracker | null>

Drops the tracker (after models were added or removed) and loads a fresh one.

Parameters#

Name Type Description
settings Partial<CurrentSpaceTrackerSettings>

remove2dModeListener#

TypeScript#
public remove2dModeListener(listener: (side: ViewSide | null) => void): void

Parameters#

Name Type Description
listener (side: ViewSide | null) => void

removedFromObbVisibleSet#

TypeScript#
public removedFromObbVisibleSet(qids: QidSet, type: string): void

@bimworks/viewercommon!ObjectStateListener.removedFromObbVisibleSet

implementationOf: ObjectStateListener.removedFromObbVisibleSet

Parameters#

Name Type Description
qids QidSet
type string

removedFromSelectionSet#

TypeScript#
public removedFromSelectionSet(qids: QidSet, type: string): void

Objects were removed from the selection

implementationOf: ObjectStateListener.removedFromSelectionSet

Parameters#

Name Type Description
qids QidSet The objects that are no longer selected
type string The origin of the change

removedFromVisibleSet#

TypeScript#
public removedFromVisibleSet(qids: QidSet): void

Objects were hidden. Any of them that were selected have been deselected first

implementationOf: ObjectStateListener.removedFromVisibleSet

Parameters#

Name Type Description
qids QidSet

removeEngineFailureListener#

TypeScript#
public removeEngineFailureListener(listener: (failure: Viewer3dEngineFailure) => void): void

Parameters#

Name Type Description
listener (failure: Viewer3dEngineFailure) => void

removeGisLayer#

TypeScript#
public removeGisLayer(id: string): void

Forgets a GIS layer entirely, so that a layer whose definition changed is rebuilt on the next toggle

Parameters#

Name Type Description
id string

removeKeyHandler#

TypeScript#
public removeKeyHandler(handler: (event: KeyboardEvent, bindingType: string | undefined) => boolean): void

Parameters#

Name Type Description
handler (event: KeyboardEvent, bindingType: string | undefined) => boolean

removeModeChangeListener#

TypeScript#
public removeModeChangeListener(listener: (mode: ViewerMode) => void): void

Remove listener for mode updates

Parameters#

Name Type Description
listener (mode: ViewerMode) => void

removeModelClusterListener#

TypeScript#
public removeModelClusterListener(listener: ModelClusterListener): void

Parameters#

Name Type Description
listener ModelClusterListener

removeModels#

TypeScript#
public removeModels(versions: Iterable<Version>): void | Promise<void>

Models were unloaded

implementationOf: ModelListener.removeModels

Parameters#

Name Type Description
versions Iterable<Version> The versions that were removed

removeNavigationModeChangeListener#

TypeScript#
public removeNavigationModeChangeListener(listener: (mode: string) => void): void

Parameters#

Name Type Description
listener (mode: string) => void

removeOfflineModels#

TypeScript#
public removeOfflineModels(vids: (string)[]): Promise<void>

Remove model versions from the offline set and delete their stored data. Removing a vid that is not in the offline set is a no-op.

Parameters#

Name Type Description
vids (string)[] The version UUIDs to remove

removeRepaintListener#

TypeScript#
public removeRepaintListener(fn: () => void): void

Parameters#

Name Type Description
fn () => void

removeResetListener#

TypeScript#
public removeResetListener(listener: () => void): void

Parameters#

Name Type Description
listener () => void

removeShadowChangeListener#

TypeScript#
public removeShadowChangeListener(listener: (shadows: ShadowState) => void): void

Parameters#

Name Type Description
listener (shadows: ShadowState) => void

removeSunChangeListener#

TypeScript#
public removeSunChangeListener(listener: (sun: SunState) => void): void

Parameters#

Name Type Description
listener (sun: SunState) => void

removeWalkStartListener#

TypeScript#
public removeWalkStartListener(listener: (state: WalkStart) => void): void

Parameters#

Name Type Description
listener (state: WalkStart) => void

render#

TypeScript#
public render(): void

Request the viewer to re-render the content

renderToMeasurementCoordinates#

TypeScript#
public renderToMeasurementCoordinates(point: vec3): vec3

A point in render space (a pick coordinate, the camera eye) in the measurement frame.

see: CoordinateFrame

Parameters#

Name Type Description
point vec3

resetResults#

TypeScript#
public resetResults(): Promise<void>

Takes away what the shown result drew - BVL and query shapes, routes, result overlays, figure layers, BVL annotation layers - and undoes the object states it switched on (the on-top set, pickability). Reset listeners are called: an owner of the shown result (the active check) lets go. Resolves once the states are undone. Persistent overlays, annotations, measurements and section planes stay (docs/ui-api-wp5/README.md §2.1)

resetToDefaultView#

TypeScript#
public resetToDefaultView(): void

Puts the camera back at the default view of the loaded models

resetWireframes#

TypeScript#
public resetWireframes(qids?: Iterable<Qid, any, any> | null): Promise<void>

Restore wireframe visibility and colour defaults for the supplied objects, or all objects when omitted.

Parameters#

Name Type Description
qids Iterable<Qid, any, any> | null

resize#

TypeScript#
public resize(width: number, height: number): void

Resize the viewer. This should only ever be called when autoresizing is off. It is higly recommended to let the Viewer3d manage it's own size based on it's position within the document

Parameters#

Name Type Description
width number The drawing buffer width in pixels
height number The drawing buffer height in pixels

restoreViewState#

TypeScript#
public restoreViewState(snapshot: ViewStateSnapshot, options?: { animate?: boolean; keepCamera?: boolean }): Promise<void>

Brings a captured view back: the object state (@bimworks/viewercommon!ObjectStateManager.restoreObjectState, models loaded since the capture keep their own state), the section planes (SectionPlanes.setState) and the camera (Camera.setViewpoint).

Parameters#

Name Type Description
snapshot ViewStateSnapshot
options { animate?: boolean; keepCamera?: boolean } animate: fly the camera back (500 ms) instead of jumping, false by default; keepCamera: leave the camera where it is, as closing a check does

Returns#

Resolves when the object state is applied (an animation may still run)

saveScreenshot#

TypeScript#
public saveScreenshot(options?: ScreenshotOptions & { save?: (blob: Blob, filename: string) => boolean | void | Promise<boolean | void> }): Promise<boolean>

Save a PNG through Flutter's native save picker or a browser download. Embedded clients may supply their own handler; returning false means cancelled.

Parameters#

Name Type Description
options ScreenshotOptions & { save?: (blob: Blob, filename: string) => boolean | void | Promise<boolean | void> }

scaleView#

TypeScript#
public scaleView(pivot: vec3, factor: number): void

Scales the camera by factor about a point of the measurement frame: the eye and the target about it, and an orthographic view's window too. A model whose alignment is scaled by the same factor about the same point then looks the same (docs/drawing-scale-design.md §8.2); 1 / factor undoes it. Ignored for a factor that is not positive

see: CoordinateFrame

Parameters#

Name Type Description
pivot vec3
factor number

screenshot#

TypeScript#
public screenshot(options?: ScreenshotOptions): Promise<Blob>

Will take a screenshot of the contents of the Viewer3d.

Parameters#

Name Type Description
options ScreenshotOptions Optional options object

Returns#

A Blob

Example#

The returned Blob can for example be downloaded by the user, using the following example

JavaScript#
	import {Utils, EncodingUtils} from "@sascom/commonjs";

	const blob = await viewer3d.screenshot();
	const width = viewer3d.width;
	const height = viewer3d.height;
	const filename = `screencapture-${width}x${height}.png`;

	Utils.downloadBlob(blob, filename);

	OR (to base64)
 
	const base64 = EncodingUtils.base64EncArr(blob);

selectObject#

TypeScript#
public selectObject(callback: (object: { qid: Qid; versionUuid: string | null } | null) => void): object

Pick one object for a tool without changing the viewer's ordinary selection. An empty-space click supplies null; clients may retry or cancel the handle.

Parameters#

Name Type Description
callback (object: { qid: Qid; versionUuid: string | null } | null) => void

Returns#

An opaque handle: it has no members of its own, it only identifies this request to cancelObjectSelection

selectVertex#

TypeScript#
public selectVertex(fn: (vertex: SelectedVertex | null) => void, options?: { snapping?: boolean }): VertexSelector

Waits for one click on a model and calls back with the point clicked, snapped to a nearby vertex or edge. A click on nothing calls back with null and keeps waiting.

Parameters#

Name Type Description
fn (vertex: SelectedVertex | null) => void
options { snapping?: boolean } snapping false: the exact point clicked, and Shift does not turn snapping on (default true)

Returns#

The selector: cancel() stops waiting

set2dMode#

TypeScript#
public set2dMode(enabled: boolean | null, options?: { animate?: boolean; side?: ViewSide }): void

Switches between 3D and 2D. 2D shows the scene straight on from one side, orthographic: a plan from "top" (the default) or "bottom", an elevation from "front", "back", "left" or "right" (ViewSide).

Entering 2D, or another side, the camera turns to look from that side about the point in the middle of the view, at the same scale, unless it looks from there already. A plan keeps the heading of the view (what lay ahead is up), squared to the nearest of the model's or the buildings' axes. Back in 3D (false, or null for a scene with height) the camera turns back to the direction and the perspective of the 3D view it left, about what is then in the middle. To show a whole storey or model, fit afterwards: viewFit, viewFitModels.

In a plan a drag with the main mouse button (one finger) turns it about the vertical axis through the point under the pointer, snapping square, and nothing tilts; a pan moves the scene with the pointer, one to one; the plan labels show from the top (setPlanLabelsEnabled). An elevation stands upright: the main button pans it as well. A flat scene (a PDF or DWG drawing on its own) is in 2D mode by itself, from the top; true puts a 3D model in 2D (a storey plan, an elevation), false keeps a flat scene in 3D, null lets the scene decide again. May be called before initialization: the mode applies when the viewer starts.

Parameters#

Name Type Description
enabled boolean | null
options { animate?: boolean; side?: ViewSide } side: where 2D looks from, default "top"; animate: false jumps instead of turning the camera smoothly

Exceptions#

setAnnotationGroupVisible#

TypeScript#
public setAnnotationGroupVisible(group: string, visible: boolean): void

Shows or hides one annotation group in this viewer; remembered for annotations added to it later

Parameters#

Name Type Description
group string
visible boolean

setAnnotationLimit#

TypeScript#
public setAnnotationLimit(limit: number): void

Show at most this many annotations, those nearest to the camera; 0 (the default) shows them all. Annotations hidden behind other geometry take no place, and hovering an object still shows its annotation. Applies immediately, on top of the limits of annotation groups (Annotation.groupLimit).

Parameters#

Name Type Description
limit number

setAnnotationScaleByDistance#

TypeScript#
public setAnnotationScaleByDistance(enabled: boolean): void

Draw annotations smaller the further they are from the camera (never larger than their normal size), except those whose Annotation.scaleByDistance is set. Applies immediately.

Parameters#

Name Type Description
enabled boolean

setAnnotationsVisible#

TypeScript#
public setAnnotationsVisible(visible: boolean): void

Shows or hides all annotations in this viewer (another viewer on the same ObjectStateManager keeps its own); remembered for annotations added later

Parameters#

Name Type Description
visible boolean

setBackgroundColor#

TypeScript#
public setBackgroundColor(color: Color): void

Change the background color

Parameters#

Name Type Description
color Color

setBackgroundGradientEnabled#

TypeScript#
public setBackgroundGradientEnabled(enabled: boolean): void

Switch between the default vertical stage gradient and the flat colour set with setBackgroundColor. The flat colour is kept while the gradient is on, so a caller can toggle back and forth without having to set it again.

Parameters#

Name Type Description
enabled boolean

setBuildingStoreysVisibleExclusive#

TypeScript#
public setBuildingStoreysVisibleExclusive(buildingStoreyQids: Iterable<Qid>, hideOpenings: boolean): void

Show only the objects of these building storeys, without their openings when hideOpenings

implementationOf: ObjectStateListener.setBuildingStoreysVisibleExclusive

Parameters#

Name Type Description
buildingStoreyQids Iterable<Qid>
hideOpenings boolean

setBuildingStoreyVisibleExclusive#

TypeScript#
public setBuildingStoreyVisibleExclusive(qid: Qid): void

Show only the objects of one building storey (ObjectStateManager.setBuildingStoreyVisibleExclusive with one storey)

implementationOf: ObjectStateListener.setBuildingStoreyVisibleExclusive

Parameters#

Name Type Description
qid Qid

setCapStyles#

TypeScript#
public setCapStyles(qids: Iterable<Qid>, style: CapStyle, embedded?: boolean): void

Sets the section cap style of objects: the pattern of their caps with SectionPlanes.capStyles (docs/section-cap-patterns.md). embedded: they are embedded elements (reinforcement, tendons, cast-in items), whose caps are found apart from those of the solids they lie in. Objects start "generic". Viewer3D draws only its uniform hatch and ignores the styles

Parameters#

Name Type Description
qids Iterable<Qid>
style CapStyle
embedded boolean

setClickHandler#

TypeScript#
public setClickHandler(handler: (click: { qid: Qid | null; shiftKey: boolean }) => void): void

While set, a click in the viewer goes to the handler instead of changing the selection; qid is null for a click on nothing. A tool's one-shot selectObject still takes precedence.

Parameters#

Name Type Description
handler (click: { qid: Qid | null; shiftKey: boolean }) => void

setCullingBudget#

TypeScript#
public setCullingBudget(budget: { automatic?: boolean; triangles?: number }): void

Sets the triangle budget: automatic (measured from the frame rate, the default) or a fixed number of triangles. Only the given properties change

Parameters#

Name Type Description
budget { automatic?: boolean; triangles?: number }

setDeletionPreview#

TypeScript#
public setDeletionPreview(key: string, qids: Iterable<Qid>, options?: { ghost?: boolean }): boolean

Shows a deletion before it is committed, until clearDeletionPreview(key): the objects out of sight whatever the visibility asks (a recorded DELETE OBJECT), or with ghost drawn see-through (one waiting for a decision). clearDeletionPreview gives them back as the visibility has them, or with committed keeps them hidden for the new version to remove. Viewer3D-Next only: false when nothing could be shown, always in Viewer3D

Parameters#

Name Type Description
key string
qids Iterable<Qid>
options { ghost?: boolean }

setGisLayerOpacity#

TypeScript#
public setGisLayerOpacity(id: string, opacity: number): void

Sets a GIS layer's opacity, 0 (invisible) .. 1 (opaque); kept, so a later (re)build of the layer has it. Imagery layers show it

Parameters#

Name Type Description
id string
opacity number

setGridEnabled#

TypeScript#
public setGridEnabled(enabled: boolean): void

Show or hide the infinite reference grid: a horizontal plane of metric grid lines that extends to the horizon, intended as a starting point when modelling from scratch. Line spacing follows the zoom level in decades (0.1 m, 1 m, 10 m, ...). The grid also acts as a surface for the orbit pivot and for double-click-to-fly-to, so orbiting and zooming over empty space behave the same as over a model.

Parameters#

Name Type Description
enabled boolean

setGridOptions#

TypeScript#
public setGridOptions(options: GridOptions): void

Configure the reference grid. Only the given properties are changed, the rest keep their current value. Has no effect on whether the grid is shown, see setGridEnabled.

Parameters#

Name Type Description
options GridOptions

setHoverFaceColor#

TypeScript#
public setHoverFaceColor(color: string): void

Set the face color for hovering. This color is mixed with the current color of the object (either original or overridden by user). Using a transparency component is currently not supported and results in undefined behaviour.

Parameters#

Name Type Description
color string

setHoverWireframeColor#

TypeScript#
public setHoverWireframeColor(color: string): void

Set the wireframe color for hovering. This color is mixed with the default wireframe color. Using a transparency component is currently not supported and results in undefined behaviour.

Parameters#

Name Type Description
color string

setMode#

TypeScript#
public setMode(mode: ViewerMode): boolean

Set the current viewer mode, either LOCAL (Using local coordinates) or GEO (Using geo coordinates)

Parameters#

Name Type Description
mode ViewerMode

Returns#

A boolean indicating whether the mode was changed. Note that you can only switch to GEO mode if all loaded models are georeferenced (getModelsWithoutGeoReference names the others). In GEO mode a DWG shows its model space only. Also note than when nothing was changed as the result of calling this method, it also returns false

setModelAlignment#

TypeScript#
public setModelAlignment(versionUuid: string, alignment: mat4 | null): void

Shows a loaded model with this alignment without storing it (store it with the server's SetAlignment); null puts back the version's stored alignment. The scene bounds follow, and so do the finished measurements taken wholly on the model (Measuring.modelOf), which keep to the same features.

Parameters#

Name Type Description
versionUuid string
alignment mat4 | null

setModelVisible#

TypeScript#
public setModelVisible(versionUuid: string, visible: boolean): void

Shows or hides a whole loaded model without unloading it; the scene bounds and the view fit follow the visible models. A version hidden before it is loaded loads unseen, until it is shown.

Parameters#

Name Type Description
versionUuid string
visible boolean

setMultiSelectMode#

TypeScript#
public setMultiSelectMode(mode: MultiSelectMode): void

Change the way multiselection is done (only applicable when ObjectStateManager's multiSelect is on). The default mode is SHIFT

Parameters#

Name Type Description
mode MultiSelectMode The new multiselection mode; may be set before the viewer is initialized

setNearPlane#

TypeScript#
public setNearPlane(nearPlane: NearPlane): void

Configure the perspective near plane in meters, or set it to "auto" to let the viewer calculate it from the current model and camera state.

Parameters#

Name Type Description
nearPlane NearPlane

setObbVisibleSet#

TypeScript#
public setObbVisibleSet(shown: QidSet, hidden: QidSet, force: boolean, type: string): void | Promise<void>

@bimworks/viewercommon!ObjectStateListener.setObbVisibleSet

implementationOf: ObjectStateListener.setObbVisibleSet

Parameters#

Name Type Description
shown QidSet
hidden QidSet
force boolean
type string

setObjectHoverEnabled#

TypeScript#
public setObjectHoverEnabled(enabled: boolean): void

Whether objects light up (and report hover) under the pointer; default true. A tool that waits for a precise click switches it off, as the measuring tools do by themselves while they are active. Switching it off drops the current hover; may be called before initialization

Parameters#

Name Type Description
enabled boolean

setOfflineMode#

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

Enter or exit offline mode. In offline mode the viewer makes no server calls: only models prepared with Viewer3d.prepareOfflineModels can be loaded, and Viewer3d.addModels rejects with ModelNotAvailableOfflineError for any other model. GEO mode is unavailable while offline.

Note that models prepared for offline use are broken by a server reindex. This is usually fine: a reindex normally accompanies a new BIM.works version — and typically an updated Viewer3d — so re-prepare your offline set after updating.

Parameters#

Name Type Description
enabled boolean true to enter offline mode, false to leave it

Example#

JavaScript#
// While online: prepare the models
await viewer.prepareOfflineModels([versionUuid]);

// Later, possibly without a connection:
await viewer.setOfflineMode(true);
const versions = await viewer.getOfflineVersions([versionUuid]);
await modelManager.addModels(versions);

setPickTarget#

TypeScript#
public setPickTarget(qid: Qid | null): void

Aim at an object without the viewer's pointer: files dragged in from the desktop send the viewer no pointer events, so the caller picks (pick) under the drag and passes the object here. It gets the pick-target highlight a tool that waits for a click gives the hovered object, and isPickTargetActive is true until endPickTarget.

Parameters#

Name Type Description
qid Qid | null The object under the drag, or null over empty space (the aim goes on)

setPlanCut#

TypeScript#
public setPlanCut(z: number | null, options?: { duration?: number }): void

The plan cut: a horizontal cut at height z (mm, render frame: CoordinateFrame) that removes what is above it and closes the cut with end caps, as a floor plan is drawn (usually 1.2 m above a storey's floor). It cuts as a section plane does, but it is none of them: SectionPlanes.getPlanes does not list it, it is not drawn, it has no icon and it leaves the six planes free. null removes it. It cuts in 3D too; a 2D user interface sets it for a plan from the top and removes it when leaving the plan. May be called before initialization.

Annotations: an annotation anchored on an object (or objects) that the cut keeps part of is drawn on the cut, where a plan from the top shows it over its object. That keeps an annotation on top of a window's box, or at the centre of a wall, which both lie above the cut. The cut hides the annotations of objects it cuts away whole, and annotations at a position of their own above it, as a section plane does by default.

Parameters#

Name Type Description
z number | null
options { duration?: number } duration: milliseconds over which Viewer3D-Next sweeps the cut to z from where it is, coming from above the model and going up above it (null), on the curve of @bimworks/viewercommon!ObjectStateManager.transition's default easing; Viewer3D cuts at once. Without it, at once

Exceptions#

  • Error when z is neither a finite number nor null, or duration is not a number of 0 or more

setPlanLabelsEnabled#

TypeScript#
public setPlanLabelsEnabled(enabled: boolean): void

Text labels in plan views (2D mode, see Viewer3dSettings.planLabels): the labels of ObjectStateManager.setLabels and a default label on every space, inside their objects when they fit. On by default

Parameters#

Name Type Description
enabled boolean

setPlanLabelsHeight#

TypeScript#
public setPlanLabelsHeight(height: "top" | "bottom"): void

The plane the plan labels lie in (Viewer3dSettings.planLabels height). "top" (the default): the top of what the section planes keep of each object, so the cut of a storey plan, or a room's ceiling, readable over its walls. "bottom": the object's floor, like text painted on it, which the walls and furniture in front of it cover in a view at an angle. Applies at once

Parameters#

Name Type Description
height "top" | "bottom"

Exceptions#

  • Error when height is not "top" or "bottom"

setProximityFadeConfig#

TypeScript#
public setProximityFadeConfig(config: { fadeFar?: number | "auto"; fadeNear?: number | "auto"; minRampRatio?: number; nearPlaneMargin?: number; smoothingTauMs?: number }): void

Configure the camera-proximity fade that is applied to soft-occluder objects (see ObjectStateManager#setSoftOccluderSet). All distances are in model units (usually mm).

Parameters#

Name Type Description
config { fadeFar?: number | "auto"; fadeNear?: number | "auto"; minRampRatio?: number; nearPlaneMargin?: number; smoothingTauMs?: number } Partial configuration, unknown keys are ignored: fadeNear (fully faded distance, default "auto" = median soft-occluder height), fadeFar (fade start distance, default "auto" = 2.5x fadeNear), minRampRatio (default 2.0), smoothingTauMs (camera damping, default 100), nearPlaneMargin (extra clip-safety margin, default 100)

setScanStationsEnabled#

TypeScript#
public setScanStationsEnabled(enabled: boolean): void

Shows or hides the markers of the scanner stations (getScanStations): the realtime setting pointCloudScanStations. On by default. Viewer3D draws no markers and only keeps the value

Parameters#

Name Type Description
enabled boolean

setSelectionMode#

TypeScript#
public setSelectionMode(mode: SelectionMode): void

Set the selection mode. Currently there are 2 modes, the default mode is SELECTION_DIRECT_PICKING.

Parameters#

Name Type Description
mode SelectionMode The new selection mode

setSelectionVisualization#

TypeScript#
public setSelectionVisualization(visualization: SelectionVisualization): void

Change how selection is visualized throughout this viewer, including already selected and subsequently loaded objects. Requests an immediate redraw. The default is orange wireframe. Choose WireframeSelectionVisualization, FatWireframeSelectionVisualization, FaceAndWireframeSelectionVisualization, XRaySelectionVisualization, or NoneSelectionVisualization for no face/edge highlight. Any style can independently enable extendedObbEnabled and set extendedObbColor.

For opaque face selection, color precedence is selection highlight > user color override > original object color. X-ray selection blends a translucent overlay over the scene, including hidden selected surfaces. Wireframe-only modes leave face colors unchanged. Removing selection (or disabling face highlighting) reveals the latest user color, or the original if the override was reset. Changing user colors while selected does not remove the selection highlight.

Face/edge style and color changes update shared uniforms, independent of the number of selected objects: no per-object color copies, geometry rebuilds, or color-buffer uploads. Selection uses cached selected-object batches for both batched and instanced geometry. Face highlighting adds one triangle pass over those batches; wireframe modes add no face pass. X-ray uses the same batches with blending and no depth testing/writing; dense overlapping selections cost more pixel work. Neither face style needs additional full-screen buffers. Extended OBB instances are built lazily and refreshed when selection, visibility or objects change. Subsequent OBB color and camera changes reuse those buffers. Set a new visualization (or reapply an edited one) to redraw after changing its colors.

Parameters#

Name Type Description
visualization SelectionVisualization Viewer-wide selection style and colors.

Example#

TypeScript#
viewer.setSelectionVisualization(new FaceAndWireframeSelectionVisualization("#ffcc00", "#0044ff"));

setShadows#

TypeScript#
public setShadows(options: ShadowOptions): ShadowState

Shadows. "ground": a soft shadow straight below the models on an invisible ground plane, under any lighting. "sun": the sun's shadows on the models, terrain and imagery, drawn while the sun lights the scene (setSun). The shadow map does not depend on the camera: it is drawn again only when the sun, the visible objects, the section planes or the geometry change. Only the given options change.

Parameters#

Name Type Description
options ShadowOptions

Exceptions#

  • TypeError on an invalid value; the settings are then unchanged

Example#

JavaScript#
viewer.setSun({enabled: true, date: "2027-02-19", time: "15:00"});
viewer.setShadows({mode: "sun"});

setSun#

TypeScript#
public setSun(options: SunOptions): SunState

Light the scene with the sun instead of the headlight, and set where it stands. Only the given options change; the others keep their values. The sun is computed for the reference (first) model's georeference, with true north corrected for the grid convergence of its projected CRS.

Parameters#

Name Type Description
options SunOptions

Returns#

The resulting state, as getSun

Exceptions#

  • TypeError or RangeError on an invalid value; the settings are then unchanged

Example#

JavaScript#
viewer.setSun({enabled: true, date: "2027-02-19", time: "15:00"});

setTextAnnotationMode#

TypeScript#
public setTextAnnotationMode(mode: "label" | "dot"): void

Show text annotations as full labels (default), or dots that expand on dot/object hover. Applies immediately.

Parameters#

Name Type Description
mode "label" | "dot"

setToSelectionSet#

TypeScript#
public setToSelectionSet(qids: Iterable<Qid>, qidsToUnselect: Iterable<Qid>, type: string): Promise<void>

The selection was replaced (also by a click in single-select mode)

implementationOf: ObjectStateListener.setToSelectionSet

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

setTransformPreview#

TypeScript#
public setTransformPreview(key: string, qids: Iterable<Qid>, modelDelta: ArrayLike<number> | mat4, options?: { ghost?: boolean; previous?: boolean; units?: "model" | "mm" }): boolean

Draws objects moved by a rigid change in their model's own frame, until clearTransformPreview(key): mm in the model's coordinates, as BUL TRANSFORM writes it, or with units "model" its own units, as a transaction's transform_spec. ghost: a ghost where they are now (a statement's target). previous: drawn where they are, with a ghost where they were before the change (a committed transaction). Objects another preview moved are taken over with that change applied first, as recorded statements apply in order, and get it back when this one is cleared. Viewer3D-Next only: false when nothing could be shown, always in Viewer3D (supportsLiveTransform)

Parameters#

Name Type Description
key string
qids Iterable<Qid>
modelDelta ArrayLike<number> | mat4
options { ghost?: boolean; previous?: boolean; units?: "model" | "mm" }

setTriangleLineRendering#

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

Draws the edges of every triangle, a diagnostic view

Parameters#

Name Type Description
enabled boolean

setVisibleSet#

TypeScript#
public setVisibleSet(shown: QidSet, hidden: QidSet, force: boolean, type: string, originalQueryList?: (string)[] | null): Promise<void>

The set of visible objects was replaced

implementationOf: ObjectStateListener.setVisibleSet

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

setWireframeColor#

TypeScript#
public setWireframeColor(qids: Iterable<Qid>, color: string | null): Promise<void>

Override per-object wireframe colour with a CSS colour string, or null to restore the fixed default.

Parameters#

Name Type Description
qids Iterable<Qid>
color string | null

setWireframeRendering#

TypeScript#
public setWireframeRendering(wireframeRendering: WireframeRendering): void

Sets when wireframes are drawn: always, only once the camera stands still, or never

Parameters#

Name Type Description
wireframeRendering WireframeRendering

setWireframeVisibility#

TypeScript#
public setWireframeVisibility(qids: Iterable<Qid>, visible: boolean | null): Promise<void>

Override wireframe visibility per object. true shows edges even with hidden faces, false hides edges, null restores following object visibility (the default). The global wireframe rendering mode still applies. Wireframe-only objects are not picked. Overrides survive face visibility changes and streaming; BVL results and resetAll reset them.

Parameters#

Name Type Description
qids Iterable<Qid>
visible boolean | null

setXRayVisualization#

TypeScript#
public setXRayVisualization(visualization: XRayVisualization): void

Change how the ObjectStateManager's x-ray set (addToXRaySet / setXRaySet) is drawn. The x-ray set is independent of selection: its objects are drawn with translucent faces and edges over the scene, without depth testing, so they show through whatever is in front of them. The objects keep their normal appearance underneath and stay pickable as before. Hidden objects are not drawn, and section planes clip the overlay. The x-ray pass runs before the selection pass, so a selected x-rayed object shows its selection on top. Colour changes update shared uniforms only. Set a new visualization (or reapply an edited one) to redraw after changing its fields. The default is blue faces at 15% opacity with pale blue edges.

Parameters#

Name Type Description
visualization XRayVisualization

Example#

TypeScript#
await osm.addToXRaySet("type = IFCCOLUMN");
viewer.setXRayVisualization(new XRayVisualization([1, 0.5, 0, 0.2], "#ffd0a0"));

showDiagnostics#

TypeScript#
public showDiagnostics(): void

Open the inspection panel (also Ctrl+Shift+F12 with the canvas focused).

showDwgLayout#

TypeScript#
public showDwgLayout(versionUuid: string, layoutName: string): boolean

Shows exactly one layout of a DWG model and fits the camera on it from the top

Parameters#

Name Type Description
versionUuid string
layoutName string

Returns#

false when nothing changed: an unknown model, or a sheet of a DWG while the viewer is in GEO mode (a sheet has no place on the earth, only model space is shown there)

showModelCluster#

TypeScript#
public showModelCluster(cluster: ModelCluster): void

Shows only the cluster's models (the other clusters' are hidden), in LOCAL mode, and fits the view to them: what the viewer does with the biggest cluster after loading

Parameters#

Name Type Description
cluster ModelCluster

showQuantityFigure#

TypeScript#
public showQuantityFigure(key: string, figure: QuantityFigure, options?: QuantityFigureOptions): void

Draw a quantity figure - the verification geometry a calculated quantity was measured on, as GET calculated.quantity.<key>.figure returns it (metres, model coordinates) - as a transient overlay in the measurement style, under a key; a figure shown under the same key replaces the previous one. Not a measurement: no id, no handles, nothing in listMeasurements().

Parameters#

Name Type Description
key string Any string, hideQuantityFigure(key) removes the figure again
figure QuantityFigure The figure JSON: {kind, primitives: [{type: "polygon" | "polyline" | "dimension" | "box", ...}]}
options QuantityFigureOptions vid: the model the figure belongs to (its placement is applied), label: the text shown on the figure

showRoute#

TypeScript#
public showRoute(route: WalkableRoute, options?: ShowRouteOptions): PathVisualizationHandle

Draws a walkable route (the polyline produced by the ComputeRoute API task) as a lifted polyline coloured by surface class, door crossings marked. Remove it with the returned object's destroy(), or clearPaths(). The points are taken in the viewer frame: request the route with reference_model set to the vid of the viewer's first model.

Parameters#

Name Type Description
route WalkableRoute
options ShowRouteOptions

showTemporaryObbFor#

TypeScript#
public showTemporaryObbFor(key: string, qids: Iterable<Qid>, type?: string): Promise<void>

Shows the box of the objects until hideTemporaryObb(key) is called with the same key and type

Parameters#

Name Type Description
key string
qids Iterable<Qid>
type string

showTransformGhost#

TypeScript#
public showTransformGhost(key: string, qids: Iterable<Qid>, deltaInverse: mat4): Promise<void>

Parameters#

Name Type Description
key string
qids Iterable<Qid>
deltaInverse mat4

showWalkableSurfaces#

TypeScript#
public showWalkableSurfaces(options?: WalkableSurfacesViewOptions): Promise<WalkableSurfacesViewHandle | null>

Shows what is walkable (docs/walkable-surfaces-visualization-design.md): every walkable surface of the loaded models as a translucent polygon a little above its floor, coloured by how it is walkable, why the rest is not, and what the other loaded models say about it. Built from the walkable-surfaces data walk mode uses, so it follows the models as they are added and removed. One view per viewer: a second call updates it. Viewer3D-Next only: null in Viewer3D.

Parameters#

Name Type Description
options WalkableSurfacesViewOptions

Returns#

The view's handle, or null when no loaded model has walkable surfaces.

sideView#

TypeScript#
public sideView(): void

View the set of loaded models from the side

start#

TypeScript#
public start(): void

Starts the viewer. The viewer will only redraw when needed.

startDefaultNavigation#

TypeScript#
public startDefaultNavigation(settings?: NavigationModeSettings): boolean

Start default navigation mode. This controls mouse and keyboard camera interaction behavior.

Parameters#

Name Type Description
settings NavigationModeSettings

startDroneNavigation#

TypeScript#
public startDroneNavigation(fullscreen?: boolean, settings?: NavigationModeSettings): boolean

Start drone navigation mode. If fullscreen is true, browser fullscreen is requested before navigation starts.

Parameters#

Name Type Description
fullscreen boolean
settings NavigationModeSettings

startExtrusionDrawing#

TypeScript#
public startExtrusionDrawing(options: ExtrusionDrawingOptions): void

Draws a footprint on a face and extrudes it into a solid, or edits an extrusion (options.edit). Enter or a click places it (onCommit), Escape stops (onCancel). The drawn solid stays shown after the commit until result.preview.remove(), so it can stand in for the object until the model has it

Parameters#

Name Type Description
options ExtrusionDrawingOptions

startGameNavigation#

TypeScript#
public startGameNavigation(fullscreen?: boolean, settings?: NavigationModeSettings): boolean

Start game navigation mode. If fullscreen is true, browser fullscreen is requested before navigation starts.

Parameters#

Name Type Description
fullscreen boolean
settings NavigationModeSettings

startMeshPlacement#

TypeScript#
public startMeshPlacement(mesh: PlacementMesh, options?: MeshPlacementOptions): Promise<PlacementTool | null>

Places a mesh that is not in the model yet with the move/rotate tool (docs/placement-controls-design.md §7.4): it follows the cursor onto the face under it until a click puts it down, then moves and turns as objects do (the same snaps, keys and typed values); Enter gives its pose. Esc removes it; after Enter it stays shown until result.preview.remove(). What the placed object becomes is up to the caller. Viewer3D-Next only: null in Viewer3D

Parameters#

Name Type Description
mesh PlacementMesh
options MeshPlacementOptions

startNavigationMode#

TypeScript#
public startNavigationMode(mode: string, settings?: NavigationModeSettings, fullscreen?: boolean): boolean

Start a predefined navigation mode or a custom mode declared in settings.navigationModes.

Parameters#

Name Type Description
mode string
settings NavigationModeSettings
fullscreen boolean

startObjectTransform#

TypeScript#
public startObjectTransform(qids: Iterable<Qid>, options: ObjectTransformOptions): Promise<PlacementTool | null>

Move or rotate objects. In Viewer3D-Next the objects themselves move while a ghost stays where they were: a drag on them moves them along the floor, arrows move along an axis, a ring turns them about the vertical axis through a pivot (stops at 90°), Space turns 90°, and typed values with units ("60cm", "x1m y-20cm", "90°") set exact moves and turns. In Viewer3D a wireframe ghost of the objects' box follows the gesture. Enter reports the accumulated transformation to onCommit, Escape calls onCancel. Applying the result (a model transaction, an alignment) is up to the caller (docs/placement-controls-design.md)

Parameters#

Name Type Description
qids Iterable<Qid> The objects; their bounding box is what the gizmo shows
options ObjectTransformOptions

Returns#

The tool while it runs, null when the objects have no bounds (not loaded)

startWalkNavigation#

TypeScript#
public startWalkNavigation(settings?: NavigationModeSettings): boolean

Start walk navigation mode. This controls mouse and keyboard camera interaction behavior.

Parameters#

Name Type Description
settings NavigationModeSettings

stop#

TypeScript#
public stop(): void

Stops the viewer. When the viewer is stopped, the view is not updated anymore. Any changes to the viewer will be accumulated and become visible as soon as the viewer is started again The main reason for stopping the viewer would be for performance, for example when the viewer is currently hidden

toggleAnimationEnabled#

TypeScript#
public toggleAnimationEnabled(): boolean

Toggles the default animation, which is an animation that continously rotates the building along the Z-Axis; returns whether it now runs

toggleDoorOpeningRendering#

TypeScript#
public toggleDoorOpeningRendering(enabled: boolean): void

Toggle whether (generated) door openings are rendered. This only works for models that have been processed when the repository setting features.generate_door_openings had been enabled. Some models contains door opening direction geometry as IFC lines, in those cases it's best to disabled rendering generated door openings.

Parameters#

Name Type Description
enabled boolean True when enabled

toggleFaceRendering#

TypeScript#
public toggleFaceRendering(enabled: boolean): void

Toggle whether faces are rendered.

Parameters#

Name Type Description
enabled boolean True when enabled

toggleForceTwoSidedRendering#

TypeScript#
public toggleForceTwoSidedRendering(enabled: boolean): void

Toggle whether to force always rendering faces two-sided (e.a. no back face culling). This overrules whatever BIM.works Repository has decided should happen.

Parameters#

Name Type Description
enabled boolean True when enabled

toggleFullScreen#

TypeScript#
public toggleFullScreen(enable?: boolean): boolean

Toggle whether the viewer is in fullscreen mode; the element that goes full screen is the setting browserFullscreenElement, else the container

Parameters#

Name Type Description
enable boolean

Returns#

Whether full screen was asked for (the browser may still refuse it; isFullScreen follows)

toggleGisLayer#

TypeScript#
public toggleGisLayer(id: string, show: boolean): Promise<void>

Toggle a specific GIS Layer on or off; resolves when it has loaded (or is hidden). Throws for an unknown id

Parameters#

Name Type Description
id string
show boolean

toggleIfcLineRendering#

TypeScript#
public toggleIfcLineRendering(enabled: boolean): void

Toggle whether ifc lines are rendered. IFC Lines are all lines that have been defined in the original IFC file, such as Axis and FootPrint representations.

Parameters#

Name Type Description
enabled boolean True when enabled

toggleVertexRendering#

TypeScript#
public toggleVertexRendering(enabled: boolean): void

Toggle whether vertices are rendered. Currently this does not have much use, in the future it will be used for snapping.

Parameters#

Name Type Description
enabled boolean True when enabled

toggleWireframeRendering#

TypeScript#
public toggleWireframeRendering(enabled: boolean): void

Toggle whether wireframes are rendered. Wireframes are usually drawn to emphesize the edges and generally make the model look better

Parameters#

Name Type Description
enabled boolean True when enabled

topView#

TypeScript#
public topView(): void

View the set of loaded models from the top

unloaded#

TypeScript#
public unloaded(qids: QidSet): void

Objects were unloaded with their model: forget them

implementationOf: ObjectStateListener.unloaded

Parameters#

Name Type Description
qids QidSet

updateModel#

TypeScript#
public updateModel(vid: string): Promise<void>

Update the internal information for the given Version. If the given Version is not loaded currently, it is silently ignored. Call it after changing the georeference or the stored alignment (SetAlignment) of a loaded model; a preview from setModelAlignment stays in effect. Measurements taken wholly on the model follow a changed alignment, as with setModelAlignment.

Parameters#

Name Type Description
vid string The Vid of the model that you want to update.

usesPointerLock#

TypeScript#
public usesPointerLock(): boolean

Returns#

Whether the navigation mode looks around with the captured mouse (game, drone, or a custom mode with pointerLock). A right- or middle-click in the view leaves such a mode for the default one, as Escape does

viewFit#

TypeScript#
public viewFit(qids: Iterable<Qid>, options?: ViewFitOptions): Promise<void>

Fit the given objects into view (ObjectStateManager.viewFit)

implementationOf: ObjectStateListener.viewFit

Parameters#

Name Type Description
qids Iterable<Qid> The objects to fit
options ViewFitOptions How to fit, as the caller gave them

viewFitMeasurement#

TypeScript#
public viewFitMeasurement(measurement: Measurement, options?: { animate?: boolean; minHalfMm?: number }): boolean

Fit the camera to a finished measurement (the "Zoom to" action of the measurement list). The box around the measurement's points is padded to at least minHalfMm in every direction so a small measurement stays readable

Parameters#

Name Type Description
measurement Measurement
options { animate?: boolean; minHalfMm?: number }

Returns#

false when the measurement has no points to fit yet

viewFitModels#

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

Fit the given models into view (ObjectStateManager.viewFitModels)

implementationOf: ObjectStateListener.viewFitModels

Parameters#

Name Type Description
versionUuids Iterable<string> The models to fit
options ViewFitOptions How to fit, as the caller gave them

viewFitQuantityFigure#

TypeScript#
public viewFitQuantityFigure(figure: QuantityFigure, options?: QuantityFigureOptions): void

Fit the camera to a quantity figure, animated

Parameters#

Name Type Description
figure QuantityFigure
options QuantityFigureOptions

walkPhysicsAvailable#

TypeScript#
public walkPhysicsAvailable(): Promise<boolean>

Returns#

Whether walk physics (collision, gravity, storey keys) can run for the loaded models: the server-generated walkable-surfaces artifact exists and could be loaded. Loads the artifact on first call.

zoom#

TypeScript#
public zoom(value: number): void

Zooms the camera towards (negative value) or away from (positive) the scene at the canvas centre, animated. In perspective the eye moves |value| mm along the view ray; an orthographic camera scales its view window instead. zoomSteps zooms as the mouse wheel does

Parameters#

Name Type Description
value number

zoomSteps#

TypeScript#
public zoomSteps(steps: number, canvasPosition?: [number, number]): Promise<void>

Zooms as steps mouse-wheel notches do (positive towards the scene; one notch covers half the remaining distance), towards canvasPosition (CSS pixels) or the canvas centre, animated like the wheel

Parameters#

Name Type Description
steps number
canvasPosition [number, number]