particle-system
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseParticleSystem (SDK7)
ParticleSystem(SDK7)
Emit particles from an entity. One component per entity, attached alongside a . No mesh required — particles render from the component itself.
ParticleSystemTransform从实体发射粒子。每个实体只能挂载一个 组件,并需与 一起挂载。无需 mesh——粒子会直接通过该组件渲染。
ParticleSystemTransformRULE: Transform.scale does NOT scale particles
规则:Transform.scale 不会缩放粒子
Particle size is controlled exclusively by and (FloatRange). The also sets emitter shape's spatial dimensions when the shape has size fields (Sphere radius, Box size, Cone radius). These are not affected by the entity's . Setting larger does not produce bigger particles.
initialSizesizeOverTimeParticleSystemTransform.scaleTransform.scale粒子大小完全由 和 (FloatRange)控制。当发射器形状包含尺寸字段时, 还会设置该形状的空间尺寸(Sphere 半径、Box 尺寸、Cone 半径)。这些尺寸不受实体 的影响。将 调大不会让粒子变大。
initialSizesizeOverTimeParticleSystemTransform.scaleTransform.scaleRULE: Particles only render to players inside scene parcels
规则:粒子只会对场景地块内的玩家渲染
Players viewing the scene from outside its parcels see nothing. Particles are not part of the scene LOD silhouette. Position emitters within parcel bounds.
玩家在场景地块外观看时看不到任何粒子。粒子不属于场景 LOD 轮廓。请将发射器放在地块边界内。
RULE: Particles only work in the Unity explorer
规则:粒子仅适用于 Unity explorer
The mobile Godot explorer and the Bevy explorer don't have this feature implemented. The renderer ignores the component.
移动端 Godot explorer 和 Bevy explorer 尚未实现此功能。渲染器会忽略该组件。
RULE: Engine caps total particles at ~1000
规则:引擎会将粒子总数限制在约 1000
The engine enforces a per-scene particle budget and will scale down emission rates across all active particle systems if total live particles would exceed the limit. Cap each system with and prefer fewer impactful systems over many small ones.
maxParticles引擎会执行按场景计算的粒子预算限制;如果所有活跃粒子系统中的存活粒子总数将要超出上限,引擎会降低各系统的发射速率。请使用 限制每个系统,并优先采用数量较少但效果更突出的系统,而不是许多小型系统。
maxParticlesRULE: prewarm requires loop = true
规则:prewarm 要求 loop = true
prewarm: trueloop: trueloop: falseprewarm: trueloop: trueloop: falseRULE: faceTravelDirection overrides billboard
规则:faceTravelDirection 会覆盖 billboard
When , particles orient along their velocity vector and is ignored. Use this for trails/streaks (asteroids, bullets, sparks). Set explicitly to avoid confusion.
faceTravelDirection: truebillboardbillboard: false当 时,粒子会沿速度向量定向, 将被忽略。适用于拖尾或条纹效果(小行星、子弹、火花)。请显式设置 ,以避免混淆。
faceTravelDirection: truebillboardbillboard: falseImport
导入
typescript
import { engine, Transform, ParticleSystem } from '@dcl/sdk/ecs'
import {
PBParticleSystem_BlendMode,
PBParticleSystem_PlaybackState,
PBParticleSystem_SimulationSpace,
} from '@dcl/sdk/ecs'
import { Color4, Vector3, Quaternion } from '@dcl/sdk/math'Aliases and are also exported from and are interchangeable with the -prefixed names. There is no alias — only . Prefer the -prefixed names everywhere for consistency.
ParticleSystemBlendModeParticleSystemPlaybackState@dcl/sdk/ecsPBParticleSystemSimulationSpacePBParticleSystem_SimulationSpacePBtypescript
import { engine, Transform, ParticleSystem } from '@dcl/sdk/ecs'
import {
PBParticleSystem_BlendMode,
PBParticleSystem_PlaybackState,
PBParticleSystem_SimulationSpace,
} from '@dcl/sdk/ecs'
import { Color4, Vector3, Quaternion } from '@dcl/sdk/math'别名 和 也会从 导出,并可与带 前缀的名称互换使用。不存在 别名——只有 。为保持一致性,建议在所有位置使用带 前缀的名称。
ParticleSystemBlendModeParticleSystemPlaybackState@dcl/sdk/ecsPBParticleSystemSimulationSpacePBParticleSystem_SimulationSpacePBField reference
字段参考
| Field | Type | Default | Notes |
|---|---|---|---|
| | | Master on/off for new emission. |
| | | Particles emitted per second (continuous). Set to |
| | | Hard cap on simultaneous live particles for this system. |
| | | Particle lifespan in seconds. |
| | | Multiplier on scene gravity (~ -9.81 m/s²). Negative = particles rise. |
| | — | Constant force vector applied each frame (world space). |
| | | Random size at spawn. |
| | | Size lerped start→end over particle lifetime. |
| | identity | Spawn orientation (3D). |
| | identity | Per-axis angular velocity (quaternion converted to Euler XYZ rad/s-equivalent). |
| | | Orient along velocity. Overrides |
| | | Random color at spawn. |
| | | Color lerped start→end over lifetime. Use alpha=0 at end to fade out. |
| | | Initial speed in m/s, randomized per particle. |
| | white quad | Particle sprite. Same |
| | | |
| | | Particles always face camera. Disable for 3D-oriented particles. |
| | — | Texture-atlas frame animation. |
| oneof Point/Sphere/Cone/Box | Point | Emitter geometry — see below. |
| | | Loop the emission cycle. |
| | | Start as if one full loop has already simulated. Requires |
| | | |
| | — | Clamp top speed. |
| | | |
| | — | Discrete emission events (see Bursts). |
FloatRange = { start: number, end: number }ColorRange = { start: Color4, end: Color4 }| 字段 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| | | 新粒子发射的总开关。 |
| | | 持续发射时的每秒粒子数。使用 |
| | | 此系统同时存活的粒子数量硬上限。 |
| | | 粒子生命周期,单位为秒。 |
| | | 场景重力倍率(约 -9.81 m/s²)。负值表示粒子上升。 |
| | — | 每帧施加的恒定力向量(世界空间)。 |
| | | 粒子生成时的随机尺寸。 |
| | | 在粒子生命周期内从起点到终点插值的尺寸。 |
| | 单位四元数 | 生成时的朝向(3D)。 |
| | 单位四元数 | 各轴角速度(四元数转换为 Euler XYZ 弧度/秒等效值)。 |
| | | 沿速度方向定向。会覆盖 |
| | | 粒子生成时的随机颜色。 |
| | | 在生命周期内从起点到终点插值的颜色。将终点 alpha 设为 0 可实现淡出。 |
| | | 初始速度,单位为 m/s,每个粒子随机生成。 |
| | 白色四边形 | 粒子精灵。与 Material 纹理使用相同的 |
| | | |
| | | 粒子始终朝向摄像机。3D 朝向的粒子应禁用此选项。 |
| | — | 纹理图集帧动画。 |
| Point/Sphere/Cone/Box 中的 oneof | Point | 发射器几何形状——参见下文。 |
| | | 循环执行发射周期。 |
| | | 启动时模拟一个完整循环。要求 |
| | | |
| | — | 限制最高速度。 |
| | | |
| | — | 离散发射事件(参见 Bursts)。 |
FloatRange = { start: number, end: number }ColorRange = { start: Color4, end: Color4 }Emitter shapes
发射器形状
Build with the helpers — never assemble the manually:
ParticleSystem.Shape.*oneoftypescript
shape: ParticleSystem.Shape.Point()
shape: ParticleSystem.Shape.Sphere({ radius: 1 }) // default radius=1
shape: ParticleSystem.Shape.Cone({ angle: 25, radius: 1 }) // angle = half-angle in degrees
shape: ParticleSystem.Shape.Box({ size: Vector3.create(1, 1, 1) })- Point — emits from the entity origin.
- Sphere — random points inside a sphere of .
radius - Cone — emits from base disk, projecting outward within half-angle. Default cone direction is the entity's local forward; rotate the parent Transform to aim it.
angle - Box — random points inside an axis-aligned box of .
size
To rotate the emission direction (e.g. point a cone downward for snow/rain), rotate the parent entity's . Example: snow falling from a cone uses on the entity, or any orientation that flips the cone axis.
Transform.rotationrotation: Quaternion.fromEulerDegrees(180, 0, 0)使用 helper 构建——切勿手动组装 :
ParticleSystem.Shape.*oneoftypescript
shape: ParticleSystem.Shape.Point()
shape: ParticleSystem.Shape.Sphere({ radius: 1 }) // default radius=1
shape: ParticleSystem.Shape.Cone({ angle: 25, radius: 1 }) // angle = half-angle in degrees
shape: ParticleSystem.Shape.Box({ size: Vector3.create(1, 1, 1) })- Point——从实体原点发射。
- Sphere——从半径为 的球体内部随机选取发射点。
radius - Cone——从底部圆盘发射,并在 半角度范围内向外投射。Cone 的默认方向是实体的局部前方;旋转父级 Transform 即可调整方向。
angle - Box——在尺寸为 的轴对齐盒体内随机选取发射点。
size
要旋转发射方向(例如让 Cone 向下发射雪或雨),请旋转父实体的 。示例:下落雪花的 Cone 使用实体上的 ,也可以使用任何翻转 Cone 轴向的朝向。
Transform.rotationrotation: Quaternion.fromEulerDegrees(180, 0, 0)Bursts
Bursts
Discrete emission events at specific times. Set to use bursts only, or combine with for continuous + bursty.
rate: 0rate > 0typescript
bursts: {
values: [{ time: 0, count: 100, cycles: 1, interval: 0.01, probability: 1.0 }]
}Burst fields: (s from cycle start), (particles per burst), (default , = infinite), (s between cycles, default ), (0–1 chance per cycle, default ).
timecountcycles10interval0.01probability1Multiple bursts in one cycle = staggered ignition pattern (fireworks).
在特定时间发生的离散发射事件。将 设为 可仅使用 bursts,也可以与 结合,以实现持续发射与突发效果。
rate0rate > 0typescript
bursts: {
values: [{ time: 0, count: 100, cycles: 1, interval: 0.01, probability: 1.0 }]
}Burst 字段:(从循环开始起算的秒数)、(每次 burst 的粒子数)、(默认 , 表示无限)、(循环之间的间隔秒数,默认 )、(每个循环发生的概率,范围 0–1,默认 )。
timecountcycles10interval0.01probability1一个循环中包含多个 burst,即形成错峰点火模式(烟花)。
Common patterns
常见模式
Anatomy of a definition — attach to an entity that also has a :
ParticleSystemTransformtypescript
const emitter = engine.addEntity()
Transform.create(emitter, { position: Vector3.create(8, 1, 8) })
ParticleSystem.create(emitter, {
rate: 20, // particles per second
lifetime: 2, // seconds each particle lives
maxParticles: 100,
initialSize: { start: 0.1, end: 0.3 }, // FloatRange sampled per particle
sizeOverTime: { start: 1.0, end: 0.0 }, // shrink to nothing over lifetime
initialVelocitySpeed: { start: 1, end: 2 },
colorOverTime: {
// fade out via alpha = 0 at end
start: Color4.create(1, 1, 1, 1),
end: Color4.create(1, 1, 1, 0),
},
shape: ParticleSystem.Shape.Point(), // emitter geometry
})For full production-ready configurations, see — 17 presets: Fire Ember, Magic Aura, Snowfall, Vortex Spiral, Gravity Fountain, Bat Swarm, Tumbling Leaves, Lightning Sparks, Heavy Rain, One-Shot Burst, Asteroid Trail, Purple Swirl, Bee Swarm, Fireworks Loop, Campfire, Flame Wisps, Moving Trail. The explosion/pickup VFX (Point/Cone + ADD fire, one-shot Sphere burst) all live there — e.g. Fire Ember (preset 1), the One-Shot Burst explosion (preset 10), and looping Fireworks Loop (preset 14).
{baseDir}/references/particle-presets.md典型 定义的结构——将其挂载到同时包含 的实体上:
ParticleSystemTransformtypescript
const emitter = engine.addEntity()
Transform.create(emitter, { position: Vector3.create(8, 1, 8) })
ParticleSystem.create(emitter, {
rate: 20, // particles per second
lifetime: 2, // seconds each particle lives
maxParticles: 100,
initialSize: { start: 0.1, end: 0.3 }, // FloatRange sampled per particle
sizeOverTime: { start: 1.0, end: 0.0 }, // shrink to nothing over lifetime
initialVelocitySpeed: { start: 1, end: 2 },
colorOverTime: {
// fade out via alpha = 0 at end
start: Color4.create(1, 1, 1, 1),
end: Color4.create(1, 1, 1, 0),
},
shape: ParticleSystem.Shape.Point(), // emitter geometry
})有关可直接用于生产环境的完整配置,请参阅 ——其中包含 17 个预设:Fire Ember、Magic Aura、Snowfall、Vortex Spiral、Gravity Fountain、Bat Swarm、Tumbling Leaves、Lightning Sparks、Heavy Rain、One-Shot Burst、Asteroid Trail、Purple Swirl、Bee Swarm、Fireworks Loop、Campfire、Flame Wisps、Moving Trail。爆炸和拾取 VFX(Point/Cone + ADD 火焰、一次性 Sphere burst)均收录于其中,例如 Fire Ember(预设 1)、One-Shot Burst 爆炸(预设 10),以及循环播放的 Fireworks Loop(预设 14)。
{baseDir}/references/particle-presets.mdPlayback control
播放控制
typescript
const ps = ParticleSystem.getMutable(entity)
// Pause emission and freeze existing particles
ps.playbackState = PBParticleSystem_PlaybackState.PS_PAUSED
// Resume
ps.playbackState = PBParticleSystem_PlaybackState.PS_PLAYING
// Stop and clear all live particles
ps.playbackState = PBParticleSystem_PlaybackState.PS_STOPPED
// Disable new emission (existing particles continue to live out their lifetime)
ps.active = falseUse for a hard cut. Use for a graceful trail-off.
playbackState = PS_STOPPEDactive = falsetypescript
const ps = ParticleSystem.getMutable(entity)
// Pause emission and freeze existing particles
ps.playbackState = PBParticleSystem_PlaybackState.PS_PAUSED
// Resume
ps.playbackState = PBParticleSystem_PlaybackState.PS_PLAYING
// Stop and clear all live particles
ps.playbackState = PBParticleSystem_PlaybackState.PS_STOPPED
// Disable new emission (existing particles continue to live out their lifetime)
ps.active = false使用 可立即硬切停止。使用 可让发射自然停止并逐渐消散。
playbackState = PS_STOPPEDactive = falseSprite-sheet animation
精灵表动画
Texture atlas with frames laid out in a grid (left-to-right, top-to-bottom). Total frames = .
tilesX * tilesYtypescript
texture: { src: 'assets/Images/flame-sheet.png' },
spriteSheet: { tilesX: 4, tilesY: 3, framesPerSecond: 12 } // 12 frames, plays at 12fpsTest-scene examples use (16 frames, bat swarm @24fps), (12 frames, fire/flame @10–12fps), and (20-frame strip, bee @30fps) sheets.
4x44x31x20纹理图集中的帧按网格排列(从左到右、从上到下)。总帧数 = 。
tilesX * tilesYtypescript
texture: { src: 'assets/Images/flame-sheet.png' },
spriteSheet: { tilesX: 4, tilesY: 3, framesPerSecond: 12 } // 12 frames, plays at 12fps测试场景示例使用 (16 帧,蝙蝠群 @24fps)、(12 帧,火焰 @10–12fps)以及 (20 帧条带,蜜蜂 @30fps)精灵表。
4x44x31x20Simulation space (local vs world)
模拟空间(局部与世界)
- (default) — particles move with the emitter. A moving emitter drags its particle cloud along. Suits aura/halo effects on a moving entity.
PSS_LOCAL - — particles stay at their spawn position in world space, so a moving emitter leaves a trail behind it.
PSS_WORLD
For a Tween-driven emitter (verified in , "Moving Trail"): keeps the cloud attached to the entity as it moves; switch to if you want the spawned particles to stay put and form a persistent trail. The test scene demonstrates the effect with — pick the space by the look you want, not as a hard requirement.
0,7-particle-systemPSS_LOCALPSS_WORLDPSS_LOCAL- (默认)——粒子随发射器移动。移动的发射器会拖拽其粒子云一同移动。适合移动实体上的光环或光晕效果。
PSS_LOCAL - ——粒子生成后停留在世界空间中的原位置,因此移动的发射器会在身后留下拖尾。
PSS_WORLD
对于由 Tween 驱动的发射器(已在 的 “Moving Trail” 中验证): 会使粒子云在实体移动时继续附着于实体;如果希望生成的粒子停留在原处并形成持久拖尾,请切换到 。测试场景使用 演示该效果——应根据期望的视觉效果选择模拟空间,而不是将其视为硬性要求。
0,7-particle-systemPSS_LOCALPSS_WORLDPSS_LOCALTexture field
Texture 字段
The field uses the same type as . Common case (local file):
textureTextureMaterialtypescript
texture: {
src: 'assets/Images/spark.png'
}The full Texture form supports filterMode/wrapMode but particle systems generally only need . Avatar/Video textures on particles are unverified — stick with file textures.
srctextureMaterialTexturetypescript
texture: {
src: 'assets/Images/spark.png'
}完整的 Texture 结构支持 filterMode 和 wrapMode,但粒子系统通常只需要 。Avatar/Video 纹理用于粒子的效果尚未验证——请使用文件纹理。
srcGotchas
易错点
- Texture path — particle textures default to . Same path conventions as Material textures. Legacy scenes may have them under
assets/Images/orassets/scene/Images/(still works); textures from Creator Hub asset packs land inassets/scene/textures/and custom items inassets/asset-packs/— reference those paths as-is.assets/custom/ - Quaternion rotation fields — is interpreted as per-axis angular velocity (quaternion → Euler XYZ).
rotationOverTime= spin 90°/s on Y. Identity = no spin.Quaternion.fromEulerDegrees(0, 90, 0) - is world-space even when
additionalForce. Wind/drift directions stay constant regardless of emitter rotation.simulationSpace = PSS_LOCAL - = hard clamp (particles never exceed
limitVelocity.dampen = 1). Lower values let velocity exceed cap briefly then decay.speed - Color.alpha = 0 at end of is the standard way to fade particles out — don't rely on
colorOverTimeending at 0 alone.sizeOverTime - Bursts ignore at the moment of evaluation —
active = falseis checked once per frame for continuous rate; setting it after a burst time will not retroactively cancel that burst.active - No mesh attached to the emitter entity — adding is unrelated; particles render via the ParticleSystem component itself.
MeshRenderer
- 纹理路径——粒子纹理默认位于 。路径约定与 Material 纹理相同。旧版场景中的纹理可能位于
assets/Images/或assets/scene/Images/(仍然有效);Creator Hub 资源包中的纹理位于assets/scene/textures/,自定义项目中的纹理位于assets/asset-packs/——请按原样引用这些路径。assets/custom/ - Quaternion 旋转字段——会被解释为各轴角速度(四元数转换为 Euler XYZ)。
rotationOverTime表示绕 Y 轴以 90°/秒旋转。单位四元数表示不旋转。Quaternion.fromEulerDegrees(0, 90, 0) - 即使 ,
simulationSpace = PSS_LOCAL仍使用世界空间。无论发射器如何旋转,风或漂移方向都保持恒定。additionalForce - 表示硬限制,粒子速度绝不会超过
limitVelocity.dampen = 1。较低的值允许速度短暂超过上限,然后逐渐衰减。speed - 在 末尾设置
colorOverTime是淡出粒子的标准方式——不要仅依赖Color.alpha = 0最终归零。sizeOverTime - 在求值时,bursts 会忽略 ——
active = false仅针对连续active每帧检查一次;在 burst 时间点之后将其设为 false,不会追溯取消该次 burst。rate - 发射器实体无需挂载 mesh——添加 与此无关;粒子通过
MeshRenderer组件本身渲染。ParticleSystem
Performance
性能
- Keep low; that product is the steady-state live count.
lifetime * rate - Disable systems out of view via or
playbackState = PS_STOPPED.active = false - Prefer for opaque/translucent effects.
PSB_ALPHAis best for glow/fire (it stacks visually) but multi-layer additive overdraw is the most expensive case.PSB_ADD - Sprite sheets are cheap; multiple textures per system is not supported (one texture per system).
- 保持 较低;该乘积就是稳定状态下的存活粒子数。
lifetime * rate - 使用 或
playbackState = PS_STOPPED禁用视野之外的系统。active = false - 不透明或半透明效果优先使用 。
PSB_ALPHA最适合辉光和火焰效果,因为它们会在视觉上叠加,但多层 additive overdraw 是开销最高的情况。PSB_ADD - 精灵表的开销较低;每个系统不支持多张纹理(每个系统只能使用一张纹理)。
Resources
资源
- — 17 ready-to-use preset configurations from the SDK7 test scene (fire, magic, snowfall, vortex, fountain, swarms, sparks, rain, bursts, fireworks, campfire, trails).
{baseDir}/references/particle-presets.md - Live tuner: (open with Decentraland client).
ParticleLab.dcl.eth
- ——来自 SDK7 测试场景的 17 个即用型预设配置,涵盖火焰、魔法、飘雪、漩涡、喷泉、群集、火花、雨、爆发、烟花、篝火和拖尾。
{baseDir}/references/particle-presets.md - 实时调节器:ParticleLab.dcl.eth(使用 Decentraland 客户端打开)。
Example scenes
示例场景
- — engine-team ground truth: all 17 presets above, every shape (Point/Sphere/Cone/Box),
https://github.com/decentraland/sdk7-test-scenes/tree/main/scenes/0,7-particle-system/PSB_ADD, continuousPSB_ALPHAvsrate(one-shot + looping fireworks),bursts(4×4/4×3/1×20),spriteSheet,limitVelocity/initialRotationwithrotationOverTime,billboard: false,faceTravelDirection, and a Tween-driven emitter demonstratingadditionalForce.simulationSpace
- ——引擎团队权威参考:包含上述全部 17 个预设、所有形状(Point/Sphere/Cone/Box)、
https://github.com/decentraland/sdk7-test-scenes/tree/main/scenes/0,7-particle-system/PSB_ADD、持续PSB_ALPHA与rate(一次性烟花和循环烟花)、bursts(4×4/4×3/1×20)、spriteSheet、limitVelocity/initialRotation配合rotationOverTime、billboard: false、faceTravelDirection,以及一个用于演示additionalForce的 Tween 驱动发射器。simulationSpace