Repository navigation
Expand file tree
/
Copy path0.3.html
More file actions
418 lines (363 loc) · 13.1 KB
/
Copy path0.3.html
File metadata and controls
418 lines (363 loc) · 13.1 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
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Globe 3D - Surveillance des Satellites en Direct</title>
<link href="https://cesium.com/downloads/cesiumjs/releases/1.110/Build/Cesium/Widgets/widgets.css" rel="stylesheet">
<script src="https://cesium.com/downloads/cesiumjs/releases/1.110/Build/Cesium/Cesium.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/satellite.js/4.0.0/satellite.min.js"></script>
<style>
html, body, #cesiumContainer {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
background-color: #000;
}
#hud {
position: absolute;
top: 15px;
left: 15px;
z-index: 10;
background: rgba(15, 23, 42, 0.9);
backdrop-filter: blur(10px);
color: #e2e8f0;
padding: 16px;
border-radius: 10px;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
width: 320px;
font-size: 13px;
border: 1px solid rgba(255, 255, 255, 0.1);
}
#hud h2 {
margin: 0 0 12px 0;
font-size: 16px;
color: #38bdf8;
}
.form-group {
margin-bottom: 10px;
}
label {
display: block;
margin-bottom: 4px;
color: #94a3b8;
font-size: 11px;
text-transform: uppercase;
letter-spacing: 0.5px;
}
select, input[type="text"] {
width: 100%;
background: #1e293b;
border: 1px solid #334155;
color: #fff;
padding: 7px 10px;
border-radius: 6px;
box-sizing: border-box;
font-size: 13px;
outline: none;
}
select:focus, input[type="text"]:focus {
border-color: #38bdf8;
}
.btn {
width: 100%;
background: #0284c7;
color: white;
border: none;
padding: 8px 12px;
border-radius: 6px;
cursor: pointer;
font-size: 12px;
font-weight: 500;
}
.btn:hover { background: #0369a1; }
.telemetry-box {
background: rgba(0, 0, 0, 0.35);
padding: 10px;
border-radius: 6px;
margin-top: 10px;
border-left: 3px solid #4ade80;
}
.telemetry-row {
display: flex;
justify-content: space-between;
margin-bottom: 4px;
}
.telemetry-val {
font-family: monospace;
color: #f8fafc;
font-weight: bold;
}
.badge {
display: inline-block;
width: 8px;
height: 8px;
border-radius: 50%;
margin-right: 6px;
}
.badge-sat { background: #4ade80; box-shadow: 0 0 6px #4ade80; }
</style>
</head>
<body>
<div id="cesiumContainer"></div>
<div id="hud">
<h2>🛰️ Contrôle Orbital</h2>
<div class="form-group">
<label for="groupSelect">Groupe CelesTrak</label>
<select id="groupSelect">
<option value="active">Tous les satellites actifs (~10 000+)</option>
<option value="stations">Stations Spatiales (ISS, Tiangong...)</option>
<option value="starlink">Starlink (~6 000+)</option>
<option value="weather">Satellites Météo</option>
<option value="gps-ops">Satellites GPS</option>
</select>
</div>
<div class="form-group">
<label for="searchInput">Filtrer par nom</label>
<input type="text" id="searchInput" placeholder="Ex: ISS, NOAA, STARLINK...">
</div>
<button class="btn" id="locateBtn" style="margin-bottom: 12px;">📍 Recentrer sur ma position</button>
<div class="telemetry-box">
<div style="font-weight: bold; margin-bottom: 6px; color: #38bdf8;" id="selectedSatName">
<span class="badge badge-sat"></span>Clique sur un satellite vert
</div>
<div class="telemetry-row">
<span>Total affiché :</span>
<span class="telemetry-val" id="satCount">0</span>
</div>
<div class="telemetry-row">
<span>Latitude :</span>
<span class="telemetry-val" id="satLat">--</span>
</div>
<div class="telemetry-row">
<span>Longitude :</span>
<span class="telemetry-val" id="satLon">--</span>
</div>
<div class="telemetry-row">
<span>Altitude :</span>
<span class="telemetry-val" id="satAlt">--</span>
</div>
<div class="telemetry-row">
<span>Vitesse :</span>
<span class="telemetry-val" id="satSpeed">--</span>
</div>
</div>
</div>
<script>
Cesium.Ion.defaultAccessToken = '';
const viewer = new Cesium.Viewer('cesiumContainer', {
baseLayerPicker: false,
geocoder: false,
homeButton: false,
sceneModePicker: false,
navigationHelpButton: false,
animation: false,
timeline: false,
fullscreenButton: false,
skyAtmosphere: new Cesium.SkyAtmosphere(),
globe: new Cesium.Globe()
});
// Fonds cartographiques Esri HD
viewer.imageryLayers.addImageryProvider(
new Cesium.UrlTemplateImageryProvider({
url: 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
maximumLevel: 19
})
);
viewer.imageryLayers.addImageryProvider(
new Cesium.UrlTemplateImageryProvider({
url: 'https://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer/tile/{z}/{y}/{x}',
maximumLevel: 19
})
);
viewer.scene.globe.enableLighting = true;
// Géolocalisation utilisateur
let userCoords = null;
if ("geolocation" in navigator) {
navigator.geolocation.getCurrentPosition((pos) => {
userCoords = { lon: pos.coords.longitude, lat: pos.coords.latitude };
viewer.entities.add({
position: Cesium.Cartesian3.fromDegrees(userCoords.lon, userCoords.lat, 0),
point: { pixelSize: 12, color: Cesium.Color.fromCssColorString('#38bdf8'), outlineColor: Cesium.Color.WHITE, outlineWidth: 2 },
label: {
text: "Vous êtes ici",
font: "12px sans-serif",
fillColor: Cesium.Color.WHITE,
outlineColor: Cesium.Color.BLACK,
outlineWidth: 2,
style: Cesium.LabelStyle.FILL_AND_OUTLINE,
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
pixelOffset: new Cesium.Cartesian2(0, -10)
}
});
});
}
document.getElementById('locateBtn').onclick = () => {
if (userCoords) {
viewer.camera.flyTo({
destination: Cesium.Cartesian3.fromDegrees(userCoords.lon, userCoords.lat, 3500000)
});
}
};
// Gestion des satellites
let satellitesList = [];
let selectedSatellite = null;
let pointCollection = viewer.scene.primitives.add(new Cesium.PointPrimitiveCollection());
// Label flottant pour le satellite sélectionné
const highlightEntity = viewer.entities.add({
position: Cesium.Cartesian3.ZERO,
label: {
text: '',
font: '14px sans-serif',
fillColor: Cesium.Color.YELLOW,
outlineColor: Cesium.Color.BLACK,
outlineWidth: 3,
style: Cesium.LabelStyle.FILL_AND_OUTLINE,
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
pixelOffset: new Cesium.Cartesian2(0, -12),
show: false
}
});
function parseTLE(rawText) {
const lines = rawText.split('\n').map(l => l.trim()).filter(l => l.length > 0);
const results = [];
for (let i = 0; i < lines.length; i += 3) {
if (lines[i] && lines[i + 1] && lines[i + 2]) {
try {
const satrec = satellite.twoline2satrec(lines[i + 1], lines[i + 2]);
results.push({ name: lines[i], satrec, visible: true, primitive: null });
} catch (e) {}
}
}
return results;
}
async function loadSatellitesGroup(groupName) {
const selectEl = document.getElementById('groupSelect');
selectEl.disabled = true;
document.getElementById('satCount').textContent = 'Téléchargement...';
pointCollection.removeAll();
satellitesList = [];
selectedSatellite = null;
highlightEntity.label.show = false;
resetHUD();
try {
const res = await fetch(`https://celestrak.org/NORAD/elements/gp.php?GROUP=${groupName}&FORMAT=tle`);
const rawTLE = await res.text();
satellitesList = parseTLE(rawTLE);
satellitesList.forEach(sat => {
sat.primitive = pointCollection.add({
position: Cesium.Cartesian3.ZERO,
pixelSize: 6,
color: Cesium.Color.LIME,
outlineColor: Cesium.Color.BLACK,
outlineWidth: 1,
id: sat
});
});
applySearchFilter();
updatePositions();
} catch (err) {
alert("Erreur de chargement CelesTrak.");
} finally {
selectEl.disabled = false;
}
}
function applySearchFilter() {
const query = document.getElementById('searchInput').value.trim().toUpperCase();
let count = 0;
satellitesList.forEach(sat => {
const match = sat.name.toUpperCase().includes(query);
sat.visible = match;
if (sat.primitive) sat.primitive.show = match;
if (match) count++;
});
document.getElementById('satCount').textContent = count;
}
document.getElementById('searchInput').addEventListener('input', applySearchFilter);
document.getElementById('groupSelect').addEventListener('change', (e) => loadSatellitesGroup(e.target.value));
// Sélection et mise en évidence
function selectSatellite(sat) {
// Rétablir l'ancien satellite sélectionné
if (selectedSatellite && selectedSatellite.primitive) {
selectedSatellite.primitive.color = Cesium.Color.LIME;
selectedSatellite.primitive.pixelSize = 6;
}
selectedSatellite = sat;
if (sat && sat.primitive) {
sat.primitive.color = Cesium.Color.YELLOW;
sat.primitive.pixelSize = 12; // Agrandir le point pour bien le repérer
document.getElementById('selectedSatName').innerHTML = `<span class="badge badge-sat"></span>${sat.name}`;
highlightEntity.label.text = sat.name;
highlightEntity.label.show = true;
}
}
function resetHUD() {
document.getElementById('selectedSatName').innerHTML = `<span class="badge badge-sat"></span>Clique sur un satellite vert`;
document.getElementById('satLat').textContent = '--';
document.getElementById('satLon').textContent = '--';
document.getElementById('satAlt').textContent = '--';
document.getElementById('satSpeed').textContent = '--';
}
// Gestion des clics et survols
const handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
// 1. Clic gauche : sélection avec tolérance de 6 pixels
handler.setInputAction((click) => {
// drillPick ou pick avec tolérance
const picked = viewer.scene.pick(click.position, 6, 6);
if (Cesium.defined(picked) && picked.primitive && picked.id && picked.id.satrec) {
selectSatellite(picked.id);
}
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
// 2. Survol souris : passe le curseur en pointer
handler.setInputAction((movement) => {
const picked = viewer.scene.pick(movement.endPosition, 4, 4);
if (Cesium.defined(picked) && picked.id && picked.id.satrec) {
viewer.canvas.style.cursor = 'pointer';
} else {
viewer.canvas.style.cursor = 'default';
}
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
// Calcul orbital régulier
function updatePositions() {
const now = new Date();
const gmst = satellite.gstime(now);
satellitesList.forEach(sat => {
if (!sat.visible) return;
const posVel = satellite.propagate(sat.satrec, now);
if (posVel.position) {
const geodetic = satellite.eciToGeodetic(posVel.position, gmst);
const cartesian = Cesium.Cartesian3.fromRadians(
geodetic.longitude,
geodetic.latitude,
geodetic.height * 1000
);
sat.primitive.position = cartesian;
// Mise à jour de la télémétrie si sélectionné
if (selectedSatellite === sat) {
highlightEntity.position = cartesian;
const lat = Cesium.Math.toDegrees(geodetic.latitude).toFixed(4);
const lon = Cesium.Math.toDegrees(geodetic.longitude).toFixed(4);
const alt = Math.round(geodetic.height);
document.getElementById('satLat').textContent = `${lat}°`;
document.getElementById('satLon').textContent = `${lon}°`;
document.getElementById('satAlt').textContent = `${alt.toLocaleString()} km`;
if (posVel.velocity) {
const v = posVel.velocity;
const speedKmH = Math.round(Math.sqrt(v.x**2 + v.y**2 + v.z**2) * 3600);
document.getElementById('satSpeed').textContent = `${speedKmH.toLocaleString()} km/h`;
}
}
}
});
}
setInterval(updatePositions, 1000);
viewer.camera.setView({
destination: Cesium.Cartesian3.fromDegrees(2.35, 48.85, 22000000)
});
// Chargement initial complet
loadSatellitesGroup('active');
</script>
</body>
</html>