Build Interactive Particle Trail
Meng ToCommunityCreated by Meng To
- Skill
- Tool integration
- Software development
- MIT
- Low risk
- Has scripts
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a technical approach to creating interactive particle trails that respond to pointer movement. By emitting particles based on distance traveled rather than time, it ensures consistent spacing regardless of gesture speed. The implementation utilizes a fixed-size GPU point pool to manage memory efficiently, with logic for handling resting states, keyboard-triggered bursts, and accessibility requirements like reduced motion preferences.
What it does
- Calculates particle emission based on pointer travel distance to maintain uniform spacing.
- Implements a ring buffer system to recycle a fixed-size GPU point pool.
- Handles resting pointer states to prevent particle clumping.
- Integrates keyboard-triggered bursts using the same particle pool.
- Provides logic for raycasting pointer interactions onto a stable 3D plane.
- Includes guidelines for managing lifecycle, motion preferences, and resource cleanup.
When to use it
- When you need individual particles to react to cursor or touch gestures.
- When you require consistent particle density across varying gesture speeds.
- When building interactive elements like dust, pollen, or mote effects.
- When you need to share a single particle pool between pointer movement and keyboard bursts.
Advantages
- Prevents gaps during fast movements and clumping during idle states.
- Maintains stable memory usage through fixed-size GPU pool allocation.
- Supports accessibility by respecting reduced motion settings.
- Ensures consistent visual behavior across different display densities and input types.
Usage examples
- “How do I ensure my particle trail doesn't leave gaps when the user moves the mouse quickly?”
- The skill explains using distance-based emission logic to interpolate points between the previous and current pointer positions, ensuring consistent spacing.
- “How can I add a keyboard-triggered burst to my existing particle trail?”
- The skill provides a method to map a control to the same interaction plane and spawn particles from the shared pool, maintaining visual consistency.
Install
1 of its files are not mirrored here, so install it from its source:
https://github.com/MengTo/Skills/tree/5ea1661a0e05d82b054553daaa6baf6d0233c33c/agent-skills/web-design/build-interactive-particle-trail
Documentation by Meng To
Build an Interactive Particle Trail
Emit discrete motes per unit of pointer travel, spread them across the entire segment, and recycle a fixed GPU pool. Reach for ambient-section-particles when particles are primarily autonomous atmosphere; reach for add-shader-cursor-trail when the output should be a continuous fluid or shader ribbon. Use this Skill when individual grains must react to the gesture.
Extracted from inner-green-3d.html, where a pointer had to lift pollen off a procedural moss root without a fast sweep leaving gaps or a resting cursor pumping a bright clump.
Resolve the interaction plane
Convert the pointer into normalized device coordinates, raycast from the camera, and intersect one stable plane near the visual surface. Reuse that hit for all interaction systems.
Reset the previous hit when the pointer leaves or the ray misses. Otherwise re-entry draws a long diagonal from the stale exit point.
For a curved visible surface, either intersect the real collider or place the response plane just in front of it. Do not raycast every decorative blade or particle.
Emit by distance
Spacing, not time, is the mechanism:
const distance = current.distanceTo(previous);
const count = Math.min(14, Math.floor(distance / 7));
for (let i = 1; i <= count; i++) {
point.lerpVectors(previous, current, i / count);
spawn(point);
}
if (count) {
previous.copy(current);
idle = 0;
} else if ((idle += dt) > 0.055) {
spawn(current); // a resting hand trickles; it does not pump
idle = 0;
}A timer emitter leaves dots behind a fast flick and piles them under a resting hand. Segment interpolation fixes both. Cap each frame at 14 emissions so a tab resume or teleport cannot exhaust the pool in one burst.
Use these landed defaults:
| parameter | default | failure prevented |
|---|---|---|
| path spacing | 7 px/world units | wider gaps read as samples, tighter gaps become a ribbon |
| per-frame cap | 14 motes | teleports overwrite the whole pool |
| idle interval | 55 ms | no idle emission feels dead; faster becomes a hotspot |
| pool size | 620 | enough overlap for a 1.6 s trail without unbounded allocation |
| lifetime | 1.6 s | shorter trails break; longer trails cloud the content |
| random size | 0.50–1.15 | identical points read as a stippled brush |
| DPR cap | 2 | fill cost spikes on dense displays |
Recycle a GPU pool
Allocate typed arrays once for origin, velocity, birth time, and random seed. Advance a ring head on spawn:
const index = head;
head = (head + 1) % POOL_SIZE;
origins.set([x, y, z], index * 3);
velocities.set([vx, vy, vz], index * 3);
birth[index] = elapsed;
random.set([size, phase], index * 2);
dirty = true;Mark dynamic attributes for upload only after respawns. Animate flight in the vertex shader from age = uTime - aBirth; do not integrate 620 particles on the CPU:
float age = uTime - aBirth;
float u = age / uLife;
vec3 p = position + aVelocity * age * (1.0 - 0.34 * u)
+ vec3(sin(aRandom.y * 6.283 + age * 2.6) * 22.0 * u,
46.0 * age,
0.0);
vAlpha = smoothstep(0.0, 0.09, u)
* (1.0 - smoothstep(0.40, 1.0, u));Cull dead points in the vertex shader by setting size to zero and moving them outside clip space. Render the pool as one THREE.Points draw call with a prebuilt soft radial texture, additive blending, and depthWrite: false.
Reuse the pool for bursts
Map a button or focused control to the same interaction plane and call spawn 40–60 times with a 2.5× spread. One pool keeps visual language, budget, and cleanup shared.
Expose a real Release pollen button with visible focus and an aria-live confirmation. Do not make pointer movement the only way to see or trigger the effect.
Respect motion and lifecycle
Under
prefers-reduced-motion: reduce, do not advance particle age. Seed a designed curved trail and let the burst button replace it with a denser still composition.Clamp
dtto 1/30 s and reset time after resume.Pause on
document.hiddenand while the section is offscreen.Size from
ResizeObserver, guard zero viewports, and cap DPR at 2.Use Pointer Events so pen and touch can participate when the surface supports it; avoid hover-only instructions.
On teardown, cancel the frame, disconnect observers, remove listeners, and dispose point geometry, material, sprite texture, and renderer.
State the cost honestly
The per-particle flight math is not the main cost; additive point overdraw and attribute uploads are. Keep sprites small, keep the pool fixed, upload only when the ring changes, and reduce lifetime before raising the pool. Measure GPU frame time and upload cost on a dense display before claiming the shader path is faster.
Verify
Compare a slow crawl and fast flick over the same path; spacing remains approximately equal.
Stop moving; confirm a trickle rather than a growing opaque clump.
Leave and re-enter; confirm no diagonal bridge from the stale point.
Trigger the keyboard burst and confirm it reuses the same pool.
Test repeated bursts; pool length stays 620 and memory stays flat.
Test 390×844, 1440×900, touch/pen, and fast resize.
Test
?reduced=1: composed still, no aging, live burst button.Hide/show and leave/re-enter the viewport; confirm no time jump.
Tab through controls, confirm visible focus and live announcements.
Confirm a clean console at both sizes.
Use demo/index.html as the working proof and demo/PROMPT.md to recreate or remix it.
Files
- ATTRIBUTION.mdAdded by AutoGineer886 B
- LICENSELicence file added by AutoGineer1.0 KiB
- SKILL.md5.9 KiB
- agents/openai.yaml246 B
- demo/PROMPT.md1.8 KiB
- demo/assets/card-ethos.jpg309.3 KiB
- demo/assets/lexend-latin.woff2(opens on GitHub)Not mirrored: opens on GitHub38.8 KiB
- demo/assets/three.min.jsScript593.8 KiB
- demo/index.html16.3 KiB
- demo/preview.jpg101.9 KiB
demo/PROMPT.md
Interactive Particle Trail Demo Prompts
Minimal prompt
Use $build-interactive-particle-trail to lift discrete pollen along this pointer path with consistent spacing at any gesture speed.Recreate the demo
Use $build-interactive-particle-trail to recreate Sylva — Pollen Trace as a standalone local HTML demo.
Preserve the grey-green field, low light pool, white Lexend headline, pale field card, ghost wordmark, and procedural root silhouette.
Show a composed pollen trace on the first screen, then let pointer, pen, or touch movement replace it with a live trail.
Raycast one interaction plane. Emit every 7 units along the complete traveled segment, cap at 14 motes per frame, and trickle once every 55 ms while idle.
Recycle a 620-point ring with a 1.6-second lifetime. Store origin, velocity, birth time, size, and phase in dynamic attributes; integrate flight in the vertex shader.
Add a keyboard-accessible Release pollen button that reuses the same pool for a 52-mote, 2.5× burst and announces the result.
Reset the previous hit on leave or ray miss.
Cap DPR at 2, clamp
dtto 1/30 s, size fromResizeObserver, and pause offscreen or hidden.Under reduced motion, seed a designed still trail; the button replaces it with a denser still rather than animating.
Support 390px through 1440px, visible focus, and a clean console.
Keep dependencies local in
demo/assets/.
Remix prompt
Use $build-interactive-particle-trail for a dark indigo astronomy chart where the pointer sheds small amber star grains. Change the subject, palette, type, and composition, but keep distance-based segment emission, the fixed 620-point pool, 1.6-second shader flight, stale-point reset, keyboard burst, reduced-motion still, and lifecycle budgets.Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs Node.js
Security
What our scanner noticed· Low risk
- Scripts that your agent may run
This skill includes scripts that your agent may run. Read them before you use it.
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- Meng To
- Publisher
- Meng To (Community)
- Source
- MengTo/Skills · agent-skills/web-design/build-interactive-particle-trail · commit 5ea1661
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Meng To.
Get it from the source
1 of this skill’s files are not mirrored here, so there is no ZIP. Get the complete skill from its source: MengTo/Skills