Reputation: 39
How can I change color in Forge Viewer when I select assembly? Do I need select all parts under assembly and change color? I know how to change one part color. Thanks
Upvotes: 0
Views: 396
Reputation: 5342
You can subscribe to the SELECTION_CHANGED_EVENT
and recursively (available in Viewer v6.5+) apply a theming color to the components by their dbid
:
viewer.addEventListener(Autodesk.Viewing.SELECTION_CHANGED_EVENT, event=>{
viewer.setThemingColor(event.dbIdArray[0], THREE.Vector4, null, true) //last boolean to toggle recursiveness
})
viewer.addEventListener(Autodesk.Viewing.AGGREGATE_SELECTION_CHANGED_EVENT, event=>{
... //multiple models
})
See doc for setThemingColor
here.
Upvotes: 0