"use client"; import React, { useMemo, useRef } from "react"; import { Canvas, useFrame } from "@react-three/fiber"; import * as THREE from "three"; // 1. Refined, clean Starfield (neat, elegant points of light) function StarField({ count = 650 }: { count?: number }) { const pointsRef = useRef(null!); const [positions, colors] = useMemo(() => { const pos = new Float32Array(count * 3); const col = new Float32Array(count * 3); const colorWhite = new THREE.Color("#ffffff"); const colorIcy = new THREE.Color("#93c5fd"); const colorSilver = new THREE.Color("#e2e8f0"); for (let i = 0; i < count; i++) { const radius = 30 + Math.random() * 80; const theta = Math.random() * 2 * Math.PI; const phi = Math.acos(2 * Math.random() - 1); pos[i * 3] = radius * Math.sin(phi) * Math.cos(theta); pos[i * 3 + 1] = radius * Math.sin(phi) * Math.sin(theta); pos[i * 3 + 2] = radius * Math.cos(phi); const r = Math.random(); const chosen = r > 0.7 ? colorIcy : r > 0.3 ? colorSilver : colorWhite; col[i * 3] = chosen.r; col[i * 3 + 1] = chosen.g; col[i * 3 + 2] = chosen.b; } return [pos, col]; }, [count]); useFrame((state, delta) => { if (!pointsRef.current) return; pointsRef.current.rotation.y += delta * 0.005; pointsRef.current.rotation.x += delta * 0.002; const targetX = (state.pointer.x * Math.PI) / 60; const targetY = (state.pointer.y * Math.PI) / 60; pointsRef.current.rotation.y += (targetX - pointsRef.current.rotation.y) * 0.02; pointsRef.current.rotation.x += (-targetY - pointsRef.current.rotation.x) * 0.02; }); return ( ); } // 2. Bright, Glowing Background Planet (Astraea - Upper Right) function BackgroundPlanetAstraea() { const groupRef = useRef(null!); const planetRef = useRef(null!); const atmosphereRef = useRef(null!); useFrame((state, delta) => { if (planetRef.current) { planetRef.current.rotation.y += delta * 0.05; } if (atmosphereRef.current) { atmosphereRef.current.rotation.y -= delta * 0.03; } if (groupRef.current) { // Subtle floating parallax const targetX = 16 + (state.pointer.x * 2.5); const targetY = 9 + (state.pointer.y * 2.0); groupRef.current.position.x += (targetX - groupRef.current.position.x) * 0.02; groupRef.current.position.y += (targetY - groupRef.current.position.y) * 0.02; } }); return ( {/* Bright Planet Core Sphere */} {/* Radiant Atmospheric Halo Rim */} {/* Outer Luminous Glow Aura Ring */} ); } // 3. Bright, Glowing Background Planet (Kore - Lower Left with Ring) function BackgroundPlanetKore() { const groupRef = useRef(null!); const planetRef = useRef(null!); const ringRef = useRef(null!); useFrame((state, delta) => { if (planetRef.current) { planetRef.current.rotation.y += delta * 0.04; } if (ringRef.current) { ringRef.current.rotation.z += delta * 0.02; } if (groupRef.current) { // Gentle floating parallax const targetX = -18 - (state.pointer.x * 3.0); const targetY = -12 - (state.pointer.y * 2.5); groupRef.current.position.x += (targetX - groupRef.current.position.x) * 0.02; groupRef.current.position.y += (targetY - groupRef.current.position.y) * 0.02; } }); return ( {/* Bright Violet Core Planet */} {/* Atmospheric Halo */} {/* Luminous Majestic Planetary Ring */} ); } // 4. Distant Luminous Stellar Moon Orb function DistantLuminousOrb() { const orbRef = useRef(null!); useFrame((state, delta) => { if (!orbRef.current) return; const t = state.clock.getElapsedTime(); orbRef.current.position.y = 14 + Math.sin(t * 0.8) * 0.6; orbRef.current.position.x = -8 + Math.cos(t * 0.5) * 0.8; }); return ( ); } export default function CosmicGalaxy() { return (
{/* Cinematic Starlight Illumination */} {/* Clean, Neat Starfield */} {/* Bright Circular Planet-Like Objects in the Background */} {/* Atmospheric depth vignettes (subtle gradient, no harsh boxes) */}
{/* Soft circular glowing light fountains behind the planets */}
); }