-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlashLightController.js
More file actions
46 lines (36 loc) · 1.19 KB
/
FlashLightController.js
File metadata and controls
46 lines (36 loc) · 1.19 KB
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
"use strict";
const FlashLightController = function(obj, settings) {
const camera = settings.activeCamera;
const speed = settings.speed;
const gm = new GlMath();
const wheelListener = function(e) {
obj.intensity = obj.intensity - event.deltaY * speed;
}
window.addEventListener("wheel", wheelListener);
const keyboardListener = function(e) {
if(e.code === "NumpadAdd") {
obj.angle = obj.angle + 1.0;
if(obj.angle <= 0)
obj.angle = 0.0;
else if(obj.angle >= 60.0)
obj.angle = 60.0;
}
else if(e.code === "NumpadSubtract") {
obj.angle = obj.angle - 1.0;
if(obj.angle <= 0)
obj.angle = 0.0;
else if(obj.angle >= 60.0)
obj.angle = 60.0;
}
}
window.addEventListener("keypress", keyboardListener);
const swithFlashListener = function(e) {
if(e.code === "KeyO") {
if(obj.intensity <= 0)
obj.intensity = 300.0;
else
obj.intensity = 0.0;
}
}
window.addEventListener("keypress", swithFlashListener);
}