# Book Flip — `book-flip@1.0.0`

An open book whose pages turn one after another in a gentle breeze, then turn back. Loops perfectly.

An open book on a desk in lamplight: each page rises, curls over the spine in a soft arc and settles on the left, revealing the next spread of printed lines, drop capitals, little pictures and page numbers; when the last page has turned they all turn back, one after another, and the book is where it began. Choose the number of pages, the cover cloth (oxblood, navy, forest or black), the paper, how much the pages curl, the seed, the backdrop and whether the camera drifts.

- Kind: object; status: published; digest sha256:45006221ab73d57a26ea6146b574024ad85f541415cc66e16312e1af5c26913d
- Role: Object (3D, three.js): a quiet, literary hero object for reading, education, story and knowledge content.
- Implementation: three; entry `src/book-flip.js`
- Files: https://aipixelwizard.com/registry/book-flip/1.0.0/<path> (`LICENSE`, `asset.json`, `demo.js`, `index.html`, `src/book-flip.js`)
- Manifest JSON: https://aipixelwizard.com/api/v1/visuals/book-flip/versions/1.0.0
- Runnable demo: https://aipixelwizard.com/registry/book-flip/1.0.0/index.html (open over http; it imports sibling packages by relative path)
- Dependencies (exact): `three@0.185.1` (source) — Renderer, geometry and materials.; `chrome-material@1.1.0` (demo) — Studio environment light, backdrop and contact shadow.; `apw-runtime@1.0.0` (demo) — Demo harness.

## Exports
- `createBook({ pages?, cover?, curl?, seed?, paper? }) => { group, setProgress(progress), dispose() }` — The covers, spine and curling pages as a group (pages 3 × 4, spine on the y axis); add it with a shadow-casting light.
- `COVERS: { oxblood, navy, forest, black }` — Cover cloth colours.

## Parameters
- `pages` (integer 4–10, default 8) — Pages: Leaves in the book; each has two printed sides.
- `cover` (select one of oxblood | navy | forest | black, default "oxblood") — Cover
- `paper` (color, default "#f1e8d2") — Paper
- `curl` (number 0–1.6, default 1) — Curl: How much a page bends as it turns.
- `seed` (integer 1–999, default 4) — Seed
- `background` (color, default "#241a12") — Backdrop
- `orbit` (boolean, default true) — Camera drift

## Composition
- Inputs: Time within the loop; the number of pages, cover, paper, curl, seed, backdrop and camera drift.
- Outputs: A full frame rendered in 3D with soft shadows.
- Coordinates: The spine is on the y axis, each page is 3 wide (x) and 4 deep (z); unturned pages lie to the right, turned ones to the left.
- Lighting: A warm key light with a shadow map and a studio environment.
- Timing: setProgress(progress) sets every page's turn; frames render in any order.
- Works with: chrome-material, orbit-camera, kinetic-title, number-reveal
- Each page is a 28-segment strip whose segment directions are the turn angle plus a bend; the strip is rebuilt every frame on the CPU.
- Page faces are canvas textures drawn once; the back face is the same texture mirrored.

## Output and loop
- 1080×1080, 30 fps, 16 s, procedural
- Seamless loop: yes — In the first half of the loop the pages turn forward one after another and in the second half they turn back in the same order; each page's angle and curl are smooth functions of the loop, so the book ends where it began.
- Verified 2026-10-06 in Chrome 154.0.8037.97 headless on Linux 7.0.0-38-generic (x64), Node 22.14.0 (WebGL 2 via SwiftShader (software)); deterministic: yes; loop check: Frame 0 vs end state (progress 1): mean |Δ| 0.0000, max |Δ| 0 of 255.

## Use it
New project: Create a WebGLRenderer with shadows, add createBook().group and call book.setProgress(progress) each frame.

Existing project: Copy src/book-flip.js; add book.group to your scene with a shadow-casting light.

Reuse ideas:
- Reading-app or library title: Oxblood, eight leaves.
- Documentation backdrop: Navy, cream paper.
- Storybook opener: Forest, many pages.

## Limitations
- The pages turn on a hinge without collision, so a turning page may pass through its neighbours by a hair.
- The text is suggested by bars, not real letters.

## License
MIT. Copyright (c) 2026 AI Pixel Wizard. Released under the MIT License. See LICENSE in this folder.

Provenance: Adapted from the owner's threejs-sketches/objects-scenes/book-flip (MIT) and rebuilt for AI Pixel Wizard in October 2026 as an original object: curling page strips as closed forms of the loop, procedurally printed page textures and a forward-then-back turn sequence for an exact loop.

