-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSatelliten.html
More file actions
719 lines (612 loc) · 28.9 KB
/
Satelliten.html
File metadata and controls
719 lines (612 loc) · 28.9 KB
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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Advanced Satellite Visualizer</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: #000;
overflow: hidden;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
color: #fff;
}
#container {
position: relative;
width: 100vw;
height: 100vh;
}
#ui-panel {
position: absolute;
top: 20px;
left: 20px;
background: rgba(0, 20, 40, 0.9);
backdrop-filter: blur(10px);
border: 1px solid rgba(0, 150, 255, 0.3);
border-radius: 15px;
padding: 20px;
min-width: 300px;
max-width: 400px;
z-index: 1000;
box-shadow: 0 8px 32px rgba(0, 150, 255, 0.1);
}
.ui-section {
margin-bottom: 20px;
}
.ui-section h3 {
color: #00aaff;
margin-bottom: 10px;
font-size: 14px;
text-transform: uppercase;
letter-spacing: 1px;
}
.control-group {
margin-bottom: 15px;
}
label {
display: block;
margin-bottom: 5px;
font-size: 12px;
color: #aaa;
}
input[type="range"] {
width: 100%;
-webkit-appearance: none;
height: 4px;
border-radius: 2px;
background: #333;
outline: none;
}
input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 16px;
height: 16px;
border-radius: 50%;
background: #00aaff;
cursor: pointer;
}
select {
width: 100%;
padding: 8px;
background: rgba(0, 50, 100, 0.8);
border: 1px solid rgba(0, 150, 255, 0.3);
border-radius: 5px;
color: #fff;
font-size: 12px;
}
select option {
background: #001122;
color: #fff;
}
.satellite-info {
background: rgba(0, 50, 100, 0.5);
padding: 10px;
border-radius: 8px;
margin-top: 10px;
border: 1px solid rgba(0, 150, 255, 0.2);
}
.satellite-info h4 {
color: #00ff88;
margin-bottom: 8px;
}
.info-row {
display: flex;
justify-content: space-between;
margin-bottom: 5px;
font-size: 11px;
}
.info-label {
color: #aaa;
}
.info-value {
color: #fff;
font-weight: bold;
}
#stats {
position: absolute;
top: 20px;
right: 20px;
background: rgba(0, 20, 40, 0.9);
backdrop-filter: blur(10px);
border: 1px solid rgba(0, 150, 255, 0.3);
border-radius: 10px;
padding: 15px;
z-index: 1000;
font-size: 12px;
}
.loading {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: #00aaff;
font-size: 18px;
z-index: 1001;
}
.btn {
background: linear-gradient(45deg, #00aaff, #0088cc);
border: none;
color: white;
padding: 8px 16px;
border-radius: 5px;
cursor: pointer;
font-size: 12px;
margin: 5px;
transition: all 0.3s ease;
}
.btn:hover {
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(0, 170, 255, 0.3);
}
.trajectory-controls {
display: flex;
gap: 10px;
margin-top: 10px;
}
</style>
</head>
<body>
<div id="container">
<div class="loading" id="loading">Loading satellite data...</div>
<div id="ui-panel">
<div class="ui-section">
<h3>🛰️ Satellite Controls</h3>
<div class="control-group">
<label>Satellite Filter</label>
<select id="satelliteFilter">
<option value="all">All Satellites</option>
<option value="starlink">Starlink</option>
<option value="iss">ISS</option>
<option value="gps">GPS</option>
<option value="weather">Weather</option>
<option value="military">Military</option>
</select>
</div>
<div class="control-group">
<label>Particle Size: <span id="sizeValue">1.0</span></label>
<input type="range" id="particleSize" min="0.5" max="3.0" step="0.1" value="1.0">
</div>
<div class="control-group">
<label>Orbit Speed: <span id="speedValue">1.0x</span></label>
<input type="range" id="orbitSpeed" min="0.1" max="5.0" step="0.1" value="1.0">
</div>
<div class="control-group">
<label>Time Acceleration: <span id="timeValue">1.0x</span></label>
<input type="range" id="timeAccel" min="0.1" max="10.0" step="0.1" value="1.0">
</div>
</div>
<div class="ui-section">
<h3>🌍 Visualization</h3>
<div>
<button class="btn" id="toggleTrajectories">Show Trajectories</button>
<button class="btn" id="toggleLabels">Show Labels</button>
</div>
<div class="trajectory-controls">
<button class="btn" id="clearTrajectories">Clear Paths</button>
<button class="btn" id="resetView">Reset View</button>
</div>
</div>
<div id="satelliteDetails" class="satellite-info" style="display: none;">
<h4 id="satName">Select a satellite</h4>
<div class="info-row">
<span class="info-label">Altitude:</span>
<span class="info-value" id="satAltitude">-</span>
</div>
<div class="info-row">
<span class="info-label">Velocity:</span>
<span class="info-value" id="satVelocity">-</span>
</div>
<div class="info-row">
<span class="info-label">Period:</span>
<span class="info-value" id="satPeriod">-</span>
</div>
<div class="info-row">
<span class="info-label">Inclination:</span>
<span class="info-value" id="satInclination">-</span>
</div>
<div class="info-row">
<span class="info-label">Country:</span>
<span class="info-value" id="satCountry">-</span>
</div>
<div class="info-row">
<span class="info-label">Launch Date:</span>
<span class="info-value" id="satLaunch">-</span>
</div>
</div>
</div>
<div id="stats">
<div>Satellites: <span id="satCount">0</span></div>
<div>FPS: <span id="fps">0</span></div>
<div>Selected: <span id="selectedSat">None</span></div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<script>
class SatelliteVisualizer {
constructor() {
this.scene = new THREE.Scene();
this.camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 10000);
this.renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
this.renderer.setSize(window.innerWidth, window.innerHeight);
this.renderer.setClearColor(0x000000, 1);
document.getElementById('container').appendChild(this.renderer.domElement);
this.satellites = [];
this.satelliteObjects = [];
this.trajectories = new Map();
this.selectedSatellite = null;
this.showTrajectories = false;
this.showLabels = false;
this.timeAcceleration = 1.0;
this.particleSize = 1.0;
this.orbitSpeed = 1.0;
this.mouse = new THREE.Vector2();
this.raycaster = new THREE.Raycaster();
this.init();
this.loadSatelliteData();
this.setupControls();
this.animate();
}
init() {
// Create Earth
const earthGeometry = new THREE.SphereGeometry(6.371, 64, 32);
const earthTexture = this.createEarthTexture();
const earthMaterial = new THREE.MeshPhongMaterial({
map: earthTexture,
transparent: true,
opacity: 0.9
});
this.earth = new THREE.Mesh(earthGeometry, earthMaterial);
this.scene.add(this.earth);
// Create atmosphere
const atmosphereGeometry = new THREE.SphereGeometry(6.8, 64, 32);
const atmosphereMaterial = new THREE.MeshPhongMaterial({
color: 0x4488ff,
transparent: true,
opacity: 0.1,
side: THREE.BackSide
});
const atmosphere = new THREE.Mesh(atmosphereGeometry, atmosphereMaterial);
this.scene.add(atmosphere);
// Lighting
const ambientLight = new THREE.AmbientLight(0x404040, 0.4);
this.scene.add(ambientLight);
const directionalLight = new THREE.DirectionalLight(0xffffff, 1);
directionalLight.position.set(1, 1, 1);
this.scene.add(directionalLight);
// Space background
this.createStarField();
// Camera position
this.camera.position.z = 30;
// Mouse controls
this.setupMouseControls();
}
createEarthTexture() {
const canvas = document.createElement('canvas');
canvas.width = 512;
canvas.height = 256;
const ctx = canvas.getContext('2d');
// Create a gradient for the earth
const gradient = ctx.createLinearGradient(0, 0, 512, 256);
gradient.addColorStop(0, '#1e3c72');
gradient.addColorStop(0.5, '#2a5298');
gradient.addColorStop(1, '#1e3c72');
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, 512, 256);
// Add some continents-like shapes
ctx.fillStyle = '#2d5a27';
ctx.fillRect(50, 80, 100, 60);
ctx.fillRect(200, 100, 80, 40);
ctx.fillRect(350, 70, 120, 80);
return new THREE.CanvasTexture(canvas);
}
createStarField() {
const starsGeometry = new THREE.BufferGeometry();
const starsCount = 5000;
const positions = new Float32Array(starsCount * 3);
for (let i = 0; i < starsCount * 3; i += 3) {
positions[i] = (Math.random() - 0.5) * 2000;
positions[i + 1] = (Math.random() - 0.5) * 2000;
positions[i + 2] = (Math.random() - 0.5) * 2000;
}
starsGeometry.setAttribute('position', new THREE.BufferAttribute(positions, 3));
const starsMaterial = new THREE.PointsMaterial({
color: 0xffffff,
size: 0.5,
transparent: true,
opacity: 0.8
});
const stars = new THREE.Points(starsGeometry, starsMaterial);
this.scene.add(stars);
}
async loadSatelliteData() {
try {
// Simulate loading real satellite data
const satelliteData = await this.generateSatelliteData();
this.satellites = satelliteData;
this.createSatelliteObjects();
document.getElementById('loading').style.display = 'none';
} catch (error) {
console.error('Error loading satellite data:', error);
document.getElementById('loading').textContent = 'Error loading data';
}
}
generateSatelliteData() {
return new Promise((resolve) => {
setTimeout(() => {
const satellites = [];
const satelliteTypes = [
{ name: 'Starlink', count: 200, color: 0x00ff88, altitude: [340, 550] },
{ name: 'GPS', count: 30, color: 0xffaa00, altitude: [20200, 20200] },
{ name: 'Weather', count: 15, color: 0x0088ff, altitude: [700, 1500] },
{ name: 'ISS', count: 1, color: 0xff0044, altitude: [408, 408] },
{ name: 'Military', count: 50, color: 0xff4400, altitude: [800, 36000] }
];
let id = 0;
satelliteTypes.forEach(type => {
for (let i = 0; i < type.count; i++) {
const altitude = type.altitude[0] + Math.random() * (type.altitude[1] - type.altitude[0]);
satellites.push({
id: id++,
name: `${type.name}-${i + 1}`,
type: type.name.toLowerCase(),
altitude: altitude,
inclination: Math.random() * 180,
raan: Math.random() * 360,
argPe: Math.random() * 360,
meanAnomaly: Math.random() * 360,
period: Math.sqrt(Math.pow(6371 + altitude, 3) / 398600) * 2 * Math.PI / 60, // minutes
velocity: Math.sqrt(398600 / (6371 + altitude)), // km/s
color: type.color,
country: ['USA', 'Russia', 'China', 'EU', 'Japan'][Math.floor(Math.random() * 5)],
launchDate: new Date(2020 + Math.random() * 5, Math.floor(Math.random() * 12), Math.floor(Math.random() * 28)).toDateString()
});
}
});
resolve(satellites);
}, 1000);
});
}
createSatelliteObjects() {
const geometry = new THREE.SphereGeometry(0.1, 8, 6);
this.satellites.forEach(sat => {
const material = new THREE.MeshBasicMaterial({
color: sat.color,
transparent: true,
opacity: 0.8
});
const satellite = new THREE.Mesh(geometry, material);
satellite.userData = sat;
// Calculate initial position
this.updateSatellitePosition(satellite, 0);
this.scene.add(satellite);
this.satelliteObjects.push(satellite);
// Create trajectory
this.trajectories.set(sat.id, []);
});
document.getElementById('satCount').textContent = this.satellites.length;
}
updateSatellitePosition(satellite, time) {
const sat = satellite.userData;
const earthRadius = 6.371;
const radius = earthRadius + sat.altitude / 100; // Scale down for visualization
// Simple orbital mechanics
const meanMotion = 2 * Math.PI / (sat.period * 60); // rad/s
const currentAnomaly = sat.meanAnomaly * Math.PI / 180 + meanMotion * time * this.timeAcceleration;
const inclination = sat.inclination * Math.PI / 180;
const raan = sat.raan * Math.PI / 180;
const argPe = sat.argPe * Math.PI / 180;
// Position in orbital plane
const x_orbit = radius * Math.cos(currentAnomaly);
const y_orbit = radius * Math.sin(currentAnomaly);
const z_orbit = 0;
// Rotate to 3D space
const x = x_orbit * (Math.cos(raan) * Math.cos(argPe) - Math.sin(raan) * Math.sin(argPe) * Math.cos(inclination)) +
y_orbit * (-Math.cos(raan) * Math.sin(argPe) - Math.sin(raan) * Math.cos(argPe) * Math.cos(inclination));
const y = x_orbit * (Math.sin(raan) * Math.cos(argPe) + Math.cos(raan) * Math.sin(argPe) * Math.cos(inclination)) +
y_orbit * (-Math.sin(raan) * Math.sin(argPe) + Math.cos(raan) * Math.cos(argPe) * Math.cos(inclination));
const z = x_orbit * (Math.sin(argPe) * Math.sin(inclination)) +
y_orbit * (Math.cos(argPe) * Math.sin(inclination));
satellite.position.set(x, y, z);
// Update trajectory
if (this.showTrajectories) {
const trajectory = this.trajectories.get(sat.id);
trajectory.push(satellite.position.clone());
if (trajectory.length > 100) trajectory.shift();
this.updateTrajectoryLine(sat.id, trajectory);
}
}
updateTrajectoryLine(satId, points) {
const lineKey = `trajectory_${satId}`;
const existingLine = this.scene.getObjectByName(lineKey);
if (existingLine) {
this.scene.remove(existingLine);
}
if (points.length > 1) {
const geometry = new THREE.BufferGeometry().setFromPoints(points);
const material = new THREE.LineBasicMaterial({
color: 0x00aaff,
transparent: true,
opacity: 0.3
});
const line = new THREE.Line(geometry, material);
line.name = lineKey;
this.scene.add(line);
}
}
setupMouseControls() {
let isDragging = false;
let previousMousePosition = { x: 0, y: 0 };
this.renderer.domElement.addEventListener('mousedown', (e) => {
isDragging = true;
previousMousePosition = { x: e.clientX, y: e.clientY };
});
this.renderer.domElement.addEventListener('mousemove', (e) => {
if (isDragging) {
const deltaMove = {
x: e.clientX - previousMousePosition.x,
y: e.clientY - previousMousePosition.y
};
const deltaRotationQuaternion = new THREE.Quaternion()
.setFromEuler(new THREE.Euler(
this.toRadians(deltaMove.y * 0.5),
this.toRadians(deltaMove.x * 0.5),
0,
'XYZ'
));
this.camera.quaternion.multiplyQuaternions(deltaRotationQuaternion, this.camera.quaternion);
previousMousePosition = { x: e.clientX, y: e.clientY };
}
});
this.renderer.domElement.addEventListener('mouseup', () => {
isDragging = false;
});
this.renderer.domElement.addEventListener('wheel', (e) => {
this.camera.position.multiplyScalar(1 + e.deltaY * 0.001);
});
this.renderer.domElement.addEventListener('click', (e) => {
this.mouse.x = (e.clientX / window.innerWidth) * 2 - 1;
this.mouse.y = -(e.clientY / window.innerHeight) * 2 + 1;
this.raycaster.setFromCamera(this.mouse, this.camera);
const intersects = this.raycaster.intersectObjects(this.satelliteObjects);
if (intersects.length > 0) {
this.selectSatellite(intersects[0].object);
}
});
}
selectSatellite(satelliteObject) {
// Reset previous selection
if (this.selectedSatellite) {
this.selectedSatellite.material.emissive.setHex(0x000000);
this.selectedSatellite.scale.set(1, 1, 1);
}
this.selectedSatellite = satelliteObject;
satelliteObject.material.emissive.setHex(0x444444);
satelliteObject.scale.set(2, 2, 2);
this.updateSatelliteInfo(satelliteObject.userData);
}
updateSatelliteInfo(sat) {
document.getElementById('satelliteDetails').style.display = 'block';
document.getElementById('satName').textContent = sat.name;
document.getElementById('satAltitude').textContent = `${sat.altitude.toFixed(1)} km`;
document.getElementById('satVelocity').textContent = `${sat.velocity.toFixed(2)} km/s`;
document.getElementById('satPeriod').textContent = `${sat.period.toFixed(1)} min`;
document.getElementById('satInclination').textContent = `${sat.inclination.toFixed(1)}°`;
document.getElementById('satCountry').textContent = sat.country;
document.getElementById('satLaunch').textContent = sat.launchDate;
document.getElementById('selectedSat').textContent = sat.name;
}
setupControls() {
// Satellite filter
document.getElementById('satelliteFilter').addEventListener('change', (e) => {
this.filterSatellites(e.target.value);
});
// Particle size
document.getElementById('particleSize').addEventListener('input', (e) => {
this.particleSize = parseFloat(e.target.value);
document.getElementById('sizeValue').textContent = this.particleSize.toFixed(1);
this.updateParticleSize();
});
// Orbit speed
document.getElementById('orbitSpeed').addEventListener('input', (e) => {
this.orbitSpeed = parseFloat(e.target.value);
document.getElementById('speedValue').textContent = this.orbitSpeed.toFixed(1) + 'x';
});
// Time acceleration
document.getElementById('timeAccel').addEventListener('input', (e) => {
this.timeAcceleration = parseFloat(e.target.value);
document.getElementById('timeValue').textContent = this.timeAcceleration.toFixed(1) + 'x';
});
// Toggle controls
document.getElementById('toggleTrajectories').addEventListener('click', () => {
this.showTrajectories = !this.showTrajectories;
document.getElementById('toggleTrajectories').textContent =
this.showTrajectories ? 'Hide Trajectories' : 'Show Trajectories';
if (!this.showTrajectories) {
this.clearAllTrajectories();
}
});
document.getElementById('clearTrajectories').addEventListener('click', () => {
this.clearAllTrajectories();
});
document.getElementById('resetView').addEventListener('click', () => {
this.camera.position.set(0, 0, 30);
this.camera.lookAt(0, 0, 0);
});
}
filterSatellites(filter) {
this.satelliteObjects.forEach(sat => {
const visible = filter === 'all' || sat.userData.type === filter;
sat.visible = visible;
});
}
updateParticleSize() {
this.satelliteObjects.forEach(sat => {
if (sat !== this.selectedSatellite) {
sat.scale.set(this.particleSize, this.particleSize, this.particleSize);
}
});
}
clearAllTrajectories() {
this.trajectories.forEach((_, satId) => {
const lineKey = `trajectory_${satId}`;
const line = this.scene.getObjectByName(lineKey);
if (line) {
this.scene.remove(line);
}
this.trajectories.set(satId, []);
});
}
toRadians(degrees) {
return degrees * (Math.PI / 180);
}
animate() {
requestAnimationFrame(() => this.animate());
const time = Date.now() * 0.001 * this.orbitSpeed;
// Update satellite positions
this.satelliteObjects.forEach(satellite => {
this.updateSatellitePosition(satellite, time);
});
// Rotate Earth
this.earth.rotation.y += 0.001 * this.timeAcceleration;
// Update FPS
this.updateFPS();
this.renderer.render(this.scene, this.camera);
}
updateFPS() {
this.frameCount = (this.frameCount || 0) + 1;
const now = Date.now();
if (!this.lastFPSUpdate) {
this.lastFPSUpdate = now;
return;
}
if (now - this.lastFPSUpdate >= 1000) {
const fps = Math.round(this.frameCount * 1000 / (now - this.lastFPSUpdate));
document.getElementById('fps').textContent = fps;
this.frameCount = 0;
this.lastFPSUpdate = now;
}
}
}
// Initialize the visualizer when the page loads
window.addEventListener('load', () => {
new SatelliteVisualizer();
});
// Handle window resize
window.addEventListener('resize', () => {
const camera = window.visualizer?.camera;
const renderer = window.visualizer?.renderer;
if (camera && renderer) {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
}
});
</script>
</body>
</html>