npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

aframe-webvr-controller

v0.0.7

Published

A component for quickly creating objects that track to a webvr controller

Downloads

21

Readme

aframe-webvr-controller

A-Frame ( http://aframe.io ) is a library made by Mozilla to make VR experiences in the web. This is a component for quickly attaching objects to WebVR controllers in a-frame. This library works perfectly fine with HTC-Vive using WebVR enabled versions of chrome and is the primary reason I made this library! For more information, check out http://webvr.info

Check out demo here: http://richardanaya.github.io/aframe-webvr-controller/examples/02_vibration/index.html

Features

  • Position tracking
  • Simple button events
  • Vibration
  • Events on triggering while interesected

Notes

  • You may have to build the latest master branch of aframe to get it to recognize your HTC Vive can go into VR mode ( or just copy mine from examples )

Installing

npm install aframe-webvr-controller

Usage

Using this component is simple. Pass in the index of the controller you wish to use. Please make sure you have an a-camera at position <0,0,0>, otherwise strange offsetting of the controllers may occur!

<html>
<head>
    <script src="../aframe.js"></script>
    <script src="../../index.js"></script>
</head>
<body>
<a-scene>
    <a-box width=".1" height=".1" depth=".1"  color="#4CC3D9" webvr-controller="0"></a-box>
    <a-box width=".1" height=".1" depth=".1"  color="#4CC3D9" webvr-controller="1"></a-box>
    <a-camera id="player"></a-camera>
</a-scene>
</body>
</html>

Let's add some button events. There are several buttons your webvrcontroller may have. For HTC Vive:

  • webvrcontrollerbutton0pressed/webvrcontrollerbutton0released - circle button
  • webvrcontrollerbutton1pressed/webvrcontrollerbutton1released - trigger button
  • webvrcontrollerbutton2pressed/webvrcontrollerbutton2released - grip button
  • webvrcontrollerbutton3pressed/webvrcontrollerbutton3released - menu button
<html>
<head>
    <script src="../aframe.js"></script>
    <script src="../../index.js"></script>
</head>
<body>
<a-scene>
    <a-box width=".1" height=".1" depth=".1"  color="#4CC3D9" webvr-controller="0">
        <a-event name="webvrcontrollerbutton0pressed" color="#0000FF"></a-event>
        <a-event name="webvrcontrollerbutton0released" color="#FF0000"></a-event>
    </a-box>
    <a-box width=".1" height=".1" depth=".1"  color="#4CC3D9" webvr-controller="1">
        <a-event name="webvrcontrollerbutton0pressed" color="#0000FF"></a-event>
        <a-event name="webvrcontrollerbutton0released" color="#FF0000"></a-event>
    </a-box>
    <a-camera id="player"></a-camera>
</a-scene>
</body>
</html>

Now lets add some vibration.

You can also pass in a number in millseconds to represent a delay (the default delay is 100). Setting the property to false or 0 will turn off vibration.

Now lets add some events for when a user presses a button while they are intersecting a component

<a-box id="table" position="0 0 0" width="2" depth="2" height=".1" color="#333333" roughness="0.8">
  <!--controller 0 button 1 will change color-->
  <a-event name="raycaster-intersected-webvrcontroller0button1pressed" color="#FFC65D"></a-event>
  <a-event name="raycaster-intersected-webvrcontroller0button1released" color="#F16745"></a-event>
</a-box>
<!--this should not get hit from the top-->
<a-box id="table2" position="0 -2 0" width="2" depth="2" height=".1" color="#333333" roughness="0.8">
  <!--controller 0 button 1 will change color-->
  <a-event name="raycaster-intersected-webvrcontroller0button1pressed" color="#FFC65D"></a-event>
  <a-event name="raycaster-intersected-webvrcontroller0button1released" color="#F16745"></a-event>
</a-box>