-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
batch the raycaster intersection cleared events on the raycaster el #3126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| clearedIntersectedEls.length = 0; | ||
| for (i = 0; i < prevIntersectedEls.length; i++) { | ||
| if (intersectedEls.indexOf(prevIntersectedEls[i]) !== -1) { return; } | ||
| el.emit('raycaster-intersection-cleared', {el: prevIntersectedEls[i]}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super-hands component uses el property on the event. How do we get the intersected element now?
see https://github.com/wmurphyrd/aframe-super-hands-component/blob/4c6b44a09cc893bdfe1828e6576466d019047032/index.js#L366 for unWatch.
and https://github.com/wmurphyrd/aframe-super-hands-component/blob/4c6b44a09cc893bdfe1828e6576466d019047032/index.js#L325 for unHover.
cc @wmurphyrd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will fail only for GearVR and Daydream, because other controllers don't use raycaster, but sphere collider.
I guess in super-hands, we need to get the raycaster component with
var raycaster = this.el.querySelector('[raycaster]') and iterate over raycaster.clearedIntersectedEls. But I'm not sure what do to with your if condition @wmurphyrd to detect if it's a raycaster event or an sphere-collider event.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's continue the discussion there c-frame/aframe-super-hands-component#79
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you'd iterate over them and clear them all at once versus one at a time.
|
What's the advantage of not including The disadvantage is other components would have to directly access the |
|
Component members can be part of the public API, it's not discouraged to expose properties/methods. Not including would just save creating an object on each tick for garbage collection purposes. Is it able to fix? |
|
Oh, never mind, I guess you can maybe pass the array without creating an object. |
|
This breaks everything using raycaster, right? As there is no way AFAIK to detect the behavior change, if we’re going to break the existing contract, maybe better to change event name so compatibility can be achieved by supporting both old and new event names... |
|
@wmurphyrd I opened #3128 to pass the cleared elements as a detail of the event. |
|
I think versions are allowed to have some small breaking changes, especially in 0.x.x, if there's some gains, as long as things can easily adapt. It'd only break things directly using the raycaster events emitted from the raycasting entity, which I thought was not used often. The contract only applies within versions, but yeah, I wish it didn't break things. |
|
Maybe it would be nicer to have a helper component that adds a listener that calls the prior contract, so if you need the old behavior you can add raycaster-legacy-events or sonething |
|
I completely agree that small breaking changes are allowed, but now that the framework has more traction and wider usage, correspondingly small affordances to ease migration seem more worthwhile to consider. Along the lines of gltf next and legacy, having legacy helper components that throw deprecation warnings once for a point release might be a reasonable approach? |
Description:
Rather than emit an event + object on the raycaster entity on each cleared intersection, emit one with no event detail, and event handlers can look it up themselves, but this event is rarely used.
Changes proposed:
raycaster.clearedIntersectedElsmember.raycaster-intersection-clearedonly once per tick.