简体   繁体   中英

Change assembly color in Forge Viewer

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

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 .

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM