Cesium 获取 3dtileset的包围盒各顶点坐标

Cesium 获取 3dtileset的包围盒各顶点坐标

js 复制代码
/**
 * 获取 3dtileset的包围盒各顶点坐标, z 方向取高度最低的位置
 * @param {*} tileset
 * @param {*} options
 * @returns
 * @ref https://blog.csdn.net/STANDBYF/article/details/135012273
 * @ref https://community.cesium.com/t/accurate-bounding-box-for-3d-tiles/5890/10
 */
export function getTilesetBoudingBoxPoints(tileset, options = {}) {
  const { center, halfAxes } = tileset._root._boundingVolume._orientedBoundingBox;
  const pointsVec3 = [];

  // 获取三个轴的位置
  const x = new Cartesian3();
  const y = new Cartesian3();
  const z = new Cartesian3();

  Matrix3.getColumn(halfAxes, 0, x);
  Matrix3.getColumn(halfAxes, 1, y);
  Matrix3.getColumn(halfAxes, 2, z);

  const halfXNegative = new Cartesian3();
  const halfXPositive = new Cartesian3();

  Cartesian3.subtract(center, x, halfXNegative)
  Cartesian3.add(center, x, halfXPositive)

  Cartesian3.subtract(halfXNegative, z, halfXNegative)
  Cartesian3.subtract(halfXPositive, z, halfXPositive)

  pointsVec3.push(Cartesian3.add(halfXNegative, y, new Cartesian3()))
  pointsVec3.push(Cartesian3.subtract(halfXNegative, y, new Cartesian3()))

  pointsVec3.push(Cartesian3.subtract(halfXPositive, y, new Cartesian3()))
  pointsVec3.push(Cartesian3.add(halfXPositive, y, new Cartesian3()))

  const pointsLL = [];
  pointsVec3.forEach(item=>{
    const ll = Cartographic.fromCartesian(item);
    pointsLL.push(
      Math.toDegrees(ll.longitude),
      Math.toDegrees(ll.latitude),
    )
  })

  return pointsLL;
}
相关推荐
云空4 小时前
《PyQt6-3D应用开发技术文档》
3d·pyqt
鹧鸪云光伏10 小时前
光伏无人机3D建模:毫秒级精度设计
3d·无人机
杀生丸学AI12 小时前
【三维生成】FlashDreamer:基于扩散模型的单目图像到3D场景
人工智能·3d·大模型·aigc·蒸馏与迁移学习·扩散模型与生成模型
gis分享者1 天前
学习threejs,使用自定义GLSL 着色器,生成漂流的3D能量球
3d·threejs·着色器·glsl·shadermaterial·能量球
m0_743106461 天前
【论文笔记】BlockGaussian:巧妙解决大规模场景重建中的伪影问题
论文阅读·计算机视觉·3d·aigc·几何学
向宇it1 天前
【unity小技巧】在 Unity 中将 2D 精灵添加到 3D 游戏中,并实现阴影投射效果,实现类《八分旅人》《饥荒》等等的2.5D游戏效果
游戏·3d·unity·编辑器·游戏引擎·材质
荔枝味啊~2 天前
相机位姿估计
人工智能·计算机视觉·3d
在下胡三汉2 天前
什么是 3D 文件?
3d
点云登山者3 天前
登山第二十六梯:单目3D检测一切——一只眼看世界
3d·3d检测·检测一切·单目3d检测
xhload3d3 天前
智慧航天运载体系全生命周期监测 | 图扑数字孪生
物联网·3d·智慧城市·html5·webgl·数字孪生·可视化·工业互联网·三维建模·工控·航空航天·火箭升空·智慧航空·智慧航天·火箭发射·火箭回收