forked from powermobileweb/ARFaceFilter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
executable file
·69 lines (65 loc) · 2.04 KB
/
main.js
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
"use strict";
function callbackMove(mv){ //called each time a head movement is detected
if (PACMAN){
PACMAN.update_mv(mv);
}
}
//entry point :
function main(){
pacmanStart(headControlStart);
}
function pacmanStart(callback){
var el = document.getElementById("pacman");
if (Modernizr.canvas && Modernizr.localstorage &&
Modernizr.audio && (Modernizr.audio.ogg || Modernizr.audio.mp3)) {
window.setTimeout(function () {
PACMAN.init(el, "./");
callback();
}, 0);
} else {
el.innerHTML = "Sorry, needs a decent browser<br /><small>" +
"(firefox 3.6+, Chrome 4+, Opera 10+ and Safari 4+)</small>";
}
}
function headControlStart(){
HeadControls.init({
settings: {
tol: {
rx: 1,//do not move if head turn more than this value (in degrees) from head rest position
ry: 3,
s: 5 //do not move forward/backward if head is larger/smaller than this percent from the rest position
},
sensibility: {
rx: 1.5,
ry: 1,
s: 1
}
},
canvasId: 'headControlsCanvas',
callbackMove: callbackMove,
callbackReady: function(errCode){
if (errCode){
switch(errCode){
case 'WEBCAM_UNAVAILABLE':
alert('Cannot found or use the webcam. You should accept to share the webcam bro otherwise we cannot detect your face !');
break;
}
console.log('ERROR : HEAD CONTROLS NOT READY. errCode =', errCode);
} else {
console.log('INFO : HEAD CONTROLS ARE READY :)');
HeadControls.toggle(true);
var domStartButton=document.getElementById('start');
domStartButton.style.display='inline-block';
domStartButton.onclick=function(){
if (PACMAN){
HeadControls.reset_restHeadPosition();
PACMAN.start();
domStartButton.style.display='none';
}
}
}
},
NNCpath: '../../dist/', //where to find NNC.json from the current path
animateDelay: 2 //avoid DOM lags
}); //end HeadControls.init params
}