I noticed that the terrain demo uses the CesiumViewerWidget, so that brought up a couple of questions.
Could I get the terrain to render in the CesiumWidget, or is there added functionality in the CVW?
Will the CesiumViewerWidget be available in the Cesium build in the future?
Scott
Good news on both accounts.
- First, you can easily use terrain with the CesiumWidget by passing in the terrainProvider you want to use as an option. Here’s an example:
var widget = new Cesium.CesiumWidget(‘cesiumContainer’, {
terrainProvider: new Cesium.CesiumTerrainProvider({
url : ‘http://cesium.agi.com/smallterrain’,
credit : ‘Terrain data courtesy Analytical Graphics, Inc.’
})
});
You can also set the terrainProvider property on the scene’s centralbody, as done in the Terrain Sandcastle demo.
- As part of the upcoming release, we completely rewrote the CesiumViewerWidget to be dojo-free and available as part of the combined Cesium file. It will work similarly to CesiumWidget, so in the above example you could simply do
var widget = new Cesium.Viewer(‘cesiumContainer’, {
terrainProvider: new Cesium.CesiumTerrainProvider({
url : ‘http://cesium.agi.com/smallterrain’,
credit : ‘Terrain data courtesy Analytical Graphics, Inc.’
})
});
I tried to set the terrainProvider on the scene’s centralBody( as well as setting centralBody.depthTestAgainstTerrain = true ), but I’m not seeing any terrain. I think this maybe just an issue with the camera really not being in a good position. ?? I looked at the code in the terrain demo, but didn’t see anything dealing with the camera. The terrain demo does have some code that’s dealing with fullscreen inside of the widget, is that doing something to trigger the terrain to render?
Scott
Can you share your code? In the “wonderful” world of Javascript, a simple typo (such as mistyping terrainProvider) will not produce any errors but will not work, either. Other than that, you should not need to take any additional steps. The full screen stuff is not necessary for terrain to show up, and the camera does not need any modification. Zoom in somewhere mountainous and tip the camera toward the horizon by middle-click dragging (the middle mouse button on most systems in the mouse wheel) or left clicking with shift held down.
Kevin
I found the problem, and I have it working now. Thanks for the quick replies.
Scott
Is the Cesium.Viewer stable? If I switch my demos over to using the Viewer, should I build the latest sources?
Scott
We try and keep master as stable as possible, so for demo purposes you can usually use it just fine. For deployment, we always recommend an official release. Also, we will be releasing b18 on Monday (Cesium releases the 1st of every month), so you can always switch to master now and then update again when b18 is available.
I just updated and the earth lost all of it’s images, did something change with the imageProvider(I’m using the CesiumWidget)? I’m sure I can figure out what the issue is, but any hints on what I should be looking into?
Scott
Are there any errors in the console? How exactly are you adding the imagery layers?
There are no errors, and I’m not doing anything with imagery layers on start up. I did expose an application level property, so that the imageryProvider can be set, but that property isn’t set until a user specifically changes that in our editor. Switching the provider via the property no longer works as well. Do I need to pass in a imagery provider to the CesiumWidget constructor?
Scott
Here’s my code:
var cesiumOptions = { “contextOptions”: { “alpha”: true }, };
if ( this.useCesiumWidget ) {
node.widget = new Cesium.CesiumWidget( this.containerDiv, cesiumOptions );
}
After looking at some of the latest code using the CesiumWidget, my guess is that there is a problem defining the second parameter to the widget, and not specifying a imageProvider…??
Scott
CesiumWidget should add a BingMapsImageryProvider by default if you don’t specify options.imageryProvider (which it doesn’t look like you are).
Is contextOptions the only property you’re setting on cesiumOptions? I tried your code and it’s working for me.
One other possibility that comes to mind is that the Web Worker that creates geometry isn’t working correctly. Do you see any 404s or anything like that in your network tab?
Scott
Yes, the contextOptions are the only options that I’m currently defining. I’ll try defining the imageProvider.
I don’t see any 404s in the network tab. I did see that my version is trying to load a0, a1, a2, and a3(.jpeg) and nothing else, but your working camera demo loads a lot of a# jpegs, but does not load a0, a1, a2, or a3.
Thanks, Scott
I found the problem. The workers were being loaded local to the application, instead of local to the cesium library. Thanks for mentioning the workers issue,
Scott