← all demos · chapter 11

three.js — a planet from noise and light

Real 3D in ~60 lines: a sphere whose vertices are pushed outward by noise (mountains from arithmetic), one light, a starfield, slow rotation. This is the exact skeleton of the planet-exploration demos on reddit. The three.js library (r185, MIT, free) loads from a CDN — no installs, and no Node.js anywhere.

Loading three.js from the CDN… the Run button wakes up when it arrives. (This page needs internet for that one file.)

Try tweaking: mountain height 0.08 → 0.25 (jagged asteroid) or 0.0 (billiard-smooth) · the noise frequencies (3.1, 2.7, 5.3, 4.1) — lower = continents, higher = gravel · planet colour to 0x8fa98f for a mossy world · rotation 0.15 → 2.0 and feel "stately" become "frantic" · star count 400 → 4000.

The 3D twist on things you know: the starfield is chapter 04's, the calm rotation is chapter 05's stately recipe, and a fresnel rim-glow atmosphere would be chapter 06's halo wrapped around the sphere. In Babylon: the same scene is CreateIcoSphere + vertex displacement + PointsCloudSystem — see the Babylon demo. Chapter 11 maps both.

In Godot: the same planet is ~80 lines of Node3D code — take a SphereMesh's arrays, push each vertex along its normal by FastNoiseLite, colour by height, rebuild as an ArrayMesh, and set it spinning under one DirectionalLight3D. Download planet_3d.gd from the Godot project. In Unity: read Mesh.vertices from a sphere, displace each with Mathf.PerlinNoise, write them back and call RecalculateNormals(); the starfield is one Particle System with zero velocity and infinite lifetime. In Unreal: displace in the material instead — a World Position Offset driven by a noise node gives the same silhouette with no CPU mesh edit; the honest vertex-level port uses a runtime/procedural mesh component.