function newSite(x,y,z,h,p,time,ids){ if(x!=null&&y!=null&&z!=null&&h!=null&&p!=null&&time!=null&&ids!=null){ this.position_x=x; this.position_y=y; this.position_z=z; this.pitch=p; this.heading=h; this.time=time; this.ids=ids; }else{ return false; } } function Fly_NZC(viewer){ this.viewer=viewer; this.scene=viewer.scene; this.entities=viewer.entities; //全部飞行站点数组 this.allSites=[]; var that =this; this.checkIds=function(ids){ for(var i=0;i180){ if(tem>=0){ tem = 360 - tem; } else{ tem = 360 + tem; } h = Cesium.Math.toRadians(tem); } //that.b=that.allSites[l].time*20 that.setInterval_fly=setInterval(that.setcamera,20); }else{ that.play_bool=true; that.l=0; that.scene.screenSpaceCameraController.enableRotate = true; that.scene.screenSpaceCameraController.enableTranslate = true; that.scene.screenSpaceCameraController.enableZoom = true; that.scene.screenSpaceCameraController.enableTilt = true; that.scene.screenSpaceCameraController.enableLook = true; } }; this.flyManager={ //用于储存暂停时的位置 Site_pause:{}, play:function(){ //如果之前点的时停止重新开始飞行 if(that.allSites.length>1){ that.scene.screenSpaceCameraController.enableRotate = false; that.scene.screenSpaceCameraController.enableTranslate = false; that.scene.screenSpaceCameraController.enableZoom = false; that.scene.screenSpaceCameraController.enableTilt = false; that.scene.screenSpaceCameraController.enableLook = false; if(that.play_bool){ //设置初始点 that.scene.camera.setView({ destination : new Cesium.Cartesian3(that.allSites[that.l].position_x,that.allSites[that.l].position_y,that.allSites[that.l].position_z), orientation : { heading : that.allSites[that.l].heading, pitch : that.allSites[that.l].pitch, roll : that.allSites[that.l].roll } }); that.Interval(); }else{ //如果之前是暂停,继续飞行 that.scene.camera.setView({ //将经度、纬度、高度的坐标转换为笛卡尔坐标 destination : new Cesium.Cartesian3(this.Site_pause.position_x,this.Site_pause.position_y,this.Site_pause.position_z), orientation : { heading : this.Site_pause.heading, pitch : this.Site_pause.pitch, roll : this.Site_pause.roll } }); that.Interval(); } } }, stop:function(){ if( that.setInterval_fly!=null){ clearInterval(that.setInterval_fly); that.setInterval_fly=null; } that.l=0; that.play_bool=true; that.scene.screenSpaceCameraController.enableRotate = true; that.scene.screenSpaceCameraController.enableTranslate = true; that.scene.screenSpaceCameraController.enableZoom = true; that.scene.screenSpaceCameraController.enableTilt = true; that.scene.screenSpaceCameraController.enableLook = true; }, pause:function(){ if( that.setInterval_fly!=null){ clearInterval(that.setInterval_fly); that.setInterval_fly=null; that.play_bool=false; } //获取暂停时的camera数据 var position=that.scene.camera.position; this.Site_pause.position_x=position.x; this.Site_pause.position_y=position.y; this.Site_pause.position_z=position.z; this.Site_pause.heading=that.scene.camera.heading; this.Site_pause.pitch=that.scene.camera.pitch; this.Site_pause.roll=that.scene.camera.roll; that.scene.screenSpaceCameraController.enableRotate = true; that.scene.screenSpaceCameraController.enableTranslate = true; that.scene.screenSpaceCameraController.enableZoom = true; that.scene.screenSpaceCameraController.enableTilt = true; that.scene.screenSpaceCameraController.enableLook = true; }, SetStartSite:function(ids){ var bool=that.checkIds(ids); if(bool){ that.l=bool; return true; }else{ return false; } }, viewToSite:function(site){ that.scene.camera.setView({ destination : new Cesium.Cartesian3(site.position_x,site.position_y,site.position_z), orientation : { heading : site.heading, pitch : site.pitch, roll : site.roll } }); } }; }