9

我正在考虑保存相机位置(特别是旋转),因此在 2D 和 3D 之间来回更改将始终返回到我上次查看的 3D 位置。做这个的最好方式是什么?

我还想将其保存为 cookie 或本地存储,以便用户可以从其他页面(可能不是美国)直接进入页面上保存的带有 Cesium 的视图。

4

2 回答 2

8

我建议在切换视图之前创建一个简单的 JS 对象并存储相机的属性。然后将其存储到 localStorage 中。我发现 store.js 是一个非常有用的与浏览器无关的本地存储的包装器。

如果您需要更多帮助,我可以在今晚晚些时候提出一个示例。

    var camera = $scope.viewer.scene.camera;
    var store = {
      position: camera.position.clone(),
      direction: camera.direction.clone(),
      up: camera.up.clone(),
      right: camera.right.clone(),
      transform: camera.transform.clone(),
      frustum: camera.frustum.clone()
    };
于 2014-05-08T18:45:25.247 回答
1

基于Mike LP的回答:

let undoCamera = {
    position: this.camera.position.clone(),
    direction: this.camera.direction.clone(),
    up: this.camera.up.clone()
};
this.camera.position = undoCamera.position;
this.camera.direction = undoCamera.direction;
this.camera.up = undoCamera.up;

这对我有用,至少在 3D 和哥伦布模式下。

frustum如果需要,您也可以对 执行相同操作。

https://www.cesium.com/docs/cesiumjs-ref-doc/Camera.html

于 2020-07-28T18:03:51.963 回答