-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3dtouch.html
165 lines (123 loc) · 5 KB
/
3dtouch.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
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src='js/lib/zig.js'></script>
<script src='js/lib/jquery-2.0.3.js'></script>
<script src='js/lib/three.js'></script>
<script src="js/lib/hammer.js"></script>
<script src="js/lib/hammer.fakemultitouch.js"></script>
<script src="js/lib/hammer.showtouches.js"></script>
<script src='js/THREE.mesh.prototype.js'></script>
<script src='js/User.js'></script>
<script src='js/HiddenObject.js'></script>
<script src='js/audio/Audio.js'></script>
<script src='js/audio/FileChannel.js'></script>
<script src='js/audio/OscillatorChannel.js'></script>
<script src='js/TouchArea.js'></script>
<script src='js/Explanation.js'></script>
<script src='js/Calibration.js'></script>
<script type="text/javascript">
var scene;
var audio;
var calibration = null;
var needCalibration = false;
var users = new Array();
var objects = new Array();
var mute = false;
var boundaries;
function initMain() {
document.oncontextmenu = function() { return false; };
initZig();
initThree();
initSettings();
Hammer.plugins.showTouches();
Hammer.plugins.fakeMultitouch();
touchArea = new TouchArea(document.getElementById('touch'));
explanation = new Explanation(document.getElementById('explanation'));
if (needCalibration) {
calibration = new Calibration();
} else {
document.getElementById('main').style.visibility = 'visible';
}
audio = new Audio();
audio.createChannel('left', 'oscillator', { freq: 1000, gain: 1});
audio.createChannel('right', 'oscillator', { freq: 200, gain: 1});
HiddenObject.generateObjects(
['red'], //, 'green', 'blue'],
{ x: {min: -500,max: 500},
y: {min: 0,max: 700},
z: {min: 1200,max: 1600}
}, {w: 200,h: 200,d: 200}
);
}
function initZig() {
zig.explained = false;
zig.addListener({
onuserfound: function(user) {
users.push(new User(user));
audio.start();
},
onuserlost: function(user) {
for (u in users) {
if (users[u].id == user.id) users[u].destruct();
}
}
});
}//initZig()
function initThree() {
// prepare
scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(75, (window.innerWidth / 2) / window.innerHeight, 1, 100000);
var renderer = new THREE.WebGLRenderer();
var light = new THREE.PointLight(0xFFFFFF);
// scene
//renderer.setSize( window.innerWidth/2, window.innerHeight );
renderer.setSize(document.getElementById('three').offsetWidth, document.getElementById('three').offsetHeight);
document.getElementById('three').appendChild(renderer.domElement);
// camera
camera.position.x = 0;
camera.position.y = 0;
camera.position.z = 0;
camera.lookAt(new THREE.Vector3(0, 0, 4000));
camera.rotation.z = 0 * Math.PI / 180;
// lights
light.position.set(10, 0, 10);
scene.add(light);
// action!
function render() {
requestAnimationFrame(render);
renderer.render(scene, camera);
}
render();
}//initThree()
function initSettings() {
$('#settings').on('click', 'input', function() {
channel = this.parentNode.dataset.channel;
type = this.dataset.type;
audio.channels[channel].setWaveType(type, !audio.channels[channel].waveType[type]);
});
};
document.addEventListener('DOMContentLoaded', initMain, false);
</script>
</head>
<body>
<div id="calibration">
<div id="calOne" class="calSpot">Touch me</div>
<div id="calTwo" class="calSpot">Touch me</div>
</div>
<div id="main">
<audio id="audio_red" src="audio/red.wav" preload="auto"></audio>
<audio id="audio_green" src="audio/green.wav" preload="auto"></audio>
<audio id="audio_blue" src="audio/blue.wav" preload="auto"></audio>
<audio id="audio_ping" src="audio/ping.wav" preload="auto"></audio>
<audio id="soundYe" src="audio/horse.mp3" preload="auto"></audio>
<audio id="soundNo" src="audio/buzz.mp3" preload="auto"></audio>
<div id="three"></div>
<div id="touch">
<div id="explanation"> Hi! Stand here, so that Kinect can find you </div>
</div>
<div id="settings"></div>
</div>
</body>
<link rel='stylesheet' href='style.css'>
</html>