Options
All
  • Public
  • Public/Protected
  • All
Menu

bimlib

Copyright © OOSD LTD 2020

Getting Started

To start using the library you must include BIMEngine-Core.js and bimlib.min.js in your html page.

You also need BIMEngine-Core.wasm

The library is mostly async based using promises.

Initializing

await bimlib.initalizeBimEngineCore();
let renderer = new bimlib.BimCTWebGL2Renderer(divElement, options);
await renderer.init();
renderer.beginDrawLoop();

The first operation should be to initialize the wasm module. To do so you have to call bimlib.initalizeBimEngineCore()

Afterwards you must create a new renderer object. For now only BimCTWebGL2Renderer is supported but other implementations are planned for the future, such as a server-side rendering one.

The third step is to asynchronously initialize the new renderer.

The last step is to start the animation loop.

The EmscriptenBIMRenderer constructor needs one required option. A HTMLDivElement that must be empty while having not zero size. Both height and width must be non-zero either using html attributes or styling. Upon construction of the renderer, event listeners are registered so that resizing of the div will also resize the renderer.

The second argument of the constructor is optional and allows customization of the renderers initialization.

Loading Data

To load data you must either fetch it yourself as a Uint8Array or provide a XMLHttpRequest to the loadDataMsgPackGzip method. The request must be fully prepared as the renderer will only call its send() method.

Using this method the data are serialized and gzipped. To get such data you can call the GET /api/v1/models/{id}/geometry of the BimCT Rest API

Events

selectionChange. This fires everytime the selected elements of the renderers change, usually as a result of using the rubberband selection. To subscribe to such an event use the following code

renderer.selectionChange.subscribe((renderer, arrayOfElements) => {
//perform some action with the elements
});

mouseRightClicked. This fires when the user right-clicks on the renderer

Unloading Data

To unload a model just call unloadModel and provide the id of the model, or call unloadAll to unload all models.

Destroying the renderer

To unload all models, destroy the renderer and all html elements it has created call destroy

Visibility

showAllElements.

hideSelectedElements.

isolateSelectedElements.

hideElementsByGlobalId.

showElementsByGlobalId.

Zoom

zoomToSelectedElements.

zoomToElementsByGlobalIds.