本文介绍了如何在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中设置元素的透明度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!