ANIMATION · Vite + three
粒子场与自定义 attributeParticle field with custom attributes
THREE.Points + BufferGeometry 自定义 position/size/color attribute,GPU 端简单动效。
旗舰完整演示
可交互场景(拖拽旋转;部分演示支持键盘)。下方提示词用于让 Agent 生成同级成品。
预期产出 · Returns
Vite 页面:数万点粒子流畅动画,可调数量与颜色。
适合用在哪
星空、雨雪、火花、数据点云等效果。
容易踩的坑
- 每帧重建 BufferAttribute 会造成 GC 卡顿,改数量时应节流。
提示词 · Prompt
Vite + Three.js:创建粒子系统
1) BufferGeometry 含 position、size(或 scale)、自定义 aPhase attribute;
2) PointsMaterial 或 ShaderMaterial,在 vertex shader 用 aPhase + uTime 做轻微摆动;
3) 粒子数默认 15000,提供 slider 调整(注意重建 geometry);
4) additive blending 可选;
5) animation loop 更新 uTime;页面卸载时 dispose geometry/material。
输出完整代码,并注释 attribute 的 itemSize 与 normalized 含义。
Vite: THREE.Points with custom attributes, shader wobble, adjustable count, dispose on teardown.