3D viewer settings

Every setting the Viewer3d constructor accepts, with its type and default, and a map of the viewer's methods by task.

new Viewer3d(objectStateManager, loadProgressHandler?, settings?) takes the settings below as its third argument. Types and descriptions are those of viewer3d.d.ts; defaults are what the implementation uses when a setting is absent. The generated API documentation with every method signature is the reference of Viewer3d and Viewer3dSettings; this page is the overview.

Settings#

tileSets#

{[id: string]: GisLayer | "separator"}. GIS layers registered when the viewer is created, keyed by id, with "separator" entries for the menu of an application that lists them. The same layers can be added later with addGisLayer(id, layer) (Geo mode). Default: none.

rightMouseClick#

(event: MouseEvent, qid, pick) => void. Called on the contextmenu event with the Qid of the object under the pointer, or null over empty space, and a PickResult pick with that qid, the coordinate hit and the face normal (both null when no surface was hit; pick is null when the viewer could not pick). viewer.pick(x, y) returns the same for any canvas position. The browser's own menu is suppressed. When the button is bound to a viewer action in the active navigation mode, the callback is not called. A Section plane entry on the clicked face is getSectionPlanes().startPlaneAt(pick.coordinate, pick.normal) (how-to/viewer3d/section-planes#context-menu). Default: none, the browser's context menu appears.

showLoader#

boolean. Show the "Loading…" element while a model loads; style it with the .viewer3d .loader selector. Default false.

cacheGeometry#

boolean. Read geometry from the browser's IndexedDB cache when it is there. Default false.

preLoadTriangles#

boolean. Load the triangle data with the model, so the first laser measurement is immediate. Default false.

proximityFade#

{enabled?: boolean, fadeNear?, fadeFar?, minRampRatio?, smoothingTauMs?}. The proximity fade of the soft-occluder set (Fade walls near the camera); enabled: false disables the feature entirely, the other keys are the starting values of setProximityFadeConfig(), distances in model units. Default: enabled, fadeNear and fadeFar "auto" (derived from the median height of the occluders), minRampRatio 2, smoothingTauMs 100.

planLabels#

{enabled?: boolean, spaces?: boolean, fontSize?: number, dropLines?: boolean, maxTilt?: number, occlusion?: boolean, height?: "top" | "bottom", orientation?: "HORIZONTAL" | "AUTO"}. Text in plan views: the labels of the ObjectStateManager's setLabels and, with spaces, the number, name and floor area of every space, drawn inside the object in 2D mode when the text fits, horizontal on screen however the plan is turned (how-to/viewer3d/show-a-floor-plan#room-labels). fontSize in pixels; dropLines leaves out the last lines of a label that does not fit until it does; maxTilt (degrees) also shows them in 3D mode when the view looks down within that angle of the vertical, lying in the object's plane; occlusion hides a label where something is drawn above it, as annotations hide; height lays it at the top of what the section planes keep of its object ("top") or on its floor ("bottom"); orientation: "AUTO" lays a label that does not fit horizontally along its object's long axis instead (corridors), turned so it never reads upside down, in views within 30° of a plan. Default: enabled, spaces true, fontSize 15, dropLines false, maxTilt 70, occlusion true, height "top", orientation "HORIZONTAL".

"default" | "walk" | "game" | "drone" | string. The mode the viewer starts in, a preset or the name of a custom mode from navigationModes (Navigation modes). Default "default".

Record<string, NavigationModeSettings>. Custom modes, each extending a preset and overriding pointer lock, keyboard movement, forwardMode, speed and keyBindings. Declaring default here changes the built-in mode. Default: none.

nearPlane#

number | "auto". The perspective near plane in metres, or "auto" to derive it from the model and the camera. Also setNearPlane() / getNearPlane() at runtime. Default "auto".

rendering.antialias#

boolean. Declared in the type definitions, but nothing reads it: the WebGL context is always created without anti-aliasing. The viewer anti-aliases on its own instead, drawing the scene into a framebuffer with 4× multisampling (MSAA) and copying the result to the canvas; no setting changes the sample count.

fatWireframes#

{enabled?: boolean, pregenerate?: boolean, cache?: boolean}. Thick wireframes, the outline FatWireframeSelectionVisualization draws (Select and colour objects); the default selection outline is the thin wireframe and does not need them. pregenerate builds them while loading (slower load, instant first selection); cache keeps them in the browser cache. Default when the object is absent: all three false. The type definitions say enabled and cache default to true; the implementation does not.

technologyAllowed#

