Panda3D WebGL Port!

Update: brython seems to be a no-go, since it doesn’t support reference counting, which we need in order to free objects from the emscripten heap, and I can’t spare the time to add this feature.

The only approach that is actually proven to work so far is emscripten-compiled CPython, so I’m back to that. The Python code is frozen using pfreeze and then compiled using emscripten, with a custom main function and loader. It works well, actually, and with a lot of work I managed to make the process fairly efficient, though it’s still a huge amount of code.

It may be interesting in the future to consider Nuitka, which is a compiler that compiles CPython bytecode to actual C code (rather than embedding Python bytecode, although it still depends on CPython). It seems to work well with Panda code on the desktop at least. It may (or may not) offer performance and size benefits. To be investigated.

In any case, I’ve done further work on the WebGL port, making it more robust and adding more features. Here’s another demo showing off pointerlock mode to achieve FPS-style controls, using a modified version of cn04’s loader with tobspr’s design - written in Python!

rdb.name/panda3d-webgl/simple_fps.html
(Don’t mind the crappy graphics or the sloppy controls - there’s still a lot of things to fix, I mainly slapped this together to test pointerlock and the load process.)

For the early adopters I’ve updated the build dependencies (includes CPython patch). Let me know if you want the freezify.py front-end that I used to produce the online demos.