首页 / 浏览问题 / 三维GIS / 问题详情
cesium 沿线飞行总是拉高
22EXP 2023年03月09日
fpf文件

<?xml version="1.0" encoding="UTF-8"?>

<SceneRoute xmlns="http://www.supermap.com.cn/ugc60">

<route name="飞行路线_3" speed="100" lineType="0" showroutestop="False" showrouteline="False" altitudefree="False" headingfree="False" tiltfree="False" flycircle="False" alongline="False">

<style>

<geostyle3d>

<linecolor>RGBA(147,112,219,255)</linecolor>

<linewidth>2</linewidth>

<altitudeMode>Absolute</altitudeMode>

<bottomAltitude>0.00</bottomAltitude>

</geostyle3d>

</style>

<routestop name="Stop1" speed="100" excluded="False" viewType="camera">

<camera>

<longitude>120.93590862289096</longitude>

<latitude>31.406270576458731</latitude>

<altitude>16.838963963091373</altitude>

<heading>272.55028477405881</heading>

<tilt>83.099633979918195</tilt>

<altitudeMode>Absolute</altitudeMode>

</camera>

<style>

<geostyle3d>

<icon/>

<markersize>4.8</markersize>

<markericonscale>1</markericonscale>

<markercolor>RGBA(255,255,255,255)</markercolor>

</geostyle3d>

</style>

<setting>

<turnTime>1.5</turnTime>

<turnSlowly>False</turnSlowly>

<stopPlayMode>StopPause</stopPlayMode>

<autoPlay>False</autoPlay>

<pauseTime>0</pauseTime>

<angularSpeed>1</angularSpeed>

</setting>

</routestop>

<routestop name="Stop2" speed="100" excluded="False" viewType="camera">

<camera>

<longitude>120.93552013691006</longitude>

<latitude>31.406268349868096</latitude>

<altitude>16.838963992893696</altitude>

<heading>272.55008290874576</heading>

<tilt>83.099633979917357</tilt>

<altitudeMode>Absolute</altitudeMode>

</camera>

<style>

<geostyle3d>

<icon/>

<markersize>4.8</markersize>

<markericonscale>1</markericonscale>

<markercolor>RGBA(255,255,255,255)</markercolor>

</geostyle3d>

</style>

<setting>

<turnTime>1.5</turnTime>

<turnSlowly>False</turnSlowly>

<stopPlayMode>StopPause</stopPlayMode>

<autoPlay>False</autoPlay>

<pauseTime>0</pauseTime>

<angularSpeed>1</angularSpeed>

</setting>

</routestop>

<routestop name="Stop3" speed="100" excluded="False" viewType="camera">

<camera>

<longitude>120.93523013170353</longitude>

<latitude>31.406277905510429</latitude>

<altitude>18.16577654518187</altitude>

<heading>272.54993184245245</heading>

<tilt>83.099556286261745</tilt>

<altitudeMode>Absolute</altitudeMode>

</camera>

<style>

<geostyle3d>

<icon/>

<markersize>4.8</markersize>

<markericonscale>1</markericonscale>

<markercolor>RGBA(255,255,255,255)</markercolor>

</geostyle3d>

</style>

<setting>

<turnTime>1.5</turnTime>

<turnSlowly>False</turnSlowly>

<stopPlayMode>StopPause</stopPlayMode>

<autoPlay>False</autoPlay>

<pauseTime>0</pauseTime>

<angularSpeed>1</angularSpeed>

</setting>

</routestop>

<routestop name="Stop4" speed="100" excluded="False" viewType="camera">

<camera>

<longitude>120.93458018347204</longitude>

<latitude>31.406276451421494</latitude>

<altitude>19.401077139191329</altitude>

<heading>272.54959287071785</heading>

<tilt>83.099665436223205</tilt>

<altitudeMode>Absolute</altitudeMode>

</camera>

<style>

<geostyle3d>

<icon/>

<markersize>4.8</markersize>

<markericonscale>1</markericonscale>

<markercolor>RGBA(255,255,255,255)</markercolor>

</geostyle3d>

</style>

<setting>

<turnTime>1.5</turnTime>

<turnSlowly>False</turnSlowly>

<stopPlayMode>StopPause</stopPlayMode>

<autoPlay>False</autoPlay>

<pauseTime>0</pauseTime>

<angularSpeed>1</angularSpeed>

</setting>

</routestop>

</route>

</SceneRoute>

//////////////////

