【问题标题】:How to set viewer.setThemingcolor upon multiple instances, without causing refresh of loader per instance?如何在多个实例上设置 viewer.setThemingcolor,而不会导致每个实例刷新加载器?
【发布时间】:2019-07-09 11:44:38
【问题描述】:

我想在材质上设置颜色,但是 setThemingColor(dbId,color,model) 会导致我的查看器在每次添加实例时刷新。这是一个问题,因为我有很多必须设置的实例。

是否有任何功能可以用来阻止查看器重新加载,添加我想要设置为颜色的整个 id 列表,然后刷新查看器?

也就是说,对于应该具有该颜色的 2000 个 id 的列表,我得到一个更新而不是 2000 个。

【问题讨论】:

    标签: three.js autodesk-forge


    【解决方案1】:

    您可以改用Model#setThemingColor( dbId, color ),然后告诉查看器在设置完所有颜色后重新加载场景。这是给你的代码sn-p:

    let selSet = viewer.getAggregateSelection();
    for(let i=0; i<selSet.length; i++) {
        const model = selSet[i].model;
        const selection = selSet[i].selection;
    
        selection.forEach(( dbId ) => {
            model.setThemingColor( dbId, color );
        });
    }
    
    viewer.impl.invalidate(true); 
    

    【讨论】:

    • 谢谢,它解决了问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-14
    • 2020-07-27
    • 2015-09-23
    • 1970-01-01
    • 1970-01-01
    • 2016-06-19
    相关资源
    最近更新 更多