I'm thinking of saving a camera position (specifically rotation) so changing back and forth between 2D and 3D will always go back to my last viewed position in 3D. What is the best way to do this?
I would also like to save it as a cookie or in local storage so that the user would go straight into that saved view on the page with Cesium from other pages (which may not be the US).
I would recommend just creating a simple JS object and storing the properties of the camera before you switch views. Then just store it into localStorage. I find store.js a really useful wrapper for browser agnostic local storage.
If you need more help I can come up with an example later tonight.
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()
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With