-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyInterface.js
141 lines (119 loc) · 4.22 KB
/
MyInterface.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/**
* MyInterface class, creating a GUI interface.
* @constructor
*/
class MyInterface extends CGFinterface {
constructor() {
super();
}
/**
* Initializes the interface.
* @param {CGFapplication} application
*/
init(application) {
super.init(application);
// init GUI. For more information on the methods, check:
// http://workshop.chromeexperiments.com/examples/gui
this.gui = new dat.GUI();
this.gui.close();
// add a group of controls (and open/expand by default)
this.initKeys();
return true;
}
/**
* Keyboard Initialization
*/
initKeys() {
this.scene.gui=this;
this.processKeyboard=function(){};
this.activeKeys={};
}
/**
* Init Interface Cameras
*/
initInterfaceCameras() {
this.cameras = this.gui.addFolder('Cameras');
this.camItem = this.cameras.add(this.scene, 'selectedView', this.scene.graph[this.scene.selectedTheme].viewIDs).name('Camera View').onChange(
this.scene.updateInterfaceCameras.bind(this.scene)
);
}
/**
* Update Interface Cameras
*/
updateCameras() {
this.cameras.remove(this.camItem);
this.camItem = this.cameras.add(this.scene, 'selectedView', this.scene.graph[this.scene.selectedTheme].viewIDs).name('Camera View').onChange(
this.scene.updateInterfaceCameras.bind(this.scene)
);
}
/**
* Init Interface Lights
*/
initInterfaceLights() {
this.lights = this.gui.addFolder('Lights');
this.lightsItems = [];
for (const light of this.scene.lights) {
if (light.light_id != undefined) {
this.lightsItems.push(this.lights.add(light, 'enabled').name(light.light_id).onChange(
() => {
light.update();
}
));
}
}
}
updateLights() {
for (const light of this.lightsItems) {
this.lights.remove(light);
}
this.lightsItems = [];
console.log(this.lightsItems);
console.log(this.scene.lights);
for (const light of this.scene.lights) {
if (light.light_id != undefined) {
this.lightsItems.push(this.lights.add(light, 'enabled').name(light.light_id).onChange(
() => {
light.update();
}
));
}
}
}
/**
* Init Interface Music
*/
initMiscellaneous() {
this.misc = this.gui.addFolder('Miscellaneous');
this.misc.add(this.scene, 'musicActive').name('Sound').onChange(this.scene.updateMusic.bind(this.scene));
}
/**
* Init Interface Themes
*/
initInterfaceThemes() {
this.themes = this.gui.addFolder('Themes');
this.themes.add(this.scene, 'selectedTheme', this.scene.textureIds).name('Selected SkyBox Texture').onChange(this.scene.updateThemes.bind(this.scene));
}
/**
* Init Game Interface
*/
initGameInterface() {
this.gameInterface = this.gui.addFolder('Game');
this.gameInterface.add(this.scene.gameOrchestrator, 'reset').name('Reset / New Game');
this.gameInterface.add(this.scene.gameOrchestrator, 'movie').name('Movie');
this.gameInterface.add(this.scene.gameOrchestrator, 'undo').name('Undo');
this.gameInterface.add(this.scene.gameOrchestrator, 'timeout', 10, 120).name('TimeOut');
this.gameInterface.add(this.scene.gameOrchestrator, 'boardSize', {'Small': '7', 'Medium': '9', 'Large': '11'}).name('Board Size');
this.gameInterface.add(this.scene.gameOrchestrator, 'player1', { 'Player': '1', 'Random Bot': '2', 'Intelligent Bot': '3' }).name("White Player");
this.gameInterface.add(this.scene.gameOrchestrator, 'player2', { 'Player': '1', 'Random Bot': '2', 'Intelligent Bot': '3' }).name("Black Player");
this.gameInterface.open();
}
processKeyDown(event) {
this.activeKeys[event.code]=true;
};
processKeyUp(event) {
this.activeKeys[event.code]=false;
};
isKeyPressed(keyCode) {
return this.activeKeys[keyCode] || false;
}
}