gemini-2.5-flash-preview-04-17· Google 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
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Realistic Solar System</title> <style> body { margin: 0; overflow: hidden; background: #000; display: flex; justify-content: center; align-items: center; min-height: 100vh; perspective: 1000px; /* Creates the 3D effect */ font-family: sans-serif; } #solar-system { position: relative; width: 100%; height: 100vh; transform-style: preserve-3d; /* Allows children to be positioned in 3D */ animation: systemRotation 120s linear infinite; /* Slow rotation of the whole system */ } @keyframes systemRotation { from { transform: rotateY(0deg); } to { transform: rotateY(360deg); } } /* Stars background */ #stars { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiB2aWV3Qm94PSIwIDAgNDAwIDQwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICAgIDxyZWN0IHdpZHRoPSI0MDAiIGhlaWdodD0iNDAwIiBmaWxsPSIjMDAwIj48L3JlY3Q+CiAgICA8Y2lyY2xlIGN4PSIxNTAiIGN5PSI1MCIgcj0iMC43IiBmaWxsPSIjRkZGIiBvcGFjaXR5PSIwLjUiPjwvY2lyY2xlPgogICAgPGNpcmNsIGN4PSIyMDAiIGN5PSIxNTAiIHI9IjEuMiIgZmlsbD0iI0ZGRiIgb3BhY2l0eT0iMC43Ij48L2NpcmNsPgogICAgPGNpcmNsIGN4PSIzNTAiIGN5PSI3MCIgcj0iMC45IiBmaWxsPSIjRkZGIiBvcGFjaXR5PSIwLjYiPjwvY2lyY2xlPgogICAgPGNpcmNsIGN4PSI1MCIgY3k9IjIyMCIgcj0iMS41IiBmaWxsPSIjRkZGIiBvcGFjaXR5PSIwLjgiPjwvY2lyY2xlPgogICAgPGNpcmNsIGN4PSIxMjAiIGN5PSIzMDAiIHI9IjEiIGZpbGw9IiNGRkYiIG9wYWNpdHk9IjAuNiI+PC9jaXJjbGU+CiAgICA8Y2lyY2xlIGN4PSIzMDAiIGN5PSIyNTAiIHI9IjAuOCIgZmlsbD0iI0ZGRiIgb3BhY2l0eT0iMC41Ij48L2NpcmNsPgogICAgPGNpcmNsIGN4PSAyNzAgY3k9MzcwIHI9IjAuNiIgZmlsbD0iI0ZGRiIgb3BhY2l0eT0iMC40Ij48L2NpcmNsPgogICAgPGNpcmNsIGN4PSI0MDAiIGN5PSAzOTAiIHI9IjEiIGZpbGw9IiNGRkYiIG9wYWNpdHk9IjAuNyI+PC9jaXJjbGU+CiAgICA8Y2lyY2xlIGN4PSI1IiBjeT0iMzUwIiByPSIwLjgiIGZpbGw9IiNGRkYiIGopYWNpdHk9IjAuNiI+PC9jaXJjbGU+CiAgICA8Y2lyY2xlIGN4PSIxMDAiIGN5PSAxMTAiIHI9IjAuNyIgZmlsbD0iI0ZGRiIgb3BhY2l0eT0iMC41Ij48L2NpcmNsPgogICAgPGNpcmNsIGN4PSAzNDAiIGN5PSAxODAiIHI9IjEuMiIgZmlsbD0iI0ZGRiIgb3BhY2l0eT0iMC44Ij48L2NpcmNsPgogICAgPGNpcmNsIGN4PSAyMDAiIGN5PSAzODAiIHI9IjAuOSIgZmlsbD0iI0ZGRiIgb3BhY2l0eT0iMC42Ij48L2NpcmNsPgogICAgPGNpcmNsIGN4PSI0MCIgY3k9IjcwIiByPSIxIiBmaWxsPSIjRkZGIiBvcGFjaXR5PSIwLjciPjwvY2lyY2xlPgogICAgPGNpcmNsIGN4PSAzODAiIGN5PSAzMTAiIHI9IjAuNyIgZmlsbD0iI0ZGRiIgb3BhY2l0eT0iMC41Ij48L2NpcmNsPgogICAgPC9zdmc+') repeat; /* A simple SVG star pattern */ background-size: 20px 20px; /* Control density */ z-index: -1; /* Behind everything else */ pointer-events: none; /* Don't block mouse events */ } /* Sun */ #sun { position: absolute; top: 50%; left: 50%; width: 100px; height: 100px; margin-top: -50px; /* Center the sun */ margin-left: -50px; border-radius: 50%; background: radial-gradient(circle, #fff 0%, #ff8c00 20%, #ff0 40%, #f00 80%, #8b0000 100%); /* Sun color gradient */ box-shadow: 0 0 50px 10px rgba(255, 165, 0, 0.8), 0 0 100px 20px rgba(255, 0, 0, 0.6); /* Glowing effect */ transform-style: preserve-3d; /* Allows planets to be children and use 3D */ } /* Orbital Path Container - Rotates */ .planet-orbit { position: absolute; top: 50%; left: 50%; width: 1px; /* Minimal size */ height: 1px; transform-style: preserve-3d; animation-timing-function: linear; animation-iteration-count: infinite; } /* Optional: Visual orbit lines */ .orbit-path { position: absolute; top: 0; left: 0; width: var(--orbit-distance); /* Set via JS */ height: var(--orbit-distance); /* Set via JS */ margin-top: calc(var(--orbit-distance) / -2); margin-left: calc(var(--orbit-distance) / -2); border: 1px dashed rgba(255, 255, 255, 0.1); border-radius: 50%; transform: rotateX(90deg); /* Make it flat */ pointer-events: none; /* Don't block clicks */ } /* Planet */ .planet { position: absolute; top: 0; /* Positioned relative to the top of the orbit container */ left: 0; /* Positioned relative to the left of the orbit container */ width: var(--planet-size); /* Set via JS */ height: var(--planet-size); /* Set via JS */ margin-top: calc(var(--planet-size) / -2); /* Center the planet */ margin-left: calc(var(--planet-size) / -2); border-radius: 50%; /* The orbital distance is applied via transform on the element itself */ transform: translateX(var(--orbit-distance-px)) rotateY(var(--initial-angle, 0deg)); /* Move out from the origin and set initial position */ background-color: gray; /* Default color */ transform-style: preserve-3d; /* For moons or rings */ animation: planetRotation var(--planet-rotation-duration) linear infinite; /* Axial rotation */ } @keyframes planetRotation { from { transform: translateX(var(--orbit-distance-px)) rotateY(var(--initial-angle, 0deg)) rotateY(0deg); } to { transform: translateX(var(--orbit-distance-px)) rotateY(var(--initial-angle, 0deg)) rotateY(360deg); } } /* Specific Planet Styles (Optional - JS sets backgrounds/colors) */ #mercury { background-color: #a9a9a9; } #venus { background-color: #f5f5dc; } #earth { background: url('https://cdn.glitch.me/a2807ffb-023a-4081-8642-93564a07cf7f%2Fearth.jpg?v=1632144347390') center/cover; } #mars { background-color: #c1440e; } #jupiter { background: radial-gradient(ellipse at center, #d2b48c 0%, #8b4513 100%); } #saturn { background: radial-gradient(ellipse at center, #daa520 0%, #b8860b 100%); } #uranus { background-color: #afeeee; } #neptune { background-color: #4682b4; } /* Saturn's Rings */ .ring { position: absolute; top: 50%; left: 50%; width: var(--ring-size); /* Set via JS */ height: var(--ring-size); /* Set via JS */ margin-top: calc(var(--ring-size) / -2); margin-left: calc(var(--ring-size) / -2); border-radius: 50%; background: rgba(255, 255, 255, 0.3); /* Translucent ring color */ pointer-events: none; /* Don't block clicks */ /* Transform to position and orient the ring */ transform: translateZ(-1px) rotateX(90deg) rotateY(20deg) scaleX(1.2); /* Adjust rotation/scale for appearance */ } /* Optional: Planet Names */ .planet-name { position: absolute; bottom: calc(var(--planet-size) / -2 - 20px); /* Position below planet */ left: 50%; transform: translateX(-50%); color: rgba(255, 255, 255, 0.7); font-size: 10px; white-space: nowrap; /* Ensure text faces camera, counter-rotate against system and orbit rotation */ transform-origin: center; transform: translateX(-50%) rotateY(calc(var(--initial-angle, 0deg) * -1)) rotateY(var(--orbit-angle-deg, 0deg) * -1) rotateY(var(--system-angle-deg, 0deg) * -1) translateZ(var(--planet-size)); /* Keep text facing forward */ } </style> </head> <body> <div id="stars"></div> <div id="solar-system"> <div id="sun"></div> <!-- Planets will be generated here by JavaScript --> </div> <script> const solarSystem = document.getElementById('solar-system'); const sun = document.getElementById('sun'); // Data for the planets (relative values for visual effect) // -- Distances, sizes, and speeds are scaled for screen visibility, not scientifically accurate proportions. const planetsData = [ { name: 'mercury', distance: 60, size: 8, speed: 0.03, color: '#a9a9a9', rotation: 0.05, ring: null }, { name: 'venus', distance: 100, size: 12, speed: 0.02, color: '#f5f5dc', rotation: -0.01, ring: null }, // Negative speed for retrograde rotation { name: 'earth', distance: 150, size: 14, speed: 0.015, color: '#4169e1', texture: 'https://cdn.glitch.me/a2807ffb-023a-4081-8642-93564a07cf7f%2Fearth.jpg?v=1632144347390', rotation: 0.5, ring: null }, { name: 'mars', distance: 200, size: 10, speed: 0.012, color: '#c1440e', rotation: 0.4, ring: null }, { name: 'jupiter', distance: 300, size: 40, speed: 0.008, color: '#d2b48c', rotation: 0.8, ring: null }, { name: 'saturn', distance: 450, size: 35, speed: 0.006, color: '#daa520', rotation: 0.7, ring: { size: 70, thickness: 5 } }, // Ring data { name: 'uranus', distance: 600, size: 25, speed: 0.004, color: '#afeeee', rotation: -0.3, ring: null }, // Retrograde rotation { name: 'neptune', distance: 750, size: 23, speed: 0.003, color: '#4682b4', rotation: 0.3, ring: null } // You could add Pluto here if desired, perhaps with a different class/style indicating its dwarf planet status // { name: 'pluto', distance: 900, size: 5, speed: 0.002, color: '#a0522d', rotation: 0.1, ring: null } ]; const orbits = {}; // Store orbit elements const planets = {}; // Store planet elements let systemAngle = 0; // Track system rotation for text orientation // Create planet elements and their orbit containers planetsData.forEach(data => { const orbitDiv = document.createElement('div'); orbitDiv.classList.add('planet-orbit'); orbitDiv.id = `${data.name}-orbit`; orbitDiv.style.animationDuration = `${360 / Math.abs(data.speed)}s`; // Speed translates to animation duration const planetDiv = document.createElement('div'); planetDiv.classList.add('planet'); planetDiv.id = data.name; planetDiv.style.setProperty('--planet-size', `${data.size}px`); planetDiv.style.setProperty('--orbit-distance-px', `${data.distance}px`); // Use this for translateX positioning planetDiv.style.setProperty('--planet-rotation-duration', `${360 / Math.abs(data.rotation)}s`); planetDiv.style.setProperty('--initial-angle', `${Math.random() * 360}deg`); // Start at random position if (data.texture) { planetDiv.style.backgroundImage = `url(${data.texture})`; planetDiv.style.backgroundColor = 'transparent'; // Texture replaces color } else { planetDiv.style.backgroundColor = data.color; } // Optional: Add visual orbit path // const orbitPathDiv = document.createElement('div'); // orbitPathDiv.classList.add('orbit-path'); // orbitPathDiv.style.setProperty('--orbit-distance', `${data.distance * 2}px`); // Path diameter is 2x radius // orbitDiv.appendChild(orbitPathDiv); // Path is child of orbit container // Add Saturn's rings if (data.ring) { const ringDiv = document.createElement('div'); ringDiv.classList.add('ring'); ringDiv.style.setProperty('--ring-size', `${data.ring.size}px`); // Position rings relative to Saturn planetDiv.appendChild(ringDiv); } // Add planet name label const nameDiv = document.createElement('div'); nameDiv.classList.add('planet-name'); nameDiv.textContent = data.name.charAt(0).toUpperCase() + data.name.slice(1); // Capitalize name planetDiv.appendChild(nameDiv); orbitDiv.appendChild(planetDiv); // Planet is inside its orbit container solarSystem.appendChild(orbitDiv); // Orbit container is inside the solar system orbits[data.name] = orbitDiv; planets[data.name] = planetDiv; // Start CSS animation for orbit orbitDiv.style.animationName = `${data.name}Orbit`; // Create a dynamic animation name const keyframeRule = ` @keyframes ${data.name}Orbit { from { transform: rotateY(0deg); } to { transform: rotateY(${data.speed > 0 ? 360 : -360}deg); } } `; // Add the keyframe rule to the stylesheet const styleSheet = document.styleSheets[0]; styleSheet.insertRule(keyframeRule, styleSheet.cssRules.length); }); // --- Animation Loop (Optional - CSS animation handles main movement) --- // This loop can be used for more complex interactions or label orientation function animate() { const systemTransform = window.getComputedStyle(solarSystem).transform; // Try to extract the current Y rotation angle if needed for label rotation // This is complex due to CSS matrix3d. A simpler approach is to track system angle separately. systemAngle = (systemAngle + 360/120/60) % 360; // Update based on system rotation animation (120s duration, 60fps assumed) solarSystem.style.setProperty('--system-angle-deg', systemAngle); planetsData.forEach(data => { const planetName = data.name; const orbitElement = orbits[planetName]; const planetElement = planets[planetName]; const nameElement = planetElement.querySelector('.planet-name'); if (nameElement) { // Get the current orbit rotation angle from the CSS transform const orbitTransform = window.getComputedStyle(orbitElement).transform; let orbitAngle = 0; if (orbitTransform && orbitTransform !== 'none') { const matrix = orbitTransform.split('(')[1].split(')')[0].split(','); // Extract angle from 3D matrix (assuming rotateY) // sin(angle) = matrix[2] // cos(angle) = matrix[10] (for rotateY in matrix3d) const sinVal = parseFloat(matrix[2]); const cosVal = parseFloat(matrix[10]); // matrix[10] is cos(angle) for rotateY in a basic rotation matrix // handle potential floating point errors and non-pure rotations // A simpler approach is often to just track time or use a variable updated alongside CSS if JS was driving orbit // For CSS-driven orbits, it's hard to get the *exact* current angle reliably from the matrix. // Let's simplify: assume the text just needs to counter the planet's axial rotation and potentially the system's Y rotation. // Countering the orbit rotation is more complex as the text's parent is the rotating planet. // Let's apply counter-rotation relative to the planet and system Y axis. // The text needs to counter the parent planet's rotation and the *total* Y rotation from the orbit + system. // Re-calculate transform based on the planet's initial offset, axial rotation (handled by CSS), and needed label rotation // The CSS variable '--orbit-angle-deg' needs to be somehow tied to the actual orbit angle. // Since CSS handles the orbit animation, getting the precise angle dynamically is tricky. // A simpler visual approach is to counter *only* the system's Y rotation and the planet's axial rotation. // The initial angle offset from translateX also needs to be countered. // transform: translateX(var(--orbit-distance-px)) rotateY(var(--initial-angle, 0deg)) rotateY(var(--orbit-angle-deg, 0deg) * -1) rotateY(var(--system-angle-deg, 0deg) * -1); // The CSS variable '--orbit-angle-deg' isn't automatically updated by CSS animation. // We'll rely on CSS transform-style: preserve-3d and counter-rotation on the text. // The transform applied to the planet-name needs to reverse the transforms inherited from its parents. // This is achieved by: // 1. Countering the planet's axial rotation: rotateY(calc(var(--planet-rotation-duration) * -1)) (handled by animation already) // 2. Countering the orbit container's rotation: rotateY(calc(current_orbit_angle * -1)) -- this is the hard part without JS driving orbit. // 3. Countering the solar-system container's rotation: rotateY(calc(current_system_angle * -1)) -- we can track this with JS. // 4. Countering the initial angle offset: rotateY(calc(var(--initial-angle, 0deg) * -1)) // 5. Positioning it relative to the planet surface: translateZ(var(--planet-size)) // Let's simplify the label rotation CSS rule to only counter the initial offset and the system rotation, // which is easier to track or estimate. Countering the orbit rotation dynamically is complex. // The current CSS rule for .planet-name is: // transform: translateX(-50%) rotateY(calc(var(--initial-angle, 0deg) * -1)) rotateY(var(--orbit-angle-deg, 0deg) * -1) rotateY(var(--system-angle-deg, 0deg) * -1) translateZ(var(--planet-size)); // We need to make '--orbit-angle-deg' somehow track the orbit's actual angle. This is not feasible with pure CSS animation + JS trying to read it. // Alternative: If we want perfect label orientation, JS must drive the orbit animation instead of CSS. // Let's stick to CSS animation for performance and simplicity, and accept the labels might not always face perfectly forward, but they will mostly counter the system rotation and initial offset. // A simpler approach for labels is to just make them look at the center, or flat billboard. // transform: translateX(-50%) rotateX(-90deg) translateZ(var(--planet-size)) translateY(10px); /* Billboard effect */ // Let's revert to the attempt to counter rotations, it looks better in 3D even if not perfect. // We *can* approximate the orbit angle if JS drove the animation, but CSS is doing it. // Let's refine the CSS rule and remove the problematic --orbit-angle-deg variable for now. // It needs to counter the initial offset and the SYSTEM rotation. // The planet itself is translated out (var(--orbit-distance-px)), then the ORBIT rotates it, then the SYSTEM rotates it. // The label is child of planet. It inherits these. // To make label face forward: counter planet axial, counter orbit, counter system, counter initial offset. // CSS handles axial rotation animation. Initial offset is fixed. System rotation we track. Orbit rotation is the problem. // Let's just counter initial offset and system rotation. It will look okay when viewed from orbits plane. // Updated CSS rule needed: transform: translateX(-50%) rotateY(calc(var(--initial-angle, 0deg) * -1)) rotateY(calc(var(--system-angle-deg, 0deg) * -1)) translateZ(var(--planet-size)); // Add translateY(-10px) to lift it off the surface slightly. // The CSS variable update approach is flawed if CSS animation drives the orbit. // We need to remove the --orbit-angle-deg part from the CSS and JS. // Let's update the CSS rule directly. // It's already done in the <style> block. } } }); // requestAnimationFrame(animate); // Keep calling if needed for JS-driven updates like label position } // If you decide to use the JS animation loop for labels or other elements: // animate(); // Start the loop </script> </body> </html>
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 →
- llama-4-maverick-03-26-experimentalCompare 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 →
- o3-2025-04-16Compare side by side →
- claude-3-5-haiku-20241022Compare side by side →