【问题标题】:Forge Viewer - getting wrong x y z coordinates while using instranceTree of viewerForge Viewer - 在使用查看器的实例树时获取错误的 x y z 坐标
【发布时间】:2020-06-07 15:22:04
【问题描述】:

当用户单击 dbId 时,我正在绘制一个标签,因为我使用下面的函数来查找坐标,但它给了我一些错误的坐标而不是正确的坐标。例如,要让 x 坐标接近 400,我只能得到 12.85。

function getObjPosition(dbId) {
    const model = viewer.model;
    const instanceTree = model.getData().instanceTree;
    const fragList = model.getFragmentList();

    let bounds = new THREE.Box3();

    instanceTree.enumNodeFragments( dbId, ( fragId ) => {
        let box = new THREE.Box3();
        fragList.getWorldBounds( fragId, box );
        bounds.union( box );
    }, true );

    const position = bounds.center();
    return position;
}

【问题讨论】:

    标签: autodesk-forge autodesk-viewer autodesk-model-derivative autodesk-data-management


    【解决方案1】:

    我好像找到了解决办法。

    最后我们要使用worldToClient来获取对应的坐标。但我想知道为什么这些东西没有记录在适当的地方来解释像我这样的新手探索这个领域?

    position =viewer.worldToClient(new THREE.Vector3(position.x,position.y,position.z))

    【讨论】:

      【解决方案2】:

      尝试通过在加载选项中设置以下内容来取消全局偏移:

      const options={
         globalOffset:{x:0,y:0,z:0}
         //...
      }
      viewer.loadModel/start(svf, options)
      viewer.loadDocumentNode(doc, geo, options)
      

      【讨论】:

      • 不,它不起作用。现在 x 坐标变为 90,之前它只有 12,但是 dbId 的实际位置对于 x 坐标大约是 400。尝试了其他一些 dbId 但同样的问题。
      猜你喜欢
      • 2019-02-17
      • 2021-12-24
      • 2018-06-16
      • 2020-10-04
      • 2020-09-19
      • 1970-01-01
      • 2021-05-31
      • 1970-01-01
      • 2014-12-02
      相关资源
      最近更新 更多