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

故事扮演 提交于 2019-12-02 10:25: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 those lines. Now I want to know the start and stop points (vertices) of those lines so that I can create a Three.Shape() of the room borders.

[EDIT] I get the fragId from dbId

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;
}

Question: Once I know the fragId is there a way to see its start and stop points(vertices)? Also will those vertices be world space or local space?


回答1:


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


来源:https://stackoverflow.com/questions/38919970/autodesk-forge-viewer-how-to-get-coordinates-of-line-start-stop

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