-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Nested raycasters cause false intersections on parent raycasters due to event bubbling #5075
Comments
If you are using multiple cursors on a single scene, you will hit other problems as well (as I did, and tried to fix in this PR, that's not been accepted yet: #4983) The way the cursor component uses a closure here means that there is a single global instance of This leads to the two cursors scribbling over each other. The code fails to follow the advice on closures here Perhaps a subset of my PR 4893 should be pulled out to fix this bug, at least. I had struggled to make the case that support for multiple cursors on a single scene was a mainstream use case. |
it's used with setAttribute which I think will assign the properties from the argument onto the data for the raycaster rather than replacing it entirely with new object. I need to check but I would be very surprised if it did. |
Yes, sorry, my comment isn't in fact relevant here, although reasons why are a little subtle...
The values aren't copied from the As far as I can tell, this That said, the shared values don't actually cause a problem in the case where one cursor is mouse-based and one is gazed-based, because they are only used for mouse-based cursors. So you'd need to have 2 x mouse-based cursors that map to different points in the 3D space (e.g. by being projected through 2 diferent canvases) to have a problem. That's exactly what I saw in this example (worked around using a custom cusror.js), but it's a very specific case, and won't apply any more broadly: In case it's helpful to anyone, here's a working example showing mouse-based + gaze-based cursors working independently in the same scene. You can set a breakpoint on the raycaster |
I was a little curious why this happens. It looks like the root cause is this code
this function This means that when A-Frame copies When
I don't know whether this is a bug, or intentional. It's certainly counter-intuitive, but maybe has performance benefits by avoiding creating unecessary (sorry for hijacking your issue with this, will ponder whether I should spin this off into a separate issue). |
In the example provided:
If cursor mouse is active all the other cursors should be inactive? Any use cases for several cursors working simulatenously? |
#5076 doesn't fix this? |
It certainly helps but as @diarmidmackenzie pointed out it doesn’t fix the whole issue for every situation which was a bit large for me to tackle in that PR so I closed it. |
A good reason for allowing mouse and other cursors would be sticking cursors onto animating objects to automate cursor behavior or let other participants use cursors remotely |
I think it should be the app responsibility to enable/disable cursor/raycaster you don't want. For example, cursor/raycaster on hands disabled initially, and when you enter vr you disable cursor/raycaster defined on a-scene that is used for desktop, and you enable cursor/raycaster on hands. Disabling raycaster that you don't use is best practice for perf to not do unnecessary work. |
I don't know what all the remaining issues are here, but I believe that fixing #5181 (which I have meaning to be raised for a while, and finally decided to get on with) would address the issues with multiple cursors that I've observed in the past & described above. |
I described the issue I had in the comment AdaRoseCannon/aframe-htmlmesh#5 (comment) and that's probably what @AdaRoseCannon saw as well. |
Description:
When the cursor on the entity hits an object it does an intersection and events are fired
It then bubbles up the DOM tree and reaches the
a-scene
which sees an intersection event assumes that it is it's own and fires off it's own intersection events so anything listening for intersection events now thinks the a-scene cursor intersected it when it did not.The fix is to check for
event.currentTarget === event.target
inonIntersection
in cursor.jsThe text was updated successfully, but these errors were encountered: