← Blog

Building Pocket Shapes, a 3D modelling app for your phone

∙ 3 min read

Pocket Shapes is an app for making simple 3D models on your phone and sending them to a 3D printer. It’s in testing now, and you can try the prototype in your browser.

Why a phone app

Much of what people design for a home 3D printer is small. Name tags and keychains. A spacer or bracket that has to be an exact size. A hole added to a model someone else made, or a model cut down to fit the printer.

The tool most beginners use for this runs in a web browser. It has an iPad app but no iPhone app, and it needs a connection. People like it because it’s quick: drop a shape, drag it to size, turn another shape into a hole and group the two.

I wanted those moves on a phone, working offline. Pocket Shapes keeps them and leaves out most of what a full CAD program has.

Who it’s for

People who own a 3D printer, or just got one, and have never used a CAD program. The words in the app are plain. A shape is a Solid or a Cutter. There’s a “Keep aspect ratio” checkbox and a “To plate” button. Sizes are in millimetres, because that’s what slicers use, and you can switch to inches.

What it does

You start on an empty build plate sized for your printer. You add shapes (box, cylinder, ball, cone, pyramid, wedge, ring and hexagon), move and resize them with round handles, and turn any of them into a Cutter. When you’re done, you export an STL or 3MF file for your slicer. The export screen tells you whether the model fits the plate.

There’s also a Library of ready-made parts. Pick the washer, choose a standard size such as M12, and the sizes are filled in for you.

Bug one: exports with gaps

A slicer needs a closed model. If the surface has gaps, it can’t tell inside from outside, and the print can fail.

My first prototype used a JavaScript library called three-bvh-csg to join shapes and cut holes. On screen it looked fine. But a box with one Cutter through it exported with 617 open edges. The eight Library parts had between 37 and 1,566 each.

So I tried Manifold, a geometry library whose joins and cuts always come out closed. It runs as WebAssembly, so it works in a browser. Before switching, I tested it on its own in the iPhone simulator, both in Safari and in a bare iOS web view, which is where the app’s editor runs. Both gave 0 open edges, and Manifold loaded in 18 to 63 ms.

It’s also much faster when you give it all the work at once. For a pegboard with 100 holes, joining all the solids in one call and all the cutters in another took 74 ms. Doing one shape at a time took 868 ms.

After the switch, the box and all eight Library parts export with 0 open edges. A test script now exports them and counts open edges, so if the gaps come back I’ll see it.

Bug two: the engine wouldn’t load in the iPhone app

The iPhone test app is a thin wrapper that shows the editor in a web view. In a desktop browser everything worked. In the app, the shape engine didn’t load, so joining shapes, the Library and export didn’t work.

The app hands the web view the page as a string of HTML, so the page has no real address. Its address is about:blank. Manifold finds its WebAssembly file by building a URL from its own location (import.meta.url). With no real address, that throws an error and the engine never starts.

The fix was small. The WebAssembly was already inside the app’s JavaScript file, so I gave Manifold a locateFile function and it stopped trying to build that URL. I also added a check that loads the page the way the phone does, as an HTML string in WebKit. It makes sure the engine starts and that exports come out closed. Testing in my laptop’s browser would never have caught this one.

Where it is now

The app is in testing on iPhone and Android, and the web prototype is still up for anyone who wants to try the editor.

If you have a 3D printer, I’d like to know: what’s the last small thing you wished you could design without sitting down at a computer? You can tell me at contact@sidecutlabs.com.

The app

Found a bug or an idea? Write in.

Feedback on an app, a bug, or something to build. One inbox reads it all.

contact@sidecutlabs.com