Panda3D WebGL Port!

While compiling CPython to ASM.js does work, I’m not convinced that it’s the most optimal solution - we’re essentially running a VM inside of a VM, and the CPython VM is really big. I’ve been looking around for Python-to-JS transpilers that will help make a lighter and faster Panda build.

The most promising one is I found is Brython, which seems in active development, and has excellent interoperability with JavaScript - you can directly call JavaScript functions from Python, and Python objects are really just decorated JavaScript objects.

So I dusted off interrogate’s C binding generator, and created an FFI tool to use emscripten’s FFI to spit out JavaScript bindings for Panda3D. Now I can call Panda3D functions from JavaScript and therefore Brython:
rdb.name/brython-panda3d.png

Brython tries to be a drop-in replacement for JavaScript, so you’re even able to put this in an HTML page:

<script type="text/python">
from panda3d.core import *
....
</script>

Of course, we would provide a code path to compile to obfuscated JS directly for production use.

There’s still some way to go (overloaded functions are not yet handled, and keyword arguments, etc.), but I can call most Panda classes and functions just fine. It’s promising so far that it compiles and loads so quickly.