【问题标题】:How can I create section box in forge viewer如何在伪造查看器中创建截面框
【发布时间】:2020-04-10 15:14:11
【问题描述】:

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

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

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

【问题讨论】:

    标签: autodesk-forge forge


    【解决方案1】:

    给你~请参考以下代码sn-p为查看器计算切面参数:

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

    【讨论】:

      猜你喜欢
      • 2021-09-29
      • 2021-09-12
      • 2021-04-23
      • 2018-06-28
      • 2018-10-22
      • 2019-05-15
      • 2021-12-31
      • 2019-11-06
      • 2021-09-06
      相关资源
      最近更新 更多