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;
}
相关推荐
Jmyd01233 小时前
文物3D数字化的技术选型指南:从WW/T 0115标准到落地工程,一次讲透采集、建档、管理与展示
3d·系统架构·博物馆·数字展厅·博物馆数字化
Martina_03216 小时前
AI生成3D模型一合并网格,材质就串色?用6步检查材质槽、UV与图集重映射
图像处理·人工智能·3d·材质·uv·游戏策划·1024程序员节
鹿野素材屋11 小时前
U3D切换场景时候变黑怎么处理
数码相机·3d
FlightYe19 小时前
视界原理之3D视频(四):裸眼、眼镜和头显
android·linux·c++·3d·ffmpeg·音视频
云飞云共享云桌面1 天前
1台SolidWorks服务器如何承载10个设计并发?
运维·服务器·网络·3d·制造
释厄6231 天前
三角基底律——矩阵3x6 是所有三角形的基底·3D中高就是边
线性代数·3d·矩阵
Solange__1 天前
图片转3D导出GLB、FBX还是OBJ?按5类任务比较材质、动画与可编辑性
人工智能·3d·ai·自然语言处理·编辑器·blender·材质
Jmyd01231 天前
博物馆AR导览数字孪生架构设计:从空间数据到AR应用全链路
3d·系统安全·ar·数字孪生·博物馆·三维数字化
chaoyuanl1 天前
超元力玻璃剧场:裸眼3D、8K高清与悬空栈桥的成熟文旅解决方案
大数据·人工智能·3d·xr·vr
苏州福兰克1 天前
运行裸眼3D显示器对电脑显卡配置有什么要求?
3d·计算机外设·电脑