-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuserControls.js
executable file
·76 lines (61 loc) · 2.11 KB
/
userControls.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
var scenes = {
'scene1': scene1,
'scene2': scene2,
'scene3': scene3,
'scene4': scene4
};
scene = scene1;
var antialiasingMode = document.getElementById('antialiasingMode'),
reflectionDepth = document.getElementById('reflectionDepth'),
sceneSelect = document.getElementById('scene'),
resolutionSelect = document.getElementById('cameraResolution');
for (var s in scenes) {
if (scenes[s] == scene)
sceneSelect.value = s;
}
resolutionSelect.value = scene.resolution.toString();
antialiasingMode.value = scene.camera.antialiasingMode;
reflectionDepth.value = scene.reflectionDepth;
sceneSelect.onchange = function (e) {
scene = scenes[sceneSelect.value];
imageBuffer = scene.buffer;
antialiasingMode.value = scene.camera.antialiasingMode;
reflectionDepth.value = scene.reflectionDepth;
setupLights();
}
resolutionSelect.onchange = function (e) {
scene.setResolution(parseInt(resolutionSelect.value));
imageBuffer = scene.buffer;
// hard reset
main();
}
reflectionDepth.onchange = function (e) {
scene.reflectionDepth = reflectionDepth.value;
}
antialiasingMode.onchange = function (e) {
scene.antialiasingMode = antialiasingMode.value;
}
var setupLights = function () {
var lctrls = document.getElementById('lights').children;
for (var i = 0; i < lctrls.length; i++) {
lctrls[i].disabled = true;
}
for (var l = 1; (l <= 2) && (l <= scene.lights.length); l ++){
var light = scene.lights[l-1];
var lightOnOff = document.getElementById('light' + l + 'on');
var lightX = document.getElementById('light' + l + 'x');
var lightY = document.getElementById('light' + l + 'y');
var lightZ = document.getElementById('light' + l + 'z');
lightOnOff.disabled = lightX.disabled = lightY.disabled = lightZ.disabled = false;
lightX.value = light.position[0];
lightY.value = light.position[1];
lightZ.value = light.position[2];
lightOnOff.onclick = function () {
light.on = !light.on;
}
lightX.onchange = lightY.onchange = lightZ.onchange = function () {
vec3.set(light, lightX.value, lightY.value, lightZ.value);
}
}
}
setupLights();