Autodesk forge 查看器缩放到边界框 [英] Autodesk forge viewer zooming to bounding box

查看:31
本文介绍了Autodesk forge 查看器缩放到边界框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个如下所示的边界框对象:

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.

推荐答案

你可以简单地调用viewer.navigation.fitBounds(immediate, bounds)来做到这一点.

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

  • 第一个参数 immediate 表示相机位置将如果将 immediate 设置为 false,则动画到新位置.
  • 第二个参数 bounds 代表要适合的边界框.
  • 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.

记得将你的边界框转换为 THREE.Box3 对象.

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

您可以参考此处的 API 文档:https://developer.autodesk.com/en/docs/viewer/v2/reference/javascript/navigation/

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

这篇关于Autodesk forge 查看器缩放到边界框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