Autodesk Forge Viewer v7 - setThemingColor

Autodesk Forge Viewer v7 - setThemingColor

我希望有人能帮我解决有关 Autodesk Forge Viewer 的 setThemingColor 函数的问题。

基本上我的问题是当我 运行

viewer.setThemingColor(dbId, new Vector4( 1, 1, 1, 1 ), null, true )

在我的代码中没有任何反应,元素也没有获得新颜色。

我尝试过的:

1) 如果我尝试 运行 浏览器中 NOP_VIEWER 上完全相同的代码行,它会起作用,但前提是它是一个新的 dbId 而不是刚刚创建的那个been 运行 来自我的代码。

2) 我已尝试确保找到叶 dbId 并使用它。没有任何作用。

3) 我尝试将模型添加到函数调用中:

viewer.setThemingColor(dbId, new Vector4( 1, 1, 1, 1 ), model, true )

4) 我已经尝试运行模型级别的功能:

model.setThemingColor(dbId, new Vector4( 1, 1, 1, 1 ));

viewer.impl.invalidate(true);

5) 我已经从我的代码中测试了 viewer.isolate(dbId) 以确保我可以访问查看器实例。这行得通。

是否有其他人遇到同样的问题或可以复制该错误? 我希望有人能帮助我们。

编辑:Petr Broz 回答后的更多信息:

"What version of the viewer are you using?":我们正在使用 v.7.*

"Do you see any error logs in the console after setting the theming color?": 我没有看到错误日志。

"At what point in time are you trying to set the color (for example, after the GEOMETRY_LOADED_EVENT)?":我在按钮上使用了一个 onClick 事件,所以它在 GEOMETRY_LOADED_EVENT

之后

答案:

我找到了解决办法。我必须将三个作为全局导入。

/* global THREE */

而不是

import {Vector4d} from "three"

这是一个快速代码笔,使用查看器版本 7.*(当前为 7.10)在预配置的 dbID(屋顶)上设置主题颜色:https://codepen.io/petrbroz/pen/WNbYXWz.

如果我们有一些额外的信息会很有帮助,例如:

  • 您使用的是哪个版本的查看器?
  • 设置主题颜色后,您是否在控制台中看到任何错误日志?
  • 您尝试在什么时间点设置颜色(例如,在 GEOMETRY_LOADED_EVENT 之后)?

或者,如果您不介意将实时 link 分享到您的应用或您的 Forge 应用配置,请给我们发送电子邮件至 forge (dot) help (at) autodesk (dot) com,我们将调查此问题我们的结局。