Hi, during my experiments on Cesium I came across two problems that break the project I'm attempting to port to Cesium. I need to keep a vehicle above ground while it is moving around the globe, and the Camera is following that vehicle at a certain distance. Example: http://dev.youbeq.com/Apps/Sandcastle/gallery/FollowModel.html .
While driving around I keep getting undefined values for the current Height, and terrain elevation keeps on changing usually on the base of the camera, the elevation drops or increases drastically making the vehicle jump around like crazy. Even if I wait for the terrain data to load around me when I start driving around that behaviour shows up and elevations keep on changing radically.
What can I do to improve the consistency of the heights returned for the terrain (getting undefined values breaks the realism of the movement)? And how can I prevent the terrain from losing detail around the area I'm currently at?
What I'm doing to get the height for a Latitude, Longitude is:
var position = Cesium.Cartesian3.fromDegrees(lng, lat, 0, ellipsoid, new Cesium.Cartesian3());
var altitude = scene.globe.getHeight(Cesium.Ellipsoid.WGS84.cartesianToCartographic(position));
Dan, Scott, and I thought about this for a while. Since we would need to make some researchy code changes to try to improve terrain loading for this scenario, we suggest a low-tech solution for now at least for the location switch use case. Instead of zooming right to the area, do a short (maybe 1.5-3 seconds?) camera flight to the area like PowderTracks:
The maximumScreenSpaceError value is something I already played with, and it can really help improve performance.
I tried the camera flyTo right now and it always jumps to a high height value, even for close distance position changes? Is there a way to change this behaviour?
I checked PowderTracks and the flyTo are cool and smooth, so I checked the code used in PowderTracks and if I understood it right the way it was done was a bit more complex then using just the camera flyTo. So to achieve the same behaviour will I have to implement in a similar way?
I had the similar issues when I created PowderTracks.The current implementation of camera.flyTo() handles the case of flying across long distances well. But that same logic doesn’t work well when trying to do a direct line of sight camera flight. The flyToTime() method in PowderTracks basically does the same thing that camera.flyTo does under the hood, but without the fancy spline path which is what causes the undesired change in height. I believe you’re also using an East-North-Up reference frame for following a vehicle, so you can probably use PowderTracks flyToTime method with only trivial changes. ie use your own desired final position instead of getting it from the path object and remove the code that changes the scenario time at the end of the flight.