# glTF to 3D Tiles converter optimization

**URL:** <https://community.cesium.com/t/gltf-to-3d-tiles-converter-optimization/25647>\
**Category:** 3D Tiles\
**Created:** [July 26, 2023, 6:34pm UTC](https://community.cesium.com/t/gltf-to-3d-tiles-converter-optimization/25647 "2023-07-26T18:34:57Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![yadu66](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/yadu66/32/12649_2.png) [@yadu66](https://community.cesium.com/u/yadu66)\
**Post date:** [July 26, 2023, 6:34pm UTC](https://community.cesium.com/t/gltf-to-3d-tiles-converter-optimization/25647/1 "2023-07-26T18:34:57Z")

</div>

I’m new to 3D geometry and WebRendering of 3d objects.

So, I came across a glTF to 3d Tile converter which seems to be taking up a lot of space post conversion. I don’t exactly understand the reason for the inefficiency and this library accepts only Embedded glTFs.

The library’s link : [https://github.com/xuzhusheng/gltf-to-3d-tiles](https://github.com/xuzhusheng/gltf-to-3d-tiles)

It would be appreciated, if someone can help me optimize the library and provide any insights on how to make it efficient. Or, any other library which is efficient and useful for my use case, as I will be rendering it on CesiumJS.

Thank you!

---

<div class="post-metadata">

**Author:** ![Marco13](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/marco13/32/2757_2.png) [@Marco13](https://community.cesium.com/u/Marco13)\
**Post date:** [July 26, 2023, 6:55pm UTC](https://community.cesium.com/t/gltf-to-3d-tiles-converter-optimization/25647/2 "2023-07-26T18:55:52Z")

</div>

It is not entirely clear what the goal of the conversion is.

When you have a large and complex glTF asset, and want to convert it into a 3D Tiles tileset so that it can be streamed to clients efficiently, then you can upload it to [Cesium ion – Cesium](https://cesium.com/platform/cesium-ion/) - it will do all the tiling and optimization work.

The library that you linked to does not seem to do anything like this. It looks like it is mainly generating a `tileset.json` file for a given input. (And… if it only accepts _embedded_ glTF assets, then this is probably not ideal: Embedded assets usually have a considerable overhead in terms of the file size. In most cases, you should use a GLB). The task to generate a `tileset.json` for given tile content has recently also been requested in the 3D Tiles tools repository, and there is a _draft_ PR with that functionality at [Generate tileset JSON from content files by javagl · Pull Request #51 · CesiumGS/3d-tiles-tools · GitHub](https://github.com/CesiumGS/3d-tiles-tools/pull/51) - maybe you want to give it a try.

---

<div class="post-metadata">

**Author:** ![yadu66](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/yadu66/32/12649_2.png) [@yadu66](https://community.cesium.com/u/yadu66)\
**Post date:** [July 27, 2023, 9:53am UTC](https://community.cesium.com/t/gltf-to-3d-tiles-converter-optimization/25647/3 "2023-07-27T09:53:46Z")

</div>

Hi, Thanks for replying and reference.

We are building a product with open source libraries, hence Cesium Ion is out of the picture. The goal of the conversion is to load big gltf models in cesiumJs.

I did tryout tileset-json-creation branch from 3d-tiles-tools, It is creating a tileset for provided input glb file, but just wanted to understand, if the glb file is huge and complex how and on what basis we have to slice the glb file, so that we can load the tileset based on the camera’s perspective.

---

<div class="post-metadata">

**Author:** ![Marco13](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/marco13/32/2757_2.png) [@Marco13](https://community.cesium.com/u/Marco13)\
**Post date:** [July 27, 2023, 4:18pm UTC](https://community.cesium.com/t/gltf-to-3d-tiles-converter-optimization/25647/4 "2023-07-27T16:18:50Z")

</div>

> It is creating a tileset for provided input glb file, but just wanted to understand, if the glb file is huge and complex how and on what basis we have to slice the glb file, so that we can load the tileset based on the camera’s perspective.

Yes, this command-line functionality is _only_ intended as a small convenience tool for people who quickly want to “wrap” a `tileset.json` around an existing glTF asset, without having to do things like the bounding box computation manually.

When you talk about a “huge and complex” GLB file, and the goal of visualizing that “based on the camera’s perspective”, then this sounds like task that has to be done by a tiler.

There could be “simple” approaches for “simple” inputs that may already yield useful results. For example: One could take the glTF asset, and put each `mesh` (or each `mesh.primitive`) into its own glTF file, and then combine these glTF files into a single tileset JSON. This would already allow you to load parts of the tileset, based on the viewpoint. But … what if there is only one `mesh`? Then the mesh _geometry_ has to be split into multiple parts. This can already be tricky. And if the mesh is very complex, then you’d not only like to _split_ it into multiple parts, but also _simplify_ the mesh and create a LOD hierarchy…

I cannot give any recommendations for open-source libraries for this task, because there are too many degrees of freedom for the type and structure of the input data, too many degrees for optimization of the output data, and too many factors (and engineering questions) that affect how to most sensibly produce good 3D Tiles tilesets.

---

<div class="post-metadata">

**Author:** ![yadu66](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/yadu66/32/12649_2.png) [@yadu66](https://community.cesium.com/u/yadu66)\
**Post date:** [July 28, 2023, 5:00am UTC](https://community.cesium.com/t/gltf-to-3d-tiles-converter-optimization/25647/5 "2023-07-28T05:00:35Z")

</div>

Thank you for your insights,  
will keep in mind about these points while writing a tiler.

Is there any way that I can use Cesium native git repository to write 3d tiles using Cesium3DTileWriter and CesiumGltfReader?

---

<div class="post-metadata">

**Author:** ![Marco13](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/marco13/32/2757_2.png) [@Marco13](https://community.cesium.com/u/Marco13)\
**Post date:** [July 28, 2023, 2:32pm UTC](https://community.cesium.com/t/gltf-to-3d-tiles-converter-optimization/25647/6 "2023-07-28T14:32:36Z")

</div>

> [@yadu66](#):
>
> Is there any way that I can use Cesium native git repository to write 3d tiles using Cesium3DTileWriter and CesiumGltfReader?

I’m not sure whether this a technical or “legal” question. But the `cesium-native` repository is open source, published under the Apache-2.0 license, and can be used (via CMake) in any C/C++ project.

---

<div class="post-metadata">

**Author:** ![yadu66](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/yadu66/32/12649_2.png) [@yadu66](https://community.cesium.com/u/yadu66)\
**Post date:** [July 31, 2023, 4:56am UTC](https://community.cesium.com/t/gltf-to-3d-tiles-converter-optimization/25647/7 "2023-07-31T04:56:14Z")

</div>

It was a technical question, my apologies for not asking clearly.

I meant can we use Cesium-native for gltf to 3d tile conversion?

---

<div class="post-metadata">

**Author:** ![Marco13](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/marco13/32/2757_2.png) [@Marco13](https://community.cesium.com/u/Marco13)\
**Post date:** [July 31, 2023, 5:19pm UTC](https://community.cesium.com/t/gltf-to-3d-tiles-converter-optimization/25647/8 "2023-07-31T17:19:20Z")

</div>

The `CesiumGltfReader` and `Cesium3DTileWriter` libraries _could_ be small building blocks for such a conversion.

With the `CesiumGltfReader`, you can read glTF assets and receive them as the data structures that are defined in the `CesiumGltf` library. And you can create new glTF assets using these classes, and write them into files with the `CesiumGltfWriter` (these could basically be the “tile contents”).

With the `Cesium3DTiles` library, you can build a 3D Tiles tileset in memory, and with `Cesium3DTileWriter`, you can write these structures to files (to eventually create the `tileset.json`).

But note that “reading input data” and “writing output data” are only _very_ tiny fragments of a proper tiler. The process of subdividing and simplifying the geometry data that was read from the glTF would be the most challenging part here (and you’d probably create a library with custom data structures for that, depending on how sophisticated that is supposed to be).

---

<div class="post-metadata">

**Author:** ![yadu66](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/yadu66/32/12649_2.png) [@yadu66](https://community.cesium.com/u/yadu66)\
**Post date:** [August 1, 2023, 9:35am UTC](https://community.cesium.com/t/gltf-to-3d-tiles-converter-optimization/25647/9 "2023-08-01T09:35:31Z")

</div>

Thank you for your support on this issue. We will try to write library using the insights you have provided.
