-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
87 lines (79 loc) · 2.74 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
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
<html lang="en"><head>
<title>Cardboard Camera</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
margin: 0px;
overflow: hidden;
}
video{
position: absolute;
top:0;
left:0;
}
#webglviewer {
bottom: 0;
left: 0;
position: absolute;
right: 0;
top: 0;
z-index: 100;
}
#canvasToTrack{
visibility: hidden;
}
#overlay{
position: absolute;
top:0;
left:0;
z-index:9999999999;
width:100%;height:100%;
}
</style>
</head>
<body>
<div id="webglviewer"></div>
<canvas id="canvasToTrack"></canvas>
<canvas id="overlay"></canvas>
<script src="js/third-party/tracking-min.js"></script>
<script src="js/third-party/threejs/three.js"></script>
<script src="js/third-party/threejs/StereoEffect.js"></script>
<script src="js/third-party/threejs/DeviceOrientationControls.js"></script>
<script src="js/main.js"></script>
<script>
var overlayCanvas = document.getElementById('overlay');
var overlayCanvasContext = overlayCanvas.getContext('2d');
var tracker = new tracking.ColorTracker(['yellow']);
function fullscreen() {
if (container.requestFullscreen && overlayCanvas.requestFullscreen) {
container.requestFullscreen();
overlayCanvas.requestFullscreen();
} else if (container.msRequestFullscreen && overlayCanvas.msRequestFullscreen) {
container.msRequestFullscreen();
overlayCanvas.msRequestFullscreen();
} else if (container.mozRequestFullScreen && overlayCanvas.mozRequestFullScreen) {
container.mozRequestFullScreen();
overlayCanvas.mozRequestFullScreen();
} else if (container.webkitRequestFullscreen && overlayCanvas.webkitRequestFullscreen) {
container.webkitRequestFullscreen();
overlayCanvas.webkitRequestFullscreen();
}
}
overlayCanvas.addEventListener('click', fullscreen, false);
tracker.on('track', function(event) {
overlayCanvasContext.clearRect(0, 0, overlayCanvas.width, overlayCanvas.height);
event.data.forEach(function(rect) {
if (rect.color === 'custom') {
rect.color = tracker.customColor;
}
overlayCanvasContext.fillStyle = rect.color;
overlayCanvasContext.fillRect(rect.x, rect.y, rect.width, rect.height);
});
});
setInterval(function(){
tracking.track('#canvasToTrack', tracker);
},100);
</script>
</body>
</html>