-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
60 lines (60 loc) · 1.58 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
<html>
<head>
<meta charset="UTF-8">
<title>Rectangular Rotations</title>
<link type="text/css" rel="stylesheet" href="index.css">
<style>
.instance {
perspective: 250px;
}
#canvas {
zoom:.3
}
</style>
</head>
<body>
<div align="center" class="controls">
perspective: <input id="perspective" type="range" min="250" max="650" value="250" step="10" /> |
zoom: <input id="zoom" type="range" min=".2" max="1" value=".3" step=".1" /> |
tilt relative to face: <input id="relative" type="checkbox" checked="checked" />
</div>
<div id="canvas">
<div class="row">
<div class="instance">
<div class="rectWrap">
<div class="rect">
<div class="top"></div>
<div class="front"></div>
<div class="left"></div>
<div class="back"></div>
<div class="right"></div>
<div class="bottom"></div>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
// control the center rectangle with arrow keys
var xAngle = 0, yAngle = 0;
document.addEventListener('keydown', function(e) {
switch(e.keyCode) {
case 37: // left
yAngle -= 90;
break;
case 38: // up
xAngle += 90;
break;
case 39: // right
yAngle += 90;
break;
case 40: // down
xAngle -= 90;
break;
};
document.querySelector('.rect').style.transform = "rotateX("+xAngle+"deg) rotateY("+yAngle+"deg)";
}, false);
</script>
<script type="text/javascript" src="index.js"></script>
</body>
</html>