NatureGL Firev1.0.0

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.

CampfirecampfireA teepee of logs burning from its own surface, in a light wind.
TorchtorchA small, hot, flickering flame that trails behind when it moves.
JetjetA 7.5 m/s flame-thrower jet splashing over a sphere obstacle.
PlumeplumeA smouldering brazier: little flame, heavy smoke, strong wind.
FireballfireballA rolling fireball above the brazier every 2.8 s.
ExplosionexplosionA detonation every 4.4 s that blooms into lobes and a soot mushroom.
MeshmeshAny mesh set on fire: a rotating torus knot by default.

#Loading presets

js
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 object

loadPreset() 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

src/config/presets/plume.js
/** 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
originAnchor relative to the domain floor centre. setOrigin() moves it later
paramsA subset of FireParams
emittersEmitter options, with offset relative to origin (or an absolute position), and mesh as a slot name
autoBurst{ type, every, offset, strength } or null
obstaclesposition relative to the domain floor centre
cameraA framing hint that only the demo uses. The library ignores it
js
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

Runs WebGL2 in this page · starts on explosion
Starts on explosion. Press 1–7 in the demo to switch presets.

#Reference

NameEmitterParams that differ from defaultsExtras
campfiremesh, slot logs (fallback teepee), fuel 9, temperature 1.1wind 0.35, expansion 0.6, smoke 0.8—
torchsphere r 0.28, fuel 70, temperature 1.4, inheritVelocity 0.6turbulence 1.1, cooling 1.3, expansion 0.5, smoke 0.7, intensity 1.1, burnRate 2.4origin 1.6 m up
jetsphere r 0.2, fuel 60, temperature 1.45, 7.5 m/s at velocityBlend 0.95turbulence 0.8, cooling 1.1, expansion 0.9, buoyancy 0.9, burnRate 5sphere obstacle r 0.55
plumesphere r 0.42, fuel 5, temperature 0.8, smoke 7wind 0.9, turbulence 1.1, cooling 0.9, expansion 0.3, buoyancy 1.1, smoke 1.8, intensity 0.9sphere obstacle r 0.62
fireballnonewind 0.2, cooling 0.8, expansion 1.2, buoyancy 1.2, smoke 1.2autoBurst fireball every 2.8 s
explosionnoneturbulence 1.2, cooling 0.9, expansion 1.6, smoke 1.5autoBurst explosion every 4.4 s
meshmesh, slot shape (fallback torus knot), 26 000 samplesturbulence 0.9, cooling 1.3, expansion 0.5, buoyancy 0.9, smoke 0.6origin 1.65 m up