Communitygithub.com

particle-sculpture

Add a 3D particle sculpture to a web page - thousands of small outlined glyphs (triangles, rings, dots) that form one shape and morph into a second as the visitor scrolls or swipes, and react to the pointer. Ships a ready web component, 20 baked shapes (brain, lightbulb, globe with continents, seed, tree, heart, key, shield and more) and a way to bake the user's own logo, image or 3D model (GLB/OBJ, for example from Sketchfab). Use whenever the user wants a particle hero, a morphing or shape-shifting 3D animation, a point cloud that turns into something else, a scroll-driven WebGL centrepiece, or wants to turn a logo or model into particles, even if they do not name the skill.

O que é particle-sculpture?

particle-sculpture is a Claude Code agent skill that add a 3D particle sculpture to a web page - thousands of small outlined glyphs (triangles, rings, dots) that form one shape and morph into a second as the visitor scrolls or swipes, and react to the pointer. Ships a ready web component, 20 baked shapes (brain, lightbulb, globe with continents, seed, tree, heart, key, shield and more) and a way to bake the user's own logo, image or 3D model (GLB/OBJ, for example from Sketchfab). Use whenever the user wants a particle hero, a morphing or shape-shifting 3D animation, a point cloud that turns into something else, a scroll-driven WebGL centrepiece, or wants to turn a logo or model into particles, even if they do not name the skill.

Funciona com~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/0sen/particle-studio/tree/HEAD/skill/particle-sculpture

Perguntar na sua IA favorita

Abre um novo chat com esta habilidade de agente já pré-carregada.

Documentação

Particle sculpture

A web component, <particle-sculpture>, that draws two shapes out of the same particles and morphs between them. It is one JavaScript file with three.js built in, plus small point files (.pts) for the shapes. No build step and no framework are needed; it works in plain HTML and inside React, Vue, Astro, Next.js and the like.

Everything you need is in this skill's assets/ folder:

  • assets/particle-sculpture.js: the element (about 0.5 MB, three.js included).
  • assets/library/<name>.pts: 20 ready shapes, 20,000 points each (about 120 KB each).
  • assets/library/manifest.json: suggested pairs with palettes, and the credits three shapes need.
  • assets/example.html and assets/sculpture.json: a complete working page. Copy from them.
  • assets/LICENSES.txt: the MIT licence of three.js. It must travel with particle-sculpture.js.

Add one to a site

  1. Pick two shapes (see "Shapes") and copy these into one folder the site serves as static files, for example public/sculpture/: particle-sculpture.js, LICENSES.txt and the two .pts files. Copy the files as they are. Do not import the script through a bundler: it is already bundled, and it fetches its other files at run time.
  2. Write sculpture.json in the same folder. Only subjects is required:
{
  "subjects": ["seed.pts", "tree.pts"],
  "direction": "down",
  "palette": ["#efeadc", "#7bd389", "#efeadc", "#d9a441"],
  "background": "#0b0b0c",
  "glyphs": ["triangle"],
  "fieldCount": 160
}
  1. Put the element in the page:
<script type="module" src="/sculpture/particle-sculpture.js"></script>
<particle-sculpture config="/sculpture/sculpture.json" style="height: 300vh"></particle-sculpture>

Paths in subjects and poster are relative to the config file. The src and config paths themselves follow normal URL rules: root-absolute (/sculpture/...) when the site is served from the domain root, relative when it may live in a subfolder. The full list of settings is in references/config.md; read it before setting anything beyond the example above.

A page can hold several sculptures. Load the script once, and give each element its own config file under any name (hero.json, network.json). Each one is a separate WebGL canvas, so keep it to a few per page.

Choose how it morphs

  • "direction": "down" follows the page scroll. Give the element a height well above the viewport (300vh is a good start); the canvas pins itself while the page scrolls through the element. Pinning uses position: sticky, which silently stops working when any ancestor has overflow: hidden, auto or scroll. Check the ancestors; this is the most common reason a scroll sculpture does not stay in place.
  • "direction": "side" shows two round arrow buttons at the bottom centre and follows a horizontal drag and the arrow keys. Use it when the sculpture sits in a normal-height section. Give the element a fixed height such as 70vh. The buttons are white on translucent black and cannot be restyled from the page, so they suit dark backgrounds; on a light background drive progress from your own buttons instead.
  • To drive it yourself (a button, a timeline, a scroll library), set the element's progress property to a number from 0 to 1. The ready promise exists only once the script has loaded, so wait for the element first:
