Challenges with Integrating Cesium for WebGL: Seeking Solutions

So I tried setting up source codes for Cesium Native so as to build it in Unity for WebGL, but this did not work out. It appears that the issue is Unity-related as well as the way they generated source code for their native library. Unity does not have any interface to separate/mark C/C++ source files for multiple plugins, therefore it basically imports all headers in single folder when trying to compile using emscripten.

This cannot work with Cesium native code because they have named many header files exactly same in various folders. Also, third party sources that Cesium native depends upon also have many headers with same names. This means that separate libraries have to be compiled from their source code as well as for third party dependencies using emscripten and then add compiled libraries to our Unity project.

It will still require quite some time to setup all the library projects and then first compile third-party dependencies and, later, the actual Cesium native sources in WASM libraries so that they can than be used as native plugins for WebGL in our app.

Has anyone faced a similar issue? Curious how we could resolve this in a simpler and more time-efficient manner.

We haven’t tried compiling our native code to WASM, and we expect there will be some challenges. We’re interested to hear how you go, though!

1 Like

Hi,

I came across with this article: https://devpost.com/software/geoforall-simplifying-3d-geospatial-metaverse-creation
which states:
Our team discovered that no precedent existed for compiling Cesium’s native code to WebAssembly (WASM). We identified issues with identical header file names across various folders in Cesium’s native code and its third-party dependencies. This necessitates separate library compilations using Emscripten, along with the integration of these compiled libraries into our Unity project.”

It seems that it is possible to build webgl from Cesium-for-Unity after these modifications. There are many eager unity developers (me also) that have been asking about this webgl-possibility so it would be nice to hear some more information about the process of precompiling separate libraries with emscripten and how to integrate this into Unity. Also some example or demo would be nice!

So far what I have investigated I was thinking that if I integrate the emcsripten into cmake and instead of creating CesiumForUnityNative-Runtime.dll it would create CesiumForUnityNative-Runtime.a that could be used in webgl build. I also wonder if Reinterop will generate the binding layers that also works in webgl or is there some modifications to be done and also what might be the modifications needed in C# side. What do You think? Probably I am missing something here for example should i first compile external libraries or something else with emscripten before that cmake build process?

1 Like

Yes, after the research our team did, we discovered it is in fact possible but no one has gone down the path yet. While recently we’ve been mainly focused on deploying V1 of our no code digital twin creation tool (ie use/leverage Cesium and other GIS data layers without any code or game engine necessary), we are currently researching this possibility and hope to develop a solution that we can release for the whole Cesium ecosystem. If you want to collaborate on something like this, please reach out to us! ethan@agoraworld.io

2 Likes

Excuse me, I’m also trying to package Cesium for Unity for the web, and I’m also trying to deploy Emscripten using the ideas you mentioned, but packaging in the /native/ folder has been unsuccessful. Have you had any success utilizing this idea or is there another solution?

Hi! Currently Cesium does not support WebGL for Cesium for Unity. Our team at Agora World is currently investigating this and have the intention of building and releasing the solution for the Cesium community. I will make sure to share when we have a solution working. If you want to collaborate please reach out!

1 Like