Autodesk Forge Viewer How to get coordinates of line start/stop

前端 未结 1 773
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-24 22:28

I am trying to do room highlighting in forge viewer.

In revit I have created lines that represent the borders of a room. After conversion to svf I know the dbids of tho

1条回答
  •  离开以前
    2021-01-24 23:11

    This is what I ended up doing. Note make sure the model is finished loading before calling instanceTree. Also in my case the dbid and fragid where one to one, not sure if this will always be the case in the instance tree.

    function getFragIdFromDbId(viewer, dbid) {
     var returnValue;
     var it = viewer.model.getData().instanceTree;
     it.enumNodeFragments(dbid, function (fragId) {
      console.log("dbId: " + dbid + " FragId : " + fragId);
      returnValue = fragId;
     }, false);
     return returnValue;
    }
    
    ...
    
    // only need the start vertex
    var floatArray = [];
    for (var i = 0; i < dbidArray.length; i++) {
    var fragId = getFragIdFromDbId(viewer, dbidArray[i]);
    var mesh = viewer.impl.getRenderProxy(viewer.model, fragId);
    var matrixWorld = mesh.matrixWorld;
    var lmvBufferGeometry = mesh.geometry;
    var lmvFloatArray = lmvBufferGeometry.vb; //this will have an array of 6  values 0,1,2 are start vertext , 3,4,5 are end vertex
    
    floatArray.push(lmvFloatArray[0]);
    floatArray.push(lmvFloatArray[1]);
    floatArray.push(lmvFloatArray[2]);
    
    }
    //use matrixWorld to convert array to worldSpace
    

    0 讨论(0)
提交回复
热议问题