Open jo-chemla opened 1 year ago
Proof-of-concept from @OmarShehata on twitter.
WebMercatorViewport
extentThis would be super useful for a lot of people! Some more details from my process if it helps:
gltf-transform
, I needed to transform all the tiles back to the origin, while retaining their relative position gltf-transform optimize
(which does Draco compression I believe among lots of other things)Thanks to you I was able to create my own method of grabbing gmaps 3d tiles.
meshDownloader.cs
using System.Net;
using UnityEngine;
//attach this script to the Cesium3DTileset object
public class meshDownloader : MonoBehaviour
{
public string outputFolder = @"D:\temp\maps\";
public void idk()
{
// var baseObj = GameObject.Find("Cesium3DTileset");
var baseObj = gameObject;
int counter = 0;
//if outputFolder doesnt end with a backslash, add one,
if (outputFolder[outputFolder.Length-1] != '\\')
{
outputFolder += @"\";
}
for (int i = 0; i < baseObj.transform.childCount; i++)
{
var tile = baseObj.transform.GetChild(i).gameObject;
if (tile.activeSelf && tile.name.Contains(".glb"))
{
//download
using (var client = new WebClient())
{
Debug.Log(counter+".glb");
client.DownloadFile(tile.name, outputFolder+counter+".glb");
counter++;
}
}
}
}
}
meshDownloaderButton.cs
using UnityEditor;
using UnityEngine;
[CustomEditor(typeof(meshDownloader))]
public class meshDownloaderButton : Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector();
var myScript = (meshDownloader)target;
if (GUILayout.Button("download"))
{
myScript.idk();
}
}
}
MeshDownloader
script to the Cesium3DTileset
object.maxium screen space error
to 0 to get the highest quality tiles. This will take a heavy performance toll! It's better to use the default value if you want to make sure things work first.Show Tiles in Hierarchy
(important)You can merge the GLB files to 1 file with glTF Transform https://gltf-transform.dev/
gltf-transform merge *
Example coordinates: 53.496306, 9.9503333
One problem I'm still trying to solve is these gaps:
My theory is that these gaps are there because the meshes in the glb files are so far from the center of the scene. Blender uses floating point values to store positions, so the further from the center of the scene the meshes are, the less precise their position is stored.
I haven't been able to find a solution for this problem yet so if anyone who reads this has an idea, I'd love to know
Probably useful at some point, Google just released all its 2500 cities datasets as OGC/Cesium 3D-tiles at its GoogleIO-May2023 conference. The 3D-tiles standard is made to stream datasets - rather than download offline/merged 3D models - and is compatible through cesium libs with UnrealEngine, Unity, CesiumJS, Nvidia OmniVerse, deck-gl etc.
Note:
There might be an oss 3D-tiles downloader/cropper/merger lying around which would result in the same feature-set than MapsModelImporter - downloading all tiles within polygon/bbox extent (at a given zoom level, or all leaves from tileset) and merging them, based off of oslandia/py3dtiles or vcityteam/py3dtilers
CesiumJS Demo | google release post | cesium blog post