---
title: "Fire effect in three.js from a sprite sheet"
description: "Play fire in three.js today: a snippet loads the packed RGBA sprite sheet on a THREE.Sprite and steps the texture offset. Steps and code."
canonical: https://appliedmanifold.com/effects/threejs-fire/
site: "Applied Manifold: The spatial compute cloud for 3D reality"
---

1.  [Home](https://appliedmanifold.com/)
2.  [Effects](https://appliedmanifold.com/effects/)
3.  [three.js VFX](https://appliedmanifold.com/effects/threejs-vfx/)
4.  three.js fire

EFFECTS // THREE.JS

# How to make fire in three.js

In three.js, you can play a looping fire, from a burning wreck to a fire whirl or a window fire. A snippet loads the packed RGBA sprite sheet on a THREE.Sprite, sets the texture repeat to one eighth, and wraps back to frame 0. Godot 4 gets a ready scene that relights the smoke.

[Get Free API Key](https://console.appliedmanifold.com/sign-in?next=/api-keys) [What the sheets hold →](https://appliedmanifold.com/docs/pyrofx/outputs/)

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

**FIREFINAL**

![First frame of the fire bake](/bakes/fire/poster.webp)

Fire, 4.1 x 7.0 m, compiled with Spatial Compiler. [Spec →](https://appliedmanifold.com/docs/pyrofx/examples/#ex-fire)

01 // WHAT YOU GET

## What you get for fire in three.js

Three fire examples come ready to start from. The steady fire is about 1.5 m across and reads as a burning wreck or a large campfire. The fire whirl spins its flames into a column 7 m tall. The window fire vents flame and smoke out of a burning room. All three loop every 2 seconds.

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 fire in three.js

1.  Ask your agent for the effect (for example "a campfire about 1 m across that loops") 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.  Advance `i` by 32 frames a second, the fire's real speed (64 frames in 2 s), and wrap it with `i % 64` so it loops.
5.  Set `sprite.scale.set(s, s, 1)` with `s` the meters per tile from `layout.json`, a little over 7 m for the fire, so it shows at its real size.

03 // REAL OUTPUT

## Compare the fire examples

**FIRE\_WHIRLFINAL**

![First frame of the fire\_whirl bake](/bakes/fire_whirl/poster.webp)

Fire whirl, 4.4 x 7.1 m, compiled with Spatial Compiler. [Spec →](https://appliedmanifold.com/docs/pyrofx/examples/#ex-fire_whirl)

**WINDOW\_FIREFINAL**

![First frame of the window\_fire bake](/bakes/window_fire/poster.webp)

Window fire, 3.9 x 4.7 m, compiled with Spatial Compiler. [Spec →](https://appliedmanifold.com/docs/pyrofx/examples/#ex-window_fire)

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 fire for your scene

Pick the example closest to your scene and ask your agent to change it: a smaller fire for a torch-lit hall, darker smoke for burning oil, or a new seed when two fires sit side by side and should not match.

Each loop runs for as long as the scene needs it, so one compile covers a fire that burns for the whole level.

05 // WHICH ONE

## Pick a fire example

-   `fire`: A steady fire about 1.5 m across, like a burning wreck. Loops, 4.1 x 7.0 m, 2 s loop.
-   `fire_whirl`: Flames spun into a tall column by a vortex force. Loops, 4.4 x 7.1 m, 2 s loop.
-   `window_fire`: A burning room venting flame and smoke through a window. Three obstacles make the building. Loops, 3.9 x 4.7 m, 2 s loop.

Each one has its own page: [Fire](https://appliedmanifold.com/effects/threejs-steady-fire/), [Fire whirl](https://appliedmanifold.com/effects/threejs-fire-whirl/), [Window fire](https://appliedmanifold.com/effects/threejs-window-fire/).

06 // RELATED

## Related pages

-   [Godot fire Godot 4A looping fire, from a burning wreck to a fire whirl or a window fire, dropped into a Godot 4 scene by your agent.](https://appliedmanifold.com/effects/godot-fire/)
-   [Unity fire UnityA looping fire, from a burning wreck to a fire whirl or a window fire, played in Unity by hand today.](https://appliedmanifold.com/effects/unity-fire/)
-   [Unreal fire Unreal EngineA looping fire, from a burning wreck to a fire whirl or a window fire, played in Unreal Engine by hand today.](https://appliedmanifold.com/effects/unreal-fire/)
-   [Roblox fire Roblox StudioA looping fire, from a burning wreck to a fire whirl or a window fire, played in Roblox Studio by hand today.](https://appliedmanifold.com/effects/roblox-fire/)
-   [three.js explosion three.jsAn explosion that plays once, a ground fireball or a shell impact, played in three.js with a documented snippet.](https://appliedmanifold.com/effects/threejs-explosion/)
-   [three.js smoke three.jsSmoke that loops as a leaning plume or rises once after a blast, played in three.js with a documented snippet.](https://appliedmanifold.com/effects/threejs-smoke/)
-   [Fire sprite sheetGet a looping fire as a 64-frame sprite sheet from the steady fire, fire whirl or window fire compile, and play it in Godot 4 or by hand.](https://appliedmanifold.com/effects/fire-sprite-sheet/)
-   [HDR emissive fireHDR emissive fire stores flame brightness above white, so bloom makes the core glow while the smoke stays lit by the scene.](https://appliedmanifold.com/learn/hdr-emissive-fire/)
-   [Loop a sprite animation three.jsLoop a fire or smoke sprite sheet in three.js from elapsed time, so it plays at the same speed on every screen.](https://appliedmanifold.com/guides/threejs-loop-sprite-animation/)
-   [OutputsWith the default export, each view writes four sheets, `<view>_pos.png`, `_neg.png`, `_colour.png` and `_aux.png`, plus `layout.json`, two still previews, the animated `preview_anim.png` and `bake_report.json`. Sheets are 8 x 8 tiles of 256 px by default.](https://appliedmanifold.com/docs/pyrofx/outputs/)

[All pages in three.js VFX →](https://appliedmanifold.com/effects/threejs-vfx/)

[three.js explosion →](https://appliedmanifold.com/effects/threejs-explosion/)

07 // FAQ

## Questions about fire in three.js

[All questions →](https://appliedmanifold.com/faq/)

**README.THREEJS\_FIRE**

### Is there a looping fire effect for three.js?

Yes. Ask your agent for a campfire about 1 m across that loops, starting from the fire, fire\_whirl or window\_fire example.

### How do I import a fire 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 fire 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 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.

### Should the first and last frames of a fire loop match?

Yes. The fire compile blends its last 12 frames into its first, so frame 64 leads straight back to frame 1 every 2 seconds.

## Compile your first effect

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

[Get Free API Key](https://console.appliedmanifold.com/sign-in?next=/api-keys) [Outputs →](https://appliedmanifold.com/docs/pyrofx/outputs/)

[All effects, guides and explainers →](https://appliedmanifold.com/effects/)
