问题
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