如何在 Autodesk Forge 查看器中更改选择颜色?
How do you change selection color in the autodesk forge viewer?
在 Forge Viewer v3 中,我们像这样设置选区的颜色:
onRequestClick(e) {
const THREE_RED_COLOR = new THREE.Color(1, 0, 0);
NOP_VIEWER.impl.setSelectionColor(THREE_RED_COLOR);
NOP_VIEWER.select($(e.target).parent().find(`th`).data(`attributes`));
}
在 v6 中,此代码仍按预期选择查看器对象,但选择颜色保持默认蓝色,并没有按预期更改为红色。
现在是否通过其他方法完成此更改?还有什么我想念的吗?
当我尝试使用 Viewer v6.4.2 时,您的代码运行良好:
viewer.impl.setSelectionColor(new THREE.Color(1, 0, 0));
viewer.addEventListener(Autodesk.Viewing.GEOMETRY_LOADED_EVENT,()=>viewer.select(1))
查看实际效果 here。
您可能想在浏览器控制台中再次尝试相关代码以找出问题。
编辑
如果您查看源代码,它清楚地表明它仅适用于 3D 模型:
/**
* Changes the color of the selection for 3D models.
*
* @example
* viewer.setSelectionColor(new THREE.Color(0xFF0000)); // red color
* @param {THREE.Color} color
*
* @alias Autodesk.Viewing.Viewer3D#setSelectionColor
*/
Viewer3D.prototype.setSelectionColor = function(color, selectionType) {
this.impl.setSelectionColor(color, selectionType);
};
将向工程部门记录功能请求,以将此功能也移植到 2D 模型。
我确认它不适用于 2D 文件。
这是我尝试的屏幕截图。
我在 2 个圆圈上调用了 get Selection。确认观看者参与其中并且我能够检测到不同的选择。
然后当我调用 setSelectionColor 函数时,没有任何反应。
尝试使用查看器viewer.clearSelection(); viewer.set2dSelectionColor(red)
其中 viewer=NOP_VIEWER; red = new THREE.Color(1,0,0)
这能解决问题吗?
在 Forge Viewer v3 中,我们像这样设置选区的颜色:
onRequestClick(e) {
const THREE_RED_COLOR = new THREE.Color(1, 0, 0);
NOP_VIEWER.impl.setSelectionColor(THREE_RED_COLOR);
NOP_VIEWER.select($(e.target).parent().find(`th`).data(`attributes`));
}
在 v6 中,此代码仍按预期选择查看器对象,但选择颜色保持默认蓝色,并没有按预期更改为红色。 现在是否通过其他方法完成此更改?还有什么我想念的吗?
当我尝试使用 Viewer v6.4.2 时,您的代码运行良好:
viewer.impl.setSelectionColor(new THREE.Color(1, 0, 0));
viewer.addEventListener(Autodesk.Viewing.GEOMETRY_LOADED_EVENT,()=>viewer.select(1))
查看实际效果 here。
您可能想在浏览器控制台中再次尝试相关代码以找出问题。
编辑
如果您查看源代码,它清楚地表明它仅适用于 3D 模型:
/**
* Changes the color of the selection for 3D models.
*
* @example
* viewer.setSelectionColor(new THREE.Color(0xFF0000)); // red color
* @param {THREE.Color} color
*
* @alias Autodesk.Viewing.Viewer3D#setSelectionColor
*/
Viewer3D.prototype.setSelectionColor = function(color, selectionType) {
this.impl.setSelectionColor(color, selectionType);
};
将向工程部门记录功能请求,以将此功能也移植到 2D 模型。
我确认它不适用于 2D 文件。 这是我尝试的屏幕截图。
我在 2 个圆圈上调用了 get Selection。确认观看者参与其中并且我能够检测到不同的选择。
然后当我调用 setSelectionColor 函数时,没有任何反应。
尝试使用查看器viewer.clearSelection(); viewer.set2dSelectionColor(red)
其中 viewer=NOP_VIEWER; red = new THREE.Color(1,0,0)
这能解决问题吗?