File size: 10,718 Bytes
6e526ed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
import streamlit as st
import streamlit.components.v1 as components

# Configure the page
st.set_page_config(
    page_title="Solar System Visualization",
    layout="wide",
    initial_sidebar_state="collapsed"
)

# Title
st.title("Interactive Solar System Visualization 🌌")

# HTML/JavaScript content
SOLAR_SYSTEM_HTML = """
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Our Solar System</title>
    <style>
        body { margin: 0; overflow: hidden; }
        canvas { display: block; width: 100% !important; height: 1024px !important; }
        #crawl-container {
            position: absolute;
            width: 100%;
            height: 1024px;
            overflow: hidden;
            perspective: 400px;
            font-family: Arial, sans-serif;
        }
        #crawl {
            position: absolute;
            top: 100%;
            left: 50%;
            width: 70%;
            transform: translateX(-50%) rotateX(25deg);
            font-size: 24px;
            text-align: justify;
            color: #feda4a;
        }
        .planet-info {
            margin-bottom: 2em;
        }
    </style>
</head>
<body>
    <div id="crawl-container">
        <div id="crawl">
            <h1>Our Amazing Solar System 🌌</h1>

            <div class="planet-info">
                <h2>The Sun β˜€οΈ</h2>
                <p>Our star, a G-type main-sequence star (G2V), located at the center of our solar system:
                - Age: 4.6 billion years
                - Surface Temperature: 5,500Β°C (10,000Β°F)
                - Diameter: 1.4 million km (865,000 miles)
                - Mass: 333,000x Earth's mass</p>
            </div>

            <div class="planet-info">
                <h2>Mercury πŸͺ</h2>
                <p>The smallest and innermost planet:
                - Distance from Sun: 57.9 million km
                - Length of year: 88 Earth days
                - Surface temperature: -180Β°C to 430Β°C
                - No moons</p>
            </div>

            <div class="planet-info">
                <h2>Venus 🌟</h2>
                <p>Earth's "sister planet":
                - Distance from Sun: 108.2 million km
                - Length of year: 225 Earth days
                - Surface temperature: 462Β°C
                - Rotates backwards compared to most planets</p>
            </div>

            <div class="planet-info">
                <h2>Earth 🌍</h2>
                <p>Our home planet:
                - Distance from Sun: 149.6 million km
                - Length of year: 365.25 days
                - Only known planet with life
                - One moon: Luna πŸŒ•</p>
            </div>

            <div class="planet-info">
                <h2>Mars πŸ”΄</h2>
                <p>The Red Planet:
                - Distance from Sun: 227.9 million km
                - Length of year: 687 Earth days
                - Two moons: Phobos and Deimos
                - Home to largest volcano in solar system</p>
            </div>

            <div class="planet-info">
                <h2>Jupiter ⭐</h2>
                <p>The largest planet:
                - Distance from Sun: 778.5 million km
                - Length of year: 11.9 Earth years
                - 79 known moons
                - Great Red Spot is a giant storm</p>
            </div>

            <div class="planet-info">
                <h2>Saturn πŸ’«</h2>
                <p>The ringed planet:
                - Distance from Sun: 1.4 billion km
                - Length of year: 29.5 Earth years
                - 82 confirmed moons
                - Spectacular ring system</p>
            </div>

            <div class="planet-info">
                <h2>Uranus ❄️</h2>
                <p>The tilted planet:
                - Distance from Sun: 2.9 billion km
                - Length of year: 84 Earth years
                - 27 known moons
                - Rotates on its side</p>
            </div>

            <div class="planet-info">
                <h2>Neptune πŸ’¨</h2>
                <p>The windiest planet:
                - Distance from Sun: 4.5 billion km
                - Length of year: 165 Earth years
                - 14 known moons
                - Strongest winds in the solar system</p>
            </div>
        </div>
    </div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
    <script>
        // Set up the scene, camera, and renderer
        const scene = new THREE.Scene();
        const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
        const renderer = new THREE.WebGLRenderer({ antialias: true });
        renderer.setSize(window.innerWidth, 1024);
        document.body.appendChild(renderer.domElement);

        // Function to create a celestial body
        function createCelestialBody(radius, color, x, y, z) {
            const geometry = new THREE.SphereGeometry(radius, 32, 32);
            const material = new THREE.MeshPhongMaterial({ color: color });
            const body = new THREE.Mesh(geometry, material);
            body.position.set(x, y, z);
            return body;
        }

        // Create the Sun and planets (not to scale to fit visualization)
        const sun = createCelestialBody(3, 0xffff00, 0, 0, 0);
        const mercury = createCelestialBody(0.4, 0xa0522d, 4, 0, 0);
        const venus = createCelestialBody(0.6, 0xdeb887, 6, 0, 0);
        const earth = createCelestialBody(0.6, 0x4169e1, 8, 0, 0);
        const moon = createCelestialBody(0.2, 0x808080, 8.8, 0, 0);
        const mars = createCelestialBody(0.5, 0xff4500, 10, 0, 0);
        const jupiter = createCelestialBody(1.2, 0xffa500, 13, 0, 0);
        const saturn = createCelestialBody(1.0, 0xf0e68c, 16, 0, 0);
        const uranus = createCelestialBody(0.8, 0x87ceeb, 19, 0, 0);
        const neptune = createCelestialBody(0.8, 0x4169e1, 22, 0, 0);

        // Add planets to the scene
        scene.add(sun);
        scene.add(mercury);
        scene.add(venus);
        scene.add(earth);
        scene.add(moon);
        scene.add(mars);
        scene.add(jupiter);
        scene.add(saturn);
        scene.add(uranus);
        scene.add(neptune);

        // Create starfield
        const starGeometry = new THREE.BufferGeometry();
        const starMaterial = new THREE.PointsMaterial({
            color: 0xFFFFFF,
            size: 0.1,
            transparent: true
        });

        const starVertices = [];
        for (let i = 0; i < 10000; i++) {
            const x = (Math.random() - 0.5) * 2000;
            const y = (Math.random() - 0.5) * 2000;
            const z = (Math.random() - 0.5) * 2000;
            starVertices.push(x, y, z);
        }

        starGeometry.setAttribute('position', new THREE.Float32BufferAttribute(starVertices, 3));
        const stars = new THREE.Points(starGeometry, starMaterial);
        scene.add(stars);

        // Add lighting
        const ambientLight = new THREE.AmbientLight(0x404040);
        scene.add(ambientLight);

        const sunLight = new THREE.PointLight(0xffffff, 1, 100);
        sunLight.position.set(0, 0, 0);
        scene.add(sunLight);

        camera.position.z = 30;

        // Animation function
        function animate() {
            requestAnimationFrame(animate);

            // Rotate celestial bodies
            sun.rotation.y += 0.001;
            mercury.rotation.y += 0.02;
            venus.rotation.y += 0.015;
            earth.rotation.y += 0.01;
            moon.rotation.y += 0.01;
            mars.rotation.y += 0.008;
            jupiter.rotation.y += 0.004;
            saturn.rotation.y += 0.003;
            uranus.rotation.y += 0.002;
            neptune.rotation.y += 0.001;

            // Orbit planets
            const time = Date.now() * 0.001;
            
            mercury.position.x = Math.cos(time * 0.5) * 4;
            mercury.position.z = Math.sin(time * 0.5) * 4;
            
            venus.position.x = Math.cos(time * 0.4) * 6;
            venus.position.z = Math.sin(time * 0.4) * 6;
            
            earth.position.x = Math.cos(time * 0.3) * 8;
            earth.position.z = Math.sin(time * 0.3) * 8;
            
            // Moon orbits Earth
            moon.position.x = earth.position.x + Math.cos(time * 2) * 0.8;
            moon.position.z = earth.position.z + Math.sin(time * 2) * 0.8;
            
            mars.position.x = Math.cos(time * 0.25) * 10;
            mars.position.z = Math.sin(time * 0.25) * 10;
            
            jupiter.position.x = Math.cos(time * 0.2) * 13;
            jupiter.position.z = Math.sin(time * 0.2) * 13;
            
            saturn.position.x = Math.cos(time * 0.15) * 16;
            saturn.position.z = Math.sin(time * 0.15) * 16;
            
            uranus.position.x = Math.cos(time * 0.1) * 19;
            uranus.position.z = Math.sin(time * 0.1) * 19;
            
            neptune.position.x = Math.cos(time * 0.08) * 22;
            neptune.position.z = Math.sin(time * 0.08) * 22;

            // Rotate the starfield
            stars.rotation.y += 0.0002;

            renderer.render(scene, camera);
        }

        animate();

        // Handle window resizing
        window.addEventListener('resize', () => {
            camera.aspect = window.innerWidth / window.innerHeight;
            camera.updateProjectionMatrix();
            renderer.setSize(window.innerWidth, 1024);
        });

        // Animate the text crawl
        const crawl = document.getElementById('crawl');
        let crawlPosition = 100;
        function animateCrawl() {
            crawlPosition -= 0.02;
            crawl.style.top = crawlPosition + '%';
            if (crawlPosition > -400) {
                requestAnimationFrame(animateCrawl);
            }
        }
        animateCrawl();
    </script>
</body>
</html>
"""

# Add description
st.markdown("""
This visualization shows our solar system with the Sun, all eight planets, and Earth's moon. 
The visualization includes:
- Rotating planets and moons
- Orbital movements
- Detailed information about each celestial body
- A starfield background

Note: The sizes and distances are not to scale to make the visualization more accessible.
""")

# Display the visualization using a custom component
components.html(SOLAR_SYSTEM_HTML, height=1024, scrolling=False)

# Add footer with data sources
st.markdown("""
---
Data sources:
- NASA Solar System Exploration
- European Space Agency (ESA)
- International Astronomical Union (IAU)
""")