kopia lustrzana https://github.com/backface/turtlestitch
7 wiersze
5.9 KiB
XML
7 wiersze
5.9 KiB
XML
<blocks app="Snap! 4.1, http://snap.berkeley.edu" version="1"><block-definition s="Leap number of hands" type="reporter" category="other"><header></header><code></code><translations></translations><inputs></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list></list><l>return window.controller.frame(0).hands.length;</l></block><list></list></block></block></script></block-definition><block-definition s="Leap %'pos' position of hand %'num'" type="reporter" category="other"><header></header><code></code><translations></translations><inputs><input type="%txt" readonly="true">x<options>x
|
|
y
|
|
z</options></input><input type="%n">1</input></inputs><script><block s="doDeclareVariables"><list><l>a</l></list></block><block s="doIfElse"><block s="reportNot"><block s="reportGreaterThan"><block var="num"/><custom-block s="Leap number of hands"></custom-block></block></block><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>pos</l><l>num</l></list><l>var a = {x:0, y:1, z:2}[pos]; return window.controller.frame(0).hands[num-1].stabilizedPalmPosition[a];</l></block><list><block var="pos"/><block var="num"/></list></block></block></script><script><block s="doReport"><l>0</l></block></script></block></script></block-definition><block-definition s="Leap %'pos' rotation of hand %'num'" type="reporter" category="other"><header></header><code></code><translations></translations><inputs><input type="%txt" readonly="true">yaw<options>yaw
|
|
pitch
|
|
roll</options></input><input type="%n">1</input></inputs><script><block s="doIfElse"><block s="reportNot"><block s="reportGreaterThan"><block var="num"/><custom-block s="Leap number of hands"></custom-block></block></block><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>pos</l><l>num</l></list><l>var f = window.controller.frame(0);
switch (pos){
 case "yaw":
 return f.hands[num-1].yaw();
 case "pitch":
 return f.hands[num-1].pitch();
 case "roll":
 return f.hands[num-1].roll();
};
 
 </l></block><list><block var="pos"/><block var="num"/></list></block></block></script><script><block s="doReport"><l>0</l></block></script></block></script></block-definition><block-definition s="Leap %'pos' position of finger %'num'" type="reporter" category="other"><header></header><code></code><translations></translations><inputs><input type="%txt" readonly="true">x<options>x
|
|
y
|
|
z</options></input><input type="%n">1</input></inputs><script><block s="doIfElse"><block s="reportNot"><block s="reportGreaterThan"><block var="num"/><block s="evaluate"><block s="reportJSFunction"><list></list><l>return window.controller.frame(0).fingers.length;</l></block><list></list></block></block></block><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>pos</l><l>num</l></list><l>var a = {x:0, y:1, z:2}[pos]; return window.controller.frame(0).fingers[num-1].stabilizedTipPosition[a];</l></block><list><block var="pos"/><block var="num"/></list></block></block></script><script><block s="doReport"><l>0</l></block></script></block></script></block-definition><block-definition s="Leap hand %'num' is pinching" type="predicate" category="other"><header></header><code></code><translations></translations><inputs><input type="%s">1</input></inputs><script><block s="doIfElse"><block s="reportNot"><block s="reportGreaterThan"><block var="num"/><custom-block s="Leap number of hands"></custom-block></block></block><script><block s="doReport"><block s="reportGreaterThan"><block s="evaluate"><block s="reportJSFunction"><list><l>num</l></list><l>return window.controller.frame(0).hands[num-1].pinchStrength;</l></block><list><block var="num"/></list></block><l>0.75</l></block></block></script><script><block s="doReport"><block s="reportBoolean"><l><bool>false</bool></l></block></block></script></block></script></block-definition><block-definition s="Leap pinch strength of hand %'num'" type="reporter" category="other"><header></header><code></code><translations></translations><inputs><input type="%n">1</input></inputs><script><block s="doIfElse"><block s="reportNot"><block s="reportGreaterThan"><block var="num"/><custom-block s="Leap number of hands"></custom-block></block></block><script><block s="doReport"><block s="reportProduct"><block s="evaluate"><block s="reportJSFunction"><list><l>num</l></list><l>return window.controller.frame(0).hands[num-1].pinchStrength;</l></block><list><block var="num"/></list></block><l>100</l></block></block></script><script><block s="doReport"><l>0</l></block></script></block></script></block-definition><block-definition s="Leap $flag" type="command" category="other"><header></header><code></code><translations></translations><inputs></inputs><script><block s="doIf"><block s="evaluate"><block s="reportJSFunction"><list></list><l>return window.controller !== undefined</l></block><list></list></block><script><block s="doStopThis"><l><option>this block</option></l></block></script></block><block s="doDeclareVariables"><list><l>test</l></list></block><block s="doSetVar"><l>test</l><block s="evaluate"><block s="reportJSFunction"><list></list><l>var leapScript,
 done = false;
leapScript = document.createElement('script'),
leapScript.onload = function () {
 done = true;
 console.log('leap is ready');
};
document.head.appendChild(leapScript);
leapScript.src = 'https://js.leapmotion.com/leap-0.6.4.min.js';
return function () {return done; }</l></block><list></list></block></block><block s="doWaitUntil"><block s="evaluate"><block var="test"/><list></list></block></block><block s="doRun"><block s="reportJSFunction"><list></list><l>window.controller = new Leap.Controller({enableGestures: true, background: true}); window.controller.connect();</l></block><list></list></block></script></block-definition></blocks> |