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 cesiumjs.org hosted version of Sandcastle?
http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html
Kevin
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();
scene.primitives.add(labels);
var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
handler.setInputAction(function(movement) {
var cartesian = scene.camera.pickEllipsoid(movement.endPosition, ellipsoid);
if (cartesian) {
var cartographic = ellipsoid.cartesianToCartographic(cartesian);
label.show = 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(){
scene.camera.flyTo({
destination : Cesium.Cartesian3.fromDegrees(7.2675, 48.3946, 2000),
});
};
setView();
var builtInCzml =
[
{
“id”:“document”,
“name”:“Ground Vehicle”,
“version”:“1.2”
},
{
“id”:“CesiumGround”,
“name”:“CesiumGround”,
“model”:{
“scale”:10,
“gltf”:"…/…/SampleData/models/CesiumGround/Cesium_Ground.gltf"},
“position”:{“cartographicDegrees”:[7.269101,48.394441,1139]},
/* “orientation”:{“unitQuaternion”:[0,0,0,1]}*/
}
];
var czmlDataSource = new Cesium.CzmlDataSource();
czmlDataSource.load(builtInCzml, ‘Built-in CZML’);
viewer.dataSources.add(czmlDataSource);