UNPKG

super-hands

Version:

All-in-one natural hand controller interaction component for A-Frame.

158 lines (156 loc) 6.94 kB
<html> <head> <title>A-Frame Super Hands Component</title> <style> html { background: #33425B; color: #FAFAFA; font-family: sans-serif; font-size: 20px; padding: 10px 20px; max-width: 41em; margin: 0 auto; } h1,h2 { font-weight: 300; font-family: serif; } a { color: #FAFAFA; } a.example { padding: 15px 0; font-size: 24px; display: block; } code, pre { font-family: monospace; background-color: #3f506d; color: #BBB; } .unemph { font-size: smaller; color: #BBB; } .preview { width: 192px; height: 96px; display: block; margin: 3px 0px; float: left; } .bonus { color: #f4f4a1; background-color: #3f506d7e; font-size: 18px; width: 93px; height: 96px; float: left; margin: 3px 0px; padding: 0 0 0 5px; position: absolute; overflow: hidden; } .bonus::after { content: 'Motion-Captured Preview Available' } .bonus+p, .preview+p, .example + p { clear: both; } </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/showdown/1.9.1/showdown.min.js"></script> </head> <body> <h1>A-Frame Super Hands Component</h1> <p>This is the examples page for the <a href="http://github.com/c-frame/aframe-super-hands-component"> super-hands A-Frame component package </a> for super-easy hand controller interactivity in A-Frame WebVR experiences. </p> <a id="physics" class="example" href="physics/">Hand controls with physics<br /> <img class="preview" src="./assets/physics.jpg"/> <!-- <div class="bonus"></div> --> </a> <p><a href="physics/index-mouse.html">Mouse cursor based version for desktop</a></p> <p><ul> <li>Grabbed boxes lock position and rotation to controller</li> <li><code>color-randomizer</code> changes the color of entities dropped inside of the color changer box</li> <li>Boxes can be stretched with two hands to change size, updating their physics bodies</li> </ul></p> <p>Example of super-hands interactivity with roomscale tracked controllers and <code>aframe-physics-system</code>. Also showcases creating a simple custom reaction component.</p> <pre> AFRAME.registerComponent('color-randomizer', { play: function() { this.el.addEventListener('drag-drop', function(evt) { evt.detail.dropped.setAttribute('material', 'color', '#'+(Math.random()*0xFFFFFF<<0).toString(16)) // notify super-hands that the gesture was accepted evt.preventDefault() }) } }) </pre> <p class = "unemph">Credit for random color generator code: <a href="http://stackoverflow.com/questions/1484506/random-color-generator-in-javascript#comment6801353_5365036">Mohsen via StackOverflow</a></p> <a id="mouse" class="example" href="mouse/"> Gaze and laser pointer controls without physics <br /> <img class="preview" src="./assets/hand-controls.jpg"/> <!-- <div class="bonus"></div> --> </a> <p><a href="mouse/index-mouse.html">Mouse cursor based version for desktop</a></p> <p><ul> <li>Grabbed entities move by controller position and rotation</li> <li>Drag-drop targets and their hovering entity appear in wireframe</li> <li>Entities change to spheres upon completing drag-drop interaction via the <code>event-set</code> component listening for the 'drag-drop' event</li> </ul></p> <p><code>super-hands</code> can also be use with other types of input including 3DOF controllers, mouse, and touch. In these cases, a raycasting can be used intead of collision detection. The confugration below works with the A-Frame <code>raycaster</code> component. <pre> super-hands="colliderEvent: raycaster-intersection; colliderEventProperty: els; colliderEndEvent: raycaster-intersection-cleared; colliderEndEventProperty: clearedEls"</pre> <p>This scene also shows the fallback movement that occurs when physics is not available.</p> <h2>Quick guide to adding making something grabbable with physics on your site</h2> <div id="dynamic-guide-here"></div> <script> (async function() { var converter = new showdown.Converter(); var response = await fetch('https://raw.githubusercontent.com/c-frame/aframe-super-hands-component/master/getting-started.md'); var md = await response.text() var html = converter.makeHtml(md); document.querySelector('#dynamic-guide-here').innerHTML = html; })() </script> <!-- <a id="sticky" class="example" href="sticky/">Sticky Grab via Custom Button Mapping<br /> <img class="preview" src="./assets/sticky.jpg"/> </a> <p>Example of customizing the button event schema options</p> <ul> <li>Press trigger to lock bat to controller</li> <li>Knock some balls around</li> <li>Press trackpad to drop the bat</li> <li>Stretch the balls by pressing both trackpads</li> </ul> --> <!-- GitHub Corner. --> <a href="https://github.com/c-frame/aframe-super-hands-component" class="github-corner"> <svg width="80" height="80" viewBox="0 0 250 250" style="fill:#222; color:#fff; position: absolute; top: 0; border: 0; right: 0;"> <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path> </svg> </a> <style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}} </style> </body> </html>