A beautiful, interactive 3D moon phase visualization built with Three.js and TypeScript. Track lunar cycles, explore moon phases, and navigate through time with smooth animations.
- 3D Moon Visualization - Realistic moon rendering with proper lighting and textures
- Interactive Timeline - Navigate through months and click on specific moon phases
- Smooth Animations - Fluid transitions between different lunar phases
- Real-time Phase Information - Current phase, illumination percentage, and upcoming events
- Keyboard Navigation - Arrow keys for date navigation, shortcuts for New/Full moon
- Responsive Design - Works on desktop and mobile devices
- Astronomical Accuracy - Uses precise Julian Day calculations for moon phases
- Node.js 20.19+ or 22.12+ (required for Vite 7.x)
- npm or yarn for package management
# Clone the repository
git clone https://github.com/NeaByteLab/MoonPhases.git
cd MoonPhases
# Install dependencies
npm install
# Start development server
npm run devOpen http://localhost:5173/MoonPhases/ to view the application.
โ/โArrow keys - Navigate daysโ/โArrow keys - Navigate weeksN- Jump to next New MoonF- Jump to next Full MoonSpace- Return to todayT- Toggle timeline visibility
- Drag - Rotate the 3D moon
- Click timeline markers - Jump to specific moon phases
npm run dev # Start development server
npm run build # Build for production
npm run preview # Preview production build
npm run lint # Run ESLint
npm run lint:fix # Fix ESLint issues
npm run typecheck # Run TypeScript checkssrc/
โโโ core/
โ โโโ ta.ts # Core astronomical calculations
โโโ components/
โ โโโ MoonRenderer.ts # 3D moon visualization
โ โโโ DateTracker.ts # Date management and animations
โ โโโ Timeline.ts # Interactive timeline component
โโโ main.ts # Application entry point
- Three.js - 3D graphics and rendering
- TypeScript - Type-safe development
- Vite - Fast build tool and dev server
- ESLint - Code linting and formatting
The application uses accurate astronomical calculations:
- Julian Day Number conversion for precise date handling
- Synodic Month calculations (29.53 days average)
- Phase illumination based on sun-moon-earth geometry
- Next phase predictions using iterative refinement
- Procedural Moon Texture - Realistic crater and surface details
- Dynamic Lighting - Sun position changes with moon phase
- Star Field Background - Subtle stellar atmosphere
- Responsive Timeline - Visual phase markers and date navigation
- Smooth Animations - Eased transitions between dates
The application uses centralized utilities following Pine Script conventions:
// Core astronomical functions
ta.moonPhase(date) // Get current phase (0-1)
ta.nextNewMoon(date) // Find next new moon
ta.nextFullMoon(date) // Find next full moon
ta.illumination(phase) // Calculate illumination %
ta.daysBetween(d1, d2) // Days between dates- Chrome 90+
- Firefox 88+
- Safari 14+
- Edge 90+
Requires WebGL support for 3D rendering.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.