1. A concise explanation of the problem you're experiencing.
Hello,
The following codes work almost without any problem. But there is something missing which I cannot solve.
I want to change the camera angle by pushing the arrow keys. The codes do this BUT instead of directing the camera towards right-left-up-down, they only direct it towards the north.
What I want to do is whenever I turn my camera towards a point, apart from the north, I want the camera to turn to the direction I pointed out.
2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.
document.addEventListener('keydown', function (e) {
setKey(e);
}, false);
function setKey(event) {
var horizontalDegrees = 5.0;
var verticalDegrees = 5.0;
var scratchRectangle = new Cesium.Rectangle();
Cesium.Camera.DEFAULT_VIEW_FACTOR = 0;
var viewRect = camera.computeViewRectangle(viewer.scene.globe.ellipsoid, scratchRectangle);
if (Cesium.defined(viewRect)) {
horizontalDegrees *= Cesium.Math.toDegrees(viewRect.east - viewRect.west) / 360.0;
verticalDegrees *= Cesium.Math.toDegrees(viewRect.north - viewRect.south) / 180.0;
}
if (event.keyCode === 39) { // right arrow
camera.rotateRight(Cesium.Math.toRadians(horizontalDegrees));
} else if (event.keyCode === 37) { // left arrow
camera.rotateLeft(Cesium.Math.toRadians(horizontalDegrees));
} else if (event.keyCode === 40) { // up arrow
camera.rotateUp(Cesium.Math.toRadians(verticalDegrees));
} else if (event.keyCode === 38) { // down arrow
camera.rotateDown(Cesium.Math.toRadians(verticalDegrees));
}
}