draco
draco copied to clipboard
WebGL build support in Unity
I'm very interested in the Draco Unity plugin and would like to use it in a project. Before starting I have a couple of questions:
- The project is meant to run in a browser, will I be able to use the Draco plugin for Unity for that or should I use the one for JavaScript?
- I'm running Ubuntu 16.04 and after importing the plugin and bunny.drc file, I'm getting a DllNotFoundException. The README.md file only mentions support for Windows, iOS and Android. Is it in any way possible to use the plugin on Ubuntu 16.04?
Thank you in advance for your help.
I've done some more research and have been able to generate answers for my questions. I will post them here if anyone has similar needs:
- Unity is able to build for WebGL, however, when I'm opening the project I get an error stating:
uncaught exception: abort("To use dlopen, you need to use Emscripten's linking support, see https://github.com/kripken/emscripten/wiki/Linking")
I currently suspect this is an issue in Unity's build system and I have replied to a forum post about a similar issue and hope for aid there.
- You can compile the Draco plugin for the Unity3D beta for Ubuntu 16.04. I downloaded the source code and followed the compile instructions for Windows. After the compilation I copied the file libdracodec_unity.so into my Unity project in the folder Assets/Plugins.
I will leave the issue open until I have a definite answer for my first question,
Hi @TobiasMorell Unfortunately we have not been able to get Unity to load a Draco plug-in in the browser as well. I will keep this open as an enhancement. Hopefully in the future we will figure out how to get this to work.
@FrankGalligan thank you for your reply. I haven't had time to check it myself, but I was thinking that it might be possible to use the readymade JavaScript compilation instead. I will examine myself when I have some spare time and post my discoveries here.
If you want to check it out you can find more information about interfacing with browser scripting.
Thanks @TobiasMorell
Hi @FrankGalligan I spent some time this morning trying to add a JavaScript library. I tried to things, none of which were successful:
- Use the pre-built emscripten library. My problem here was that it does not work like the Unity plugin, i.e. it does not contain the function DecodeMeshForUnity.
- Build a JavaScript version of the plugin with Emscripten. I tried to mess around with the make-files, hoping that it would allow me to output a JavaScript-file instead of the .so file that it does now. I feel like this might be a decent solution, but my knowledge about CMake and Make is very limited. Would it be possible to add a make-target in the final step that compiles everything with Emscripten instead of gcc?
@tomfinegan Can you help @TobiasMorell out with cmake?
@TobiasMorell:
I'm assuming you already have the emsdk installed, and that an Emscripten build of Draco works for you in its standard form. In other words, this should already work:
$ cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=/path/to/Emscripten.cmake path/to/draco && make
Assuming the above is working, what happens if you run cmake and build Draco like this?
$ cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=/path/to/Emscripten.cmake -DBUILD_UNITY_PLUGIN=1 -DENABLE_JS_GLUE=0 && make
@TobiasMorell
Note, the second step is likely not enough, but would be a starting point. Glue code and IDL are likely needed for DracoToUnityMesh, ReleaseUnityMesh(), and DecodeMeshForUnity(). I can look into hooking this up next week.
Hi @tomfinegan. Thank you for your help.
Both commands ran to completion without any errors. However, it seems that the second command outputs both the libdracodec_unity.so file and the draco_encoder.js and draco_decoder.js. I was not able to find a js-version of the Unity-plugin after the build. Please let me know if there's anything I can do to help.
Hi @tomfinegan. Have you had time to look into this issue?
Only enough time to confirm that Draco needs IDL and wrapper code for the Draco Unity Plugin for this to progress further. I'm going to flip the assignment of this back to @FrankGalligan, at least for now, as I don't have time to investigate this more deeply at present.
Hey guys, any updates about this? would like to contribute to this if any "direction" was given in how to complete this @FrankGalligan @tomfinegan
My forked Unity package is a much improved version and works in WebGL as well: https://gitlab.com/atteneder/DracoUnity It's a shame my PR #540 goes unoticed for months now.
I think I am running into this also, anyone have ideas?
@tomfinegan have you had time to look at @atteneder's PR referenced above?