Animation · project 18 of 19

Desert sunrise.

A low-poly flight over the dunes while the sun comes up. Move to steer.

Open the project ↗Get the skill and the code
Desert sunrise, screenshot

How to use it

  1. Let it play: the sun comes up over the dunes.
  2. Move the mouse or a finger across the scene to steer.
  3. Press Replay sunrise to start again.

Where it helps most

  • A calm opening screen for a site or a talk.
  • A first three.js project: small, forgiving, and good-looking early.

The idea

A short, calm piece to sit next to the campfire: a flight over the sand as the sun comes up, something you can steer with a finger and replay.

The build

Claude built it in three.js: flat-shaded, low-poly dunes from layered noise, low pyramids on the horizon, a few floating shapes, and a sun with slowly turning rays that climbs out of a starry night sky while the sky and fog warm up behind it. Moving the pointer or a finger across the scene steers. With reduced motion it shows a single still frame.

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 short, calm 3D animation in the browser with three.js (loaded from a local file, no CDN): a low-poly flight over desert dunes at sunrise.

Scene:
- Terrain: a large plane displaced with layered noise into dunes, flat-shaded (faceted triangles) in warm sand tones, scrolling toward the camera so you appear to fly over it.
- The sun: a glowing disc with a ring of thin rays that turn slowly, rising from behind the dunes while the sky and fog move from a starry night blue to warm sunrise orange; the stars fade as it climbs.
- The sun: a disc with a ring of thin rays that turn slowly, rising from behind the dunes over about 20 seconds while the sky and fog colour move from deep orange to bright day.

Interaction: moving the pointer or a finger across the scene steers (camera banks and drifts left/right, eased). A 'Replay sunrise' button restarts it.
Page: full-screen canvas, a small back link and title in the corners, a one-line hint and the button at the bottom with safe-area padding. With prefers-reduced-motion, show one still frame instead of the flight. No inline scripts or styles. Keep it light enough for a phone.
Page: full-screen canvas, a small back link and title in the corners, a one-line hint and the button at the bottom with safe-area padding. Respect prefers-reduced-motion (slower, no banking). No inline scripts or styles. Keep it light enough for a phone.
Get the code4 files, exactly as they run on this site

three.js r128 is loaded from the site's own /animations/vendor/ folder and is not repeated here.

sunrise.js98 lines

Raw file

