Four 3D hardcover books lying in a stack on a dark background, orange, black, green and cream, with their spines facing out and striped and grid patterns on the covers of the lower three

3D web pageSolo, design and codeDrawing 35 of 37

My own
library

A page on my site for the books I've read, drawn as a pile of 3D hardcovers you scroll through. Press a book and it opens to its own page, and from there you can open it to a title page. There are 52 books on it so far, and I'm still writing the notes that go inside them.

Sheet 02 of 08/The page

What it is

The library is a page on this site for the books I've read and still think about. Each book is one plain <article> in library/index.html with a title and an author, and there are 52 of them right now. The page reads those articles and draws every one as a hardcover lying in a pile on a dark stage.

You scroll down the pile, and pressing a book opens its own page. Each book has room for a line on why it stayed with me, a list of what I took from it and a few favourite quotes. None of the 52 have those filled in yet, so every book page says I'm still working on it.

A dark web page titled My own library with a short intro on the right, and a dark red book called Meditations lying at the bottom
PL 02The top of the library page, with the first book of the pile coming up under the title.

Sheet 03 of 08/Design

Picking the design

Before building it I made three concepts as real pages you could scroll: a shelf, an index and a blueprint. They're still in tools/library-concepts/, all three running on the same 8 placeholder books. I didn't pick any of them. I went with Stripe Press as the reference instead.

My first version drew the books in CSS 3D, where every face of a book is a flat panel shaded with gradients. They looked like boxes to me, so I moved to real 3D models drawn with Three.js, with textures on them. The CSS books are still in the code as the fallback for when WebGL can't start.

Three books named Dune, Dune Messiah and Children of Dune stacked on a dark background, drawn as flat shaded panels with square corners
PL 03Dune and the two books under it drawn by the CSS fallback, where every face is a flat panel shaded with gradients.
The same three Dune books as lit 3D models with rounded spines, the lower two showing ring and ray patterns on their covers
PL 04The same three books as Three.js models, with round spines, three lights on them and the lettering drawn into canvas textures.

Sheet 04 of 08/The books

How each book is made

There are no model files. book3d.js builds each book in code the first time it scrolls near the screen. A book is two boards, a block of pages between them and a round spine, which is half a cylinder squashed to 55 percent with a cap at the head and the tail. The boards stick out a little past the pages, like they do on a real hardcover.

The textures are drawn on 2D canvases. The cover gets its pattern, a groove by the hinge, its number, the title and the author. The spine has the author at the head, the title in the middle and the number at the tail, and the page edges are fine lines on cream. One small noise tile goes over the cloth as grain.

Each book only needs four things on its <li>: a cover colour, an ink colour, a pattern and a thickness. There are six patterns (lines, rings, grid, diagonal stripes, bands and rays), and I set every thickness by hand, from 0.45 for the thinnest books up to 2.6 for The Count of Monte Cristo. The page can also work out the thickness from a page count, at 320 pages for a thickness of 1, but no book uses that yet.

A close view of two dark blue book spines, a very thick one titled The Count of Monte Cristo above a thinner one titled Moby-Dick
PL 05The Count of Monte Cristo is the thickest book on the pile, at a thickness of 2.6. Moby-Dick under it is 1.6.
A red 3D book with diagonal stripes tilted out of a stack of books, showing its cover with the title, its rounded spine and the cream page block
PL 06Crime and Punishment pressed and dragged out of the pile, turned to show its cover, its round spine and the page edges.

Sheet 05 of 08/The pile

The pile and the scroll

Each book sits on a plain button in the page, and Three.js paints the book over it on one canvas fixed over the whole screen. The buttons stay as the things you press and tab to, so layout, focus and clicks are still normal HTML. The camera is set up so one unit in the 3D scene is one CSS pixel, and that keeps every book lined up with its button.

There's one camera for the whole pile, at the middle of the screen. Books below the middle show their covers and books above it show their back boards. Scrolling fast tips the pile toward the covers by up to about 14 degrees, pointing at a book lifts it a little, and pressing and dragging turns it in your hand. Every pose eases toward where it should be, so a book springs back when you let go. Down the left edge there's a tick for each book, and pointing at the ticks fans them out and names the book.

The drawing loop only runs while something is moving and for 1.4 seconds after the last scroll or press. A book more than 30 percent of a screen past the top or bottom isn't drawn, the pixel ratio is capped at 2, and every book shares the same noise tile and page materials.

A screen recording of a pile of 3D books scrolling by. One red book lifts, the screen turns red with that book standing beside its title, and then the book opens to a cream title page
PL 07Scrolling down the pile, then pressing Crime and Punishment. Its page opens in the book's own red, and Open the book lays it open on the title page.

Sheet 06 of 08/Opening

Opening a book

Pressing a book opens a full screen dialog with one section per book, each in that book's own colours, like Stripe Press does it. The book stands on the left and turns round to face you the first time it opens, and the text is on the right. Scrolling the dialog runs from one book into the next and the address bar follows along, so a link like /library/#dune opens straight to that book.

The Open the book button lays a CSS book open on top. The cover swings over to a title page with the book's number, title and author, and each note gets its own spread after that. You turn pages with the buttons, the arrow keys or by clicking a page, and Escape closes the book before it closes the dialog. None of the notes are written yet, so the page after the title page says Notes to come.

An orange page with a striped 3D book standing at an angle on the left, and on the right the title Dune, the author, an Open the book button and a short notes heading
PL 08Dune's page in the reader. The book stands on the left in its own colours, and the notes column on the right still says Notes to come.
An open book on an orange background, the striped inside cover on the left and a cream title page on the right reading No. 31 of 52, Dune, Frank Herbert, with page buttons below
PL 09Open the book lays Dune open on its title page, with its number out of 52, the title and the author.
An open book with two cream pages on an orange background, the left page headed What I took from it and the right page reading Notes to come
PL 10The spread after the title page. Every book shows Notes to come here until I write its notes.

Sheet 07 of 08/Fallbacks

Phones, no JavaScript and reduced motion

With JavaScript off, the page is a plain list of titles and authors on the dark stage, because every book is already written in the HTML. If WebGL can't start, the CSS books stay on the pile and on the book pages. On a phone the pile fills the width, the tick index is hidden and each book page becomes one column with the book on top.

If your device is set to reduce motion, the scroll tilt, the easing and the spin when a book page opens are switched off, and the books show up in place instead of rising in as they scroll into view.

Three phone screenshots side by side, showing a stack of colourful 3D books, a dark red page with The Brothers Karamazov standing above its title, and the same book open on its title page
PL 11The pile, a book page and an open book on a phone screen 390 pixels wide.
A dark page listing book titles in a serif font with each author in small grey type underneath, separated by thin lines
PL 12The same page with JavaScript turned off. Every book is a plain title and author in the HTML.

Sheet 08 of 08/Source

Inspect the work