asteroids
This commit is contained in:
parent
a4c65b53a6
commit
069a494d39
@ -114,6 +114,39 @@ earthData.planet.add(moonPivot);
|
||||
moonPivot.add(moon);
|
||||
moon.position.x = 2;
|
||||
|
||||
// --- Asteroid Belt ---
|
||||
const asteroidCount = 1500;
|
||||
const asteroidGeometry = new THREE.SphereGeometry(0.05, 8, 8); // A small sphere for asteroids
|
||||
const asteroidMaterial = new THREE.MeshStandardMaterial({ color: 0x999999, roughness: 0.9 });
|
||||
const asteroidMesh = new THREE.InstancedMesh(asteroidGeometry, asteroidMaterial, asteroidCount);
|
||||
|
||||
const beltMinRadius = 23;
|
||||
const beltMaxRadius = 28;
|
||||
const beltHeight = 1.5; // Vertical thickness
|
||||
|
||||
const dummy = new THREE.Object3D();
|
||||
const asteroidData = [];
|
||||
|
||||
for (let i = 0; i < asteroidCount; i++) {
|
||||
const radius = Math.random() * (beltMaxRadius - beltMinRadius) + beltMinRadius;
|
||||
const angle = Math.random() * Math.PI * 2;
|
||||
const y = (Math.random() - 0.5) * beltHeight;
|
||||
const orbitSpeed = (Math.random() * 0.002 + 0.0005); // Slower than Mars, faster than Jupiter
|
||||
const rotationSpeed = Math.random() * 0.05;
|
||||
|
||||
asteroidData.push({ radius, angle, y, orbitSpeed, rotationSpeed });
|
||||
|
||||
dummy.position.set(
|
||||
Math.cos(angle) * radius,
|
||||
y,
|
||||
Math.sin(angle) * radius
|
||||
);
|
||||
dummy.updateMatrix();
|
||||
asteroidMesh.setMatrixAt(i, dummy.matrix);
|
||||
}
|
||||
|
||||
scene.add(asteroidMesh);
|
||||
|
||||
|
||||
const planets = [mercuryData, venusData, earthData, marsData, jupiterData, saturnData, uranusData, neptuneData];
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user