【问题标题】:Forge Viewer material manager getModelMaterials() doesn't return added materialsForge Viewer 材质管理器 getModelMaterials() 不返回添加的材质
【发布时间】:2022-06-14 15:35:41
【问题描述】:

当我使用materialManager.addMaterial(...) 添加新材质,然后调用materialManager.getMaterials(),返回的地图不包含我添加的材质。如果我想重复使用我的材料,我必须从materialManager._materials 获取。 materialManager.getMaterials() 不返回用户添加的材料有什么原因吗?

【问题讨论】:

    标签: autodesk-viewer


    【解决方案1】:

    getModelMaterials()findMaterial() 将仅查找具有特定名称前缀 model:x|mat 的材料。 x 代表Model.id

    所以,我建议你这样添加素材,然后调用

    const model = viewer.model;
    cosnt materialManager = viewer.mpl.matman();
    const materialNameHash = materialManager._getMaterialHash(model, 'my-red-mat'); //!<<< `model:1|mat:my-red-mat`
    
    const mat = new THREE.MeshBasicMaterial({ color: new THREE.Color('red'),  side: THREE.DoubleSide });
    
    materialManager.addMaterial( materialNameHash, mat, true );
    
    // find my-red-mat
    materialManager.findMaterial(model, 'my-red-mat');
    

    【讨论】:

      猜你喜欢
      • 2018-03-18
      • 2021-01-04
      • 2019-06-25
      • 2019-07-31
      • 2021-03-02
      • 2021-06-12
      • 2018-06-17
      • 2017-05-31
      • 2021-06-24
      相关资源
      最近更新 更多