Demo of the wave form collapse (WFC) algorithm with react three fiber and web assembly (WASM) Tweet
Demo_WFC_Application.mov
The WFC algorithm is part of the family of procedural algorithms and allows to construct object grids that follow human designed neighbouring rules. It was first introduced by Maxim Gumin and apated for 3D by many others such as in the StΓ₯lberg experiments or generative cities. This project provides a baseline of the WFC algorithm in a flexible but still a very performant manner. We present a pipeline containing three parts the fast flexible WFC WASM implementation, a model and adjancency exporter and a demo that showcases the results and interacts with the WFC WASM. In this repository one will find the adjancency exporter, the compiled WASM and the demo. The demo can be tested at https://inftyworld.vercel.app/.
The WFC WASM version features a 32x16x32 3D solver, with a run and a run step mode. Voxels can be preset to set the floor or pad the walls. Additionaly a sampling rate of objects can be set to force certain models over others, this is usefull to create for example more sparse results. The solver features a backtracking step, to avoid getting stuck in unsolvable situations. For the exporter part of the pipeline we used blender to model the objects. One is able to export the models and adjacency examples with the provided python scripts. The results of the compination of the exporter and the WASM can be viewed in the demo, which also has a generate and a step mode. Models can be exported and smapling rate can be changed.
In the following you find a short description of the most important files that are in connection with WFC. Files that are not named here are either config files or supporting structure to render and display the results.
.
βββ public
β βββ ... .glb # All models glb files
β βββ wfc.wasm # Web assembly wave form collapse
β βββ constraint.json # Adjacency constraints
β
βββ src
β βββ components
β β βββ generator # Generator files loading and using WFC
β β βββ displayer # Displayer of generated WFC structures
β βββ models # All models tsx files
β βββ wfc # Emscripten WFC javascript module
β
βββ stores
β βββ generationStore.tsx # Config for WFC such as size and samples
β
βββ blender
βββ infty.blend # Blender file with objects and scripts
βββ nameExporter.py # Name exporter to copy paste in javascript
βββ constraintExporter.py # Constraint exporter for adjacency
βββ objectExporter.py # Object exportet for models
βββ gltfjsxify.sh # TSX file generator from glb files
This project was part of the Computer Graphics internship by the university of TΓΌbingen. Big thanks to Martin Donald for his amazing tutorial as well as Oskar StΓ₯lberg and Marian Kleineberg for their inspiration.