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;
}
相关推荐
嘀咕博客1 天前
Stable Virtual Camera:Stability AI等推出的AI模型 ,2D图像轻松转3D视频
人工智能·3d·音视频·ai工具
平行云2 天前
赋能数字孪生:Paraverse平行云实时云渲染平台LarkXR,提供强大的API与SDK用于二次开发和深度集成
3d·unity·ue5·webgl·实时云渲染·云xr
VSORender_Farm2 天前
新手该选哪款软件?3ds Max vs Blender深度对比
3d·渲染·blender·云渲染·设计·建筑·效果图
渊鱼L2 天前
CAD球体密堆积_圆柱体试件3D插件 球体颗粒在圆柱容器内的堆积建模
3d
云飞云共享云桌面2 天前
昆山精密机械公司8个Solidworks共用一台服务器
运维·服务器·网络·3d·自动化·制造
咔咔一顿操作3 天前
【CSS 3D 交互】实现精美翻牌效果:从原理到实战
前端·css·3d·交互·css3
Magnum Lehar3 天前
wpf 3d游戏引擎的PrimitiveMesh.h和ToolsCommon.h
3d·游戏引擎
新启航光学频率梳4 天前
激光频率梳 3D 轮廓测量 -- 平晶干涉法观察高精度平面度
科技·3d·制造
AndrewHZ4 天前
【3D算法技术】blender中,在曲面上如何进行贴图?
算法·3d·blender·贴图·三维建模·三维重建·pcg
新启航光学频率梳4 天前
激光频率梳 3D 轮廓测量 - 油路板的凹槽深度和平面度测量
科技·3d·制造