[英]Autodesk Forge Viewer v7 - setThemingColor
I hope somebody can help me with a question about the setThemingColor function for the Autodesk Forge Viewer.我希望有人可以帮助我解决有关 Autodesk Forge Viewer 的 setThemingColor 函数的问题。
Basically my issue is that when I run the基本上我的问题是当我运行
viewer.setThemingColor(dbId, new Vector4( 1, 1, 1, 1 ), null, true )
from within my code nothing happens, and the element does not get a new color.在我的代码中没有任何反应,并且元素没有获得新颜色。
What I have tried:我尝试过的:
1) If I try to run exactly the same line of code in the browser on the NOP_VIEWER it works, but only if it is a new dbId and not the one which had just been run from within my code. 1) 如果我尝试在 NOP_VIEWER 上的浏览器中运行完全相同的代码行,它会起作用,但前提是它是一个新的 dbId 而不是刚刚从我的代码中运行的那个。
2) I have tried to make sure to find the leaf dbId and use this. 2) 我试图确保找到叶 dbId 并使用它。 Did not have any effect.
没有任何影响。
3) I have tried to add the model to the function call: 3)我尝试将模型添加到函数调用中:
viewer.setThemingColor(dbId, new Vector4( 1, 1, 1, 1 ), model, true )
4) I have tried to run the function on the level of the model: 4)我尝试在模型级别运行该函数:
model.setThemingColor(dbId, new Vector4( 1, 1, 1, 1 ));
viewer.impl.invalidate(true);
5) I have from within my code tested viewer.isolate(dbId)
to make sure I have access to the viewer instance. 5) 我在我的代码中测试了
viewer.isolate(dbId)
以确保我可以访问查看器实例。 And this works.这有效。
Is anybody else experiencing the same issue or can replicate the bug?有没有其他人遇到同样的问题或可以复制错误? I hope somebody can help us out.
我希望有人可以帮助我们。
EDIT: More infor after Petr Broz answer:编辑:Petr Broz 回答后的更多信息:
"What version of the viewer are you using?": We are using v. 7.* “您使用的是哪个版本的查看器?”:我们使用的是 v. 7.*
"Do you see any error logs in the console after setting the theming color?": I see no error logs. “设置主题颜色后,您是否在控制台中看到任何错误日志?”:我没有看到错误日志。
"At what point in time are you trying to set the color (for example, after the GEOMETRY_LOADED_EVENT
)?": I use a onClick event on button, so it is after GEOMETRY_LOADED_EVENT
“您在什么时间点尝试设置颜色(例如,在
GEOMETRY_LOADED_EVENT
)?”:我在按钮上使用 onClick 事件,所以它是在GEOMETRY_LOADED_EVENT
之后
ANSWER:回答:
I found the solution.我找到了解决方案。 I had to import THREE as a global.
我不得不导入三个作为全局变量。
/* global THREE */
instead of代替
import {Vector4d} from "three"
Here's a quick codepen setting the theming color on a pre-configured dbID (roof of the house), using viewer version 7.* (currently 7.10): https://codepen.io/petrbroz/pen/WNbYXWz .这是使用查看器版本 7.*(当前为 7.10)在预先配置的 dbID(屋顶)上设置主题颜色的快速代码笔: https ://codepen.io/petrbroz/pen/WNbYXWz。
It'd be helpful if we had some additional info, for example:如果我们有一些额外的信息会很有帮助,例如:
GEOMETRY_LOADED_EVENT
)?GEOMETRY_LOADED_EVENT
)? Alternatively, if you don't mind sharing a live link to your app or your Forge app config, please send us an email to forge (dot) help (at) autodesk (dot) com
, and we'll investigate the issue from our end.或者,如果您不介意分享指向您的应用程序或 Forge 应用程序配置的实时链接,请向我们发送电子邮件至
forge (dot) help (at) autodesk (dot) com
,我们将从我们的结尾。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.