BIM.works SDKs - v3.0.0-b.115
    Preparing search index...

    2D viewer based on WebGL.

    Implements

    Index

    Constructors

    Properties

    canvas: HTMLCanvasElement

    The canvas the 2D viewer draws on (inside container)

    container: HTMLElement
    modelManager: ModelManager
    objectStateManager: ObjectStateManager

    Methods

    • Objects were added to the selection

      Parameters

      • qids: Iterable<Qid>

        The objects added

      Returns void | Promise<void>

    • Objects were made visible

      Parameters

      • qids: Iterable<Qid>

      Returns Promise<void>

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

      Parameters

      • newVersions: Iterable<Version>

        The versions that were added

      • allVersions: Iterable<Version>

        Every loaded version, the new ones included

      Returns Promise<void>

    • A camera pose position (mm, frame of the 3D viewer) in 2D world coordinates; z is passed through

      Parameters

      • position: ArrayLike<number>

      Returns Float32Array

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

      Parameters

      • 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

      Returns void

    • Parameters

      Returns void | Promise<void>

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

      Parameters

      • qids: Iterable<Qid>

        The objects whose colour was reset

      Returns void | Promise<void>

    • 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.

      Returns void

    • 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

      Returns { minZ: number; qid: string } | null

    • Get access to the Control object for programmatic viewer manipulation

      Returns Control

    • The size of the text labels in pixels (15 by default)

      Returns number

    • Get the height of the viewer in pixels

      Returns number

    • Returns ModelManager

      The ModelManager connected to this viewer

    • Get the width of the viewer in pixels

      Returns number

    • Whether any model is loaded in the plan

      Returns boolean

    • Called when the given object is not being hovered on anymore

      Parameters

      • qid: Qid

        The Qid of the object that is not being hovered over anymore

      Returns void

    • Called when the given object is being hovered on

      Parameters

      • qid: Qid

        The Qid of the object being hovered over

      • previousQid: Qid

        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

      Returns void

    • 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.

      Returns Promise<void>

    • Returns boolean

      Whether rendering of generated door opening directions is currently enabled

    • Returns boolean

      Whether face rendering is currently enabled

    • Returns boolean

    • Returns boolean

      Whether IFC line rendering is currently enabled

    • Whether the text labels are shown (toggleShowText); false before init

      Returns boolean

    • Returns boolean

      Whether wireframe rendering is currently enabled

    • The primary selection has changed (only with settings.managePrimarySelection)

      Parameters

      • qid: Qid

        The newly selected primary object, null or undefined when the primary selection was cleared

      Returns void | Promise<unknown>

    • Objects were removed from the selection

      Parameters

      • qids: Iterable<Qid>

        The objects that are no longer selected

      Returns void | Promise<void>

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

      Parameters

      • qids: Iterable<Qid>

      Returns Promise<void>

    • Models were unloaded

      Parameters

      • versions: Iterable<Version>

        The versions that were removed

      Returns Promise<void>

    • Parameters

      • width: number
      • height: number

      Returns void

    • Will take a screenshot of the contents of the Viewer2d.

      Parameters

      Returns Promise<Blob>

      A Blob

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

      	const width = viewer2d.width;
      const height = viewer2d.height;
      const filename = `screencapture-${width}x${height}.png`;
      Utils.downloadBlob(blob, filename);
    • Show only the objects of these building storeys, without their openings when hideOpenings

      Parameters

      • buildingStoreyQids: Iterable<Qid>

      Returns void

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

      Parameters

      • buildingStoreyQid: unknown

      Returns void

    • Set the depth of the camera cone, default is 250px

      Parameters

      • depth: number

        The depth in pixels

      Returns void

    • Toggle whether the cone indicating where the 3D camera is (in a Viewer3d) should be visible, default is visible

      Parameters

      • visible: boolean

        Whether it should be visible

      Returns void

    • 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

      Parameters

      • viewer: any

      Returns void

    • 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.

      Parameters

      Returns void

    • To be called whenever the rendering state has changed and updates need to become visible

      Returns void

    • Parameters

      • scale: number

      Returns void

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

      Parameters

      • qids: Iterable<Qid>

        The objects selected now

      • qidsToUnselect: Iterable<Qid>

        The objects no longer selected

      Returns void | Promise<void>

    • The set of visible objects was replaced

      Parameters

      • qids: Iterable<Qid>

        The objects that have been made visible

      • qidsToHide: Iterable<Qid>

        The objects that have been made invisible

      Returns void | Promise<unknown>

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

      Returns 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

      Returns 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

      • enabled: boolean

        True when enabled

      Returns void

    • Toggle whether faces are rendered.

      Parameters

      • enabled: boolean

        True when enabled

      Returns void

    • Toggles full screen (the container fills the window); returns whether it is now full screen

      Parameters

      • Optionalenable: boolean

      Returns boolean

    • 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

      • enabled: boolean

        True when enabled

      Returns void

    • Toggles whether the text labels are shown

      Returns void

    • Toggle whether user panning (by mouse or touch device) is enabled or disabled. It is enabled by default

      Parameters

      • enabled: boolean

        Whether it should be enabled

      Returns void

    • Toggle whether user rotate (by mouse or touch device) is enabled or disabled. It is enabled by default

      Parameters

      • enabled: boolean

        Whether it should be enabled

      Returns void

    • Toggle whether user selection (by mouse or touch device) is enabled or disabled. It is enabled by default

      Parameters

      • enabled: boolean

        Whether it should be enabled

      Returns void

    • 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

      Parameters

      • enabled: boolean

        Whether it should be enabled

      Returns void

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

      Parameters

      • enabled: boolean

        True when enabled

      Returns void

    • 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.

      Parameters

      Returns void | Promise<void>

      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.

      Parameters

      Returns void | Promise<void>

    • The inverse of cameraPoseToWorld for a 2D world position: [x, y] in mm in the frame of the 3D viewer

      Parameters

      • worldCoordinates: ArrayLike<number>

      Returns number[]