viewList: [

        {

          x: 118.3746877401,

          y: 35.1966543876,

          z: 58.3533109673,

          heading: 0.5100976948,

          pitch: -14.6369198109,

          roll: 360,

          distance: 0,

          speed: 20,

        },

        // {

        //   x: 118.3794271711,

        //   y: 35.1733488699,

        //   z: 58.3533109673,

        //   heading: 0.5128288878,

        //   pitch: -14.6379226966,

        //   roll: 360,

        //   distance: 0,

        //   speed: 20,

        // },

        {

          x: 118.3639906116,

          y: 35.1587022071,

          z: 59.5288595557,

          heading: 0.5039381226,

          pitch: -14.6399143583,

          roll: 360,

          distance: 0,

          speed: 20,

        },

        // {

        //   x: 118.3764203566,

        //   y: 35.1553972205,

        //   z: 58.3533109673,

        //   heading: 0.5110958583,

        //   pitch: -14.6415755994,

        //   roll: 360,

        //   distance: 0,

        //   speed: 20,

        // },

        // {

        //   x: 118.3755386454,

        //   y: 35.1880215975,

        //   z: 82.3654611622,

        //   heading: 0.5105883107,

        //   pitch: -14.6434841862,

        //   roll: 360,

        //   distance: 0,

        //   speed: 20,

        // },

        // {

        //   x: 118.3737649464,

        //   y: 35.1891594725,

        //   z: 85.8656338365,

        //   heading: 0.509566151,

        //   pitch: -14.6462126335,

        //   roll: 360,

        //   distance: 0,

        //   speed: 20,

        // },

        {

          x: 118.3763845342,

          y: 35.1913796006,

          z: 58.3533109673,

          heading: 0.511075958,

          pitch: -14.6542157513,

          roll: 360,

          distance: 0,

          speed: 20,

        },

      ],

 

 var routes = new Cesium.RouteCollection(window.lineanalyse.entities);

      //添加fpf飞行文件,fpf由SuperMap iDesktop生成

      var fpfUrl = "../../../static/Assets/fly.fpf";

      routes.fromFile(fpfUrl);

      //初始化飞行管理

      var scene = window.lineanalyse.scene;

      var flyManager = new Cesium.FlyManager({ scene: scene, routes: routes });

      flyManager.stopArrived.addEventListener((routeStop) => {

        routeStop.waitTime = 1; //修改站点的停留时间

      });

      flyManager.readyPromise.then(() => {

        var route = flyManager.currentRoute;

        flyManager.currentIndex = 1; //飞行路线可以添加多个route,设置索引来加载不同的路线

        for (var k = 0; k < this.viewList.length; k++) {

          var position =  Cesium.Cartesian3.fromDegrees(

            this.viewList[k].x,

            this.viewList[k].y,

            this.viewList[k].z

          );

          var routeStop = new Cesium.RouteStop({

            point: position,

            heading: scene.camera.heading,

            tilt: Cesium.Math.toRadians(this.viewList[k].pitch),

            stopName: "站" + k,

            speed: this.viewList[k].speed,

            waitTime: 1,

          });

          route.addStop(routeStop);

        }

        flyManager.play();

      });

这是所有的代码

1个回答

您好,1、"../../../static/Assets/fly.fpf" 请问飞行文件可以发我一份吗?

2、此处获取了飞行路线route,如果加站点,可以使用flyManager .viewToStop()。

1,865EXP 2023年03月09日
<?xml version="1.0" encoding="UTF-8"?>

<SceneRoute xmlns="http://www.supermap.com.cn/ugc60">

<route name="飞行路线_3" speed="100" lineType="0" showroutestop="False" showrouteline="False" altitudefree="False" headingfree="False" tiltfree="False" flycircle="False" alongline="False">

<style>

<geostyle3d>

<linecolor>RGBA(147,112,219,255)</linecolor>

<linewidth>2</linewidth>

<altitudeMode>Absolute</altitudeMode>

<bottomAltitude>0.00</bottomAltitude>

</geostyle3d>

</style>

<routestop name="Stop1" speed="100" excluded="False" viewType="camera">

<camera>

<longitude>120.93590862289096</longitude>

<latitude>31.406270576458731</latitude>

<altitude>16.838963963091373</altitude>

<heading>272.55028477405881</heading>

<tilt>83.099633979918195</tilt>

<altitudeMode>Absolute</altitudeMode>

</camera>

<style>

<geostyle3d>

<icon/>

<markersize>4.8</markersize>

<markericonscale>1</markericonscale>

<markercolor>RGBA(255,255,255,255)</markercolor>

</geostyle3d>

</style>

<setting>

<turnTime>1.5</turnTime>

<turnSlowly>False</turnSlowly>

<stopPlayMode>StopPause</stopPlayMode>

<autoPlay>False</autoPlay>

<pauseTime>0</pauseTime>

<angularSpeed>1</angularSpeed>

</setting>

</routestop>

