Web App으로 도약하는 방법을 배우려면 Leap Motion 용 New York Times Reader를 디 컴파일해야합니다.
구현 (built.js)과 관련하여 다음 코드가 도움이 될 수 있습니다. (Backbone.js 기반)
var LeapController = new Leap.Controller ({enableGestures : true});
window.L = LeapController;
LeapController.on('deviceConnected', function() {
console.log('deviceConnected', arguments);
// in the example code, this fires when the app starts.
// in our app, it only fires when the device is reconnected after having been connected when the app was started.
dispatch.trigger('LeapControl:reconnect');
});
LeapController.on('ready', function() {
// this fires when the app is ready.
dispatch.trigger('LeapControl:reconnect');
});
LeapController.on('connect', function() {
console.log('device is connected');
// this fires when no device is plugged in. wtf.
});
LeapController.connection.on('deviceConnect', function() {
console.log('deviceConnect');
// this fires when the device is changes state from plugged in to ungplugged and vice versa.
});
LeapController.on('deviceDisconnected', function() {
console.log('deviceDisconnected', arguments);
dispatch.trigger('LeapControl:disconnect');
});
물론 뉴욕 타임즈 독자의 개발자들은 이미 도약 컨트롤러가 이미로드 된 응용 프로그램 이전에 연결된 경우는 발견하기 쉽지 않다 것이라고도 발견했다. ("태권도 연맹"하하 ....) LeapControl의 동작을 정의 된 코드의
그리고 부분 : 분리/재 연결 이벤트, 이해할 : 따라서
newNews.views.Disconnected = Backbone.View.extend({
el: $('#disconnection-box'),
initialize: function() {
_.bindAll(this);
},
open: function() {
this.listenTo(dispatch, 'LeapControl:disconnect', this.show);
this.listenTo(dispatch, 'LeapControl:reconnect', this.hide);
return this;
}, ........
, LeapControl : 다시 연결이 트리거 된하는 "도약 모션 컨트롤러가 감지되지 않았습니다"라는 팝업이 표시되지 않습니다.도약의 움직임이 이미 응용 프로그램을 실행하기 전에 꽂혀 있었다 디버깅시
는 이벤트가 순서를 다음 트리거, 그리고 정확한 검출을 보장 할 것 :
- LeapController.on ('연결'기능을() { console.log ('장치가 연결됨'); });
- LeapController.on ('ready', function() { dispatch.trigger ('LeapControl : reconnect'); }); 미리 연결되어 있지 않은 경우
동시에, 이것 만이이 트리거 될 것이다
- LeapController.on (함수() { CONSOLE.LOG ('장치가 연결되어'접속 '), });
결론적으로이 시나리오를 처리하기 위해 '준비'이벤트를 사용할 수 있습니다. HTH
감사합니다. @Dmitry. Leap Motion 디바이스 용으로 빌드 한 앱은 JavaScript의 웹 앱입니다. 이것들은 클라이언트 OS에 직접 접근 할 수 없다. Leap Motion API 문서는 다음 위치에 있습니다. http://js.leapmotion.com/api/v0.2.0-beta6/docs 거기에 연결된 참/거짓 전화가없는 것 같습니다. – Theo
@Theo 게시물을 업데이트했습니다. 시도해보십시오. –
@Dimitry 많은 감사. 코드가 잘 작동합니다 (닫는 괄호가 누락되었습니다). http://jsfiddle.net/theo/5x3DA/ 귀하의 코드는 페이지를로드 한 후 장치가 연결 또는 분리되면 나타 내기 위해 잘 작동 : 이 바이올린에서보세요. 그러나 페이지를로드 할 때 장치가 이미 연결되어 있는지 여부는 표시하지 않습니다. 그래서 장치 없이도이 경우를 테스트 할 수 있어야합니다. 그 이유는 ID를 확인하고 싶기 때문입니다 ... – Theo