Closed sirkitree closed 6 years ago
Thanks for the kind words. Those collider properties on super-hands
are input parameters that tell it what events to expect from your chosen collision detection component. In that example, we are configuring super-hands
to listen for the 'collisions'
event that physics-collider
generates.
What you're looking for are the gesture events that super-hands
creates by interpreting input from controller buttons, movement, and collisions. 'hover-end'
will be emitted on an entity when the collision with a controller ends. You may also want 'grab-end'
which will be emitted from an entity that has been grabbed once the grabbing button is released.
The reaction components also add and remove states on the affected entities, so you could listen for 'stateremoved'
with event.detail.state === 'hovered'
/ event.detail.state === 'grabbed'
(A-Frame <= v0.7.1) or event.detail === 'hovered'
/ event.detail === 'grabbed'
(A-Frame master). Listening for states is the more precise option because, while a gesture event communicates intent to perform an action, state changes communicate an action has been taken. In many cases these are the same, but they can differ under more advanced configurations (e.g. if you have filtered your reaction components to only accept specific buttons or if you don't have all reaction components enabled on all collidable entities)
Since all of these are coming not from the hands but from the affected entities, you'd want to register your listeners on your a-scene
rather than the hand so that they will bubble up to the listener. event.target
will point to the affected entity and, in the case of the gesture events, event.detail.hand
will point to the controller entity.
Ah, thank you for the explanation. In this case it would seem that since I want the position of the element that I moved with my hands, I should probably be listening to the events that particular element emits instead of the ones coming from superhands. Still, this helps me understand what is going on so thank you for the reply.
Hi! Thanks for such a great component :) I hope it's ok to ask for support here. Happy to post elsewhere if you prefer.
I'm trying to detect the end of a collision so that I can get the current position of the object I moved with the superhands component.
I see this defined in your example in the README:
My question is around the
colliderEndEvent
. Can I assume that I can set this to an arbitrary string and then detect that event like so?then in js
Or do I somehow have to create that event first?
Thanks for any help you can offer.