Tuesday, December 15, 2020

3D Models with 3D Terrain

Version 2 of the Mapbox GL JS mapping library includes the option to view the world's terrain in 3D. Mapbox is also very good at displaying 3D models. Combine the new 3D terrain with a 3D model and you can produce a very realistic looking 3D map. For example check-out this 3D Map of the Golden Gate Bridge.

I had a little look at the source code on the 3D Map of the Golden Bridge and it appears to be a fairly straightforward combination of mixing two demo maps from the Mapbox GL documentation. At the heart of this map is the Add a 3D Model example map mixed with the Add 3D Terrain to the Map demo map.

The San Francisco map above displays a 3D model of the Golden Gate Bridge using the glTF file format for 3D scenes and models. This is a well used format for 3D models and there are plenty of freely available glTF files of 3D models on the internet. If you want to experiment with adding other 3D models to Mapbox GL then you really are spoiled for choice of freely available 3D models. 

For example try Sketchfab. If a Sketchfab model has a download button then you can download the model as a glTF file. You only then need to copy the code for Add a 3D Model and switch the glTF link to your downloaded glTF file (just remember to change the latitude and longitude to add the model in the correct location).

No comments: