You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Autodesk Viewer中setGhosting能否仅对隔离部件生效?

Autodesk Viewer 仅虚化特定隔离部件的实现方案

全局的setGhosting(true)会对所有可见模型部件生效,这就是你操作后整个模型都虚化的原因。要实现仅对被隔离的部件应用虚化,别用全局的setGhosting,改用Viewer提供的针对特定DBID的虚化控制方法:

  • 如果你想让被隔离的部件单独虚化:

    // 假设已获取目标部件的DBID列表:isolatedDbIds
    // 先执行隔离(仅显示这些部件)
    viewer.isolate(isolatedDbIds);
    // 仅对这些被隔离的部件设置虚化
    viewer.setGhosted(isolatedDbIds, true);
    
  • 要是你的需求是让未被隔离的部件虚化、被隔离的保持清晰,可这么做:

    // 获取模型所有DBID(rootId一般为0)
    const rootId = viewer.model.getRootId();
    const allDbIds = viewer.model.getInstanceTree().getNodeChildren(rootId);
    // 先全局开启虚化
    viewer.setGhosting(true);
    // 隔离目标部件
    viewer.isolate(isolatedDbIds);
    // 取消被隔离部件的虚化状态,让它们清晰显示
    viewer.setGhosted(isolatedDbIds, false);
    

注意:调用这些方法前要确保模型已完全加载,可通过viewer.model.isLoaded()做判断;后续要重置虚化状态,直接调用viewer.setGhosting(false)或者viewer.setGhosted(allDbIds, false)即可。

内容的提问来源于stack exchange,提问作者Zecele

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 23:02:40