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

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

在这里插入图片描述


/**
 * 获取 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. PCL 计算最小包围OBB及其顶点坐标

    2024-03-16 11:28:02       37 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-03-16 11:28:02       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-03-16 11:28:02       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-03-16 11:28:02       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-03-16 11:28:02       18 阅读

热门阅读

  1. ISCE2StaMPS全流程

    2024-03-16 11:28:02       14 阅读
  2. AutoMapper12.0.1 扩展方法封装

    2024-03-16 11:28:02       20 阅读
  3. RabbitMq多数据源配置

    2024-03-16 11:28:02       18 阅读
  4. 开发K8S Operator

    2024-03-16 11:28:02       18 阅读
  5. LeetCode 174.地下城游戏 Python题解

    2024-03-16 11:28:02       20 阅读
  6. 探索机器学习:智能时代的魔法

    2024-03-16 11:28:02       22 阅读
  7. Github 2024-03-13 C开源项目日报 Top10

    2024-03-16 11:28:02       17 阅读
  8. Python 算法交易实验68 回测对象重构

    2024-03-16 11:28:02       23 阅读
  9. HTML前置基础

    2024-03-16 11:28:02       16 阅读