【问题标题】:Cesium JS flying to camera.lookAt (Migrating from Google Earth Plugin API lookAt)Cesium JS 飞到 camera.lookAt(从 Google Earth Plugin API lookAt 迁移)
【发布时间】:2017-04-27 12:29:40
【问题描述】:

在将我的飞行功能从 Google 地球插件迁移到 Cesium 时需要一些帮助。基本上在 ge 中,我创建了一个外观并调用 setAbstractView,如下所示

var ge = google.earth.createInstance('map3d')
var lookAt = TVV.mapObject.createLookAt('');
lookAt.set(
    21.2765107698755,
    -157.825362273258,
    0,
    ge.ALTITUDE_RELATIVE_TO_GROUND,
    20.1690873648706,
    74.9605580474674,
    764.534479411941
);
ge.getView().setAbstractView(lookAt);

那是我的谷歌地球插件代码。在 cesium 中遵循我的迁移指南:

// fly to code that works with cesium (but a little bit off)
viewer.camera.flyTo({
    destination : Cesium.Cartesian3.fromDegrees(-157.825362273258, 21.2765107698755, 764.534479411941),
    orientation : {
        heading : Cesium.Math.toRadians(20.1690873648706),
        pitch : Cesium.Math.toRadians(74.9605580474674 - 90.0),
        roll: 0
    }
})

该代码几乎位于正确的位置。我必须将其拖到右侧才能看到我之前设置的地标(因此该视图与 Google 地球中的不完全一样)。

所以我尝试了这个我也找到的代码。

// code that works with cesium
var center = Cesium.Cartesian3.fromDegrees(-157.825362273258, 21.2765107698755);
var heading = Cesium.Math.toRadians(20.1690873648706);
var pitch = Cesium.Math.toRadians(74.9605580474674);
var range = 764.534479411941;
viwer.camera.lookAt(center, new Cesium.HeadingPitchRange(heading, pitch, range));

该代码看起来更接近之前的 google earth 插件视图。但是,当然,它不会将相机飞到视图中。它只会立即设置视图。

我的问题是,如何利用我的 lat、lng、heading、pitch 和 range 值将相机飞到 cesium 中的 lookAt 视图?

这里是来自 GE 和 Cesium 的相关 API 文档,如果您觉得它们有用的话。

GE createLookAt https://developers.google.com/earth/documentation/reference/interface_g_e_plugin.html#a82f1b3618531a6bfab793b04c76a43e7

GE Camera Control(搜索“平移到绝对位置”) https://developers.google.com/earth/documentation/camera_control

铯看 https://cesiumjs.org/Cesium/Build/Documentation/Camera.html#lookAt

铯飞到 https://cesiumjs.org/Cesium/Build/Documentation/Camera.html#flyTo

我也发现了这个,但不确定如何集成它。如果有人可以提供 codepen/jsfiddle 或类似的东西,将不胜感激! https://groups.google.com/forum/#!topic/cesium-dev/r5rddMUeS80

【问题讨论】:

    标签: google-maps kml google-earth-plugin cesium


    【解决方案1】:

    感谢来自 Cesium 论坛的 Hannah Pinkos 的回答。

    在创建实体并使用 google earth 插件中的航向、俯仰(倾斜)和范围值后,您可以飞到具有偏移量的实体...

    var heading = Cesium.Math.toRadians(20.1690873648706g);
    var pitch = Cesium.Math.toRadians(74.9605580474674 - 90);
    var range = 764.534479411941;
    
    TVV.mapObject.flyTo(entity, {
     offset: new Cesium.HeadingPitchRange(heading, pitch, range)
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-06-24
      • 2018-06-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-01
      • 1970-01-01
      相关资源
      最近更新 更多