blaind / bevy_text_mesh

A bevy 3D text mesh generator for displaying text
MIT License
65 stars 16 forks source link

Adding TextMeshPlugin makes any 2d text disappear #9

Closed gilescope closed 2 years ago

gilescope commented 2 years ago

When I add in the TextMeshPlugin then any 2d text ( https://github.com/bevyengine/bevy/blob/main/examples/ui/text.rs ) disappears. I am guessing that it's just that the 2d text is getting upset by a different font loader.

It would be great if I could use your awesome 3d text and also have some 2d ui (like fps and other HUD info). Took me a little while to track this down that this was the cause.

gilescope commented 2 years ago

alternatively if we can pin 3d text to the camera so that it moves around with the camera then that works too - more than one way to skin a cat. But ideally it would be great if the std bevy text and this didn't interfere with each other.

blaind commented 2 years ago

This is a duplicate to #3, also mentioned in the README limitations - should be highlighted though.

The reason for separate .ttf FontLoader was that there was no way to access font bytes through the bevy loader.

Non-exhaustive list of options to fix it:

  1. Submit a pull request for Bevy to expose underlying font bytes
  2. Make bevy_text_mesh `AssetLoader' be 100% compatible with other Bevy plugins (being a drop-in-replacement)
  3. Use non-asset-loader way to load the fonts for text mesh
  4. Pinning 3D text to the camera (comment above)
  5. Investigate if some recent change in Bevy already would enable direct usage of the fonts
  6. Submit a pull request for ab_glyph crate to expose font bytes for further processing in bevy_text_mesh
  7. Build the tessellation on top of ab_glyph example as basis of ab_glyph API
  8. Some others?

I'd lean first for 5 and then 1. Any comments?

blaind commented 2 years ago

Regarding option 1, this is how bevy current loads fonts:

The font is exposed through a ab_glyph::FontArc at font.rs

gilescope commented 2 years ago

In my case the text is independent of the camera and is more embedded in the 3d world. (I don't really need depth so set that to be small).

"Submit a pull request for Bevy to expose underlying font bytes" - I think first we should probably raise an issue against bevy to say we'd like to be able to use the raw font data. But yes I think being able to get access to the raw loaded asset sounds in general a helpful thing that others may also need. I'm sure people with assets other than fonts will need that escape hatch.

blaind commented 2 years ago

One option would be to create the text mesh as a labeled assed instead of standard asset.

Example: https://github.com/blaind/bevy_text_mesh/pull/15/files#diff-bfff203afa941530d8cb8f6accb08e223c008b9bb6808f6fcc0b7866436354a3

blaind commented 2 years ago

Regarding multiple asset loaders, there's an open bevy issue at https://github.com/bevyengine/bevy/issues/367

gilescope commented 2 years ago

Tbh am steering clear at the moment as am doing wasm and am trying to avoid non-rust dependencies to keep things simple.

On Sat, 27 Aug 2022 at 08:19, Mika @.***> wrote:

One option would be to create the text mesh as a labeled assed instead of standard asset.

Example: https://github.com/blaind/bevy_text_mesh/pull/15/files#diff-bfff203afa941530d8cb8f6accb08e223c008b9bb6808f6fcc0b7866436354a3

— Reply to this email directly, view it on GitHub https://github.com/blaind/bevy_text_mesh/issues/9#issuecomment-1229140962, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGEJCHJGTHY6BSGGEKYYPDV3G6RNANCNFSM5UEFVZ3A . You are receiving this because you authored the thread.Message ID: @.***>

blaind commented 2 years ago

Closed as fixed by #15