Page Turn Effect
A Three.js WebGL page-curl transition that animates a plane geometry between open and closed states.
PageTurnEffect mounts a Three.js renderer into its container div and animates a paper curl by deforming the vertices of a PlaneGeometry. When isOpen changes the right side of the plane folds toward the centre, simulating a page turning. A paper-texture.png is loaded as a material map if present at the public root.
The component fills its parent absolutely (w-full h-full absolute inset-0), so place it inside a position: relative container with explicit dimensions.
SSR note —
PageTurnEffectis"use client"and initialises a WebGL context on mount. Wrap it indynamic(() => import(...), { ssr: false })for Next.js apps.
Installation
npx shadcn@latest add @adv/page-turn-effectUsage
import { useState } from 'react';
import dynamic from 'next/dynamic';
const PageTurnEffect = dynamic(
() => import('@/components/page-turn-effect'),
{ ssr: false }
);
export default function BookPage() {
const [open, setOpen] = useState(false);
return (
<div className="relative w-80 h-96">
<PageTurnEffect isOpen={open} onComplete={() => console.log('done')} />
<button onClick={() => setOpen((v) => !v)}>Turn page</button>
</div>
);
}Example
status: idle
Props
| Prop | Type | Default | Description |
|---|---|---|---|
isOpen | boolean | — | Required. Drives the animation direction — true curls the page open, false curls it closed. |
onComplete | () => void | — | Required. Called when the curl animation reaches its target state. |