Skip to content

API Reference

Classes

ViewerTHREE.EventDispatcher

Typedefs

ViewerConfiguration : Object

Configuation object used to initialise bimU.io Viewer.

Viewpoint : Object

BCF-compatible camera viewpoint.

onProgressCallback : function

This callback reports model loading progress.

Viewer ⇐ THREE.EventDispatcher

Kind: global class
Extends: THREE.EventDispatcher

new Viewer(configs)

bimU.io Viewer main application. You should always create an instance of Viewer by passing the ViewerConfiguration object into the constructor.

Param Type Description
configs ViewerConfiguration Viewer configuation object. See ViewerConfiguration.

Example

let viewerConfigs = {
    domElementId: "viewer",
    accessToken: null,
    baseUrl: "https://viewer.bimu.io/rest/api/v1",
    THREE: null,
    showFPS: true,
    showUI: false
};
let viewer = new bimU.Viewer(viewerConfigs);

viewer.initialize()

You must call this method before using any other methods of Viewer.

Kind: instance method of Viewer

viewer.setViewpoint(viewpointObject)

Set camera viewpoint and clipping planes.

Kind: instance method of Viewer
See: BCF Documentation

Param Type Description
viewpointObject Viewpoint The BCF compatible viewpoint definition. See Viewpoint.

viewer.getViewpoint() ⇒ Viewpoint

Get camera viewpoint and clipping planes.

Kind: instance method of Viewer
Returns: Viewpoint - The BCF compatible viewpoint definition. See Viewpoint.
See: BCF Documentation

viewer.setProjectionMode(mode, value)

This method changes camera parameters directly.

Kind: instance method of Viewer

Param Type Description
mode CameraTypesEnum Perspective camera or orthographic camera.
value number Field of View or View to World Scale.

viewer.isPerspectiveMode() ⇒ boolean

This is a helper method for checking camera type.

Kind: instance method of Viewer
Returns: boolean - Whether current camera is a perspective one.

viewer.switchSectionbox()

This method toggles section box visibility.

Kind: instance method of Viewer

viewer.sectionAroundSelection()

This method creates a section box around current selection.

Kind: instance method of Viewer

viewer.anyElementSelected(showWarning) ⇒ boolean

This is a helper method for checking if there's any element selected.

Kind: instance method of Viewer
Returns: boolean - Whether at least one element selected.

Param Type Description
showWarning boolean Whether an event should be dispathed if there's no element selected.

viewer.orientToView(viewe)

This method aligns current camera to an orthogonal view.

Kind: instance method of Viewer

Param Type Description
viewe ViewOrientation Top, Bottom, Front, Back, Left, Right.

viewer.zoomToFit()

This method zooms model extent to fit current viewport.

Kind: instance method of Viewer

viewer.zoomToSelection()

This method moves camera to focus on current selection.

Kind: instance method of Viewer

viewer.getBoundingBoxBySelectedElements() ⇒ THREE.Box3

This method returns a bounding box of selected elements.

Kind: instance method of Viewer
Returns: THREE.Box3 - Represents an axis-aligned bounding box (AABB) in 3D space.

viewer.zoomToObject(object3D)

This method moves camera to focus on a particular 3D object.

Kind: instance method of Viewer

Param Type Description
object3D THREE.Object3D The base class for most objects in Three.js.

viewer.loadModel(modelConfigs, onProgress, onLoaded, onError)

Load model from bimU.io

Kind: instance method of Viewer

Param Type Description
modelConfigs object Model configuration object.
onProgress onProgressCallback Callback when model is being downloaded.
onLoaded onLoadedCallback Callback when model is fully loaded.
onError onErrorCallback Callback when an error occurs.

viewer.unselectAllElements()

This method unselects all selected elements.

Kind: instance method of Viewer

viewer.unhideAllElements()

This method make all hidden elements visible.

Kind: instance method of Viewer

viewer.resetVisibility()

This method unhide all elements and clear all section planes.

Kind: instance method of Viewer

viewer.setVisibility(elementIndices, isVisible)

This method makes elements hidden or visible.

Kind: instance method of Viewer

Param Type Description
elementIndices Array.<number> An array of element indices.
isVisible boolean True is visible. False is hidden.

viewer.hideSelectedElements()

This method make all selected elements invisible.

Kind: instance method of Viewer

viewer.isPointInSectionBox(point)

This method checks whether a 3D point is within the current section box.

Kind: instance method of Viewer

Param Type Description
point THREE.Vector3 A 3D point.

viewer.getFileProperties(onSuccess, onError) ⇒ Object

This method retrieves file properties from bimU.io server.

Kind: instance method of Viewer
Returns: Object - File property object.

Param Type Description
onSuccess onSuccessCallback Callback when data is received.
onError onErrorCallback Callback when an error occurs.

viewer.getModelMetadata(onSuccess, onError) ⇒ Object

This method retrieves model metadata from bimU.io server.

Kind: instance method of Viewer
Returns: Object - Model metadata object.

Param Type Description
onSuccess onSuccessCallback Callback when data is received.
onError onErrorCallback Callback when an error occurs.

viewer.getElementDataByIndex(elementIndex, onSuccess, onError) ⇒ Object

This method retrieves model element data (Revit parameters, Navisworks properties, etc.) from bimU.io server.

Kind: instance method of Viewer
Returns: Object - Element data object.

Param Type Description
elementIndex number Element index.
onSuccess onSuccessCallback Callback when data is received.
onError onErrorCallback Callback when an error occurs.

