Download index.html from Bohemicus/galaxy: direct link, hf CLI and curl.
- Browser
- Download file 17.5 kB
-
https://huggingface.co/spaces/Bohemicus/galaxy/resolve/main/index.html
- Command line
-
hf download hf://spaces/Bohemicus/galaxy/index.html
-
curl -L -o index.html https://huggingface.co/spaces/Bohemicus/galaxy/resolve/main/index.html
17.5 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Andromeda Galaxy in 3D</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script> | |
| <style> | |
| body { | |
| margin: 0; | |
| overflow: hidden; | |
| background: linear-gradient(to bottom, #000428, #004e92); | |
| color: white; | |
| font-family: 'Arial', sans-serif; | |
| } | |
| canvas { | |
| display: block; | |
| } | |
| .galaxy-info { | |
| background: rgba(0, 0, 0, 0.7); | |
| backdrop-filter: blur(5px); | |
| border-radius: 15px; | |
| transition: all 0.3s ease; | |
| } | |
| .galaxy-info:hover { | |
| background: rgba(0, 0, 0, 0.9); | |
| } | |
| .controls { | |
| background: rgba(0, 0, 0, 0.5); | |
| border-radius: 10px; | |
| padding: 10px; | |
| } | |
| .star { | |
| position: absolute; | |
| background: white; | |
| border-radius: 50%; | |
| animation: twinkle var(--duration) infinite ease-in-out; | |
| } | |
| @keyframes twinkle { | |
| 0%, 100% { opacity: 0.2; } | |
| 50% { opacity: 1; } | |
| } | |
| </style> | |
| </head> | |
| <body class="relative h-screen flex flex-col"> | |
| <!-- Background stars --> | |
| <div id="stars-container" class="absolute inset-0 overflow-hidden"></div> | |
| <!-- Header --> | |
| <header class="z-10 py-4 px-6 text-center"> | |
| <h1 class="text-4xl md:text-5xl font-bold bg-clip-text text-transparent bg-gradient-to-r from-purple-400 to-blue-500"> | |
| Andromeda Galaxy in 3D | |
| </h1> | |
| <p class="mt-2 text-lg text-blue-200">M31 - Our Galactic Neighbor</p> | |
| </header> | |
| <!-- Main content --> | |
| <main class="flex-grow flex flex-col md:flex-row items-center justify-center p-4 z-10"> | |
| <!-- 3D Galaxy Container --> | |
| <div id="galaxy-container" class="w-full md:w-2/3 h-96 md:h-full relative"> | |
| <!-- This will be populated by Three.js --> | |
| </div> | |
| <!-- Galaxy Information --> | |
| <div class="galaxy-info w-full md:w-1/3 p-6 mt-4 md:mt-0 md:ml-6"> | |
| <h2 class="text-2xl font-bold mb-4 text-purple-300">About Andromeda</h2> | |
| <ul class="space-y-3"> | |
| <li><span class="font-semibold text-blue-300">Distance:</span> ~2.5 million light-years</li> | |
| <li><span class="font-semibold text-blue-300">Diameter:</span> ~220,000 light-years</li> | |
| <li><span class="font-semibold text-blue-300">Stars:</span> ~1 trillion (10<sup>12</sup>)</li> | |
| <li><span class="font-semibold text-blue-300">Type:</span> Barred spiral galaxy</li> | |
| <li><span class="font-semibold text-blue-300">Discovery:</span> 964 AD by Persian astronomer</li> | |
| </ul> | |
| <div class="mt-6 controls"> | |
| <div class="flex items-center mb-3"> | |
| <label for="rotation-speed" class="mr-3">Rotation Speed:</label> | |
| <input type="range" id="rotation-speed" min="0" max="0.02" step="0.001" value="0.005" class="flex-grow"> | |
| </div> | |
| <div class="flex items-center mb-3"> | |
| <label for="zoom" class="mr-3">Zoom:</label> | |
| <input type="range" id="zoom" min="3" max="20" step="0.5" value="10" class="flex-grow"> | |
| </div> | |
| <div class="flex items-center mb-3"> | |
| <label for="view-angle" class="mr-3">View Angle:</label> | |
| <input type="range" id="view-angle" min="0" max="90" step="1" value="0" class="flex-grow"> | |
| </div> | |
| <div class="flex space-x-2 mb-3"> | |
| <button id="frontal-view" class="px-3 py-1 bg-blue-600 hover:bg-blue-700 rounded transition flex-1"> | |
| Frontal | |
| </button> | |
| <button id="sagittal-view" class="px-3 py-1 bg-blue-600 hover:bg-blue-700 rounded transition flex-1"> | |
| Sagittal | |
| </button> | |
| <button id="top-view" class="px-3 py-1 bg-blue-600 hover:bg-blue-700 rounded transition flex-1"> | |
| Top | |
| </button> | |
| </div> | |
| <button id="reset-view" class="px-4 py-2 bg-blue-600 hover:bg-blue-700 rounded transition w-full mb-3"> | |
| Reset View | |
| </button> | |
| <button id="add-stars" class="px-4 py-2 bg-purple-600 hover:bg-purple-700 rounded transition w-full"> | |
| Add More Stars | |
| </button> | |
| </div> | |
| </div> | |
| </main> | |
| <!-- Footer --> | |
| <footer class="z-10 py-3 text-center text-sm text-blue-300"> | |
| <p>Explore the beauty of our cosmic neighbor - The Andromeda Galaxy (M31)</p> | |
| </footer> | |
| <script> | |
| // Create background stars | |
| function createStars() { | |
| const container = document.getElementById('stars-container'); | |
| const starCount = 200; | |
| for (let i = 0; i < starCount; i++) { | |
| const star = document.createElement('div'); | |
| star.className = 'star'; | |
| // Random properties | |
| const size = Math.random() * 3; | |
| const x = Math.random() * 100; | |
| const y = Math.random() * 100; | |
| const duration = 2 + Math.random() * 3; | |
| star.style.width = `${size}px`; | |
| star.style.height = `${size}px`; | |
| star.style.left = `${x}%`; | |
| star.style.top = `${y}%`; | |
| star.style.setProperty('--duration', `${duration}s`); | |
| container.appendChild(star); | |
| } | |
| } | |
| // Initialize Three.js scene | |
| function initGalaxy() { | |
| const container = document.getElementById('galaxy-container'); | |
| // Scene | |
| const scene = new THREE.Scene(); | |
| // Camera | |
| const camera = new THREE.PerspectiveCamera(75, container.clientWidth / container.clientHeight, 0.1, 1000); | |
| camera.position.z = 15; | |
| // Renderer | |
| const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true }); | |
| renderer.setSize(container.clientWidth, container.clientHeight); | |
| container.appendChild(renderer.domElement); | |
| // Create galaxy particles | |
| const particleCount = 5000; | |
| const particles = new THREE.BufferGeometry(); | |
| const positions = new Float32Array(particleCount * 3); | |
| const colors = new Float32Array(particleCount * 3); | |
| const color = new THREE.Color(); | |
| // Spiral galaxy parameters | |
| const arms = 2; | |
| const armSeparation = Math.PI * 2 / arms; | |
| const coreRadius = 2; | |
| const armWidth = 0.5; | |
| for (let i = 0; i < particleCount; i++) { | |
| // Spiral distribution | |
| const arm = Math.floor(Math.random() * arms); | |
| const angle = Math.random() * Math.PI * 2; | |
| const radius = coreRadius + Math.random() * 5; | |
| // Spiral shape | |
| const spiralAngle = angle + arm * armSeparation; | |
| const spiralRadius = radius * (1 + armWidth * Math.sin(angle * 5)); | |
| // Position | |
| const x = spiralRadius * Math.cos(spiralAngle); | |
| const y = spiralRadius * Math.sin(spiralAngle); | |
| const z = (Math.random() - 0.5) * 0.5; | |
| positions[i * 3] = x; | |
| positions[i * 3 + 1] = y; | |
| positions[i * 3 + 2] = z; | |
| // Color - mix of blue, white and purple | |
| const colorValue = Math.random(); | |
| if (colorValue < 0.7) { | |
| color.setHSL(0.6, 0.75, 0.5 + Math.random() * 0.3); // Blue | |
| } else if (colorValue < 0.9) { | |
| color.setHSL(0.8, 0.8, 0.7); // Purple | |
| } else { | |
| color.setHSL(0, 0, 0.9 + Math.random() * 0.1); // White | |
| } | |
| colors[i * 3] = color.r; | |
| colors[i * 3 + 1] = color.g; | |
| colors[i * 3 + 2] = color.b; | |
| } | |
| particles.setAttribute('position', new THREE.BufferAttribute(positions, 3)); | |
| particles.setAttribute('color', new THREE.BufferAttribute(colors, 3)); | |
| // Particle material | |
| const particleMaterial = new THREE.PointsMaterial({ | |
| size: 0.05, | |
| vertexColors: true, | |
| transparent: true, | |
| opacity: 0.8, | |
| sizeAttenuation: true | |
| }); | |
| // Create galaxy particle system | |
| const galaxy = new THREE.Points(particles, particleMaterial); | |
| scene.add(galaxy); | |
| // No lights needed since we're using MeshBasicMaterial | |
| // Controls | |
| const rotationSpeed = document.getElementById('rotation-speed'); | |
| const zoomControl = document.getElementById('zoom'); | |
| const viewAngleControl = document.getElementById('view-angle'); | |
| const frontalView = document.getElementById('frontal-view'); | |
| const sagittalView = document.getElementById('sagittal-view'); | |
| const topView = document.getElementById('top-view'); | |
| const resetView = document.getElementById('reset-view'); | |
| let currentRotationSpeed = parseFloat(rotationSpeed.value); | |
| let targetZoom = parseFloat(zoomControl.value); | |
| let targetRotationX = 0; | |
| let targetRotationY = 0; | |
| // Animation loop | |
| function animate() { | |
| requestAnimationFrame(animate); | |
| // Get particle positions and update them for rotation | |
| const positions = particles.attributes.position.array; | |
| const particleCount = positions.length / 3; | |
| for (let i = 0; i < particleCount; i++) { | |
| const x = positions[i * 3]; | |
| const y = positions[i * 3 + 1]; | |
| // Calculate radius from center | |
| const radius = Math.sqrt(x * x + y * y); | |
| // Skip particles too close to center | |
| if (radius < 0.5) continue; | |
| // Calculate current angle | |
| const angle = Math.atan2(y, x); | |
| // Calculate rotation speed (faster near center) | |
| const speed = currentRotationSpeed * (1 + (1 - radius/8)); | |
| // Update position with rotation | |
| positions[i * 3] = radius * Math.cos(angle + speed); | |
| positions[i * 3 + 1] = radius * Math.sin(angle + speed); | |
| } | |
| // Mark positions as needing update | |
| particles.attributes.position.needsUpdate = true; | |
| // Smooth zoom and rotation | |
| camera.position.z += (targetZoom - camera.position.z) * 0.1; | |
| galaxy.rotation.x += (targetRotationX - galaxy.rotation.x) * 0.1; | |
| galaxy.rotation.y += (targetRotationY - galaxy.rotation.y) * 0.1; | |
| renderer.render(scene, camera); | |
| } | |
| animate(); | |
| // Event listeners | |
| rotationSpeed.addEventListener('input', () => { | |
| currentRotationSpeed = parseFloat(rotationSpeed.value); | |
| }); | |
| zoomControl.addEventListener('input', () => { | |
| targetZoom = parseFloat(zoomControl.value); | |
| }); | |
| // View angle control | |
| viewAngleControl.addEventListener('input', () => { | |
| const angle = parseFloat(viewAngleControl.value) * Math.PI / 180; | |
| targetRotationX = angle; | |
| }); | |
| // Preset views | |
| frontalView.addEventListener('click', () => { | |
| targetRotationX = 0; | |
| targetRotationY = 0; | |
| viewAngleControl.value = '0'; | |
| }); | |
| sagittalView.addEventListener('click', () => { | |
| targetRotationX = Math.PI/2; | |
| targetRotationY = 0; | |
| viewAngleControl.value = '90'; | |
| }); | |
| topView.addEventListener('click', () => { | |
| targetRotationX = 0; | |
| targetRotationY = Math.PI/2; | |
| viewAngleControl.value = '0'; | |
| }); | |
| resetView.addEventListener('click', () => { | |
| rotationSpeed.value = '0.005'; | |
| currentRotationSpeed = 0.005; | |
| zoomControl.value = '10'; | |
| targetZoom = 10; | |
| targetRotationX = 0; | |
| targetRotationY = 0; | |
| viewAngleControl.value = '0'; | |
| galaxy.rotation.set(0, 0, 0); | |
| }); | |
| // Add more stars button | |
| const addStarsBtn = document.getElementById('add-stars'); | |
| addStarsBtn.addEventListener('click', () => { | |
| const currentCount = particles.attributes.position.count; | |
| const additionalStars = 1000; // Number of stars to add | |
| const newCount = currentCount + additionalStars; | |
| // Create new arrays with expanded size | |
| const newPositions = new Float32Array(newCount * 3); | |
| const newColors = new Float32Array(newCount * 3); | |
| // Copy existing data | |
| newPositions.set(particles.attributes.position.array); | |
| newColors.set(particles.attributes.color.array); | |
| // Add new stars | |
| for (let i = currentCount; i < newCount; i++) { | |
| // Same distribution logic as initial creation | |
| const arm = Math.floor(Math.random() * arms); | |
| const angle = Math.random() * Math.PI * 2; | |
| const radius = coreRadius + Math.random() * 5; | |
| const spiralAngle = angle + arm * armSeparation; | |
| const spiralRadius = radius * (1 + armWidth * Math.sin(angle * 5)); | |
| newPositions[i * 3] = spiralRadius * Math.cos(spiralAngle); | |
| newPositions[i * 3 + 1] = spiralRadius * Math.sin(spiralAngle); | |
| newPositions[i * 3 + 2] = (Math.random() - 0.5) * 0.5; | |
| // Color | |
| const colorValue = Math.random(); | |
| if (colorValue < 0.7) { | |
| color.setHSL(0.6, 0.75, 0.5 + Math.random() * 0.3); | |
| } else if (colorValue < 0.9) { | |
| color.setHSL(0.8, 0.8, 0.7); | |
| } else { | |
| color.setHSL(0, 0, 0.9 + Math.random() * 0.1); | |
| } | |
| newColors[i * 3] = color.r; | |
| newColors[i * 3 + 1] = color.g; | |
| newColors[i * 3 + 2] = color.b; | |
| } | |
| // Update geometry | |
| particles.setAttribute('position', new THREE.BufferAttribute(newPositions, 3)); | |
| particles.setAttribute('color', new THREE.BufferAttribute(newColors, 3)); | |
| console.log(`Added ${additionalStars} stars. Total: ${newCount}`); | |
| }); | |
| // Handle window resize | |
| window.addEventListener('resize', () => { | |
| camera.aspect = container.clientWidth / container.clientHeight; | |
| camera.updateProjectionMatrix(); | |
| renderer.setSize(container.clientWidth, container.clientHeight); | |
| }); | |
| } | |
| // Initialize everything when DOM is loaded | |
| document.addEventListener('DOMContentLoaded', () => { | |
| createStars(); | |
| initGalaxy(); | |
| }); | |
| </script> | |
| <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Bohemicus/galaxy" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
| </html> |