方法一:
let width = window.viewer.canvas.clientWidth / 2;
let height = window.viewer.canvas.clientHeight / 2;
let destination = viewer.scene.globe.pick(
viewer.camera.getPickRay(new Cesium.Cartesian2(width, height)),
viewer.scene
);
viewer.scene.camera.flyTo({
destination: destination,
orientation: {
heading: viewer.camera.heading,
pitch: Cesium.Math.toRadians(-90),
roll: viewer.camera.roll,
},
});
方法二:
function rotateAngle(angle = -30) {
let position = viewer.camera.position;
let cartographic = Cesium.Cartographic.fromCartesian(position);
let heading = viewer.camera.heading;
let height = cartographic.height;
let pitch = Cesium.Math.toRadians(angle);
let width = window.viewer.canvas.clientWidth / 2;
let cheight = window.viewer.canvas.clientHeight / 2;
let destination = viewer.scene.globe.pick(
viewer.camera.getPickRay(new Cesium.Cartesian2(width, cheight)),
viewer.scene
);
viewer.camera.flyToBoundingSphere(new Cesium.BoundingSphere(destination), {
offset: new Cesium.HeadingPitchRange(heading, pitch, height),
duration: 2,
});
}