F3D can be built in WebAssembly using emscripten in order to embed it into a web browser. It is used by our web viewer and covers most of the libf3d public API. A simple example is available here.
This guide is describing how to build VTK and F3D with emscripten using Docker on Linux or Windows.
While it's possible to setup an emscripten cross-compiling toolchain locally, it's easier to use Docker and the provided npm scripts.
Install Docker and npm locally.
From the root of the repository run the following command:
npm run buildBy default, the latest Docker image is pulled automatically, but you can force a specific Docker image by setting the environment variable F3D_DOCKER_TIMESTAMP to a timestamp (see .github/workflows/versions.json file)
It's also possible to use podman instead of docker, please set the F3D_DOCKER_CLIENT environment variable to podman.
On completion, a directory dist is created containing the artifacts (f3d.js and f3d.wasm).
assimp, occt, webifc and draco plugins are automatically included.
From the root of the repository, after the build step, run the following command:
npm testIt's possible to generate a local package to use in other javascript projects. Run the following command:
npm packIt will build and generate a f3d-vX.X.X.tgz file.
This file can be imported into your project:
npm install f3d-vX.X.X.tgz