From 5b014b301c6c047eb92f183eb192cb4fccf99021 Mon Sep 17 00:00:00 2001 From: Andre-John Mas Date: Fri, 17 Nov 2023 15:27:57 -0500 Subject: [PATCH] adding capitalised Earth.ts --- src/viewer/Earth.ts | 47 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/viewer/Earth.ts diff --git a/src/viewer/Earth.ts b/src/viewer/Earth.ts new file mode 100644 index 0000000..e284047 --- /dev/null +++ b/src/viewer/Earth.ts @@ -0,0 +1,47 @@ +import { Color, TextureLoader, MeshPhongMaterial, SphereGeometry, Mesh, Group } from '../utils/three'; +import SceneComponent from './interfaces/SceneComponent'; +import SatelliteOrbitScene from './SatelliteOrbitScene'; + +class Earth implements SceneComponent { + basePath = '/StuffInSpace/images'; + radiusInKm = 6371.0; + pxToRadius = 3185.5; + + sphere: Mesh | undefined = undefined; + group: Group | undefined = undefined; + + + init (scene: SatelliteOrbitScene) { + const dayTexture = new TextureLoader().load(`${this.basePath}/earth-blue-marble.jpg`); + const nightTexture = new TextureLoader().load(`${this.basePath}/nightearth-4096.png`); + const bumpTexture = new TextureLoader().load(`${this.basePath}/earth-topology.png`); + const earthSpecularMap = new TextureLoader().load(`${this.basePath}/earth-water.png`); + + const dayMaterial = new MeshPhongMaterial({ + map: dayTexture, + bumpMap: bumpTexture, + emissiveMap: nightTexture, + emissive: new Color(0x888888), + emissiveIntensity: 5, + specularMap: earthSpecularMap, + specular: 1, + shininess: 15, + bumpScale: 1 + }); + + const radius = scene.km2pixels(this.radiusInKm); + const geometry = new SphereGeometry(radius, 32, 32); + this.sphere = new Mesh( geometry, dayMaterial ); + scene.add(this.sphere); + } + + update (): void { + // do nothing + } + + getMesh () { + return this.sphere; + } +} + +export default Earth; \ No newline at end of file