-
Notifications
You must be signed in to change notification settings - Fork 0
/
help.js
146 lines (115 loc) · 4.97 KB
/
help.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
142
143
144
function openPopup() {
document.getElementById('test').style.display = 'block';
}
function closePopup() {
document.getElementById('test').style.display = 'none';
}
function requestCORSIfNotSameOrigin(img, url) {
if ((new URL(url)).origin !== window.location.origin) {
img.crossOrigin = "";
}
}
function getTexture(image_URL){
var image=new Image();
image["webGLTexture"] = false;
requestCORSIfNotSameOrigin(image, image_URL);
image.onload=function(e) {
var texture=gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
gl.generateMipmap(gl.TEXTURE_2D);
gl.bindTexture(gl.TEXTURE_2D, null);
image["webGLTexture"] = texture;
};
image.src=image_URL;
return image;
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function read_prop(obj, prop) {
return obj[prop];
}
/**
* The function used to display the menu with the objects when clicking on the menu on the left side.
**/
function openFurniture(roomStyle) {
if (roomStyle == 1) {
if (document.getElementById("bedroom").style.display == "block") document.getElementById("bedroom").style.display="none"
else
document.getElementById("bedroom").style.display="block";}
else if (roomStyle == 2) {
if (document.getElementById("living-room").style.display == "block") document.getElementById("living-room").style.display="none"
else
document.getElementById("living-room").style.display="block";}
else if (roomStyle == 3) {
if (document.getElementById("kitchen").style.display == "block") document.getElementById("kitchen").style.display="none"
else
document.getElementById("kitchen").style.display="block";}
else if (roomStyle == 4) {
if (document.getElementById("decor").style.display == "block") document.getElementById("decor").style.display="none"
else
document.getElementById("decor").style.display="block";}
else if (roomStyle == 5) {
if (document.getElementById("office").style.display == "block") document.getElementById("office").style.display="none"
else
document.getElementById("office").style.display="block";}
else if (roomStyle == 6) {
if (document.getElementById("childroom").style.display == "block") document.getElementById("childroom").style.display="none"
else
document.getElementById("childroom").style.display="block";}
}
//The function for the button to set the view on top
function topView() {
angle = 0.0;
elevation = -90.0;
}
//The function for the button to reset the view
function resetView() {
elevation = -25;
angle = -15;
lookRadius = 10.0;
}
//The button used to disable or enable collision
function disableCollision() {
if (collisionDisabled == false) {
collisionDisabled = true;
document.getElementById("disable-collision").innerHTML = "enable collision";
}
else if (collisionDisabled == true) {
collisionDisabled = false;
document.getElementById("disable-collision").innerHTML = "disable collision";
}
}
function radToDeg(r) {
return r * 180 / Math.PI;
}
function degToRad(d) {
return d * Math.PI / 180;
}
//Called when the slider for texture influence is changed
function updateTextureInfluence(val){
textureInfluence = val;
}
function updateLightType(val){
currentLightType = parseInt(val);
}
function updateShader(val){
currentShader = parseInt(val);
}
function updateAmbientLightInfluence(val){
ambientLightInfluence = val;
}
function updateEmitInfluence(val){
emitInfluence = val;
}
function updateAmbientLightColor(val){
val = val.replace('#','');
ambientLightColor[0] = parseInt(val.substring(0,2), 16) / 255;
ambientLightColor[1] = parseInt(val.substring(2,4), 16) / 255;
ambientLightColor[2] = parseInt(val.substring(4,6), 16) / 255;
ambientLightColor[3] = 1.0;
}