Skip to content

Commit

Permalink
New sounds, better code.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrevicenzi committed Jul 1, 2015
1 parent 8a44579 commit f15f5df
Show file tree
Hide file tree
Showing 9 changed files with 160 additions and 251 deletions.
1 change: 0 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"tests"
],
"dependencies": {
"underscore-min": "http://underscorejs.org/underscore-min.js",
"jquery-2.1.4.min": "http://code.jquery.com/jquery-2.1.4.min.js",
"leap-0.6.4.min": "http://js.leapmotion.com/leap-0.6.4.min.js",
"leap-plugins-0.1.10.min": "http://js.leapmotion.com/leap-plugins-0.1.10.min.js",
Expand Down
15 changes: 5 additions & 10 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ gulp.task('vendor', function() {
gulp.task('main', function() {
gulp.src([
'js/leap-extras.js',
'js/threejs-position.js',
'js/marionette-drawer.js',
'js/app.js'
])
Expand All @@ -27,14 +26,10 @@ gulp.task('main', function() {
.pipe(gulp.dest('dist/js'));
});

gulp.task('model', function() {
gulp.src(['models/*.json'])
.pipe(gulp.dest('dist/models'));
});

gulp.task('img', function() {
gulp.src(['images/*.png'])
.pipe(gulp.dest('dist/images'));
gulp.task('cp', function() {
gulp.src(['models/*.json']).pipe(gulp.dest('dist/models'));
gulp.src(['images/*.png']).pipe(gulp.dest('dist/images'));
gulp.src(['sounds/*.mp3']).pipe(gulp.dest('dist/sounds'));
});

gulp.task('css', function() {
Expand All @@ -56,4 +51,4 @@ gulp.task('replace', function() {

gulp.task('js', ['vendor', 'main']);

gulp.task('default', ['js', 'css', 'replace', 'model', 'img']);
gulp.task('default', ['js', 'css', 'replace', 'cp']);
22 changes: 14 additions & 8 deletions js/app.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,38 @@
var drawer;

function rotateRadian(radian){
if (radian < 0) {
return radian - Math.PI;
} else {
return radian + Math.PI;
}
}

function moveObject(hand) {
if (hand && (hand.timeVisible > 0.25) && (hand.confidence > 0.7)) {
var pitch = hand.pitch(),
roll = hand.roll(),
yaw = hand.yaw(),
roll = hand.roll() * -1,
yaw = hand.yaw() * -1,
p = {
x: hand.stabilizedPalmPosition[0],
y: hand.stabilizedPalmPosition[1],
z: hand.stabilizedPalmPosition[2]
};

drawer.moveObject(hand.type, p.x, p.y, p.z);
drawer.rotateObject(hand.type, pitch * -1, yaw, roll);
drawer.rotateObject(hand.type, pitch, rotateRadian(yaw), roll);
}
}

$(document).ready(function () {
drawer = new MarionetteDrawer();
drawer.init(document.getElementById('container'));
drawer.addScenario();
drawer.setup();
drawer.setupStats();
drawer.setBackground();
drawer.animate();

var controller = new Leap.Controller();

console.log(drawer.scene);

controller.use('screenPosition', {
scale: 0.25
})
Expand All @@ -37,7 +44,6 @@ $(document).ready(function () {
arm: false
});


controller.on('frame', function (frame) {
moveObject(frame.getLeftHand());
moveObject(frame.getRightHand());
Expand Down
24 changes: 2 additions & 22 deletions js/leap-extras.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,13 @@ Leap.Controller.plugin('leapExtras', function() {

return {
frame: {
getHandsCount: function () {
return this.hands.length;
},

getFingersCount: function () {
return _.reduce(this.hands, function (memo, hand) {
return memo + hand.fingers.length;
}, 0);
},

getExtendedFingersCount: function () {
return _.reduce(this.hands, function (memo, hand) {
return memo + _.filter(hand.fingers, function (finger) { return finger.extended; }).length;
}, 0);
},

getLeftHand: function () {
return _.findWhere(this.hands, { type: 'left' });
return $.grep(this.hands, function (hand){ return hand.type === 'left'; })[0];
},

getRightHand: function () {
return _.findWhere(this.hands, { type: 'right' });
return $.grep(this.hands, function (hand){ return hand.type === 'right' })[0];
},

getFrameRate: function () {
return this.currentFrameRate;
}
}
};
});

0 comments on commit f15f5df

Please sign in to comment.