Almost everyone has clicked through a "3D flipbook" on a website at some point — and immediately noticed something felt off.
Sometimes the page stretches like rubber when you drag it toward the top corner. Sometimes it looks like a flat paper cutout sliding across the screen. And almost always, if you try to flick through pages quickly the way you would thumb through a real book, the UI locks up, forcing you to wait until Page 1 finishes its animation before you are allowed to touch Page 2.
When we built the 3D Flipbook inside RePaint (our open-source WebGL UI engine), we wanted to answer two practical questions:
- What actually makes the human eye believe a digital rectangle is a physical sheet of paper?
- Can we author an entire illustrated 3D book using nothing but a plain Markdown file (
book.md) and.pngimages — without touching rendering code?
It turns out you do not need a heavy 3D mesh engine or cloth simulation. You only need four simple, physical ideas working together.
Idea 1: The "Sheet on Your Desk" Rule (Paper Bends, Never Stretches)
Place a real sheet of paper on your desk and pinch the bottom-right corner (A), pulling it up and to the left toward your finger (P).
Two everyday physical rules happen automatically:
- The crease is always a mirror: Draw an imaginary line halfway between where the corner used to be (
A) and where your finger is now (P). The paper folds cleanly along the perpendicular line right through that midpoint — flipping the back of the sheet like a mirror reflection. - The spine holds the paper back: Try pulling that corner too far up or too far left. You hit a natural limit because the paper is anchored to the top and bottom of the book spine! Clamping your cursor inside two simple circles centered at the top and bottom of the spine instantly stops the "stretchy rubber page" artifact.
Idea 2: Lighting Sells the Thickness (Three Subtle Gradients)
Geometry alone still looks flat — like folding an origami shape in MS Paint. What actually convinces your brain that the paper curves upward off the table is light and shadow:
- The Drop Shadow underneath: As the flap lifts, it casts a soft dark gradient onto the newly revealed page below. The wider the turn, the softer and wider the shadow spreads.
- The Spine Gutter: A gentle vertical shadow down the middle crease gives the open book depth before you even touch a page.
- The Cylindrical Roll Gleam: Real paper does not crease like a sharp knife edge unless you press it flat — it curves in a smooth roll that catches overhead room light! Painting a soft translucent white highlight band just inside the fold edge immediately gives the sheet physical volume and warmth.
Idea 3: The "Wave Cascade" (Every Sheet Is an Independent Component)
Here is the secret behind our favorite interaction in RePaint: rapid-clicking a corner 4 or 5 times so multiple curved pages chase each other across the book like ocean waves.
Why can't ordinary flipbooks do this? Because most libraries draw "the book" as one monolithic state machine (isTurning = true).
In RePaint, every physical sheet of paper is its own independent component with its own cached GPU layer:
- The instant Sheet 1 lifts off the right-hand stack, Sheet 2 underneath is immediately unlocked and ready to be grabbed or clicked — while Sheet 1 is still flying through mid-air!
- The Mid-Air Z-Order Flip: On the right side of a book, Page 1 sits above Page 3. Once they land on the left side, Page 3 must sit above Page 1! If two flying sheets used a fixed layer order, they would slice right through each other mid-flight. Each
BookSheetautomatically flips its stacking priority on the exact frame its fold crosses the center spine — making multi-page wave cascades look completely natural in both directions. - Once a sheet finishes landing, it merges back into the resting book stack and releases its temporary GPU texture, dropping idle usage right back to
0%.
Idea 4: Writing a 3D Illustrated Book in Plain Markdown (book.md)
A great UI component should be effortless to feed with real content. Nobody wants to recompile C# coordinates just to fix a typo on Page 4 or add a diagram to Page 6!
So we wired RePaint's BookPages renderer directly to a plain wwwroot/book/book.md file:
---
CoverTitle: REPAINT
CoverSubtitle: 3D Flipbook · Markdown & Images
CoverByline: by Neperi Engineering
---
Badge: PAPER FOLD PHYSICS
# Why Real Paper Never Stretches
When you peel corner P away from resting corner A, real paper
folds along the exact perpendicular bisector.

- Drop any .png or .jpg into wwwroot/book/ and reference it above.
- Click Reload .md to preview your changes live without rebuilding!
> TIP: Rapid-click any page corner 4–5 times to launch a 3D wave!
Every --- divider starts a new page. Headings, badges, bullet lists, callout boxes, and embedded  images are automatically word-wrapped and recorded once into resolution-independent Skia vector buffers (SKPicture).
That means when you drag a page corner at any angle, both the typography and your embedded illustrations bend, mirror, clip, and catch soft 3D shadows seamlessly at 60–120fps — and editing the book is as easy as saving a .md file and clicking Reload .md.
Try It Yourself (Open Source MIT)
You can explore the complete 3D Wave Flipbook — alongside the 10,000-row virtual list, 2,400-card 2D QuadTree grid, and Aurora ::selection firework inputs — in the open-source RePaint repository:
- GitHub Repository (MIT): https://github.com/neperisearch/repaint
- Customize Your Own Book: Edit
wwwroot/book/book.md, drop images intowwwroot/book/, and publish as 100% static files for GitHub Pages or any static site!
About the Team Behind RePaint
RePaint is crafted by the engineering team behind Neperi Search — a fast, typo-tolerant multilingual full-text search engine and REST/MCP API built for websites, e-commerce catalogs, and RAG pipelines. Just like RePaint cuts away heavy DOM overhead to make complex graphics feel effortless, Neperi Search finds the exact passage through typos, missing accents, and noisy OCR across 20+ languages on plain CPUs with zero analyzer setup.