-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwatcher.html
59 lines (43 loc) · 1.41 KB
/
watcher.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
<html>
<head>
</head>
<body>
<script src="http://threejs.org/build/three.min.js"></script>
<script src="/socket.io/socket.io.js"></script>
<script src="/network/three-packets.js"></script>
<script>
var socket = io.connect('http://localhost');
socket.on('init', function (data) {
socket.emit('my other event', { my: 'data' });
});
socket.on('move',function(data){
console.log('receiving move');
packetizer.updateMeshFromPacket(mesh, data);
animate();
});
</script>
<script>
var camera, scene, renderer;
var geometry, material, mesh;
init();
animate();
function init() {
camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 10000 );
camera.position.z = 1000;
scene = new THREE.Scene();
geometry = new THREE.CubeGeometry( 200, 200, 200 );
material = new THREE.MeshBasicMaterial( { color: 0xff0000, wireframe: true } );
mesh = new THREE.Mesh( geometry, material );
scene.add( mesh );
renderer = new THREE.CanvasRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
}
function animate() {
// note: three.js includes requestAnimationFrame shim
requestAnimationFrame( animate );
renderer.render( scene, camera );
}
</script>
</body>
</html>