diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2019-11-10 10:48:22 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2019-11-10 10:48:22 +0000 |
| commit | d7f253b511723bb1025852986f05d2d756570ac4 (patch) | |
| tree | 3616049cab8166e3cb8dff04f104de48fd4ad147 /src | |
| parent | slice preview, localStorage, slice saving (diff) | |
| download | leap-finger-scan-d7f253b511723bb1025852986f05d2d756570ac4.tar.gz leap-finger-scan-d7f253b511723bb1025852986f05d2d756570ac4.zip | |
run without leap
Diffstat (limited to 'src')
| -rw-r--r-- | src/index.js | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/src/index.js b/src/index.js index 28f4dbd..0c3e79b 100644 --- a/src/index.js +++ b/src/index.js @@ -289,26 +289,19 @@ window.onkeyup = (e) => { } } -const update = (frame) => { - const hand = frame.hands[0]; - if (!hand) - return; - - palm.position.set(...hand.palmPosition); - palm.quaternion.setFromUnitVectors(new T.Vector3(0, -1, 0), new T.Vector3(...hand.palmNormal)); - - for (var finger of hand.fingers) { - const i = finger.type; - fingers[i].update(finger); - } -} - restore(localStorage.getItem('data')); setInterval(() => { const data = fingers.map(finger => finger.store()); localStorage.setItem('data', JSON.stringify(data)); }, 2000); +const loop = () => { + orbit.update(); + renderer.render(scene, camera); + + requestAnimationFrame(loop); +}; +loop(); const controller = Leap.loop({ frameEventName: 'animationFrame', @@ -316,9 +309,15 @@ const controller = Leap.loop({ // optimizeHMD: true, background: true, }, frame => { - update(frame); + const hand = frame.hands[0]; + if (!hand) + return; - orbit.update(); - renderer.render(scene, camera); -}); + palm.position.set(...hand.palmPosition); + palm.quaternion.setFromUnitVectors(new T.Vector3(0, -1, 0), new T.Vector3(...hand.palmNormal)); + for (var finger of hand.fingers) { + const i = finger.type; + fingers[i].update(finger); + } +}); |
