我需要在模型浏览器中完全隐藏对象,但保持其在场景中可见。
我尝试了一些方法,包括这个: 隐藏模型树面板上的对象
但它对我不起作用,因为
viewer.modelstructure.createUI()
功能不存在。
此外,viewer.modelstructure
中的树对象为空。我无法直接访问元素。
setModelStructurePanel 函数现在已标记为已弃用,因此我也无法使用它。
我正在为 Forge Viewer 使用
@contecht/react-adsk-forge-viewer
React Typescript 包装器,也许这就是原因。
从检查元素获取 lmv-nodeid。
viewer.addEventListener(Autodesk.Viewing.EXTENSION_ACTIVATED_EVENT,async(e)=>{
if(e.extensionId == "Autodesk.ModelStructure" && e.type=="extensionActivated"){
let lmvnodeid = 939; // change this in your case, for multiple nodes, change this to array and put the below code in for loop
let node = document.querySelectorAll('[lmv-nodeid="' + lmvnodeid + '"]')[0]
node.style.display = 'none'
}
});