broadfield-dev commited on
Commit
b79cc65
·
verified ·
1 Parent(s): f79888b

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +94 -72
index.html CHANGED
@@ -3,98 +3,120 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Solar System with NEOs</title>
7
  <style>
8
- body { margin: 0; padding: 0; background-color: #000; overflow: hidden; }
9
- canvas { display: block; }
10
  </style>
11
  </head>
12
  <body>
13
- <canvas id="solarSystemCanvas"></canvas>
14
-
15
  <script>
16
- // Setup canvas
17
- const canvas = document.getElementById('solarSystemCanvas');
18
- const ctx = canvas.getContext('2d');
19
- canvas.width = 800;
20
- canvas.height = 600;
 
21
 
22
- // Sun at the center
23
- const sun = {
24
- x: canvas.width / 2,
25
- y: canvas.height / 2,
26
- radius: 20,
27
- color: '#ffcc00'
28
- };
29
 
30
- // Planets data (simplified)
31
- const planets = [
32
- { name: 'Mercury', distance: 50, radius: 3, color: '#999999', speed: 0.01 },
33
- { name: 'Venus', distance: 70, radius: 5, color: '#ff9933', speed: 0.008 },
34
- { name: 'Earth', distance: 100, radius: 6, color: '#0066ff', speed: 0.006 },
35
- { name: 'Mars', distance: 150, radius: 4, color: '#ff3300', speed: 0.004 },
36
- { name: 'Jupiter', distance: 220, radius: 12, color: '#ff9933', speed: 0.002 },
37
- { name: 'Saturn', distance: 280, radius: 10, color: '#ffcc66', speed: 0.0015 },
38
- { name: 'Uranus', distance: 320, radius: 8, color: '#00ccff', speed: 0.001 },
39
- { name: 'Neptune', distance: 360, radius: 8, color: '#0066ff', speed: 0.0008 }
40
- ];
41
 
42
- // NEOs data (fictional and simplified)
43
- const neos = [
44
- { name: 'NEO1', distance: 110, radius: 1, color: '#cccccc', speed: 0.0055 },
45
- { name: 'NEO2', distance: 105, radius: 1, color: '#cccccc', speed: 0.0057 },
46
- { name: 'NEO3', distance: 120, radius: 1, color: '#cccccc', speed: 0.0059 },
47
- { name: 'NEO4', distance: 95, radius: 1, color: '#cccccc', speed: 0.0061 },
48
- { name: 'NEO5', distance: 115, radius: 1, color: '#cccccc', speed: 0.0063 },
49
- { name: 'NEO6', distance: 100, radius: 1, color: '#cccccc', speed: 0.0065 },
50
- { name: 'NEO7', distance: 90, radius: 1, color: '#cccccc', speed: 0.0067 },
51
- { name: 'NEO8', distance: 125, radius: 1, color: '#cccccc', speed: 0.0069 },
52
- { name: 'NEO9', distance: 130, radius: 1, color: '#cccccc', speed: 0.0071 },
53
- { name: 'NEO10', distance: 135, radius: 1, color: '#cccccc', speed: 0.0073 }
 
 
 
 
54
  ];
55
 
56
- let time = 0;
 
 
 
 
 
 
57
 
58
- function draw() {
59
- // Clear canvas
60
- ctx.fillStyle = 'black';
61
- ctx.fillRect(0, 0, canvas.width, canvas.height);
 
 
 
 
 
 
62
 
63
- // Draw Sun
64
- ctx.beginPath();
65
- ctx.arc(sun.x, sun.y, sun.radius, 0, Math.PI * 2);
66
- ctx.fillStyle = sun.color;
67
- ctx.fill();
68
 
69
- // Draw Planets
70
- planets.forEach(planet => {
71
- const angle = time * planet.speed;
72
- const x = sun.x + Math.cos(angle) * planet.distance;
73
- const y = sun.y + Math.sin(angle) * planet.distance;
74
-
75
- ctx.beginPath();
76
- ctx.arc(x, y, planet.radius, 0, Math.PI * 2);
77
- ctx.fillStyle = planet.color;
78
- ctx.fill();
79
  });
80
 
81
- // Draw NEOs
82
  neos.forEach(neo => {
83
- const angle = time * neo.speed;
84
- const x = sun.x + Math.cos(angle) * neo.distance;
85
- const y = sun.y + Math.sin(angle) * neo.distance;
86
-
87
- ctx.beginPath();
88
- ctx.arc(x, y, neo.radius, 0, Math.PI * 2);
89
- ctx.fillStyle = neo.color;
90
- ctx.fill();
91
  });
92
 
93
- time += 0.05;
94
- requestAnimationFrame(draw);
95
  }
96
 
97
- draw();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  </script>
99
  </body>
100
  </html>
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>3D Solar System with NEOs</title>
7
  <style>
8
+ body { margin: 0; overflow: hidden; }
9
+ canvas { width: 100%; height: 100%; }
10
  </style>
11
  </head>
12
  <body>
13
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
14
+ <script src="https://cdn.jsdelivr.net/npm/[email protected]/examples/js/controls/OrbitControls.js"></script>
15
  <script>
16
+ // Scene setup
17
+ const scene = new THREE.Scene();
18
+ const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
19
+ const renderer = new THREE.WebGLRenderer();
20
+ renderer.setSize(window.innerWidth, window.innerHeight);
21
+ document.body.appendChild(renderer.domElement);
22
 
23
+ // Orbit controls for camera movement
24
+ const controls = new THREE.OrbitControls(camera, renderer.domElement);
25
+ camera.position.set(0, 20, 100);
26
+ controls.update();
 
 
 
27
 
28
+ // Lights
29
+ const ambientLight = new THREE.AmbientLight(0x404040);
30
+ scene.add(ambientLight);
31
+ const pointLight = new THREE.PointLight(0xffffff);
32
+ pointLight.position.set(0, 100, 100);
33
+ scene.add(pointLight);
 
 
 
 
 
34
 
35
+ // Sun
36
+ const sunGeometry = new THREE.SphereGeometry(5, 32, 32);
37
+ const sunMaterial = new THREE.MeshBasicMaterial({ color: 0xffcc00 });
38
+ const sun = new THREE.Mesh(sunGeometry, sunMaterial);
39
+ scene.add(sun);
40
+
41
+ // Planets
42
+ const planets = [
43
+ { name: 'Mercury', distance: 10, scale: 0.2 },
44
+ { name: 'Venus', distance: 15, scale: 0.4 },
45
+ { name: 'Earth', distance: 20, scale: 0.5 },
46
+ { name: 'Mars', distance: 25, scale: 0.3 },
47
+ { name: 'Jupiter', distance: 35, scale: 2 },
48
+ { name: 'Saturn', distance: 45, scale: 1.5 },
49
+ { name: 'Uranus', distance: 55, scale: 1 },
50
+ { name: 'Neptune', distance: 65, scale: 1 }
51
  ];
52
 
53
+ planets.forEach(planet => {
54
+ const geometry = new THREE.SphereGeometry(planet.scale, 32, 32);
55
+ const material = new THREE.MeshPhongMaterial({ color: Math.random() * 0xffffff });
56
+ const mesh = new THREE.Mesh(geometry, material);
57
+ mesh.position.x = planet.distance;
58
+ scene.add(mesh);
59
+ });
60
 
61
+ // NEOs (fictional for now, will update with real data)
62
+ let neos = [];
63
+ for (let i = 0; i < 10; i++) {
64
+ const geometry = new THREE.SphereGeometry(0.1, 32, 32);
65
+ const material = new THREE.MeshBasicMaterial({ color: 0xcccccc });
66
+ const neo = new THREE.Mesh(geometry, material);
67
+ neo.position.set(Math.random() * 30 - 15, Math.random() * 10 - 5, Math.random() * 30 - 15);
68
+ scene.add(neo);
69
+ neos.push(neo);
70
+ }
71
 
72
+ // Animation
73
+ function animate() {
74
+ requestAnimationFrame(animate);
 
 
75
 
76
+ planets.forEach((planet, index) => {
77
+ const planetMesh = scene.children[3 + index];
78
+ planetMesh.position.x = Math.cos(Date.now() * 0.001 * (index + 1)) * planet.distance;
79
+ planetMesh.position.z = Math.sin(Date.now() * 0.001 * (index + 1)) * planet.distance;
 
 
 
 
 
 
80
  });
81
 
 
82
  neos.forEach(neo => {
83
+ neo.position.x += Math.sin(Date.now() * 0.001) * 0.1;
84
+ neo.position.z += Math.cos(Date.now() * 0.001) * 0.1;
 
 
 
 
 
 
85
  });
86
 
87
+ controls.update();
88
+ renderer.render(scene, camera);
89
  }
90
 
91
+ animate();
92
+
93
+ // Fetching NEO data from NASA API
94
+ function fetchNEOData() {
95
+ fetch('https://api.nasa.gov/neo/rest/v1/feed?start_date=2025-02-18&end_date=2025-02-19&api_key=DEMO_KEY')
96
+ .then(response => response.json())
97
+ .then(data => {
98
+ // Update NEOs with real data
99
+ const neoData = data.near_earth_objects['2025-02-18'];
100
+ if (neoData) {
101
+ neos.forEach((neo, index) => {
102
+ if (index < neoData.length) {
103
+ const obj = neoData[index];
104
+ // Note: This is a very simplistic representation. Real trajectory calculation would require more complex physics.
105
+ neo.position.set(
106
+ obj.close_approach_data[0].miss_distance.astronomical * 100 - 50,
107
+ obj.close_approach_data[0].miss_distance.astronomical * 50,
108
+ obj.close_approach_data[0].miss_distance.astronomical * 100 - 50
109
+ );
110
+ }
111
+ });
112
+ }
113
+ }).catch(error => console.error('Error fetching NEO data:', error));
114
+ }
115
+
116
+ // Update NEO data periodically
117
+ fetchNEOData(); // Initial fetch
118
+ setInterval(fetchNEOData, 3600000); // Update every hour
119
+
120
  </script>
121
  </body>
122
  </html>