webgl-particle-galaxy
它能做什么
创建一个视觉效果非常惊艳的动画,成千上万个明亮的光点像银河一样一起旋转。整个过程直接在你的浏览器中完成,无需下载任何东西。
适用场景
- ✓为网站制作一个有未来感的动态背景。
- ✓在网页上展示复杂的视觉效果。
- ✓当你需要一个吸睛且有技术含量的视觉元素时。
技能链接
https://github.com/nexu-io/open-design/blob/main/plugins/_official/examples/webgl-particle-galaxy/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“帮我创建一个旋转的粒子星系,用作网站背景。”
每周 5 个新技能,1 分钟读完。
工作原理
它使用一种叫 WebGL 的技术,直接在你电脑的显卡上绘制成千上万个光点。这些光点沿着实时计算出的轨道运动,从而形成星系的效果。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Particle Galaxy Skill
Produce a single self-contained index.html that renders a real-time particle system full-screen, with a clean typographic overlay on top. The signature move: compute each particle's position on the GPU so the CPU never loops over particles.
Why this is a powered artifact
OpenDesign detects getContext('webgl2') and renders this file in powered preview — a cross-origin-isolated iframe with allow-same-origin. The full GPU pipeline is available; you do not need to work around the opaque sandbox.
Resource map
webgl-particle-galaxy/
├── SKILL.md ← you're reading this
└── example.html ← a working 50,000-point WebGL2 galaxy (READ FIRST)
Workflow
Step 0 — Read the reference
Read example.html end to end. Note the shape: no vertex buffer — the vertex shader reads gl_VertexID, hashes it into a stable per-particle seed, and derives a log-spiral orbit with an inner-fast rotation curve. Points are drawn with gl.drawArrays(gl.POINTS, 0, N) in one call, additive-blended (blendFunc(ONE, ONE) with premultiplied color) so overlapping points glow.
Step 1 — Pick the motion
Choose a field the vertex shader can express cheaply from gl_VertexID + uTime:
- Spiral galaxy (default): log-spiral arms, rotation curve
speed ≈ k / (r + ε), thin disk. - Attractor / flow: curl or a strange-attractor step baked as a closed-form function of time.
- Explosion / reform: interpolate between a seeded start and a target shape on a looping clock.
Step 2 — Build index.html
- One file, zero external requests. Bind a VAO even with no attributes (some drivers require it).
- Point size in the vertex shader (
gl_PointSize), clamped and DPR-aware; soft round sprites viagl_PointCoord+ a gaussian falloff in the fragment shader. - Additive blending on a dark clear color; premultiply the fragment color so
blendFunc(ONE, ONE)reads as glow, not double-exposure. - Compile shaders with error logging (
getShaderInfoLog/getProgramInfoLog) so a typo fails loudly.
Step 3 — Overlay + brand
- Map the accent colors to the active DESIGN.md when one is present; otherwise a restrained dark palette with one vivid accent (the reference uses lime
#63fe13for the arms and a white-blue core). - Headline ≤ 15ch plus one supporting line. Never bury the particles behind the text.
Step 4 — Self-review (P0)
- Renders continuously at ~60fps; the FPS badge updates.
- Tens of thousands of points in a single draw call (no per-particle CPU loop).
- No WebGL console errors; program links cleanly.
- Resizes crisply on window resize (no stretching / blur).
- Degrades to a message (not a blank page) if
webgl2is unavailable.
常见问题
这里的“粒子”是什么意思?
它们就是一些小小的光点或彩色圆点,把它们聚在一起,就组成了星系的图像。
为什么它运行得很快?
因为每个光点的运动计算都是由显卡(GPU)完成的。对于这类任务,显卡比主处理器(CPU)快得多。
我需要安装什么软件吗?
不需要,所有内容都直接在你现代的网页浏览器中运行。
详情
作者的原始描述
A real-time particle galaxy — tens of thousands of additive-blended GPU points spiraling around a bright core, their orbits solved entirely in the vertex shader (from gl_VertexID), so the whole cloud draws in one call. Rendered as a single self-contained `index.html`. Use when the brief asks for a "particle field", "particle galaxy", "point cloud", "instanced points", "starfield", "GPU particles",
repo: nexu-io/open-design
热度
- GitHub 星标
- 101k
- 排名
- #1061
- 许可证
- Apache-2.0
- 更新时间
- 2026/10/15
评论
- …