-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.html
119 lines (112 loc) · 2.98 KB
/
test.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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>
Balls 3D
</title>
<script type="text/javascript" src="o3djs/base.js"></script>
<script type="text/javascript" src="balls3d/b3d.js"></script>
<script type="text/javascript" src="balls3d/b3do.js"></script>
<script type="text/javascript" id="o3dscript">
function debug(s, l){
if (l === undefined) {
document.getElementById("dbg").innerHTML += s + "<br>"
}
else {
document.getElementById("dbg" + l).innerHTML = s + "<br>"
}
}
function debugh(s) {
g_debug_http.open("POST", s, true)
g_debug_http.send(null)
}
// like it says
function keyPressedCallback(event) {
event = event || window.event
var keyChar = String.fromCharCode(o3djs.event.getEventKeyChar(event))
// alert(" g_eyePosition: " + g_eyePosition)
// alert(" g_viewInfo: " + g_viewInfo)
var mat=g_viewInfo.drawContext.view
switch(keyChar) {
case '%': // left
b3do.turnCamera(0.05)
break
case "'": // right
b3do.turnCamera(-0.05)
break
case '&': // up (forward)
case 'w':
b3do.moveCamera(0.4)
break
case '(': // down (backward)
case 's':
b3do.moveCamera(-0.5)
break
case 'a': // up (forward)
b3do.slideCamera(0.5)
break
case 'd': // down (backward)
b3do.slideCamera(-0.5)
break
case '!': // page up
b3do.raiseCamera(0.5)
break
case '"': // page down
b3do.raiseCamera(-0.5)
break
case '.': //
if (g_world.is_running())
g_world.pause()
else
g_world.start()
break
case 'r':
g_b1.pos=[-1,4,0]
g_b2.pos=[1,4,0]
break
case 't':
debug("touch: " + g_b1.touchesBall(g_b2),4)
break
}
debug("key pressed-->" + keyChar + "<-- code: " + o3djs.event.getEventKeyChar(event) + " shift: "+event.shiftKey,1)
}
function main(){
/// o3d requires us to run main code in a callback, so:
/*
debug("hello I must be going")
v1 = [1,0,0]
v2 = [1,-.5,0]
a = V3.cos(v1, v2)
debug("angle: "+a
*/
b3do.run(main2)
}
function main2(){
g_world = new b3do.world(-10.0, 0.01, 0)
g_b1 = g_world.addDBall(.5, [1, 2, 0], [0, 0, 0, 1])
g_b2 = g_world.addDBall(.5, [1.25, 4, -.4], [0, 0, 0, 1],undefined,undefined,.5)
g_bx1 = g_world.addSBox([1,2,3], [0, 3, 0], [[1, 0, 0], -80])
debug("g_world: " + g_world + " gravity: " + g_world.world.gravity, 1)
debug("dynamics[0].pos: " + g_world.world.dynamics[0], 3)
}
</script>
</head>
<body onload="main()">
<h3>Balls 3D Physics Engine</h3>
Use arrow keys to navigate; pg up/dn; period
<br/>
<!-- Start of O3D plugin -->
<div id="o3d" style="width: 600px; height: 480px;"></div>
<div id="dbg0"></div>
<div id="dbg1"></div>
<div id="dbg2"></div>
<div id="dbg3"></div>
<div id="dbg4"></div>
<div id="dbg5"></div>
<div id="dbg6"></div>
<div id="dbg"></div>
<!-- End of O3D plugin -->
</body>
</html>