JavaScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
dist update to remove object3d mesh when component removed from entity (#17) Jun 5, 2017
docs Remove build.js from git ignore Apr 14, 2017
.gitignore
LICENSE Initial commit Jul 22, 2016
README.md
index.js
package.json

README.md

aframe-controller-cursor-component

This is an old component! A-Frame 0.6.0 and up includes laser-controls. Use that instead!


A-Frame component for adding a laser-style cursor to a tracked controls (e.g., HTC Vive, Oculus Touch).

API

Property Description Default Value
color Laser color. #74BEC1
downEvents Event to detect button down, comma-separated. For example, use trackpaddown for 3DoF. triggerdown
upEvents Event to detect button up, comma-separated. For example, use trackpadup for 3DoF. triggerup
radius Laser radius (top and bottom). 0.001

Usage

Attach the component to an entity alongside a tracked controls entity.

<a-entity hand-controls="right" controller-cursor></a-entity>

The controller cursor component is based on A-Frame's built-in cursor, many of the events and states are shared.

mouseup and mousedown are mapped to the trigger. Pulling the trigger will emit the same events as clicking.

Notes

To avoid intersecting with the laser, the raycaster's near property is set to 0.03. Thus, you may see odd results when the top of the controller is held extremely close to the entity you wish to intersect.

This component was built for the Vive controller model. If you are using a different model, you may need to modify the raycaster and position of the laser. In the future, this should be made more easily configurable.

Browser

Install and use by directly including the browser files:

<head>
  <title>My A-Frame Scene</title>
  <script src="https://rawgit.com/aframevr/aframe/8d60730/dist/aframe-master.min.js"></script>
  <script src="https://unpkg.com/aframe-controller-cursor-component@0.2.7/dist/aframe-controller-cursor-component.min.js"></script>
</head>

<body>
  <a-scene>
    <a-entity vive-controls="hand: left"></a-entity>
    <a-entity vive-controls="hand: right" controller-cursor></a-entity>
  </a-scene>
</body>

npm

Install via npm:

npm install aframe-controller-cursor-component

Then register and use.

require('aframe');
require('aframe-controller-cursor-component');