aframe-haptics-component

A controller haptics (vibrations) component for A-Frame.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
aframe-haptics-component
1,358871.6.33 years ago7 years agoMinified + gzip package size for aframe-haptics-component in KB

Readme

aframe-haptics-component

Version License A controller haptics (vibrations) component for A-Frame. Supported by experimental Gamepad Extensions. Read about browser support. Demo

API

| Property | Description | Default Value | | -------- | ----------- | ------------- | | actuatorIndex | Index of the actuator from the gamepad's array of actuators. | 0 | | dur | Duration of vibration pulse (milliseconds). | 100 | | enabled | Whether the component should pulse on the event. | true | | events | Array of events to listen for to trigger a pulse (e.g., triggerdown, triggerup) | | | eventsFrom | Target entity to listen for events if other than the controller entity. | this.el | | force | Intensity of pulse (from 0 to 1) | 1 |

Methods

| Name | Description | |-------|---------------------------------------------------------------------------------------------------------------------| | pulse | Manually trigger pulse (can pass in force and duration as arguments, defaults data-defined duration and force). | ```js this.el.components.haptics.pulse(); // function pulse (force, duration) this.el.components.haptics.pulse(0.5, 200); ```

Installation

Browser

Install and use by directly including the browser files: ```html My A-Frame Scene
<a-entity hand-controls="left"  haptics="events: triggerdown; dur: 1000; force: 0.5"></a-entity>
<a-entity hand-controls="right" haptics="events: triggerdown; dur: 500; force: 1.0"></a-entity>
```

npm

Install via npm: ```bash npm install aframe-haptics-component ``` Then require and use. ```js require('aframe'); require('aframe-haptics-component'); ```