# Terrain demo

**URL:** <https://community.cesium.com/t/terrain-demo/574>\
**Category:** CesiumJS\
**Created:** [June 24, 2013, 4:46pm UTC](https://community.cesium.com/t/terrain-demo/574 "2013-06-24T16:46:15Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Scott\_Haynes](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/scott_haynes/32/2063_2.png) [@Scott\_Haynes](https://community.cesium.com/u/Scott_Haynes)\
**Post date:** [June 24, 2013, 4:46pm UTC](https://community.cesium.com/t/terrain-demo/574/1 "2013-06-24T16:46:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Matt\_Amato](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/matt_amato/32/1993_2.png) [@Matt\_Amato](https://community.cesium.com/u/Matt_Amato)\
**Post date:** [June 24, 2013, 4:56pm UTC](https://community.cesium.com/t/terrain-demo/574/2 "2013-06-24T16:56:41Z")

</div>

Good news on both accounts.

1. 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](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](http://localhost:8080/Apps/Sandcastle/index.html?src=Terrain.html).

1. 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](http://cesium.agi.com/smallterrain)’,

credit : ‘Terrain data courtesy Analytical Graphics, Inc.’

})

});

---

<div class="post-metadata">

**Author:** ![Scott\_Haynes](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/scott_haynes/32/2063_2.png) [@Scott\_Haynes](https://community.cesium.com/u/Scott_Haynes)\
**Post date:** [June 24, 2013, 5:18pm UTC](https://community.cesium.com/t/terrain-demo/574/3 "2013-06-24T17:18:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Kevin\_Ring](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/kevin_ring/32/2003_2.png) [@Kevin\_Ring](https://community.cesium.com/u/Kevin_Ring)\
**Post date:** [June 24, 2013, 5:29pm UTC](https://community.cesium.com/t/terrain-demo/574/4 "2013-06-24T17:29:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Scott\_Haynes](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/scott_haynes/32/2063_2.png) [@Scott\_Haynes](https://community.cesium.com/u/Scott_Haynes)\
**Post date:** [June 24, 2013, 6:12pm UTC](https://community.cesium.com/t/terrain-demo/574/5 "2013-06-24T18:12:18Z")

</div>

I found the problem, and I have it working now. Thanks for the quick replies.

Scott

---

<div class="post-metadata">

**Author:** ![Scott\_Haynes](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/scott_haynes/32/2063_2.png) [@Scott\_Haynes](https://community.cesium.com/u/Scott_Haynes)\
**Post date:** [June 27, 2013, 1:14pm UTC](https://community.cesium.com/t/terrain-demo/574/6 "2013-06-27T13:14:48Z")

</div>

Is the Cesium.Viewer stable? If I switch my demos over to using the Viewer, should I build the latest sources?

Scott

---

<div class="post-metadata">

**Author:** ![Matt\_Amato](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/matt_amato/32/1993_2.png) [@Matt\_Amato](https://community.cesium.com/u/Matt_Amato)\
**Post date:** [June 27, 2013, 1:24pm UTC](https://community.cesium.com/t/terrain-demo/574/7 "2013-06-27T13:24:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Scott\_Haynes](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/scott_haynes/32/2063_2.png) [@Scott\_Haynes](https://community.cesium.com/u/Scott_Haynes)\
**Post date:** [June 27, 2013, 1:25pm UTC](https://community.cesium.com/t/terrain-demo/574/8 "2013-06-27T13:25:58Z")

</div>

Awesome, thanks.

Scott

---

<div class="post-metadata">

**Author:** ![Scott\_Haynes](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/scott_haynes/32/2063_2.png) [@Scott\_Haynes](https://community.cesium.com/u/Scott_Haynes)\
**Post date:** [June 27, 2013, 3:40pm UTC](https://community.cesium.com/t/terrain-demo/574/9 "2013-06-27T15:40:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Matt\_Amato](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/matt_amato/32/1993_2.png) [@Matt\_Amato](https://community.cesium.com/u/Matt_Amato)\
**Post date:** [June 27, 2013, 3:42pm UTC](https://community.cesium.com/t/terrain-demo/574/10 "2013-06-27T15:42:43Z")

</div>

Are there any errors in the console? How exactly are you adding the imagery layers?

---

<div class="post-metadata">

**Author:** ![Scott\_Haynes](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/scott_haynes/32/2063_2.png) [@Scott\_Haynes](https://community.cesium.com/u/Scott_Haynes)\
**Post date:** [June 27, 2013, 3:52pm UTC](https://community.cesium.com/t/terrain-demo/574/11 "2013-06-27T15:52:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Scott\_Haynes](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/scott_haynes/32/2063_2.png) [@Scott\_Haynes](https://community.cesium.com/u/Scott_Haynes)\
**Post date:** [June 27, 2013, 4:35pm UTC](https://community.cesium.com/t/terrain-demo/574/12 "2013-06-27T16:35:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Scott\_Hunter](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/scott_hunter/32/2006_2.png) [@Scott\_Hunter](https://community.cesium.com/u/Scott_Hunter)\
**Post date:** [June 27, 2013, 5:34pm UTC](https://community.cesium.com/t/terrain-demo/574/13 "2013-06-27T17:34:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Scott\_Haynes](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/scott_haynes/32/2063_2.png) [@Scott\_Haynes](https://community.cesium.com/u/Scott_Haynes)\
**Post date:** [June 27, 2013, 8:51pm UTC](https://community.cesium.com/t/terrain-demo/574/14 "2013-06-27T20:51:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Scott\_Haynes](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/scott_haynes/32/2063_2.png) [@Scott\_Haynes](https://community.cesium.com/u/Scott_Haynes)\
**Post date:** [June 27, 2013, 9:32pm UTC](https://community.cesium.com/t/terrain-demo/574/15 "2013-06-27T21:32:46Z")

</div>

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
