Model floats above or sinks into the terrain
The same model.glb sits correctly without terrain but hovers about 8 metres above once world terrain is enabled, and in mountains half of it is buried. Three factors stack: the model origin is not at its base, the height is hardcoded to 0, and terrain exaggeration scales the ground.
- The model bottom floats roughly 8 metres after enabling world terrain.
- In a mountainous area the lower half of the model is cut off by the terrain.
- The printed position longitude, latitude and height match the design coordinates exactly.
- After load, read model.boundingSphere and subtract its centre from the entity position to get the origin offset.
- Do not sample height right after constructing the Viewer, because terrain tiles have not arrived yet.
- Use sampleTerrainMostDetailed or wait for globe.tilesLoaded to obtain the real ground height.
- Check terrainExaggeration, since the same coordinate sits differently under two terrain settings.
- Check whether heightReference is CLAMP_TO_GROUND and whether the model origin is at its base.
Either set heightReference to Cesium.HeightReference.CLAMP_TO_GROUND on the model, or compute placeHeight as groundHeight minus bottomOffset, for example ground 45 m with a bottom offset of -12.4 m, and place it through Cesium.Transforms.eastNorthUpToFixedFrame. Reset terrainExaggeration to 1.0 while calibrating.
var entity = viewer.entities.add({
position: Cesium.Cartesian3.fromDegrees(116.391, 39.907, 0),
model: { uri: '/models/tower.glb' }
});
viewer.scene.globe.tilesLoaded = true;
entity.model.readyPromise.then(function (model) {
var bs = model.boundingSphere;
console.log('包围球半径', bs.radius);
console.log('中心相对原点', Cesium.Cartesian3.subtract(
bs.center, entity.position.getValue(viewer.clock.currentTime), new Cesium.Cartesian3()
));
});var terrain = await Cesium.createWorldTerrainAsync();
var carto = Cesium.Cartographic.fromDegrees(116.391, 39.907);
var samples = await Cesium.sampleTerrainMostDetailed(terrain, [carto]);
console.log('地面高程', samples[0].height);
- Calling scene.sampleHeight immediately after creating the Viewer, which returns 0 from the ellipsoid rather than the terrain height.
- Baking the correction into the GLB by re-exporting, which breaks as soon as another area has different elevation.
Atlaslog (2026). Model floats above or sinks into the terrain. https://www.jingweizhi.com/en/cookbook/cesium-model-float-sink.html (accessed 2026-11-03).