[英]autodesk forge viewer set selection color to default
在 object 选择我使用下面的代码来更改选定的 object 颜色,
viewerApp.getCurrentViewer().impl.setSelectionColor(new THREE.Color(1, 0, 0));
它工作正常,但如何将选择颜色设置为默认值?
我都试过了
viewerApp.getCurrentViewer().clearSelection();
和
viewerApp.getCurrentViewer().clearThemingColors();
但这些方法似乎不起作用。
难道我做错了什么? 或者更改颜色并将其恢复为默认值的最佳做法是什么?
查看器版本:6*
这个选择颜色实际上是硬编码的,没有保存在任何配置中。 您需要通过指定原始颜色来重置颜色,如下所示:
.impl.setSelectionColor(new THREE.Color(0.4, 0.6, 1));
如果目标是更改所选元素的颜色,我强烈建议改用setThemingColor 。 这将为定义的 dbid 设置主题颜色,这可以在任何时候轻松清除。 您可以将其连接到 select 事件,以自动清除和重新分配 colors。 您可以在初始化查看器后处理此问题。
在 v7 中:
viewerApp.getCurrentViewer().viewer.addEventListener(Autodesk.Viewing.SELECTION_CHANGED_EVENT, event=>{
viewerApp.getCurrentViewer().clearThemingColors();
event.dbIdArray.forEach(id =>
{
viewerApp.getCurrentViewer().setThemingColor(id, new THREE.Vector4(1,0,0,1)
})
}
)
但是,如果您确实想采用这种方法,则必须找出默认颜色是什么,并使用setSelectionColor
和这种颜色来覆盖它:编辑感谢 Cyrille,我们现在知道了! 所以相应地调整了颜色
viewerApp.getCurrentViewer().impl.setSelectionColor(new THREE.Color(0.4, 0.6, 1));
没有明确定义 function。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.