-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyInterface.js
83 lines (68 loc) · 1.84 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
/**
* MyInterface class, creating a GUI interface.
*/
class MyInterface extends CGFinterface {
/**
* @constructor
*/
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();
// add a group of controls (and open/expand by default)
this.initKeys();
return true;
}
/**
* initKeys
*/
initKeys() {
this.scene.gui=this;
this.processKeyboard=function(){};
this.activeKeys={};
}
/**
* Init Interface Cameras
*/
initInterfaceCameras() {
this.cameras = this.gui.addFolder('Cameras');
this.cameras.add(this.scene, 'selectedView', this.scene.viewIDs).name('Camera View').onChange(
() => {
this.scene.camera = this.scene.graph.cameras[this.scene.selectedView];
this.setActiveCamera(this.scene.camera);
}
);
}
/**
* Init Interface Lights
*/
initInterfaceLights() {
this.lights = this.gui.addFolder('Lights');
for (const light of this.scene.lights) {
if (light.light_id != undefined) {
this.lights.add(light, 'enabled').name(light.light_id).onChange(
() => {
light.update();
}
);
}
}
}
processKeyDown(event) {
this.activeKeys[event.code]=true;
};
processKeyUp(event) {
this.activeKeys[event.code]=false;
};
isKeyPressed(keyCode) {
return this.activeKeys[keyCode] || false;
}
}