What is (x1, y1)? Are they a latitude/longiutude pair? If so, you can just use Cesium.Cartesian3.fromDegrees like you do in your example. There are many function to create a Cartesian depending on what (x1, y1) are, see the Cartesian3 docs.
thank you gabby.
maybe I didn’t describe my question clearly.
for example, I want the globe center on (116, 40), how can I calculate the position of the camera.
the height is the current height of camera, and orientation of camera is fixed.
viewer.camera.setView( {
//how to calculate x,y to make sure globe center on (116, 40)
destination : Cesium.Cartesian3.fromDegrees(x,y,120000),
orientation: {//fixed
heading : Cesium.Math.toRadians(-0),
pitch : Cesium.Math.toRadians(-40),
roll : 0.0
}
});
I want a formula, because I need to change the position by user click data list.
When you set the view to a location, it should center on that point. You don’t have to set the camera position. I don’t understand what the problem is you’re running into here, can you be more specific?
you said: ‘When you set the view to a location, it should center on that point’
when the orientation–pitch attribute of the camera is -90, this is right. (left part of the picture)
but my question is the right part of the picture, the camera was not perpendicular to the ground,I thouht a formula
var distance = viewer.camera.positionCartographic.height/Math.abs(tan(40));
var degree = distance / (2 * Math.PI * 6378137.0) * 360;
I think the distance should be latitude, but my test was lost.
you said: ‘When you set the view to a location, it should center on that point’
when the orientation–pitch attribute of the camera is -90, this is right. (left part of the picture)
but my question is the right part of the picture, the camera was not perpendicular to the ground,I thouht a formula
var distance = viewer.camera.positionCartographic.height/Math.abs(tan(40));
var degree = distance / (2 * Math.PI * 6378137.0) * 360;
I think the distance should be latitude, but my test was lost.