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;
}
相关推荐
全栈小58 小时前
【AI】从0开始玩转混元3D⼤模型,如何让一张静态实物图片一键转为3D实物图,大模型都表示服了,超级简单易上手,快来试试!
人工智能·3d·腾讯·混元达3d大模型·腾讯混元3d大模型
渊鱼L10 小时前
CAD多面体密堆积3D插件
3d
时间之里15 小时前
【图像处理3D】:焦距的像素单位标定
图像处理·数码相机·3d
JoannaJuanCV17 小时前
BEV和OCC学习-5:数据预处理流程
深度学习·目标检测·3d·occ·bev
虾球xz1 天前
CppCon 2015 学习:3D Face Tracking and Reconstruction using Modern C++
开发语言·c++·学习·3d
JoannaJuanCV1 天前
BEV和OCC学习-3:mmdet3d 坐标系
3d·occ·bev
lingling0091 天前
3D视觉重构工业智造:解码迁移科技如何用“硬核之眼“重塑生产节拍
科技·3d·重构
Shan12051 天前
3Ds Max 2026安装包+教程网盘下载与安装教程指南
数学建模·3d
时间之里1 天前
【图像处理3D】:世界坐标系
图像处理·数码相机·3d
渲吧云渲染1 天前
3ds Max 渲染技术突破:一键解锁照片级真实感!
3d