-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTermProject.html
More file actions
158 lines (129 loc) · 4.06 KB
/
TermProject.html
File metadata and controls
158 lines (129 loc) · 4.06 KB
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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Robot in class challenge</title>
<!-- Babylon.js -->
<script src="js/hand.minified-1.2.js"></script>
<script src="js/cannon.js"></script>
<script src="js/oimo.js"></script>
<script src="js/babylon.d.js"></script>
<script src="js/jquery-2.1.4.min.js"></script>
<script src="TermProject.js"></script>
<style>
#renderCanvas {
width: 640px;
height: 480px;
touch-action: none;
}
</style>
</head>
<body onload="main()">
<table style="width:100%">
<tr>
<td>
<canvas id="renderCanvas" height="400px"></canvas>
</td>
<td>
<table style="width:100%">
<tr style="width:100%">
<td style="width:200px">
<select name="bodypart" id="bodypart" >
<option value="lamont">Robot</option>
<option value="head">Head</option>
<option value="chest">Chest</option>
<option value="rightshoulder">Right Shoulder</option>
<option value="rightelbow">Right Elbow</option>
<option value="rightwrist">Right Wrist</option>
<option value="leftshoulder">Left Shoulder</option>
<option value="leftelbow">Left Elbow</option>
<option value="leftwrist">Left Wrist</option>
<option value="waist">Waist</option>
<option value="righthip">Right Hip</option>
<option value="rightknee">Right Knee</option>
<option value="rightankle">Right Ankle</option>
<option value="lefthip">Left Hip</option>
<option value="leftknee">Left Knee</option>
<option value="leftankle">Left Ankle</option>
</select><br>
Rot X: <input name="rotX" orien="x" type="range" value="0" max="360" min="1"
oninput="handleScroll(this);"></input><br>
Rot Y: <input name="rotY" orien="y" type="range" value="0" max="360" min="1"
oninput="handleScroll(this);"></input><br>
Rot Z: <input name="rotZ" orien="z" type="range" value="0" max="360" min="1"
oninput="handleScroll(this);"></input><br><br>
<button value="Animate" name="animButton">Animate</button>
<button value="Animate" name="stopAnimButton">Stop Animate</button>
<script>
var w = false, a = false, s = false, d = false;
var fwd = false, bwd = false, right = false, left = false;
var keycode;
onkeypress = function() {movement()};
onkeyup = function() {stop()}
function movement() {
keycode = event.keyCode;
//determine which key was pressed
if(keycode == 119){
w = true;
}
if(keycode == 115){
s = true;
}
if(keycode == 97){
a = true;
}
if(keycode == 100){
d = true;
}
//if key is pressed move in that direction
if(w){
robot.obj.position.x += .1;
}
if(s){
robot.obj.position.x -= .1;
}
if(a){
robot.obj.position.z += .1;
}
if(d){
robot.obj.position.z -= .1;
}
if(w && !fwd){
runningfwd();
fwd = true;
}
if(s){
}
if(a){
}
if(d){
}
//console.log(keycode,w,a,s,d);
}
function stop(){
keycode = event.keyCode;
if(keycode == 87){
w = false;
stopanimation();
fwd = false;
}
if(keycode == 83){
s = false;
}
if(keycode == 65){
a = false;
}
if(keycode == 68){
d = false;
}
//console.log(keycode,w,a,s,d);
}
</script>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>