Spaces:
Running
Running
get real planets position ,time laps s,h,DD,MM,YY
Browse files- index.html +21 -6
- script.js +150 -58
- style.css +26 -3
index.html
CHANGED
|
@@ -108,6 +108,10 @@
|
|
| 108 |
<div class="text-sm text-purple-300">
|
| 109 |
<span id="dateDisplay"></span>
|
| 110 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
<div class="text-sm text-green-400 flex items-center gap-2">
|
| 112 |
<i data-feather="map-pin" class="w-4 h-4"></i>
|
| 113 |
<span id="locationDisplay">Loading location...</span>
|
|
@@ -159,11 +163,11 @@
|
|
| 159 |
<div class="fixed bottom-4 left-4 glass-effect p-4 rounded-xl">
|
| 160 |
<div class="space-y-4">
|
| 161 |
<div class="flex items-center gap-4">
|
| 162 |
-
<label class="text-sm text-gray-300">Speed</label>
|
| 163 |
-
<input type="range" id="speedSlider" min="0" max="
|
| 164 |
<span id="speedValue" class="speed-indicator font-bold">1.0x</span>
|
| 165 |
</div>
|
| 166 |
-
|
| 167 |
<label class="text-sm text-gray-300">Zoom</label>
|
| 168 |
<input type="range" id="zoomSlider" min="0.5" max="3" value="1" step="0.1" class="w-32">
|
| 169 |
<span id="zoomValue" class="text-purple-300 font-bold">1.0x</span>
|
|
@@ -178,7 +182,15 @@
|
|
| 178 |
<span>Reset</span>
|
| 179 |
</button>
|
| 180 |
</div>
|
| 181 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
</div>
|
| 183 |
|
| 184 |
<!-- Legend -->
|
|
@@ -223,7 +235,6 @@
|
|
| 223 |
</div>
|
| 224 |
</div>
|
| 225 |
</div>
|
| 226 |
-
|
| 227 |
<!-- Stats Display -->
|
| 228 |
<div class="fixed top-24 right-4 glass-effect p-4 rounded-xl">
|
| 229 |
<h3 class="text-sm font-bold mb-2 text-purple-300">Statistics</h3>
|
|
@@ -240,9 +251,13 @@
|
|
| 240 |
<span class="text-gray-400">Years Elapsed:</span>
|
| 241 |
<span id="yearsDisplay">0</span>
|
| 242 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 243 |
</div>
|
| 244 |
</div>
|
| 245 |
-
|
| 246 |
|
| 247 |
<script src="script.js"></script>
|
| 248 |
<script>feather.replace();</script>
|
|
|
|
| 108 |
<div class="text-sm text-purple-300">
|
| 109 |
<span id="dateDisplay"></span>
|
| 110 |
</div>
|
| 111 |
+
<div class="text-sm text-yellow-400 flex items-center gap-2">
|
| 112 |
+
<i data-feather="clock" class="w-4 h-4"></i>
|
| 113 |
+
<span id="timeDisplay">Time Lapse: 0D</span>
|
| 114 |
+
</div>
|
| 115 |
<div class="text-sm text-green-400 flex items-center gap-2">
|
| 116 |
<i data-feather="map-pin" class="w-4 h-4"></i>
|
| 117 |
<span id="locationDisplay">Loading location...</span>
|
|
|
|
| 163 |
<div class="fixed bottom-4 left-4 glass-effect p-4 rounded-xl">
|
| 164 |
<div class="space-y-4">
|
| 165 |
<div class="flex items-center gap-4">
|
| 166 |
+
<label class="text-sm text-gray-300">Time Speed</label>
|
| 167 |
+
<input type="range" id="speedSlider" min="0" max="100" value="1" step="0.1" class="w-32">
|
| 168 |
<span id="speedValue" class="speed-indicator font-bold">1.0x</span>
|
| 169 |
</div>
|
| 170 |
+
<div class="flex items-center gap-4">
|
| 171 |
<label class="text-sm text-gray-300">Zoom</label>
|
| 172 |
<input type="range" id="zoomSlider" min="0.5" max="3" value="1" step="0.1" class="w-32">
|
| 173 |
<span id="zoomValue" class="text-purple-300 font-bold">1.0x</span>
|
|
|
|
| 182 |
<span>Reset</span>
|
| 183 |
</button>
|
| 184 |
</div>
|
| 185 |
+
<div class="time-controls">
|
| 186 |
+
<span class="text-xs text-gray-400">Quick jump:</span>
|
| 187 |
+
<div class="time-unit" data-time="1">1D</div>
|
| 188 |
+
<div class="time-unit" data-time="7">1W</div>
|
| 189 |
+
<div class="time-unit" data-time="30">1M</div>
|
| 190 |
+
<div class="time-unit" data-time="365">1Y</div>
|
| 191 |
+
<div class="time-unit" data-time="3650">10Y</div>
|
| 192 |
+
</div>
|
| 193 |
+
</div>
|
| 194 |
</div>
|
| 195 |
|
| 196 |
<!-- Legend -->
|
|
|
|
| 235 |
</div>
|
| 236 |
</div>
|
| 237 |
</div>
|
|
|
|
| 238 |
<!-- Stats Display -->
|
| 239 |
<div class="fixed top-24 right-4 glass-effect p-4 rounded-xl">
|
| 240 |
<h3 class="text-sm font-bold mb-2 text-purple-300">Statistics</h3>
|
|
|
|
| 251 |
<span class="text-gray-400">Years Elapsed:</span>
|
| 252 |
<span id="yearsDisplay">0</span>
|
| 253 |
</div>
|
| 254 |
+
<div class="flex justify-between gap-4">
|
| 255 |
+
<span class="text-gray-400">Current Date:</span>
|
| 256 |
+
<span id="currentDateDisplay" class="text-blue-300"></span>
|
| 257 |
+
</div>
|
| 258 |
</div>
|
| 259 |
</div>
|
| 260 |
+
</div>
|
| 261 |
|
| 262 |
<script src="script.js"></script>
|
| 263 |
<script>feather.replace();</script>
|
script.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
// Solar System Simulation
|
| 2 |
class SolarSystem {
|
| 3 |
constructor() {
|
|
@@ -11,7 +12,9 @@ class SolarSystem {
|
|
| 11 |
this.time = 0;
|
| 12 |
this.fps = 60;
|
| 13 |
this.lastFrameTime = performance.now();
|
| 14 |
-
this.
|
|
|
|
|
|
|
| 15 |
|
| 16 |
this.planets = [
|
| 17 |
{
|
|
@@ -19,147 +22,163 @@ class SolarSystem {
|
|
| 19 |
type: 'Terrestrial',
|
| 20 |
radius: 4,
|
| 21 |
distance: 60,
|
| 22 |
-
|
| 23 |
color: '#9CA3AF',
|
| 24 |
info: {
|
| 25 |
diameter: '4,879 km',
|
| 26 |
moons: 0,
|
| 27 |
-
orbitalPeriod: '
|
| 28 |
-
}
|
|
|
|
|
|
|
| 29 |
},
|
| 30 |
{
|
| 31 |
name: 'Venus',
|
| 32 |
type: 'Terrestrial',
|
| 33 |
radius: 7,
|
| 34 |
distance: 85,
|
| 35 |
-
|
| 36 |
color: '#FEF3C7',
|
| 37 |
info: {
|
| 38 |
diameter: '12,104 km',
|
| 39 |
moons: 0,
|
| 40 |
-
orbitalPeriod: '
|
| 41 |
-
}
|
|
|
|
|
|
|
| 42 |
},
|
| 43 |
{
|
| 44 |
name: 'Earth',
|
| 45 |
type: 'Terrestrial',
|
| 46 |
radius: 8,
|
| 47 |
distance: 110,
|
| 48 |
-
|
| 49 |
color: '#3B82F6',
|
| 50 |
info: {
|
| 51 |
diameter: '12,742 km',
|
| 52 |
moons: 1,
|
| 53 |
-
orbitalPeriod: '365 days'
|
| 54 |
},
|
| 55 |
moons: [{
|
| 56 |
radius: 2,
|
| 57 |
distance: 15,
|
| 58 |
-
|
| 59 |
color: '#E5E7EB'
|
| 60 |
-
}]
|
|
|
|
|
|
|
| 61 |
},
|
| 62 |
{
|
| 63 |
name: 'Mars',
|
| 64 |
type: 'Terrestrial',
|
| 65 |
radius: 5,
|
| 66 |
distance: 140,
|
| 67 |
-
|
| 68 |
color: '#EF4444',
|
| 69 |
info: {
|
| 70 |
diameter: '6,779 km',
|
| 71 |
moons: 2,
|
| 72 |
-
orbitalPeriod: '
|
| 73 |
},
|
| 74 |
moons: [
|
| 75 |
{
|
| 76 |
radius: 1,
|
| 77 |
distance: 10,
|
| 78 |
-
|
| 79 |
color: '#F3F4F6'
|
| 80 |
},
|
| 81 |
{
|
| 82 |
radius: 1,
|
| 83 |
distance: 14,
|
| 84 |
-
|
| 85 |
color: '#D1D5DB'
|
| 86 |
}
|
| 87 |
-
]
|
|
|
|
|
|
|
| 88 |
},
|
| 89 |
{
|
| 90 |
name: 'Jupiter',
|
| 91 |
type: 'Gas Giant',
|
| 92 |
radius: 20,
|
| 93 |
distance: 200,
|
| 94 |
-
|
| 95 |
color: '#FB923C',
|
| 96 |
info: {
|
| 97 |
diameter: '139,820 km',
|
| 98 |
moons: 79,
|
| 99 |
-
orbitalPeriod: '
|
| 100 |
},
|
| 101 |
moons: [
|
| 102 |
{
|
| 103 |
radius: 2,
|
| 104 |
distance: 28,
|
| 105 |
-
|
| 106 |
color: '#FCD34D'
|
| 107 |
},
|
| 108 |
{
|
| 109 |
radius: 2,
|
| 110 |
distance: 35,
|
| 111 |
-
|
| 112 |
color: '#FDE68A'
|
| 113 |
}
|
| 114 |
-
]
|
|
|
|
|
|
|
| 115 |
},
|
| 116 |
{
|
| 117 |
name: 'Saturn',
|
| 118 |
type: 'Gas Giant',
|
| 119 |
radius: 17,
|
| 120 |
distance: 260,
|
| 121 |
-
|
| 122 |
color: '#F59E0B',
|
| 123 |
hasRings: true,
|
| 124 |
info: {
|
| 125 |
diameter: '116,460 km',
|
| 126 |
moons: 82,
|
| 127 |
-
orbitalPeriod: '29 years'
|
| 128 |
},
|
| 129 |
moons: [
|
| 130 |
{
|
| 131 |
radius: 3,
|
| 132 |
distance: 30,
|
| 133 |
-
|
| 134 |
color: '#FBBF24'
|
| 135 |
}
|
| 136 |
-
]
|
|
|
|
|
|
|
| 137 |
},
|
| 138 |
{
|
| 139 |
name: 'Uranus',
|
| 140 |
type: 'Ice Giant',
|
| 141 |
radius: 12,
|
| 142 |
distance: 320,
|
| 143 |
-
|
| 144 |
color: '#06B6D4',
|
| 145 |
info: {
|
| 146 |
diameter: '50,724 km',
|
| 147 |
moons: 27,
|
| 148 |
-
orbitalPeriod: '84 years'
|
| 149 |
-
}
|
|
|
|
|
|
|
| 150 |
},
|
| 151 |
{
|
| 152 |
name: 'Neptune',
|
| 153 |
type: 'Ice Giant',
|
| 154 |
radius: 11,
|
| 155 |
distance: 370,
|
| 156 |
-
|
| 157 |
color: '#1E40AF',
|
| 158 |
info: {
|
| 159 |
diameter: '49,244 km',
|
| 160 |
moons: 14,
|
| 161 |
-
orbitalPeriod: '
|
| 162 |
-
}
|
|
|
|
|
|
|
| 163 |
}
|
| 164 |
];
|
| 165 |
|
|
@@ -173,8 +192,9 @@ class SolarSystem {
|
|
| 173 |
this.animate();
|
| 174 |
this.updateDate();
|
| 175 |
this.updateLocation();
|
|
|
|
| 176 |
setInterval(() => this.updateDate(), 1000);
|
| 177 |
-
setInterval(() => this.updateLocation(), 30000);
|
| 178 |
}
|
| 179 |
resize() {
|
| 180 |
this.canvas.width = window.innerWidth;
|
|
@@ -202,10 +222,10 @@ resize() {
|
|
| 202 |
const speedSlider = document.getElementById('speedSlider');
|
| 203 |
speedSlider.addEventListener('input', (e) => {
|
| 204 |
this.speed = parseFloat(e.target.value);
|
|
|
|
| 205 |
document.getElementById('speedValue').textContent = this.speed.toFixed(1) + 'x';
|
| 206 |
});
|
| 207 |
-
|
| 208 |
-
// Zoom control
|
| 209 |
const zoomSlider = document.getElementById('zoomSlider');
|
| 210 |
zoomSlider.addEventListener('input', (e) => {
|
| 211 |
this.zoom = parseFloat(e.target.value);
|
|
@@ -221,20 +241,20 @@ resize() {
|
|
| 221 |
'<i data-feather="pause" class="w-4 h-4"></i><span>Pause</span>';
|
| 222 |
feather.replace();
|
| 223 |
});
|
| 224 |
-
|
| 225 |
// Reset button
|
| 226 |
document.getElementById('resetBtn').addEventListener('click', () => {
|
| 227 |
this.time = 0;
|
| 228 |
-
this.
|
| 229 |
this.zoom = 1;
|
| 230 |
this.speed = 1;
|
|
|
|
| 231 |
document.getElementById('zoomSlider').value = 1;
|
| 232 |
document.getElementById('speedSlider').value = 1;
|
| 233 |
document.getElementById('zoomValue').textContent = '1.0x';
|
| 234 |
document.getElementById('speedValue').textContent = '1.0x';
|
|
|
|
| 235 |
});
|
| 236 |
-
|
| 237 |
-
// Fullscreen button
|
| 238 |
document.getElementById('fullscreenBtn').addEventListener('click', () => {
|
| 239 |
if (!document.fullscreenElement) {
|
| 240 |
document.documentElement.requestFullscreen();
|
|
@@ -253,12 +273,21 @@ resize() {
|
|
| 253 |
document.getElementById('locationDisplay').textContent = 'Updating...';
|
| 254 |
this.updateLocation();
|
| 255 |
});
|
| 256 |
-
// Close info panel
|
| 257 |
document.getElementById('closeInfo').addEventListener('click', () => {
|
| 258 |
document.getElementById('planetInfo').classList.add('hidden');
|
| 259 |
});
|
| 260 |
|
| 261 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 262 |
this.canvas.addEventListener('click', (e) => {
|
| 263 |
const rect = this.canvas.getBoundingClientRect();
|
| 264 |
const x = e.clientX - rect.left - this.centerX;
|
|
@@ -277,7 +306,6 @@ resize() {
|
|
| 277 |
}
|
| 278 |
});
|
| 279 |
}
|
| 280 |
-
|
| 281 |
showPlanetInfo(planet) {
|
| 282 |
const info = document.getElementById('planetInfo');
|
| 283 |
info.classList.remove('hidden');
|
|
@@ -288,17 +316,77 @@ resize() {
|
|
| 288 |
document.getElementById('planetDiameter').textContent = planet.info.diameter;
|
| 289 |
document.getElementById('planetMoons').textContent = planet.info.moons || 'None';
|
| 290 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 291 |
updateDate() {
|
| 292 |
const now = new Date();
|
| 293 |
document.getElementById('dateDisplay').textContent = now.toLocaleDateString('en-US', {
|
| 294 |
weekday: 'long',
|
| 295 |
year: 'numeric',
|
| 296 |
month: 'long',
|
| 297 |
-
day: 'numeric'
|
|
|
|
|
|
|
|
|
|
| 298 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 299 |
}
|
| 300 |
-
|
| 301 |
-
async updateLocation() {
|
| 302 |
const locationDisplay = document.getElementById('locationDisplay');
|
| 303 |
|
| 304 |
if (!navigator.geolocation) {
|
|
@@ -352,15 +440,16 @@ drawSun() {
|
|
| 352 |
this.ctx.fill();
|
| 353 |
}
|
| 354 |
drawPlanet(planet) {
|
| 355 |
-
const
|
| 356 |
-
const
|
| 357 |
-
const
|
|
|
|
| 358 |
|
| 359 |
-
// Draw orbit
|
| 360 |
this.ctx.strokeStyle = 'rgba(147, 51, 234, 0.2)';
|
| 361 |
this.ctx.lineWidth = 1;
|
| 362 |
this.ctx.beginPath();
|
| 363 |
-
this.ctx.
|
| 364 |
this.ctx.stroke();
|
| 365 |
|
| 366 |
// Draw rings for Saturn
|
|
@@ -372,7 +461,7 @@ drawPlanet(planet) {
|
|
| 372 |
this.ctx.stroke();
|
| 373 |
}
|
| 374 |
|
| 375 |
-
// Draw planet
|
| 376 |
this.ctx.fillStyle = planet.color;
|
| 377 |
this.ctx.beginPath();
|
| 378 |
this.ctx.arc(x, y, planet.radius * this.zoom, 0, Math.PI * 2);
|
|
@@ -381,7 +470,8 @@ drawPlanet(planet) {
|
|
| 381 |
// Draw moons
|
| 382 |
if (planet.moons) {
|
| 383 |
planet.moons.forEach(moon => {
|
| 384 |
-
const
|
|
|
|
| 385 |
const moonX = x + Math.cos(moonAngle) * moon.distance * this.zoom;
|
| 386 |
const moonY = y + Math.sin(moonAngle) * moon.distance * this.zoom;
|
| 387 |
|
|
@@ -392,13 +482,15 @@ drawPlanet(planet) {
|
|
| 392 |
});
|
| 393 |
}
|
| 394 |
|
| 395 |
-
// Draw planet name
|
| 396 |
if (this.zoom > 0.8) {
|
| 397 |
this.ctx.fillStyle = 'rgba(255, 255, 255, 0.7)';
|
| 398 |
this.ctx.font = `${Math.max(10, 10 * this.zoom)}px Arial`;
|
| 399 |
this.ctx.textAlign = 'center';
|
| 400 |
this.ctx.fillText(planet.name, x, y - planet.radius * this.zoom - 5);
|
| 401 |
}
|
|
|
|
|
|
|
| 402 |
}
|
| 403 |
adjustBrightness(color, amount) {
|
| 404 |
const num = parseInt(color.replace('#', ''), 16);
|
|
@@ -417,14 +509,13 @@ adjustBrightness(color, amount) {
|
|
| 417 |
|
| 418 |
// Draw planets
|
| 419 |
this.planets.forEach(planet => this.drawPlanet(planet));
|
| 420 |
-
|
| 421 |
// Update time
|
| 422 |
if (!this.isPaused) {
|
| 423 |
this.time++;
|
| 424 |
-
this.
|
|
|
|
| 425 |
}
|
| 426 |
-
|
| 427 |
-
// Update stats less frequently
|
| 428 |
if (this.time % 10 === 0) {
|
| 429 |
this.updateStats();
|
| 430 |
}
|
|
@@ -439,8 +530,9 @@ adjustBrightness(color, amount) {
|
|
| 439 |
}
|
| 440 |
updateStats() {
|
| 441 |
document.getElementById('fpsDisplay').textContent = this.fps;
|
| 442 |
-
|
| 443 |
-
document.getElementById('
|
|
|
|
| 444 |
}
|
| 445 |
}
|
| 446 |
// Initialize the solar system
|
|
|
|
| 1 |
+
|
| 2 |
// Solar System Simulation
|
| 3 |
class SolarSystem {
|
| 4 |
constructor() {
|
|
|
|
| 12 |
this.time = 0;
|
| 13 |
this.fps = 60;
|
| 14 |
this.lastFrameTime = performance.now();
|
| 15 |
+
this.startDate = new Date();
|
| 16 |
+
this.currentDate = new Date();
|
| 17 |
+
this.timeLapseSpeed = 1; // days per frame
|
| 18 |
|
| 19 |
this.planets = [
|
| 20 |
{
|
|
|
|
| 22 |
type: 'Terrestrial',
|
| 23 |
radius: 4,
|
| 24 |
distance: 60,
|
| 25 |
+
orbitalPeriod: 87.97, // days
|
| 26 |
color: '#9CA3AF',
|
| 27 |
info: {
|
| 28 |
diameter: '4,879 km',
|
| 29 |
moons: 0,
|
| 30 |
+
orbitalPeriod: '87.97 days'
|
| 31 |
+
},
|
| 32 |
+
eccentricity: 0.2056,
|
| 33 |
+
inclination: 7.0
|
| 34 |
},
|
| 35 |
{
|
| 36 |
name: 'Venus',
|
| 37 |
type: 'Terrestrial',
|
| 38 |
radius: 7,
|
| 39 |
distance: 85,
|
| 40 |
+
orbitalPeriod: 224.70,
|
| 41 |
color: '#FEF3C7',
|
| 42 |
info: {
|
| 43 |
diameter: '12,104 km',
|
| 44 |
moons: 0,
|
| 45 |
+
orbitalPeriod: '224.70 days'
|
| 46 |
+
},
|
| 47 |
+
eccentricity: 0.0067,
|
| 48 |
+
inclination: 3.39
|
| 49 |
},
|
| 50 |
{
|
| 51 |
name: 'Earth',
|
| 52 |
type: 'Terrestrial',
|
| 53 |
radius: 8,
|
| 54 |
distance: 110,
|
| 55 |
+
orbitalPeriod: 365.26,
|
| 56 |
color: '#3B82F6',
|
| 57 |
info: {
|
| 58 |
diameter: '12,742 km',
|
| 59 |
moons: 1,
|
| 60 |
+
orbitalPeriod: '365.26 days'
|
| 61 |
},
|
| 62 |
moons: [{
|
| 63 |
radius: 2,
|
| 64 |
distance: 15,
|
| 65 |
+
orbitalPeriod: 27.32, // days
|
| 66 |
color: '#E5E7EB'
|
| 67 |
+
}],
|
| 68 |
+
eccentricity: 0.0167,
|
| 69 |
+
inclination: 0.0
|
| 70 |
},
|
| 71 |
{
|
| 72 |
name: 'Mars',
|
| 73 |
type: 'Terrestrial',
|
| 74 |
radius: 5,
|
| 75 |
distance: 140,
|
| 76 |
+
orbitalPeriod: 686.98,
|
| 77 |
color: '#EF4444',
|
| 78 |
info: {
|
| 79 |
diameter: '6,779 km',
|
| 80 |
moons: 2,
|
| 81 |
+
orbitalPeriod: '686.98 days'
|
| 82 |
},
|
| 83 |
moons: [
|
| 84 |
{
|
| 85 |
radius: 1,
|
| 86 |
distance: 10,
|
| 87 |
+
orbitalPeriod: 0.32, // days
|
| 88 |
color: '#F3F4F6'
|
| 89 |
},
|
| 90 |
{
|
| 91 |
radius: 1,
|
| 92 |
distance: 14,
|
| 93 |
+
orbitalPeriod: 1.26, // days
|
| 94 |
color: '#D1D5DB'
|
| 95 |
}
|
| 96 |
+
],
|
| 97 |
+
eccentricity: 0.0935,
|
| 98 |
+
inclination: 1.85
|
| 99 |
},
|
| 100 |
{
|
| 101 |
name: 'Jupiter',
|
| 102 |
type: 'Gas Giant',
|
| 103 |
radius: 20,
|
| 104 |
distance: 200,
|
| 105 |
+
orbitalPeriod: 4332.59,
|
| 106 |
color: '#FB923C',
|
| 107 |
info: {
|
| 108 |
diameter: '139,820 km',
|
| 109 |
moons: 79,
|
| 110 |
+
orbitalPeriod: '11.86 years'
|
| 111 |
},
|
| 112 |
moons: [
|
| 113 |
{
|
| 114 |
radius: 2,
|
| 115 |
distance: 28,
|
| 116 |
+
orbitalPeriod: 1.77, // days
|
| 117 |
color: '#FCD34D'
|
| 118 |
},
|
| 119 |
{
|
| 120 |
radius: 2,
|
| 121 |
distance: 35,
|
| 122 |
+
orbitalPeriod: 3.55, // days
|
| 123 |
color: '#FDE68A'
|
| 124 |
}
|
| 125 |
+
],
|
| 126 |
+
eccentricity: 0.0489,
|
| 127 |
+
inclination: 1.31
|
| 128 |
},
|
| 129 |
{
|
| 130 |
name: 'Saturn',
|
| 131 |
type: 'Gas Giant',
|
| 132 |
radius: 17,
|
| 133 |
distance: 260,
|
| 134 |
+
orbitalPeriod: 10759.22,
|
| 135 |
color: '#F59E0B',
|
| 136 |
hasRings: true,
|
| 137 |
info: {
|
| 138 |
diameter: '116,460 km',
|
| 139 |
moons: 82,
|
| 140 |
+
orbitalPeriod: '29.46 years'
|
| 141 |
},
|
| 142 |
moons: [
|
| 143 |
{
|
| 144 |
radius: 3,
|
| 145 |
distance: 30,
|
| 146 |
+
orbitalPeriod: 2.74, // days
|
| 147 |
color: '#FBBF24'
|
| 148 |
}
|
| 149 |
+
],
|
| 150 |
+
eccentricity: 0.0565,
|
| 151 |
+
inclination: 2.49
|
| 152 |
},
|
| 153 |
{
|
| 154 |
name: 'Uranus',
|
| 155 |
type: 'Ice Giant',
|
| 156 |
radius: 12,
|
| 157 |
distance: 320,
|
| 158 |
+
orbitalPeriod: 30688.5,
|
| 159 |
color: '#06B6D4',
|
| 160 |
info: {
|
| 161 |
diameter: '50,724 km',
|
| 162 |
moons: 27,
|
| 163 |
+
orbitalPeriod: '84.01 years'
|
| 164 |
+
},
|
| 165 |
+
eccentricity: 0.0457,
|
| 166 |
+
inclination: 0.77
|
| 167 |
},
|
| 168 |
{
|
| 169 |
name: 'Neptune',
|
| 170 |
type: 'Ice Giant',
|
| 171 |
radius: 11,
|
| 172 |
distance: 370,
|
| 173 |
+
orbitalPeriod: 60182,
|
| 174 |
color: '#1E40AF',
|
| 175 |
info: {
|
| 176 |
diameter: '49,244 km',
|
| 177 |
moons: 14,
|
| 178 |
+
orbitalPeriod: '164.79 years'
|
| 179 |
+
},
|
| 180 |
+
eccentricity: 0.0113,
|
| 181 |
+
inclination: 1.77
|
| 182 |
}
|
| 183 |
];
|
| 184 |
|
|
|
|
| 192 |
this.animate();
|
| 193 |
this.updateDate();
|
| 194 |
this.updateLocation();
|
| 195 |
+
this.updateTimeDisplay();
|
| 196 |
setInterval(() => this.updateDate(), 1000);
|
| 197 |
+
setInterval(() => this.updateLocation(), 30000);
|
| 198 |
}
|
| 199 |
resize() {
|
| 200 |
this.canvas.width = window.innerWidth;
|
|
|
|
| 222 |
const speedSlider = document.getElementById('speedSlider');
|
| 223 |
speedSlider.addEventListener('input', (e) => {
|
| 224 |
this.speed = parseFloat(e.target.value);
|
| 225 |
+
this.timeLapseSpeed = this.speed * 0.1; // Convert to days per frame
|
| 226 |
document.getElementById('speedValue').textContent = this.speed.toFixed(1) + 'x';
|
| 227 |
});
|
| 228 |
+
// Zoom control
|
|
|
|
| 229 |
const zoomSlider = document.getElementById('zoomSlider');
|
| 230 |
zoomSlider.addEventListener('input', (e) => {
|
| 231 |
this.zoom = parseFloat(e.target.value);
|
|
|
|
| 241 |
'<i data-feather="pause" class="w-4 h-4"></i><span>Pause</span>';
|
| 242 |
feather.replace();
|
| 243 |
});
|
|
|
|
| 244 |
// Reset button
|
| 245 |
document.getElementById('resetBtn').addEventListener('click', () => {
|
| 246 |
this.time = 0;
|
| 247 |
+
this.currentDate = new Date();
|
| 248 |
this.zoom = 1;
|
| 249 |
this.speed = 1;
|
| 250 |
+
this.timeLapseSpeed = 0.1;
|
| 251 |
document.getElementById('zoomSlider').value = 1;
|
| 252 |
document.getElementById('speedSlider').value = 1;
|
| 253 |
document.getElementById('zoomValue').textContent = '1.0x';
|
| 254 |
document.getElementById('speedValue').textContent = '1.0x';
|
| 255 |
+
this.updateTimeDisplay();
|
| 256 |
});
|
| 257 |
+
// Fullscreen button
|
|
|
|
| 258 |
document.getElementById('fullscreenBtn').addEventListener('click', () => {
|
| 259 |
if (!document.fullscreenElement) {
|
| 260 |
document.documentElement.requestFullscreen();
|
|
|
|
| 273 |
document.getElementById('locationDisplay').textContent = 'Updating...';
|
| 274 |
this.updateLocation();
|
| 275 |
});
|
| 276 |
+
// Close info panel
|
| 277 |
document.getElementById('closeInfo').addEventListener('click', () => {
|
| 278 |
document.getElementById('planetInfo').classList.add('hidden');
|
| 279 |
});
|
| 280 |
|
| 281 |
+
// Time jump controls
|
| 282 |
+
document.querySelectorAll('.time-unit').forEach(unit => {
|
| 283 |
+
unit.addEventListener('click', (e) => {
|
| 284 |
+
const jumpDays = parseInt(e.target.dataset.time);
|
| 285 |
+
this.time += jumpDays / this.timeLapseSpeed;
|
| 286 |
+
this.updateTimeDisplay();
|
| 287 |
+
this.updateDate();
|
| 288 |
+
});
|
| 289 |
+
});
|
| 290 |
+
// Canvas click for planet info
|
| 291 |
this.canvas.addEventListener('click', (e) => {
|
| 292 |
const rect = this.canvas.getBoundingClientRect();
|
| 293 |
const x = e.clientX - rect.left - this.centerX;
|
|
|
|
| 306 |
}
|
| 307 |
});
|
| 308 |
}
|
|
|
|
| 309 |
showPlanetInfo(planet) {
|
| 310 |
const info = document.getElementById('planetInfo');
|
| 311 |
info.classList.remove('hidden');
|
|
|
|
| 316 |
document.getElementById('planetDiameter').textContent = planet.info.diameter;
|
| 317 |
document.getElementById('planetMoons').textContent = planet.info.moons || 'None';
|
| 318 |
}
|
| 319 |
+
|
| 320 |
+
updateTimeDisplay() {
|
| 321 |
+
const timeDisplay = document.getElementById('timeDisplay');
|
| 322 |
+
if (timeDisplay) {
|
| 323 |
+
const days = Math.floor(this.timeLapseSpeed * this.time);
|
| 324 |
+
const years = Math.floor(days / 365.26);
|
| 325 |
+
const remainingDays = days % 365.26;
|
| 326 |
+
const months = Math.floor(remainingDays / 30.44);
|
| 327 |
+
const remainingDays2 = Math.floor(remainingDays % 30.44);
|
| 328 |
+
|
| 329 |
+
let timeString = '';
|
| 330 |
+
if (years > 0) timeString += `${years}Y `;
|
| 331 |
+
if (months > 0) timeString += `${months}M `;
|
| 332 |
+
if (remainingDays2 > 0 || timeString === '') timeString += `${remainingDays2}D`;
|
| 333 |
+
|
| 334 |
+
timeDisplay.textContent = `Time Lapse: ${timeString}`;
|
| 335 |
+
}
|
| 336 |
+
}
|
| 337 |
+
|
| 338 |
+
calculatePlanetPosition(planet, elapsedTime) {
|
| 339 |
+
const meanAnomaly = (2 * Math.PI * elapsedTime) / planet.orbitalPeriod;
|
| 340 |
+
const eccentricity = planet.eccentricity || 0;
|
| 341 |
+
|
| 342 |
+
// Solve Kepler's equation (simplified)
|
| 343 |
+
let E = meanAnomaly;
|
| 344 |
+
for (let i = 0; i < 5; i++) {
|
| 345 |
+
E = meanAnomaly + eccentricity * Math.sin(E);
|
| 346 |
+
}
|
| 347 |
+
|
| 348 |
+
// True anomaly
|
| 349 |
+
const trueAnomaly = 2 * Math.atan2(
|
| 350 |
+
Math.sqrt(1 + eccentricity) * Math.sin(E / 2),
|
| 351 |
+
Math.sqrt(1 - eccentricity) * Math.cos(E / 2)
|
| 352 |
+
);
|
| 353 |
+
|
| 354 |
+
// Distance from sun
|
| 355 |
+
const r = planet.distance * (1 - eccentricity * Math.cos(E));
|
| 356 |
+
|
| 357 |
+
// Position
|
| 358 |
+
const x = r * Math.cos(trueAnomaly);
|
| 359 |
+
const y = r * Math.sin(trueAnomaly);
|
| 360 |
+
|
| 361 |
+
// Apply inclination
|
| 362 |
+
const inclination = (planet.inclination || 0) * Math.PI / 180;
|
| 363 |
+
const yInclined = y * Math.cos(inclination);
|
| 364 |
+
|
| 365 |
+
return { x, y: yInclined, r };
|
| 366 |
+
}
|
| 367 |
updateDate() {
|
| 368 |
const now = new Date();
|
| 369 |
document.getElementById('dateDisplay').textContent = now.toLocaleDateString('en-US', {
|
| 370 |
weekday: 'long',
|
| 371 |
year: 'numeric',
|
| 372 |
month: 'long',
|
| 373 |
+
day: 'numeric',
|
| 374 |
+
hour: '2-digit',
|
| 375 |
+
minute: '2-digit',
|
| 376 |
+
second: '2-digit'
|
| 377 |
});
|
| 378 |
+
|
| 379 |
+
// Update current date display
|
| 380 |
+
const currentDateDisplay = document.getElementById('currentDateDisplay');
|
| 381 |
+
if (currentDateDisplay) {
|
| 382 |
+
currentDateDisplay.textContent = this.currentDate.toLocaleDateString('en-US', {
|
| 383 |
+
month: 'short',
|
| 384 |
+
day: 'numeric',
|
| 385 |
+
year: 'numeric'
|
| 386 |
+
});
|
| 387 |
+
}
|
| 388 |
}
|
| 389 |
+
async updateLocation() {
|
|
|
|
| 390 |
const locationDisplay = document.getElementById('locationDisplay');
|
| 391 |
|
| 392 |
if (!navigator.geolocation) {
|
|
|
|
| 440 |
this.ctx.fill();
|
| 441 |
}
|
| 442 |
drawPlanet(planet) {
|
| 443 |
+
const elapsedTime = this.timeLapseSpeed * this.time;
|
| 444 |
+
const position = this.calculatePlanetPosition(planet, elapsedTime);
|
| 445 |
+
const x = this.centerX + position.x * this.zoom;
|
| 446 |
+
const y = this.centerY + position.y * this.zoom;
|
| 447 |
|
| 448 |
+
// Draw orbit
|
| 449 |
this.ctx.strokeStyle = 'rgba(147, 51, 234, 0.2)';
|
| 450 |
this.ctx.lineWidth = 1;
|
| 451 |
this.ctx.beginPath();
|
| 452 |
+
this.ctx.ellipse(this.centerX, this.centerY, planet.distance * this.zoom, planet.distance * this.zoom, 0, 0, Math.PI * 2);
|
| 453 |
this.ctx.stroke();
|
| 454 |
|
| 455 |
// Draw rings for Saturn
|
|
|
|
| 461 |
this.ctx.stroke();
|
| 462 |
}
|
| 463 |
|
| 464 |
+
// Draw planet
|
| 465 |
this.ctx.fillStyle = planet.color;
|
| 466 |
this.ctx.beginPath();
|
| 467 |
this.ctx.arc(x, y, planet.radius * this.zoom, 0, Math.PI * 2);
|
|
|
|
| 470 |
// Draw moons
|
| 471 |
if (planet.moons) {
|
| 472 |
planet.moons.forEach(moon => {
|
| 473 |
+
const moonElapsedTime = this.timeLapseSpeed * this.time;
|
| 474 |
+
const moonAngle = (2 * Math.PI * moonElapsedTime) / moon.orbitalPeriod;
|
| 475 |
const moonX = x + Math.cos(moonAngle) * moon.distance * this.zoom;
|
| 476 |
const moonY = y + Math.sin(moonAngle) * moon.distance * this.zoom;
|
| 477 |
|
|
|
|
| 482 |
});
|
| 483 |
}
|
| 484 |
|
| 485 |
+
// Draw planet name
|
| 486 |
if (this.zoom > 0.8) {
|
| 487 |
this.ctx.fillStyle = 'rgba(255, 255, 255, 0.7)';
|
| 488 |
this.ctx.font = `${Math.max(10, 10 * this.zoom)}px Arial`;
|
| 489 |
this.ctx.textAlign = 'center';
|
| 490 |
this.ctx.fillText(planet.name, x, y - planet.radius * this.zoom - 5);
|
| 491 |
}
|
| 492 |
+
|
| 493 |
+
return { x, y, position };
|
| 494 |
}
|
| 495 |
adjustBrightness(color, amount) {
|
| 496 |
const num = parseInt(color.replace('#', ''), 16);
|
|
|
|
| 509 |
|
| 510 |
// Draw planets
|
| 511 |
this.planets.forEach(planet => this.drawPlanet(planet));
|
|
|
|
| 512 |
// Update time
|
| 513 |
if (!this.isPaused) {
|
| 514 |
this.time++;
|
| 515 |
+
this.currentDate = new Date(this.startDate.getTime() + this.timeLapseSpeed * this.time * 24 * 60 * 60 * 1000);
|
| 516 |
+
this.updateTimeDisplay();
|
| 517 |
}
|
| 518 |
+
// Update stats less frequently
|
|
|
|
| 519 |
if (this.time % 10 === 0) {
|
| 520 |
this.updateStats();
|
| 521 |
}
|
|
|
|
| 530 |
}
|
| 531 |
updateStats() {
|
| 532 |
document.getElementById('fpsDisplay').textContent = this.fps;
|
| 533 |
+
const totalDays = Math.floor(this.timeLapseSpeed * this.time);
|
| 534 |
+
document.getElementById('daysDisplay').textContent = totalDays;
|
| 535 |
+
document.getElementById('yearsDisplay').textContent = (totalDays / 365.26).toFixed(2);
|
| 536 |
}
|
| 537 |
}
|
| 538 |
// Initialize the solar system
|
style.css
CHANGED
|
@@ -29,12 +29,35 @@
|
|
| 29 |
::-webkit-scrollbar-thumb:hover {
|
| 30 |
background: linear-gradient(135deg, #a855f7, #f472b6);
|
| 31 |
}
|
| 32 |
-
|
| 33 |
-
#locationDisplay {
|
| 34 |
cursor: pointer;
|
| 35 |
transition: opacity 0.3s ease;
|
| 36 |
}
|
| 37 |
|
| 38 |
-
#locationDisplay:hover {
|
| 39 |
opacity: 0.8;
|
| 40 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
::-webkit-scrollbar-thumb:hover {
|
| 30 |
background: linear-gradient(135deg, #a855f7, #f472b6);
|
| 31 |
}
|
| 32 |
+
#locationDisplay, #timeDisplay {
|
|
|
|
| 33 |
cursor: pointer;
|
| 34 |
transition: opacity 0.3s ease;
|
| 35 |
}
|
| 36 |
|
| 37 |
+
#locationDisplay:hover, #timeDisplay:hover {
|
| 38 |
opacity: 0.8;
|
| 39 |
}
|
| 40 |
+
|
| 41 |
+
.time-controls {
|
| 42 |
+
display: flex;
|
| 43 |
+
gap: 8px;
|
| 44 |
+
align-items: center;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
.time-unit {
|
| 48 |
+
padding: 4px 8px;
|
| 49 |
+
background: rgba(147, 51, 234, 0.2);
|
| 50 |
+
border-radius: 4px;
|
| 51 |
+
font-size: 12px;
|
| 52 |
+
cursor: pointer;
|
| 53 |
+
transition: all 0.3s ease;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
.time-unit:hover {
|
| 57 |
+
background: rgba(147, 51, 234, 0.4);
|
| 58 |
+
transform: scale(1.05);
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
.time-unit.active {
|
| 62 |
+
background: rgba(147, 51, 234, 0.6);
|
| 63 |
+
}
|