UNPKG

@micosmo/aframe

Version:
51 lines (31 loc) 2.95 kB
# @micosmo/aframe/button Aframe component that implements a virtual button controller that can be triggered by collision detection events, virtual trigger events or keyboard events. The entity element that the *button* component is attached to is assumed to be a visual representation of a button. The *button* component is configured with a button *press* color that will be applied to the visual element when the button is fires and the pressed state is entered. The color is restored when the button *release* occurs. ## API ### IMPORTING ```javascript import '@micosmo/aframe/button'; ``` ### COMPONENTS #### Component: button Implements a virtual button controller that generates synthetic *vrbuttondown* and *vrbuttonup* events to the element that the button is connected to. The *button* component listens to the following events: * collisionstart : Collision detection event that is generated by a [collider]('./collider') that is also attached to the element. * collisionend : Collision ended event that is generated by a [collider]('./collider') that is also attached to the element. * Other events as defined by the schema. ##### SCHEMA Property | Type | Default | Description -------- | ---- | ------- | ----------- pressedColor | color | red | The color that is applied to the element that the button component is attached to. playCooldown | number | 0.5 | The time in seconds that the button cools down before responding to new input events. keyid | string | '' | The logical key name that is assigned to this *button*. If this is not specified then generic key event listeners are added that will map to all keys in the associated *keymap*. Works fine if the *keymap* is dedicated to the *button*. events | array[string] | ['triggerDown', 'triggerUp'] | Synthetic events that the *button* will listen for. The first event id will map to the button's *press* behaviour and the second to the button's *release* behaviour. If only one of the events is provided the *button* will simulate a *press* and *release* sequence. ##### METHODS None ##### PROPERTIES None ## LICENSE ISC - Internet Systems Consortium Copyright 2019 Micosmo ([www.micosmo.com](http://www.micosmo.com)) Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.