# Particles

Seeded particles for sparks, snow, smoke, spray, embers, confetti, trails and streaks.

A node with `particles` emits seeded, deterministic particles. Presets are tuned looks; every field you set overrides the preset.

```json title="apps/docs/examples/particles.json"
{
  "camera": { "position": [0, 1.5, 8], "target": [0, 1, 0], "fov": 45 },
  "lighting": { "rig": "neon_rim" },
  "environment": { "background": { "solid": "#05040a" } },
  "post": { "bloom": 1, "tone_mapping": "agx" },
  "nodes": {
    "sparks": {
      "transform": { "position": [-2.5, 0.5, 0] },
      "particles": {
        "preset": "sparks",
        "count": 300,
        "lifetime": 1.2,
        "speed": 6,
        "size": 0.05,
        "emitter": "point",
        "direction": [0, 1, 0],
        "spread": 40,
        "gravity": [0, -9, 0],
        "glow": 5
      }
    },
    "smoke": {
      "transform": { "position": [0, 0, 0] },
      "particles": { "preset": "smoke", "count": 120 }
    },
    "snow": {
      "transform": { "position": [2.5, 2, 0] },
      "particles": {
        "preset": "snow",
        "count": 600,
        "emitter": { "box": { "size": [3, 4, 3] } },
        "stretch": 0.03,
        "gravity": [0, -3, 0]
      }
    }
  },
  "timeline": { "duration": 4, "loop": "loop" }
}
```

![Render of particles](/renders/particles.jpg)

## Presets

`spray` (white water or runway spray), `sparks` (streaks, add gravity), `smoke`, `snow` (use a big `box` emitter around the action), `embers`, `sparkles`, `starfield`, `bokeh` and `confetti`.

## Shape and Motion

- `emitter`: `point`, a `sphere`, a `box`, or the `surface` of a mesh node.
- `direction` and `spread` (half-angle in degrees) aim a cone. Leave them out to emit every way.
- `speed`, `lifetime`, `gravity` and `drag`.
- `size`, and `grow`, the size at the end of life: smoke and spray billow, sparks shrink.
- `colors` over life, and `glow` above 1 to bloom.

## Streaks and Trails

- `"stretch": 0.03` draws each particle as a streak over that many seconds of its travel: driving snow or rain in headlights, tracer fire. Sparks streak by default; `0` makes them dots.
- `"trail": true` leaves particles where they were born, so a moving emitter draws a wake: engine spray, exhaust, dust behind a car. Parent the emitter to the moving node.

Fade a whole system in or out with an `opacity` track on its node. In a looping timeline, particle lifetimes are fitted so the loop is seamless.

## API Reference

### Particles

A deterministic (seeded) GPU particle system.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `colors` | `Color[]` | — | Color over lifetime (evenly spaced gradient stops). |
| `count` | `integer (1 to 100000)` | `500` | Number of live particles. |
| `direction` | `[x, y, z]` | — | Emit in a cone around this direction (node-local) instead of every way; `spread` is the cone's half-angle in degrees. |
| `drag` | `number (≥ 0)` | — | Air drag per second: particles shoot out and slow down (spray, sparks). |
| `emitter` | `Emitter` | `{"sphere":{"radius":1}}` | Where particles are born. |
| `glow` | `number (≥ 0)` | — | Brightness multiplier; above 1 the particles glow through bloom. |
| `gravity` | `[x, y, z]` | `[0,0,0]` | Acceleration on every particle, `[x, y, z]`. |
| `grow` | `number (≥ 0)` | — | Size multiplier at the end of life (spray and smoke billow, sparks shrink). |
| `lifetime` | `number` | `2` | Particle lifetime in seconds. |
| `preset` | `ParticlePreset` | — | Tuned look; explicit fields override it. |
| `seed` | `integer` | — | Overrides the scene seed for this system. |
| `size` | `number` | `0.03` | Particle size in world units. |
| `speed` | `number` | `1` | Initial speed in units/second. |
| `spread` | `number (0 to 180)` | — | Cone half-angle in degrees around `direction`. |
| `stretch` | `number (0 to 1)` | — | Motion streaks: draw each particle stretched along its velocity over this many seconds of travel (0.05 to 0.1 for rain-like snow, sparks, tracer fire). Sparks streak by default; 0 turns that off. |
| `trail` | `boolean` | — | Leave particles where they were born when the node moves (engine spray, exhaust, snow around a moving camera) instead of carrying them along. |
### ParticlePreset

| Value | Description |
| --- | --- |
| `"confetti"` |  |
| `"sparkles"` |  |
| `"embers"` |  |
| `"snow"` |  |
| `"starfield"` |  |
| `"bokeh"` |  |
| `"smoke"` |  |
| `"spray"` | White water or wheel spray: bursts out fast, billows and fades. |
| `"sparks"` | Hot sparks: bright, fast, falling and shrinking. |
### Emitter

Where particles spawn.

| Value | Description |
| --- | --- |
| `"point"` |  |

- `{"sphere": { … }}`: Spawn inside a sphere around the node.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `radius` (required) | `number` | — | Sphere radius. |

- `{"box": { … }}`: Spawn inside a box around the node.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `size` (required) | `[x, y, z]` | — | Full box size `[x, y, z]`. |

- `{"surface": { … }}`: Spawn on the surface of another node's mesh.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `node` (required) | `string` | — | Id of the mesh node whose surface particles spawn on. |
