Перейти к содержанию
Skillpedia
Сайты и интерфейсы (фронтенд)7.2k · #13457

pointer-trail-emitter

Что он делает

Этот скилл строит собственный след курсора, который создаёт частицы по пройденному расстоянию, а не по времени. Он нужен фронтенд-разработчикам, которым нужен точный ручной эффект указателя на простом JavaScript и холсте.

Когда использовать

  • ✓Когда нужен след курсора, который выглядит гладко, независимо от того, быстро или медленно движется мышь.
  • ✓Когда готовый шейдерный эффект курсора не даёт нужного контроля.
  • ✓Когда след должен реагировать на движение указателя по части страницы.

Ссылка на скилл

https://github.com/MengTo/Skills/blob/main/agent-skills/web-design/pointer-trail-emitter/SKILL.md

Скопируйте и вставьте её в ваш ИИ (Claude, ChatGPT или Cursor) с просьбой следовать инструкциям.

Как использовать

Самый простой способ: скопируйте сообщение и вставьте его в свой ИИ. Он прочитает скилл и выполнит инструкции.

Готовое сообщение для вставки

Используй этот скилл, чтобы помочь мне: https://github.com/MengTo/Skills/blob/main/agent-skills/web-design/pointer-trail-emitter/SKILL.md Прочитай файл SKILL.md по этой ссылке и следуй его инструкциям в моей задаче.
Хотите, чтобы ваш ИИ сам находил такие скиллы?Установите бесплатный MCP Skillpedia: одна строка, и перед каждой задачей он ищет среди 15 000+ скиллов.Установить за 1 минуту →

Пример запроса к вашему ИИ

“Хочу след курсора на моём сайте, который остаётся гладким, когда я резко дёргаю мышь и когда двигаю её медленно.”

5 новых скиллов в неделю. 1 минута чтения.

Как это работает

Агент измеряет, насколько сдвинулся указатель, затем тратит это расстояние фиксированными шагами, чтобы поставить частицы. След рисуется на холсте простым JavaScript, с небольшим эффектом ожидания, чтобы он не обрывался резко.

Технический текст (оригинальный SKILL.md)

Оригинальный текст автора на английском, прямо с GitHub.

Pointer Trail Emitter

Build the emitter yourself when the trail's density has to respond to how fast the hand is moving.

Reach for add-shader-cursor-trail or shaders-cursor-ripples when you want the packaged WebGPU looks from the Shaders library. Reach for reveal-hover-effect when the cursor exposes a second image through a mask. Reach for ambient-section-particles when motes fill a section and the pointer only disturbs them. Reach for this when the pointer lays them.

The bundled demo keeps the stage intentionally neutral. A plain dark field makes spacing, scatter, and coast easy to judge without a background image competing with the trail. The wisps are dependency-free Vanilla JavaScript rendered through the Canvas 2D API; CSS styles the interface only. There are no shaders, WebGL, or Three.js. Keep the live canvas separate from the interface so the emitter stays testable rather than baked into a composition.

Emit by distance, not by time

This is the whole mechanism. Accumulate the distance the emitter has moved and spend it in fixed steps:

E.acc += moved;
let guard = 0;
while (E.acc >= STEP && guard++ < 14) {
  E.acc -= STEP;
  spawn(/* … */);
}

Spacing along the path is then STEP, whatever the hand is doing, so the trail reads as one continuous ribbon at a crawl and at a flick alike.

Tie emission to a timer instead and spacing becomes proportional to speed — the pointer covers speed × interval between spawns. A flick breaks the line into scattered dots, and a resting hand piles every mote on one spot. That is the failure this prevents, and it is worth building the toggle to see it once.

Measured over one fixed path: distance emission laid 1885 motes slowly and 1738 quickly, a 1.08× spread — the count follows the path. The same two sweeps on a timer laid 2537 and 1545, a 1.64× spread — the count follows the clock.

Cap the loop. A window blur, a tab restore, or a teleporting pointer can hand you a single enormous moved, and without the guard that one frame spawns thousands of motes and stalls.

Place each mote where it is owed

Spawning every mote of a frame at the pointer's current position clumps them at one end of the segment. A flick then reads as a blob with a gap behind it. Lay each at its own distance along the segment:

