This article contains information about how to work with 3D vector tiles and Cesium.
For the purpose of visualisation of elevation model, another format can be used, so called Quantized 3D Mesh - the elevation is represented by either regular, but more commonly irregular triangle web.
Sources of 3D data
Have your own terrain data and convert them to 3D quantized mesh format - then you need a server to a) process the data and b) to serve them
Use data provided by the Cesium service
Having 3D tiles data source is only one part of the problem. The 3D tiles will help you just to draw the elevation, but one also needs to “drape” another data source over the elevation, such as the streets map, outdoor map or the satellite map. That way, you can see nice 3D shaped landscape.
Configuring Cesium map application
When building a web applications, you have several options and you probably know already, which libraries and build-stack you are going to use. You can find a lot of useful examples at the Sandcastle of the Cesium project. We will demonstrate, how to create 3D web mapping application based on the cesium-webpack-example
Step 1: Install and run minimal Cesium application using webpack
Then run the command, which should install all necessary dependencies
And after all necessary packages are successfully downloaded, you can start the development server, which will make it easy to develop a custom 3D mapping application
And open the link http://localhost:8080/ in your browser
Basic example with Cesium data sources will popup. Now let’s start hacking around this example. The sources are located in the
src/ folder, the file
src/index.js is of our main interest:
We will restructure the code, so it uses sources directing to MapTiler cloud services. Let’s start from scratch, delete all the code, maybe except for the imports
First we need to define the TerrainProvider instance
As second step, we need to define the ImageProvider - and we will use the URL reference to one of the Maptiler services, in this case, it will be the Outdoor map:
We now have to important data sources: the terrain and the imagery overlay. This can be now pluged-in to the application. This can be done, using very complex Cesium.Viewer class or much simplier Cesium.Widget class.
Don’t forget to add used classes, which is
CesiumTerrainProvider, UrlTemplateImageryProvider and the
CesiumWidget to the import statement. The node server will reload automatically every time you change the code.
Now we just have to zoom to desired location (e.g. Alps region), this is done with the help of the Camera object
The full example now looks like this: