-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuniverse.js
62 lines (46 loc) · 1.53 KB
/
universe.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
/**
* The Universe
*
* Oh if all universes were this simple =)
*
*/
import * as THREE from "three";
import { universeGrid } from "./universeGrid";
// X = red
// Y = green
// Z = blue
const axesHelper = new THREE.AxesHelper( 15 );
axesHelper.position.set(0,0,0)
export const universeProperties = {
showGrid: false,
showAxes: false,
//G: 6.67430e-11 // Gravitational constant
G: 6.67430e-11 // increasing G is a hacky way to speed up all planetary motion
}
export function initUniverse(gui, scene, renderer, camera) {
universeProperties.showGrid ? scene.add(universeGrid): null;
universeProperties.showAxes ? scene.add(axesHelper): null;
const universeFolder = gui.addFolder( 'Universe' ).close();
universeFolder.add(universeProperties, 'showGrid').name("Show Grid").onChange(v => {
universeProperties.showGrid = v
if (v === true) {
scene.add( universeGrid );
} else {
scene.remove( universeGrid );
}
renderer.render(scene, camera);
})
universeFolder.add(universeProperties, 'showGrid').name("Show Grid").onChange(v => {
universeProperties.showAxes = v
if (v === true) {
scene.add( axesHelper );
} else {
scene.remove( axesHelper );
}
renderer.render(scene, camera);
})
universeFolder.add(universeProperties, 'G').name("Gravitational constant G").onChange(v => {
universeProperties.G = v
renderer.render(scene, camera);
})
}