<routestop name="Stop2" speed="100" excluded="False" viewType="camera">

<camera>

<longitude>120.93552013691006</longitude>

<latitude>31.406268349868096</latitude>

<altitude>16.838963992893696</altitude>

<heading>272.55008290874576</heading>

<tilt>83.099633979917357</tilt>

<altitudeMode>Absolute</altitudeMode>

</camera>

<style>

<geostyle3d>

<icon/>

<markersize>4.8</markersize>

<markericonscale>1</markericonscale>

<markercolor>RGBA(255,255,255,255)</markercolor>

</geostyle3d>

</style>

<setting>

<turnTime>1.5</turnTime>

<turnSlowly>False</turnSlowly>

<stopPlayMode>StopPause</stopPlayMode>

<autoPlay>False</autoPlay>

<pauseTime>0</pauseTime>

<angularSpeed>1</angularSpeed>

</setting>

</routestop>

<routestop name="Stop3" speed="100" excluded="False" viewType="camera">

<camera>

<longitude>120.93523013170353</longitude>

<latitude>31.406277905510429</latitude>

<altitude>18.16577654518187</altitude>

<heading>272.54993184245245</heading>

<tilt>83.099556286261745</tilt>

<altitudeMode>Absolute</altitudeMode>

</camera>

<style>

<geostyle3d>

<icon/>

<markersize>4.8</markersize>

<markericonscale>1</markericonscale>

<markercolor>RGBA(255,255,255,255)</markercolor>

</geostyle3d>

</style>

<setting>

<turnTime>1.5</turnTime>

<turnSlowly>False</turnSlowly>

<stopPlayMode>StopPause</stopPlayMode>

<autoPlay>False</autoPlay>

<pauseTime>0</pauseTime>

<angularSpeed>1</angularSpeed>

</setting>

</routestop>

<routestop name="Stop4" speed="100" excluded="False" viewType="camera">

<camera>

<longitude>120.93458018347204</longitude>

<latitude>31.406276451421494</latitude>

<altitude>19.401077139191329</altitude>

<heading>272.54959287071785</heading>

<tilt>83.099665436223205</tilt>

<altitudeMode>Absolute</altitudeMode>

</camera>

<style>

<geostyle3d>

<icon/>

<markersize>4.8</markersize>

<markericonscale>1</markericonscale>

<markercolor>RGBA(255,255,255,255)</markercolor>

</geostyle3d>

</style>

<setting>

<turnTime>1.5</turnTime>

<turnSlowly>False</turnSlowly>

<stopPlayMode>StopPause</stopPlayMode>

<autoPlay>False</autoPlay>

<pauseTime>0</pauseTime>

<angularSpeed>1</angularSpeed>

</setting>

</routestop>

</route>

</SceneRoute>

你看看
飞行不是很明显

1、沿线飞行相机视线拉高是因为你设置的飞行站点heading、pitch不是正确的数值,以及你的原始飞行路线的站点和viewList数组中的站点位置相差也较大。

2、根据提供的代码来看,您是想在原来飞行路线上加上viewList中新的飞行站点是吧,我这边测试了,viewList飞行站点如果设置的的heading、pitch是角度值,实例 RouteStop()的时候,heading、pitch需要通过Cesium.Math.toRadians()转换,如果在viewList数组中本身已经是转换后,则不需要。

let viewList = [

    {

      x: 120.83458018347204,

      y: 31.406276451421494,

      z: 200.401077139191329,

      heading: 272.54959287071785,

      pitch: -83.099665436223205,

      roll: 360,

      distance: 0,

      speed: 20,

    },

    {

      x: 120.73458018347204,

      y: 31.406276451421494,

      z: 300.401077139191329,

      heading: 272.54959287071785,

      pitch: -83.099665436223205,

      roll: 360,

      distance: 0,

      speed: 20,

    }];

 var routeStop = new Cesium.RouteStop({

        point: position,

        heading: 4.756887770564091,//Cesium.Math.toRadians(viewList[k].heading),

        tilt:-0.12043410664317929,//Cesium.Math.toRadians(viewList[k].pitch),

        stopName: "站" + k,

        speed:viewList[k].speed,

        waitTime: 1,

      });

3、可以多查阅API,理解参数含义后去设置。http://support.supermap.com.cn:8090/webgl/web/apis/3dwebgl.html

4、有关camera的方位角,可以参考:https://blog.csdn.net/supermapsupport/article/details/101343950?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522167835261716800184154735%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=167835261716800184154735&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~rank_v31_ecpm-1-101343950-null-null.blog_rank_default&utm_term=%E6%96%B9%E4%BD%8D%E8%A7%92&spm=1018.2226.3001.4450

...