Reputation: 11077
I'm currently using A-Frame to build WebXR (WebVR) applications, and it's not always that I'm able to have the controllers (Oculus Touch, Vive Controls) with me to test them out. Is there a way to "simulate" the events that the different controllers emit?
Upvotes: 1
Views: 520
Reputation: 14645
I'm not sure about lower levels, but i have an idea on a higher one: If you have your vive controllers, and want to test out oculus touch events, you could do some mapping.
I'd do a component, intercepting the original events, and emitting new ones with the same details:
AFRAME.registerComponent("event-mapper", {
init: function() {
let viveEvents = ["menuup", "menudown"]
let oculusEvents = ["gripdown", "gripup"]
viveEvents .forEach((event, index) => {
this.el.addEventListener(event, (e) => {
this.el.emit(oculusEvents [index], {detail: e})
})
})
}
}
If you want it to be "dynamic" you could use a real Map() instead of two arrays, but here it seems redundant.
Furthermore, by including the detail
in the emitted event, all details, values, targets also get passed with the new event.
<a-entity event-mapper></a-entity>
Check it out in my fiddle (mapped some mouse events, onto made up ones)
Upvotes: 1