/* Desert sunrise: a small three.js scene. A low-poly flight over dunes and pyramids while the sun comes up. */
(function () {
  'use strict';
  var cv = document.getElementById('sunCv'), box = cv.parentElement, btn = document.getElementById('sunReplay'), fb = document.getElementById('sunFb');
  var reduce = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
  var S = null, running = false, raf = 0, t = 0, last = 0, steer = 0, steerT = 0, failed = false;
  function fail() { failed = true; cv.style.display = 'none'; btn.hidden = true; fb.hidden = false; }
  function H(x, z) { return Math.sin(x * 0.08 + Math.sin(z * 0.05) * 2) * 3 + Math.sin(z * 0.11 + x * 0.03) * 2.5 + Math.sin((x + z) * 0.3) * 0.4; }
  function build() {
    var T = window.THREE, W = box.clientWidth || 320, Hh = box.clientHeight || 190, r;
    if (!T) return fail();
    try { r = new T.WebGLRenderer({ canvas: cv, antialias: true }); } catch (e) { return fail(); }
    r.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
    r.setSize(W, Hh, false);
    var sc = new T.Scene(), sky = new T.Color(0x0b1a3a);
    sc.background = sky; sc.fog = new T.Fog(0x0b1a3a, 40, 170);
    var cam = new T.PerspectiveCamera(62, W / Hh, 0.1, 500);
    cam.position.set(0, 10, 30);
    var geo = new T.PlaneGeometry(320, 320, 80, 80); geo.rotateX(-Math.PI / 2);
    sc.add(new T.Mesh(geo, new T.MeshStandardMaterial({ color: 0xc2843a, flatShading: true, roughness: 1, metalness: 0 })));
    var amb = new T.AmbientLight(0x6f7fb0, 0.3); sc.add(amb);
    var sunL = new T.DirectionalLight(0xff9a3c, 0.2); sc.add(sunL);
    var sun = new T.Group(); sc.add(sun);
    sun.add(new T.Mesh(new T.SphereGeometry(14, 28, 28), new T.MeshBasicMaterial({ color: 0xffd166, fog: false })));
    [18, 24].forEach(function (rad, i) { sun.add(new T.Mesh(new T.SphereGeometry(rad, 20, 20), new T.MeshBasicMaterial({ color: 0xffb43c, transparent: true, opacity: 0.16 - i * 0.05, fog: false, depthWrite: false }))); });
    var rays = new T.Group(); sun.add(rays);
    for (var i = 0; i < 12; i++) {
      var ray = new T.Mesh(new T.PlaneGeometry(i % 2 ? 1.2 : 2.2, i % 2 ? 60 : 85), new T.MeshBasicMaterial({ color: 0xffd166, transparent: true, opacity: 0.22, fog: false, depthWrite: false, side: T.DoubleSide, blending: T.AdditiveBlending }));
      ray.rotation.z = i / 12 * Math.PI; rays.add(ray);
    }
    var sp = [];
    for (var j = 0; j < 450; j++) { var a = Math.random() * Math.PI * 2, b = Math.random() * Math.PI * 0.5; sp.push(Math.cos(a) * Math.cos(b) * 220, Math.sin(b) * 220, Math.sin(a) * Math.cos(b) * 220); }
    var sg = new T.BufferGeometry(); sg.setAttribute('position', new T.Float32BufferAttribute(sp, 3));
    var starM = new T.PointsMaterial({ color: 0xffffff, size: 1.6, transparent: true, fog: false, depthWrite: false });
    sc.add(new T.Points(sg, starM));
    var pm = new T.MeshStandardMaterial({ color: 0xe0a85a, flatShading: true, roughness: 0.9 }), pyr = [], orbs = [];
    for (var k = 0; k < 7; k++) {
      var s = 5 + Math.random() * 8, m = new T.Mesh(new T.ConeGeometry(s, s * 1.3, 4), pm);
      m.userData = { x: (Math.random() < 0.5 ? -1 : 1) * (16 + Math.random() * 60), z: Math.random() * 220, s: s };
      m.rotation.y = Math.random() * Math.PI; sc.add(m); pyr.push(m);
    }
    for (var q = 0; q < 5; q++) {
      var o = new T.Mesh(new T.OctahedronGeometry(1.6 + Math.random() * 1.6), new T.MeshStandardMaterial({ color: 0xffd166, flatShading: true, emissive: 0xff7a1a, emissiveIntensity: 0.5, roughness: 0.4 }));
      o.userData = { x: (Math.random() - 0.5) * 80, z: Math.random() * 220, y: 12 + Math.random() * 12, p: Math.random() * 6 };
      sc.add(o); orbs.push(o);
    }
    var night = new T.Color(0x0b1a3a), dawn = new T.Color(0xd35400), day = new T.Color(0x87ceeb), warm = new T.Color(0xff8a3c), white = new T.Color(0xfff4d6);
    var pos = geo.attributes.position;
    S = {
      draw: function () {
        var p = Math.min(t / 10, 1), e = 1 - Math.pow(1 - p, 3), off = t * 26;
        if (p < 0.5) sky.copy(night).lerp(dawn, p * 2); else sky.copy(dawn).lerp(day, (p - 0.5) * 2);
        sc.fog.color.copy(sky);
        for (var i = 0; i < pos.count; i++) pos.setY(i, H(pos.getX(i), pos.getZ(i) - off));
        pos.needsUpdate = true;
        steer += (steerT - steer) * 0.05;
        var cx = Math.sin(t * 0.45) * 9 + steer * 20, cz = 30;
        var cy = Math.max(H(cx, cz - off), H(cx, cz - 8 - off), H(cx, cz - 16 - off)) + 5 + Math.sin(t * 0.9) * 1.2;
        cam.position.x = cx; cam.position.z = cz; cam.position.y += (cy - cam.position.y) * 0.08;
        sun.position.set(0, -22 + e * 72, -160);
        rays.rotation.z = t * 0.25;
        cam.lookAt(cx * 0.35, 8 + e * 14, -160);
        cam.rotateZ(-Math.cos(t * 0.45) * 0.14 - steer * 0.18);
        sunL.position.set(0, Math.max(sun.position.y, 2), -160).normalize();
        sunL.color.copy(warm).lerp(white, Math.max(0, (p - 0.4) / 0.6));
        sunL.intensity = 0.15 + e * 1.25; amb.intensity = 0.3 + p * 0.35;
        starM.opacity = Math.max(0, 1 - p / 0.6);
        pyr.forEach(function (m) { var z = ((m.userData.z + off) % 220) - 190; m.position.set(m.userData.x, H(m.userData.x, z - off) + m.userData.s * 0.55, z); });
        orbs.forEach(function (o) { var z = ((o.userData.z + off * 1.4) % 220) - 190; o.position.set(o.userData.x + Math.sin(t + o.userData.p) * 4, o.userData.y + Math.sin(t * 1.7 + o.userData.p) * 3, z); o.rotation.x = t * 1.3 + o.userData.p; o.rotation.y = t * 0.9; });
        r.render(sc, cam);
      },
      resize: function () { var w = box.clientWidth, h = box.clientHeight; if (!w || !h) return; r.setSize(w, h, false); cam.aspect = w / h; cam.updateProjectionMatrix(); if (!running) S.draw(); }
    };
    if ('ResizeObserver' in window) new ResizeObserver(S.resize).observe(box); else window.addEventListener('resize', S.resize);
  }
  function frame(now) {
    if (!running) return;
    raf = requestAnimationFrame(frame);
    t += Math.min((now - last) / 1000, 0.05); last = now;
    S.draw();
  }
  function start() {
    if (failed || running) return;
    if (!S) { build(); if (!S) return; if (reduce) { t = 7; S.draw(); return; } }
    if (reduce) return;
    running = true; last = performance.now(); raf = requestAnimationFrame(frame);
  }
  function stop() { running = false; cancelAnimationFrame(raf); }
  function point(e) { var b = cv.getBoundingClientRect(); steerT = ((e.clientX - b.left) / b.width - 0.5) * 2; }
  cv.addEventListener('pointermove', point);
  cv.addEventListener('pointerdown', point);
  cv.addEventListener('pointerleave', function () { steerT = 0; });
  cv.addEventListener('pointerup', function (e) { if (e.pointerType !== 'mouse') steerT = 0; });
  btn.addEventListener('click', function () { t = 0; if (reduce && S) { t = 7; S.draw(); } else start(); });
  document.addEventListener('visibilitychange', function () { if (document.hidden) stop(); else start(); });
  start();
})();
index.html25 lines

Raw file

<!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>Desert sunrise | Animations | Shahrouz Ghadimi</title>
<meta name="description" content="Desert sunrise: a low-poly flight over the dunes while the sun comes up. A 3D animation by Shahrouz Ghadimi.">
<link rel="icon" href="../../favicon.svg" type="image/svg+xml">
<link rel="stylesheet" href="../scene.css">
<link rel="stylesheet" href="./sunrise.css">
</head>
<body>
<div class="stagebox"><canvas id="sunCv" role="img" aria-label="Animated 3D flight over low-poly sand dunes and pyramids while the sun rises. Move across it to steer."></canvas></div>
<p class="fail" id="sunFb" hidden>3D preview is not available in this browser.</p>
<div class="top"><a href="../">&larr; Animations</a><span>Desert sunrise</span></div>
<div class="bar">
  <p class="hint">Move across the scene to steer.</p>
  <button type="button" class="fbtn" id="sunReplay">Replay sunrise</button>
</div>
<script src="../vendor/three-r128.min.js"></script>
<script src="./sunrise.js"></script>
</body>
</html>
sunrise.css2 lines

Raw file

#sunCv{display:block;width:100%;height:100%;touch-action:none}
scene.css18 lines

Raw file

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

Write to me Email meHow to use what is here