Animation · project 17 of 19
Campfire.
A 3D campfire drawn live: ray-marched flames, moving shadows and a crackle made from scratch.
How to use it
- Press Light the fire.
- Turn the sound on for the crackle. Go full screen and leave it running.
Where it helps most
- Background for a quiet evening or a waiting screen.
- Learning how a shader, a flickering light and generated sound make something feel real.
The idea
The mountain stop on this site is about the time off the clock, and a fire belongs there. I wanted one that feels real in a browser: flames that move like flames, light that flickers across the stones, and the sound of it, with no video or audio file behind it.
The build
Claude built the scene in three.js: ray-marched flames in a shader, a flickering point light that throws moving shadows over the stones and logs, drifting sparks and smoke, and a crackle made with the Web Audio API. It waits behind a still picture until you light it, and sound stays off until you ask.
Free to take
Build your own.
Copy the skill, paste it into your own AI, and say what you want different. How to use a skill, step by step ›
Get the skillThe instructions your AI follows. Works in Claude, ChatGPT, Gemini or any other
You are a creative coder. Build a real-time 3D campfire for the browser with three.js (bundled into the page, no CDN).
Scene:
- A small clearing at night: a ring of stones, a few logs leaning into a cone, sand or dirt, dark pine silhouettes and a starry sky.
- Flames as a ray-marched volume in a fragment shader (noise-driven, hot core to orange to transparent tips) on a camera-facing quad or box, not sprites.
- One warm point light at the fire whose intensity and position flicker with the same noise, casting soft moving shadows on the stones and logs.
- Rising sparks (a small particle system) and a faint smoke plume.
Sound (off by default): synthesize a crackle with the Web Audio API: filtered noise bed plus random short pops. No audio files.
Page: show a still poster first with a 'Light the fire' button; start the scene only then. Buttons for sound on/off and full screen. Drag to look around. Respect prefers-reduced-motion with calmer flicker, keep 60 fps on a phone, and show the poster if WebGL is missing. No inline scripts or styles, so it works under a strict Content-Security-Policy.
Get the code4 files, exactly as they run on this site
The scene itself is a single bundled file with three.js built in (animations/campfire/campfire.js, about 550 KB) and is not repeated here.
index.html29 lines
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="color-scheme" content="dark">
<title>Campfire | Animations | Shahrouz Ghadimi</title>
<meta name="description" content="Campfire: a 3D campfire drawn live in your browser, with ray-marched flames, flickering firelight and a crackle synthesized from scratch.">
<link rel="icon" href="../../favicon.svg" type="image/svg+xml">
<link rel="stylesheet" href="../scene.css">
<link rel="stylesheet" href="./campfire.css">
</head>
<body>
<div class="stagebox" id="fireViz">
<div class="fire-poster" id="firePoster" role="img" aria-label="A campfire burning at night"></div>
<div class="fire-host" id="fireHost"></div>
<div class="top"><a href="../">← Animations</a><span>Campfire</span></div>
<div class="bar">
<p class="hint" id="fireHint">Ray-marched flames, moving shadows and a crackle made from scratch.</p>
<button type="button" class="fbtn main" id="fireStart">Light the fire</button>
<button type="button" class="fbtn" id="fireSnd" aria-pressed="false" hidden>Sound off</button>
<button type="button" class="fbtn" id="fireFs" hidden>Full screen</button>
</div>
</div>
<script src="./campfire.js"></script>
<script src="./fire.js"></script>
</body>
</html>
fire.js (buttons, sound, full screen)30 lines
/* Campfire page: the 3D scene starts only when someone presses the button. The scene itself is campfire.js. */
(function () {
'use strict';
var viz = document.getElementById('fireViz'), host = document.getElementById('fireHost'), poster = document.getElementById('firePoster');
var start = document.getElementById('fireStart'), snd = document.getElementById('fireSnd'), fs = document.getElementById('fireFs'), hint = document.getElementById('fireHint');
var reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
var api = null;
function setSnd(on) { snd.setAttribute('aria-pressed', on ? 'true' : 'false'); snd.textContent = on ? 'Sound on' : 'Sound off'; }
function sync() { if (!api) return; api.setRunning(!document.hidden); if (document.hidden && api.isOn()) api.toggleSound().then(setSnd); }
start.addEventListener('click', function () {
start.disabled = true; start.textContent = 'Lighting...';
setTimeout(function () {
try { api = window.Campfire.start(host, { reduce: reduceMotion }); }
catch (e) { start.disabled = false; start.textContent = '3D is not available here'; return; }
host.setAttribute('role', 'img'); host.setAttribute('aria-label', 'A 3D campfire at night, burning in real time');
poster.classList.add('gone'); start.hidden = true; snd.hidden = false; fs.hidden = !viz.requestFullscreen || window.self !== window.top;
hint.textContent = 'Drag to look around.'; sync();
}, 40);
});
snd.addEventListener('click', function () {
if (!api) return;
api.toggleSound().then(setSnd, function () { snd.textContent = 'Sound unavailable'; });
});
fs.addEventListener('click', function () {
try { (document.fullscreenElement ? document.exitFullscreen() : viz.requestFullscreen()).catch(function () {}); } catch (e) {}
});
document.addEventListener('fullscreenchange', function () { fs.textContent = document.fullscreenElement ? 'Exit full screen' : 'Full screen'; });
document.addEventListener('visibilitychange', sync);
})();
campfire.css2 lines
.fire-host,.fire-poster{position:absolute;inset:0}.fire-host canvas{display:block}.fire-poster{background:#04060b url(./poster.jpg) center/contain no-repeat;transition:opacity .8s ease}.fire-poster.gone{opacity:0;pointer-events:none}
scene.css (shared by the animations)18 lines
/* Full-screen pages for the Campfire and Desert sunrise scenes. */
html,body{height:100%;margin:0;background:#04060b;color:#f3ead9;font:15px/1.4 ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;overflow:hidden}
.stagebox{position:fixed;inset:0}
.top{position:fixed;z-index:3;left:0;right:0;top:0;display:flex;justify-content:space-between;align-items:center;gap:12px;padding:calc(12px + env(safe-area-inset-top,0px)) 16px 12px;pointer-events:none;font-size:13px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;text-shadow:0 1px 8px rgba(0,0,0,.7)}
.top a{pointer-events:auto;color:inherit;text-decoration:none;min-height:44px;display:inline-flex;align-items:center}
.top a:hover{text-decoration:underline}
.bar{position:fixed;z-index:3;left:0;right:0;bottom:0;display:flex;flex-wrap:wrap;justify-content:center;align-items:center;gap:8px;padding:12px 16px calc(14px + env(safe-area-inset-bottom,0px));pointer-events:none}
.bar .hint{flex-basis:100%;text-align:center;margin:0;font-size:13px;opacity:.85;text-shadow:0 1px 8px rgba(0,0,0,.8)}
.fbtn{pointer-events:auto;min-height:46px;padding:0 20px;border-radius:999px;border:1px solid rgba(255,190,130,.45);background:rgba(12,8,6,.66);color:#ffe6c9;font:inherit;font-weight:700;font-size:14px;cursor:pointer;-webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px)}
.fbtn:hover:not(:disabled){background:rgba(255,150,70,.3)}
.fbtn:focus-visible{outline:2px solid #ffd9a8;outline-offset:2px}
.fbtn[hidden]{display:none}
.fbtn.main{background:linear-gradient(180deg,#ffb05a,#f0701f);color:#2a1104;border-color:transparent}
.fbtn.main:hover:not(:disabled){background:linear-gradient(180deg,#ffbf78,#f58233)}
.fbtn[aria-pressed="true"]{background:rgba(255,170,100,.22)}
.fail{position:fixed;inset:0;display:grid;place-items:center;padding:24px;text-align:center}
.fail[hidden]{display:none}
Have an idea of your own?
Look around your day, find the thing that wastes your time, and build the fix. Everything here is free to help you start. If you would rather I built it, or you just want to talk an idea through, write to me.