paperlab 0.0.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -8
- package/dist/index.cjs +2652 -647
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1129 -81
- package/dist/index.d.ts +1129 -81
- package/dist/index.js +2609 -638
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -2,10 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
**Physical, realistic paper as a React component.** A hero image that peels, a receipt that unrolls, a letter that folds, a poster rippling in wind, a gallery ring of prints — real 3D paper, not a CSS fake. Content is a texture on a mesh that genuinely bends, so text and imagery curl with perfect continuity.
|
|
4
4
|
|
|
5
|
+
**[Try it →](https://nourmtir0722.github.io/Paperlab/)** · [the editor](https://nourmtir0722.github.io/Paperlab/editor/) · [the reference](https://nourmtir0722.github.io/Paperlab/docs/) · [for agents](https://github.com/NourMtir0722/Paperlab/blob/main/AGENTS.md)
|
|
6
|
+
|
|
5
7
|
| | |
|
|
6
8
|
|---|---|
|
|
7
|
-
|  |  |
|
|
10
|
+
|  |  |
|
|
11
|
+
|
|
12
|
+
Every frame above is real geometry — no video, no sprite sheet. Type a sentence into the playground and it builds you a room out of it:
|
|
13
|
+
|
|
14
|
+

|
|
9
15
|
|
|
10
16
|
## Quick start
|
|
11
17
|
|
|
@@ -42,12 +48,21 @@ import { PaperField } from 'paperlab'
|
|
|
42
48
|
<PaperField images={photos} preset="photo-print" layout="ring" />
|
|
43
49
|
```
|
|
44
50
|
|
|
51
|
+
Or build a space out of a sentence and walk through it:
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
import { PaperStage } from 'paperlab'
|
|
55
|
+
|
|
56
|
+
<PaperStage text="the paper remembers every hand that folded it" progress={scroll} />
|
|
57
|
+
```
|
|
58
|
+
|
|
45
59
|
## What's inside
|
|
46
60
|
|
|
47
|
-
- **Behaviors** — `peel`, `unroll`, `flip`, `letter-fold`, `hang`, `fly`, `fall`: human-named params ('tightness', not 'cylinderRadius') over a stack of pure geometry deformers. Draggable handles when `interactive`.
|
|
48
|
-
- **Stocks & surfaces** —
|
|
61
|
+
- **Behaviors** — `peel`, `unroll`, `flip`, `letter-fold`, `hang`, `fly`, `fall`, `carry`, `flight`, `crumple`: human-named params ('tightness', not 'cylinderRadius') over a stack of pure geometry deformers. Draggable handles when `interactive`.
|
|
62
|
+
- **Stocks & surfaces** — seven paper stocks (thermal gets banding, newsprint gets grain) plus grain, torn deckle edges, crease lines, and aging as composable shader effects. Real lighting throughout.
|
|
49
63
|
- **Physics** — curated idle motion (`float`, `tumble`, `breeze`…) that composes with behaviors, and a verlet **cloth** mode: pin the top edge, add wind, grab the sheet and pull.
|
|
50
|
-
- **Field mode** — 10+ papers render as *one instanced draw call* with the deformers running on the GPU (parity-tested against the CPU path), arranged by pure layout functions: `
|
|
64
|
+
- **Field mode** — 10+ papers render as *one instanced draw call* with the deformers running on the GPU (parity-tested against the CPU path), arranged by pure layout functions. Every layout names somewhere paper actually sits: `book` (pages splayed from a spine — `split: 0` makes it a swatch deck), `accordion` (one continuous concertina strip), `fan` (a hand of cards), `spread` (a stack slid sideways), `pile` (a heap on a desk), `rack` (prints stood in a row, leaning back), `wall` (a pinned studio wall), `spill` (a dropped stack mid-air), `colonnade` (banners arranged along a walk, for stage mode), plus `ring`, `sheet`, and `sweep` — a specimen chart of one sheet at ten stages of the same curl. Each pose carries a **bias** — how strongly that one sheet takes the deformation — so the top of a pile curls while the sheets pressed underneath lie flat, in the same draw call. The camera frames itself from the layout's own poses, so a wide `wall` and a deep `ring` both land without hand-tuning.
|
|
65
|
+
- **Stage mode** — paper as *architecture*: banners hung along a walk, a figure walking down it, light coming through the paper from the far end. `<PaperStage text="…" />` builds the whole space out of a sentence, and binding `progress` to scroll makes the page scroll the walk. Every part of the scene — the arrangement, the figure, the camera, the light source — reads the same walk, so they cannot drift apart. Quality adapts to the machine on its own.
|
|
51
66
|
- **Presets** — everything serializes to `.paper` JSON validated by a zod schema. Diffable, forkable, shareable.
|
|
52
67
|
- **Agent-first export** — the editor's **Copy for AI** button produces a self-contained brief you paste into Claude Code (or any coding agent): install line, inlined component, placement contract, and a verification step the agent can self-check. See [AGENTS.md](https://github.com/NourMtir0722/Paperlab/blob/main/AGENTS.md).
|
|
53
68
|
- **Accessible by default** — `prefers-reduced-motion` freezes behaviors at their pose, a hidden DOM mirror carries the content for screen readers, and a flat DOM fallback renders when WebGL isn't available.
|
|
@@ -60,16 +75,45 @@ pnpm install && pnpm dev # → localhost:5173
|
|
|
60
75
|
|
|
61
76
|
A Figma-shaped editor: presets on the left, sculpt on canvas (drag the blue handles), inspector on the right, transport at the bottom (space = play/pause). Field mode composes galleries; **Export code** ends the session in your codebase.
|
|
62
77
|
|
|
78
|
+
## Papers are made to be passed around
|
|
79
|
+
|
|
80
|
+
A paper is data — a `.paper` JSON object validated by a zod schema — so it travels without asking anyone's permission. **You do not need to fork this repo to share one.**
|
|
81
|
+
|
|
82
|
+
**Sending one.** Sculpt a paper in the [editor](https://nourmtir0722.github.io/Paperlab/editor/) and hit **Share**: you get a link with the whole paper packed into it. Anyone who opens that link lands in their own editor with your paper loaded and *editable* — a fork, not a read-only view. Paste it in a thread, a PR, a Discord. (Uploaded images are too big for a URL; use the ⬇ download and send the `.paper` file instead.)
|
|
83
|
+
|
|
84
|
+
**Receiving one.** Open the link, or drag a `.paper` file onto the preset panel. Either way it lands in your library next to the built-ins, ready to take apart.
|
|
85
|
+
|
|
86
|
+
**Using one in your project.** A `.paper` file is a preset object, so it goes straight in:
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
import alice from './alice-note.paper.json'
|
|
90
|
+
|
|
91
|
+
<Paper preset={alice} autoplay />
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Or register it once by name and refer to it everywhere:
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
import { registerPreset } from 'paperlab'
|
|
98
|
+
|
|
99
|
+
registerPreset('alice-note', alice)
|
|
100
|
+
<Paper preset="alice-note" />
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
That's the whole loop: **make → send → remix → ship.** If you'd rather your paper shipped *with* the library so everyone gets it by name, that's the first rung of [CONTRIBUTING.md](https://github.com/NourMtir0722/Paperlab/blob/main/CONTRIBUTING.md) — a preset PR is JSON and no code.
|
|
104
|
+
|
|
63
105
|
## Repository
|
|
64
106
|
|
|
65
107
|
| | |
|
|
66
108
|
|---|---|
|
|
67
|
-
| [`packages/paperlab`](https://github.com/NourMtir0722/Paperlab) | the npm library |
|
|
68
|
-
| [`apps/editor`](https://github.com/NourMtir0722/Paperlab) | the editor |
|
|
109
|
+
| [`packages/paperlab`](https://github.com/NourMtir0722/Paperlab/blob/main/packages/paperlab/) | the npm library |
|
|
110
|
+
| [`apps/editor`](https://github.com/NourMtir0722/Paperlab/blob/main/apps/editor/) | the editor |
|
|
111
|
+
| [`apps/playground`](https://github.com/NourMtir0722/Paperlab/blob/main/apps/playground/) | the playground — one input, one scene, shareable by link |
|
|
69
112
|
| [`docs/llms.txt`](https://github.com/NourMtir0722/Paperlab/blob/main/docs/llms.txt) | the agent-readable API reference |
|
|
113
|
+
| [`docs/roadmap.md`](https://github.com/NourMtir0722/Paperlab/blob/main/docs/roadmap.md) | what this is, what's decided, and what's next |
|
|
70
114
|
|
|
71
115
|
```sh
|
|
72
|
-
pnpm test #
|
|
116
|
+
pnpm test # unit suite — deformer math, schema, cloth, layouts, exports
|
|
73
117
|
pnpm test:parity # GPU golden-vector gate: every deformer's GLSL twin vs its JS twin
|
|
74
118
|
pnpm build
|
|
75
119
|
```
|