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;
}
相关推荐
IT古董3 小时前
【第五章:计算机视觉-计算机视觉在工业制造领域中的应用】1.工业缺陷分割-(1)工业品缺陷风格基础知识:割任务定义、数据集介绍
计算机视觉·3d·自动驾驶
wenjie学长4 小时前
[3dmax自研插件]——3ds Max 智能材质检查器
3d·3dmax插件·材质·模型材质贴图检查·拖拽使用
xhload3d14 小时前
智慧钢厂高炉冶炼仿真分析 | 图扑数字孪生
3d·智慧城市·html5·webgl·数字孪生·可视化·热力图·智慧工厂·工业互联网·工业组态·高炉炼铁·数字工厂·高炉炉体·智慧高炉·高炉
lrh30251 天前
Custom SRP 12 - HDR
3d·unity·srp·render pipeline
开发游戏的老王1 天前
虚幻引擎虚拟制片入门教程 之 3D渲染基础知识:模型、材质、贴图、UV等
3d·虚幻·材质·模型·着色器·uv
Kingsdesigner2 天前
从AI画稿到3D虚拟时装:Illustrator与Substance 3D的服装设计工作流
人工智能·3d·illustrator·substance 3d·sampler·stager·数字时尚
程序猿阿伟2 天前
《3D动作游戏受击反馈:从模板化硬直到沉浸式打击感的开发拆解》
前端·网络·3d
Bar_artist2 天前
AI 颠覆室内设计:SpatialGen 实现 “一句话生成 3D 房间”
人工智能·3d
CG_MAGIC2 天前
3D 云渲染:不止于高效,更是创作的革新之力
3d·3dmax·渲云渲染
2501_933360722 天前
覆盖动画 / 工业 / 科研!Rhino 7:专业 3D 建模的全能解决方案,新手也能上手
数学建模·3d