Get THREE.Mesh elements in Autodesk Forge Viewer

后端 未结 1 364
囚心锁ツ
囚心锁ツ 2020-12-22 03:40

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;         


        
相关标签:
1条回答
  • 2020-12-22 04:12

    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)
     })
    
    0 讨论(0)
提交回复
热议问题