Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
217 views
in Technique[技术] by (71.8m points)

Apply custom appearance to individual model fragments in forge viewer

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!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...