} // orbit lines function createOrbit(distance){ const curve = new THREE.EllipseCurve( 0,0, distance, distance, 0,2*Math.PI ); const points = curve.getPoints(100); const geo = new THREE.BufferGeometry().setFromPoints(points); const mat = new THREE.LineBasicMaterial({color:0x444444}); const orbit = new THREE.LineLoop(geo,mat); orbit.rotation.x = Math.PI/2; scene.add(orbit); } // planets createPlanet(8,80,0xb1b1b1,0.01,"Mercury",0xffffff); createPlanet(10,120,0xffcc88,0.008,"Venus",0xffaa55); createPlanet(11,160,0x3399ff,0.007,"Earth",0x66ccff); createPlanet(9,200,0xff5533,0.006,"Mars",0xff7744); createAsteroidBelt(240); createPlanet(18,300,0xffaa88,0.004,"Jupiter",0xffbb88); createPlanet(16,360,0xffddaa,0.003,"Saturn",0xffddaa); createPlanet(14,420,0x66ccff,0.002,"Uranus",0x99ddff); createPlanet(14,480,0x3366ff,0.002,"Neptune",0x6699ff); Page 1 of 4 // asteroid belt function createAsteroidBelt(radius){ for(let i=0;i<2000;i++){ const geo = new THREE.SphereGeometry(1.2,6,6); const mat = new THREE.MeshStandardMaterial({color:0x888888}); const rock = new THREE.Mesh(geo,mat); const angle = Math.random()*Math.PI*2; const dist = radius + Math.random()*40; rock.position.x = Math.cos(angle)*dist; rock.position.z = Math.sin(angle)*dist; scene.add(rock); } } // facts let paused=false; const factsData={ Mercury:["Closest planet","Smallest planet","88 day year","No moons","Extreme heat"], Venus:["Hottest planet","Rotates backward","Thick atmosphere","Volcanic","Earth size"], Earth:["Life planet","71% water","One moon","Oxygen atmosphere","Magnetic field"], Mars:["Red planet","Olympus Mons","Two moons","Dust storms","Water evidence"], Jupiter:["Largest planet","Great Red Spot","Gas giant","Many moons","Strong gravity"], Saturn:["Beautiful rings","Gas giant","Low density","Many moons","Large rings"], Uranus:["Ice giant","Sideways rotation","Very cold","Blue color","27 moons"], Neptune:["Farthest planet","Strong winds","Ice giant","Deep blue","14 moons"] }; // speech function showFacts(name){ paused=true; Page 2 of 4 const facts=factsData[name]; const div=document.getElementById("facts"); div.innerHTML="<b>"+name+"</b><br>"+facts.join("<br>"); div.style.display="block"; const speech = new SpeechSynthesisUtterance( name+" facts. "+facts.join(". ") ); speech.onend=function(){ paused=false; } speechSynthesis.speak(speech); } // double click planet const raycaster = new THREE.Raycaster(); const mouse = new THREE.Vector2(); window.addEventListener("dblclick",e=>{ mouse.x=(e.clientX/window.innerWidth)*2-1; mouse.y=-(e.clientY/window.innerHeight)*2+1; raycaster.setFromCamera(mouse,camera); const hit = raycaster.intersectObjects(planets); if(hit.length>0){ showFacts(hit[0].object.userData.name); } }); // right click stop rotation Page 3 of 4 window.addEventListener("contextmenu",function(e){ e.preventDefault(); paused = !paused; }); // animation function animate(){ requestAnimationFrame(animate); if(!paused){ planets.forEach(p=>{ p.userData.angle+=p.userData.speed; p.position.x=Math.cos(p.userData.angle)*p.userData.distance; p.position.z=Math.sin(p.userData.angle)*p.userData.distance; }); } controls.update(); renderer.render(scene,camera); } animate(); </script> </body> </html> Page 4 of 4