kulkalkul / bevy_mod_billboard

Billboard text and texture support for bevy
Apache License 2.0
92 stars 16 forks source link

Texture Atlas and Sprite sheet Billboarding #23

Open Kaendor opened 8 months ago

Kaendor commented 8 months ago

Hello!

Expected

I would like to know if there is a way to do sprite animation on billboarded texture or if it's not possible at the moment.

What you did

let layout = TextureAtlas::from_grid(
     goblin_sheet.clone(),
     Vec2::new(33., 36.),
     4,
     1,
     None,
     None,
);

let atlas_handle = texture_atlases.add(layout);
let sprite = TextureAtlasSprite::new(0);

commands.spawn(monster_bundle).with_children(|b| {
     b.spawn(BillboardTextureBundle {
          transform: Transform::from_translation(Vec3::Y * 2.),
          texture: BillboardTextureHandle(goblin_sheet.clone()),
          mesh: BillboardMeshHandle(
                meshes.add(shape::Quad::new(Vec2::new(2., 2.)).into()),
          ),
          ..default()
     })
     .insert((sprite, atlas_handle));
 });

What went wrong

If I understand correctly, the crate is only for Texture and not for Sprite so the above code only render the whole atlas instead of the cropped sprite.

Thanks for the hardwork!

kulkalkul commented 8 months ago

Yeah this is correct, unfortunately, the way the crate works is as you described, doesn't use any bevy primitives, so it requires duplicate implementation for stuff like that.