harshil

sketcher

A drawing and 3D modeling app. Draw shapes, merge them, cut them, and turn them into 3D objects.

prototypeC++2025-03 → 2025-05sologithub ↗

what
A desktop app to draw 2D shapes, combine them, and pull them into 3D solids. It opens and saves 3D model files.
the hard part
Merging two shapes means finding every point where their edges cross, and getting the inside and outside right.
where it is
Works on desktop. A version that runs in your browser is being built.

What you can do

  • Draw shapes: polygons, lines and smooth curves.
  • Combine two shapes (boolean operation — Combining two shapes: union (both together), intersection (only the overlap), subtraction (the first minus the second).): join them, keep only the overlap, or cut one out of the other.
  • Pull a flat shape into a 3D solid (extrude — Pull a flat 2D shape along a straight line to make a 3D solid, like pushing dough through a mold.).
  • Make boxes, cylinders and spheres. Move, turn and resize them.
  • Open and save 3D model files (OBJ and STL).
  • Find where two 3D models cut through each other.

Design choices

  • Merging by hand first. Join and overlap are written from scratch: is this point inside the shape? where do these two edges cross? Cutting one shape out of another has more tricky cases (holes, edges that touch), so it uses the Clipper library.

In your browser

Sketcher is a desktop app. The browser version compiles the same C++ code to WebAssembly — A compact program format that browsers run at near-native speed. C++, Rust and Python runtimes can compile to it.. The old drawing code does not work in browsers, so it is being rewritten first.

numbers

valuewhatsource
4.3klines of C++ written for the app (the Clipper library not counted)repo
46commits, 18 Mar → 29 May 2025GitHub

explore the code

Explorer 7 parts · tap one
Sketcher/geometry/

The shapes - point, line, polygon, triangle, curve, box, cylinder, sphere - and the code that builds them from what you type. source ↗

Sketcher/geometry/src/FileConverter.cpp

Opens and saves 3D model files (OBJ and STL). source ↗

Sketcher/SketcherGUI/src/SketchGLWidget.cpp

The 2D drawing area. source ↗

Sketcher/SketcherGUI/src/GLWidget.cpp

The 3D view. Turn and zoom the model. source ↗

Sketcher/SketcherGUI/src/polygon_boolean.cpp

Merging shapes. Union and intersection are written by hand. Subtraction uses the Clipper library. source ↗

Sketcher/SketcherGUI/src/ExtrudeUtils.cpp

Turns a flat shape into a 3D solid. source ↗

Sketcher/SketcherGUI/src/TriangleIntersection.cpp

Finds where two triangles, or two whole 3D models, cut through each other. source ↗

keys

This page reads like any web page. If you use vim, it also works like vim.

move
j / knext / previous line
gg / Gtop / bottom
Ctrl-d / Ctrl-uhalf a page down / up
]] / [[next / previous heading
H / Lprevious / next project or post
act
Enter or gfopen the link on the current line
Kexplain the term on the current line
/ then n / Nsearch this page
:command line: a page name, help, q
Spacemenu: f find, p projects, w writing
Space a / Ctrl-e / Alt-1…4pin a page, list pins, jump to a pin
Ctrl-oback
Escclose, clear search