确定节点是查看器中的部件还是零件 [英] Determine if node is an assembly or part in viewer

查看:50
本文介绍了确定节点是查看器中的部件还是零件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找确定节点是装配体还是零件.我已经查看了viewer3D.js代码,并遇到了以下标志:

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:

尽管当我访问这些标志时,所有节点的结果始终为0,无论它是GEOMETRY,COMPOSITE还是ASSEMBLY.

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?

推荐答案

您可以简单地检查节点是否有子节点.只有叶节点具有几何形状.我不知道更直接的方法

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
 }

这篇关于确定节点是查看器中的部件还是零件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