← All projects

three-wfc

by @Fennec-hub

77

A blazing fast ⚡ Wave Function Collapse engine for three.js, built for real-time 2D, 2.5D, and 3D procedural world generation at scale.

About this project

Three-WFC: A Blazing Fast ⚡ Wave Function Collapse Solver for Three.js 🚧 Work in Progress 🚧 This library provides a highly optimized Wave Function Collapse (WFC) implementation designed for use with Three.js (though the core logic can run independently). It focuses heavily on performance by leveraging techniques like Typed Arrays, bitmasking, min-heaps for entropy selection, and avoiding garbage collection during the solving process. The goal is to enable complex procedural generation directly in the browser with minimal performance impact. ✨ Key Features Performance-Focused: Optimized for speed using: Typed Arrays: Minimizes garbage collection and memory overhead by using pre-allocated buffers (Uint32Array, Float32Array, Int16Array, etc.) for all core data structures. Bitmasking (WFCOptionsBuffer): Efficiently represents and checks tile compatibility using bitwise operations, significantly faster than array lookups. Min-Heap Entropy Selection (WFCMinHeap): Quickly finds the next cell to collapse (O(log n)) without requiring full grid scans on each step. Includes a key-to-position map for fast updates/removals.

From the project README on GitHub

Stars
77
Forks
1
License
MIT
Last push
2 Jun 2025

Add this badge to your README

Show that your project is listed on Made in Algeria.

Made in Algeria
[![Made in Algeria](https://www.madeinalgeria.dev/badge/three-wfc.svg)](https://www.madeinalgeria.dev/projects/three-wfc)

Related projects