我得到这个错误:未捕获的TypeError:>无法读取未定义的属性'getRootId‘,即使我使用Autodesk.Viewing.GEOMETRY_LOADED_EVENT..still也没有效果。
发布于 2017-08-31 14:38:40
当您想访问instanceTree时,您只需等待Autodesk.Viewing.OBJECT_TREE_CREATED_EVENT被触发
viewer.addEventListener(Autodesk.Viewing.OBJECT_TREE_CREATED_EVENT, function () {
var instanceTree = model.getData().instanceTree //cool
})发布于 2017-08-28 19:41:40
你不应该使用instanceTree数据结构,但函数/操作,这是受支持的方式。如果您需要枚举叶节点,请尝试类似于described here的方法
function getAllLeafComponents(viewer, callback) {
var cbCount = 0; // count pending callbacks
var components = []; // store the results
var tree; // the instance tree
function getLeafComponentsRec(parent) {
cbCount++;
if (tree.getChildCount(parent) != 0) {
tree.enumNodeChildren(parent, function (children) {
getLeafComponentsRec(children);
}, false);
} else {
components.push(parent);
}
if (--cbCount == 0) callback(components);
}
viewer.getObjectTree(function (objectTree) {
tree = objectTree;
var allLeafComponents = getLeafComponentsRec(tree.getRootId());
});
}https://stackoverflow.com/questions/45910495
复制相似问题