{webGl2?, webGpu?, webWorker?, sharedArrayBuffer?, transferable?: boolean}. Which technologies the viewer may use; each is also checked for availability at runtime. webGl2 is required. webWorker moves loading and culling off the main thread; sharedArrayBuffer shares memory between the threads and needs a cross-origin-isolated page; transferable moves buffers between threads instead of copying when shared memory is not available. Default {webGl2: true} and everything else false, so web workers are off unless you enable them (how-to/viewer3d/embed-the-viewer#same-origin-module-urls-and-workers).

spatialQuerying.implementationPreferences#

Array<{type: "WEBGPU" | "WEBGL" | "CPU"}>. Where spatial queries (picking, culling, rectangle selection) run, first preference first; the viewer takes the first one the browser supports. Default [{type: "CPU"}].

realtimeSettings.culling#

boolean. Skip objects that cannot be seen instead of sending them to the GPU; a large gain on big models. Runs on the CPU, WebGL or WebGPU depending on technologyAllowed. Default false.

hideObjectOnMiddleClick#

boolean. A middle click on an object hides it. Applied by the viewer only, without going through the ObjectStateManager (how-to/viewer3d/hide-and-isolate#the-interactive-shortcuts). Default true.

Read by the implementation, not declared#

The viewer reads more keys than the type definitions declare. They are not part of the supported API and can change without notice: webGlDebugging, webGlDebuggingStat, shaderPrecisionDebug, viewerStats, downloadBvh, geometryTransport ("auto", "fetch" or "ws"), sharedGeometryBuffers, webWorkerPath, and under realtimeSettings: orderIndependentTransparency, drawWireframes ("ALWAYS", "AUTO", "AT_REST", "NEVER"; also toggleWireframeRendering() at runtime), useVertexColorsForLines, forceTwoSidedRendering and sectionCulling.

Methods by task#

Task Methods
Lifecycle initializeViewer() (await before anything else), start(), stop(), destroy(), render(), resize(w, h) (only with auto-resizing off), toggleFullScreen(), focus(), getWidth(), getHeight(), getCanvas(), container
Models addModels(versions) and removeModels(versions) — prefer the ModelManager's methods; updateModel(vid) after a geo-reference change; getMainBounds()
DWG drawings addDwgSemanticsListener(listener) (the layouts and layers of a loaded drawing), showDwgLayout(versionUuid, name), hideDwgSheets(versionUuid) (Show DWG drawings)
Placement setMode("LOCAL" | "GEO"), getMode(), addModeChangeListener(), removeModeChangeListener(), addGisLayer(id, layer), toggleGisLayer(id, show)
Camera getCamera() (getViewpoint(), setViewpoint(viewpoint, ms), fov, nearPlane), frontView(), sideView(), topView(), set2dMode(enabled, {side, animate}), is2dMode(), get2dSide(), add2dModeListener(listener), viewFit(qids, options), viewFitModels(vids, options), zoom(value), toggleAnimationEnabled(), cameraPoseUpdated()
Navigation startDefaultNavigation(), startWalkNavigation(), startGameNavigation(fullscreen), startDroneNavigation(fullscreen), startNavigationMode(mode, settings, fullscreen), getNavigationMode(), walkPhysicsAvailable(), showRoute(), followRoute(), clearPaths(), ensureCurrentSpaceTracker() (the room the camera is in, Walk through a building)
Grid setGridEnabled(), isGridEnabled(), setGridOptions(), getGridOptions(), getGridSnapSpacing() (Show the reference grid)
Selection setMultiSelectMode("SHIFT" | "AUTO"), setSelectionMode(mode), getSelectionMode(), setSelectionVisualization(), setHoverFaceColor(), setHoverWireframeColor() (Select and colour objects)
X-ray and fade setXRayVisualization(), getXRayVisualization() — the style of the ObjectStateManager's x-ray set (X-ray a set of objects); setProximityFadeConfig() — the ramp of its soft-occluder set (Fade walls near the camera)
Rendering toggleWireframeRendering(), toggleFaceRendering(), toggleVertexRendering(), toggleIfcLineRendering(), toggleDoorOpeningRendering(), toggleForceTwoSidedRendering() and their get/is counterparts, setBackgroundColor(), setBackgroundGradientEnabled(), isBackgroundGradientEnabled()
Sections and measuring getSectionPlanes() (startStandardPlane(side) and startTopPlane() with the other sides, startPlaneAt(coordinate, normal), startSectionBox(), getPlanes(), onPlanesChange(fn), disableAll()), disableSectionPlanes() (Section planes), setPlanCut(z) and getPlanCut() (a floor plan's cut, none of the six planes: how-to/viewer3d/show-a-floor-plan#cut), getMovablePlanes() (addTopPlane(), addAxisPlane(axis), addPlane(coordinate, normal), how-to/viewer3d/section-planes#movable-planes), measuring (startAreaMeasurement(), startAngleMeasurement(), startLaserMeasurement(), startVerticalLaserMeasurement(), startObjectDistanceMeasurement(), measureObjectDistance(qidA, qidB) and the others, Measure areas, angles and with the laser, Measure the distance between two objects), viewFitMeasurement(measurement)
Picking pick(canvasX, canvasY) returns the object, point and face normal under a canvas position without selecting; selectObject(callback)
Offline prepareOfflineModels(), removeOfflineModels(), getOfflineModels(), getOfflineVersions(), setOfflineMode(), isOfflineMode()
Plan labels setPlanLabelsEnabled(enabled), isPlanLabelsEnabled(), fontScaling (pixels), setPlanLabelsHeight("top" | "bottom") and getPlanLabelsHeight() (on the top of the objects or on their bottom, at once) — the text the planLabels setting describes; the labels themselves come from the ObjectStateManager's setLabels and resetLabels
Output screenshot(options) returns a Blob (includeText: true with the plan labels, annotations: true with the template annotations)

Selection, visibility and colour of objects are not viewer methods; they belong to the ObjectStateManager, which the viewer implements as a listener. Several of those changes animated in one call are objectStateManager.transition(steps, options) and stopTransitions(how) (Animate state changes); this viewer animates them on WebGPU and applies each step at once on WebGL.

Pages#

  • Default key bindingsEvery action the 3D viewer binds by default, with its mouse and keyboard combinations, the modes it applies in and the rules that resolve a key.