Skip to content

Commit

Permalink
adding capitalised Earth.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
ajmas committed Nov 17, 2023
1 parent ab1d818 commit 5b014b3
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/viewer/Earth.ts
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 5b014b3

Please sign in to comment.