Prismatic Triangles
v1.0.0Your image seen through a wall of faceted glass. Each triangle bends the picture at its own angle and splits the colour at its edges, and the facets lean toward the pointer as it passes. Shows the plain image under reduced motion.
Installation
Run once in your project root to configure paths and dependencies:
npx vectorvesper initDownloads and registers the component in your project:
npx vectorvesper add prismatic-trianglesIf installing manually or managing your package lock:
npm install @vectorvesper/motion threeUsage
A hero or feature panel where one strong image should feel like it sits behind glass: a product shot, a portrait, architecture. Bold colour and clear shapes refract best; a busy or low-contrast image turns to noise.
Import
Usage
Do
- Use position to keep the subject in view when the image is cropped to fit.
- Keep refraction low when text sits on top; the higher it goes, the more the picture breaks up.
Don't
- Do not pass a small image. It is stretched to cover the area, and the facets magnify any blur.
WebGL — render it on the client only
On Next.js, load it with ssr: false from a Client Component, as below. Vite apps need nothing extra.
prefers-reduced-motion and provides a graceful fallback.Props
Your image seen through a wall of faceted glass. Each triangle bends the picture at its own angle and splits the colour at its edges, and the facets near the pointer lean toward it and catch the light.
<PrismaticTriangles />
The glass and the image behind it. Fills the area, which is 100svh tall unless you size it.
| Prop | Type | Default | Description |
|---|---|---|---|
src* | string | — | The image behind the glass. It fills the area the way `object-fit: cover` does. |
position | string | "50% 50%" | Which part of the image stays in view when it is cropped, as CSS `object-position`. |
density | number | 5 | How many triangles fit the height. |
refraction | number | 0.035 | How far each facet bends the image, as a share of the height. |
dispersion | number | 0.35 | How much the bent image splits into colour, 0 to 1. |
tilt | number | 0.8 | How far the facets lean, 0 to 2. |
speed | number | 0.25 | How fast the light turns. |
glow | number | 1 | How bright the edges near the pointer get. 0 turns it off. |
reach | number | 0.45 | How far the pointer reaches, as a share of the height. |
className | string | — | Sizes the area. Without a height it is 100svh tall. |
style | React.CSSProperties | — | Inline styles for the area. A height here wins over the default. |
children | React.ReactNode | — | Content drawn over the glass. |