Create a new Viewer3d.
The ObjectStateManager manages all object related state such as visibility, color and selection
OptionalloadProgressHandler: LoadProgressHandlerAn object that get's specific methods called when there is progress to be reported
Optionalsettings: Viewer3dSettingsOptional settings
ReadonlybimReadonlyclientReadonlycontainerReadonlymodelReadonlyobjectReadonlysettingsGet a reference to the Measuring component which can be used for measurements related actions
This method will get called when objects have been added to the selection.
Iterable<@bimworks/jssdk!Qid> that provides the @bimworks/jssdk!Qids of the objects added to the selection set.
Objects were added to the set of visible objects
An Iterable
This method can return a Promise, if it does, subsequent listeners will only be notified after the returned Promise has resolved
Register a listener to be called whenever a point is selected in MeasurementType "POINT"
Called when the color of the given objects has been reset
The Qids of the objects for which the color has been reset
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.
Disable any active sectionplanes
Focus the viewer
View the set of loaded models from the front
The current Camera
The Canvas element used for rendering 3D content
Get the height of the viewer in pixels
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.
An AxisAlignedBoundingBox3D object
The current viewer mode, either LOCAL (Using local coordinates) or GEO (Using geo coordinates)
Get a reference to the SectionPlanes component which can be used for creating/modifying/removing section planes and boxes
The current selection mode
Get the width of the viewer in pixels
Called then the given object is not being hovered on anymore
The Qid of the object that is not being hovered over anymore
Called then the given object is being hovered on
The Qid of the object being hovered over
The Qid of the previous objects that was being hovered over
The screenspace location of the hover event. 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
Initializes the Viewer3d, it is important to wait for this async method to finish before calling any other methods on the viewer
Whether rendering of generated door opening directions is currently enabled
Whether face rendering is currently enabled
Whether forced two-sided rendering is currently enabled
Whether IFC line rendering is currently enabled
Whether vertex rendering is currently enabled
Whether wireframe rendering is currently enabled
The primary selection has changed
The Qid of the newly selected primary object or null if primary selection was unselected
Objects have been removed from the selection set
The Qids of the objects that have been removed from the selection set
Objects were removed from the set of visible objects
An Iterable
This method can return a Promise, if it does, subsequent listeners will only be notified after the returned Promise has resolved
Request the viewer to re-render the content
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
Will take a screenshot of the contents of the Viewer3d.
Optionaloptions: ScreenshotOptionsOptional options object
A Blob
The returned Blob can for example be downloaded by the user, using the following example
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);
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.
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.
Set the current viewer mode, either LOCAL (Using local coordinates) or GEO (Using geo coordinates)
A boolean indicating whether the mode was changed. Note that you can only switch to GEO mode if all loaded models are georeferenced. Also note than when nothing was changed as the result of calling this method, it also returns false
Change the way multiselection is done (only applicable when ObjectStateManager's multiSelect is on). The default mode is SHIFT
The new multiselection mode
Set the selection mode. Currently there are 2 modes, the default mode is SELECTION_DIRECT_PICKING.
The new selection mode
Change how the selection state is visualized
The type of visualization to use for selection, currently this can be either WireframeSelectionVisualization or NoneSelectionVisualization
This method will get called when the set of selected objects has been
Iterable<@bimworks/jssdk!Qid> that provides the @bimworks/jssdk!Qids of the objects added to the selection set.
Unused
The set of visible objects has been replaced to the given set
This method can return a Promise, if it does, subsequent listeners will only be notified after the returned Promise has resolved
View the set of loaded models from the side
Starts the viewer. The viewer will only redraw when needed.
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
Toggles the default animation, which is an animation that continously rotates the building along the Z-Axis
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.
True when enabled
Toggle whether faces are rendered.
True when enabled
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.
True when enabled
Toggle whether the viewer is in fullscreen mode
Optionalenable: booleanToggle a specific GIS Layer on or off
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.
True when enabled
Toggle whether vertices are rendered. Currently this does not have much use, in the future it will be used for snapping.
True when enabled
Toggle whether wireframes are rendered. Wireframes are usually drawn to emphesize the edges and generally make the model look better
True when enabled
View the set of loaded models from the top
Update the internal information for the given Version. If the given Version is not loaded currently, it is silently ignored. This method can be useful to call after updating the geo reference of a loaded model.
The Vid of the model that you want to update.
Fit the given object into view.
The Qids of the objects to fit
Optionaloptions: ViewFitOptionsTo provide a buffer around the objects. A percentage, where 0 means no buffer and 100 means only buffer
Fit the given models into view.
The models to fit
Optionaloptions: ViewFitOptionsTo provide a buffer around the objects. A percentage, where 0 means no buffer and 100 means only buffer
A 3D BIM viewer based on WebGL2. Minimal example:
Example