---
title: "three.js MCP for fire, smoke and explosion sprites"
description: "The agent that writes your three.js scene can call Spatial Compiler's hosted MCP server for fire, smoke and explosion sprite sheets to play on a Sprite."
canonical: https://appliedmanifold.com/mcp/threejs/
site: "Applied Manifold: The spatial compute cloud for 3D reality"
---

1.  [Home](https://appliedmanifold.com/)
2.  [Engine MCP](https://appliedmanifold.com/mcp/)
3.  three.js MCP

MCP // THREE.JS

# three.js MCP for fire, smoke and explosion sprites

A three.js project is code and files, so the agent that writes your scene can also call Spatial Compiler's hosted MCP server for effects. It gets fire, smoke, explosion and dust as PNG sprite sheets and plays them with a documented snippet on a THREE.Sprite. Godot 4 still gets a ready scene that relights the smoke.

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

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

**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)

01 // ALONGSIDE

## What MCP adds when your agent already writes the code

MCP is the protocol your agent uses to call tools. In a three.js project your agent edits the JavaScript directly, so a server helps most when it produces a file the agent cannot write as code, such as a precomputed fire. Spatial Compiler's server is hosted and works from any MCP client.

Ask your agent to compile into a folder your bundler serves, such as `public/fx/`. Each compile writes up to four PNG sheets per view (smoke, which has no flame, skips the color sheet), 2048 x 2048 px with 64 frames, plus `layout.json` with the frame count, playback rate and loop flag. For a sprite that takes one texture, ask for `export.pack` to put the light from above in RGB and opacity in alpha.

02 // CODE

## Play the sheet on a sprite

The window fire loop is 64 frames over 2 s, so the sprite advances 32 frames a second.

The six-way lighting shader runs only in Godot 4, so in three.js the sprite keeps the shading from the one direction you packed.

fire.js

```
import * as THREE from "three";
// scene, camera and renderer come from your app

const tex = new THREE.TextureLoader().load("/fx/window_fire/sheet.png"); // the RGBA sheet your agent packed
tex.repeat.set(1 / 8, 1 / 8);
const sprite = new THREE.Sprite(
  new THREE.SpriteMaterial({ map: tex, transparent: true, depthWrite: false })
);
sprite.scale.set(5, 5, 1); // use meters per tile from layout.json
scene.add(sprite);

const clock = new THREE.Clock();
renderer.setAnimationLoop(() => {
  const frame = Math.floor(clock.getElapsedTime() * 32) % 64;
  tex.offset.set((frame % 8) / 8, 1 - (Math.floor(frame / 8) + 1) / 8);
  renderer.render(scene, camera);
});
```

For many sprites, clone the texture per sprite so each can show its own frame. When a one-shot such as the dust ring ends, call `sprite.removeFromParent()` and `material.dispose()`.

03 // REAL OUTPUT

## A loop and a one-shot to start from

The window fire is a 2 s loop, 3.9 x 4.7 m. The dust ring plays once in 2.1 s across 10.5 m.

**DUST\_RINGFINAL**

![First frame of the dust\_ring bake](/bakes/dust_ring/poster.webp)

Dust ring, 10.5 x 2.2 m, compiled with Spatial Compiler. [Spec →](https://appliedmanifold.com/docs/pyrofx/examples/#ex-dust_ring)

04 // RELATED

## Related pages

-   [three.js VFX three.jsFire, smoke, explosion and dust effects in three.js: sprite sheets you play with a documented snippet, next to Godot 4's ready scene.](https://appliedmanifold.com/effects/threejs-vfx/)
-   [Sprite sheet UV math three.jsTurn a frame number into texture offset and repeat values for a three.js sprite sheet, in JavaScript and in GLSL.](https://appliedmanifold.com/guides/threejs-sprite-sheet-uv/)
-   [MCP or RESTPick MCP when an agent makes the calls and REST when your own code does; both reach the same Spatial Compiler service.](https://appliedmanifold.com/mcp/mcp-vs-rest/)
-   [Roblox Studio MCP Roblox StudioUse Spatial Compiler's hosted MCP server while you build in Roblox Studio: 1024 px flipbooks you set on a ParticleEmitter by hand.](https://appliedmanifold.com/mcp/roblox-studio/)
-   [Engine MCP serversAn engine MCP server is an editor plugin that lets your agent read and change your project through tools.](https://appliedmanifold.com/learn/engine-mcp/)
-   [Install via MCPPoint your MCP client at the hosted server, `https://spatialcompiler.dev/mcp`, which signs you in with an OAuth 2.1 browser login, or run the local server with `npx -y @applied-manifold/spatial-compiler` and your API key in `SPATIAL_API_KEY`.](https://appliedmanifold.com/docs/mcp/)

[All pages in Engine MCP →](https://appliedmanifold.com/mcp/)

[← Roblox Studio MCP](https://appliedmanifold.com/mcp/roblox-studio/)[Game assets over MCP →](https://appliedmanifold.com/mcp/game-assets/)

05 // FAQ

## three.js MCP questions

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

**README.THREEJS**

### Is there a three.js MCP server for game effects?

Yes. Spatial Compiler works with any MCP client to compile fire, smoke, explosion and dust into PNG sprite sheets that three.js plays.

### How do I calculate UV coordinates for a three.js sprite sheet?

Set texture repeat to one eighth by one eighth, offset x to column over 8 and offset y to 1 minus row plus 1 over 8.

### How do I blend fire and smoke sprites in three.js?

Use THREE.AdditiveBlending on the flame sprite and THREE.NormalBlending on the smoke sprite, both with transparent true and depthWrite false.

### How do I play an explosion flipbook once and remove it in three.js?

Stop advancing frames after cell 63, then call removeFromParent on the sprite and dispose on its material using frame times from layout.json.

## 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) [Install via MCP →](https://appliedmanifold.com/docs/mcp/)

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