Spaces:
Running
Running
Update index.html
Browse files- index.html +15 -16
index.html
CHANGED
@@ -38,16 +38,16 @@
|
|
38 |
const sun = new THREE.Mesh(sunGeometry, sunMaterial);
|
39 |
scene.add(sun);
|
40 |
|
41 |
-
// Planets with more realistic orbital
|
42 |
const planets = [
|
43 |
-
{ name: 'Mercury', distance: 10, scale: 0.2, speed: 0.00582 }, //
|
44 |
-
{ name: 'Venus', distance: 15, scale: 0.4, speed: 0.00224 },
|
45 |
-
{ name: 'Earth', distance: 20, scale: 0.5, speed: 0.00199 },
|
46 |
-
{ name: 'Mars', distance: 25, scale: 0.3, speed: 0.00106 },
|
47 |
-
{ name: 'Jupiter', distance: 35, scale: 2, speed: 0.00028 },
|
48 |
-
{ name: 'Saturn', distance: 45, scale: 1.5, speed: 0.00013 },
|
49 |
-
{ name: 'Uranus', distance: 55, scale: 1, speed: 0.00006 },
|
50 |
-
{ name: 'Neptune', distance: 65, scale: 1, speed: 0.00004 } //
|
51 |
];
|
52 |
|
53 |
planets.forEach(planet => {
|
@@ -69,17 +69,16 @@
|
|
69 |
neos.push(neo);
|
70 |
}
|
71 |
|
72 |
-
// Animation
|
73 |
-
let
|
74 |
-
function animate(
|
75 |
requestAnimationFrame(animate);
|
76 |
|
77 |
-
|
78 |
-
lastTime = time;
|
79 |
|
80 |
planets.forEach((planet, index) => {
|
81 |
const planetMesh = scene.children[3 + index];
|
82 |
-
const angle =
|
83 |
planetMesh.position.x = Math.cos(angle) * planet.distance;
|
84 |
planetMesh.position.z = Math.sin(angle) * planet.distance;
|
85 |
});
|
@@ -93,7 +92,7 @@
|
|
93 |
renderer.render(scene, camera);
|
94 |
}
|
95 |
|
96 |
-
animate(
|
97 |
|
98 |
// Fetching NEO data from NASA API
|
99 |
function fetchNEOData() {
|
|
|
38 |
const sun = new THREE.Mesh(sunGeometry, sunMaterial);
|
39 |
scene.add(sun);
|
40 |
|
41 |
+
// Planets with more realistic orbital speeds
|
42 |
const planets = [
|
43 |
+
{ name: 'Mercury', distance: 10, scale: 0.2, speed: 0.00582 }, // Fastest orbit
|
44 |
+
{ name: 'Venus', distance: 15, scale: 0.4, speed: 0.00224 },
|
45 |
+
{ name: 'Earth', distance: 20, scale: 0.5, speed: 0.00199 },
|
46 |
+
{ name: 'Mars', distance: 25, scale: 0.3, speed: 0.00106 },
|
47 |
+
{ name: 'Jupiter', distance: 35, scale: 2, speed: 0.00028 },
|
48 |
+
{ name: 'Saturn', distance: 45, scale: 1.5, speed: 0.00013 },
|
49 |
+
{ name: 'Uranus', distance: 55, scale: 1, speed: 0.00006 },
|
50 |
+
{ name: 'Neptune', distance: 65, scale: 1, speed: 0.00004 } // Slowest orbit
|
51 |
];
|
52 |
|
53 |
planets.forEach(planet => {
|
|
|
69 |
neos.push(neo);
|
70 |
}
|
71 |
|
72 |
+
// Animation with real-time movement
|
73 |
+
let time = 0;
|
74 |
+
function animate() {
|
75 |
requestAnimationFrame(animate);
|
76 |
|
77 |
+
time += 0.05; // Adjust this value for speed of animation
|
|
|
78 |
|
79 |
planets.forEach((planet, index) => {
|
80 |
const planetMesh = scene.children[3 + index];
|
81 |
+
const angle = time * planet.speed; // Use speed to set individual movement speeds
|
82 |
planetMesh.position.x = Math.cos(angle) * planet.distance;
|
83 |
planetMesh.position.z = Math.sin(angle) * planet.distance;
|
84 |
});
|
|
|
92 |
renderer.render(scene, camera);
|
93 |
}
|
94 |
|
95 |
+
animate();
|
96 |
|
97 |
// Fetching NEO data from NASA API
|
98 |
function fetchNEOData() {
|