-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
206 lines (155 loc) · 5.25 KB
/
index.html
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<html>
<head>
<title>Projecto</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript" src="webgl-utils.js"></script>
<script type="text/javascript" src="math.js"></script>
<script type="text/javascript" src="models.js"></script>
<script id="shader-fs" type="x-shader/x-fragment">
precision mediump float;
varying vec3 LightingDirection;
varying vec3 AmbientColor;
varying vec3 VN; //vertex normal
varying mat3 NMatrix;
varying vec3 DirectionalColor;
void main(void) {
vec3 vLightWeighting;
vec3 transformedNormal = NMatrix * VN;
float directionalLightWeighting = max(dot(transformedNormal, LightingDirection), 0.0);
vLightWeighting = AmbientColor + DirectionalColor * directionalLightWeighting;
gl_FragColor = vec4((1.0,1.0,1.0,1.0) * vLightWeighting, 1);
}
</script>
<script id="shader-vs" type="x-shader/x-vertex">
attribute vec3 aVertexPosition;
attribute vec3 aVertexNormal;
uniform mat4 uMVMatrix;
uniform mat4 uPMatrix;
uniform mat3 uNMatrix;
uniform vec3 uAmbientColor;
uniform vec3 uLightingDirection;
uniform vec3 uDirectionalColor;
uniform bool uUseLighting;
varying vec3 LightingDirection;
varying vec3 VN;
varying mat3 NMatrix;
varying vec3 DirectionalColor;
varying vec3 AmbientColor;
void main(void) {
NMatrix = uNMatrix;
VN = aVertexNormal;
LightingDirection = uLightingDirection;
DirectionalColor = uDirectionalColor;
AmbientColor = uAmbientColor;
gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);
}
</script>
<script type="text/javascript" src="proj.js"></script>
<style type="text/css">
div.container {
width: 100%;
/*border: 1px solid gray;*/
background-image: url("simple_background_that_will_give_us_20.jpg");
}
header, footer {
padding: 1em;
color: white;
background-color: black;
clear: left;
text-align: center;
}
nav {
float: left;
max-width: 50%;
margin: 0;
padding: 1em;
}
nav ul {
list-style-type: none;
padding: 0;
}
nav ul a {
text-decoration: none;
}
article {
margin-left: 170px;
border-left: 1px solid gray;
padding: 1em;
overflow: hidden;
}
</style>
</head>
<body onload="webGLStart();">
<div class="container">
<header>
<h1>Welcome to Fractal town - CV 2016/2017</h1>
</header>
<nav>
<br/>
Use <code>+</code>/<code>-</code> to increase/decrease recursive levels
<br/>
<br>
Drag the <code>mouse</code> on the fractal to spin
<br/>
<h2>Directional light:</h2>
<table style="border: 0; padding: 10px;">
<tr>
<td><b>Direction:</b>
<td>X: <input type="text" id="lightDirectionX" value="0.0" />
<td>Y: <input type="text" id="lightDirectionY" value="0.0" />
<td>Z: <input type="text" id="lightDirectionZ" value="1.0" />
</tr>
<tr>
<td><b>Colour:</b>
<td>R: <input type="text" id="directionalR" value="0.2" />
<td>G: <input type="text" id="directionalG" value="0.2" />
<td>B: <input type="text" id="directionalB" value="0.2" />
</tr>
</table>
<h2>Ambient light:</h2>
<table style="border: 0; padding: 10px;">
<tr>
<td><b>Colour:</b>
<td>R: <input type="text" id="ambientR" value="0.2" />
<td>G: <input type="text" id="ambientG" value="0.2" />
<td>B: <input type="text" id="ambientB" value="0.2" />
</tr>
</table>
<table style="border: 0; padding: 10px;">
<p>Rotation on X:
<button id="XX-on-off-button">On / Off</button>
<button id="XX-direction-button">Change Direction</button>
<button id="XX-slower-button">Slower</button>
<button id="XX-faster-button">Faster</button>
</p>
<p>Rotation on Y:
<button id="YY-on-off-button">On / Off</button>
<button id="YY-direction-button">Change Direction</button>
<button id="YY-slower-button">Slower</button>
<button id="YY-faster-button">Faster</button>
</p>
<p>Rotation on Z:
<button id="ZZ-on-off-button">On / Off</button>
<button id="ZZ-direction-button">Change Direction</button>
<button id="ZZ-slower-button">Slower</button>
<button id="ZZ-faster-button">Faster</button>
</p>
<button id="move-downscale-button">Downscale</button>
<button id="move-scale-button">Scale</button>
</table>
</nav>
<article>
<p>Choose the <b>Fractal</b>:
<select id="fractal">
<option value="0">Sierpinski pyramid</option>
<option value="1">Koch Snowflake 3D</option>
<option value="2">Menger Sponger</option>
<option value="3">Xadrez 3D</option>
</select>
</p>
<canvas id="AACanvas" style="border: none;" width="500" height="500"></canvas>
</article>
<footer>Álvaro Martins 72447 && André Nascimento 73152</footer>
</div>
</body>
</html>