Giter Club home page Giter Club logo

aframe-controller-cursor-component's Introduction

aframe-controller-cursor-component

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
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://aframe.io/releases/0.5.0/aframe.min.js"></script>
  <script src="https://unpkg.com/aframe-controller-cursor-component/dist/aframe-controller-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');

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.