Hmm. Not getting any errors now except “TypeError: PyType_Ready(ParticleSystemManager)”. But nothing else either. Have to check my code more carefully.
That’s part of panda3d.physics; I am not sure what that could signify, but I suggest commenting out the part where you load that module for now to see if you can get a simpler Panda program working.
python (recommend 3.8, have not worked with 3.9 yet): Python Release Python 3.8.6 | Python.org
NOTE: the python version installed on your system has to be the same as what you use here
get a copy of the panda3d build toolkit: GitHub - panda3d/panda3d at webgl-port
NOTE: download the zip, don’t use the clone as it will bring all of panda3d and not what you want
copy the thirdparty and editor directories from this download into <panda3d-webgl-port path>/
copy freezify.py from <webgl-editor-and-dependencies path>/editor/ to your application directory
Emscripten compile python
terminal window
cd to <py source path>
./<emsdk path>/emsdk_env.sh
enter this on the console (disable-toolbox-glue is OSX only):
BASECFLAGS=-m32 LDFLAGS=-m32 emconfigure ./configure --without-threads --without-pymalloc --disable-shared --without-signal-module --disable-toolbox-glue --disable-ipv6
make
NOTE: might be some errors, but look for libpython3.8.a; if it got that far, probably ok.
copy libpython3.8.a to <panda3d-webgl-port path>/thirdparty/emscripten-libs/python/lib and delete any other files there
copy all files in the python source Include directory to <panda3d-webgl-port path>/thirdparty/emscripten-libs/python/include/python3.8/
Emscripten compile panda3d
cd to <panda3d-webgl-port path>
./<emsdk path>/emsdk_env.sh
python makepanda/makepanda.py --use-png --use-jpeg --use-egg --use-zlib --no-freetype --use-bullet --no-openssl --use-direct --use-pview --use-gles2 --use-openal --use-python --use-vorbis --no-egl --use-freetype --optimize 4 --outputdir embuilt --target emscripten --no-egl --use-freetype
NOTE: might error out, but if you get to 92%, probably ok. Make sure there are core.so and direct.so in the embuilt/panda3d directory.
Emscripten compile and link your app
edit these lines in freezify.py
THIRDPARTY_DIR = “/<path to>/panda3d-webgl-port/thirdparty/emscripten-libs”
PY_MODULE_DIR = “/<path to>/Python-3.8.6/Modules”
PY_STDLIB_DIR = “/<path to>/Python-3.8.6/lib”
PANDA_BUILT_DIR = “/<path to>/panda3d-webgl-port/embuilt”
PRELOAD_FILES = [<quoted comma-separated list of EVERY asset in your application with directories such as “models/wall.bam”>]
either rename your app starting file to main.py or edit the freezer.addModule line to be your file
cd to your application directory
python3.8 -OO freezify,py [double cap-O]
NOTE: I also changed all the library references in freezify.py to be .o or .so as appropriate. And, I took a list of the .o files in the Modules directory and put it into PY_MODULES. Then I got lists of .a and .bc files in embuilt/lib and put them into PANDA_LIBS and PANDA_MODS. Lots of other little edits to freezify, but I assume they will be in the new source freezify.py that you provide.
I managed to compile everything but I’m also getting the “no module found” error. In fact, I’m getting it importing pretty much anything, not just panda3d.core. I’m going to continue investigating tomorrow.
I never answered about enabling applications/wasm as a MIME type for Apache. I know about MIME types and how to set them for Apache and other servers, but if my program idea ever gets far enough, some very future version of this would be deployed at schools or other education organizations (hence the dynamic content), and I don’t want to require anything more than “unzip in a server directory”. This sounds naive, but intentionally so. That is the goal for now, no server customization.
I struggled to get the linked-in Python modules to be recognised properly, then I realised it would be easier to just modify the Python build scripts to link all modules into libpython3.8.a, so I did that. To save you some time, I updated this archive with the new Python build, which also includes the patch I made to the Python source and the command I used to build it: http://rdb.name/webgl-editor-and-dependencies.zip
I also committed a bunch of things to add WebGL 2 support, and change the build system to use .o files instead of .bc, so I recommend grabbing the latest source from the webgl-port branch on Git.
I built Panda with the --static flag, but I don’t think that doing so has any advantage (emscripten effectively forces everything to be static linking one way or the other). You may however need to adjust freezify.py to use the .o files instead of .a though, unless you also build with --static.
I needed to force an explicit call to init_libpnmimagetypes to allow loading jpg/png files, and init_libwebgldisplay to force the display module to load, but maybe this is just because of the use of --static. This required a change to the Panda source (which I also committed).
I recommend running python3.8 -OO freezify.py to optimise the Python modules for a slimmer build.
Thank you very much. I especially like putting all modules in to libpython. Going forward, is there a script/kit developers can use to build their own libpython with everything in it to use a different version of python (step 2 in my script), or better to just make available the different versions of the library?
Building now. Have a lot of edits for freezify.py.
and defined them as extern void. They are NOT in the PRELOAD (I removed them for testing), I will try to add them to PRELOAD. But it can’t be that every image has to be preloaded, I thought that was just for efficiency. So, something else I need to change to get images loaded?
My dmm_freezify is on my server.
All the asset directories such as floors are also on my server, of course.