use bevy::color::palettes; use bevy::prelude::*; use bevy_mod_billboard::prelude::*; fn main() { App::new() .add_plugins(DefaultPlugins) .add_plugins(BillboardPlugin) .add_systems(Startup, (setup_billboard, setup_scene)) .add_systems(Update, move_cube) .run(); } #[derive(Component)] pub struct ParentCube; fn setup_billboard( mut commands: Commands, asset_server: Res, mut meshes: ResMut>, mut materials: ResMut>, ) { let fira_sans_regular_handle = asset_server.load("FiraSans-Regular.ttf"); commands .spawn(( PbrBundle { mesh: meshes.add(Cuboid::default()), material: materials.add(Color::Srgba(palettes::css::GRAY)), transform: Transform::from_translation(Vec3::new(0.0, -2.0, 1.0)), ..default() }, ParentCube, )) .with_children(|parent| { parent.spawn(BillboardTextBundle { transform: Transform::from_translation(Vec3::new(0., 1.0, 0.)) .with_scale(Vec3::splat(0.0085)), text: Text::from_section( "parented text", TextStyle { font_size: 60.0, font: fira_sans_regular_handle.clone(), color: Color::WHITE, }, ) .with_justify(JustifyText::Center), ..default() }); }); } // Important bits are above, the code below is for camera, reference cube and rotation fn setup_scene(mut commands: Commands) { commands.spawn(Camera3dBundle { transform: Transform::from_translation(Vec3::new(5., 0., 0.)) .looking_at(Vec3::ZERO, Vec3::Y), ..default() }); } fn move_cube( mut parent_cube: Query<&mut Transform, With>, mut accumulated: Local, mut direction: Local, time: Res