Apply custom appearance to individual model fragments in forge viewer

时光毁灭记忆、已成空白 提交于 2021-01-24 20:15:52

问题


In the viewable, the model has three leaf nodes that are named “Solid1” but have a parent name of “Tread”, how do I search by parent name to get the dbId?

Following the answer from Default material for model in Forge Viewer I can see that we can set a color. Is it possible to instead apply a texture?

Thanks!


回答1:


The Viewer has a search() function so you can search for any component based on its properties. You can then go up and down the instance tree to go from Thread to Solid1 or vice versa. See e.g. https://forge.autodesk.com/blog/selection-override

Yes, you can also use texture for materials. See e.g. https://github.com/Autodesk-Forge/library-javascript-viewer-extensions/blob/master/src/Autodesk.ADN.Viewing.Extension.Material/Autodesk.ADN.Viewing.Extension.Material.js#L273
That code is used in this sample https://forge-rcdb.autodesk.io/configurator?id=58c7ae474c6d400bfa5aaf37 Just enable the "Material" extension by clicking on it, then you will be able to assign textured materials to faces.



来源:https://stackoverflow.com/questions/65585300/apply-custom-appearance-to-individual-model-fragments-in-forge-viewer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!