broadfield-dev commited on
Commit
32d34db
·
verified ·
1 Parent(s): 824c1ab

Update index.html

Browse files
Files changed (1) hide show
  1. 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 periods
42
  const planets = [
43
- { name: 'Mercury', distance: 10, scale: 0.2, speed: 0.00582 }, // ~88 Earth days
44
- { name: 'Venus', distance: 15, scale: 0.4, speed: 0.00224 }, // ~225 Earth days
45
- { name: 'Earth', distance: 20, scale: 0.5, speed: 0.00199 }, // ~365 Earth days
46
- { name: 'Mars', distance: 25, scale: 0.3, speed: 0.00106 }, // ~687 Earth days
47
- { name: 'Jupiter', distance: 35, scale: 2, speed: 0.00028 }, // ~11.86 Earth years
48
- { name: 'Saturn', distance: 45, scale: 1.5, speed: 0.00013 }, // ~29.46 Earth years
49
- { name: 'Uranus', distance: 55, scale: 1, speed: 0.00006 }, // ~84 Earth years
50
- { name: 'Neptune', distance: 65, scale: 1, speed: 0.00004 } // ~164.8 Earth years
51
  ];
52
 
53
  planets.forEach(planet => {
@@ -69,17 +69,16 @@
69
  neos.push(neo);
70
  }
71
 
72
- // Animation
73
- let lastTime = 0;
74
- function animate(time) {
75
  requestAnimationFrame(animate);
76
 
77
- const deltaTime = time - lastTime;
78
- lastTime = time;
79
 
80
  planets.forEach((planet, index) => {
81
  const planetMesh = scene.children[3 + index];
82
- const angle = planet.speed * time * 0.001; // Adjust speed for real-time simulation
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(0);
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() {