ts
import { BURSTS, EMITTERS, Particles } from "@apricotjs/react-native";
import type { BurstName, BurstOptions, EmitOptions, Emitter, EmitterName, ParticlesHandle, ParticlesProps } from "@apricotjs/react-native";Particles#
| Prop | Type | Default | Description |
|---|---|---|---|
emit |
EmitterName | EmitOptions | false |
none | A stream that runs while set. Changes apply while it runs |
glow |
boolean |
false |
Adds the particles' colour to what is behind them, which glows on a dark scene. false draws them over it |
texture |
THREE.Texture | null |
a soft dot | A picture each particle shows, tinted by its colour (from useTexture) |
max |
number |
1000 |
The most particles alive at once. New ones beyond it replace the oldest |
ref |
Ref<ParticlesHandle> |
Fires bursts and streams from code |
Plus transform props. Changing max, glow or texture replaces the particle set, and streams started from code start again.
ParticlesHandle#
| Method | Description |
|---|---|
burst(burst, options?) |
Fires a burst. Pass a name from BURSTS (with options overriding its values) or your own BurstOptions |
emit(stream, options?) |
Starts a stream. Pass a name from EMITTERS (with options overriding its values) or your own EmitOptions. Returns an Emitter |
Emitter#
| Member | Description |
|---|---|
set(options) |
Changes any stream option while it runs |
stop() |
Stops sending particles. Those already out finish their lives |
running |
Whether it is still sending them out |
BurstOptions#
Spread is a number or a range [min, max]. With a range, each particle gets a random value in it.
| Option | Type | Default | Description |
|---|---|---|---|
at |
Vec3 |
[0, 0, 0] |
Where they start |
area |
Vec3 |
none | Size of a box round at. Particles start anywhere inside it |
count |
number |
40 |
How many |
colors |
colours | ["#ffffff"] |
Each particle takes one |
fadeTo |
colour | none | The colour they turn to over their life |
speed |
Spread |
[1, 2] |
Metres per second |
direction |
Vec3 |
[0, 1, 0] |
The way they fly |
spread |
degrees | 180 |
How far from direction they scatter. 180 is every way |
life |
Spread |
[0.6, 1.2] |
Seconds |
size |
Spread |
0.05 |
Metres |
grow |
number |
1 |
Size at the end of a life, as a multiple of the start size |
spin |
Spread |
0 |
Degrees per second |
shape |
"dot" | "square" |
"dot" |
A soft dot, or a fluttering paper square |
gravity |
number |
0 |
Metres per second², downwards. Negative values rise |
wind |
Vec3 |
[0, 0, 0] |
A steady push, metres per second² |
drag |
number |
0 |
How quickly they slow in the air |
EmitOptions#
Every BurstOptions field except count, plus:
| Option | Type | Default | Description |
|---|---|---|---|
rate |
number |
20 |
Particles a second |
Presets#
BURSTS (BurstName): sparkle, firework, pop, confetti.
EMITTERS (EmitterName): smoke, fountain, snow, sparkler.
Each preset is a plain options object. Spread one to change it: { ...EMITTERS.snow, area: [10, 0, 10] }.