问题描述
我正在使用以下方法确定特定元素的边界框:
I am using the following method for determining the bounding box of a specific element:
MyViewer.select( [dbId]); var box = MyViewer.utilities.getBoundingBox();
这行得通,但是我想知道是否有直接函数可以做到这一点(类似于getBulkProperties的工作方式),尤其是当我循环运行大量dbId时.
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.
谢谢班杜
推荐答案
@Bandu,我找不到更直接的方法,但是下面的代码功能可能有用吗?
@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
}
这篇关于Forge Viewer API:特定元素的边界框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!