FIRE FOUNTAIN
PARTICLE SYSTEM
By Shane Brumback · · Free Three.js tutorial
Build a realistic fire fountain particle system with Three.js — sphere particles, velocity physics, gravity simulation, and interactive sliders for real-time control — then take the same rig further into a glowing lava fountain.
LIVE DEMO
The fire fountain is running in the background right now. Launch the full-screen demo to orbit the scene and use the sliders to adjust the simulation in real-time.
Orbit: drag · Zoom: scroll · Esc to exit
Introduction
Three.js is a powerful JavaScript library for creating stunning 3D visualizations. One exciting application is fire fountain particle systems — realistic, dynamic fire effects that simulate flames erupting upward in a fountain-like manner.
This tutorial creates hundreds of sphere particles with random velocities, simulates gravity pulling them back down, and resets them at the origin to create a continuous flowing fountain. Interactive sliders let you adjust height, velocity, particle count, and radius in real-time — then the Lava & VFX section shows how the same rig becomes a glowing molten lava fountain.
WANT TO BLOW SOMETHING UP?
Switch gears from fountains to a full 3D rockfire explosion in Three.js — flying debris, fire, smoke, a shockwave, and a scorch crater that grows with the blast. The whole effect in one copy-paste file, with a live demo you can orbit.
See the Rockfire Explosion TutorialFrequently Asked Questions
How do I create a fire particle system in Three.js?
Create a BufferGeometry with many vertices, assign random positions and velocities, use a PointsMaterial with an additive blending fire texture, then animate particles upward with gravity and fade-out in the render loop. Reset particles when they die to create a continuous fountain effect.
What is the best blending mode for fire particles in Three.js?
Use THREE.AdditiveBlending on your PointsMaterial. This makes overlapping particles appear brighter (light adds together), creating a realistic glowing fire effect. Combine with depthWrite: false and transparent: true for proper layering.
How do I make particles fade out as they rise?
Track each particle's age or lifetime in an attribute array. In your animation loop, reduce opacity based on age. Use a custom ShaderMaterial for per-particle opacity, or use size attenuation so particles shrink as they age, giving the appearance of fading.
How many particles can Three.js handle for a fire effect?
Modern GPUs handle 10,000-100,000 point particles easily at 60fps. For a fire fountain, 1,000-5,000 particles gives a good look. Use BufferGeometry (not regular Geometry) and update positions via the position attribute buffer for best performance.
How do I make a lava fountain effect in Three.js?
Start from the same fire fountain — velocity-driven particles with gravity and a reset loop — then map each blob's age to a colour ramp (white-hot, then yellow, orange, deep red, and finally dark crust). Render the blobs as one THREE.Points with a custom ShaderMaterial instead of 1,000 meshes, add a second additive Points pass for glow instead of lights or bloom, and spawn ember sparks, drifting smoke, and cooling crust splashes where blobs land.
How do I add glow to particles without bloom in Three.js?
Draw the same particles a second time with THREE.AdditiveBlending, a larger point size, and a soft radial falloff in the fragment shader. Overlapping glow halos add together and read like bloom, but it costs just one extra draw call and runs well on mobile with no post-processing pass.
How It Works
- Particle Creation: 1,000 sphere meshes with random radii and yellow-to-orange gradient colors
- Velocity Physics: Each particle gets random X, Y, Z velocity — Y is upward thrust, X/Z create spread
- Gravity Simulation: Each frame subtracts a random friction value from Y velocity, pulling particles down
- Reset Loop: When particles fall below reset height, they teleport back to origin with fresh velocity
- OrbitControls: Auto-rotating camera with drag/zoom for exploring the effect from any angle
- Interactive Sliders: Real-time adjustment of fountain height, velocity ranges, particle count, and size — drag them live to feel how each parameter shapes the plume
Those six moving parts are the whole engine. Master them here on the fire fountain and you can re-skin the exact same rig into a lava fountain, a water jet, confetti, or sparks — only the colours and spawn rules change, the physics loop stays identical.
From Fire Fountain to Lava Fountain
The fire fountain above already does the hard part: it throws particles upward, lets gravity drag them back, and recycles them forever. To make the same effect read as molten lava instead of fire, you change how the particles look over their lifetime rather than how they move.
- Age → colour ramp: track how long each blob has been alive and map that to white-hot → yellow → orange → deep red → dark crust. Fresh blobs are blinding; old ones cool to a glowing-cracked rock.
- Thicker, slower blobs: lava is heavier than flame, so widen the particle radius range and lower the upward velocity a touch — the plume should lob rather than flicker.
- A churning vent: a small animated noise shader on a ground plane sells the idea that the blobs are erupting from a molten pool, not from nothing.
- Embers, smoke & splashes: spawn a few bright ember sparks and soft smoke puffs near the vent, and leave cooling crust where blobs land. These extras cost almost nothing but add enormous realism.
Every one of those is a presentation tweak layered on the identical velocity-and-reset loop you already have. That is the real lesson of this tutorial: a solid particle rig is a canvas, and fire vs. lava is just paint.
Performance: 1,000 Meshes vs. One Draw Call
This beginner-friendly version uses 1,000 individual THREE.Mesh spheres because it is the easiest mental model: one object, one position, one colour. It runs fine for a demo, but each mesh is its own draw call, and that cost climbs fast as you crank the particle slider.
The production move — and the one a real lava fountain uses — is to render all the blobs as a single THREE.Points cloud driven by a custom ShaderMaterial. One geometry, one material, roughly one draw call for the whole fountain regardless of count. The colour ramp, the fake-sphere shading, and the glow all live in the shader, so the GPU does the heavy lifting.
- Glow without bloom: draw the points a second time with additive blending and a soft falloff — one extra draw call that looks like a post-processing bloom pass but costs a fraction of it.
- Mobile budget: cap the device pixel ratio (around 1.5), skip MSAA, and start with fewer particles so phones stay at 60fps.
- Pause when hidden: stop the render loop when the tab is in the background so you never waste battery animating an invisible fountain.
The takeaway: learn the effect with 1,000 meshes here, then graduate to Points + a shader when you want thousands of molten blobs without the frame-rate tax.
DEMO VIDEO
How It Works
- Scene, camera, renderer & orbit controls.
- A pool of gradient-colored particles.
- Launch velocity: up hard, out gently.
- Gravity + the reset loop (the heart of it).
- Stay responsive on resize.
The detailed code breakdown and the full copy-paste file are below. Every step is an exact excerpt of the full file, and the full file is the same code as the live demo.
In plain English: when the window changes size, we match the camera and canvas to it so the fountain never looks stretched. Developer note: you must call camera.updateProjectionMatrix() after changing aspect — without it the new aspect ratio is ignored and the scene distorts.
Lava & VFX: How the Molten Fountain Is Built
The beginner version above threw 1,000 individual THREE.Mesh spheres — one draw call each. The lava fountain running in the live background keeps the exact same velocity-and-reset loop but swaps the look: every molten blob is drawn from a single THREE.Points cloud with a custom ShaderMaterial, so the whole fountain is about eight draw calls no matter the particle count. On top of that it layers a colour ramp, fake-sphere crust, additive glow (fake bloom, no post-processing), a churning vent, embers, smoke, and cooling crust — the upgrade promised in the “1,000 Meshes vs. One Draw Call” card above. Here is how each piece works, straight from js/lava-fountain.js.
1. One Points cloud instead of 1,000 meshes
In plain English: one geometry holds every blob, with a per-particle position, aSize, aHeat (how hot/young it is) and aSeed (per-blob randomness), drawn as a single THREE.Points — one draw call for the whole fountain. Developer note: DynamicDrawUsage tells the GPU these buffers change every frame, and aHeat is what the shaders read to colour each blob by its age.
2. The lava colour ramp (one GLSL function)
In plain English: a single function maps a blob’s heat t (1 = just erupted, 0 = cooled crust) through white-hot → yellow → orange → deep red → dark crust. Developer note: fresh blobs are blinding; as aHeat falls each frame the same blob slides down the ramp and cools — this is the entire “fire turns to lava” look, done on the GPU.
3. Fake-sphere shading & glowing crust cracks
In plain English: each point is a flat square, but nz = sqrt(1.0 - d) fakes a sphere normal from gl_PointCoord so flat points read as round molten blobs. Developer note: fbm noise drives thin cracks that keep glowing (lavaRamp(0.35)*crack), and crust grows as vHeat drops so a cooling blob turns to cracked rock — no lights, no textures.
4. Glow without bloom (a second additive pass)
In plain English: the same blob geometry is drawn a second time with a soft radial falloff (exp(-d*4.0)) and additive blending — overlapping halos add up and read like a bloom post-process, but it is just one extra draw call. Developer note: the custom (ONE, ONE) colour blend with ZERO/ONE on the ALPHA channel adds light without destroying the canvas’s destination alpha, so the glow never punches black holes in the transparent hero background.
5. The churning lava vent
In plain English: a flat PlaneGeometry on the ground runs two layers of animated fbm noise to sell a molten pool the blobs erupt from. Developer note: dark crust plates float on the hotter centre, and a sin(uTime*...) term makes the pool pulse/flicker, with a separate additive ventGlow sprite (driven by uGlow in the animate loop) over it for the heat bloom.
6. Embers, splashes & cooling crust
In plain English: sparks live in a fixed-size ring buffer (sIdx = (sIdx+1) % MAX_SPARKS) so emitting embers never allocates memory or triggers garbage collection. Developer note: when the step loop sees a blob cross y < 0 while falling it calls splash(), which sprays a ring of droplet sparks, drops an instanced crust decal (dHeat = 1, cooling toward 0 each frame), and sometimes a smoke puff — the landing feedback that sells real lava.
7. Mobile performance budget
In plain English: on mobile the script caps the device pixel ratio at 1.5, turns MSAA off (antialias: !isMobile), emits fewer embers and smoke, starts at 1,000 blobs, and pauses the whole render loop when the tab is backgrounded. Developer note: it is the same fire-fountain velocity-and-reset loop under the hood — only the look (Points + shaders + glow + vent) and these perf guards changed, which is why phones stay near 60fps and never burn battery on an invisible fountain.
Keep Building in Three.js
- Building 3D Medical Simulations with Three.js: walk an interactive operating room with PointerLockControls, collisions and clickable equipment, then try the 3D anatomy games.