Autodesk forge viewer zooming to bounding box

徘徊边缘 提交于 2021-02-05 10:49:27

问题


I have a bounding box object as below:

bb = {
  "min": {
    "x": -6.637446403503418,
    "y": -19.579801559448242,
    "z": -0.22575747966766357
  },
  "max": {
    "x": 10.237555503845215,
    "y": 19.15947914123535,
    "z": 9.774243354797363
  }
}

I want to zoom to this bounding box and make camera as centre.


回答1:


You can simply call viewer.navigation.fitBounds( immediate, bounds ) to do this.

  • The first argument, immediate, means that camera position will animate to the new location if immediate is set as false.
  • The second argument, bounds, stands for the bounding box to fit.

Remember to convert your bounding box to THREE.Box3 object.

You can refer here for the API document: https://developer.autodesk.com/en/docs/viewer/v2/reference/javascript/navigation/



来源:https://stackoverflow.com/questions/45282331/autodesk-forge-viewer-zooming-to-bounding-box

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!