huxingyi / dust3d

Dust3D is a cross-platform 3D modeling software that makes it easy to create low poly 3D models for video games, 3D printing, and more.
https://dust3d.org/
MIT License
2.99k stars 223 forks source link

Experiment WebAssembly #155

Closed huxingyi closed 1 year ago

huxingyi commented 1 year ago

Install emsdk:

$ git clone https://github.com/emscripten-core/emsdk.git
$ cd emsdk
$ git pull
$ ./emsdk install 3.1.25
$ ./emsdk activate 3.1.25
$ em++ --version

Build Qt6 as normal host version:

$ gunzip qt-everywhere-src-6.5.2.tar.xz
$ tar xvf qt-everywhere-src-6.5.2.tar
$ cd qt-everywhere-src-6.5.2
$ ./configure
$ cmake --build . --parallel

Build Qt6 as WebAssembly version:

$ mkdir qt-everywhere-src-6.5.2-webassembly
$ tar xvf qt-everywhere-src-6.5.2.tar -C ./qt-everywhere-src-6.5.2-webassembly
$ cd /Users/jeremy/Repositories/emsdk
$ ./emsdk install 3.1.25
$ ./emsdk activate 3.1.25
$ cd /Users/jeremy/Repositories/qt-everywhere-src-6.5.2-webassembly/qt-everywhere-src-6.5.2
$ source /Users/jeremy/Repositories/emsdk/emsdk_env.sh
$ ./configure -feature-thread -qt-host-path /Users/jeremy/Repositories/qt-everywhere-src-6.5.2/qtbase -platform wasm-emscripten -prefix $PWD/qtbase
$ cmake --build . --parallel -t qtbase -t qtdeclarative -t qtimageformats -t qtsvg

Build Dust3D WebAssembly:

$ cd /Users/jeremy/Repositories/dust3d/application
$ source /Users/jeremy/Repositories/emsdk/emsdk_env.sh
$ /Users/jeremy/Repositories/qt-everywhere-src-6.5.2-webassembly/qt-everywhere-src-6.5.2/qtbase/bin/qmake
$ make -j`sysctl -n hw.logicalcpu`

Run local server on application folder:

SimpleHTTPServer_SharedArrayBuffer.py:

#!/usr/bin/env python3
from http.server import HTTPServer, SimpleHTTPRequestHandler, test
import sys

class SimpleHTTPServer_SharedArrayBuffer (SimpleHTTPRequestHandler):
    def end_headers (self):
        self.send_header('Cross-Origin-Opener-Policy', 'same-origin')
        self.send_header('Cross-Origin-Embedder-Policy', 'require-corp')
        SimpleHTTPRequestHandler.end_headers(self)

if __name__ == '__main__':
    test(SimpleHTTPServer_SharedArrayBuffer, HTTPServer, port=int(sys.argv[1]) if len(sys.argv) > 1 else 8000)
$ python3 SimpleHTTPServer_SharedArrayBuffer.py

Notes:

TODOs:

image Screenshot 2023-08-19 at 11 32 39 pm Screenshot 2023-08-20 at 9 13 20 am Screenshot 2023-08-20 at 3 49 52 pm