@splinetool/modelling-wasm
Advanced tools
Comparing version 0.9.93 to 0.9.96
{ | ||
"name": "@splinetool/modelling-wasm", | ||
"version": "0.9.93", | ||
"version": "0.9.96", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
# modelling-wasm | ||
## Description | ||
This sub-repo contains all of the code for the subdivision surface modeling tools. It is largely comprised of C++ code that is compiled to WebAssembly. The `web` folder is for prototyping / testing in an isolated environment. | ||
A subdivision surface is represented by the `spl::SubdivisionSurface` class. Internally, this class actually maintains two different, interlinked data structures. The first is a customized version of the `pmp::Surface_mesh` class. This class serves as the low-level, halfedge mesh representation. Any topological changes / edits are made on this data structure and then propagated to the second data structure, which is an `OpenSubdiv::Far::TopologyRefiner`. This is necessary because internally, OpenSubdiv uses its own custom representation to accelerate the mesh refinement process. | ||
While all of this "back-and-forth" cross-talk between different representations might seem like a lot of work (read: slow), it is actually quite optimized. We follow a similar procedure to the one titled "custom factory for direct conversion," outlined in the [OpenSubdiv documentation](https://graphics.pixar.com/opensubdiv/docs/far_overview.html). Basically, there is a custom "conversion" class in `conversion.h` that is specifically designed to convert a `pmp::Surface_mesh` instance into the equivalent OpenSubdiv data structure. | ||
## References | ||
- [Emscripten and Ninja](https://github.com/emscripten-core/emscripten/issues/10412) | ||
- [Emscripten and C++ Starter CMake Project](https://gist.github.com/WesThorburn/00c47b267a0e8c8431e06b14997778e4) | ||
- [OpenSubdiv Documentation](https://graphics.pixar.com/opensubdiv/docs/intro.html) | ||
## Dependencies | ||
Right now, this project has the following dependencies: | ||
- OpenSubdiv (C++) | ||
- PMP (C++) | ||
And for the prototype web app: | ||
- Three.js | ||
- OrbitControls (part of the Three.js `examples` folder) | ||
- BufferGeometryUtils (same as above) | ||
- TransformControls (same as above) | ||
OpenSubdiv and PMP are both submodules that must be initialized after cloning this repository (see notes below). | ||
## Installation | ||
Install the git submodules needed for this repo with: `git submodule update --init --recursive`. The only submodules at the moment are PMP and OpenSubdiv. | ||
#### MacOS | ||
You need to install Emscripten, cmake and Ninja build system: | ||
```sh | ||
brew install emscripten cmake ninja | ||
``` | ||
#### Windows | ||
First, install Emscripten. Open the Emscripten command prompt (or `cmd` and run `emsdk_env.bat` to set up the necessary environment variables). | ||
Install Ninja (build system). Ensure that `ninja.exe` is in your `PATH` | ||
## Build | ||
Run `yarn build` or: | ||
- Create a folder called `build` inside this repository - navigate into this directory: `mkdir build && cd build` | ||
- Inside `build` run `emcmake cmake -G Ninja -DCMAKE_BUILD_TYPE=Release ..` | ||
- Next, run `cmake --build .` - this will generate a pair of `.wasm` + `.js` files in the `web` directory | ||
- Navigate into the `web` directory and start up an HTTP server: `python3 -m http.server` | ||
- Open your browser: `localhost:8000` | ||
- For convenience: if you already built the binary once and but changed something and want to quickly build again, you can from `packages/modelling-wasm/build` run `cd .. && rm -rf build && mkdir build && cd build && emcmake cmake -G Ninja -DCMAKE_BUILD_TYPE=Release .. && cmake --build . -jXX` where XX is should be less than the 2\*number of cores in your CPU. | ||
Note: for code completion in VS Code, make sure you install the "CMake" and "CMake Integration" addons. |
617307
2