如何在 Forge 查看器中创建剖面框

How can I create section box in forge viewer

我想在 Forge 查看器中构建一个剖面框。我通过区域标记有 minx、maxX、minY、maxY。我也有 minZ 和 maxZ 通过级别选择 (levels[i].elevation – globalOffset.Z).

我想要类似于截面分析中默认添加框按钮的类似功能,但我想添加最小最大坐标

你能帮我解决这个问题吗?

给你~请参考以下代码片段为观众计算切面参数:

const minPt = new THREE.Vector3( -82.73119354248047, -115.42709350585938, -31.42848777770996 ); //!<<< put your point here
const maxPt = new THREE.Vector3( -0.0000020212402347397074, 0, 0 ); //!<<< 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 );