forked from bostongfx/cs460student_2019
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ClassIntro.html
275 lines (190 loc) · 6.96 KB
/
ClassIntro.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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>CS460 Computer Graphics at the University of Massachusetts Boston</title>
<script type="text/javascript" src="../../js/xtk_edge.js"></script>
<link rel="stylesheet" type="text/css" href="../../styles/fonts.css"/>
<style>
html, body {
background-color:#000;
margin: 0;
padding: 0;
height: 100%;
overflow: hidden !important;
font-family: din_condensed;
font-size: 18pt;
}
</style>
<script type='text/javascript'>
window.onload = function() {
// create a new test_renderer
r = new X.renderer3D();
r.init();
// UMASS BOSTON
//
// create a cube
umassboston = new X.cube();
// skin it..
umassboston.texture.file = 'umassboston.png';
// hide it for now!
umassboston.visible = false;
r.add(umassboston);
// BOSTON GFX
//
// create a cube
bostongfx = new X.cube();
// skin it..
bostongfx.texture.file = 'bostongfx.png';
// hide it for now!
bostongfx.visible = false;
r.add(bostongfx);
// setup the camera
r.camera.position = [00, 00, 60];
// .. and render it
r.render();
};
clicked = false;
window.onclick = function() {
if (clicked) return; // sometimes you click again by accident,
// and restart the animation.. let's not!
// we need user feedback, to allow the music to play..
// let's do it on click!
clicked = true;
animation();
}
function animation() {
// start the music
var music = document.getElementById('music');
music.autoplay = true;
music.load();
setTimeout(function() {
umassboston.visible = true;
}, 400);
setTimeout(function() {
umassboston.visible = false;
r.camera.position = [0, 0, -25];
bostongfx.visible = true;
}, 3200);
setTimeout(rotate_bostongfx, 6200);
};
function rotate_bostongfx() {
var rotateCounter = 0;
var spinner1 = setInterval(function(){
rotateCounter += 1;
// console.log(rotateCounter*2);
if (rotateCounter*2 >= 90) {
clearInterval(spinner1); // this is not time-based now...
bostongfx.visible = false;
// now the real CS460 logo..
create_cs460_logo();
return;
}
bostongfx.transform.rotateY(rotateCounter*2);
},100);
};
function create_cs460_logo() {
document.getElementById('caption').style.display = 'block';
// create a new X.object
cs460logo = new X.object();
// add the points, normals and colors
//
// this means 648000 / 3 == 216000 vertices
// on my work machine I could set 24000000 / 3 == 8 mio vertices
cs460logo.points = new X.triplets(648000);
cs460logo.normals = new X.triplets(648000);
cs460logo.colors = new X.triplets(648000);
// and set the type to POINTS
cs460logo.type = 'POINTS';
// create the points, normals and colors
for ( var x = 0; x < 60; x++) {
for ( var y = 0; y < 60; y++) {
for ( var z = 0; z < 60; z++) {
cs460logo.points.add(x, y, z);
cs460logo.normals.add(1, 1, 1);
cs460logo.colors.add(x/60, y/60, z/60);
}
}
}
// add the object
r.add(cs460logo);
// setup the camera
r.camera.position = [500, 500, 500];
setTimeout(zoom_into_cs460logo, 2000);
};
function zoom_into_cs460logo() {
var zoomer = setInterval(function() {
// we can stop once we are far away enough
if (r.camera.view[14] > 1000) {
clearInterval(zoomer);
// console.log('zooming done');
setTimeout(function() {
document.getElementById('caption').style.display = 'none';
start_content();
}, 2000);
return;
}
// zoom in
r.camera.zoomIn();
}, 10);
};
function start_content() {
// reduce music volume
var music = document.getElementById('music');
music.volume = .1;
// activate speech
var voice = document.getElementById('voice');
voice.autoplay = true;
voice.volume = 1;
voice.load();
frames = ['content1', 'content2', 'content3', 'content4', 'content5', null];
times = [0, // Today...
1000, //
4200, // And
6000, //
10000, // this is lecture 19
14000];
//
// this is (like the whole animation concept), a little hacky!!
//
for (var f in frames) {
setTimeout(function(f) {
if (f > 0) {
document.getElementById(frames[f-1]).style.display = 'none';
}
if (frames[f] != null) {
document.getElementById(frames[f]).style.display = 'block';
} else {
music.volume = .1;
setTimeout(function(f) {
fadeout = setInterval(function(f) {
if (music.volume <= 0.) {
clearInterval(fadeout);
return;
}
music.volume -= .05;
}, 500);
},3000);
}
}.bind(this,f), times[f]);
}
};
</script>
</head>
<body>
<div style="visibility:hidden">
<audio id='music'>
<source src="bensound-evolution.mp3">
</audio>
<audio id='voice'>
<source src="lecture23.mp3">
</audio>
</div>
<div id='caption' style='display:none;position: absolute;color:white;top:45%;left:50%;margin-left:50px;font-size:440%'>CS460</div>
<div id='content1' style='display:none;position: absolute;color:white;top:25%;left:30%;margin-left:50px;font-size:440%'>Today...</div>
<div id='content2' style='display:none;position: absolute;color:white;top:30%;left:20%;margin-left:50px;font-size:440%'>We will learn more about animations..</div>
<div id='content3' style='display:none;position: absolute;color:white;top:20%;left:10%;margin-left:50px;font-size:440%'>And...</div>
<div id='content4' style='display:none;position: absolute;color:white;top:35%;left:20%;margin-left:50px;font-size:440%'>We will talk to an emmy winning prime-time animator!</div>
<div id='content5' style='display:none;position: absolute;color:white;top:45%;left:40%;margin-left:50px;font-size:440%'>This is lecture 23.</div>
</body>
</html>