Constellation
NewFreeA living star network: points of light drifting through depth with parallax and bokeh, joined by delicate lines that form and dissolve, now and then drawing a named figure.
- canvas
- stars
- constellation
- network
- particles
- background
- interactive
- hero
Installation
pnpm dlx shadcn@latest add https://kagadmodyaa.vercel.app/r/constellation.jsonNeeds a React + Tailwind project set up with shadcn. Copies the effect into your project, along with lib/effect-runtime.ts, the small WebGL layer it runs on. No other dependencies.
Or from npm
pnpm add @kagadmodyaa/effectsimport { Constellation } from '@kagadmodyaa/effects/constellation'One package with every free effect, one import path each. No Tailwind or shadcn needed, and no stylesheet to import: the few layout rules an effect needs come with it. The npm package and the command above ship the same source.
Usage
Use it like any other component. Choose a theme with preset; any prop you pass as well overrides the preset.
import { Constellation } from '@/components/effects/constellation/constellation'
export function Hero() {
return (
<section className="relative h-[640px] overflow-hidden">
{/* fills its parent; move the pointer over it, or click for a supernova */}
<Constellation preset="Observatory" className="absolute inset-0" />
<div className="relative z-10 mx-auto max-w-xl px-6 pt-28 text-center text-white">
<h1 className="text-5xl font-semibold tracking-tight">Find the shape of the night.</h1>
</div>
</section>
)
}
// Presets: Observatory, Aurum, Chart (the light one: ink on paper), Nebula, Mono.
// The stage above is <ConstellationShowcase />, also exported, with a headline and a button that calls
// ref.current.nova() to set off a supernova. figureRegion=[left, top, right, bottom] keeps figures clear of your copy.<Constellation preset="Aurum" count={220} />Presets
ObservatoryAurumChartNebulaMono
Props
| Name | Type | Default | Description |
|---|---|---|---|
| preset | 'Observatory' | 'Aurum' | 'Chart' | 'Nebula' | 'Mono' | none (the defaults below) | A named theme. Any prop you pass as well overrides the preset’s value. |
| count | number | 220 | Stars on a 1200 by 720 stage. The count scales with the size of the stage and backs off on slow devices. Range 60 to 600. |
| starSize | number | 1 | Size of the stars. Brighter and nearer stars are larger. Range 0.4 to 2.5. |
| twinkle | number | 0.55 | How much the stars shimmer, with now and then a brief glint. Range 0 to 1. |
| spread | number | 0.7 | How much star colours vary with temperature, from cool to hot. 0 is a single colour. Range 0 to 1. |
| linkDistance | number | 135 | How far a star reaches for a neighbour. Near stars reach further, far ones less. Range 40 to 260 px. |
| linkOpacity | number | 0.55 | Strength of the lines between stars. Range 0 to 1. |
| linkWidth | number | 1 | Width of the lines, as a multiple of a hairline. Range 0.4 to 2.2. |
| figures | boolean | true | Now and then a handful of stars glide into a named figure and are joined by crisp lines. |
| depth | number | 0.65 | Parallax between the layers: how far the camera drifts and leans with the pointer. 0 is a flat sky. Range 0 to 1. |
| bokeh | number | 0.55 | Depth of field. Stars in front of and behind the focus layer melt into soft discs. Range 0 to 1. |
| nebula | number | 0.6 | Two layers of drifting cloud behind the stars. Range 0 to 1. |
| speed | number | 1 | How fast the sky drifts and the figures come and go. 0 freezes it. Range 0 to 3. |
| pointerRadius | number | 0.22 | Size of the pointer's lantern, as a fraction of the stage's shorter side. Range 0.05 to 0.5. |
| pointerForce | number | 1 | How strongly the pointer pulls and lights the stars and how hard a click bursts. 0 turns it off. Range 0 to 2. |
| pointerLinks | boolean | true | Join the stars near the pointer to it with fine lines. |
| starColor | string | '#e4eeff' | Ordinary stars. A hex colour. |
| warmColor | string | '#ffd9b4' | The hot end of the spectrum. A hex colour. |
| coolColor | string | '#93b6ff' | The cool end of the spectrum. A hex colour. |
| linkColor | string | '#8fb0ff' | The lines between stars. A hex colour. |
| background | string | '#050a17' | Background colour. A light colour switches the sky to a chart: ink dots and hairlines on paper. A hex colour. |
| hazeA | string | '#1d3f9a' | Broad, soft cloud. A hex colour. |
| hazeB | string | '#0f7c97' | Finer, wispier cloud. A hex colour. |
| grid | number | 0 | A faint chart grid of circles, meridians and a degree scale. Range 0 to 1. |
| grain | number | 0.3 | Film grain. A little is always on to keep the dark gradients smooth. Range 0 to 1. |
| className | string | — | Extra class on the root element. The effect fills its parent: give the parent a height. |
| style | CSSProperties | — | Inline style on the root element. |
Files
What the command adds to your project, and where.
components/effects/constellation/constellation.tsxThe component.
components/effects/constellation/network.tsxThe component.
components/effects/constellation/showcase.tsxThe component.
components/effects/constellation/poster.tsxThe component.
components/effects/constellation/engine.tsThe component.
components/effects/constellation/sprites.tsThe component.
components/effects/constellation/loop.tsThe component.
components/effects/constellation/look.tsThe component.
components/effects/constellation/figures.tsThe component.
lib/effect-runtime.tsShared by every shader effect: resizing, pausing, reduced motion, context loss and the no-WebGL fallback. Installed once.
Behaviour
- Stars drift slowly on layers: near ones slide further than far ones as the camera wanders, and the pointer leans it a little. Depth also sets size and brightness, and a focus plane sits in the middle, so stars in front of and behind it become soft bokeh discs. Set depth to 0 for a flat sky.
- Each star links to its few nearest neighbours on the same layer. Lines fade with distance, depth and focus, and they grow in and dissolve out smoothly as stars drift together and apart, so the network is always rewiring.
- Every so often a handful of stars glide into a named figure: crisp lines are drawn between them, they flare with diffraction spikes and the name appears, then everything lets go and drifts on. Turn constellation figures off to keep it a pure drifting network.
- Move the pointer over the page and it becomes a lantern: nearby stars brighten, lean toward it and join it with fine lines. Click or tap to set off a supernova, a shock wave that pushes the stars outward; they spring back and re-link.
- Chart is made for light pages: ink dots, hairlines, a faint grid with a degree scale and Greek letters on the figure stars, on paper. Any light background colour switches the sky to that style.
- It fills its parent and shares a single animation frame with every other instance on the page. It pauses off screen and in a background tab, lowers its resolution and star count automatically when frames run slow, and draws one composed still frame, with a figure in place, under prefers-reduced-motion. Before the first frame, and without a canvas, you see an SVG poster in the same colours.