WFreeCAD / README.md
HelloSun's picture
Initial WFreeCAD static space
ebc1b3a verified
|
Raw History Blame Contribute Delete
2.04 kB
---
title: WFreeCAD
emoji: ⚙️
colorFrom: yellow
colorTo: red
sdk: static
pinned: false
short_description: A tiny in-browser FreeCAD Part studio
---
# WFreeCAD
A tiny, static, in-browser FreeCAD Python playground. Pick a Part macro, orbit the result, edit the code, and run it again.
- Four instant examples: a spur gear, a desktop computer, a rocket, and a mug.
- Upload any `.py` macro that uses the supported `FreeCAD` / `Part` subset.
- Live execution happens locally in a Pyodide Web Worker; nothing is sent to a server.
- Results are rendered with Three.js and `three-bvh-csg`, with soft shadows and an optional edge overlay.
## How it works
Example scenes are precomputed with `cadshim.py` under CPython and stored as `scenes/*.json`, so the examples render immediately without downloading Python. Uploaded macros are executed by Pyodide in `worker.js`, serialized into the same scene JSON format, and displayed by `viewer.js`.
The shim supports a practical subset of FreeCAD's Part API:
- `FreeCAD.Vector`, `Rotation`, `Placement`, and `ActiveDocument`
- `Part.makeBox`, `makeCylinder`, `makeSphere`, `makeCone`, `makeTorus`, `makePolygon`
- `Part.Face`, `Shape.extrude`, `Shape.cut`, `Shape.fuse`, `Shape.common`
- `Part.show`, `ViewObject.ShapeColor`, and `ViewObject.Transparency`
It is intentionally not a full FreeCAD distribution. Unsupported API calls return a clear error in the preview panel.
## Local development
```bash
cd wfreecad
python3 -m http.server 8123
```
Open <http://127.0.0.1:8123/>.
Examples are generated by:
```bash
python3 tools/build_scenes.py
```
Thumbnails are rendered from `tools/thumb.html` through the same Three.js viewer, so their materials and lighting match the main preview.
## Stack
- [Three.js](https://threejs.org/) + [three-bvh-csg](https://github.com/gkjohnson/three-bvh-csg)
- [Pyodide](https://pyodide.org/)
- [CodeMirror 5](https://codemirror.net/5/)
- Custom FreeCAD Part shim and static scene format
No backend, database, or build step is required at runtime.