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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Solar System</title>
|
7 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
|
8 |
+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/examples/js/controls/OrbitControls.min.js"></script>
|
9 |
+
<style>
|
10 |
+
* {
|
11 |
+
margin: 0;
|
12 |
+
padding: 0;
|
13 |
+
box-sizing: border-box;
|
14 |
+
}
|
15 |
+
|
16 |
+
body {
|
17 |
+
overflow: hidden;
|
18 |
+
background: #000;
|
19 |
+
font-family: 'Arial', sans-serif;
|
20 |
+
}
|
21 |
+
|
22 |
+
#canvas-container {
|
23 |
+
position: fixed;
|
24 |
+
top: 0;
|
25 |
+
left: 0;
|
26 |
+
width: 100%;
|
27 |
+
height: 100%;
|
28 |
+
}
|
29 |
+
|
30 |
+
.controls {
|
31 |
+
position: absolute;
|
32 |
+
bottom: 30px;
|
33 |
+
left: 50%;
|
34 |
+
transform: translateX(-50%);
|
35 |
+
display: flex;
|
36 |
+
gap: 20px;
|
37 |
+
background: rgba(0, 0, 0, 0.7);
|
38 |
+
padding: 15px 25px;
|
39 |
+
border-radius: 50px;
|
40 |
+
backdrop-filter: blur(10px);
|
41 |
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
42 |
+
}
|
43 |
+
|
44 |
+
.control-btn {
|
45 |
+
background: linear-gradient(45deg, #4a00e0, #8e2de2);
|
46 |
+
border: none;
|
47 |
+
color: white;
|
48 |
+
width: 50px;
|
49 |
+
height: 50px;
|
50 |
+
border-radius: 50%;
|
51 |
+
cursor: pointer;
|
52 |
+
font-size: 18px;
|
53 |
+
display: flex;
|
54 |
+
align-items: center;
|
55 |
+
justify-content: center;
|
56 |
+
transition: all 0.3s ease;
|
57 |
+
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
|
58 |
+
}
|
59 |
+
|
60 |
+
.control-btn:hover {
|
61 |
+
transform: scale(1.1);
|
62 |
+
box-shadow: 0 8px 25px rgba(142, 45, 226, 0.4);
|
63 |
+
}
|
64 |
+
|
65 |
+
.speed-control {
|
66 |
+
display: flex;
|
67 |
+
align-items: center;
|
68 |
+
gap: 15px;
|
69 |
+
color: white;
|
70 |
+
}
|
71 |
+
|
72 |
+
.speed-slider {
|
73 |
+
width: 200px;
|
74 |
+
height: 6px;
|
75 |
+
-webkit-appearance: none;
|
76 |
+
background: linear-gradient(to right, #4a00e0, #8e2de2);
|
77 |
+
border-radius: 3px;
|
78 |
+
outline: none;
|
79 |
+
}
|
80 |
+
|
81 |
+
.speed-slider::-webkit-slider-thumb {
|
82 |
+
-webkit-appearance: none;
|
83 |
+
width: 20px;
|
84 |
+
height: 20px;
|
85 |
+
border-radius: 50%;
|
86 |
+
background: white;
|
87 |
+
cursor: pointer;
|
88 |
+
box-shadow: 0 0 10px rgba(142, 45, 226, 0.8);
|
89 |
+
}
|
90 |
+
|
91 |
+
.info-panel {
|
92 |
+
position: absolute;
|
93 |
+
top: 30px;
|
94 |
+
right: 30px;
|
95 |
+
width: 320px;
|
96 |
+
background: rgba(0, 0, 0, 0.85);
|
97 |
+
backdrop-filter: blur(20px);
|
98 |
+
border-radius: 20px;
|
99 |
+
padding: 25px;
|
100 |
+
color: white;
|
101 |
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
102 |
+
box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
|
103 |
+
transform: translateX(120%);
|
104 |
+
transition: transform 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
|
105 |
+
z-index: 100;
|
106 |
+
}
|
107 |
+
|
108 |
+
.info-panel.visible {
|
109 |
+
transform: translateX(0);
|
110 |
+
}
|
111 |
+
|
112 |
+
.info-header {
|
113 |
+
display: flex;
|
114 |
+
align-items: center;
|
115 |
+
margin-bottom: 20px;
|
116 |
+
}
|
117 |
+
|
118 |
+
.planet-icon {
|
119 |
+
width: 50px;
|
120 |
+
height: 50px;
|
121 |
+
border-radius: 50%;
|
122 |
+
margin-right: 15px;
|
123 |
+
background-size: cover;
|
124 |
+
}
|
125 |
+
|
126 |
+
.planet-name {
|
127 |
+
font-size: 24px;
|
128 |
+
font-weight: bold;
|
129 |
+
background: linear-gradient(45deg, #4a00e0, #8e2de2);
|
130 |
+
-webkit-background-clip: text;
|
131 |
+
-webkit-text-fill-color: transparent;
|
132 |
+
}
|
133 |
+
|
134 |
+
.info-content {
|
135 |
+
line-height: 1.6;
|
136 |
+
}
|
137 |
+
|
138 |
+
.info-item {
|
139 |
+
margin-bottom: 15px;
|
140 |
+
padding-bottom: 15px;
|
141 |
+
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
142 |
+
}
|
143 |
+
|
144 |
+
.info-label {
|
145 |
+
color: #8e2de2;
|
146 |
+
font-weight: bold;
|
147 |
+
margin-bottom: 5px;
|
148 |
+
}
|
149 |
+
|
150 |
+
.info-value {
|
151 |
+
color: white;
|
152 |
+
font-size: 16px;
|
153 |
+
}
|
154 |
+
|
155 |
+
.info-description {
|
156 |
+
color: #ccc;
|
157 |
+
font-size: 14px;
|
158 |
+
line-height: 1.5;
|
159 |
+
}
|
160 |
+
|
161 |
+
.close-btn {
|
162 |
+
position: absolute;
|
163 |
+
top: 15px;
|
164 |
+
right: 15px;
|
165 |
+
background: rgba(255, 255, 255, 0.1);
|
166 |
+
border: none;
|
167 |
+
color: white;
|
168 |
+
width: 30px;
|
169 |
+
height: 30px;
|
170 |
+
border-radius: 50%;
|
171 |
+
cursor: pointer;
|
172 |
+
font-size: 16px;
|
173 |
+
}
|
174 |
+
|
175 |
+
.title {
|
176 |
+
position: absolute;
|
177 |
+
top: 30px;
|
178 |
+
left: 30px;
|
179 |
+
color: white;
|
180 |
+
font-size: 28px;
|
181 |
+
font-weight: bold;
|
182 |
+
text-shadow: 0 0 20px rgba(142, 45, 226, 0.8);
|
183 |
+
}
|
184 |
+
|
185 |
+
.title span {
|
186 |
+
background: linear-gradient(45deg, #4a00e0, #8e2de2);
|
187 |
+
-webkit-background-clip: text;
|
188 |
+
-webkit-text-fill-color: transparent;
|
189 |
+
}
|
190 |
+
|
191 |
+
@media (max-width: 768px) {
|
192 |
+
.controls {
|
193 |
+
flex-direction: column;
|
194 |
+
border-radius: 20px;
|
195 |
+
padding: 15px;
|
196 |
+
}
|
197 |
+
|
198 |
+
.info-panel {
|
199 |
+
width: calc(100% - 40px);
|
200 |
+
right: 20px;
|
201 |
+
top: 20px;
|
202 |
+
}
|
203 |
+
|
204 |
+
.title {
|
205 |
+
font-size: 20px;
|
206 |
+
top: 15px;
|
207 |
+
left: 15px;
|
208 |
+
}
|
209 |
+
}
|
210 |
+
</style>
|
211 |
+
</head>
|
212 |
+
<body>
|
213 |
+
<div id="canvas-container"></div>
|
214 |
+
|
215 |
+
<div class="title">Interactive <span>Solar System</span></div>
|
216 |
+
|
217 |
+
<div class="controls">
|
218 |
+
<button id="playPauseBtn" class="control-btn">鈴革笍</button>
|
219 |
+
<div class="speed-control">
|
220 |
+
<span>馃悽</span>
|
221 |
+
<input type="range" id="speedSlider" class="speed-slider" min="0" max="2" step="0.1" value="1">
|
222 |
+
<span>馃惏</span>
|
223 |
+
</div>
|
224 |
+
</div>
|
225 |
+
|
226 |
+
<div id="infoPanel" class="info-panel">
|
227 |
+
<button class="close-btn">脳</button>
|
228 |
+
<div class="info-header">
|
229 |
+
<div class="planet-icon" id="planetIcon"></div>
|
230 |
+
<div class="planet-name" id="planetName">Planet Name</div>
|
231 |
+
</div>
|
232 |
+
<div class="info-content">
|
233 |
+
<div class="info-item">
|
234 |
+
<div class="info-label">Distance from Sun</div>
|
235 |
+
<div class="info-value" id="distance">0 million km</div>
|
236 |
+
</div>
|
237 |
+
<div class="info-item">
|
238 |
+
<div class="info-label">Orbital Period</div>
|
239 |
+
<div class="info-value" id="period">0 Earth days</div>
|
240 |
+
</div>
|
241 |
+
<div class="info-item">
|
242 |
+
<div class="info-label">Description</div>
|
243 |
+
<div class="info-description" id="description">Planet description...</div>
|
244 |
+
</div>
|
245 |
+
</div>
|
246 |
+
</div>
|
247 |
+
|
248 |
+
<script>
|
249 |
+
// Planet data with realistic information
|
250 |
+
const planetData = [
|
251 |
+
{
|
252 |
+
name: "Mercury",
|
253 |
+
radius: 1.2,
|
254 |
+
distance: 20,
|
255 |
+
speed: 8.0,
|
256 |
+
rotationSpeed: 0.017,
|
257 |
+
color: 0x8a8a8a,
|
258 |
+
description: "The smallest planet in our solar system and closest to the Sun. Mercury has no atmosphere and experiences extreme temperature variations.",
|
259 |
+
distanceFromSun: 57.9,
|
260 |
+
orbitalPeriod: 88
|
261 |
+
},
|
262 |
+
{
|
263 |
+
name: "Venus",
|
264 |
+
radius: 3.0,
|
265 |
+
distance: 30,
|
266 |
+
speed: 6.5,
|
267 |
+
rotationSpeed: 0.004,
|
268 |
+
color: 0xe39e1c,
|
269 |
+
description: "The hottest planet in our solar system with a thick toxic atmosphere. Venus is often called Earth's sister planet due to its similar size.",
|
270 |
+
distanceFromSun: 108.2,
|
271 |
+
orbitalPeriod: 225
|
272 |
+
},
|
273 |
+
{
|
274 |
+
name: "Earth",
|
275 |
+
radius: 3.1,
|
276 |
+
distance: 40,
|
277 |
+
speed: 5.5,
|
278 |
+
rotationSpeed: 0.01,
|
279 |
+
color: 0x1f77b4,
|
280 |
+
description: "Our home planet and the only known place in the universe with life. Earth has a diverse biosphere and a protective atmosphere.",
|
281 |
+
distanceFromSun: 149.6,
|
282 |
+
orbitalPeriod: 365
|
283 |
+
},
|
284 |
+
{
|
285 |
+
name: "Mars",
|
286 |
+
radius: 1.7,
|
287 |
+
distance: 50,
|
288 |
+
speed: 4.5,
|
289 |
+
rotationSpeed: 0.0097,
|
290 |
+
color: 0xff7f0e,
|
291 |
+
description: "The Red Planet known for its iron oxide surface. Mars has the largest volcano and canyon in the solar system.",
|
292 |
+
distanceFromSun: 227.9,
|
293 |
+
orbitalPeriod: 687
|
294 |
+
},
|
295 |
+
{
|
296 |
+
name: "Jupiter",
|
297 |
+
radius: 10.0,
|
298 |
+
distance: 70,
|
299 |
+
speed: 2.5,
|
300 |
+
rotationSpeed: 0.024,
|
301 |
+
color: 0xd8ca9d,
|
302 |
+
description: "The largest planet in our solar system, a gas giant with a prominent Great Red Spot storm. Jupiter has at least 79 moons.",
|
303 |
+
distanceFromSun: 778.5,
|
304 |
+
orbitalPeriod: 4333
|
305 |
+
},
|
306 |
+
{
|
307 |
+
name: "Saturn",
|
308 |
+
radius: 8.4,
|
309 |
+
distance: 90,
|
310 |
+
speed: 2.0,
|
311 |
+
rotationSpeed: 0.019,
|
312 |
+
color: 0xf0e0a0,
|
313 |
+
description: "Famous for its spectacular ring system made of ice and rock particles. Saturn is the least dense planet in our solar system.",
|
314 |
+
distanceFromSun: 1432.0,
|
315 |
+
orbitalPeriod: 10759
|
316 |
+
},
|
317 |
+
{
|
318 |
+
name: "Uranus",
|
319 |
+
radius: 3.6,
|
320 |
+
distance: 110,
|
321 |
+
speed: 1.5,
|
322 |
+
rotationSpeed: 0.015,
|
323 |
+
color: 0xa0d0e0,
|
324 |
+
description: "An ice giant that rotates on its side, possibly due to an ancient collision. Uranus has a blue-green color due to methane in its atmosphere.",
|
325 |
+
distanceFromSun: 2867.0,
|
326 |
+
orbitalPeriod: 30687
|
327 |
+
},
|
328 |
+
{
|
329 |
+
name: "Neptune",
|
330 |
+
radius: 3.5,
|
331 |
+
distance: 130,
|
332 |
+
speed: 1.2,
|
333 |
+
rotationSpeed: 0.018,
|
334 |
+
color: 0x4f79da,
|
335 |
+
description: "The windiest planet with speeds up to 2,100 km/h. Neptune was the first planet discovered through mathematical predictions.",
|
336 |
+
distanceFromSun: 4515.0,
|
337 |
+
orbitalPeriod: 60190
|
338 |
+
}
|
339 |
+
];
|
340 |
+
|
341 |
+
// Initialize Three.js
|
342 |
+
const scene = new THREE.Scene();
|
343 |
+
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 3000);
|
344 |
+
const renderer = new THREE.WebGLRenderer({ antialias: true });
|
345 |
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
346 |
+
renderer.setPixelRatio(window.devicePixelRatio);
|
347 |
+
document.getElementById('canvas-container').appendChild(renderer.domElement);
|
348 |
+
|
349 |
+
// Add orbit controls
|
350 |
+
const controls = new THREE.OrbitControls(camera, renderer.domElement);
|
351 |
+
controls.enableDamping = true;
|
352 |
+
controls.dampingFactor = 0.05;
|
353 |
+
|
354 |
+
// Create stars background
|
355 |
+
const starsGeometry = new THREE.BufferGeometry();
|
356 |
+
const starsMaterial = new THREE.PointsMaterial({ color: 0xffffff, size: 1 });
|
357 |
+
const starsVertices = [];
|
358 |
+
|
359 |
+
for (let i = 0; i < 10000; i++) {
|
360 |
+
const x = (Math.random() - 0.5) * 2000;
|
361 |
+
const y = (Math.random() - 0.5) * 2000;
|
362 |
+
const z = (Math.random() - 0.5) * 2000;
|
363 |
+
starsVertices.push(x, y, z);
|
364 |
+
}
|
365 |
+
|
366 |
+
starsGeometry.setAttribute('position', new THREE.Float32BufferAttribute(starsVertices, 3));
|
367 |
+
const starField = new THREE.Points(starsGeometry, starsMaterial);
|
368 |
+
scene.add(starField);
|
369 |
+
|
370 |
+
// Create the Sun
|
371 |
+
const sunGeometry = new THREE.SphereGeometry(10, 64, 64);
|
372 |
+
const sunMaterial = new THREE.MeshBasicMaterial({
|
373 |
+
color: 0xffff00,
|
374 |
+
emissive: 0xffff33,
|
375 |
+
emissiveIntensity: 1
|
376 |
+
});
|
377 |
+
const sun = new THREE.Mesh(sunGeometry, sunMaterial);
|
378 |
+
scene.add(sun);
|
379 |
+
|
380 |
+
// Add sun glow effect
|
381 |
+
const sunGlowGeometry = new THREE.SphereGeometry(12, 32, 32);
|
382 |
+
const sunGlowMaterial = new THREE.MeshBasicMaterial({
|
383 |
+
color: 0xffff00,
|
384 |
+
transparent: true,
|
385 |
+
opacity: 0.3
|
386 |
+
});
|
387 |
+
const sunGlow = new THREE.Mesh(sunGlowGeometry, sunGlowMaterial);
|
388 |
+
scene.add(sunGlow);
|
389 |
+
|
390 |
+
// Create planets
|
391 |
+
const planets = [];
|
392 |
+
const orbits = [];
|
393 |
+
|
394 |
+
planetData.forEach((planet, index) => {
|
395 |
+
// Create planet
|
396 |
+
const geometry = new THREE.SphereGeometry(planet.radius, 32, 32);
|
397 |
+
const material = new THREE.MeshLambertMaterial({ color: planet.color });
|
398 |
+
const mesh = new THREE.Mesh(geometry, material);
|
399 |
+
|
400 |
+
// Position planet
|
401 |
+
const distance = planet.distance; // Scale down for visualization
|
402 |
+
mesh.position.x = distance;
|
403 |
+
|
404 |
+
// Create orbit path
|
405 |
+
const orbitGeometry = new THREE.BufferGeometry();
|
406 |
+
const orbitPoints = [];
|
407 |
+
const orbitSegments = 128;
|
408 |
+
|
409 |
+
for (let i = 0; i <= orbitSegments; i++) {
|
410 |
+
const theta = (i / orbitSegments) * Math.PI * 2;
|
411 |
+
orbitPoints.push(
|
412 |
+
Math.cos(theta) * distance,
|
413 |
+
0,
|
414 |
+
Math.sin(theta) * distance
|
415 |
+
);
|
416 |
+
}
|
417 |
+
|
418 |
+
orbitGeometry.setAttribute('position', new THREE.Float32BufferAttribute(orbitPoints, 3));
|
419 |
+
const orbitMaterial = new THREE.LineBasicMaterial({
|
420 |
+
color: 0xffffff,
|
421 |
+
transparent: true,
|
422 |
+
opacity: 0.6
|
423 |
+
});
|
424 |
+
const orbit = new THREE.Line(orbitGeometry, orbitMaterial);
|
425 |
+
scene.add(orbit);
|
426 |
+
orbits.push(orbit);
|
427 |
+
|
428 |
+
// Add to scene
|
429 |
+
scene.add(mesh);
|
430 |
+
|
431 |
+
// Store planet data
|
432 |
+
planets.push({
|
433 |
+
mesh: mesh,
|
434 |
+
data: planet,
|
435 |
+
angle: Math.random() * Math.PI * 2,
|
436 |
+
distance: distance,
|
437 |
+
speed: planet.speed * 0.05,
|
438 |
+
rotationSpeed: planet.rotationSpeed
|
439 |
+
});
|
440 |
+
|
441 |
+
// Add rings to Saturn
|
442 |
+
if (planet.name === "Saturn") {
|
443 |
+
const ringGeometry = new THREE.RingGeometry(planet.radius * 1.5, planet.radius * 2.5, 64);
|
444 |
+
const ringMaterial = new THREE.MeshBasicMaterial({
|
445 |
+
color: 0xf0e0a0,
|
446 |
+
side: THREE.DoubleSide,
|
447 |
+
transparent: true,
|
448 |
+
opacity: 0.8
|
449 |
+
});
|
450 |
+
const ring = new THREE.Mesh(ringGeometry, ringMaterial);
|
451 |
+
ring.rotation.x = Math.PI / 3;
|
452 |
+
mesh.add(ring);
|
453 |
+
}
|
454 |
+
});
|
455 |
+
|
456 |
+
// Add ambient light
|
457 |
+
const ambientLight = new THREE.AmbientLight(0x333333);
|
458 |
+
scene.add(ambientLight);
|
459 |
+
|
460 |
+
// Add directional light (sunlight)
|
461 |
+
const sunLight = new THREE.PointLight(0xffffff, 1.5, 3000);
|
462 |
+
sunLight.position.set(0, 0, 0);
|
463 |
+
scene.add(sunLight);
|
464 |
+
|
465 |
+
// Position camera
|
466 |
+
camera.position.set(0, 100, 300);
|
467 |
+
controls.update();
|
468 |
+
|
469 |
+
// UI Controls
|
470 |
+
let isPlaying = true;
|
471 |
+
let speed = 1;
|
472 |
+
|
473 |
+
const playPauseBtn = document.getElementById('playPauseBtn');
|
474 |
+
const speedSlider = document.getElementById('speedSlider');
|
475 |
+
const infoPanel = document.getElementById('infoPanel');
|
476 |
+
const closeBtn = document.querySelector('.close-btn');
|
477 |
+
|
478 |
+
playPauseBtn.addEventListener('click', () => {
|
479 |
+
isPlaying = !isPlaying;
|
480 |
+
playPauseBtn.textContent = isPlaying ? '鈴革笍' : '鈻讹笍';
|
481 |
+
});
|
482 |
+
|
483 |
+
speedSlider.addEventListener('input', (e) => {
|
484 |
+
speed = parseFloat(e.target.value);
|
485 |
+
});
|
486 |
+
|
487 |
+
closeBtn.addEventListener('click', () => {
|
488 |
+
infoPanel.classList.remove('visible');
|
489 |
+
});
|
490 |
+
|
491 |
+
// Raycaster for planet selection
|
492 |
+
const raycaster = new THREE.Raycaster();
|
493 |
+
const mouse = new THREE.Vector2();
|
494 |
+
|
495 |
+
function onMouseClick(event) {
|
496 |
+
// Calculate mouse position in normalized device coordinates
|
497 |
+
mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
|
498 |
+
mouse.y = - (event.clientY / window.innerHeight) * 2 + 1;
|
499 |
+
|
500 |
+
// Update the picking ray with the camera and mouse position
|
501 |
+
raycaster.setFromCamera(mouse, camera);
|
502 |
+
|
503 |
+
// Calculate objects intersecting the picking ray
|
504 |
+
const intersects = raycaster.intersectObjects(planets.map(p => p.mesh));
|
505 |
+
|
506 |
+
if (intersects.length > 0) {
|
507 |
+
const planetMesh = intersects[0].object;
|
508 |
+
const planet = planets.find(p => p.mesh === planetMesh);
|
509 |
+
|
510 |
+
if (planet) {
|
511 |
+
showPlanetInfo(planet.data);
|
512 |
+
}
|
513 |
+
}
|
514 |
+
}
|
515 |
+
|
516 |
+
function showPlanetInfo(planet) {
|
517 |
+
document.getElementById('planetName').textContent = planet.name;
|
518 |
+
document.getElementById('distance').textContent = `${planet.distanceFromSun} million km`;
|
519 |
+
document.getElementById('period').textContent = `${planet.orbitalPeriod} Earth days`;
|
520 |
+
document.getElementById('description').textContent = planet.description;
|
521 |
+
|
522 |
+
// Set planet icon color
|
523 |
+
const icon = document.getElementById('planetIcon');
|
524 |
+
icon.style.backgroundColor = `#${planet.color.toString(16).padStart(6, '0')}`;
|
525 |
+
|
526 |
+
infoPanel.classList.add('visible');
|
527 |
+
}
|
528 |
+
|
529 |
+
window.addEventListener('click', onMouseClick);
|
530 |
+
|
531 |
+
// Handle window resize
|
532 |
+
window.addEventListener('resize', () => {
|
533 |
+
camera.aspect = window.innerWidth / window.innerHeight;
|
534 |
+
camera.updateProjectionMatrix();
|
535 |
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
536 |
+
});
|
537 |
+
|
538 |
+
// Animation loop
|
539 |
+
function animate() {
|
540 |
+
requestAnimationFrame(animate);
|
541 |
+
|
542 |
+
if (isPlaying) {
|
543 |
+
// Rotate sun
|
544 |
+
sun.rotation.y += 0.002 * speed;
|
545 |
+
sunGlow.rotation.y += 0.002 * speed;
|
546 |
+
|
547 |
+
// Update planets
|
548 |
+
planets.forEach(planet => {
|
549 |
+
// Orbit around sun
|
550 |
+
planet.angle += planet.speed * speed;
|
551 |
+
planet.mesh.position.x = Math.cos(planet.angle) * planet.distance;
|
552 |
+
planet.mesh.position.z = Math.sin(planet.angle) * planet.distance;
|
553 |
+
|
554 |
+
// Rotate on axis
|
555 |
+
planet.mesh.rotation.y += planet.rotationSpeed * speed;
|
556 |
+
});
|
557 |
+
}
|
558 |
+
|
559 |
+
controls.update();
|
560 |
+
renderer.render(scene, camera);
|
561 |
+
}
|
562 |
+
|
563 |
+
animate();
|
564 |
+
</script>
|
565 |
+
</body>
|
566 |
+
</html>
|