I'm trying to fly to a coordinate and view the eastern or western horizons in 3D from near ground level. In Google Earth API this was accomplished by using the following line of code:
var ground_offset = 1.6; //average height of person
var east_view = 90;
var west_view = 270;
var tilt = 90;
ground_offset = 1.6; //average height of person
var lookAt = ge.createLookAt('');
lookAt.set(latitude, longitude, ground_offset,
ge.ALTITUDE_RELATIVE_TO_GROUND, east_view, tilt, altitude_of_ground);
ge.getView().setAbstractView(lookAt);
However, in Cesium, the camera is usually too high, implying that the height I retrieved was not correct. Where am I going wrong?
The following is an example of the code I'm using in Cesium (in real life, the latitude and longitude are inserted in real time using php):
var viewer = new Cesium.Viewer('cesiumContainer', {
fullscreenElement: 'previewContent'
});
var scene = viewer.scene;
var globe = scene.globe;
globe.depthTestAgainstTerrain = true;
var cesiumTerrainProviderMeshes = new Cesium.CesiumTerrainProvider({
url : '//assets.agi.com/stk-terrain/world'
});
viewer.terrainProvider = cesiumTerrainProviderMeshes;
var Azimuth = 90.0; //East = 90.0. West = 270.0
var PitchAngle = 0.0;
var RollAngle = 0.0;
var longitude = -74.209701;
var latitude = 40.082129;
// Query the terrain height of the Cartographic position
var terrainProvider = new Cesium.CesiumTerrainProvider({
url : ‘https://assets.agi.com/stk-terrain/world’
});
var positions = [
Cesium.Cartographic.fromDegrees(longitude, latitude),
];
var promise = Cesium.sampleTerrain(terrainProvider, 11, positions);
Cesium.when(promise, function(updatedPositions) {
var Fudge = 1.6; //average height of person
var height = positions[0].height + Fudge;
var camera = viewer.camera;
var camera = viewer.camera;
camera.setView({
destination : Cesium.Cartesian3.fromDegrees(longitude, latitude, height),
orientation: {
heading : Cesium.Math.toRadians(Azimuth),
pitch : Cesium.Math.toRadians(PitchAngle),
roll : Cesium.Math.toRadians(RollAngle)
}
});
});