Overlay images on terrain (moving from Google Earth to Cesiumjs)

In Google Earth Plugin we have something called Ground overlays ( https://developers.google.com/earth/documentation/geometries#groundoverlay ) that allows us to set images on top of the terrain, and it will take care to follow the elevation of the terrain.

I have different vehicles with different shadow images that I want to overlay on the terrain according to the position and orientation of the vehicle. I have been looking through the demos and reference doc and can't find a way to accomplish the same. I checked out the Polygon but it will only position correctly with the flat ground, when the terrain layer is active it will not show, but even if I could get the altitude of each of the vertices right it would not work in cases where there are different heights inside the polygon.

What I really want is a way to show the shadows the vehicle casts on the terrain, in GE Plugin I had to use that "hack". Is this possible in Cesium?

Thanks for the help.

The Cesium equivalent of a GE GroundOverlay is the SingleTileImageryProvider class. Takes an image and a bounding rectangle in radians. Not entirely sure if that solves your use case based on the second paragraph, but hopefully that helps.

Thanks for the help.

Using that SingleTileImageryProvider class I can overlay an image on the terrain but I can't seem to change its position while I move around, the only way I found to simulate that is by removing and creating those tiles X times per second (actually I had to limit for every 5 seconds or else it would explode), which isn't a good approach. Did I miss something and there is a way to update the tile location (I tried setting the rectangle with no success) or is there another type of class that I could use?

Yeah, looking at the source for SingleTileImageryProvider, the Rectangle property seems to be read-only after creation.

Perhaps you could do something with an Image material and a RectanglePrimitive? The “Materials” demo in the Sandcastle gallery shows an example of applying an Image Material, and the RectanglePrimitive class looks like it updates its position. Seems like it might actually be a decent equivalent.

Any of the Cesium team have suggestions, or comments on the differences between a SingleTileImageryProvider and a RectanglePrimitive + ImageryMaterial?

The first thing I tried was checking those examples, but the problem I find with those primitives is that when you turn the terrain meshes on they don't take into account the elevation of the terrain.

Hi Andre,

The RectanglePrimitive doesn’t yet support draping over terrain. This is an important feature we want to add for KML, but it is probably a few months out. In the meantime, is your approach for SingleTileImageryProvider working well enough? Perhaps keep a head/tail of 16-64 images?


Thanks for the info Patrick.
I stopped playing around with the SingleTileImageryProvider waiting for a better solution, but I will git it another shot with your idea.

Hi Patrick,

Will the draping over terrain feature be added only to the KML branch or
will it be implemented in master?



It will be a general feature so it will be implemented in a separate branch, most likely in the form of a new geometry and appearance, but the details are TBA.

We will then integrate it with the KML data source just like, for example, the KML data source creates regular polygon geometry now.

Just to set expectations, we haven’t started on this yet.