HI all
First off wanted to say a big thanks to the Cesium team. It really is an amazing bit of software.
I have an issue with cameras, the issue is totally down to my lack of understanding and am looking for some pointers in the right direction.
I have developed a web based satellite tracking application and I am trying to implement a feature in the 3d view, which is where Cesium is used, that allows you to follow a satellite either from your location or the satellite. So for example in the following from home view the camera is placed at your location and points at the satellite, the reverse being true for the follow from satellite
The current implementation can be seen at the url below. Please give the page a little time to load and once loaded accept the cookies and allow the browser to use your location.
http://www.agsattrack.com/?view=3d (Please only use Firefox/Chrome or Safari)
Find a satellite that is above the horizon at your location, clicking on a satellite will show its orbit and any passes at your location during the current orbit.
Ensure the satellite is selected by clicking on it and then click on the 'From Home' icon in the toolbar. You should now be following the satellite from your location.
The 'From Satellite' doesn't work at all, it seems to point into space all of the time.
The code that is altering the camera is as follows, this code is run every time the satellite positions are updated which by default is every 5 seconds.
if (_followFromObserver) {
eye = ellipsoid.cartographicToCartesian(Cesium.Cartographic.fromDegrees(observer.getLon(), observer.getLat(), 100));
target = new Cesium.Cartesian3(following.get('x'), following.get('y'), following.get('z'));
target = target.multiplyByScalar(1000);
up = Cesium.Cartesian3.UNIT_X;
} else {
target = ellipsoid.cartographicToCartesian(Cesium.Cartographic.fromDegrees(observer.getLon(), observer.getLat(), 100));
eye = new Cesium.Cartesian3(following.get('x'), following.get('y'), following.get('z'));
eye = target.multiplyByScalar(1000);
up = Cesium.Cartesian3.UNIT_X;
}
scene.getCamera().controller.lookAt(eye, target, up);
The theory behind this is that the eye and target are set depending upon which following option is selected. The lookat method on the camera controller is then used to position the camera.
So there are three problems here
1) The follow from home works some of the time !
2) The follow from satellite doesn't work at all.
3) I would like to orientate the camera so that when following from the observers location the camera is orientated with the horizon.
I am obviously doing something wrong here and I am sure its just due to my total lack of understanding.
Any pointers in the right direction would be greatly appreciated.
Many Thanks
Alex