export const viewer = new Viewer(‘cesiumContainer’, {
timeline: false,
animation: false,
sceneModePicker: false,
baseLayerPicker: false,
terrainProvider: createWorldTerrainAsync(), // Enable world terrain for clamping
globe: true, // Enable the globe (this should be true to show the terrain)
});
In here whenever I set true the “globe” variable I’m receiving following errors. Anyone have an idea?
const viewer = new Cesium.Viewer("cesiumContainer", {
terrain: Cesium.Terrain.fromWorldTerrain(),
});
Running the code you provided, I get the same first error that you shared. Did you find this code suggested somewhere specific? Perhaps it is outdated and we need to review that part of our documentation.
Please let me know if this alternative code works as you expect and if you know the origin of the initial code you shared and where our docs can be improved.
// const imageryViewModels = ;
// Define the custom provider const customProviderViewModel = new window.Cesium.ProviderViewModel({ name: ‘Google 3D Tiles’, tooltip: ‘View Google 3D Tiles’, iconUrl: ‘/earth.png’, category : ‘Tiles 3d’, creationFunction: function () { return null; } });
baseLayerPicker.viewModel.imageryProviderViewModels.push(customProviderViewModel);
then to be able to observe the clicks on the other maps: window.Cesium.knockout.getObservable(baseLayerPicker.viewModel, ‘selectedImagery’).subscribe((selectedLayer) => { if (selectedLayer.category !== ‘Tiles 3d’) { const primitives = viewerRef.current.scene.primitives; const length = primitives.length; let existGoogle = false; for (let i = 0; i < length; ++i) { if (primitives._primitives[i]._url !== undefined) { const p = primitives.length; false;
// search google3DTileset
for (let i = 0; i < length; ++i) {
if (primitives._primitives[i]._url !== undefined) {
const p = primitives.get(i);
p.show = true;
existGoogle = true;
break;
}
}
if (!existGoogle) {
viewerRef.current.scene.primitives.add(google3DTileset);
}
}
this allowed me to make the map change work, as you can see on my map there are also two markers, so I had to check if the primitive had a url or not
hope this is useful to other users
One additional item to share. The CesiumJS API also supports subscribing to the knockout observable with Cesium.subscribeAndEvaluate() (note: this function is marked private so it is not in the documentation, but you can still use it)