Is it possible to modify the compiled output for WebGL from Unity to embed multiple viewers in a single page? A quick examination appears to suggest that everything is dependent on there being a single variable ‘Module’ where everything happens. This would seem to make it difficult to embed multiple independent WebGL based Unity players within a webpage.
I agree, the way emscripten sets this up currently by using a global “Module” variable probably makes this impossible right now. I will enquire with the emscripten devs if there is any plan to change this.
That said, even if this worked right now, I probably would not recommend it, due to the memory constraints we currently run into when trying to even get a single piece of WebGL content to work on a page.
FYI, I got a reply back from Mozilla. It seems that emscripten supports compiler flags which would make this possible. The way we currently embed content into the web page would not work with that, however. Longer term, I want to make a very simple embedding API like UnityObject2.js for the web player, where you can just call a JavaScript function to create the canvas element with the Unity WebGL content, of which you could have multiple on the page.
However, this is not a priority right now. So for the time being, your best bet is probably using iframes.