EFFECTS // THREE.JS

How to make an explosion in three.js

In three.js, you can play an explosion that plays once, a ground fireball or a shell impact. A snippet loads the packed RGBA sprite sheet on a THREE.Sprite, sets the texture repeat to one eighth, and removes it after the last frame. Godot 4 gets a ready scene that relights the smoke.

  • Godot 4 Available
  • Unity Manual setup
  • Unreal Engine Manual setup
  • Roblox Studio Manual setup
  • three.js Available

A draft compile is from $0.05, and new accounts start with $5 of usage.

FIREBALLFINAL
First frame of the fireball bake
Fireball, 9.4 x 13.4 m, compiled with Spatial Compiler. Spec →

01 // WHAT YOU GET

What you get for explosion in three.js

Two explosion examples cover the common cases. The fireball bursts from the ground and rolls upward for 3.7 seconds, about 9.4 m wide and 13.4 m tall at its peak. The impact is a shell hitting dry ground: a flash, thrown earth and a little smoke in 2 seconds, about 3.5 m across.

Each compile is four 2048 px PNG sheets of 64 frames on an 8 x 8 grid, a layout.json with the timing, and previews. The sheets carry lighting from six directions and the flame separately, not one painted color image, so three.js needs a small material to show them.

02 // HOW TO

Play the explosion in three.js

  1. Ask your agent for the effect (for example "a car explosion about 6 m tall that plays once") with export.pack writing the light from above into RGB and opacity into alpha, so one PNG holds gray shading you can tint. (main_pos.png as it comes holds three light directions in RGB, not a color.) Load it with TextureLoader and set texture.repeat.set(1 / 8, 1 / 8).
  2. Put it on a THREE.Sprite with a SpriteMaterial (transparent: true, depthWrite: false) so it always faces the camera. For the flame, make a second texture in an image editor, main_colour.png multiplied by the alpha of main_neg.png squared, and draw it on a second sprite with THREE.AdditiveBlending. That texture is normalized, so restore the peak on the flame sprite with material.color.setScalar(emitMax), where emitMax is scales.emit_max_hdr.
  3. Each frame, pick the tile: column i % 8 and row Math.floor(i / 8), then set texture.offset.set(col / 8, 1 - (row + 1) / 8).
  4. The explosion's frames crowd its fast start, so pick i from the clock: i = layout.frame_times_s.findIndex((t) => t >= elapsed). When that returns -1, after 4 s, call sprite.removeFromParent() and material.dispose().
  5. Set sprite.scale.set(s, s, 1) with s the meters per tile from layout.json, a little over 13.4 m for the explosion, so it shows at its real size.

03 // REAL OUTPUT

Compare the explosion examples

IMPACTFINAL
First frame of the impact bake
Impact, 3.5 x 2.8 m, compiled with Spatial Compiler. Spec →

These clips are final-quality compiles of the shipped examples, played from their own sheets. Your agent can start from any of them.

04 // ADJUST IT

Adjust the explosion for your scene

Use the fireball for vehicles, barrels and big set pieces, and the impact for shells, grenades and anything that hits the ground. Ask your agent for a smaller burst, more smoke after the flash, or a few seeds so repeated explosions do not look identical.

Both end once the effect has faded, so the last frame is empty and the effect can be removed without a pop.

05 // WHICH ONE

Pick a explosion example

  • fireball: A fuel explosion that bursts from the ground and rolls upward. Plays once, 9.4 x 13.4 m, 3.7 s.
  • impact: A shell hitting dry ground: flash, thrown earth, a little smoke. Three emitters in one box. Plays once, 3.5 x 2.8 m, 2.0 s.

Each one has its own page: Fireball, Impact.

07 // FAQ

Questions about explosion in three.js

All questions →

README.THREEJS_EXPLOSION
Is there a one shot explosion effect for three.js?

Yes. Ask your agent for an explosion that plays once, starting from the fireball or impact example, then play the packed sheet.

How do I import an explosion sprite sheet into three.js?

Load the PNG with TextureLoader, set repeat to one eighth on both axes and put it on a SpriteMaterial with transparent true.

How do I randomize the starting frame of several three.js explosion sprites?

Give each sprite its own texture with texture.clone() and start its frame counter at a random integer from 0 to 63.

How do I blend explosion flame and smoke in three.js?

Use two sprites. Put the flame on a SpriteMaterial with THREE.AdditiveBlending and the smoke on normal blending, both with depthWrite false.

How many frames does an explosion effect use?

The explosion compile uses 64 frames on an 8 by 8 grid and gives more frames to the fast burst at the start.

Compile your first effect

You pay per compile and see the price before it runs. New accounts start with $5 of usage.

All effects, guides and explainers →