particle-system
This skill should be used when the user asks to "build a particle system", "make confetti/snow/smoke/sparks", "create a connected-dot/constellation network background", "add a flow-field or curl-noise particle effect", "render thousands of GPU particles with Three.js Points", or "animate emitters with forces". Covers per-particle integration, forces, flow fields, burst/continuous emission, spatial-grid connected dots, and GPU points + shaders.
1How It Works & Mechanism
Capabilities rely entirely on "inline runnable code + rules": SKILL.md directly provides per-particle state integration loops, force functions, flow fields / curl noise, spatial grid connections, and GPU Points shader snippets—ready to copy and run without libraries or build steps.
Drive many small elements with simple per-particle rules to get emergent, organic motion. Use 2D canvas for hundreds, GPU `Points` for thousands.
Stability depends on integration scheme rather than parameter tuning: Explicitly requires semi-implicit Euler (update velocity first, then update position with new velocity) and dt clamping, reasoned respectively by stability under spring/damping forces and preventing simulation blowups after browser tab throttling.
Prefer **semi-implicit Euler** (update velocity first, then position with the new velocity, as above) — it is stable for the spring/drag forces particles use. Use a fixed or clamped `dt` (`Math.min(dt, 1/30)`) so a stalled tab does not explode the simulation.
Performance bottlenecks are identified with data structure solutions: Connected-dot networks avoid pairwise comparisons by bucketing particles into radius-based cells and checking only 8 neighboring cells, reducing complexity from O(n²) to near O(n).
Naively checking every pair is O(n²) and dies past ~300 particles. Use a **uniform spatial grid**: bin particles by cell, only compare against the 8 neighboring cells.
The path to tens of thousands of particles is moving animation into the vertex shader: Positions are fed into BufferGeometry and rendered as Points, along with two specific switches for a "glowing dot" look—additive blending + disabling depth writes, and discarding pixels via gl_PointCoord distance to clip squares into circles.
`AdditiveBlending` + `depthWrite: false` gives the glowing-particle look. `discard` on `gl_PointCoord` distance makes square points round.
Deliverables are restricted to single-file HTML without bundlers: Inline 2D canvas, or GPU mode referencing three from a CDN via importmap—one render loop, zero build steps.
For a self-contained particle effect (constellation background, confetti burst, flow field, GPU points) the deliverable is **one HTML file that opens directly in a browser** — canvas 2D inline, or Three.js from a CDN via an importmap for GPU `Points`, one render loop, no build step.
Determinism is the prerequisite for verification: Uses seeded PRNG (mulberry32) instead of raw Math.random, making `?t=N` freeze-frames reproducible—the same N yields the exact same pixels, making screenshot verification viable.
**Seed the RNG** — replace bare `Math.random()` with a seeded PRNG (e.g. mulberry32) so spawn positions, angles, and bursts reproduce frame-for-frame.
2Core Capabilities
3External Dependencies
| Kind | Dependency / Endpoint |
|---|---|
| cli | npx playwright screenshot(验证回路:打开本地 file:// 页面并截冻结帧) |
| cli | 仓库根共享脚本 scripts/seek-shot.sh、scripts/contact-sheet.sh(截图与拼图;不在 skill 目录内) |
| cli | ffmpeg / ffprobe(contact-sheet.sh 用 hstack 拼图;probe-mp4.sh 读编码参数) |
| network | 交付 HTML 经 importmap 从 CDN 取 three(GPU Points 分支)——产物期引用,由浏览器拉取 |
| package | simplex-noise(流场/curl 噪声示例引用的噪声库,注释中点名) |
4Recommended Governance & Evidence
- scripts/: Executes local scripts or commands: (SKILL.md instruction) npx playwright screenshot --wait-for-timeout=600 "file://$PWD/
- 网络端点: Declares external network access: No network calls exist in skill directory code; runtime network surface comes from toolchain: `npx playwright` pulls playw from npm registry on first run
- 本地工作目录: File I/O and artifact output: Core deliverable: single particles.html (created by agent per output contract)
5Second-Pass Verification
- [ok] 「skill 目录内无脚本」是否成立(决定蓝而非黄/橙的关键) — 文件清单实证:skills/particle-system/ 下只有 SKILL.md、README.md(0 B)、references/particle-recipes.md。SKILL.md 提到的 `scripts/seek-shot.sh` 实际位于仓库根 scripts/,并非 skill 自有资产;因此判级对象内确实没有可执行代码。已在 reason/risks 记录「单装 skill 目录会使引用悬空」。
- [ok] 是否存在凭证或环境变量读取 — 全仓正则 `process.env|API_KEY|TOKEN|SECRET|Authorization` 在三个 iart 仓内零命中(唯一命中在 javascript-animation-skills 的 soundtrack/references/ai-music.md,属另一 skill)。本 skill 的 credential_reads 为空成立。
- [ok] 是否有比蓝更高的触发条件被漏掉(红档特征) — 对 `sandbox|automationcontrolled|no-verify|stealth|bypass|ignoreHTTPSErrors|dangerously` 全仓扫描零命中;不存在关沙箱、关 TLS、绕过自动化侦测或任意代码执行面。
- [ok] GPU / 无头渲染前提是否真的写进文档(任务特别提示项) — SKILL.md 验证段原文承认这是环境前提并把归因从代码上摘开:'For GPU points, WebGL needs a GPU context; Playwright/Chromium supplies one (swiftshader) headless.';完成清单第 1 条也要求无 WebGL 错误。
- [ok] 「O(n) 连接点」与「?t=N 可复现」两条能力声明是否与代码相符 — 空间网格实现(`cell = radius` 分桶、只查 3×3 邻域)与声明一致;harness 要求 seeded PRNG + 固定步进(`const step = 1 / 60`)再渲单帧,确实保证同 N 同像素。无夸大。
- [ok] reference 描述是否逐条落地 — references/particle-recipes.md 开篇即 'Complete, runnable systems for canvas and GPU particles.',与 SKILL.md 末尾列出的能力项(confetti/snow/smoke、鼠标吸引排斥、simplex 流场与 curl、空间网格星座、GPU Points)在文件内可逐节验证。
6Verdict & Scenarios
d8271a602d6dd44b…