Skip to content
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

3d text widget #7426

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open

Conversation

VictorKoenders
Copy link

@VictorKoenders VictorKoenders commented Jan 30, 2023

This PR implements a basic of rendering text widgets in 3D space.

Fixes #5598

The following situation causes multiple textures:

commands.spawn(Text3dBundle {
    text: Text {
        sections: vec![
            TextSection::new(
                "normal ",
                TextStyle {
                    font: font_normal,
                    font_size: 24.0,
                    color: Color::BLACK,
                },
            ),
            TextSection::new(
                "bold",
                TextStyle {
                    font: font_bold,
                    font_size: 24.0,
                    color: Color::BLACK,
                },
            ),
        ],
        ..Default::default()
    },

    ..default()
});

There's a couple of ways to solve this:

  • Add a material that supports multiple textures (I don't think bevy currently supports this)
  • Generating a child node for each unique info.glyphs[*].atlas_info.texture_atlas entry (would be a lot of node management)
  • Make it so you can only generate a Text3dbundle with a single segment
  • Document this behavior and fix it in the future, keeping the assert in place

For this PR I've decided to generate child node for each texture. Let me know if another solution is better.


Changelog

Breaking changes

  • Renamed bevy_text::update_text2d_layout to bevy_text::update_layout::<Text2dBounds>
  • bevy_text::extract_text2d_sprite is now limited to entities with a Text2dBounds component

Added

  • Added bevy_text::Text3dBundle which allows rendering text in 3d space

@github-actions
Copy link
Contributor

Welcome, new contributor!

Please make sure you're read our [contributing guide](CONTRIBUTING.md) and we look forward to reviewing your Pull request shortly ✨

2 similar comments
@github-actions
Copy link
Contributor

Welcome, new contributor!

Please make sure you're read our [contributing guide](CONTRIBUTING.md) and we look forward to reviewing your Pull request shortly ✨

@github-actions
Copy link
Contributor

Welcome, new contributor!

Please make sure you're read our [contributing guide](CONTRIBUTING.md) and we look forward to reviewing your Pull request shortly ✨

@alice-i-cecile alice-i-cecile added C-Feature A new feature, making something new possible A-UI Graphical user interfaces, styles, layouts, and widgets labels Jan 31, 2023
@VictorKoenders VictorKoenders changed the title [WIP] 3d text widget 3d text widget Feb 1, 2023
@VictorKoenders VictorKoenders marked this pull request as ready for review February 1, 2023 07:36
@VictorKoenders
Copy link
Author

Rebased onto main

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2023

Your PR increases Bevy Minimum Supported Rust Version. Please update the rust-version field in the root Cargo.toml file.

@mockersf
Copy link
Member

mockersf commented Feb 6, 2023

Your PR increases Bevy Minimum Supported Rust Version. Please update the rust-version field in the root Cargo.toml file.

Sorry for the wrong message, the job checking for MSRV failed installing dependencies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-UI Graphical user interfaces, styles, layouts, and widgets C-Feature A new feature, making something new possible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for text widgets in 3d
3 participants