kopia lustrzana https://github.com/backface/turtlestitch
1 wiersz
5.3 KiB
XML
1 wiersz
5.3 KiB
XML
<blocks app="Snap! 4.0, http://snap.berkeley.edu" version="1"><block-definition s="Leap $flag" type="command" category="other"><header></header><code></code><inputs></inputs><script><block s="doRun"><block s="reportJSFunction"><list></list><block s="reportURL"><l>crossorigin.me/http://js.leapmotion.com/leap-0.6.4.min.js</l></block></block><list></list></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><block-definition s="Leap number of hands" type="reporter" category="other"><header></header><code></code><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><inputs><input type="%txt">x</input><input type="%n">1</input></inputs><script><block s="doDeclareVariables"><list><l>a</l></list></block><block s="doIfElse"><block s="reportAnd"><block s="reportListContainsItem"><block s="reportNewList"><list><l>x</l><l>y</l><l>z</l></list></block><block var="pos"/></block><block s="reportNot"><block s="reportGreaterThan"><block var="num"/><custom-block s="Leap number of hands"></custom-block></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><inputs><input type="%txt">yaw</input><input type="%n">1</input></inputs><script><block s="doIfElse"><block s="reportAnd"><block s="reportListContainsItem"><block s="reportNewList"><list><l>yaw</l><l>pitch</l><l>roll</l></list></block><block var="pos"/></block><block s="reportNot"><block s="reportGreaterThan"><block var="num"/><custom-block s="Leap number of hands"></custom-block></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><inputs><input type="%txt">x</input><input type="%n">1</input></inputs><script><block s="doIfElse"><block s="reportAnd"><block s="reportListContainsItem"><block s="reportNewList"><list><l>x</l><l>y</l><l>z</l></list></block><block var="pos"/></block><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></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><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="reportFalse"></block></block></script></block></script></block-definition><block-definition s="Leap pinch strength of hand %'num'" type="reporter" category="other"><header></header><code></code><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></blocks> |