Namespace Mapbox.Unity.MeshGeneration.Factories
Classes
AbstractTileFactory
Factories Factories corresponds to Mapbox Api endpoints for the most part.Terrain factory uses terrain rgb api, Image factory uses raster image api and vector tile factory uses vector data api. Only exception to this at the moment is Directions factory, which is a monobehaviour in Drive demo scene but we’ll probably rework that in the future as well. Factories do the api calls.They are responsible for reporting progress and logging/reporting any network issue. They can also keep track of tiles if necessary (i.e.update/refresh data after initial creation) Factories processes the received data in different ways. Terrain factories creates the mesh from the received data (or a flat terrain depending the settings) MapImage factory applies received image to tile game object. Vector Tile Factory deals with a much more complex and detailed data compared to other two so it doesn’t do the whole processing itself and uses some subclasses (LayerVisualizers) to do it. Creating a custom factory is a good idea if you want to fetch raw data and process is in a totally different custom way, like creating terrain and then cut off water areas from terrain mesh. Vector Tile factory, for example, is built to be flexible and work with multiple vector layers. But if you don’t need that all, you can create a custom version of it and process what you need in a much more concrete and performant way. Another example here would be custom terrain mesh. Current terrain factories work with a custom sized grid and apply height data on that. By creating a custom terrain factory, you can have a custom mesh instead of a grid, optimize and minimize vertex count etc.
DirectionsFactory
MapImageFactory
TerrainFactoryBase
TileProcessFinishedEventArgs
VectorTileFactory
Vector Tile Factory Vector data is much more detailed compared to terrain and image data so we have a different structure to process vector data(compared to other factories). First of all, how does the vector data itself structured? Vector tile data contains 'vector layers' as immediate children.And then each of these vector layers contains a number of 'features' inside.I.e.vector data for a tile has 'building', 'road', 'landuse' etc layers. Then building layer has a number of polygon features, road layer has line features etc. Similar to this, vector tile factory contains bunch of 'layer visualizers' and each one of them corresponds to one (or more) vector layers in data.So when data is received, factory goes through all layers inside and passes them to designated layer visualizers.We're using layer name as key here, to find the designated layer visualizer, like 'building', 'road'. (vector tile factory visual would help here). If it can't find a layer visualizer for that layer, it'll be skipped and not processed at all.If all you need is 1-2 layers, it's indeed a big waste to pull whole vector data and you can use 'Style Optimized Vector Tile Factory' to pull only the layer you want to use.