由于3D建模的数据可能很大,初步建议在数据加载的时候加上提示框,告知用户“需要等待”,但cesium加载模型的方法类似于require,无法做到通过回调来控制提示信息的显示于消失,写法如下

 

      this.gltfEntity = this.viewer.entities.add({
              position: Cesium.Cartesian3.fromDegrees(
                114.307031,
                30.555222,
                0
              ),
              model: {
                uri: "/static/modeldata/output/wuhan_new.gltf",
                minimumPixelSize: 1,
                scale: 1
              }
            });
      this.viewer.zoomTo(this.gltfEntity)

 

但仔细查看cesium的API,发现zoomTo方法返回的是promise

 

cesium加载大容量的3D模型文件

 

所以完全可以使用promise.then的成功回调来做一些操作,比如影藏掉提示框等,下面只是简单的打印时间信息:

      let startTime = new Date().getTime();
            let endTime;
            this.gltfEntity = this.viewer.entities.add({
              position: Cesium.Cartesian3.fromDegrees(
                114.307031,
                30.555222,
                0
              ),
              model: {
                uri: "/static/modeldata/output/wuhan_new.gltf",
                minimumPixelSize: 1,
                scale: 1
              }
            });
            this.viewer.zoomTo(this.gltfEntity).then(function() {
              endTime = new Date().getTime();
              console.log('加载完毕,共耗时', endTime - startTime)
            });

  

网上还有3DTiles方法,待后续了解

相关文章:

  • 2021-07-25
  • 2021-10-21
  • 2022-12-23
  • 2022-12-23
  • 2021-05-29
  • 2021-07-13
  • 2022-12-23
猜你喜欢
  • 2021-12-16
  • 2021-09-05
  • 2021-11-08
  • 2022-12-23
  • 2021-11-26
  • 2021-12-25
  • 2021-11-24
相关资源
相似解决方案