-
-
Notifications
You must be signed in to change notification settings - Fork 35.3k
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
Fix sprite raycasting bugs #16423
Fix sprite raycasting bugs #16423
Conversation
How about add sprite.camera in |
I think the docs need to be really clear on this. If a user calculates a camera vector manually instead of using |
Yes, I am aware of that. This PR is a proof-of-concept. |
I've tested the change with |
What about |
I've tested #14936, it works fine. |
So, do we want to go with this approach? And if so, what instructions should we provide the user? |
I would say yes.
I would note in the documentation for |
@WestLangley would it make sense to throw a more clear and explicit error when the camera isn't defined on the raycaster and sprites are being used? It looks like an exception would get thrown anyway. And should it be supported to set the camera explicitly instead of with the |
I think using camera in the renderer is better than using camera in the raycaster. |
@06wj I'll give that a try... |
Added |
I think this approach is better since it's not necessary anymore to modify |
@gkjohnson Does this now satisfy your concerns? |
Sorry for the slow response -- I'm away this weekend. I personally prefer adding the camera to the raycaster. I feel relying on side effects from calling render seems a little confusing and not all that extensible. It means you can't raycast against a scene without rendering it first and you must raycast between renders if you're rendering from multiple camera angles because the last camera rendered with will be the one active on the sprites. I think adding extra variables on to the raycaster for custom raycast scenarios is a fine pattern myself and have used it in my own projects when implementing a custom raycast function. Both ways work, though! Those are just a couple of the potential concerns that come to mind. |
In fact, raycast will fail if the scene is not rendered, no matter it is Sprite or other Mesh. Because the matrix of camera and objects are updated after the scene is rendered. Whether or not the Sprite is raycasted depends on which camera it was rendered by, not which camera the ray was generated by. |
The camera used to set the ray, and the camera used in the raycasting algorithm must be the same camera. I am inclined to revert to what I proposed originally. |
What are you referring to exactly? Sry, many approaches were discussed and I just want to be sure to understand the right thing. |
Doing what I said in my original post. |
Well, do whatever you think is best. Any of the proposed solutions is better than the current one. |
cdc9a46
to
c572f96
Compare
@WestLangley I do feel that One use case that comes to mind is using a controller with a pointer in VR to select sprites. |
Can /ping @gkjohnson |
It looks like it could be -- is your goal to have an example with which to test the behavior? Or show people how to use it? I haven't done a whole lot of WebVR work myself so I'd have to get set up to run the VR examples. I can probably do that at some point, though. If you'd prefer to wait for the example then maybe the |
According to @mrdoob, sprites do not work well in VR due to the multiple cameras. For GUIs, non-billboarded planes are used instead. |
I think this PR can be merged. It is the best we can do at the moment, and it is certainly better than what we have now. |
OK, merging. |
Fixes #14936 and #14624.
Adding a reference to
camera
inRaycaster.setFromCamera()
seems the least hacky approach I can think of./ping @06wj
/ping @Mugen87