Three.js Space Station (Rotating Habitat Ring)
An orbital station in Three.js above a procedural planet, with a spinning habitat ring that computes its artificial gravity, sun-tracking solar wings, radiators, blinking navigation lights and shuttles docking at the forward port.
Key topics: space station, three.js space, artificial gravity, rotating habitat, procedural planet, sci-fi environment
Game Over
What this code does
- Spin Gravity: a ring of radius r spinning at ω gives a = ω²r at the rim, so 1 g at 40 m needs about 4.7 rpm; the HUD shows the fraction of g at the current display speed.
- Ring Modules: a torus plus 24 cylindrical modules merged into one geometry, with a thin emissive torus as the window band.
- Spine & Arrays: the non-rotating spine carries the truss, six solar wings that rotate toward the sun, radiators and the docking port.
- Planet Shader: fbm noise for continents, clouds and ice caps, night-side city lights masked by the terminator, and an atmospheric rim.
- Traffic: shuttles ease in along +z, hold at the port with engines off, then depart.
- Controls: ring spin, solar tracking, docking traffic and lights.
Related Demos
Continue Learning
JavaScript Implementation
// Spin gravity: a ring of radius r rotating at ω gives centripetal acceleration a = ω² r
const r = 40, oneG = Math.sqrt(9.81 / r) // ≈ 0.5 rad/s ≈ 4.7 rpm for 1 g
ring.rotation.z += oneG * dt
// Build the ring from merged parts: a torus plus 24 cylindrical modules placed around it
const parts = [new THREE.TorusGeometry(r, 3.2, 20, 120)]
for (let k = 0; k < 24; k++) {
const a = k / 24 * Math.PI * 2
parts.push(new THREE.CylinderGeometry(4, 4, 2, 20).rotateX(Math.PI / 2).rotateZ(-a).translate(Math.cos(a) * r, Math.sin(a) * r, 0))
}
scene.add(new THREE.Mesh(mergeGeometries(parts.map(g => g.toNonIndexed())), hullMaterial))