This repository contains source codes for the article on Habr about different methods to build wasm-module from c++, AssemblyScript and Rust. These modules build the Delaunay triangulation of the plain. We use a port of this algorithm.
It requires Emscripten
Create directory \output\libs\ to store temporary build files. Next build object files
emcc .\delaunay.cpp -o output\libs\delaunay.o -c
emcc .\bvh.cpp -o output\libs\bvh.o -c
Finally, build the module
emcc .\delaunay_api.cpp output\libs\delaunay.o output\libs\bvh.o -o output/delaunay.js -lembind -s MODULARIZE -s EXPORT_NAME=delaunay -s ALLOW_MEMORY_GROWTH=1 -Oz
It requires AssemblyScript
asc assembly/delaunay_api.ts -o build/delaunay.wasm --bindings esm -O --converge --noAssert
It's possible to add the additional parameter --uncheckedBehavior always. This will speed up the module at nearly 20%.
It requires wasm-pack
wasm-pack build
Here is an example applicarion, which use the module from the Rust.
./python_wasm/delaunay_wasm.py contains an example of the Python class, which loads the module from the Rust by using Wasmer.