我想在伪造查看器中构建一个节框。我通过区域标记获得了minx,maxX,minY,maxY。另外,我通过级别选择(级别[i] .elevation – globalOffset.Z)获得了minZ和maxZ。
我想要类似的功能,例如“剖面分析”中的默认“添加框”按钮,但我想添加最小最大坐标
您能帮我吗?
答案 0 :(得分:0)
在这里〜请参考以下代码片段为查看器计算切面参数:
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 );