在 Autodesk Forge Viewer 中为对象着色的最佳方法

Best approach to color objects in Autodesk Forge Viewer

我正在使用 Autodesk Forge 查看器执行 BIM 项目(我使用的是查看器版本 6*)。

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

检查下图。

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

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

sample_image

更新:

这是我正在使用的代码片段

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

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

新尝试:

所以我设法 set/hide 遵循此 tutorial 的对象纹理(只是灰色)。但后来我尝试使用 setThemingColor 方法,但对象仍然不会显示预期的颜色

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

我在这里错过了什么?

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

这是一个 example of how the method is used in the Forge Digital Twin 演示。