# The Particle Helper

> Learn all about the fabulous particle helper in Babylon.js.

Source: https://doc.babylonjs.com/features/featuresDeepDive/particles/particle_system/particleHelper

## Introducing the Particle Helper

Starting with Babylon.js v3.3, you can now use the Particle Helper to create complex particle systems without having to deal with individual properties.

To use the Particle Helper, you only need to know the name of the effect and then call this code:

```javascript
BABYLON.ParticleHelper.CreateAsync("sun", scene).then((set) => {
    set.start();
});
```

This will create regular particle systems. If you want to use GPU particle systems instead, just call this code:

```javascript
BABYLON.ParticleHelper.CreateAsync("sun", scene, true).then((set) => {
    set.start();
});
```

You can find a demo here: [Playground: Particle Helper Example](https://playground.babylonjs.com/#MX2Z99#172) - Simple example of creating a particle system with the particle helper.

## ParticleSystemSet

When calling `BABYLON.ParticleHelper.CreateAsync()`, you will get a Promise that resolves with a `ParticleSystemSet`.
This class provides the following properties and functions:

- `emitterNode`: Use this property to get the transform node used as the emitter by the particle systems.
- `start(emitter)`: Call this function to start all particle systems associated with the current set. You can use the optional parameter to overwrite the emitter.
- `dispose()`: Call this function to stop and clear all particle systems.

You can also get the list of particle systems used by the set with `set.systems`.

## Available Effects

Each effect can be described using a JSON file [like this one](https://github.com/BabylonJS/Assets/blob/master/particles/systems/sun.json).

List of available effects:

| Effect name   | Image                                             | Playground                                                                                          |
| ------------- | ------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| **sun**       | ![sun](https://doc.babylonjs.com/img/how_to/Particles/sun.webp)             | [Playground: Particle Sun Demo](https://playground.babylonjs.com/#MX2Z99#172) - Particle Sun Demo.             |
| **smoke**     | ![smoke](https://doc.babylonjs.com/img/how_to/Particles/smoke.webp)         | [Playground: Particle Smoke Demo](https://playground.babylonjs.com/#MX2Z99#173) - Particle Smoke Demo.         |
| **rain**      | ![rain](https://doc.babylonjs.com/img/how_to/Particles/rain.webp)           | [Playground: Particle Rain Demo](https://playground.babylonjs.com/#MX2Z99#175) - Particle Rain Demo.           |
| **fire**      | ![fire](https://doc.babylonjs.com/img/how_to/Particles/fire.webp)           | [Playground: Particle Fire Demo](https://playground.babylonjs.com/#I2D9MM#18) - Particle Fire Demo.           |
| **explosion** | ![explosion](https://doc.babylonjs.com/img/how_to/Particles/explosion.webp) | [Playground: Particle Explosion Demo](https://playground.babylonjs.com/#MX2Z99#177) - Particle Explosion Demo. |

## Custom ParticleSets

It is reasonably simple to create your own custom particleSet. Each particleSet listed above is stored in a Babylon.js folder currently located [**at this URL**](https://github.com/BabylonJS/Assets/tree/master/particles/systems). For instance, when you use "sun" as the particleSet _type_, `ParticleHelper` will load [**this JSON**](https://github.com/BabylonJS/Assets/blob/master/particles/systems/sun.json), which defines the "sun" particleSet _type_.

You may store these custom JSON particleSets anywhere you wish. You can set the base URL for the particleHelper with: `BABYLON.ParticleHelper.BaseAssetsUrl = “https://yourBaseUrl”;`

This must be done BEFORE you execute the `CreateAsync` call, which loads your particleSet JSON file:

```javascript
var myParticleSet = new BABYLON.ParticleHelper.CreateAsync("tornado", scene).then(function(set) {
    set.start();
});
```

In the above example, "tornado" is NOT the _name_ of a particle system. It is the name of a particleSet _type_. In a moment, we will see how the _type_ string is used.

Let's look at the line of code that loads JSON particleSets into the particleHelper:

`` Tools.LoadFile(`${ParticleHelper.BaseAssetsUrl}/systems/${type}.json`, (data) => { ``

Notice that _type_ is used as the name of the JSON file. Using the previous example, your complete filename would be `tornado.json`.

Also notice the `/systems/` subfolder hierarchy. Your custom particleSet JSON file needs to be located in a subfolder called `/systems/`. So, `yourDomain/systems/tornado.json` is where your file should be located and how it should be named (for our example).

## Generate Custom ParticleSets

You can automatically generate a new JSON particleSet into a variable by configuring your particle systems and then using the [ExportSet option](https://doc.babylonjs.com/api/classes/babylon.particlehelper#exportset).

Usage: `var mySet = BABYLON.ParticleHelper.ExportSet( [includedPS1, includedPS2, includedPS3...] );`

## Further reading

- [Particles Overview](https://doc.babylonjs.com/features/featuresDeepDive/particles/particle_system)
- [Particles](https://doc.babylonjs.com/features/featuresDeepDive/particles)
- [How to Use Sub Emitters](https://doc.babylonjs.com/features/featuresDeepDive/particles/particle_system/subEmitters)
- [Solid Particle System](https://doc.babylonjs.com/features/featuresDeepDive/particles/solid_particle_system)
- [How to Customize the Particle System](https://doc.babylonjs.com/features/featuresDeepDive/particles/particle_system/customizingParticles)
