NatureGL Firev1.0.0

naturegl-fire v1.0.0

Fire you can walk around

A real 3D fluid solver for flame and smoke, stepped on the GPU every frame and raymarched into your three.js scene. It burns from any mesh surface, blooms into explosions, flows around obstacles and lights everything near it.

$ npm install && npm run dev

#A fluid sim, not a sprite sheet

Fuel, temperature and smoke live in a 3D voxel grid inside a box you place in your world. Each frame the solver burns fuel into heat, lets the hot gas rise and curl, and projects the velocity so the gas stays incompressible. Then it raymarches the result against your scene's depth, so the fire sits correctly behind and in front of your geometry.

Follow the quick start or see what runs each frame.

The campfire preset on high: the demo's teepee of logs is the emitter mesh, and the fire light lights the stones and the courtyard around it.
presets, one file each
7
quality tiers, low to ultra
4
voxels on high (64×96×64)
393K
GPU embers advected by the gas
4096

#What's in the box

#Seven fires, ready to load

Every preset is one file in src/config/presets/: sim parameters, emitters, obstacles, an optional auto-burst and a camera hint. Load one with loadPreset, and print your own with getParams().

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.
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.

See all seven presets

#A campfire in your scene

main.js
import * as THREE from 'three';
import { FireSystem, createTeepeeGeometry } from 'naturegl-fire';

const logs = new THREE.Mesh(createTeepeeGeometry(), new THREE.MeshStandardMaterial({ color: 0x1a120c }));
scene.add(logs);

const fire = await FireSystem.create({
  renderer, scene, camera,
  domain: { center: [0, 3, 0], size: [4, 6, 4] },  // the fire lives in this box
  meshes: { logs },                                // the campfire burns from the logs' surface
  preset: 'campfire',
});

const timer = new THREE.Timer();
renderer.setAnimationLoop(t => {
  timer.update(t);
  fire.update(timer.getDelta());   // offscreen simulation step
  fire.render();                   // your scene + the fire → canvas
});

#From a spark to a mushroom cloud

Two fire.explode() calls, the second at strength 1.4. The burst is carved into noise pockets and pushed outward with jitter, so it breaks into lobes, then cools into soot that rises and rolls.

#Part of the NatureGL series

NatureGL Fire renders into a scene you own and takes its key light and ambient from outside through setLighting, so it fits under a NatureGL Sky sky or next to the other packs.