← Ziding Zhang

Kamifold: turning a photo into a paper model you can print and fold

Drop a photo or type a description, unfold convex polyhedral parts along non-overlapping crease trees onto 1:1 ISO A4 sheets, watch them fold in WebGL 2, and print an illustrated assembly booklet.

December 2, 2026 · Project · What is not yet established


The interactive for “Kamifold: turning a photo into a paper model you can print and fold”, as it first appears. Open it here
Turn a photo into a paper model you can print and fold. Try one of the examples first. On its own page

Open Kamifold Studio →

A flat photograph carries colours and a silhouette, not fold geometry. To turn one into a real cardstock object you can actually cut with scissors and glue on a desk, every curved shape has to become a small set of developable convex polyhedra whose 2D nets unfold with zero overlap, pack cleanly inside ISO A4 margins, and stand upright once assembled.

Kamifold studio interface showing the tactile stationery control card on the left and a red-and-white striped octagonal paper lighthouse resting on faint cut-and-fold sheet outlines over a sage drafting mat.
The landing studio with the five-part Coastal Lighthouse on its drafting mat. Open the studio to drop in a photograph, test the Tin Robot or Pembroke Corgi examples, scrub between flat sheets and the folded 3D model, or print the A4 booklet.

Built after seeing Hassan’s kami preview, this browser studio separates the craft problem into two clean layers—much like turning a single photograph into physical glass optics in Optical Lens Bench or interactive scenes in The Night Stacks:

  1. General convex polyhedral unfolding and folding kinematics. Every part (box, prism, tapered frustum, pyramid, cone, or wedge) is represented by its exact 3D vertices and outward-wound faces. A single spanning-tree unfolder computes exact dihedral angles (arccos(n_a · n_b)), checks 2D polygon separation, adds tapered numbered glue tabs along cut seams, and drives a live Three.js hinge hierarchy where flat printed nets rise off the A4 sheets (t = 0 → 0.54) and lift into their assembled 3D poses (t = 0.54 → 1.0).
  2. Dual texture and millimeter-exact A4 vector output. Face graphics—stripes, arched doors, glowing lantern mullions, dials, eyes, noses, or cropped photo projections—render onto both WebGL canvas textures and clip-pathed 1:1 millimeter vector SVGs (210 × 297 mm) with a 5 cm print-scale check bar, a cover page with lettered callout pins, and 2×3 isometric assembly step cards.
Three-stage sequence of the 12-part Pembroke Corgi paper model: flat unfolded cut-and-fold nets across two A4 sheets on the left, partially folded boxes and pyramid ears casting shadows on the sheets in the middle, and the finished standing paper corgi on the right.
Left to right: all 12 Pembroke Corgi parts laid flat across two A4 sheets, mid-fold on their blueprint outlines, and snapped into the standing 8 cm paper model.

Everything runs locally in the browser with no sign-up: drop or paste any photo for instant palette extraction and silhouette synthesis, try natural-language edits like make the chest bigger or new colours, share any model via a compressed URL hash, or connect your own Google Gemini, Together AI, OpenRouter, or OpenAI key directly from the browser for multimodal Vision-LLM generation.

Multi-page ISO A4 print preview showing the Pembroke Corgi cover sheet with radial callout pins A through L, illustrated 2x3 step-by-step build cards, and numbered cut-and-fold A4 sheets.
The printable A4 booklet: an isometric callout cover, numbered step cards with ghosted prior parts, and 1:1 millimeter cut-and-fold sheets ready for browser printing or SVG download.
Agent context: sources, method and working notes

Engineering & verification notes

  • Unified hinge-tree theorem (public/interactive/paper-model-studio/src/unfolder.js): Each convex polyhedron’s face adjacency graph is expanded via a style-aware Prim spanning tree (box cross net, strip perimeter wrap for prisms/frustums, fan apex unfold for cones/pyramids) with 2D separating-axis overlap checks (convexPolysOverlap2D). Because every shared edge P0 → P1 is oriented CCW on the parent face, aligning each child pivot’s local +X axis along the crease gives the exact outward mountain-fold rotation +u · dihedralAngle around +X for every convex primitive. Automated Node verification confirmed < 2.8 × 10⁻¹⁵ cm max 3D vertex reconstruction error across all 8 tested primitive families and 0 net overlaps across all 12 built-in and procedural archetypes.
  • Physical stability check (src/geometry.js): Models are automatically grounded (minY = 0), centred, and tested by projecting the surface-area-weighted centre of mass (proportional to uniform-density cardstock shell weight) onto the 2D convex hull of ground-contacting vertices (y <= minY + 0.28 cm).
  • A4 packing & print pipeline (src/packer.js, src/print-preview.js): Shelf bin-packing with 90° rotation fits nets inside ISO A4 (210 × 297 mm, 12 mm side margins, 19.5 mm header clearance, 10.5 mm scissor clearance). Per-face UV decals map affinely onto the unfolded millimeter polygons via exact 2×3 SVG transforms (computeFaceUvToSheetMatrix). Dedicated @media print rules output exact 210mm × 297mm pages one per sheet.
  • Browser & privacy boundary (src/ai-providers.js): Optional BYOK keys for Google Gemini (gemini-3.8-flash), Together AI, OpenRouter, and OpenAI are persisted solely in the visitor’s localStorage and sent directly from the browser to the selected provider endpoint.
  • Visual & console QA: Verified in headless Google Chrome (WebGL 2, 1440×900 desktop and 390×844 mobile) across landing hero, photo swatch upload, flat sheets, mid-fold, lift-and-snap assembly, semantic edit (make the chest bigger), A4 print preview, cut-and-fold SVG sheets, and Tin Robot with 0 console errors, 0 page errors, and 0 failed requests.

Have an answer, a counterexample, or a story? See Talk to me for open questions and live trials.

Credits: Ziding Zhang with Gemini 4 Neon. Inspired by Hassan El Mghari's (@nutlope) kami paper-model demo. Built with Three.js r170, WebGL 2, and vector ISO A4 SVG generation.