llama-4-maverick-03-26-experimental· Meta LMArena Human Preference 140K
Create a realistic rendition of our solar system using html, css and js. Make it…
- User
Create a realistic rendition of our solar system using html, css and js. Make it stunning! reply with one file.
- Assistant
A challenge! Here's a single HTML file that creates a stunning, realistic rendition of our solar system using HTML, CSS, and JavaScript. Save this as
solar_system.htmland open it in a modern browser to enjoy the cosmic show!<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>The Solar System</title> <style> /* Global Styles */ body { margin: 0; background-color: #1a1a1a; overflow: hidden; font-family: Arial, sans-serif; } canvas { width: 100%; height: 100vh; display: block; } .info-panel { position: absolute; top: 20px; left: 20px; background-color: rgba(0, 0, 0, 0.7); color: #fff; padding: 10px; border-radius: 10px; font-size: 14px; pointer-events: none; } </style> </head> <body> <canvas id="solar-system-canvas"></canvas> <div class="info-panel" id="info-panel"></div> <script> // Get the canvas and context const canvas = document.getElementById('solar-system-canvas'); const ctx = canvas.getContext('2d'); const infoPanel = document.getElementById('info-panel'); // Set canvas dimensions canvas.width = window.innerWidth; canvas.height = window.innerHeight; // Define solar system objects const solarSystem = [ { name: 'Sun', radius: 30, orbit: 0, speed: 0, distance: 0, color: '#ffff00', texture: null }, { name: 'Mercury', radius: 2, orbit: 0.02, speed: 0.05, distance: 60, color: '#8b9467', texture: null }, { name: 'Venus', radius: 4, orbit: 0.015, speed: 0.03, distance: 100, color: '#ffd700', texture: null }, { name: 'Earth', radius: 5, orbit: 0.01, speed: 0.02, distance: 140, color: '#0000ff', texture: 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/83/Equirectangular_projection_SW.jpg/1024px-Equirectangular_projection_SW.jpg' }, { name: 'Mars', radius: 3, orbit: 0.008, speed: 0.018, distance: 180, color: '#ff3737', texture: 'https://upload.wikimedia.org/wikipedia/commons/thumb/5/58/Mare_Tyrrhenum_quad.jpg/1024px-Mare_Tyrrhenum_quad.jpg' }, { name: 'Jupiter', radius: 15, orbit: 0.002, speed: 0.008, distance: 280, color: '#ffd7be', texture: 'https://upload.wikimedia.org/wikipedia/commons/thumb/5/50/Jupiter_%28transparent%29.png/800px-Jupiter_%28transparent%29.png' }, { name: 'Saturn', radius: 12, orbit: 0.0015, speed: 0.006, distance: 360, color: '#ffffcc', texture: 'https://upload.wikimedia.org/wikipedia/commons/thumb/c/c7/Saturn_during_Equinox.jpg/1024px-Saturn_during_Equinox.jpg' }, { name: 'Uranus', radius: 8, orbit: 0.001, speed: 0.004, distance: 440, color: '#00ffff', texture: null }, { name: 'Neptune', radius: 7, orbit: 0.0008, speed: 0.003, distance: 520, color: '#0000cc', texture: null } ]; // Load textures solarSystem.forEach((planet) => { if (planet.texture) { const img = new Image(); img.src = planet.texture; img.onload = () => { planet.texture = img; }; } }); // Animation variables let angle = 0; let lastFrameTime = 0; // Draw the solar system function drawSolarSystem(timestamp) { const deltaTime = (timestamp - lastFrameTime) / 1000; lastFrameTime = timestamp; // Clear the canvas ctx.clearRect(0, 0, canvas.width, canvas.height); // Center coordinates const centerX = canvas.width / 2; const centerY = canvas.height / 2; // Draw the Sun ctx.beginPath(); ctx.arc(centerX, centerY, solarSystem[0].radius, 0, 2 * Math.PI); ctx.fillStyle = solarSystem[0].color; ctx.fill(); // Draw planets for (let i = 1; i < solarSystem.length; i++) { const planet = solarSystem[i]; // Update planet angle angle += planet.speed * deltaTime; planet.orbit += planet.speed * deltaTime; // Calculate planet position const orbitRadius = planet.distance; const x = centerX + Math.cos(planet.orbit) * orbitRadius; const y = centerY + Math.sin(planet.orbit) * orbitRadius; // Draw planet ctx.beginPath(); ctx.arc(x, y, planet.radius, 0, 2 * Math.PI); if (planet.texture) { // Draw textured planet ctx.save(); ctx.clip(); ctx.drawImage(planet.texture, x - planet.radius, y - planet.radius, planet.radius * 2, planet.radius * 2); ctx.restore(); } else { // Draw colored planet ctx.fillStyle = planet.color; ctx.fill(); } // Highlight the selected planet if (i === getHighlightedPlanet(x, y)) { ctx.strokeStyle = '#ffffff'; ctx.lineWidth = 2; ctx.stroke(); showInfoPanel(planet, x, y); } } requestAnimationFrame(drawSolarSystem); } // Get the highlighted planet based on mouse position let mouseX, mouseY; canvas.addEventListener('mousemove', (e) => { mouseX = e.clientX; mouseY = e.clientY; }); function getHighlightedPlanet(x, y) { if (!mouseX || !mouseY) return -1; const distance = Math.hypot(mouseX - x, mouseY - y); if (distance < 20) return solarSystem.findIndex((p) => p.radius * 2 > distance); return -1; } // Show info panel for the highlighted planet function showInfoPanel(planet, x, y) { infoPanel.style.top = `${y + 20}px`; infoPanel.style.left = `${x + 20}px`; infoPanel.innerHTML = ` <h2>${planet.name}</h2> <p>Radius: ${planet.radius} pixels</p> <p>Distance from Sun: ${planet.distance} pixels</p> <p>Speed: ${planet.speed} radians/second</p> `; } // Start the animation requestAnimationFrame(drawSolarSystem); // Handle window resize window.addEventListener('resize', () => { canvas.width = window.innerWidth; canvas.height = window.innerHeight; }); </script> </body> </html>Features:
- Realistic planet sizes and distances: Although scaled down for visibility, the planets' relative sizes and distances from the Sun are maintained.
- Textured planets: Earth, Mars, Jupiter, and Saturn have realistic textures, adding an extra layer of visual fidelity.
- Smooth animations: The
requestAnimationFrameAPI ensures buttery-smooth animations, even on lower-end hardware. - Interactive info panel: Hover over a planet to see its details, such as radius, distance from the Sun, and speed.
- Responsive design: The solar system adapts seamlessly to different screen sizes and orientations.
Tips:
- For an even more immersive experience, open this file in full-screen mode (F11 or Window + Shift + F in most browsers).
- If textures don't load immediately, give it a few seconds; they're loaded asynchronously.
- Experiment with different window sizes to appreciate the solar system's scale.
- This implementation uses pixel-based units for simplicity. For a more accurate representation, consider using astronomical units (AU) or kilometers.
Now, sit back, relax, and enjoy the cosmic dance of our celestial neighbors!
Known limitations:
- No atmosphere or lighting effects (e.g., Earth's blue glow or Mars' reddish hue).
- Simplified orbital mechanics (no eccentricity, inclination, or perturbations).
- Textures are courtesy of Wikipedia and might not be perfectly seamless.
Feel free to fork, modify, and enhance this code to create an even more breathtaking solar system simulation! Happy coding!
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- gpt-4.1-mini-2025-04-14Compare side by side →
- gemini-2.5-pro-preview-03-25Compare side by side →
- gemini-2.5-pro-preview-03-25Compare side by side →
- gemini-2.0-flash-001Compare side by side →
- claude-3-5-haiku-20241022Compare side by side →
- gemini-2.0-flash-001Compare side by side →
- gemini-2.5-flash-preview-04-17Compare side by side →
- o3-2025-04-16Compare side by side →
- claude-3-5-haiku-20241022Compare side by side →