supermap添加模型和fpf文件回放

389 阅读1分钟

1.添加模型

this.$http.get("。。。。地址rest/realspace/datas.rjson").then(res=>{
  for(var i=0;i<res.data.length;i++){
    const url =  "。。。。地址rest/realspace/datas/" + res.data[i].name + "/config";
    Viewer.scene.addS3MTilesLayerByScp(url, {name: res.data[i].name});
  }
});

2. fpf回放

try {
  var routes = new Cesium.RouteCollection(Viewer.entities);//创建一个路线集合对象
  routes.fromFile("./*****.fpf");//路线集合对象加载飞行文件   (文件在public根目录)
  this.flyManager = new Cesium.FlyManager({
    scene: Viewer.scene,
    routes: routes
  });
  this.flyManager.stopArrived.addEventListener(function (routeStop) {
    routeStop.waitTime = 1; // 在每个站点处停留1s
  });
  //飞行路线就绪
  this.flyManager.readyPromise.then(function () {
    var currentRoute = this.flyManager.currentRoute;
    currentRoute.isLineVisible = true;
    currentRoute.isStopVisible = true;
    //生成飞行文件中的所有站点列表
    var allStops = this.flyManager.getAllRouteStops();
    console.log(allStops);
  });
}catch (e){
   console.log(e);
}

//开始运行要设置延时,否则不执行
if (this.flyManager) {
  setTimeout(function(){
    console.log("开始运行");
    this.flyManager.play();
  },1000);
}