首页 / 浏览问题 / 三维GIS / 问题详情
cesium 沿线飞行的镜头不对
22EXP 2023年03月09日
cesium的沿线飞行飞着就往天上转一圈在返回目的地

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,865EXP 2023年03月09日
你这个我搜到了,不全,无从查起
飞行站点Cesium.RouteStop(options)中的heading是本站点的方位角,方位角为与正北方向的夹角,不同站点位置的heading、tilt是不同的,根据代码设置的都是同一个scene.camera.heading。

关闭所有的鼠标控制镜头的方法,避免鼠标操作破坏飞行过程。

例如//scene.screenSpaceCameraController.enableRotate = false;  //scene.screenSpaceCameraController.enableTranslate = false;
...