Get THREE.Mesh elements in Autodesk Forge Viewer

亡梦爱人 提交于 2019-11-29 16:43:48
Philippe

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:

 var instanceTree = model.getData().instanceTree

 var fragIds = []

 instanceTree.enumNodeFragments(dbId, function(fragId){
     fragIds.push(fragId)
 })

 // to change material or transform, need to iterate all
 // fragments of a given dbId and apply same material/transform

 fragIds.forEach(function(fragId) {

     var renderProxy = viewer.impl.getRenderProxy(viewer.model, fragId)

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