turtlestitch/libraries/leap-library.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 %&apos;pos&apos; position of hand %&apos;num&apos;" 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 %&apos;pos&apos; rotation of hand %&apos;num&apos;" 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);&#xD;switch (pos){&#xD; case "yaw":&#xD; return f.hands[num-1].yaw();&#xD; case "pitch":&#xD; return f.hands[num-1].pitch();&#xD; case "roll":&#xD; return f.hands[num-1].roll();&#xD;};&#xD; &#xD; </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 %&apos;pos&apos; position of finger %&apos;num&apos;" 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 %&apos;num&apos; 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 %&apos;num&apos;" 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>