Click anywhere to blast · Press Space to blast · Press Esc to exit

3D ROCKFIRE EXPLOSION
IN THREE.JS

By Shane Brumback · · Free Three.js tutorial

A rockfire explosion in Three.js throws a burst of 3D debris rocks outward from a center point under gravity, then layers glowing fire, drifting smoke, flying sparks, an expanding shockwave ring, a bright flash, and camera shake on top. This free tutorial builds the whole effect in one copy-paste file.

Jagged debris rocks are blasted outward with real velocity, gravity, and bounce, wrapped in additive fire and sparks, drifting smoke, a shockwave ring, a bright flash, and a jolt of camera shake — click anywhere or press Space to detonate.

3D rockfire explosion effect built with Three.js

LIVE DEMO

The rocks, fire, smoke, and shockwave firing behind this page are the live demo. Click anywhere, or press Space, to set off a rockfire blast. Scroll to keep reading.

Hides the page so you get the scene full screen — click or press Space to blast, press Esc to exit.

Introduction

A "rockfire" blast is the full-fat version of a particle explosion — not just a puff of embers, but chunks of rock hurled into the air, glowing fire and sparks, a roll of smoke, a shockwave ring on the ground, and a camera that kicks when it goes off. In this tutorial you'll build the whole thing in Three.js, and it still comes in at a single file you can copy and run.

The debris rides on a THREE.InstancedMesh. Here's why that matters: if you made each of the ~90 rocks its own mesh, the GPU would have to be told about them one at a time every frame — dozens of separate "draw calls" that quickly make the scene stutter. An InstancedMesh is one object that stamps the same rock shape in many places at once, so the whole pile of debris costs the GPU about as much as a single rock. The fire, smoke, and sparks work the same way: three THREE.Points systems that draw hundreds of dots in one go. A shockwave RingGeometry, a flash sphere, a transient point light, and decaying camera shake sell the impact.

Learn the pattern once and reuse it everywhere — mortar impacts, demolitions, meteor strikes, boss deaths. It's all the same loop: reset the debris to the center, launch it, spawn the particles, flash and shake, then let gravity and fade do the rest.

What you should know first: this is an intermediate build. You'll get the most out of it if you've already set up a basic Three.js scene (a renderer, a camera, and a mesh in a render loop). If that's new, start with How to Program a Simple Particle System or Creating and Animating Simple 3D Objects, then come back here. No build tools are needed — everything loads from a CDN.

WANT A RIGGED CHARACTER YOU CAN DRIVE?

Loved this? The companion tutorial loads a free rigged super soldier GLB in Three.js and gives it a full keyboard controller — WASD to move, Shift to run, Space to jump, F to fire. Same rig-and-animate idea, taken to a playable character.

Rigged super soldier 3D model with WASD keyboard controller in Three.js See the Super Soldier (WASD) Tutorial

Frequently Asked Questions

How do you make an exploding rocks and fire effect in Three.js?

Launch a batch of 3D rock meshes outward from a center point with random velocity and spin, step them each frame under gravity with a floor bounce, and layer glowing fire, smoke, and spark particles plus an expanding shockwave ring over the top. In Three.js you draw all the rocks with a single InstancedMesh and the fire, smoke, and sparks with THREE.Points, so the whole blast stays fast.

How do you throw many 3D rocks efficiently in Three.js?

Use a THREE.InstancedMesh so every rock shares one geometry and one material and renders in a single draw call. Give each instance its own position, rotation, and scale by writing a matrix with a dummy Object3D each frame and setting instanceMatrix.needsUpdate = true. A displaced icosahedron makes a cheap jagged rock, and marking the instance matrix as DynamicDrawUsage tells the GPU it changes every frame.

How do you add fire, smoke, and sparks to a Three.js explosion?

Build three separate THREE.Points systems that share a soft radial-gradient sprite texture: fire and sparks use additive blending so they glow, while smoke uses normal blending so it reads as dark drifting haze. Each frame you move every mote, apply a little gravity, and fade its per-vertex color toward black as its life runs out, which gives the burst its natural rise-and-dissolve look.

How do you make a Three.js explosion feel powerful?

Stack a few punchy transient effects on the first frames of the blast: an expanding shockwave ring that scales outward and fades, a bright flash core sphere, a strong but short-lived point light, and camera shake that decays over about a second. Add an optional WebAudio boom made from a pitch-dropping sine plus filtered noise and the hit lands much harder than the particles alone.

How It Works

  1. Jagged rock geometry comes from an IcosahedronGeometry whose vertices are randomly displaced, so every rock looks hand-chipped.
  2. Two InstancedMeshes draw the debris — plain rocks and emissive "hot" rocks — each in one draw call, with a per-instance matrix written every frame.
  3. resetBody() drops every rock back to a fresh pile at the center before each blast, so repeat clicks always explode from the middle instead of re-launching yesterday's scattered debris.
  4. launch() then gives each rock a random outward-and-upward velocity plus a fast random spin.
  5. stepBodies() applies gravity, then bounces and damps each rock when it hits the floor so the debris settles naturally.
  6. Three Points systems — fire, smoke, sparks — share a soft sprite and fade their per-vertex color over each mote's life. Fire and sparks use additive blending to glow.
  7. A shockwave RingGeometry scales outward and fades in the first second, with a bright flash sphere and a transient point-light flare at the center.
  8. Camera shake decays each frame and ACES tone mapping plus lighting set the mood. blast() — wired to click, Space, and the button — resets the age, resets and re-launches every rock, and respawns the particles, so one call restarts the entire explosion.

What To Try Next

  • Tune the ROCKS, FLAME, SMOKE, and SPARK counts to scale the blast up or down for your target hardware.
  • Recolor the hot-rock emissive and the flame palette for lava-orange, toxic-green, or icy-blue variants.
  • Leave a lingering scorch decal on the ground after the shockwave fades instead of clearing it.
  • Call blast() from game events — a projectile hit or a boss death — instead of a click.
  • Swap the synthesized boom() for a real explosion sound file loaded through the Web Audio API.

MAKE A RIGGED 3D MODEL — NO CODE

Go from a text prompt to a rigged, animated 3D capybara walking in Three.js — using Grok Bot to generate the model, with no modeling and no code. A full step-by-step walkthrough with a live demo.

Rigged 3D capybara model animated in Three.js See the Rigged Capybara Tutorial