This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
PLANETARY is a professional-grade 3D solar system visualization with accurate astronomical data and N-body physics simulation. Built with Three.js, it provides an interactive educational experience for exploring the solar system with real-time physics calculations, orbital mechanics, and high-quality 3D rendering.
npm run dev- Start development server with Vitenpm run build- Build production bundlenpm test- Run all tests with Vitestnpm run test:ui- Run tests with visual interfacenpm run check- Run all checks (tests with coverage, linting, formatting)
npm run test:runner -- MathUtils- Run specific test filenpm run test:runner -- --ui- Run tests with UInpm run test:runner -- --watch- Run tests in watch modenpm run test:runner -- --coverage- Run tests with coverage reportnpm run test:runner -- --all- Run all checks (equivalent tonpm run check)
npm run lint- Run ESLint on source filesnpm run lint:fix- Auto-fix linting issuesnpm run format- Format code with Prettiernpm run format:check- Check code formatting
To run a single test file, use: npm run test:runner -- [TestFileName] (without .test.js extension)
The project follows a modular architecture with clear separation of concerns:
- Engine.js - Main orchestrator that manages all subsystems (RenderEngine, SimulationEngine, DataManager, UIEngine)
- Event-driven communication - Subsystems communicate via event system rather than direct coupling
- Performance monitoring - Built-in performance tracking and optimization
- Rendering (
src/rendering/) - Three.js-based 3D rendering with LOD, materials, lighting - Physics (
src/physics/) - N-body integration, Keplerian orbits, coordinate transformations - Celestial Bodies (
src/celestial/) - Object-oriented hierarchy for stars, planets, moons, asteroids - UI System (
src/ui/) - Interactive controls, tooltips, information panels - Data Management (
src/core/DataManager.js) - NASA JPL Horizons API integration, caching
- SolarSystem.js - Central class managing collections of celestial bodies
- Body categorization - Automatic sorting into stars, planets, moons, asteroids, comets, spacecraft
- Physics integration - Seamless switching between N-body simulation and Keplerian orbits
- Coordinate systems - Support for different reference frames (inertial, body-centered)
- Three.js - 3D rendering and WebGL abstraction
- mathjs - Advanced mathematical operations
- ml-matrix - Linear algebra for coordinate transformations
- lil-gui - Debug and control interface
- Vite - Build tool and development server
- Vitest - Testing framework with Jest-compatible API
- ESLint - Code linting
- Prettier - Code formatting
- Unit tests for mathematical utilities, physics calculations, celestial body operations
- Integration tests for subsystem interactions
- Mock setup includes Three.js, Web Workers, performance APIs in
test/setup.js - Coverage reporting with HTML output in
coverage/directory - Custom test runner (
test-runner.js) provides enhanced CLI functionality
- Tests are co-located with source files (e.g.,
MathUtils.js→MathUtils.test.js) - Each module exports through
index.jsfiles for clean imports - Configuration files at root level (
vite.config.js,vitest.config.js)
- N-body integration with Runge-Kutta 4th order
- Keplerian orbits for efficient computation
- Perturbations including J2, atmospheric drag, solar radiation pressure
- Time scaling for educational time-lapse effects
- Reference frame transformations for different viewing perspectives
- Level of Detail (LOD) system for performance
- Instanced rendering for similar objects
- Texture streaming for high-resolution planetary surfaces
- Custom shaders for atmospheric effects and planetary rings
- Adaptive quality based on performance metrics
- NASA JPL Horizons API for accurate ephemeris data
- Caching system using IndexedDB for offline capability
- Progressive loading of celestial body data
- Real-time vs historical simulation modes
- The project uses ES6 modules throughout
- Event-driven architecture reduces coupling between subsystems
- Performance is critical - monitor frame rates and memory usage
- All physics calculations maintain double precision
- UI components are designed for both desktop and touch interfaces