Spaces:
Running
Running
File size: 1,231 Bytes
78fdef7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | /**
* @file Moon.js
* @description Constructs the 3D Moon model using the provided BTC moon texture.
* Implements a dull regolith material with bump mapping for realism.
*/
const MOON_MAP = 'assets/textures/btc_moon.jpg';
export const moonGroup = new THREE.Group();
export let moonMesh;
/**
* Initializes the Moon mesh and adds it to the moonGroup.
* @returns {THREE.Group} The assembled Moon group.
*/
export function initMoon() {
const textureLoader = new THREE.TextureLoader();
// The real Moon is roughly 27% the radius of Earth.
const moonGeometry = new THREE.SphereGeometry(0.27, 64, 64);
const moonTexture = textureLoader.load(MOON_MAP);
const moonMaterial = new THREE.MeshPhongMaterial({
map: moonTexture,
bumpMap: moonTexture, // Use the diffuse map to fake crater depth shadows
bumpScale: 0.005,
shininess: 0, // Moon dust is dull and not shiny
emissive: 0xffffff,
emissiveMap: moonTexture,
emissiveIntensity: 0.20 // Brightens the dark side by exactly 20%
});
moonMesh = new THREE.Mesh(moonGeometry, moonMaterial);
moonMesh.name = "MoonMesh";
moonGroup.add(moonMesh);
return moonGroup;
}
|