3d tiles under terrain and single layer pickering

1. A concise explanation of the problem you’re experiencing.

Hello everyone. I am new to Cesium and during the realization of my app I had 2 problems.
First, my app has a 3dTiles layer with 3d buildings and a geojsondatasoure layer with the scope of the project. I just want to get information by picking the buildings, but if the 2 layers are active I can not; the geojson datasource stays on top of me and does not let me select the buildings (photo 1). What I can do?
The second problem comes with 3d buildings and their attachment to the model of elevations. With the ellipsoid there is no problem, the problem comes with cesium world terrain. They are sunk under the ground. I have tried with heightOffset but some continue sunk or overraised. Is there any way to individually place each building on the ground?
Thank you very much,

2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.

Hello World! @import url(../Build/Cesium/Widgets/widgets.css); html, body, #cesiumContainer { width: 100%; height: 100%; margin: 0; padding: 0; overflow: hidden; } #toolbar { background: rgba(42, 42, 42, 0.8); padding: 4px; border-radius: 4px; } #toolbar input { vertical-align: middle; padding-top: 2px; padding-bottom: 2px; } #toolbar .header { font-weight: bold; } h2 { color: black; } p { color: black; }



I have a similar problem; but instead of 3DTile I am using a simpe box.
On WGS84 Ellipsoid the box is clipped to the ground; when on WorldTerrain the box is partwise beneath the surface.
You can confirm this:
- setting to WGS84-Ellipsoid
- Click "onEllipsoid"
--> the box is clipped to ground
- click "magnitude 10"
- click "up"
--> the box is "flying" over the surface

- setting to Cesium World Terrain
- click "onTerrain"
--> part of the box is beneath surface:
- click "magnitude 10"
- click "up"
--> the box is comimg more up but still partwise under surface

This is the code:
var viewer = new Cesium.Viewer('cesiumContainer');
var CC3 = Cesium.Cartesian3;
var magnitude = 1;

var box_height = 30;

var thebox = viewer.entities.add({
    name : 'building',
    position: Cesium.Cartesian3.fromDegrees(-90.1922703175, 38.6286636758, box_height/2),
    box : {
        dimensions : new Cesium.Cartesian3(40, 30, box_height),
        material : Cesium.Color.RED,
        outline : true,
        outlineColor : Cesium.Color.BLACK

//var terrainProvider = new Cesium.CesiumTerrainProvider({
// url : '//assets.agi.com/stk-terrain/world',
    requestVertexNormals : true

var terrainProvider = Cesium.createWorldTerrain();

function getVector(name)
    var GD_full_transform = Cesium.Transforms.eastNorthUpToFixedFrame(thebox._position._value, viewer.scene.globe.ellipsoid, new Cesium.Matrix4());
    var GD_rot_transform = Cesium.Matrix4.getRotation(GD_full_transform,new Cesium.Matrix3());
    if(name=="east"){return Cesium.Matrix3.getColumn(GD_rot_transform,0,new CC3());}
    if(name=="north"){return Cesium.Matrix3.getColumn(GD_rot_transform,1,new CC3());}
    if(name=="up"){return Cesium.Matrix3.getColumn(GD_rot_transform,2,new CC3());}
function move(scalar,unitVector)
    var mycarte = thebox._position._value;
    var relMove = CC3.multiplyByScalar(unitVector,scalar,new CC3());
    thebox.position = mycarte;
    var mycarto = new Cesium.Cartographic();
    mycarto = viewer.scene.globe.ellipsoid.cartesianToCartographic(thebox._position._value);
    console.log("lon "+mycarto.longitude/Math.PI*180);
    console.log("lat "+mycarto.latitude/Math.PI*180);
    console.log("alt "+mycarto.height);

function setOnTerrain()
    var mycarte = thebox._position._value;
    thebox.position = mycarte;
    var mycarto = new Cesium.Cartographic();
    mycarto = viewer.scene.globe.ellipsoid.cartesianToCartographic(thebox._position._value);
    //takes the terrain, a precision value and the point of interest
    Cesium.sampleTerrain(terrainProvider, 11, [mycarto]).then(function(){
        console.log("setting to terrain height: "+(mycarto.height));
        mycarto.height += box_height/2;
        thebox.position = viewer.scene.globe.ellipsoid.cartographicToCartesian(mycarto);

function setOnEllipsoid()
    var mycarte = thebox._position._value;
    thebox.position = mycarte;
    var mycarto = new Cesium.Cartographic();
    mycarto = viewer.scene.globe.ellipsoid.cartesianToCartographic(thebox._position._value);
    mycarto.height = box_height/2;
    console.log("setting to ellipsoid height: "+(mycarto.height));
    thebox.position = viewer.scene.globe.ellipsoid.cartographicToCartesian(mycarto);

Sandcastle.addToolbarButton('magnitude 1', function()
Sandcastle.addToolbarButton('magnitude 10', function()

Sandcastle.addToolbarButton('east', function()
Sandcastle.addToolbarButton('west', function()
Sandcastle.addToolbarButton('north', function()
Sandcastle.addToolbarButton('south', function()
Sandcastle.addToolbarButton('up', function()
Sandcastle.addToolbarButton('down', function()
Sandcastle.addToolbarButton('onTerrain', function()
Sandcastle.addToolbarButton('onEllipsoid', function()

What is wrong?

Hi all,

Pol, I don’t think you attached that image, seeing it would help!

unterzwerg, I don’t understand what problem you are having. Do you not want the box to be below terrain at all?



Hello Gabby,

 I have not remembered to put the images as an example, I'm sorry. In this email I attached 4 images where it is clear how the buildings look in WSG84 and in Cesium World Terrain as well as the problem that I have with the picking when having selected both the buildings and the scope of the project.

Thank you very much,




unterzwerg - try using sampleTerrainMostDetailed. The box lines up perfectly after doing that.

Hey Pol,

For the issue where the GeoJSON is preventing picking buildings, you can use drillPick to get the building that’s underneath the GeoJSON. Also in Cesium 1.46 the GeoJSON will no longer drape over 3D Tiles by default so this may not be a problem once you upgrade.

For the second issue, Cesium doesn’t support clamping 3D Tiles to terrain. The most common workaround is to adjust the height of the tileset like in this Sancastle demo. You can determine a good height to use by calling sampleTerrainMostDetailed.

Hello Gabby,
thanks for answering
I want the box to be ABOVE the terrain at all; the box should be positioned on the ground.

Thank you!!!
I suppose that works!

Hi, Sean. Thank you for answering so quickly. I have been working on the heights with the sampleTerrainMostDetailed to adjust the height of the buildings in the terrain model through a button.

There isn’t a way to adjust individual buildings right now. The next closest thing is setting the transform of individual tiles. Just be careful though because the transforms are applied hierarchically, so the parent tile transform affects the child tile transform.

Thanks Sean.

I’m gonna left the buildings on the WGS84 Ellipsoid. Transformations of individual tiles sounds too complicated for me.