In Forge Viewer v3 we were setting the color of a selection like this:
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`));
}
In v6, this code still selects the viewer objects as expected, but the selection color stays at default blue and does not change to red as expected. Is this change done through a different method now? Is there something else I am missing?
try using viewer viewer.clearSelection(); viewer.set2dSelectionColor(red)
viewer.clearSelection(); viewer.set2dSelectionColor(red)
where viewer=NOP_VIEWER; red = new THREE.Color(1,0,0)
viewer=NOP_VIEWER; red = new THREE.Color(1,0,0)
Does that fix it?
Your code worked fine when I tried with Viewer v6.4.2:
viewer.impl.setSelectionColor(new THREE.Color(1, 0, 0));
viewer.addEventListener(Autodesk.Viewing.GEOMETRY_LOADED_EVENT,()=>viewer.select(1))
See it in action here .
You might want to try relevant code again in your browser console to isolate the issue.
EDIT
If you look at the source it clearly states that it only works for the 3D models:
/**
* 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);
};
Will log a feature request with Engineering to port this functionality to 2D models as well.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.