Forge Viewer API: Bounding box for a specific element

淺唱寂寞╮ 提交于 2021-01-29 14:19:10

问题


I am using the following method for determining the bounding box of a specific element:

MyViewer.select( [dbId]); var box = MyViewer.utilities.getBoundingBox();

This works but I wonder if there is a direct function to do this (similar to how getBulkProperties work), especially when I am running through a large number of dbIds in a loop.

I also figured out that I can do this by finding the list of fragments of the element and calculating bounding box of each to calculate element's bounding box. That is more work.

Thanks Bandu


回答1:


@Bandu, I do not find any more direct method, but maybe the code function below could be of use?

 function getModifiedWorldBoundingBox (fragIds) {

        //fragments list array
        var fragList = NOP_VIEWER.model.getFragmentList();
        const fragbBox = new THREE.Box3()
        const nodebBox = new THREE.Box3()

        fragIds.forEach(function(fragId) { 
           fragList.getWorldBounds(fragId, fragbBox) 
           nodebBox.union(fragbBox)
        })

    return nodebBox
 }


来源:https://stackoverflow.com/questions/51035030/forge-viewer-api-bounding-box-for-a-specific-element

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