问题
I am looking to determine if a node is an assembly or a part. I have looked through the viewer3D.js code and came across the below flags:
Although when I work access these flags, the result is always 0 for all nodes regardless whether it is a GEOMETRY, COMPOSITE OR ASSEMBLY.
Are these flags currently in use? Or are they legacy code that is no longer being used?
回答1:
You can simply check if the node has children or not. Only leaf nodes have geometry. I don't know of a more direct way to do that
const instanceTree = viewer.model.getData().instanceTree
var childCount = 0
instanceTree.enumNodeChildren(nodeId, (childId) => {
++childCount
})
if (childCount) {
//this is an "assembly" node
}
来源:https://stackoverflow.com/questions/42931337/determine-if-node-is-an-assembly-or-part-in-viewer