Interest in cross compiling to webassembly
I'm very interested in using libigl for interactive simulations and posting them online. Supporting webassembly and webgl through emscripten could make any application linking against this library more accessible.
I've created a branch which can do this with minimal changes. A few #ifdef, extracting the main loop, disabling comiso and embree, disabling popen and disabling wireframe mode.
If there is interest in this, I can contribute my changes as a few PRs.
This is my branch: https://github.com/bwrsandman/libigl/tree/emscripten
Here is the webassembly interactive draw mesh tutorial: https://bwrsandman.github.io/libigl

That is really cool. We've considered working on a emscripten version a while back (in fact I had a branch myself enabling this), but we never had time to polish it out. Now our new python bindings come with a WebGL viewer as well, so we don't have a strong incentive to work on an emscripten port.
That being said if the changes are minimal I'd be interested in seeing a PR with the list of changes. Not sure if we'd be able to merge them, but I can at least take a look. You'd need to base it off of the dev branch though, since master is now a bit old.
I rebased to dev. It get compile errors in eigen which I didn't have before. Not sure if its already known.
libigl/include/igl/arap_rhs.h:38:12: error: no template named 'SparseCompressedBase' in namespace 'Eigen'
Eigen::SparseCompressedBase<DerivedK>& K);
~~~~~~~^
libigl/include/igl/arap_dof.cpp:227:3: error: no matching function for call to 'arap_rhs'
arap_rhs(V,F,V.cols(),data.energy,K);
Here are the changes from dev. https://github.com/libigl/libigl/compare/dev...bwrsandman:emscripten-dev
Hi @bwrsandman the version of Eigen used in masterand dev differs.
Set the cmake variable LIBIGL_EIGEN_VERSION to 3.3.7 should do the trick.
Thanks. That seems to have fixed it.
Is there an option to not use SIMD as webassembly simd is a bit different from emmintrin.h?
I forked libigl and have an inline/header-only build in event-horizon-webassembly that builds to desktop and the web with a "dear imgui" menu and the bunny mesh.
set "USE_EMSCRIPTEN = 1" in the makefile for a web build, "USE_EMSCRIPTEN = 0" for a desktop build
It's loosely based on sketchpunk/FunWithWebGL2 I hit a wall getting barycentric wireframe creation - something to do with the number of columns = 4. The shader implementations expect a "w" vertex paramater as well as x,y,z to do it's thing, but I've no idea how to proceed. I hit an eigen assert that I don't understand.
set "USE_BARYCENTRIC = 1" in the makefile for a barycentric wireframe build, "USE_BARYCENTRIC = 0" otherwise
I got it working !
Now if somwone who understands uniforms in WebGL can step in to wire up the face and edge colours, no backface culling, probably more that I missed, your feedback is welcome!