I would like to get the THREE.Mesh object of an element in Autodesk Forge Viewer. Here is the code:
var dbId; // geometry node Id of an element
var viewer; // GuiViewer3D
var mesh = viewer.impl.getRenderProxy(viewer.model, dbId);
The return mesh object is a THREE.Mesh object but with null Geometry and Material, so it is useless. How can I get the real THREE.Mesh object?
Thank you.
It depends what you want to do with the mesh: if you want to change the render style, you need to get the renderProxy, if you want to transform the component position or rotation, you need to get the fragmentProxy.
Those methods take as input the fragment ids not the dbId.
Find examples for both at:
Viewing.Extension.Material
Viewing.Extension.Transform
You get the fragment Ids for a given dbId either from the selection event, as illustrated in the above samples, or by using enumNodeFragments: