Create a new Viewer2d
The ObjectStateManager manages all object related state such as visibility, color and selection
Optionalsettings: Viewer2dSettingsOptional settings, will use default settings when not provided
ReadonlycanvasThe canvas the 2D viewer draws on (inside container)
ReadonlycontainerReadonlymodelReadonlyobjectObjects were added to the selection
The objects added
A camera pose position (mm, frame of the 3D viewer) in 2D world coordinates; z is passed through
The pose (eye, pivot, target) of a camera has been updated (ObjectStateManager.setCameraPose)
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
The new camera pose, in the 3D viewer's render frame
The colour of the given objects has been reset to their own
The objects whose colour was reset
Destroys the viewer and any (heavy) resources associated with it. As long as there is a reference to the Viewer2d instance it won't be completely destroyed.
The storey the plan shows: the current one while visible, else the first visible storey with a level; null for none. minZ is the storey's lowest point in model mm
Get access to the Control object for programmatic viewer manipulation
The size of the text labels in pixels (15 by default)
Get the height of the viewer in pixels
The ModelManager connected to this viewer
Get the width of the viewer in pixels
Whether any model is loaded in the plan
Called when the given object is not being hovered on anymore
The Qid of the object that is not being hovered over anymore
Called when the given object is being hovered on
The Qid of the object being hovered over
The object hovered before, null or undefined for none
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
This method must be called before loading any of the models. Keep in mind that this method is async, and models can only be loaded after the returned Promise has resolved.
Whether rendering of generated door opening directions is currently enabled
Whether face rendering is currently enabled
Whether IFC line rendering is currently enabled
Whether the text labels are shown (toggleShowText); false before init
Whether wireframe rendering is currently enabled
The primary selection has changed (only with settings.managePrimarySelection)
The newly selected primary object, null or undefined when the primary selection was cleared
Objects were removed from the selection
The objects that are no longer selected
Objects were hidden. Any of them that were selected have been deselected first
Models were unloaded
The versions that were removed
Will take a screenshot of the contents of the Viewer2d.
Optionaloptions: ScreenshotOptionsOptional options object
A Blob
Show only the objects of these building storeys, without their openings when hideOpenings
Show only the objects of one building storey (ObjectStateManager.setBuildingStoreyVisibleExclusive with one storey)
Set the depth of the camera cone, default is 250px
The depth in pixels
Toggle whether the cone indicating where the 3D camera is (in a Viewer3d) should be visible, default is visible
Whether it should be visible
The viewer whose camera poses this viewer shows as the camera cone. Only needed when that viewer is not registered on this viewer's ObjectStateManager; the 2D viewer uses its global base translation to bring poses into its own world frame
Switch how the synced 3D camera indicator behaves inside the 2D viewer. "MAP" keeps the map fixed and lets the cone move through it. "FOLLOW" keeps the cone centered while moving the map, clamping manual interaction so the cone stays inside the viewport.
The camera tracking mode
To be called whenever the rendering state has changed and updates need to become visible
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
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
Toggles full screen (the container fills the window); returns whether it is now full screen
Optionalenable: booleanToggle 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
Toggles whether the text labels are shown
Toggle whether user panning (by mouse or touch device) is enabled or disabled. It is enabled by default
Whether it should be enabled
Toggle whether user rotate (by mouse or touch device) is enabled or disabled. It is enabled by default
Whether it should be enabled
Toggle whether user selection (by mouse or touch device) is enabled or disabled. It is enabled by default
Whether it should be enabled
Toggle whether user zooming (by mouse wheel or touch device) is enabled or disabled. It is enabled by default. Changing this settings also enabled/disabled zoom on double-click
Whether it should be enabled
Toggle whether wireframes are rendered. Wireframes are usually drawn to emphesize the edges and generally make the model look better
True when enabled
Fits the given objects into view: the viewport is updated so that it shows the bounding box of all of them, and the building
storey most of them are on is made visible. The plan's rotation is set by options.rotation (ViewFitRotation, default
"KEEP"); with "OBJECT_AXIS" the object of options.rotationObject (or the one fitted object) orients the plan.
The Qids of the objects to fit
Optionaloptions: ViewFitOptionsMargin, animation and rotation, see ViewFitOptions
Resolves once the fit has been applied; the "OBJECT_AXIS" rotation first queries the object's oriented bounding box
Fits the given models into view as a whole, using the bounds of each model as loaded. Models not loaded in this viewer are skipped. Rotation as for viewFit; "MODEL_AXIS" uses the oriented bounding boxes of exactly these models.
The models to fit
Optionaloptions: ViewFitOptionsMargin, animation and rotation, see ViewFitOptions
The inverse of cameraPoseToWorld for a 2D world position: [x, y] in mm in the frame of the 3D viewer
2D viewer based on WebGL.