diff --git a/examples/text_image.rs b/examples/text_image.rs index 7cf3c72..5203ed7 100644 --- a/examples/text_image.rs +++ b/examples/text_image.rs @@ -14,9 +14,11 @@ fn main() { App::new() .add_plugins(DefaultPlugins) .add_systems(Startup, add_texture) - .add_systems(Update, rotate_mesh.run_if(|keys: Res>| -> bool { - keys.pressed(KeyCode::Space) - })) + .add_systems( + Update, + rotate_mesh + .run_if(|keys: Res>| -> bool { keys.pressed(KeyCode::Space) }), + ) .run(); } @@ -83,30 +85,32 @@ fn add_texture( ["Up", "Down", "Left", "Right", "Top", "Bottom"] .into_iter() .for_each(|text| { - parent.spawn(NodeBundle { - style: Style { - height: Val::Percent(100.0 / 6.0), - width: Val::Percent(100.0), - justify_content: JustifyContent::Center, - justify_items: JustifyItems::Center, - align_items: AlignItems::Center, - align_content: AlignContent::Center, - ..default() - }, - ..default() - }).with_children(|parent| { - parent.spawn(TextBundle { - text: Text::from_section( - text, - TextStyle { - color: Color::BLACK, - font_size: 64.0, - ..default() - }, - ), + parent + .spawn(NodeBundle { + style: Style { + height: Val::Percent(100.0 / 6.0), + width: Val::Percent(100.0), + justify_content: JustifyContent::Center, + justify_items: JustifyItems::Center, + align_items: AlignItems::Center, + align_content: AlignContent::Center, + ..default() + }, ..default() + }) + .with_children(|parent| { + parent.spawn(TextBundle { + text: Text::from_section( + text, + TextStyle { + color: Color::BLACK, + font_size: 64.0, + ..default() + }, + ), + ..default() + }); }); - }); }); }); @@ -130,31 +134,6 @@ fn add_texture( } { - let cube_size = 4.0; - let a = 1.0 / 6.0; - let b = 2.0 * a; - let c = 3.0 * a; - let d = 4.0 * a; - let e = 5.0 * a; - let f = 1.0; - let cuboid = Mesh::from(Cuboid::new(cube_size, cube_size, cube_size)) - .with_inserted_attribute( - Mesh::ATTRIBUTE_UV_0, - vec![ - // Top side - [1.0, 0.0], [0.0, 0.0], [0.0, a], [1.0, a], - // Bottom side - [1.0, a], [0.0, a], [0.0, b], [1.0, b], - // Right side - [1.0, b], [0.0, b], [0.0, c], [1.0, c], - // Left side - [1.0, c], [0.0, c], [0.0, d], [1.0, d], - // Back side - [1.0, d], [0.0, d], [0.0, e], [1.0, e], - // Front side - [1.0, e], [0.0, e], [0.0, f], [1.0, f], - ]); - let mesh = meshes.add(cuboid); let material = materials.add(StandardMaterial { base_color_texture: Some(image_handle), ..default() @@ -178,13 +157,10 @@ fn add_texture( } } -fn rotate_mesh( - mut query: Query<&mut Transform, With>>, - time: Res