【发布时间】:2021-04-11 23:30:37
【问题描述】:
我们在 Web 应用程序中使用 forge viewer(v7)。
我们的要求是从 Forge 查看器中裁剪特定的房间/区域。例如,如果我们在 forge 查看器中显示了一个房屋模型,那么如果用户选择了一个厨房(从菜单或导航栏),那么查看器应该只显示厨房区域(包括它的所有对象,如橱柜、燃烧器、冰箱、水槽等。 ) 和所有其他对象/部分应隐藏。卧室、浴室等也是如此。它仅用于在运行时查看,而不用于任何自动化。
在使用 Forge API(使用 Revit 引擎)的帮助下,我们正在获取房间坐标(最小和最大 X、Y、Z)。
GeometryElement geoElement = room.ClosedShell;
BoundingBoxXYZ boundingBox = geoElement.GetBoundingBox();
XYZ min = boundingBox.Min;
XYZ max = boundingBox.Max;
我们正在使用 viewer.setCutPlanes 函数在查看器中绘制剖切面。
var minPt = new THREE.Vector3(x,y,z); //!<<< put your point here
var maxPt = new THREE.Vector3(x,y,z); //!<<< put your point here
const normals = [
new THREE.Vector3(1, 0, 0),
new THREE.Vector3(0, 1, 0),
new THREE.Vector3(0, 0, 1),
new THREE.Vector3(-1, 0, 0),
new THREE.Vector3(0, -1, 0),
new THREE.Vector3(0, 0, -1)
];
const bbox = new THREE.Box3(minPt, maxPt);
const cutPlanes = [];
for (let i = 0; i < normals.length; i++) {
const plane = new THREE.Plane(normals[i], -1 * maxPt.dot(normals[i]));
// offset plane with negative normal to form an octant
if (i > 2) {
const ptMax = plane.orthoPoint(bbox.max);
const ptMin = plane.orthoPoint(bbox.min);
const size = new THREE.Vector3().subVectors(ptMax, ptMin);
plane.constant -= size.length();
}
const n = new THREE.Vector4(plane.normal.x, plane.normal.y, plane.normal.z, plane.constant);
cutPlanes.push(n);
}
viewer.setCutPlanes(cutPlanes);
但是当我们将这些坐标(通过 API 获得)传递给这个前端 JS 代码时,cutPlanes 会在不正确的位置/点创建。例如,当我们传递厨房的坐标时,它会裁剪屋顶的一小部分,并且与所有其他房间相同。
可能的原因是Revit和forge查看器坐标不一样。
有没有人知道我们如何使用 Forge 查看器映射这些 Revit 坐标并绘制剖切面?
【问题讨论】:
标签: autodesk-forge autodesk-viewer