await customElements.whenDefined('particle-sculpture');
const el = document.querySelector('particle-sculpture');
const ok = await el.ready;   // false when the sculpture could not start

Lay it out

  • Size and position. The shape is always centred in the element and scaled to it. To put the shape on the right with a headline on the left, make the element narrower and move the element (a grid column, or margin-left: 40%); the pinned canvas takes the element's width, not the viewport's. On narrow screens let it go full width and put the copy above or over a solid backing.
  • Copy that stays during a scroll morph. The element has no slot for content. Put the copy in a sibling that covers the element (position: absolute; inset: 0) and inside it a block with position: sticky; top: 0; height: 100vh, so the headline stays for the whole morph. assets/example.html does exactly this. Give the overlay pointer-events: none (and auto on its links and buttons) so the pointer still reaches the particles.
  • Text and particles. Keep text off the middle of the shape or give it a solid backing. The particles are bright, and text over them is hard to read.
  • Name it for assistive technology. The canvas has no label of its own. Put role="img" and an aria-label describing the two shapes on the element when it carries meaning, or aria-hidden="true" when it is decoration. Leave the role off a side-mode element, which is focusable and has real buttons inside.

Shapes

The 20 library shapes: brain, lightbulb, seed, tree, car, trophy, dna, figure, cube, skyline, globe, network, heart, home, key, shield, book, cap, bubble, soundwave. Any two can be paired. manifest.json lists ten pairs chosen for meaning (thinking → idea, start → growth, access → security and so on) with a palette each; prefer one of them when the user has no shapes in mind. book, cube and car read less clearly than the rest, so avoid them for a hero unless asked.

brain, lightbulb and car come from CC BY 4.0 models. If the page uses one, the credit in manifest.json (title, author, source, licence link, changes) has to be shown somewhere on the published site, such as the footer or a credits page. The element does not show it. Add it, and tell the user you did and why.

For the user's own logo, image or 3D model, read references/custom-shapes.md. In short: the free studio at https://particles.shirlaw.app turns an upload into the files with no install, and the open-source project bakes them from the command line.

Make it fit the site

  • Take palette (one to four colours) and background from the site's own colours rather than keeping the defaults. Each entry gets an equal share of the particles, so repeat a colour to weight it: neutral, accent, neutral gives the accent a third. On a light background use darker particle colours; glyphs are thin outlines, and pale colours vanish on white.
  • Set background to the colour of the section behind the element so the canvas has no visible edge.
  • colorGrouping (0 to 1, default 0.7) makes neighbouring particles share a colour so the palette falls in bands; 0 is confetti. fieldCount (0 to 2000) adds glyphs drifting behind and in front of the shape; 100 to 300 gives depth without clutter.

What to check before you finish

  • Open the page and confirm the shape draws and morphs. A blank area almost always means a wrong path: the browser's network tab will show a 404 for sculpture.json or a .pts file. The page must be served over http(s); opening the file directly from disk blocks the fetches.
  • The element needs WebGL 2. Where it is missing, or a file fails to load, ready resolves false and the element shows the poster image from the config if there is one, and nothing otherwise. It keeps its height either way, so a 300vh scroll hero becomes a tall empty stretch. Handle that: when ready is false, add a class that collapses the element to a normal height, as assets/example.html does. If you can take a screenshot of the working sculpture, also save it as the poster with a posterAlt; if you cannot, say so and leave the poster out rather than pointing at a file that does not exist.
  • Phones and narrow viewports draw at most 8,000 particles automatically. With prefers-reduced-motion the element crossfades instead of flying the particles. You do not need to add either.
  • In a framework that renders on the server, load the script on the client only (a <script type="module"> tag, or the framework's client-side script component). The custom element tag itself is safe to render on the server.
  • Under a Content Security Policy, the element needs script-src for its file, connect-src for sculpture.json and the .pts files, and img-src for the poster. It needs no inline styles.

Limits worth telling the user

It has been tested in Chromium only, and frame rate has not been measured on real phones. Say so if the user asks about browser support or performance rather than guessing, and suggest lowering count if a device struggles.

Habilidades Relacionadas