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;
}
相关推荐
摩尔线程2 小时前
摩尔线程LiteGS入选ECCV 2026 高质量3DGS训练迎来效率突破
3d·摩尔线程
LateFrames5 小时前
CT(DCM)外轮廓实时识别 → 逐层拼3D → 导出STL到Blender
图像处理·3d·可视化·医疗·ct重建
云飞云共享云桌面1 天前
广东精密机械设备工厂8-10人共享一台SolidWorks设计服务器
运维·服务器·3d·自动化·汽车·制造
AI视觉网奇1 天前
bambu-studio-ai 踩坑实战笔记
人工智能·3d
MagicUrban1 天前
经纬管网MagicPipe3D V3.8.1发布,参数化自主可控三维管线建模工具
3d·gis·智慧城市·bim·地下管网
LONGZETECH1 天前
传统实训 vs 仿真实训:从技术架构拆解新能源汽车教学的范式之变
c语言·3d·unity·架构·汽车
科技之门2 天前
AI3D从建模到贴图、绑骨和动画的完整流程怎么做?V2Fun完整工作流指南
人工智能·3d·贴图
dalong102 天前
WPF:3D甜甜圈
3d·c#·wpf·甜甜圈
Hello_Damon_Nikola3 天前
LIS3DH从入门到精通_三轴加速度计实战指南
单片机·嵌入式硬件·3d
DFT计算杂谈4 天前
3d-Kagome Kondo体系
3d