/
Settings.js
46 lines (39 loc) · 1.32 KB
/
Settings.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
// used to store settings changeable through GUI
var Settings = function() {
this.stepsize = 0.5;
this.movementMatrix = randomWalkMatrix(this.stepsize);
this.run = true;
this.move = false;
this.collide = false;
this.animate = true;
this.cameraPosition = 200;
this.spawningAreaSize = 8;
this.maxPop = 20000;
}
// add GUI
var settings = new Settings();
var gui = new dat.GUI();
var stepsizecontroller = gui.add(settings, 'stepsize', 0, 2);
gui.add(settings, 'run');
gui.add(settings, 'move');
gui.add(settings, 'collide');
gui.add(settings, 'animate');
var cameracontroller = gui.add(settings, 'cameraPosition', 0, 1000);
stepsizecontroller.onFinishChange(function(value) {
settings.movementMatrix = randomWalkMatrix(value);
});
cameracontroller.onFinishChange(function(value) {
camera.position.z = value;
});
gui.add(settings, 'spawningAreaSize', 1, 50);
gui.add(settings, 'maxPop', 1000, 20000);
function randomWalkMatrix(stepsize) {
return Array(
new THREE.Vector3(stepsize ,0 ,0),
new THREE.Vector3(-stepsize ,0 ,0),
new THREE.Vector3(0 ,stepsize ,0),
new THREE.Vector3(0 ,-stepsize ,0),
new THREE.Vector3(0 ,0 ,stepsize),
new THREE.Vector3(0 ,0 ,-stepsize)
);
}