select
This commit is contained in:
parent
c8e8c06fa2
commit
1922e61d1c
@ -30,6 +30,7 @@ canvas {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
|
margin-bottom: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#stats-buttons button:hover {
|
#stats-buttons button:hover {
|
||||||
|
|||||||
@ -63,9 +63,9 @@ const segments = 128;
|
|||||||
const orbitMaterial = new THREE.LineBasicMaterial({ color: 0xffffff, opacity: 0.5, transparent: true });
|
const orbitMaterial = new THREE.LineBasicMaterial({ color: 0xffffff, opacity: 0.5, transparent: true });
|
||||||
|
|
||||||
function createPlanet(radius, textureFile, distance, orbitSpeed) {
|
function createPlanet(radius, textureFile, distance, orbitSpeed) {
|
||||||
const texture = textureLoader.load(`assets/textures/${textureFile}`);
|
const texture = textureLoader.load(`assets/textures/${textureFile}?v=${Date.now()}`);
|
||||||
const geometry = new THREE.SphereGeometry(radius, 32, 32);
|
const geometry = new THREE.SphereGeometry(radius, 32, 32);
|
||||||
const material = new THREE.MeshBasicMaterial({ map: texture });
|
const material = new THREE.MeshBasicMaterial({ map: texture }); // Reverted
|
||||||
const planet = new THREE.Mesh(geometry, material);
|
const planet = new THREE.Mesh(geometry, material);
|
||||||
|
|
||||||
const pivot = new THREE.Object3D();
|
const pivot = new THREE.Object3D();
|
||||||
@ -159,6 +159,22 @@ const planetData = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// --- Selection Outline ---
|
||||||
|
let outlineMesh;
|
||||||
|
const outlineMaterial = new THREE.MeshBasicMaterial({ color: 0xffff00, side: THREE.BackSide });
|
||||||
|
const outlineScale = 1.15;
|
||||||
|
|
||||||
|
function setOutline(object) {
|
||||||
|
if (outlineMesh && outlineMesh.parent) {
|
||||||
|
outlineMesh.parent.remove(outlineMesh);
|
||||||
|
}
|
||||||
|
|
||||||
|
outlineMesh = new THREE.Mesh(object.geometry, outlineMaterial);
|
||||||
|
outlineMesh.scale.set(outlineScale, outlineScale, outlineScale);
|
||||||
|
object.add(outlineMesh);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Stats Panel
|
// Stats Panel
|
||||||
const statsInfo = document.getElementById('stats-info');
|
const statsInfo = document.getElementById('stats-info');
|
||||||
const statsButtons = document.getElementById('stats-buttons');
|
const statsButtons = document.getElementById('stats-buttons');
|
||||||
@ -178,31 +194,42 @@ function updateStats(planetUUID) {
|
|||||||
statsButtons.addEventListener('click', (event) => {
|
statsButtons.addEventListener('click', (event) => {
|
||||||
if (event.target.tagName === 'BUTTON') {
|
if (event.target.tagName === 'BUTTON') {
|
||||||
const planetName = event.target.dataset.planet;
|
const planetName = event.target.dataset.planet;
|
||||||
let planetUUID;
|
let planetObject, planetUUID;
|
||||||
|
|
||||||
statsButtons.querySelectorAll('button').forEach(btn => btn.classList.remove('active'));
|
statsButtons.querySelectorAll('button').forEach(btn => btn.classList.remove('active'));
|
||||||
event.target.classList.add('active');
|
event.target.classList.add('active');
|
||||||
|
|
||||||
if (planetName === 'earth') {
|
if (planetName === 'earth') {
|
||||||
|
planetObject = earthData.planet;
|
||||||
planetUUID = earthData.planet.uuid;
|
planetUUID = earthData.planet.uuid;
|
||||||
} else if (planetName === 'mercury') {
|
} else if (planetName === 'mercury') {
|
||||||
|
planetObject = mercuryData.planet;
|
||||||
planetUUID = mercuryData.planet.uuid;
|
planetUUID = mercuryData.planet.uuid;
|
||||||
} else if (planetName === 'venus') {
|
} else if (planetName === 'venus') {
|
||||||
|
planetObject = venusData.planet;
|
||||||
planetUUID = venusData.planet.uuid;
|
planetUUID = venusData.planet.uuid;
|
||||||
} else if (planetName === 'mars') {
|
} else if (planetName === 'mars') {
|
||||||
|
planetObject = marsData.planet;
|
||||||
planetUUID = marsData.planet.uuid;
|
planetUUID = marsData.planet.uuid;
|
||||||
} else if (planetName === 'jupiter') {
|
} else if (planetName === 'jupiter') {
|
||||||
|
planetObject = jupiterData.planet;
|
||||||
planetUUID = jupiterData.planet.uuid;
|
planetUUID = jupiterData.planet.uuid;
|
||||||
} else if (planetName === 'saturn') {
|
} else if (planetName === 'saturn') {
|
||||||
|
planetObject = saturnData.planet;
|
||||||
planetUUID = saturnData.planet.uuid;
|
planetUUID = saturnData.planet.uuid;
|
||||||
} else if (planetName === 'uranus') {
|
} else if (planetName === 'uranus') {
|
||||||
|
planetObject = uranusData.planet;
|
||||||
planetUUID = uranusData.planet.uuid;
|
planetUUID = uranusData.planet.uuid;
|
||||||
} else if (planetName === 'neptune') {
|
} else if (planetName === 'neptune') {
|
||||||
|
planetObject = neptuneData.planet;
|
||||||
planetUUID = neptuneData.planet.uuid;
|
planetUUID = neptuneData.planet.uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (planetUUID) {
|
if (planetUUID) {
|
||||||
updateStats(planetUUID);
|
updateStats(planetUUID);
|
||||||
|
if (planetObject) {
|
||||||
|
setOutline(planetObject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -210,6 +237,7 @@ statsButtons.addEventListener('click', (event) => {
|
|||||||
// Display Earth's stats by default and set button to active
|
// Display Earth's stats by default and set button to active
|
||||||
updateStats(earthData.planet.uuid);
|
updateStats(earthData.planet.uuid);
|
||||||
statsButtons.querySelector('button[data-planet="earth"]').classList.add('active');
|
statsButtons.querySelector('button[data-planet="earth"]').classList.add('active');
|
||||||
|
setOutline(earthData.planet); // Initial outline for Earth
|
||||||
|
|
||||||
|
|
||||||
// Animation loop
|
// Animation loop
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user