FreeCAD Ported to the Browser: 2.2M Lines of CAD via WASM
Following LibreCAD and OpenSCAD, FreeCAD has been ported to WebAssembly. In four days, the Fable agent used JSPI, a custom Qt build and a WebGL2 shim to fit a massive CAD kernel into the browser.
Following earlier WebAssembly ports of LibreCAD and OpenSCAD, the next target was far bigger: FreeCAD. This parametric CAD platform, comprising roughly 1.5 million lines of C++ and 700,000 lines of Python, bundles the OpenCASCADE geometry kernel, the Coin3D scene graph, an embedded CPython interpreter, PySide6 Qt bindings, and VTK/SMESH for FEM into a single wasm module. Sparked by a Hacker News thread, the port was completed in about four days, largely by an AI agent called Fable, with every prompt and session transcript published openly.
The hardest problems were twofold. Preserving the blocking semantics of FreeCAD's hundreds of modal dialog calls required a custom Qt build with WebAssembly JSPI support, since prebuilt Qt-for-wasm packages don't offer it. The second major obstacle was translating Coin3D's legacy fixed-function OpenGL calls (glBegin, matrix stacks) into WebGL2/GLES semantics, solved with a roughly 900-line hand-written emulator and an offscreen-framebuffer compositing trick for Qt's GL widget.
Development followed a kernel-first discipline: headless FreeCADCmd was validated in Node and the browser before touching the GUI, followed by linking, window boot, and finally the WebGL2 viewport. Along the way, subtle bugs — a wrong depth-clear default, white flashes during selection drags, and vertex buffers being read from stale memory — were fixed one by one until the renderer reached interactive frame rates.
The result is a 196 MB static wasm module with roughly a 96 MB compressed first load, currently limited to recent Chromium-based browsers that support JSPI. For engineers, it demonstrates that even enormous, decades-old desktop codebases with deep platform assumptions can be moved into the browser through disciplined engineering paired with AI-assisted automation.