git.s-ol.nu leap-finger-scan / d7f253b
run without leap s-ol 3 years ago
1 changed file(s) with 18 addition(s) and 19 deletion(s). Raw diff Collapse all Expand all
288288 }
289289 }
290290
291 const update = (frame) => {
292 const hand = frame.hands[0];
293 if (!hand)
294 return;
295
296 palm.position.set(...hand.palmPosition);
297 palm.quaternion.setFromUnitVectors(new T.Vector3(0, -1, 0), new T.Vector3(...hand.palmNormal));
298
299 for (var finger of hand.fingers) {
300 const i = finger.type;
301 fingers[i].update(finger);
302 }
303 }
304
305291 restore(localStorage.getItem('data'));
306292 setInterval(() => {
307293 const data = fingers.map(finger => finger.store());
308294 localStorage.setItem('data', JSON.stringify(data));
309295 }, 2000);
310296
297 const loop = () => {
298 orbit.update();
299 renderer.render(scene, camera);
300
301 requestAnimationFrame(loop);
302 };
303 loop();
311304
312305 const controller = Leap.loop({
313306 frameEventName: 'animationFrame',
315308 // optimizeHMD: true,
316309 background: true,
317310 }, frame => {
318 update(frame);
319
320 orbit.update();
321 renderer.render(scene, camera);
311 const hand = frame.hands[0];
312 if (!hand)
313 return;
314
315 palm.position.set(...hand.palmPosition);
316 palm.quaternion.setFromUnitVectors(new T.Vector3(0, -1, 0), new T.Vector3(...hand.palmNormal));
317
318 for (var finger of hand.fingers) {
319 const i = finger.type;
320 fingers[i].update(finger);
321 }
322322 });
323