import React, { useState, useRef, useEffect } from 'react'; import { Canvas } from '@react-three/fiber'; import { OrbitControls, Stars } from '@react-three/drei'; import * as THREE from 'three'; import Navbar from '../components/Navbar'; import PlanetInfo from '../components/PlanetInfo'; import StarField from '../components/StarField'; import Sun from '../components/Sun'; import Planet from '../components/Planet'; export default function SolarSystem() { const [selectedPlanet, setSelectedPlanet] = useState(null); const [speed, setSpeed] = useState(1); const [cameraDistance, setCameraDistance] = useState(100); const [viewMode, setViewMode] = useState('solar-system'); const [planetData, setPlanetData] = useState(null); // Planet data configuration const planets = [ { name: "Mercury", size: 2, distance: 30, speed: 0.04, color: "#A5A5A5", texture: null, onClick: () => handlePlanetClick("mercury") }, { name: "Venus", size: 3.5, distance: 45, speed: 0.03, color: "#E3BB76", texture: null, onClick: () => handlePlanetClick("venus") }, { name: "Earth", size: 3.6, distance: 60, speed: 0.02, color: "#22A6B3", texture: null, onClick: () => handlePlanetClick("earth") }, { name: "Mars", size: 2.8, distance: 75, speed: 0.018, color: "#FF6B6B", texture: null, onClick: () => handlePlanetClick("mars") }, { name: "Jupiter", size: 10, distance: 100, speed: 0.012, color: "#DDA15E", texture: null, onClick: () => handlePlanetClick("jupiter") }, { name: "Saturn", size: 8.5, distance: 130, speed: 0.01, color: "#BC8F5F", texture: null, hasRings: true, onClick: () => handlePlanetClick("saturn") }, { name: "Uranus", size: 6, distance: 160, speed: 0.008, color: "#7ED6DF", texture: null, onClick: () => handlePlanetClick("uranus") }, { name: "Neptune", size: 5.8, distance: 190, speed: 0.006, color: "#219EBD", texture: null, onClick: () => handlePlanetClick("neptune") } ]; const handlePlanetClick = (planetName) => { setSelectedPlanet(planetName); // Update camera position for better view setCameraDistance(40); }; const handleClosePlanetInfo = () => { setSelectedPlanet(null); setCameraDistance(100); }; return (
{/* Navbar */} {/* 3D Canvas */}
{/* Lights */} {/* Controls */} {/* Starfield */} {/* Sun */} handlePlanetClick('sun')} /> {/* Planets */} {planets.map((planet) => ( ))} {/* Orbit lines for clarity */} {planets.map((planet, i) => ( ))} {/* Planet Info Modal */} {selectedPlanet && ( )} {/* Info Panel */}

Interactive Solar System

Click on any planet to learn more about it. Use your mouse to rotate, zoom, and explore the solar system.

Click the Sun or planets to explore
Earth is our home planet
Mars - the Red Planet
{/* Footer Attribution */}
Built with anycoder
); }