CarbonO2 commited on
Commit
49395ac
·
verified ·
1 Parent(s): 48922c4

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. index.html +881 -0
index.html CHANGED
@@ -0,0 +1,881 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Interactive 3D Solar System</title>
7
+ <style>
8
+ @import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Exo+2:wght@300;400;600&display=swap');
9
+
10
+ * {
11
+ margin: 0;
12
+ padding: 0;
13
+ box-sizing: border-box;
14
+ }
15
+
16
+ :root {
17
+ --primary: #00d4ff;
18
+ --secondary: #ff6b35;
19
+ --accent: #a855f7;
20
+ --dark: #0a0a1a;
21
+ --light: #e0e0ff;
22
+ }
23
+
24
+ body {
25
+ font-family: 'Exo 2', sans-serif;
26
+ background: var(--dark);
27
+ color: var(--light);
28
+ overflow: hidden;
29
+ height: 100vh;
30
+ }
31
+
32
+ #canvas-container {
33
+ position: fixed;
34
+ top: 0;
35
+ left: 0;
36
+ width: 100%;
37
+ height: 100%;
38
+ z-index: 1;
39
+ }
40
+
41
+ .header {
42
+ position: fixed;
43
+ top: 0;
44
+ left: 0;
45
+ right: 0;
46
+ z-index: 100;
47
+ padding: 1rem 2rem;
48
+ display: flex;
49
+ justify-content: space-between;
50
+ align-items: center;
51
+ background: linear-gradient(180deg, rgba(10,10,26,0.9) 0%, transparent 100%);
52
+ }
53
+
54
+ .logo {
55
+ font-family: 'Orbitron', sans-serif;
56
+ font-size: 1.5rem;
57
+ font-weight: 900;
58
+ background: linear-gradient(135deg, var(--primary), var(--accent));
59
+ -webkit-background-clip: text;
60
+ -webkit-text-fill-color: transparent;
61
+ background-clip: text;
62
+ text-transform: uppercase;
63
+ letter-spacing: 3px;
64
+ }
65
+
66
+ .logo span {
67
+ font-size: 0.8rem;
68
+ color: var(--light);
69
+ -webkit-text-fill-color: var(--light);
70
+ opacity: 0.7;
71
+ }
72
+
73
+ .header a {
74
+ color: var(--primary);
75
+ text-decoration: none;
76
+ font-size: 0.9rem;
77
+ padding: 0.5rem 1rem;
78
+ border: 1px solid var(--primary);
79
+ border-radius: 20px;
80
+ transition: all 0.3s ease;
81
+ }
82
+
83
+ .header a:hover {
84
+ background: var(--primary);
85
+ color: var(--dark);
86
+ }
87
+
88
+ .controls {
89
+ position: fixed;
90
+ bottom: 2rem;
91
+ left: 2rem;
92
+ z-index: 100;
93
+ display: flex;
94
+ flex-direction: column;
95
+ gap: 1rem;
96
+ }
97
+
98
+ .control-btn {
99
+ background: rgba(0, 212, 255, 0.1);
100
+ border: 1px solid var(--primary);
101
+ color: var(--primary);
102
+ padding: 0.8rem 1.2rem;
103
+ border-radius: 8px;
104
+ cursor: pointer;
105
+ font-family: 'Orbitron', sans-serif;
106
+ font-size: 0.8rem;
107
+ transition: all 0.3s ease;
108
+ backdrop-filter: blur(10px);
109
+ }
110
+
111
+ .control-btn:hover {
112
+ background: var(--primary);
113
+ color: var(--dark);
114
+ transform: translateX(5px);
115
+ }
116
+
117
+ .control-btn.active {
118
+ background: var(--primary);
119
+ color: var(--dark);
120
+ }
121
+
122
+ .planet-info {
123
+ position: fixed;
124
+ top: 50%;
125
+ right: -400px;
126
+ transform: translateY(-50%);
127
+ width: 350px;
128
+ background: rgba(10, 10, 26, 0.95);
129
+ border: 1px solid var(--primary);
130
+ border-radius: 20px;
131
+ padding: 2rem;
132
+ z-index: 100;
133
+ transition: right 0.5s cubic-bezier(0.4, 0, 0.2, 1);
134
+ backdrop-filter: blur(20px);
135
+ box-shadow: 0 0 50px rgba(0, 212, 255, 0.2);
136
+ }
137
+
138
+ .planet-info.visible {
139
+ right: 2rem;
140
+ }
141
+
142
+ .planet-info h2 {
143
+ font-family: 'Orbitron', sans-serif;
144
+ font-size: 2rem;
145
+ margin-bottom: 0.5rem;
146
+ background: linear-gradient(135deg, var(--primary), var(--accent));
147
+ -webkit-background-clip: text;
148
+ -webkit-text-fill-color: transparent;
149
+ background-clip: text;
150
+ }
151
+
152
+ .planet-info .subtitle {
153
+ color: var(--secondary);
154
+ font-size: 0.9rem;
155
+ margin-bottom: 1.5rem;
156
+ text-transform: uppercase;
157
+ letter-spacing: 2px;
158
+ }
159
+
160
+ .planet-info .stats {
161
+ display: grid;
162
+ grid-template-columns: 1fr 1fr;
163
+ gap: 1rem;
164
+ margin-bottom: 1.5rem;
165
+ }
166
+
167
+ .stat {
168
+ background: rgba(0, 212, 255, 0.05);
169
+ padding: 1rem;
170
+ border-radius: 10px;
171
+ text-align: center;
172
+ }
173
+
174
+ .stat-label {
175
+ font-size: 0.7rem;
176
+ text-transform: uppercase;
177
+ letter-spacing: 1px;
178
+ opacity: 0.7;
179
+ margin-bottom: 0.3rem;
180
+ }
181
+
182
+ .stat-value {
183
+ font-family: 'Orbitron', sans-serif;
184
+ font-size: 1rem;
185
+ color: var(--primary);
186
+ }
187
+
188
+ .planet-info .description {
189
+ font-size: 0.9rem;
190
+ line-height: 1.6;
191
+ opacity: 0.8;
192
+ margin-bottom: 1.5rem;
193
+ }
194
+
195
+ .close-btn {
196
+ position: absolute;
197
+ top: 1rem;
198
+ right: 1rem;
199
+ background: none;
200
+ border: none;
201
+ color: var(--light);
202
+ font-size: 1.5rem;
203
+ cursor: pointer;
204
+ opacity: 0.7;
205
+ transition: opacity 0.3s;
206
+ }
207
+
208
+ .close-btn:hover {
209
+ opacity: 1;
210
+ }
211
+
212
+ .legend {
213
+ position: fixed;
214
+ bottom: 2rem;
215
+ right: 2rem;
216
+ z-index: 100;
217
+ background: rgba(10, 10, 26, 0.9);
218
+ border: 1px solid rgba(0, 212, 255, 0.3);
219
+ border-radius: 15px;
220
+ padding: 1.5rem;
221
+ backdrop-filter: blur(10px);
222
+ }
223
+
224
+ .legend h3 {
225
+ font-family: 'Orbitron', sans-serif;
226
+ font-size: 0.9rem;
227
+ margin-bottom: 1rem;
228
+ color: var(--primary);
229
+ }
230
+
231
+ .legend-item {
232
+ display: flex;
233
+ align-items: center;
234
+ gap: 0.5rem;
235
+ margin-bottom: 0.5rem;
236
+ font-size: 0.8rem;
237
+ }
238
+
239
+ .legend-dot {
240
+ width: 12px;
241
+ height: 12px;
242
+ border-radius: 50%;
243
+ }
244
+
245
+ .loading {
246
+ position: fixed;
247
+ top: 0;
248
+ left: 0;
249
+ width: 100%;
250
+ height: 100%;
251
+ background: var(--dark);
252
+ display: flex;
253
+ flex-direction: column;
254
+ justify-content: center;
255
+ align-items: center;
256
+ z-index: 1000;
257
+ transition: opacity 0.5s ease;
258
+ }
259
+
260
+ .loading.hidden {
261
+ opacity: 0;
262
+ pointer-events: none;
263
+ }
264
+
265
+ .loading-spinner {
266
+ width: 80px;
267
+ height: 80px;
268
+ border: 3px solid rgba(0, 212, 255, 0.1);
269
+ border-top-color: var(--primary);
270
+ border-radius: 50%;
271
+ animation: spin 1s linear infinite;
272
+ }
273
+
274
+ @keyframes spin {
275
+ to { transform: rotate(360deg); }
276
+ }
277
+
278
+ .loading-text {
279
+ margin-top: 1.5rem;
280
+ font-family: 'Orbitron', sans-serif;
281
+ color: var(--primary);
282
+ letter-spacing: 3px;
283
+ }
284
+
285
+ .speed-control {
286
+ position: fixed;
287
+ top: 50%;
288
+ left: 2rem;
289
+ transform: translateY(-50%);
290
+ z-index: 100;
291
+ display: flex;
292
+ flex-direction: column;
293
+ gap: 0.5rem;
294
+ }
295
+
296
+ .speed-label {
297
+ font-family: 'Orbitron', sans-serif;
298
+ font-size: 0.7rem;
299
+ color: var(--primary);
300
+ text-transform: uppercase;
301
+ letter-spacing: 2px;
302
+ }
303
+
304
+ .speed-slider {
305
+ -webkit-appearance: none;
306
+ width: 150px;
307
+ height: 6px;
308
+ background: rgba(0, 212, 255, 0.2);
309
+ border-radius: 3px;
310
+ outline: none;
311
+ }
312
+
313
+ .speed-slider::-webkit-slider-thumb {
314
+ -webkit-appearance: none;
315
+ width: 18px;
316
+ height: 18px;
317
+ background: var(--primary);
318
+ border-radius: 50%;
319
+ cursor: pointer;
320
+ box-shadow: 0 0 10px var(--primary);
321
+ }
322
+
323
+ @media (max-width: 768px) {
324
+ .planet-info {
325
+ width: 100%;
326
+ right: -100%;
327
+ top: auto;
328
+ bottom: 0;
329
+ transform: none;
330
+ border-radius: 20px 20px 0 0;
331
+ }
332
+
333
+ .planet-info.visible {
334
+ right: 0;
335
+ }
336
+
337
+ .legend {
338
+ display: none;
339
+ }
340
+
341
+ .controls {
342
+ bottom: 1rem;
343
+ left: 1rem;
344
+ }
345
+
346
+ .speed-control {
347
+ left: 1rem;
348
+ top: auto;
349
+ bottom: 8rem;
350
+ }
351
+ }
352
+ </style>
353
+ </head>
354
+ <body>
355
+ <div class="loading" id="loading">
356
+ <div class="loading-spinner"></div>
357
+ <div class="loading-text">INITIALIZING SOLAR SYSTEM</div>
358
+ </div>
359
+
360
+ <div id="canvas-container"></div>
361
+
362
+ <header class="header">
363
+ <div class="logo">Solar System <span>3D Model</span></div>
364
+ <a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank">Built with anycoder</a>
365
+ </header>
366
+
367
+ <div class="controls">
368
+ <button class="control-btn active" id="toggle-orbits">Toggle Orbits</button>
369
+ <button class="control-btn" id="toggle-labels">Toggle Labels</button>
370
+ <button class="control-btn" id="reset-view">Reset View</button>
371
+ </div>
372
+
373
+ <div class="speed-control">
374
+ <span class="speed-label">Simulation Speed</span>
375
+ <input type="range" class="speed-slider" id="speed-slider" min="0" max="100" value="30">
376
+ </div>
377
+
378
+ <div class="planet-info" id="planet-info">
379
+ <button class="close-btn" onclick="closePlanetInfo()">&times;</button>
380
+ <h2 id="info-name">Earth</h2>
381
+ <div class="subtitle" id="info-type">Terrestrial Planet</div>
382
+ <div class="stats">
383
+ <div class="stat">
384
+ <div class="stat-label">Diameter</div>
385
+ <div class="stat-value" id="info-diameter">12,742 km</div>
386
+ </div>
387
+ <div class="stat">
388
+ <div class="stat-label">Distance from Sun</div>
389
+ <div class="stat-value" id="info-distance">149.6M km</div>
390
+ </div>
391
+ <div class="stat">
392
+ <div class="stat-label">Orbital Period</div>
393
+ <div class="stat-value" id="info-period">365.25 days</div>
394
+ </div>
395
+ <div class="stat">
396
+ <div class="stat-label">Moons</div>
397
+ <div class="stat-value" id="info-moons">1</div>
398
+ </div>
399
+ </div>
400
+ <p class="description" id="info-description">
401
+ The third planet from the Sun and the only astronomical object known to harbor life.
402
+ </p>
403
+ </div>
404
+
405
+ <div class="legend">
406
+ <h3>Planets</h3>
407
+ <div class="legend-item"><div class="legend-dot" style="background: #ffd700;"></div> Sun</div>
408
+ <div class="legend-item"><div class="legend-dot" style="background: #b5651d;"></div> Mercury</div>
409
+ <div class="legend-item"><div class="legend-dot" style="background: #e6c47a;"></div> Venus</div>
410
+ <div class="legend-item"><div class="legend-dot" style="background: #4a90d9;"></div> Earth</div>
411
+ <div class="legend-item"><div class="legend-dot" style="background: #c1440e;"></div> Mars</div>
412
+ <div class="legend-item"><div class="legend-dot" style="background: #d4a574;"></div> Jupiter</div>
413
+ <div class="legend-item"><div class="legend-dot" style="background: #e8c47a;"></div> Saturn</div>
414
+ <div class="legend-item"><div class="legend-dot" style="background: #4fd0e8;"></div> Uranus</div>
415
+ <div class="legend-item"><div class="legend-dot" style="background: #4b70dd;"></div> Neptune</div>
416
+ </div>
417
+
418
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
419
+ <script src="https://cdn.jsdelivr.net/npm/three@0.128.0/examples/js/controls/OrbitControls.js"></script>
420
+ <script>
421
+ // Planet data
422
+ const planetData = {
423
+ mercury: {
424
+ name: 'Mercury',
425
+ type: 'Terrestrial Planet',
426
+ diameter: '4,879 km',
427
+ distance: '57.9M km',
428
+ period: '88 days',
429
+ moons: '0',
430
+ description: 'The smallest planet in our solar system and closest to the Sun. Mercury has a heavily cratered surface similar to Earth\'s Moon.',
431
+ color: 0xb5651d,
432
+ size: 0.4,
433
+ orbitRadius: 10,
434
+ orbitSpeed: 4.15
435
+ },
436
+ venus: {
437
+ name: 'Venus',
438
+ type: 'Terrestrial Planet',
439
+ diameter: '12,104 km',
440
+ distance: '108.2M km',
441
+ period: '225 days',
442
+ moons: '0',
443
+ description: 'The second planet from the Sun and Earth\'s closest neighbor. Venus has a thick, toxic atmosphere filled with carbon dioxide.',
444
+ color: 0xe6c47a,
445
+ size: 0.9,
446
+ orbitRadius: 15,
447
+ orbitSpeed: 1.62
448
+ },
449
+ earth: {
450
+ name: 'Earth',
451
+ type: 'Terrestrial Planet',
452
+ diameter: '12,742 km',
453
+ distance: '149.6M km',
454
+ period: '365.25 days',
455
+ moons: '1',
456
+ description: 'The third planet from the Sun and the only astronomical object known to harbor life. About 71% of its surface is covered with water.',
457
+ color: 0x4a90d9,
458
+ size: 1,
459
+ orbitRadius: 20,
460
+ orbitSpeed: 1
461
+ },
462
+ mars: {
463
+ name: 'Mars',
464
+ type: 'Terrestrial Planet',
465
+ diameter: '6,779 km',
466
+ distance: '227.9M km',
467
+ period: '687 days',
468
+ moons: '2',
469
+ description: 'The fourth planet from the Sun, often called the "Red Planet" due to iron oxide on its surface. Mars has the largest volcano in the solar system.',
470
+ color: 0xc1440e,
471
+ size: 0.5,
472
+ orbitRadius: 25,
473
+ orbitSpeed: 0.53
474
+ },
475
+ jupiter: {
476
+ name: 'Jupiter',
477
+ type: 'Gas Giant',
478
+ diameter: '139,820 km',
479
+ distance: '778.5M km',
480
+ period: '11.86 years',
481
+ moons: '79',
482
+ description: 'The largest planet in our solar system. Jupiter is a gas giant with a mass more than twice that of all the other planets combined.',
483
+ color: 0xd4a574,
484
+ size: 3,
485
+ orbitRadius: 35,
486
+ orbitSpeed: 0.084
487
+ },
488
+ saturn: {
489
+ name: 'Saturn',
490
+ type: 'Gas Giant',
491
+ diameter: '116,460 km',
492
+ distance: '1.4B km',
493
+ period: '29.46 years',
494
+ moons: '82',
495
+ description: 'The sixth planet from the Sun and famous for its beautiful ring system. Saturn is made mostly of hydrogen and helium.',
496
+ color: 0xe8c47a,
497
+ size: 2.5,
498
+ orbitRadius: 45,
499
+ orbitSpeed: 0.034
500
+ },
501
+ uranus: {
502
+ name: 'Uranus',
503
+ type: 'Ice Giant',
504
+ diameter: '50,724 km',
505
+ distance: '2.9B km',
506
+ period: '84 years',
507
+ moons: '27',
508
+ description: 'The seventh planet from the Sun. Uranus has the coldest planetary atmosphere in the solar system and rotates on its side.',
509
+ color: 0x4fd0e8,
510
+ size: 1.8,
511
+ orbitRadius: 55,
512
+ orbitSpeed: 0.012
513
+ },
514
+ neptune: {
515
+ name: 'Neptune',
516
+ type: 'Ice Giant',
517
+ diameter: '49,244 km',
518
+ distance: '4.5B km',
519
+ period: '164.8 years',
520
+ moons: '14',
521
+ description: 'The eighth and farthest known planet from the Sun. Neptune has the strongest winds in the solar system, reaching 2,100 km/h.',
522
+ color: 0x4b70dd,
523
+ size: 1.7,
524
+ orbitRadius: 65,
525
+ orbitSpeed: 0.006
526
+ }
527
+ };
528
+
529
+ // Scene setup
530
+ let scene, camera, renderer, controls;
531
+ let planets = {};
532
+ let orbits = {};
533
+ let labels = {};
534
+ let showOrbits = true;
535
+ let showLabels = false;
536
+ let simulationSpeed = 0.3;
537
+ let sun;
538
+
539
+ function init() {
540
+ // Scene
541
+ scene = new THREE.Scene();
542
+
543
+ // Camera
544
+ camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 0.1, 2000);
545
+ camera.position.set(0, 80, 120);
546
+
547
+ // Renderer
548
+ renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
549
+ renderer.setSize(window.innerWidth, window.innerHeight);
550
+ renderer.setPixelRatio(window.devicePixelRatio);
551
+ renderer.toneMapping = THREE.ACESFilmicToneMapping;
552
+ renderer.toneMappingExposure = 1;
553
+ document.getElementById('canvas-container').appendChild(renderer.domElement);
554
+
555
+ // Controls
556
+ controls = new THREE.OrbitControls(camera, renderer.domElement);
557
+ controls.enableDamping = true;
558
+ controls.dampingFactor = 0.05;
559
+ controls.minDistance = 20;
560
+ controls.maxDistance = 500;
561
+
562
+ // Create starfield
563
+ createStarfield();
564
+
565
+ // Create Sun
566
+ createSun();
567
+
568
+ // Create planets
569
+ createPlanets();
570
+
571
+ // Lighting
572
+ const ambientLight = new THREE.AmbientLight(0x333333);
573
+ scene.add(ambientLight);
574
+
575
+ const sunLight = new THREE.PointLight(0xffffff, 2, 500);
576
+ sunLight.position.set(0, 0, 0);
577
+ scene.add(sunLight);
578
+
579
+ // Event listeners
580
+ window.addEventListener('resize', onWindowResize);
581
+ renderer.domElement.addEventListener('click', onMouseClick);
582
+
583
+ // Control buttons
584
+ document.getElementById('toggle-orbits').addEventListener('click', toggleOrbits);
585
+ document.getElementById('toggle-labels').addEventListener('click', toggleLabels);
586
+ document.getElementById('reset-view').addEventListener('click', resetView);
587
+ document.getElementById('speed-slider').addEventListener('input', (e) => {
588
+ simulationSpeed = e.target.value / 100;
589
+ });
590
+
591
+ // Hide loading
592
+ setTimeout(() => {
593
+ document.getElementById('loading').classList.add('hidden');
594
+ }, 1500);
595
+
596
+ // Start animation
597
+ animate();
598
+ }
599
+
600
+ function createStarfield() {
601
+ const starsGeometry = new THREE.BufferGeometry();
602
+ const starCount = 10000;
603
+ const positions = new Float32Array(starCount * 3);
604
+ const colors = new Float32Array(starCount * 3);
605
+
606
+ for (let i = 0; i < starCount * 3; i += 3) {
607
+ const radius = 500 + Math.random() * 500;
608
+ const theta = Math.random() * Math.PI * 2;
609
+ const phi = Math.acos(2 * Math.random() - 1);
610
+
611
+ positions[i] = radius * Math.sin(phi) * Math.cos(theta);
612
+ positions[i + 1] = radius * Math.sin(phi) * Math.sin(theta);
613
+ positions[i + 2] = radius * Math.cos(phi);
614
+
615
+ const color = new THREE.Color();
616
+ color.setHSL(Math.random() * 0.2 + 0.5, 0.2, Math.random() * 0.5 + 0.5);
617
+ colors[i] = color.r;
618
+ colors[i + 1] = color.g;
619
+ colors[i + 2] = color.b;
620
+ }
621
+
622
+ starsGeometry.setAttribute('position', new THREE.BufferAttribute(positions, 3));
623
+ starsGeometry.setAttribute('color', new THREE.BufferAttribute(colors, 3));
624
+
625
+ const starsMaterial = new THREE.PointsMaterial({
626
+ size: 1.5,
627
+ vertexColors: true,
628
+ transparent: true,
629
+ opacity: 0.8
630
+ });
631
+
632
+ const stars = new THREE.Points(starsGeometry, starsMaterial);
633
+ scene.add(stars);
634
+ }
635
+
636
+ function createSun() {
637
+ // Sun sphere
638
+ const sunGeometry = new THREE.SphereGeometry(5, 64, 64);
639
+ const sunMaterial = new THREE.MeshBasicMaterial({
640
+ color: 0xffdd00,
641
+ emissive: 0xffaa00,
642
+ emissiveIntensity: 1
643
+ });
644
+ sun = new THREE.Mesh(sunGeometry, sunMaterial);
645
+ scene.add(sun);
646
+
647
+ // Sun glow
648
+ const glowGeometry = new THREE.SphereGeometry(6, 32, 32);
649
+ const glowMaterial = new THREE.MeshBasicMaterial({
650
+ color: 0xff8800,
651
+ transparent: true,
652
+ opacity: 0.3,
653
+ side: THREE.BackSide
654
+ });
655
+ const glow = new THREE.Mesh(glowGeometry, glowMaterial);
656
+ scene.add(glow);
657
+
658
+ // Outer glow
659
+ const outerGlowGeometry = new THREE.SphereGeometry(8, 32, 32);
660
+ const outerGlowMaterial = new THREE.MeshBasicMaterial({
661
+ color: 0xff4400,
662
+ transparent: true,
663
+ opacity: 0.1,
664
+ side: THREE.BackSide
665
+ });
666
+ const outerGlow = new THREE.Mesh(outerGlowGeometry, outerGlowMaterial);
667
+ scene.add(outerGlow);
668
+
669
+ // Create label
670
+ createLabel('Sun', new THREE.Vector3(0, 8, 0), 0xffdd00);
671
+ }
672
+
673
+ function createPlanets() {
674
+ const planetNames = Object.keys(planetData);
675
+
676
+ planetNames.forEach((name, index) => {
677
+ const data = planetData[name];
678
+ const angle = (index / planetNames.length) * Math.PI * 2;
679
+
680
+ // Create orbit
681
+ const orbitGeometry = new THREE.RingGeometry(data.orbitRadius - 0.1, data.orbitRadius + 0.1, 128);
682
+ const orbitMaterial = new THREE.MeshBasicMaterial({
683
+ color: 0x00d4ff,
684
+ transparent: true,
685
+ opacity: 0.15,
686
+ side: THREE.DoubleSide
687
+ });
688
+ const orbit = new THREE.Mesh(orbitGeometry, orbitMaterial);
689
+ orbit.rotation.x = Math.PI / 2;
690
+ orbit.userData = { type: 'orbit' };
691
+ orbits[name] = orbit;
692
+ scene.add(orbit);
693
+
694
+ // Create planet group
695
+ const planetGroup = new THREE.Group();
696
+ planetGroup.userData = {
697
+ type: 'planet',
698
+ name: name,
699
+ orbitRadius: data.orbitRadius,
700
+ orbitSpeed: data.orbitSpeed,
701
+ angle: angle
702
+ };
703
+
704
+ // Planet sphere
705
+ const planetGeometry = new THREE.SphereGeometry(data.size, 32, 32);
706
+ const planetMaterial = new THREE.MeshStandardMaterial({
707
+ color: data.color,
708
+ roughness: 0.7,
709
+ metalness: 0.3
710
+ });
711
+ const planet = new THREE.Mesh(planetGeometry, planetMaterial);
712
+ planet.userData = { type: 'planet', name: name };
713
+ planetGroup.add(planet);
714
+
715
+ // Position planet
716
+ const x = Math.cos(angle) * data.orbitRadius;
717
+ const z = Math.sin(angle) * data.orbitRadius;
718
+ planetGroup.position.set(x, 0, z);
719
+
720
+ planets[name] = planetGroup;
721
+ scene.add(planetGroup);
722
+
723
+ // Create label
724
+ const labelY = data.size + 2;
725
+ createLabel(data.name, new THREE.Vector3(x, labelY, z), data.color, name);
726
+ });
727
+
728
+ // Add rings for Saturn
729
+ const saturnRingGeometry = new THREE.RingGeometry(3.5, 5, 64);
730
+ const saturnRingMaterial = new THREE.MeshBasicMaterial({
731
+ color: 0xc9a86c,
732
+ transparent: true,
733
+ opacity: 0.7,
734
+ side: THREE.DoubleSide
735
+ });
736
+ const saturnRing = new THREE.Mesh(saturnRingGeometry, saturnRingMaterial);
737
+ saturnRing.rotation.x = Math.PI / 2.5;
738
+ planets.saturn.add(saturnRing);
739
+ }
740
+
741
+ function createLabel(text, position, color, planetName = null) {
742
+ const canvas = document.createElement('canvas');
743
+ const context = canvas.getContext('2d');
744
+ canvas.width = 256;
745
+ canvas.height = 64;
746
+
747
+ context.fillStyle = 'rgba(0, 0, 0, 0)';
748
+ context.fillRect(0, 0, canvas.width, canvas.height);
749
+
750
+ context.font = 'bold 32px Orbitron';
751
+ context.textAlign = 'center';
752
+ context.fillStyle = '#' + color.toString(16).padStart(6, '0');
753
+ context.fillText(text, 128, 40);
754
+
755
+ const texture = new THREE.CanvasTexture(canvas);
756
+ const spriteMaterial = new THREE.SpriteMaterial({
757
+ map: texture,
758
+ transparent: true,
759
+ opacity: 0.8
760
+ });
761
+ const sprite = new THREE.Sprite(spriteMaterial);
762
+ sprite.position.copy(position);
763
+ sprite.scale.set(15, 4, 1);
764
+
765
+ if (planetName) {
766
+ labels[planetName] = sprite;
767
+ sprite.visible = showLabels;
768
+ }
769
+
770
+ scene.add(sprite);
771
+ }
772
+
773
+ function toggleOrbits() {
774
+ showOrbits = !showOrbits;
775
+ document.getElementById('toggle-orbits').classList.toggle('active');
776
+
777
+ Object.values(orbits).forEach(orbit => {
778
+ orbit.visible = showOrbits;
779
+ });
780
+ }
781
+
782
+ function toggleLabels() {
783
+ showLabels = !showLabels;
784
+ document.getElementById('toggle-labels').classList.toggle('active');
785
+
786
+ Object.values(labels).forEach(label => {
787
+ label.visible = showLabels;
788
+ });
789
+ }
790
+
791
+ function resetView() {
792
+ camera.position.set(0, 80, 120);
793
+ controls.reset();
794
+ }
795
+
796
+ function showPlanetInfo(name) {
797
+ const data = planetData[name];
798
+ if (!data) return;
799
+
800
+ document.getElementById('info-name').textContent = data.name;
801
+ document.getElementById('info-type').textContent = data.type;
802
+ document.getElementById('info-diameter').textContent = data.diameter;
803
+ document.getElementById('info-distance').textContent = data.distance;
804
+ document.getElementById('info-period').textContent = data.period;
805
+ document.getElementById('info-moons').textContent = data.moons;
806
+ document.getElementById('info-description').textContent = data.description;
807
+
808
+ document.getElementById('planet-info').classList.add('visible');
809
+ }
810
+
811
+ function closePlanetInfo() {
812
+ document.getElementById('planet-info').classList.remove('visible');
813
+ }
814
+
815
+ function onMouseClick(event) {
816
+ const mouse = new THREE.Vector2();
817
+ mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
818
+ mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;
819
+
820
+ const raycaster = new THREE.Raycaster();
821
+ raycaster.setFromCamera(mouse, camera);
822
+
823
+ const planetObjects = [];
824
+ Object.values(planets).forEach(group => {
825
+ group.children.forEach(child => {
826
+ if (child.userData.type === 'planet') {
827
+ planetObjects.push(child);
828
+ }
829
+ });
830
+ });
831
+
832
+ const intersects = raycaster.intersectObjects(planetObjects);
833
+
834
+ if (intersects.length > 0) {
835
+ const planetName = intersects[0].object.userData.name;
836
+ showPlanetInfo(planetName);
837
+ }
838
+ }
839
+
840
+ function onWindowResize() {
841
+ camera.aspect = window.innerWidth / window.innerHeight;
842
+ camera.updateProjectionMatrix();
843
+ renderer.setSize(window.innerWidth, window.innerHeight);
844
+ }
845
+
846
+ function animate() {
847
+ requestAnimationFrame(animate);
848
+
849
+ // Rotate Sun
850
+ sun.rotation.y += 0.002;
851
+
852
+ // Animate planets
853
+ Object.values(planets).forEach(planetGroup => {
854
+ const data = planetGroup.userData;
855
+ data.angle += data.orbitSpeed * simulationSpeed * 0.01;
856
+
857
+ const x = Math.cos(data.angle) * data.orbitRadius;
858
+ const z = Math.sin(data.angle) * data.orbitRadius;
859
+
860
+ planetGroup.position.set(x, 0, z);
861
+
862
+ // Rotate planet
863
+ planetGroup.children[0].rotation.y += 0.02;
864
+
865
+ // Update label position
866
+ const planetName = data.name;
867
+ if (labels[planetName]) {
868
+ const planetData = planetData[planetName];
869
+ labels[planetName].position.set(x, planetData.size + 2, z);
870
+ }
871
+ });
872
+
873
+ controls.update();
874
+ renderer.render(scene, camera);
875
+ }
876
+
877
+ // Initialize
878
+ init();
879
+ </script>
880
+ </body>
881
+ </html>