vue结合Cesium加载gltf模型

Cesium支持什么格式?

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

Cesium加载Gltf模型

  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. cesium gltf并实时改变位置 CallbackProperty方式

    2024-01-08 12:42:03       31 阅读
  2. Three.js的THREE.LOD如何gltf模型

    2024-01-08 12:42:03       59 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-08 12:42:03       91 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-08 12:42:03       97 阅读
  3. 在Django里面运行非项目文件

    2024-01-08 12:42:03       78 阅读
  4. Python语言-面向对象

    2024-01-08 12:42:03       88 阅读

热门阅读

  1. mysql 高阶查询

    2024-01-08 12:42:03       58 阅读
  2. C语言-蓝桥杯2022年第十三届省赛真题-质因数个数

    2024-01-08 12:42:03       64 阅读
  3. 数据结构1

    2024-01-08 12:42:03       43 阅读
  4. 安全防御之安全审计技术

    2024-01-08 12:42:03       51 阅读