Determine if node is an assembly or part in viewer

孤人 提交于 2019-12-12 04:45:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!