【问题标题】:Restore sectionBox in forge viewer在伪造查看器中恢复 sectionBox
【发布时间】:2021-12-31 22:02:56
【问题描述】:

How to get bounding box info of intersection box in forge viewer? 我想恢复要恢复的部分扩展框边界值。对于下面的方法,我得到框值。 getSelectionbox

现在我想将其恢复到查看器/将保存的值设置为查看器,因为有什么方法可用吗?

我使用了 setSectionBox(box),但它不适合我。

谢谢

这里是代码示例:

viewer.restoreState(currentState, null, false);

                viewer.hide(Object.values(val.hiddenNodes));
                if(Object.values(val.isolateNodes).length > 0){                     
                    viewer.isolate(Object.values(val.isolateNodes));
                }
                if(val.cutPlanes.length !== 0){
                    viewer.loadExtension("Autodesk.Section").then(function(sectionTool){
                        sectionTool.activate(val.sectionStyle);
                        
                        
                        var sectionTool = markupsExt.tool.getSectionBoxValues();

                        const sectionbboxmin = new THREE.Vector3(val.sectionBox[0], val.sectionBox[1], val.sectionBox[2]);      
                        const sectionbboxmax = new THREE.Vector3(val.sectionBox[3], val.sectionBox[4], val.sectionBox[5]);
                        const box = new THREE.Box3(sectionbboxmin,sectionbboxmax);
                        box.transform = val.sectionBoxTransform;
                        sectionTool.setSectionBox(box);
                    });
                }

【问题讨论】:

    标签: autodesk-forge forge


    【解决方案1】:

    我刚刚尝试使用以下代码 sn-p 将自定义截面框应用于 Forge Viewer 中的模型:

    let box = new THREE.Box3(new THREE.Vector3(-100,-100,-100), new THREE.Vector3(100,100,100));
    let sectionExt = viewer.getExtension('Autodesk.Section');
    sectionExt.setSectionBox(box);
    

    结果是这样的:

    所以这似乎工作正常。您能否提供有关您如何尝试设置部分框的更多详细信息?

    编辑:

    您可以通过以下方式从剖切面列表中恢复剖面框(例如您可以从 viewer.getState() 获得的剖面框):

    function restoreSectionBox(viewer, cutplanes) {
        let box = new THREE.Box3();
        for (const cutplane of cutplanes) {
            const normal = new THREE.Vector3(cutplane[0], cutplane[1], cutplane[2]);
            const offset = cutplane[3];
            const pointOnPlane = normal.negate().multiplyScalar(offset);
            box.expandByPoint(pointOnPlane);
        }
        const sectionExt = viewer.getExtension('Autodesk.Section');
        sectionExt.setSectionBox(box);
    }
    
    // ...
    
    let cutplanes = [
        [1, 0, 0, 40],
        [0, 1, 0, 50],
        [0, 0, 1, 30],
        [-1, 0, 0, 60],
        [0, -1, 0, 20],
        [0, 0, -1, 70]
    ];
    restoreSectionBox(viewer, cutplanes);
    

    【讨论】:

    • 我应该做的是 loadMode -> 选择元素 -> 右键单击​​ -> 选择为部分框。现在从我得到的模型中获取状态(视口,切面)并存储截面框值。然后使用 restoreState(storeViewport) 和 setSectionBox 恢复该状态。但我得到的输出是边界框,但大小不同,切割平面也不同。
    • 在这种情况下,您如何从剖切面计算边界框可能存在一些问题。您能否在问题中也包含该代码?
    • 我已经添加了我的代码 sn-p 用于恢复状态和恢复部分框。
    • 我不确定您从哪里获取 val.cutPlanesval.sectionStyleval.sectionBox 值。但是我已经用一个代码更新了我的答案,该代码可以从可以使用viewer.getState() 获得的剖切面列表中恢复剖面框。
    • val.cutPlanes, val.sectionStyle, val.sectionBox 这个值存储在db中。
    猜你喜欢
    • 2018-06-28
    • 2018-10-22
    • 2019-05-15
    • 2021-11-07
    • 2021-11-15
    • 2020-11-09
    • 2018-08-22
    • 2019-11-28
    • 2019-08-30
    相关资源
    最近更新 更多