Tiny Solar System
A real-gravity orrery in a glass ball: comets whip round the sun trailing blue and gold tails, moons shatter into sparkling rings, and a living world lights its cities at night.
This world didn't start here.
It needs WebGPU or WebGL2: try a recent Chrome, Edge or Safari, or open it on its own.
Open on its own
Goal & tips
Goal Keep the system stable while the ocean world stays in the green habitable zone, until life lights up its night side.
Try this
- Drag to aim and let go to throw a comet (1). A plain tap gives it a round orbit
- Push a planet with Nudge (2), but keep the ocean world in the green ring
- Send a moon too close to its planet and it shatters into a ring
- Drop the black hole if you dare
Keys 1–4 Fling, Nudge, Spawn, Time[ / ] slower / fasterB black holeF sun flareC Cinema
Secret Who made the sun wink?
Show hint (spoiler)
Get all the planets into one straight line through the sun. It happens now and then on its own: speed time up with ] and keep watching, or nudge planets into step.
The prompt
Build "Tiny Solar System", a playable miniature world: a tiny solar system in a glass sphere with real gravity, where the player flings comets, nudges planets and tries to keep life alive on one world, as ONE self-contained HTML file.
It must be **beautiful above everything**, like a premium animated film: a gorgeous toy cosmos with a radiant sun, jewel-like planets, glowing orbits and comet tails. Great animation on everything that moves: nothing pops, snaps or teleports; things grow, ease, overshoot a little and settle. Calm and satisfying to play, spectacular to watch.
## Tech
* three.js r170 with WebGPURenderer (automatic WebGL2 fallback). Load it with an importmap from jsDelivr: map "three", "three/webgpu" and "three/tsl" to `three@0.170.0/build/three.webgpu.min.js`, and "three/addons/" to `three@0.170.0/examples/jsm/`.
* Use TSL node materials, OrbitControls from the addons, and a subtle BloomNode pass (strength ~0.4, threshold ~1.5) so only emissive things glow (the sun and flares, comet tails, orbit trails, city lights on the living planet, the black hole's accretion disc).
* No external assets. Every texture is drawn on a canvas or generated as pixel data at startup. Every sound is synthesized with WebAudio. The only network requests are three.js from jsDelivr and the Fredoka font from Google Fonts; if the font fails to load, fall back to a system rounded sans-serif without breaking anything.
* Start the HTML with `<!doctype html>` and `<meta charset="utf-8">`.
* It must run inside a sandboxed iframe (`sandbox="allow-scripts allow-pointer-lock"`, no `allow-same-origin`). There, `localStorage` and cookies throw a SecurityError: wrap every storage access in `try/catch` and keep values in memory instead. Do not use `alert`, pop-ups or top-level navigation.
* Neutral tone mapping, soft 2048 shadow map (1024 on phones).
* Known three r170 pitfalls, avoid them:
* the scene background is drawn after transparent objects, so draw the sky/backdrop as a mesh (or give transparent sky objects `depthWrite: true`), or they disappear;
* never `.clone()` a CanvasTexture (the clone uploads black); create separate textures or use DataTexture;
* never let a helper overwrite a shared temp vector that its caller is still using.
* The simulation runs on a fixed 60 Hz timestep and is frame-rate independent. At low frame rates, drop simulation time instead of exploding.
* A quality scaler lowers the pixel ratio, then particle counts, when frames get slow.
* Respect prefers-reduced-motion: softer shake, slower camera moves.
## Priorities
Build in this order and finish each tier properly before the next. A polished tier 1 beats a broken everything.
1. **Must be excellent:** the sun and 4–5 mini planets (rocky, ringed, gas giant, icy) with moons in a glass sphere, real N-body gravity with stable orbits, flinging comets and asteroids with a predicted path, comet tails, the demo mode.
2. **Must work:** nudging planets, spawning planets, collisions and debris, rings forming, the habitable zone and life, time control, milestones, sound, the card UI, camera.
3. **Polish:** eclipses, sun flares, the black hole event, the syzygy Easter egg.
Never ship a feature half-working: if a tier-3 feature can't be done well, leave it out cleanly.
## The system
* A large **glass sphere** (subtle reflections and rim highlights) on a brass stand, containing a tiny cosmos: deep space with stars and a faint nebula inside the glass, against a dark studio backdrop.
* **The sun:** a glowing, gently churning sphere (animated noise surface, corona, bloom) that is the light source for everything.
* **Planets (default system, seed 0001):** a small rocky planet, a blue-green planet (the candidate for life), a **ringed** planet, a striped **gas giant** with a storm spot, an **icy** planet; 1–3 moons; an **asteroid belt** of instanced rocks. Each has its own look and slow spin.
## Physics
* Real **N-body gravity** (sun, planets, moons, comets, asteroids as test particles) with a stable symplectic integrator (velocity Verlet or leapfrog) at a fixed timestep, with substeps; softening to avoid singularities. Orbits are elliptical and planets tug each other.
* **Collisions:** small bodies hitting a planet make a flash and a crater mark; two planets colliding merge with a big burst and debris that forms a **ring** or new moons; a moon that strays too close to a big planet is torn apart into a **ring** (Roche limit).
* **Trails:** faint glowing orbit trails (toggle).
* Bodies that escape the glass sphere bounce softly off it (it's a toy).
## Tools (card, keys 1–5)
* **Fling:** drag from a point to aim and throw a **comet** (or asteroid, toggle): a dotted **predicted path** shows before release. Comets grow **tails pointing away from the sun** (ion tail blue, dust tail gold) that brighten near the sun.
* **Nudge:** drag a planet to give it a push (with its new predicted orbit shown).
* **Spawn:** pick a planet type in the card and tap to place it with a circular-orbit velocity.
* **Time:** a slider for simulation speed (¼× to 16×) and a pause.
* **Black hole (event button):** drop a small black hole: an accretion disc glows, nearby light bends slightly, and it swallows bodies that come too close (with spaghetti streaks) until it evaporates after a while.
## Life
* A **habitable zone** ring (soft green band at the right distance from the sun) is shown on the orbital plane.
* A planet that stays inside the zone for 60 seconds of system time **comes alive**: first oceans and clouds, then green continents, then **city lights** on its night side. If it leaves the zone too long, it freezes or bakes (reversibly).
* **Eclipses:** when a moon passes in front of the sun from a planet's point of view, its shadow is visible on the planet.
* **Sun flares** now and then: a loop of glowing plasma arcs off the sun.
## Goal and milestones
* **Life** meter: how long the life-planet has stayed habitable, plus system stability (no planets lost). Milestones along the way.
* At 100%: the living planet sparkles with city lights, a tiny rocket launches from it and circles the sun.
Milestones (toasts, once each): "First comet tail", "First collision", "A ring is born", "Perfect orbit", "Eclipse", "Life detected", "Survived the black hole", "Living system".
## Easter egg
If all planets line up in a straight line from the sun (a **syzygy**, within a few degrees), the sun **winks** (a cartoon eyelid closes once over its glow). Toast: "The sun saw that." Never hint at it in the UI.
## Interface
A light, playful UI that never covers the world. On phones the card becomes a compact bottom sheet.
* Top left:
* small caps "POKEABLE · WORLD";
* a big chunky rounded heading on two lines, "Tiny" / "Solar System", in Fredoka from Google Fonts, light on the dark backdrop, with a tiny planet orbiting the "o";
* caption "Fling comets. Keep life alive.".
* Top right: a live status dot with "WEBGPU · LIVE" (or "WEBGL2 · LIVE"), a speaker pill button (ON / MUTED), and "PAUSED" when paused.
* Right card "System": about 240 px wide, off-white, 20 px corners, soft shadow, no hairlines, solar orange (#f29b38) accent, collapsible to a small pill. Contents:
* a big animated "Life" % with a bar, the living planet's status (frozen, habitable, alive), and counters for planets, moons and comets
* tool picker: Fling (comet/asteroid toggle), Nudge, Spawn (with planet type chips: Rocky, Ocean, Ringed, Gas giant, Ice), Time, each with a drawn icon and its key number
* event buttons: Black hole, Sun flare, Meteor shower
* sliders with monospace value chips: Simulation speed (¼×–16×), Gravity strength, Trail length, Sound (master volume)
* switches: Trails (on), Habitable zone (on), Slow motion (¼ speed), Cinema
* buttons Reset and New (random seed), a dark full-width Pause/Resume pill, and the world's number ("No. 0001").
* Bottom left: a one-line hint that changes with the tool:
* Fling: "Drag to aim. Let go to throw a comet."
* Nudge: "Drag a planet to push it."
* Spawn: "Tap to add a planet."
* Time: "Speed up or slow down time."
* Bottom right: a collapsible "How it works" panel, 5–6 plain lines on N-body gravity and the integrator, comet tails, collisions and rings, the habitable zone and life, the camera controls, and synthesized sound.
* Toasts at the top centre for milestones and events.
* Keys: 1–4 tools, B black hole, F sun flare, H meteor shower, [ and ] time speed, Space pause, R reset, N new, M mute, S slow motion, C cinema, 0 reset view, Esc stop follow / exit cinema.
## Camera
* OrbitControls with damping and zoom to cursor, within sensible limits.
* Double-click any planet, moon or comet to follow it; Esc or 0 stops.
* Camera bar (floating pill, bottom right of the scene area): zoom −, a zoom % readout, zoom +, rotate left, rotate right, reset; button moves tween smoothly.
* The default framing fits the whole world into the free area, accounting for the card and title.
* **Cinema (`C`):** hides all UI and slowly orbits the camera.
## Sound
* WebAudio only. Create the AudioContext on the first gesture and never before.
* Master gain feeds a compressor, so rapid actions never clip. Limit voices (about 16) and wrap every call in try/catch so a failing audio call never breaks the world.
* Loops: a deep warm space drone that slowly changes chord, the sun's soft roar (low filtered noise), a whoosh layer that follows comet speeds near the sun.
* One-shots: a sling twang when flinging, a crackle for comet tails igniting, deep booms for collisions (scaled by size), a shimmering sweep when a ring forms, a warm swell when life is detected, the black hole's low warping hum, a tiny wink chime, chimes for milestones.
## Demo mode (required)
If the URL has `?demo=1` (or `#demo`), auto-play a deterministic 4.0 s loop:
* Rules:
* Hide all UI and the cursor; never create an AudioContext.
* Fixed quality, default seed, the default system already orbiting with trails, default camera, no OrbitControls.
* Drive the simulation from real elapsed time with the fixed timestep, and restart from the identical state every 4.0 s.
* Start moving within 1 s of load, and stay readable at 15 fps.
* Timeline:
* 0.0–1.2 s: planets orbit with soft glowing trails; the gas giant's storm turns.
* 1.2–2.6 s: a comet flies in on a predicted path, swings close around the sun with a growing blue-gold tail.
* 2.6–3.4 s: a small moon breaks up near the ringed planet into a sparkling ring.
* 3.4–4.0 s: the living planet's night side twinkles with city lights.
## Before you finish, check
* Orbits are stable over minutes at all speeds; energy doesn't blow up; close encounters behave.
* Fling with a predicted path, nudge, spawn; comet tails point away from the sun.
* Collisions, merges, rings from shattered moons, debris.
* The habitable zone and life stages; eclipses; flares; the black hole; the syzygy wink.
* Every tool, slider, switch, button and key; follow mode; Cinema; pause and resume; resizing to phone width.
* Sound behaviour.
* It works inside `<iframe sandbox="allow-scripts allow-pointer-lock">` with no errors (storage blocked).
* `?demo=1` matches the timeline.
* No console or WebGPU validation errors, and it stays smooth on a mid-range laptop.
Put the beauty of the glowing orbits and a comet swinging around the sun first. It should feel like holding the universe in a glass ball.