This project is a web-based application that procedurally generates a unique, spherical 3D planet and simulates a simple ecosystem on its surface. It uses Perlin noise to create detailed terrain, including mountains, oceans, and various biomes. The application is built with modern web technologies, including Three.js for 3D rendering and vanilla JavaScript for the core logic.
- Procedural Planet Generation: Generates a unique 3D planet with detailed terrain using Perlin noise.
- Customizable Parameters: Allows users to customize various generation parameters, such as:
- Seed: The random seed for the noise generation.
- Noise Scale: The level of detail in the terrain.
- Octaves, Persistence, Lacunarity: Parameters to control the complexity of the noise.
- Sea Level: The height of the oceans.
- Exponent: A parameter to control the sharpness of the terrain features.
- Dynamic Biome Simulation: Simulates different biomes (e.g., desert, forest, tundra) based on altitude, temperature, and moisture.
- Simple Ecosystem Simulation: Visualizes "life forms" that move around the planet's surface.
- Interactive 3D Viewer: A fluid 3D viewer that allows users to rotate, zoom, and pan around the planet.
- Comprehensive UI: A user-friendly interface for controlling simulation speed, pausing/resuming, and toggling visualizations.
The core of the terrain generation is based on Perlin noise, a type of gradient noise developed by Ken Perlin. Here's how it's used in this project:
- Noise Generation: A noise function is used to generate a value for each vertex on the planet's sphere.
- Fractional Brownian Motion (fBm): To create more detailed and natural-looking terrain, multiple layers of noise (called octaves) are combined. Each octave has a higher frequency and lower amplitude than the previous one, controlled by the
lacunarityandpersistenceparameters, respectively. - Vertex Displacement: The generated noise value for each vertex is used to displace it along its normal, creating the mountains and valleys on the planet's surface.
- Colorization: The final elevation of each vertex, along with its latitude, is used to determine its biome and assign a corresponding color.
- Performance: Generating a detailed planet with a high-resolution mesh and running a real-time simulation can be computationally expensive. The project is optimized by carefully managing the geometry and minimizing the complexity of the simulation loop.
- Seamless Spherical Mapping: Applying Perlin noise to a sphere without creating seams or distortions at the poles is a classic challenge. This project uses 3D Perlin noise, which is evaluated at each vertex's 3D position, ensuring a seamless and continuous terrain.
- UI/UX Design: Creating an intuitive and responsive UI that allows for real-time manipulation of the generation parameters without overwhelming the user was a key focus.
To run this project locally, you need a simple HTTP server. Here's how you can do it:
If you have Python installed, you can use its built-in HTTP server.
- Clone the repository:
git clone https://github.com/[your-username]/procedural-planet-generator.git cd procedural-planet-generator - Start the server:
- For Python 3:
python -m http.server
- For Python 2:
python -m SimpleHTTPServer
- For Python 3:
- Open in your browser:
Navigate to
http://localhost:8000in your web browser.
If you have Node.js installed, you can use the http-server package.
- Clone the repository (if you haven't already):
git clone https://github.com/your-username/procedural-planet-generator.git cd procedural-planet-generator - Install and run the server:
npx http-server
- Open in your browser:
Navigate to
http://localhost:8080(or the URL provided byhttp-server) in your web browser.