Alternative Model Tree

A Model Tree Implementation for HOOPS Communicator using jsTree, Tabulator and Goldenlayout.

While the standard model tree in HOOPS Communicator is quite feature-rich it has not been written with customization in mind. The class below implements a model tree using the above mentioned open source libraries and can be fairly easily modified and enhanced.

A few implementation notes:
JsTree is a great library (in fact we used it for the first version of HOOPS Communicator) but it does not support the concept of selection “breadcrums” natively and the way it handles mixed checkbox states does not quite work with the somewhat more complex visibility states in HOOPS Communicator. It required a bit of “wrangling” to make it function and update correctly. In hindsight writing this type of tree control from scratch might be a better option.

An attempt was made to improve on the way IFC relationship data is displayed. Not only does the relationship window display the complete hierachy of the related/relating entities but it allows for selection of those entities without updating the main tree. If you want the main tree (and the relationship window) to update as well simply hold down the “alt” key.


The Model Tree itself should be initialized in the modelStructureReady callback of your application:

var scTree = new ScTree(hwv, true, true);

Creates a new ScTree object.
The first parameter is the webviewer object. The second parameter indicates if the GoldenLayout layout manager should be used. If this is set to true all the required divs will be created automatically and the viewer itself will be included in the layout. In this case it expects the viewer div to have the id “content” which is the standard naming for our demo viewer. If you want to manage your own layout instead you need to define three divs with the following ids:

“scTreeModelTreeDiv” for Main Model Tree
“scTreeRelationshipDiv” for IFC relationship info
“scTreePropertyDiv” for Node Properties

The third parameter indicates if the relationship window should be displayed (which is currently only relevant for IFC models).

This function refreshes the model tree. You need to call it after instantiating the scTree class. It also needs to be called whenever nodes are added to the model tree (e.g. when loadSubtreeFromModel() is called)

Below is the main code for the scTree class. To use this class you need to include the following libraries (either via CDN as shown here or directly):

<script src=""></script>
<link rel="stylesheet" href="" />

<script type="text/javascript" src=""></script>
<link href="" rel="stylesheet">

<link type="text/css" rel="stylesheet" href="" />
<link type="text/css" rel="stylesheet" href="" />
<script type="text/javascript" src=""></script>

It is important to note that this code is not production-ready and provided “as-is”. It is really meant as a starting point for your own development and as an example for some of the functionality and concepts used in HOOPS Communicator.

ScTree.js (23.8 KB)

I have updated the Model Tree code to now support multiple independent model trees for different parts of the hierarchy. This can be useful for separating the model tree in the case of federated BIM models for example. To make this work the constructor was slightly changed. It now accepts the div id’s for the modeltree, relationshiptree and properties. Those will be used only if useLayout is set to false. The startnode for the model tree is then set in the refresh() function that should be called after the scTree object has been created.

See below for an example that creates two modeltrees, the second one omitting the relationshiptree and the properties.

var scTree1 = new ScTree(hwv, false, true, "modeltreediv", "relationshipdiv", "propertydiv");
var scTree2 = new ScTree(hwv, false, false, "modeltreediv2", null,null);


ScTree.js (25.9 KB)