我正在玩Leap Motion的JS SDK . 无论我在互联网上看到哪个例子,即使浏览器窗口处于后台,它也能正常运行=每个帧都会更新示例 . 但是,我无法弄清楚如何实现同样的事情,我的例子总是在浏览器窗口失去焦点时停止 . 让我们来看一个非常小的例子:
<body>
<p style="margin-left: 100px" id="info"></p>
<script>
var info = document.getElementById('info');
var controller = new Leap.Controller({
host: '127.0.0.1',
port: 6437,
enableGestures: true,
frameEventName: 'animationFrame',
useAllPlugins: true
});
controller.connect();
controller.setBackground(true);
controller.on('frame', onFrame);
function onFrame(frame) {
info.innerHTML = frame.id;
}
</script>
</body>
Controller.setBackground()说:通知Leap Motion WebSocket服务器,当应用程序在后台并且未被主动使用时,您的应用程序始终希望接收跟踪数据帧 . 请注意,将此选项设置为true可能会在用户与其他应用程序交互时导致对应用程序的意外输入 . 大多数应用程序不应在后台接收帧 .
有点对我不起作用,我做错了什么?非常感谢!
1 回答
答案是这是一个错误:https://github.com/leapmotion/leapjs/issues/158
你没有做错任何事 .
此问题已修复 .