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, scale_entity) .run(); } fn setup_billboard( mut commands: Commands, asset_server: Res, mut meshes: ResMut>, ) { let image_handle = asset_server.load("rust-logo-256x256.png"); let transform = Transform::from_translation(Vec3::new(0., 0., 0.)); // transform.rotate_axis(Vec3::X, 45.0f32.to_radians()); // transform.rotate_axis(Vec3::Y, 45.0f32.to_radians()); commands.spawn(BillboardTextureBundle { texture: BillboardTextureHandle(image_handle), mesh: BillboardMeshHandle(meshes.add(Rectangle::new(2., 2.))), transform, ..default() }); } // Important bits are above, the code below is for camera, reference cube and rotation #[derive(Component)] pub struct CameraHolder; fn setup_scene( mut commands: Commands, mut meshes: ResMut>, mut materials: ResMut>, ) { let mut transform = Transform::from_translation(Vec3::new(3.3, 1.0, 9.5)); transform.rotate_axis(Dir3::X, -45.0f32.to_radians()); transform.rotate_axis(Dir3::Y, -45.0f32.to_radians()); commands .spawn((CameraHolder, Transform::IDENTITY, GlobalTransform::IDENTITY)) .with_children(|parent| { parent.spawn(Camera3dBundle { transform, projection: OrthographicProjection { far: 100.0, near: -100.0, scale: 6.0, scaling_mode: bevy::render::camera::ScalingMode::FixedVertical(2.0), ..default() } .into(), ..default() }); }); commands.spawn(PbrBundle { mesh: meshes.add(Cuboid::default()), material: materials.add(Color::Srgba(palettes::css::GRAY)), transform: Transform::from_translation(Vec3::NEG_Y * 2.), ..default() }); } fn scale_entity( keyboard: Res>, mut billboard: Query<&mut Transform, With>, ) { let mut billboard = billboard.single_mut(); if keyboard.pressed(KeyCode::KeyS) { billboard.scale.x = (billboard.scale.x - 0.01).max(0.); } }