本文介绍了如何在Forge Viewer中创建节框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在伪造查看器中构建一个节框.我通过区域标记获得了minx,maxX,minY,maxY.另外,我通过级别选择(级别[i] .elevation – globalOffset.Z)获得了minZ和maxZ.

I wanted to build a section box inside forge viewer. I have the minx, maxX, minY, maxY through area marking. Also I have minZ and maxZ through level selection (levels[i].elevation – globalOffset.Z).

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

I want a similar functionality like the default Add Box button in Section Analysis but I want to add the min max co-ordinates

您能帮我吗?

推荐答案

在这里〜请参考以下代码片段为查看器计算切面参数:

Here you go ~ Please refer to the following code snippet to calculate cut plane parameters for the viewer:

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 );

这篇关于如何在Forge Viewer中创建节框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 01:13