vue结合Cesium加载gltf模型

Cesium支持什么格式?

Cesium支持的格式包括:3D模型格式(如COLLADA、gITF、OBJ)、影像格式(如JPEG、PNG、GeoTIFF)、地形格式(如STL、Heightmap)、矢量数据格式(如GeoJSON、KMZ)、时间动态数据格式(如CZML),以及其他各种数据格式。此外,Cesium还通过插件支持其他特定格式。

Cesium加载Gltf模型

javascript 复制代码
  const position = Cesium.Cartesian3.fromDegrees(
    91.18062333588327,
    29.64956,
    3640.0
  );
  viewer.scene.globe.depthTestAgainstTerrain = true;
  const heading = Cesium.Math.toRadians(90); //135度转弧度
  const pitch = Cesium.Math.toRadians(0);
  const roll = 0;
  const hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);
  const orientation = Cesium.Transforms.headingPitchRollQuaternion(
    position,
    hpr
  );
  const entity = viewer.entities.add({
    position: position,
    orientation: orientation,
    model: {
      uri: "./assets/cesium_gltf/GLTF/M_BWG.gltf", //注意entitits.add方式加载gltf文件时,这里是uri,不是url,并且这种方式只能加载.glb格式的文件
      scale: 1.0, //缩放比例
      minimumPixelSize: 128, //最小像素大小,可以避免太小看不见
      maximumScale: 20000, //模型的最大比例尺大小。minimumPixelSize的上限
      incrementallyLoadTextures: true, //加载模型后纹理是否可以继续流入
      runAnimations: true, //是否启动模型中制定的gltf动画
      clampAnimations: true, //制定gltf动画是否在没有关键帧的持续时间内保持最后一个姿势
      // shadows: Cesium.ShadowMode.ENABLED,
      heightReference: Cesium.HeightReference.NONE,
    },
  });
  viewer.trackedEntity = entity; // 聚焦模型
  viewer.flyTo(entity);

效果图:

相关推荐
SailingCoder5 分钟前
【 从“打补丁“到“换思路“ 】一次企业级 AI Agent 的架构拐点
大数据·前端·人工智能·面试·架构·agent
~央千澈~24 分钟前
抖音弹幕游戏开发之第12集:添加冷却时间机制·优雅草云桧·卓伊凡
java·服务器·前端
CappuccinoRose38 分钟前
CSS 语法学习文档(十三)
前端·css·学习·postcss·模块化·预处理器
OpenTiny社区38 分钟前
Angular Module→Standalone 架构进化解析
前端·架构·angular.js
哆啦A梦15881 小时前
Vue3魔法手册 作者 张天禹 06_监控
前端·vue.js·typescript
恋猫de小郭2 小时前
你知道不,你现在给 AI 用的 Agent Skills 可能毫无作用,甚至还拖后腿?
前端·人工智能·ai编程
用户600071819102 小时前
【翻译】用生成器实现可续充队列
前端
少云清2 小时前
【UI自动化测试】4_web自动化测试 _元素定位(重点)
前端·web前端自动化
若丶相见2 小时前
腾讯云完整部署方案:CODING + CI/CD + Docker + Nginx + K8s 扩展
前端·后端
比奇堡鱼贩3 小时前
python第五次作业
开发语言·前端·python