如何在 autodesk-viewer 中设置元素的透明性? [英] How set transparenty of element in autodesk-viewer?

查看:26
本文介绍了如何在 autodesk-viewer 中设置元素的透明性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置模型元素的透明度,但我做不到.我正在寻找一种方法可以做到这一点,但我尝试过的方法不起作用.

I'm trying to set the transparency of an element of a model, but I can't do it. I'm looking for a method that will do this, but the methods I tried did not work.

推荐答案

Viewer 并没有真正提供任何原生/内置的东西来做到这一点,但只要你可以参考,THREE.js 在图形操作方面总是你的朋友查看器中目标元素的材质(通过其 dbid/nodeid):

Viewer does not really offer anything native/built-in to do this but THREE.js is always your friend in terms of graphical operations so long as you can reference the material of the target element (by its dbid/nodeid) in Viewer:

var fragList = viewer.model.getFragmentList();    

var fragIds = []

model.getData().instanceTree.enumNodeFragments(
  dbid, (fragId) => {
   fragIds.push(fragId)
});

    fragIds.forEach((fragId) => {
      //grab the material
      var material = fragList.getMaterial(fragId);

      if(material) {
        //set transparency
        material.opacity = 0.5;
        material.transparent = true;
        //mark for update
        material.needsUpdate = true
      }
    })
  });
  viewer.impl.invalidate(true, true, true) //notify renderer to update
}

这篇关于如何在 autodesk-viewer 中设置元素的透明性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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