const t = moved > 1e-6 ? Math.min(1, guard * STEP / moved) : 0;
spawn(E.lx + dx * t, E.ly + dy * t, ang);

Take the ring-buffer slot before advancing it

const i = E.i; E.i = (i + 1) % N;   // correct

Advancing first writes the position into the next slot and the life into this one, so every mote appears where the previous one started. Dense trails hide it; sparse ones show it on every spawn. Symptom to recognise: motes that look one step behind the cursor and pop rather than fade in.

Lag the emitter behind the pointer

Damp the emitter toward the pointer instead of pinning it:

E.x = damp(E.x, px, 16, dt);

A rigidly pinned emitter makes a fast flick look like the trail is welded to the cursor. The lag is what gives the drift its slack.

Anchor the trail to the screen, not the world

For an in-scene 3-D trail, parent the points to the camera and work in camera space. Map the pointer through the frustum's own half-height:

const hh = Math.tan(camera.fov * Math.PI / 360) * D;
const x = nx * hh * camera.aspect, y = ny * hh;

Unprojecting to a world plane instead pins the trail to the set: the moment the rig drifts or parallaxes, the trail swims across the screen rather than staying under the hand.

Use quads or points that ignore depth (depthTest:false, depthWrite:false) and give them their own render order. If the scene has secondary passes — a mirror, a reflection probe — put the trail on its own layer so it never appears in them.

Scale the scatter against the plane it hangs on

Spread is meaningless as an absolute. At a distance of 3.4 units with a 36° camera, the plane the trail hangs on is only about 2.2 units tall — so ±0.03 units of jitter is a thread stitched to the cursor, not a drift.

Compute the plane extent, then express scatter as a fraction of it. The same number that reads as a soft cloud on one camera is a hard line on another.

Let them coast

Damping matters more than initial velocity. At 1 - 1.1 * dt every mote stops within a tenth of a unit of where it spawned and the trail never opens out; halve it and the scatter carries.

Add a slow curl so the drif

Частые вопросы

Нужен ли WebGL или Three.js?

Нет. Скилл использует простой JavaScript и Canvas 2D API, без шейдеров.

Почему не ставить точки по таймеру?

Таймер делает интервал зависимым от скорости, поэтому быстрые движения оставляют пробелы. Испускание по расстоянию сохраняет ровный интервал.

Может ли он работать над 3D-сценой?

Да. Скилл охватывает привязку следа к экрану в 3D-сцене.

Подробности

Оригинальное описание автора

Build a cursor trail whose spacing stays constant at any hand speed, by emitting motes per unit of distance travelled rather than on a timer, so a flick draws the same continuous ribbon as a crawl instead of breaking into scattered dots. Covers sub-segment placement, the ring-buffer ordering trap, the idle breath a distance emitter needs, anchoring the trail to the screen in a 3-D scene, scaling scatter against the plane it hangs on, coasting instead of stopping dead, touch and reduced-motion fallbacks, and why moving the emitter to a DOM overlay to raise its z-index costs more than it buys. U

repo: MengTo/Skills

Популярность

Звёзды на GitHub
7.2k
Место в рейтинге
#13457
Лицензия
MIT
Обновлён
01.11.2026

Полезен ли этот скилл?

0

Войдите , чтобы голосовать.

Комментарии

  • …

Другие скиллы из этого репозитория

3d-cloth-material

7.2k

Помогает агенту создавать реалистичную тканую ткань в Three.js: переплетение нитей, мягкий блеск, естественные складки, подгибы и швы.

ПрограммированиеСайты и интерфейсы (фронтенд)

3d-falling-leaves

7.2k

Помогает агенту добавить в трёхмерную сцену реалистичные падающие листья, которые кувыркаются, уносятся ветром и переиспользуются при движении камеры.

ПрограммированиеСайты и интерфейсы (фронтенд)

3d-four-seasons

7.2k

Помогает агенту добавить в трёхмерную сцену весну, лето, осень и зиму, меняя растительность, свет, небо и снег без перестройки сцены.

ПрограммированиеСайты и интерфейсы (фронтенд)

3d-high-poly-models

7.2k

Помогает агенту создавать детализированные трёхмерные модели с гладкими формами и правдоподобными краями, а затем готовить более лёгкие версии, которые хорошо работают в вебе.

ПрограммированиеСайты и интерфейсы (фронтенд)

Похожие скиллы