viewer.toggleFullscreen()

This method enables or exits full screen mode.

Kind: instance method of Viewer

viewer.readCoordinates()

This method starts user interaction to read XYZ coordinates.

Kind: instance method of Viewer

viewer.measureDistance()

This method starts user interaction to measure distance point by point.

Kind: instance method of Viewer

viewer.measureHeight()

This method starts user interaction to measure height by three points.

Kind: instance method of Viewer

viewer.measureAngle()

This method starts user interaction to measure angles by a triangle formed by three points.

Kind: instance method of Viewer

viewer.measureArea()

This method starts user interaction to measure area by a polygon.

Kind: instance method of Viewer

viewer.clearAllMeasurements()

This method removes all current measurements shown in the viewer.

Kind: instance method of Viewer

viewer.setColor(elementIndices, color, transparency)

This method sets element color.

Kind: instance method of Viewer

Param Type Description
elementIndices Array.<number> An array of element indices.
color THREE.Color Color object in RGB.
transparency number 0 is Opaque. 1 is invisible.

viewer.setTexture(elementIndices, texture)

This method adds texture to elements.

Kind: instance method of Viewer

Param Type Description
elementIndices Array.<number> An array of element indices.
texture THREE.Texture Texture object.

viewer.addObject(object3D) ⇒ string

This method adds an arbitrary 3D object to the viewer.

Kind: instance method of Viewer
Returns: string - UUID of created Object3D.

Param Type Description
object3D THREE.Object3D Three.js Object3D object.

viewer.removeObject(objectId)

This method removes an existing 3D object from the viewer.

Kind: instance method of Viewer

Param Type Description
objectId string Three.js Object3D UUID.

viewer.addTag(type, text, location) ⇒ string

This method adds a 3D sprite to a particular location.

Kind: instance method of Viewer
Returns: string - UUID of created Object3D.

Param Type Description
type string Tag type.
text string Text to display in tag.
location THREE.Vector3 A 3D point where this tag should be placed.

viewer.removeTag(tagId)

This method removes an existing tag from the viewer.

Kind: instance method of Viewer

Param Type Description
tagId string Three.js Object3D UUID.

viewer.getGeometry(elementIndex) ⇒ THREE.Geometry

This method returns primitive geometry of a particular element.

Kind: instance method of Viewer
Returns: THREE.Geometry - Three.js Geometry object.

Param Type Description
elementIndex number Element index.

viewer.getLocation(elementIndex) ⇒ THREE.Vector3

This method returns the center point of a particular element.

Kind: instance method of Viewer
Returns: THREE.Vector3 - Three.js Vector3 object.

Param Type Description
elementIndex number Element index.

viewer.getSelectedElementIndices() ⇒ Array.<number>

This method returns the center point of a particular element.

Kind: instance method of Viewer
Returns: Array.<number> - An array of element indices.

viewer.addCustomAction(name, tooltip, icon, callback)

This method creates a menu item on the user interface of the viewer.

Kind: instance method of Viewer

Param Type Description
name string Name of custom action.
tooltip string Short description.
icon string Icon string.
callback function A callback function when the menu item is clicked.

viewer.removeCustomAction(name)

This method removes an existing menu item.

Kind: instance method of Viewer

Param Type Description
name string Name of custom action.

viewer.setBackgroundColor(color)

This method sets background color of the viewer canvas.

Kind: instance method of Viewer

Param Type Description
color THREE.Color Color object in RGB.

viewer.toggleWireframeMode()

This method turns on or off wireframe mode.

Kind: instance method of Viewer

viewer.getElementDataByFilter(filter, properties, isDistinct) ⇒ Object

This method retrieves element data based on a custom element filter from bimU.io server.

Kind: instance method of Viewer
Returns: Object - Element data object.

Param Type Description
filter string A query string of filter.
properties Array.<string> An array of element properties to return.
isDistinct boolean Whether return only unique values.

viewer.getElementDataByElementId(elementIdArray, properties) ⇒ Object

This method retrieves element data by an array of element IDs from bimU.io server.

Kind: instance method of Viewer
Returns: Object - Element data object.

Param Type Description
elementIdArray Array.<string> An array of element IDs.
properties Array.<string> An array of element properties to return.

viewer.getElementDataByUniqueId(uniqueIdArray, properties) ⇒ Object

This method retrieves element data by an array of unique IDs from bimU.io server.

Kind: instance method of Viewer
Returns: Object - Element data object.

Param Type Description
uniqueIdArray Array.<string> An array of unique IDs.
properties Array.<string> An array of element properties to return.

viewer.dispose()

This method destroy this Viewer instance and release all resources.

Kind: instance method of Viewer

ViewerConfiguration : Object

Configuation object used to initialise bimU.io Viewer.

Kind: global typedef
Properties

Name Type Description
domElementId string DIV element ID
accessToken string Access token
baseUrl string Override base URL of bimU.io server.
showFPS boolean Whether show FPS meter.
showUI boolean Whether show UI.

Viewpoint : Object

BCF-compatible camera viewpoint.

Kind: global typedef
Properties

Name Type Description
camera string Perspective camera or orthographic camera.
clippingPlanes string Clipping plane definition.
originatingSystem string Where this viewpoint was created from.

onProgressCallback : function

This callback reports model loading progress.

Kind: global typedef

Param Type Description
type string Event type.
progress number Model loading progress in percentage.