Skip to content

Mouse location within viewport rendered to image #239

Answered by aevyrie
ThomasAlban asked this question in Q&A
Discussion options

You must be logged in to vote

You will need to (a) write a shim, or (b) write your own picking backend: https://docs.rs/bevy_mod_picking/latest/bevy_mod_picking/backend/index.html

To support picking over an image, you will need to create a shim that takes the pointer's location on the image from egui, and sends it to the picking plugin.

  • in egui, on your image, get the pointer's position
  • override the pointer's PointerLocation - instead of the window render target, set it to your image's rendertarget

This should be enough to inform the existing backends of where your pointer is. Because they know the pointer is over an image instead of a window, they can find the camera associated with that image and use it for raycas…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ThomasAlban
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants