mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 20:53:53 +00:00
585baf0a66
# Objective Make the coordinate systems of screen-space items (cursor position, UI, viewports, etc.) consistent. ## Solution Remove the weird double inversion of the cursor position's Y origin. Once in bevy_winit to the bottom and then again in bevy_ui back to the top. This leaves the origin at the top left like it is in every other popular app framework. Update the `world_to_viewport`, `viewport_to_world`, and `viewport_to_world_2d` methods to flip the Y origin (as they should since the viewport coordinates were always relative to the top left). ## Migration Guide `Window::cursor_position` now returns the position of the cursor relative to the top left instead of the bottom left. This now matches other screen-space coordinates like `RelativeCursorPosition`, UI, and viewports. The `world_to_viewport`, `viewport_to_world`, and `viewport_to_world_2d` methods on `Camera` now return/take the viewport position relative to the top left instead of the bottom left. If you were using `world_to_viewport` to position a UI node the returned `y` value should now be passed into the `top` field on `Style` instead of the `bottom` field. Note that this might shift the position of the UI node as it is now anchored at the top. If you were passing `Window::cursor_position` to `viewport_to_world` or `viewport_to_world_2d` no change is necessary. |
||
---|---|---|
.. | ||
src | ||
Cargo.toml |