turtlestitch/libraries/leap-library.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 %&apos;pos&apos; position of hand %&apos;num&apos;" 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 %&apos;pos&apos; rotation of hand %&apos;num&apos;" 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);&#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><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 %&apos;num&apos; 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 %&apos;num&apos;" 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,&#xD; done = false;&#xD;leapScript = document.createElement(&apos;script&apos;),&#xD;leapScript.onload = function () {&#xD; done = true;&#xD; console.log(&apos;leap is ready&apos;);&#xD;};&#xD;document.head.appendChild(leapScript);&#xD;leapScript.src = &apos;https://js.leapmotion.com/leap-0.6.4.min.js&apos;;&#xD;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>