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);

效果图:

相关推荐
冷冷的菜哥1 天前
react多文件分片上传——支持拖拽与进度展示
前端·react.js·typescript·多文件上传·分片上传
玄魂1 天前
VChart 官网上线 智能助手与分享功能
前端·llm·数据可视化
Lucky GGBond1 天前
Vue + Spring Boot 实现 Excel 导出实例
vue.js·spring boot·excel
wyzqhhhh1 天前
插槽vue/react
javascript·vue.js·react.js
许___1 天前
Vue使用原生方式把视频当作背景
前端·javascript·vue.js
萌萌哒草头将军1 天前
尤雨溪强烈推荐的这个库你一定要知道 ⚡️⚡️⚡️
前端·vue.js·vite
2401_878454531 天前
Vue 核心特性详解:计算属性、监听属性与事件交互实战指南
前端·vue.js·交互
GISer_Jing1 天前
Next.js数据获取演进史
java·开发语言·javascript
1024小神1 天前
uniapp+vue3+vite+ts+xr-frame实现ar+vr渲染踩坑记
前端
测试界清流1 天前
基于pytest的接口测试
前端·servlet