Lesson 13 of 13
Solar System
Final Project: Solar System
You've learned all the building blocks. Now combine them into a small solar system:
- Scene with dark background and fog
- Sun at the center with an emissive material (glows without light)
- Planets orbiting at different radii using Groups
- Lights from the sun (PointLight)
- Stars particle system in the background
- Animation with delta time for frame-rate independence
Emissive Materials
MeshStandardMaterial can self-illuminate with emissive and emissiveIntensity:
new THREE.MeshStandardMaterial({
color: 0xffaa00,
emissive: 0xff6600,
emissiveIntensity: 1.5
})
PointLight with Distance
A PointLight from the sun illuminates planets:
const sunLight = new THREE.PointLight(0xfff4cc, 3, 100);
sunLight.position.set(0, 0, 0);
scene.add(sunLight);
Orbit Groups Pattern
Each planet lives in its own orbit group. Rotating the group orbits the planet:
const orbit = new THREE.Group();
const planet = new THREE.Mesh(geo, mat);
planet.position.x = orbitRadius;
orbit.add(planet);
scene.add(orbit);
// In animation loop:
orbit.rotation.y += delta * orbitSpeed;
Your Task
Implement createPlanet(radius, color, orbitRadius) that:
- Creates a sphere mesh with
MeshStandardMaterialof the given color - Wraps it in an orbit
Groupwith the planet at(orbitRadius, 0, 0) - Returns
{ mesh, orbit }
Three.js loading...
Loading...
Click "Run" to execute your code.