可以通过下列方式拿到构件树: var it = viewer.model.getData().instanceTree; //或 viewer.getObjectTree(function( instanceTree ) { console.log( instanceTree ); }); 因数据优化的缘故,所有数据都是平坦化过的,要重建数据结构可以通过: function buildModelTree( model ) { //builds model tree recursively function _buildModelTreeRec( node ) { it.enumNodeChildren( node.dbId, function(childId) { node.children = node.children || []; var childNode = { dbId: childId, name: it.getNodeName( childId ) }; node.children.push( childNode ); _buildModelTreeRec( childNode ); }); } //get model instance tree and root component var it = model.getData().instanceTree; var rootId = it.getRootId(); var rootNode = { dbId: rootId, name: it.getNodeName( rootId ) }; _buildModelTreeRec( rootNode ); return rootNode; } var root = buildModelTree( viewer.model );
可以通过下列方式拿到构件树:
因数据优化的缘故,所有数据都是平坦化过的,要重建数据结构可以通过: