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