【问题标题】:Best approach to color objects in Autodesk Forge Viewer在 Autodesk Forge Viewer 中为对象着色的最佳方法
【发布时间】:2020-11-03 10:01:00
【问题描述】:

我正在使用 Autodesk forge 查看器(我正在使用查看器版本 6*)进行 BIM 项目。

我想根据完成状态为不同的对象涂上不同的颜色。

查看下图。

对象已经着色我尝试使用 setThemingColor 但它不起作用。我不想使用 setSelectionColor,因为我的对象是在不选择特定对象的情况下显示颜色。

例如:在下图中,我想用相应的颜色为圆圈对象着色。

sample_image

更新:

这是我正在使用的代码 sn-p

function changeObjectColor(modelId, status){
 
  var color ;
  switch (status) {
    case 'Green':
      color =  new THREE.Vector4(0, 0.5, 0, 0.5);
      break;
    case 'Red':
      color =  new THREE.Vector4(1, 0, 0, 0.5);
      break;
  }

  viewerApp.getCurrentViewer().setThemingColor(modelId,color);
}

结果 result after setting the color

我也使用了隔离和选择方法,但是即使在删除这两个方法调用之后,特定对象的颜色仍然不会改变

新的尝试:

所以我设法在tutorial 之后设置/隐藏对象纹理(只是灰色)。但是后来我尝试使用 setThemingColor 方法,但对象仍然不会显示预期的颜色

  viewerApp.getCurrentViewer().setThemingColor(modelId, color, null, true);
  viewerApp.getCurrentViewer().impl.invalidate(true, true, false);

我在这里错过了什么?

【问题讨论】:

    标签: autodesk-forge autodesk-viewer autodesk


    【解决方案1】:

    setThemingColor 方法在 v6 中可用,应该可以正常工作。考虑发布负责设置颜色的代码的 sn-p。

    这是exampleForge Digital Twin 演示中如何使用该方法的@。

    【讨论】:

    • 你好 Petr,我用我的代码更新了帖子,我将通过这个例子谢谢
    • 谢谢!请注意,如果您正在为不是叶节点的对象 ID 着色(换句话说,具有此 ID 的对象由多个对象组成),您需要将 setThemingColor 方法的第 4 个参数设置为 @ 987654326@ 以递归方式应用颜色。
    • 我使用了 viewerApp.getCurrentViewer().setThemingColor(modelId, color, null, true);但结果对我来说是一样的
    • 不确定this 是否有帮助?
    猜你喜欢
    • 2021-04-26
    • 2021-05-13
    • 2020-01-16
    • 2017-08-16
    • 2021-01-31
    • 2018-12-06
    • 2017-06-28
    • 2020-08-06
    • 2020-05-06
    相关资源
    最近更新 更多