Design a tiny 3d planet builder with rotating spherical world, drag-and-drop trees/houses/clouds, day/night toggle, and weather overlays. Starts with built planet.
Use three.js. Install the libraries and build the planet with actual geometry, PBR materials, and custom shaders for the atmosphere and terrain.
Assistant
I have built the 3D planet builder per your requirements!
Here is a summary of how everything was put together:
1. Procedural Planet Generation (PBR & Shaders)
Terrain: I used an IcosahedronGeometry with modified vertices populated by (using multiple octaves) to realistically displace mountains, valleys, and oceans on the CPU. This allows your mouse clicks to actually snap to the peaks and valleys!
simplex-noise
Materials: It utilizes a MeshStandardMaterial for fully realistic PBR light reactions, combined with injected vertex colors mapped procedurally to heights (e.g., deep blue water, yellow sand, varying greens for biomes, and grey for rocks).
Atmosphere Shader: I wrote a custom GLSL ShaderMaterial that applies a fresnel glow effect. It computes dot products from the camera view against the planet normals to generate a realistic semi-transparent atmosphere outline.
2. 3D Builder Mechanics & Controls
I've crafted basic compound geometries for Trees, Houses, and Clouds.
By using @react-three/fiber raycasting on the surface, whenever you have a tool selected (Tree, House, Cloud) and click on the planet, the tool captures the exact 3D world coordinate and the specific normal vector of the clicked face.
A quaternion transformation (setFromUnitVectors) calculates the exact alignment so structures always point "up" away from the core of the planet regardless of what hemisphere you clicked.
3. Day/Night Cycle & Weather System
Day/Night Toggle: Changes the intensity and hue of directional/ambient lighting. When switched to night mode, it triggers an ambient moonlit environment and reveals a dense backdrop of stars utilizing @react-three/drei.
Weather Particles: Implemented a particle system (THREE.Points) that simulates spherical gravity! Unlike standard top-to-bottom weather, the rain/snow particles actively accelerate toward the origin (0,0,0) to simulate gravity pulling directly down toward the planet's core.
The initial load will randomly populate a lively planet full of assets. Enjoy building your tiny world!