Action | URL | Notes |
---|---|---|
Get needed tools | ||
python | get | (recommend 3.8, have not worked with 3.9 yet) the python version used in the last line below has to be the same as what you use here on mac, might need to do: pyenv install 3.8.6 pyenv global 3.8.6 [sets 3.8.6 as the default] be sure node (windows and osx) or nodejs (linux) is installed be sure flex is installed (pip install flex) |
install panda3d | pip install panda3d [need 1.10.9 or more recent] | |
install emscripten | get | follow platform-specific notes |
get a copy of the panda3d build toolkit, specifically the webgl-port branch | git clone --branch webgl-port https://github.com/panda3d/panda3d.git | |
download a copy of the thirdparty tools | get | will be named webgl-editor-and-dependencies |
copy the thirdparty and editor directories from this download into <panda3d-webgl-port path>/ | be sure the libpython in thirdparty/emscripten-libs/python/lib matches the version of python you will use | |
if there is an 'embuilt' directory in <panda3d-webgl-port path>, delete it | this forces a build from scratch; you need this for a new build | |
copy freezify.py from <webgl-editor-and-dependencies path>/editor/ to your application directory | ||
Emscripten compile panda3d | ||
be sure flex and bison are installed | check with bison --version, flex --version
sudo apt install flex sudo apt install bison | |
cd to <panda3d-webgl-port path> | ||
./<emsdk path>/emsdk_env.sh | set up emscripten environment variables might need chmod+x emsdk_env.sh | |
Critical: be sure emscripten is in your PATH. Especially these:
<path to>/emsdk <path to>/emsdk/upstream/emscripten <path to>/emsdk/node/12.18.1_64bit/bin | ||
python makepanda/makepanda.py --use-png --use-jpeg --use-egg --use-zlib --use-freetype --use-bullet --no-openssl --use-direct --use-pview --use-gles2 --use-openal --use-python --use-vorbis --no-egl --target emscripten --outputdir embuilt --optimize 4 --threads 4 | no-png means let the browser use its own png processing. It works fine
threads argument is optional for faster build on faster machines there will be MANY warnings, but they are ok get lunch -- this will take a half hour or more | |
Emscripten compile your application | ||
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>] | eg 'models/wall.bam',... for PRELOAD list | |
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 | |
if you get an out of memory error in the JavaScript console, modify TOTAL_MEMORY= in freezify.py |