Skip to content

mattrei/aframe-toggle-controls-component

Repository files navigation

aframe-toggle-controls-component

Version License

A Toggle Controls component for A-Frame. Toggle is touch and mouse click or by any other event, like from the input mapping or keydown events.

For A-Frame.

API

Multiple components may be set on the scene entity.

Property Description Default Value
enabled Listen for events false
toggled Initial toggled state false
events List of events that are used for toggling []
type Type of the toggle. Either single or double single
toggleTimeout The time in milliseconds between to toggleEvents if the toggleType is double 400
onEvents Events to be fired when the toggle state is toggled []
offEvents Events to be fired when the toggle state is not toggled []
eventCond Check the specific event if the key meets the value. Format key=value, like keyCode=Space ``

Installation

Browser

Install and use by directly including the browser files:

<head>
  <title>My A-Frame Scene</title>
  <script src="https://aframe.io/releases/0.9.0/aframe.min.js"></script>
  <script src="https://unpkg.com/aframe-toggle-controls-component/dist/aframe-toggle-controls-component.min.js"></script>
</head>

<body>
  <a-scene toggle-controls="onEvents: toggleOn: offEvents: toggleOff;">
  </a-scene>
</body>

npm

Install via npm:

npm install aframe-toggle-controls-component

Then require and use.

require('aframe');
require('aframe-toggle-controls-component');

Releases

No releases published

Packages

No packages published