问题
i am using cesium on my gwt project and i am using cesium-terrain-server for terrain. (Not cesium-gwt , devoloping my own code with jsni) My problem : i am creating graphic on terrain (polygon , polyline) , when i navigate on map , graphics are moving from its position. is there any way to immobilize them on the point(s) which i selected before ?
example code :
var polygon = new Cesium.PolygonGraphics({
fill : true;
material : Cesium.Color.BLUE.withAlpha(0.5),
outline : true,
hierarchy :{
positions: cartesian3s
}
})
then i am adding polygon as entity to cesium viewers entities.
回答1:
If graphics appear to "move" or slide around when navigating a map with terrain on it, that typically means the graphics in question are being drawn underneath the terrain (on the WGS84 ellipsoid itself), and are showing through the terrain. There's a bit of an optical illusion where the eye doesn't understand that it's seeing through a mountain or the ground itself to some graphics far underneath. It's only when the camera moves that it becomes visually apparent that something is wrong. If you want the graphics to appear stationary, they must be at the correct altitude for the terrain they're on.
The ability to drape polygons on terrain was added in Cesium 1.3 and has been asked about elsewhere on SO. But it looks like this capability has not been added to the Entity API as of yet, so your current options are (a) if on flat terrain, sample the height at a point and move the polygon to that height, or (b) skip the Entity API layer and use graphics primitives, specifically the GroundPrimitive to render the polygon draped on terrain.
来源:https://stackoverflow.com/questions/33370129/navigating-on-cesium-terrain-map-corrupts-position-of-graphics