Make Anchor work for Rectangle Mesh2d
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
## What problem does this solve or what need does it fill?
Currently inserting `Anchor` when using a `Rectangle` mesh2d component has no effect (anchor will be the default - center). Given that Anchors work for sprites which IIUC are just rectangle meshes with images on them I don't see why this shouldn't also work for Rectangle mesh2d's.
## What solution would you like?
Take into account the Anchor component in Mesh2d rendering for the `Rectangle` primitive shape and apply (the same transform logic that exists in the sprite pipeline for anchors)[https://github.com/bevyengine/bevy/blob/3f2baf8ecd7f8948fb67cf11b0f2811d7a1ca1ae/crates/bevy_sprite/src/render/mod.rs#L734].
## What alternative(s) have you considered?
None.
## Additional context
I'd be happy to implement this and submit a PR for it but I'd need some guidance on the implementation.
Contributor guide
Research direction
Start by reading the sprite anchor transform logic referenced in crates/bevy_sprite/src/render/mod.rs, then locate the Mesh2d rendering path for the Rectangle primitive. Compare the two paths and verify that an Anchor on a Rectangle changes its placement consistently with sprites.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100