3D Buildings with Terrain

We have a 2 different DBs that dynamically send us points for buildings to render on the earth with terrain. The building data is sent dynamically based upon the user input or a defined scenario. I’ve been using the PolygonGraphics of the Entity with some varying results. Seems like the polygons always render on the ellipsoid. I updated our version of Cesium to 1.35 last night so we’re up to date with the latest released version. What would be my best path forward? Should I learn about generating the 3D Tile sets? or should I generate geojson when I get the building data? My understanding of the 3D Tile sets is that you setup the 3D objects into a file ahead of time. Due to the dynamic nature of our application is there a current solution to render polygons on the terrain surface? I’ve already set up the sampleTerrain call for each building so I know that I’ve got good elevation data.



Extruded polygons that conform to the earth’s terrain is not possible yet, so your approach of using sampleTerrain for each building is good. Are you setting the polygon’s height property? I’m not sure why else the the polygons would be stuck on the ellipsoid.

Typically 3D Tiles tilesets are generated ahead of time, but it is definitely possible for the server to generate a suitable tileset.json and have tiles ready to be requested. It depends on how much data you have and whether it benefits from tiling or not. If you go down this approach you would likely be using either the b3dm or vector tile format, b3dm being more like glTF, and vector tiles being more like points, lines, and polygons. Vector tiles are still in-progress and wouldn’t be ideal for production use yet.

For dynamic updates you can set a tile’s expiration so that it re-requests its content at a fixed interval or at a specific date.

I would avoid generating GeoJson as internally it is just converted to polygons. I actually think PolygonGraphics is the best solution for now once the height is working.

Is this correct? This is being called from the sampleTerrain promise, and the code does execute. It seems to help the situation, but not fully fix the buildings from appearing to move as the camera is pitching. It seems as though the buildings are not rendering at the correct place.

var setPolygonHeight = function( height, key ) {

var node = _nodes[ key ];

if ( node && node.cesiumObj ) {

node.cesiumObj.polygon.height.setValue( height );



The looks correct. If you set the height to some extreme value do you notice the change?

Usually when buildings appear to move they are being rendered below the surface. It seems that the height value passed in is either incorrect or not tall enough to meet the rendered terrain.

I tried multiplying the value by 4, and I didn’t notice any difference. Could this have something to do with entity’s position, or the fact that the entity that has defined the polygon has a entity parent?


I did figure out one issue. I thought the extrudedHeight was relative to the height, but it is relative to the ellipsiod. The extrudedHeight better be greater than the height. When the height is set from the sampleTerrain call then the extrudedHeight needs to be set as well. After setting the height and the extrudedHeight the buildings are floating. I’m wondering how I determine the ‘level’ parameter of the sampleTerrain function. I know that the pick returns wildly different values for the terrain height as the camera zooms out.

We didn’t have the highest level of detail set in the sampleTerrain function. We switched to the sampleTerrainMostDetailed function and all is well! Thanks, Scott