Reference
Presets
Seven fires, one file each, in src/config/presets/. Hover a card to see the fire move, click to enlarge it, or run one live.
campfireA teepee of logs burning from its own surface, in a light wind.torchA small, hot, flickering flame that trails behind when it moves.jetA 7.5 m/s flame-thrower jet splashing over a sphere obstacle.plumeA smouldering brazier: little flame, heavy smoke, strong wind.fireballA rolling fireball above the brazier every 2.8 s.explosionA detonation every 4.4 s that blooms into lobes and a soot mushroom.meshAny mesh set on fire: a rotating torus knot by default.#Loading presets
fire.loadPreset('explosion'); // by name
fire.loadPreset('campfire', { meshes: { logs } }); // fill a mesh slot
fire.loadPreset('torch', { origin: [1, 1.2, 0] }); // anchor in world space
fire.loadPreset(savedJson, { keepFluid: true }); // an object, without clearing the fluid
fire.presetName; // 'explosion', or null for an objectloadPreset() replaces the emitters, the obstacles and the auto-burst. Every parameter that the preset doesn't list resets to its default. Unless you pass keepFluid: true, the fluid, embers and TAA history are cleared, and the fire grows back from nothing in a second or two. Presets don't ease into each other.
#Presets are plain data
/** Plume — a smouldering brazier: little flame, lots of rolling smoke, deflected by a sphere. */
export default {
label: 'Plume',
origin: [0, 0, 0],
params: { wind: 0.9, turbulence: 1.1, cooling: 0.9, expansion: 0.3, buoyancy: 1.1, smoke: 1.8, intensity: 0.9, burnRate: 3.2 },
emitters: [
{
type: 'sphere', offset: [0, 0.62, 0], radius: 0.42,
fuel: 5, temperature: 0.8, smoke: 7, flicker: 0.8,
velocity: [0, 1.6, 0], velocityBlend: 0.3,
embers: 0.25, emberOffset: [0, 0.2, 0], emberRadius: 0.3,
},
],
autoBurst: null,
obstacles: [{ type: 'sphere', position: [0.1, 3.2, 0.1], radius: 0.62 }],
camera: { position: [6.8, 3.4, 8.4], target: [0, 2.5, 0] },
};| Field | |
|---|---|
origin | Anchor relative to the domain floor centre. setOrigin() moves it later |
params | A subset of FireParams |
emitters | Emitter options, with offset relative to origin (or an absolute position), and mesh as a slot name |
autoBurst | { type, every, offset, strength } or null |
obstacles | position relative to the domain floor centre |
camera | A framing hint that only the demo uses. The library ignores it |
import { PRESETS, getPresetParams } from 'naturegl-fire';
Object.keys(PRESETS); // ['campfire', 'torch', 'jet', 'plume', 'fireball', 'explosion', 'mesh']
getPresetParams('jet'); // a deep clone you can edit#Try one live
explosion. Press 1–7 in the demo to switch presets.#Reference
| Name | Emitter | Params that differ from defaults | Extras |
|---|---|---|---|
campfire | mesh, slot logs (fallback teepee), fuel 9, temperature 1.1 | wind 0.35, expansion 0.6, smoke 0.8 | — |
torch | sphere r 0.28, fuel 70, temperature 1.4, inheritVelocity 0.6 | turbulence 1.1, cooling 1.3, expansion 0.5, smoke 0.7, intensity 1.1, burnRate 2.4 | origin 1.6 m up |
jet | sphere r 0.2, fuel 60, temperature 1.45, 7.5 m/s at velocityBlend 0.95 | turbulence 0.8, cooling 1.1, expansion 0.9, buoyancy 0.9, burnRate 5 | sphere obstacle r 0.55 |
plume | sphere r 0.42, fuel 5, temperature 0.8, smoke 7 | wind 0.9, turbulence 1.1, cooling 0.9, expansion 0.3, buoyancy 1.1, smoke 1.8, intensity 0.9 | sphere obstacle r 0.62 |
fireball | none | wind 0.2, cooling 0.8, expansion 1.2, buoyancy 1.2, smoke 1.2 | autoBurst fireball every 2.8 s |
explosion | none | turbulence 1.2, cooling 0.9, expansion 1.6, smoke 1.5 | autoBurst explosion every 4.4 s |
mesh | mesh, slot shape (fallback torus knot), 26 000 samples | turbulence 0.9, cooling 1.3, expansion 0.5, buoyancy 0.9, smoke 0.6 | origin 1.65 m up |