-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
102 lines (80 loc) · 2.63 KB
/
app.js
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import * as THREE from 'three';
import BaseApp from './src/js/BaseApp.js'
import Planet from './src/js/Planet.js'
import Interface from './src/js/Interface.js'
import Atmosphere from './src/js/Atmosphere.js'
import Sun from './src/js/Sun.js';
import Stars from './src/js/Stars.js';
export default class app extends BaseApp {
constructor() {
super();
// Interface (GUI)
this.interface = new Interface(this);
this.time = 0;
this.playing = false;
this.stars = new Stars(this);
super.postProcessing();
this.render();
}
loadScene(props) {
this.sceneId = props.sceneId;
// Seed
this.seed = props.seed;
props.seed = (THREE.MathUtils.seededRandom(this.seed) + 0.5); // Normalized seed between 0.5 and 1.5
switch (this.sceneId) {
case "0": this.loadScene0(props); break;
case "1": this.loadScene1(props); break;
case "2": this.loadScene2(props); break;
default: break;
}
}
// Earth-like
loadScene0(props) {
this.sun = new Sun(this);
this.planet = new Planet(this, props);
this.atmos = new Atmosphere(this, props);
this.interface.init();
this.interface.goToPlanet();
this.interface.loadHistoryInterface();
}
// Water world
loadScene1(props) {
this.sun = new Sun(this);
this.planet = new Planet(this, props);
this.atmos = new Atmosphere(this, props);
this.atmos.size = 0.04;
this.atmos.waveLengths = new THREE.Vector3(700, 530, 440);
this.playing = true;
this.interface.init();
this.interface.goToPlanetFast();
this.interface.loadBasicInterface();
this.planet.updatePlanetName("Water world");
}
// Red planet
loadScene2(props) {
this.sun = new Sun(this);
this.planet = new Planet(this, props);
this.atmos = new Atmosphere(this, props);
this.atmos.size = 0.02;
this.atmos.waveLengths = new THREE.Vector3(400, 500, 550);
this.playing = true;
this.interface.init();
this.interface.goToPlanetFast();
this.interface.loadBasicInterface();
this.planet.updatePlanetName("Not Mars");
}
render() {
super.render();
if (this.playing) {
this.time += 0.016;
}
if (this.sceneId) {
this.planet.update();
this.atmos.update();
this.sun.update();
this.stars.update();
this.interface.update();
}
}
}
new app();