STK World Mesh and models

Morning all,

I am working on a project that moves some simple models here and there to represent the movements of army units. I know that when I use an STK world terrain mesh the models are properly grounded and life is good.

Therefore, I am trying to have the default terrain be the STK world terrain mesh. A simple code snippet is below.

Everything looks good. The globe is rendered in 3D as I’d hope, models are correct, etc (disregard the orientation of the models- that is a quaternion problem I’m working on).

However the center of the models still float through the air despite the globe being rendered in 3D. But if I manually select the STK world terrain mesh, the ground rises up and places the models pretty as pie.

My question is whether you can show me where I’ve gone wrong and how might I properly select the STK world terrain mesh?

Many thanks, erik

Hi Erik,

Your code looks correct to me, and when I paste this code into Sandcastle, it does activate STK World Terrain as we’d expect:

var viewer = new Cesium.Viewer(‘cesiumContainer’);

var scene = viewer.scene;

var globe = scene.globe;


globe.terrainProvider = new Cesium.CesiumTerrainProvider({

url : ‘//


Can you explain a bit more about what you’re seeing? Do you see terrain features at all before you select STK World Terrain via the UI? When you do select it, the models themselves don’t move, right? You just see the terrain rise up to meet them?


Thanks for the reply Kevin. My message was a bit confused because my head is a bit confused.

I have pasted some code below everyone can see by cut/paste into Sandcastle.


I would like to use the STK world terrain mesh as the 3D layer.


I called for that through globe.terrainProvider. Works nicely. The earth comes up in 3D all looks great. You’ll notice some parallax effect, but not too much.


However, if I move the mouse with the viewer and hover over the baseLayerPicker (but do not click on it), the temporary popup window tells me that I am still using the WGS84 Ellipsoid.

Once I manually click on “STK world terrain mesh” from the baseLayerPicker pull down, the terrain changes slightly and the model is glued to the spot – no parallax whatsoever and the temporary popup window when the mouse hovers over the baseLayerPicker now indicates that I am using the STK world terrain meshes.


I thought I had already chosen the STK mesh to be active through globe.terrainProvider. Is there another way to automatically select the STK world terrain meshes that gets me to the same place where the STK mesh is activated as if I had clicked on it manually? If not, no worries.

Two other quickies:

  • I am getting an error having to do with ‘undefined’ elevations. Any thoughts?

  • You can see the root of my lingering CZML orientation confusion with quaternions. Are Cesium’s quaternion parameters ordered x,y,z,w? And therefore does not 0,0,0,1 have a northerly bearing?

Many thanks Kevin et al, Erik

Hi Erik,

I ran your Sandcastle demo. I see what you’re talking about with the base layer picker. The reason for that is that by setting globe.terrainProvider directly, we’re going behind the base layer picker’s back, and it doesn’t know what we’ve changed the terrain provider. You can avoid that by constructing the Viewer with the correct terrain provider in the first place, though it’s a big clunky. See the updated Sandcastle code at the end of this email.

However, I don’t see the parallax effect you’re talking about. Even with your original code, the model is glued nicely to the terrain, and I don’t see any difference after explicitly selecting STK World Terrain using the base layer picker.

Which version of Cesium are you using? There was a bug introduced just prior to 1.2 (though it was fixed before 1.2 was shipped I believe) that made Cesium sometimes not download the full-resolution terrain that it should. Can you reproduce the problem on the hosted version of Sandcastle?


Here’s the updated Sandcastle code I mentioned in the first paragraph:

var terrainProviderViewModels = Cesium.createDefaultTerrainProviderViewModels();

var viewer = new Cesium.Viewer(‘cesiumContainer’, {

terrainProviderViewModels: terrainProviderViewModels,

selectedTerrainProviderViewModel: terrainProviderViewModels[1]


var scene = viewer.scene;

var globe = scene.globe;

var label;

var ellipsoid = scene.globe.ellipsoid;

var labels = new Cesium.LabelCollection();

label = labels.add();


var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);

handler.setInputAction(function(movement) {

var cartesian =, ellipsoid);

if (cartesian) {

var cartographic = ellipsoid.cartesianToCartographic(cartesian); = true;

label.text = ‘(’ + Cesium.Math.toDegrees(cartographic.longitude).toFixed(4) + ', ’ + Cesium.Math.toDegrees(cartographic.latitude).toFixed(4) + ', ’ + scene.globe.getHeight(Cesium.Ellipsoid.WGS84.cartesianToCartographic(cartesian)).toFixed(1) + ‘)’;

label.position = cartesian;

} else {

label.text = ‘’;


}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);

function setView(){{

destination : Cesium.Cartesian3.fromDegrees(7.2675, 48.3946, 2000),




var builtInCzml =




“name”:“Ground Vehicle”,










/* “orientation”:{“unitQuaternion”:[0,0,0,1]}*/



var czmlDataSource = new Cesium.CzmlDataSource();

czmlDataSource.load(builtInCzml, ‘Built-in CZML’);