xeokit / xeokit-sdk

Open source JavaScript SDK for viewing high-detail, full-precision 3D BIM and AEC models in the Web browser.
https://xeokit.io
Other
736 stars 291 forks source link

"storeys" hierarchy TreeView crashes when adding non-IFC model #231

Closed tothatt81 closed 4 years ago

tothatt81 commented 4 years ago

Hey Lindsay,

The TreeView plugin seems to crash the whole viewer with the duplex model. Would you please look into it? Thanks!

xeolabs commented 4 years ago

Will do - can also reproduce this issue here: https://xeokit.github.io/xeokit-viewer/?project=Duplex

barnabasmolnar commented 4 years ago

Hey,

A quick FYI

https://github.com/xeokit/xeokit-sdk/blob/master/src/plugins/TreeViewPlugin/ModelTreeView.js#L203

You're looking for an IfcProject type here but I just checked and the duplex metamodel json has none.

xeolabs commented 4 years ago

When configuring the TreeViewPlugin with hierarchy: "storeys", I made it expect the model to have an IfcBuilding element type. When not, it will log this error:

[xeokit plugin TreeViewPlugin]: Failed to build storeys hierarchy for model 'myModel' - perhaps this model is not an IFC model?

and then not build the nodes, without crashing. We can then still switch it to another hierarchy mode, ie. myTreeView.hierarchy="containment".

xeolabs commented 4 years ago

Fixed in commit https://github.com/xeokit/xeokit-sdk/commit/4a7958f748f01879d315ff6ba084f5679282a53e