From 9f2410a4ac8cf035ce48662028bb1a8674b8367c Mon Sep 17 00:00:00 2001 From: Daniel McNab <36049421+DJMcNab@users.noreply.github.com> Date: Thu, 7 Jan 2021 01:17:06 +0000 Subject: [PATCH] Add `from_xyz` to `Transform` (#1212) * Add the from_xyz helper method to Transform * Use `from_xyz` where possible --- crates/bevy_render/src/entity.rs | 3 +-- .../src/components/global_transform.rs | 6 +++++ .../src/components/transform.rs | 6 +++++ .../hierarchy/hierarchy_maintenance_system.rs | 7 +++-- .../src/transform_propagate_system.rs | 27 ++++++++----------- crates/bevy_ui/src/entity.rs | 3 +-- examples/2d/contributors.rs | 2 +- examples/2d/texture_atlas.rs | 2 +- examples/3d/3d_scene.rs | 6 ++--- examples/3d/load_gltf.rs | 4 +-- examples/3d/msaa.rs | 4 +-- examples/3d/parenting.rs | 8 +++--- examples/3d/spawner.rs | 8 +++--- examples/3d/texture.rs | 2 +- examples/3d/update_gltf_scene.rs | 6 ++--- examples/3d/z_sort_debug.rs | 8 +++--- examples/android/android.rs | 6 ++--- examples/asset/asset_loading.rs | 10 +++---- examples/asset/hot_asset_reloading.rs | 4 +-- examples/game/breakout.rs | 12 ++++----- examples/ios/src/lib.rs | 8 +++--- examples/shader/array_texture.rs | 3 +-- examples/shader/hot_shader_reloading.rs | 4 +-- examples/shader/mesh_custom_attribute.rs | 4 +-- examples/shader/shader_custom_material.rs | 4 +-- examples/shader/shader_defs.rs | 6 ++--- examples/window/multiple_windows.rs | 6 ++--- 27 files changed, 86 insertions(+), 83 deletions(-) diff --git a/crates/bevy_render/src/entity.rs b/crates/bevy_render/src/entity.rs index c8837d39c3..a87aa88896 100644 --- a/crates/bevy_render/src/entity.rs +++ b/crates/bevy_render/src/entity.rs @@ -8,7 +8,6 @@ use crate::{ use base::MainPass; use bevy_asset::Handle; use bevy_ecs::Bundle; -use bevy_math::Vec3; use bevy_transform::components::{GlobalTransform, Transform}; /// A component bundle for "mesh" entities @@ -73,7 +72,7 @@ impl Default for Camera2dBundle { ..Default::default() }, visible_entities: Default::default(), - transform: Transform::from_translation(Vec3::new(0.0, 0.0, far - 0.1)), + transform: Transform::from_xyz(0.0, 0.0, far - 0.1), global_transform: Default::default(), } } diff --git a/crates/bevy_transform/src/components/global_transform.rs b/crates/bevy_transform/src/components/global_transform.rs index ad567e3e0e..e829cd8be3 100644 --- a/crates/bevy_transform/src/components/global_transform.rs +++ b/crates/bevy_transform/src/components/global_transform.rs @@ -12,6 +12,12 @@ pub struct GlobalTransform { } impl GlobalTransform { + /// Create a new [`GlobalTransform`] at the position `(x, y, z)` + #[inline] + pub fn from_xyz(x: f32, y: f32, z: f32) -> Self { + Self::from_translation(Vec3::new(x, y, z)) + } + #[inline] pub fn identity() -> Self { GlobalTransform { diff --git a/crates/bevy_transform/src/components/transform.rs b/crates/bevy_transform/src/components/transform.rs index 388a996257..6b370e5c16 100644 --- a/crates/bevy_transform/src/components/transform.rs +++ b/crates/bevy_transform/src/components/transform.rs @@ -12,6 +12,12 @@ pub struct Transform { } impl Transform { + /// Create a new [`Transform`] at the position `(x, y, z)` + #[inline] + pub fn from_xyz(x: f32, y: f32, z: f32) -> Self { + Self::from_translation(Vec3::new(x, y, z)) + } + #[inline] pub fn identity() -> Self { Transform { diff --git a/crates/bevy_transform/src/hierarchy/hierarchy_maintenance_system.rs b/crates/bevy_transform/src/hierarchy/hierarchy_maintenance_system.rs index fadd9707bc..8db0d9813f 100644 --- a/crates/bevy_transform/src/hierarchy/hierarchy_maintenance_system.rs +++ b/crates/bevy_transform/src/hierarchy/hierarchy_maintenance_system.rs @@ -72,7 +72,6 @@ mod test { use super::*; use crate::{hierarchy::BuildChildren, transform_propagate_system::transform_propagate_system}; use bevy_ecs::{IntoSystem, Resources, Schedule, SystemStage, World}; - use bevy_math::Vec3; #[test] fn correct_children() { @@ -92,13 +91,13 @@ mod test { let mut parent = None; let mut children = Vec::new(); commands - .spawn((Transform::from_translation(Vec3::new(1.0, 0.0, 0.0)),)) + .spawn((Transform::from_xyz(1.0, 0.0, 0.0),)) .for_current_entity(|entity| parent = Some(entity)) .with_children(|parent| { parent - .spawn((Transform::from_translation(Vec3::new(0.0, 2.0, 0.0)),)) + .spawn((Transform::from_xyz(0.0, 2.0, 0.0),)) .for_current_entity(|entity| children.push(entity)) - .spawn((Transform::from_translation(Vec3::new(0.0, 0.0, 3.0)),)) + .spawn((Transform::from_xyz(0.0, 0.0, 3.0),)) .for_current_entity(|entity| children.push(entity)); }); let parent = parent.unwrap(); diff --git a/crates/bevy_transform/src/transform_propagate_system.rs b/crates/bevy_transform/src/transform_propagate_system.rs index 6914ad31ab..a5b3ef19b0 100644 --- a/crates/bevy_transform/src/transform_propagate_system.rs +++ b/crates/bevy_transform/src/transform_propagate_system.rs @@ -72,7 +72,6 @@ mod test { use super::*; use crate::hierarchy::{parent_update_system, BuildChildren, BuildWorldChildren}; use bevy_ecs::{Resources, Schedule, SystemStage, World}; - use bevy_math::Vec3; #[test] fn did_propagate() { @@ -88,7 +87,7 @@ mod test { // Root entity world.spawn(( - Transform::from_translation(Vec3::new(1.0, 0.0, 0.0)), + Transform::from_xyz(1.0, 0.0, 0.0), GlobalTransform::identity(), )); @@ -96,18 +95,18 @@ mod test { world .build() .spawn(( - Transform::from_translation(Vec3::new(1.0, 0.0, 0.0)), + Transform::from_xyz(1.0, 0.0, 0.0), GlobalTransform::identity(), )) .with_children(|parent| { parent .spawn(( - Transform::from_translation(Vec3::new(0.0, 2.0, 0.)), + Transform::from_xyz(0.0, 2.0, 0.), GlobalTransform::identity(), )) .for_current_entity(|entity| children.push(entity)) .spawn(( - Transform::from_translation(Vec3::new(0.0, 0.0, 3.)), + Transform::from_xyz(0.0, 0.0, 3.), GlobalTransform::identity(), )) .for_current_entity(|entity| children.push(entity)); @@ -116,14 +115,12 @@ mod test { assert_eq!( *world.get::(children[0]).unwrap(), - GlobalTransform::from_translation(Vec3::new(1.0, 0.0, 0.0)) - * Transform::from_translation(Vec3::new(0.0, 2.0, 0.0)) + GlobalTransform::from_xyz(1.0, 0.0, 0.0) * Transform::from_xyz(0.0, 2.0, 0.0) ); assert_eq!( *world.get::(children[1]).unwrap(), - GlobalTransform::from_translation(Vec3::new(1.0, 0.0, 0.0)) - * Transform::from_translation(Vec3::new(0.0, 0.0, 3.0)) + GlobalTransform::from_xyz(1.0, 0.0, 0.0) * Transform::from_xyz(0.0, 0.0, 3.0) ); } @@ -145,18 +142,18 @@ mod test { let mut children = Vec::new(); commands .spawn(( - Transform::from_translation(Vec3::new(1.0, 0.0, 0.0)), + Transform::from_xyz(1.0, 0.0, 0.0), GlobalTransform::identity(), )) .with_children(|parent| { parent .spawn(( - Transform::from_translation(Vec3::new(0.0, 2.0, 0.0)), + Transform::from_xyz(0.0, 2.0, 0.0), GlobalTransform::identity(), )) .for_current_entity(|entity| children.push(entity)) .spawn(( - Transform::from_translation(Vec3::new(0.0, 0.0, 3.0)), + Transform::from_xyz(0.0, 0.0, 3.0), GlobalTransform::identity(), )) .for_current_entity(|entity| children.push(entity)); @@ -166,14 +163,12 @@ mod test { assert_eq!( *world.get::(children[0]).unwrap(), - GlobalTransform::from_translation(Vec3::new(1.0, 0.0, 0.0)) - * Transform::from_translation(Vec3::new(0.0, 2.0, 0.0)) + GlobalTransform::from_xyz(1.0, 0.0, 0.0) * Transform::from_xyz(0.0, 2.0, 0.0) ); assert_eq!( *world.get::(children[1]).unwrap(), - GlobalTransform::from_translation(Vec3::new(1.0, 0.0, 0.0)) - * Transform::from_translation(Vec3::new(0.0, 0.0, 3.0)) + GlobalTransform::from_xyz(1.0, 0.0, 0.0) * Transform::from_xyz(0.0, 0.0, 3.0) ); } } diff --git a/crates/bevy_ui/src/entity.rs b/crates/bevy_ui/src/entity.rs index 7eef58b4bd..64fb748e17 100644 --- a/crates/bevy_ui/src/entity.rs +++ b/crates/bevy_ui/src/entity.rs @@ -6,7 +6,6 @@ use crate::{ }; use bevy_asset::Handle; use bevy_ecs::Bundle; -use bevy_math::Vec3; use bevy_render::{ camera::{Camera, OrthographicProjection, VisibleEntities, WindowOrigin}, draw::Draw, @@ -189,7 +188,7 @@ impl Default for CameraUiBundle { ..Default::default() }, visible_entities: Default::default(), - transform: Transform::from_translation(Vec3::new(0.0, 0.0, far - 0.1)), + transform: Transform::from_xyz(0.0, 0.0, far - 0.1), global_transform: Default::default(), } } diff --git a/examples/2d/contributors.rs b/examples/2d/contributors.rs index b1f5627372..a38ab5dca2 100644 --- a/examples/2d/contributors.rs +++ b/examples/2d/contributors.rs @@ -74,7 +74,7 @@ fn setup( // some sprites should be flipped let flipped = rnd.gen_bool(0.5); - let mut transform = Transform::from_translation(Vec3::new(pos.0, pos.1, 0.0)); + let mut transform = Transform::from_xyz(pos.0, pos.1, 0.0); transform.scale.x *= if flipped { -1.0 } else { 1.0 }; commands diff --git a/examples/2d/texture_atlas.rs b/examples/2d/texture_atlas.rs index b02c724e99..c643d5e931 100644 --- a/examples/2d/texture_atlas.rs +++ b/examples/2d/texture_atlas.rs @@ -79,7 +79,7 @@ fn setup( // draw the atlas itself .spawn(SpriteBundle { material: materials.add(texture_atlas_texture.into()), - transform: Transform::from_translation(Vec3::new(-300.0, 0.0, 0.0)), + transform: Transform::from_xyz(-300.0, 0.0, 0.0), ..Default::default() }); } diff --git a/examples/3d/3d_scene.rs b/examples/3d/3d_scene.rs index d9dee8b308..dadb559a86 100644 --- a/examples/3d/3d_scene.rs +++ b/examples/3d/3d_scene.rs @@ -26,17 +26,17 @@ fn setup( .spawn(PbrBundle { mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })), material: materials.add(Color::rgb(0.8, 0.7, 0.6).into()), - transform: Transform::from_translation(Vec3::new(0.0, 0.5, 0.0)), + transform: Transform::from_xyz(0.0, 0.5, 0.0), ..Default::default() }) // light .spawn(LightBundle { - transform: Transform::from_translation(Vec3::new(4.0, 8.0, 4.0)), + transform: Transform::from_xyz(4.0, 8.0, 4.0), ..Default::default() }) // camera .spawn(Camera3dBundle { - transform: Transform::from_translation(Vec3::new(-2.0, 2.5, 5.0)) + transform: Transform::from_xyz(-2.0, 2.5, 5.0) .looking_at(Vec3::default(), Vec3::unit_y()), ..Default::default() }); diff --git a/examples/3d/load_gltf.rs b/examples/3d/load_gltf.rs index ccd1e98a49..c3340c6e0d 100644 --- a/examples/3d/load_gltf.rs +++ b/examples/3d/load_gltf.rs @@ -12,11 +12,11 @@ fn setup(commands: &mut Commands, asset_server: Res) { commands .spawn_scene(asset_server.load("models/FlightHelmet/FlightHelmet.gltf#Scene0")) .spawn(LightBundle { - transform: Transform::from_translation(Vec3::new(4.0, 5.0, 4.0)), + transform: Transform::from_xyz(4.0, 5.0, 4.0), ..Default::default() }) .spawn(Camera3dBundle { - transform: Transform::from_translation(Vec3::new(0.7, 0.7, 1.0)) + transform: Transform::from_xyz(0.7, 0.7, 1.0) .looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::unit_y()), ..Default::default() }); diff --git a/examples/3d/msaa.rs b/examples/3d/msaa.rs index 67bf1f45e3..1fe5688fd0 100644 --- a/examples/3d/msaa.rs +++ b/examples/3d/msaa.rs @@ -27,12 +27,12 @@ fn setup( }) // light .spawn(LightBundle { - transform: Transform::from_translation(Vec3::new(4.0, 8.0, 4.0)), + transform: Transform::from_xyz(4.0, 8.0, 4.0), ..Default::default() }) // camera .spawn(Camera3dBundle { - transform: Transform::from_translation(Vec3::new(-3.0, 3.0, 5.0)) + transform: Transform::from_xyz(-3.0, 3.0, 5.0) .looking_at(Vec3::default(), Vec3::unit_y()), ..Default::default() }); diff --git a/examples/3d/parenting.rs b/examples/3d/parenting.rs index 556bd1b307..ff8c2e9c27 100644 --- a/examples/3d/parenting.rs +++ b/examples/3d/parenting.rs @@ -38,7 +38,7 @@ fn setup( .spawn(PbrBundle { mesh: cube_handle.clone(), material: cube_material_handle.clone(), - transform: Transform::from_translation(Vec3::new(0.0, 0.0, 1.0)), + transform: Transform::from_xyz(0.0, 0.0, 1.0), ..Default::default() }) .with(Rotator) @@ -47,18 +47,18 @@ fn setup( parent.spawn(PbrBundle { mesh: cube_handle, material: cube_material_handle, - transform: Transform::from_translation(Vec3::new(0.0, 0.0, 3.0)), + transform: Transform::from_xyz(0.0, 0.0, 3.0), ..Default::default() }); }) // light .spawn(LightBundle { - transform: Transform::from_translation(Vec3::new(4.0, 5.0, -4.0)), + transform: Transform::from_xyz(4.0, 5.0, -4.0), ..Default::default() }) // camera .spawn(Camera3dBundle { - transform: Transform::from_translation(Vec3::new(5.0, 10.0, 10.0)) + transform: Transform::from_xyz(5.0, 10.0, 10.0) .looking_at(Vec3::default(), Vec3::unit_y()), ..Default::default() }); diff --git a/examples/3d/spawner.rs b/examples/3d/spawner.rs index 581776c355..1dc2cee20d 100644 --- a/examples/3d/spawner.rs +++ b/examples/3d/spawner.rs @@ -39,12 +39,12 @@ fn setup( commands // light .spawn(LightBundle { - transform: Transform::from_translation(Vec3::new(4.0, -4.0, 5.0)), + transform: Transform::from_xyz(4.0, -4.0, 5.0), ..Default::default() }) // camera .spawn(Camera3dBundle { - transform: Transform::from_translation(Vec3::new(0.0, 15.0, 150.0)) + transform: Transform::from_xyz(0.0, 15.0, 150.0) .looking_at(Vec3::default(), Vec3::unit_y()), ..Default::default() }); @@ -62,11 +62,11 @@ fn setup( ), ..Default::default() }), - transform: Transform::from_translation(Vec3::new( + transform: Transform::from_xyz( rng.gen_range(-50.0, 50.0), rng.gen_range(-50.0, 50.0), 0.0, - )), + ), ..Default::default() }); } diff --git a/examples/3d/texture.rs b/examples/3d/texture.rs index c2822ea891..db47465500 100644 --- a/examples/3d/texture.rs +++ b/examples/3d/texture.rs @@ -96,7 +96,7 @@ fn setup( }) // camera .spawn(Camera3dBundle { - transform: Transform::from_translation(Vec3::new(3.0, 5.0, 8.0)) + transform: Transform::from_xyz(3.0, 5.0, 8.0) .looking_at(Vec3::default(), Vec3::unit_y()), ..Default::default() }); diff --git a/examples/3d/update_gltf_scene.rs b/examples/3d/update_gltf_scene.rs index a8a323b9f9..a5140e8098 100644 --- a/examples/3d/update_gltf_scene.rs +++ b/examples/3d/update_gltf_scene.rs @@ -26,11 +26,11 @@ fn setup( ) { commands .spawn(LightBundle { - transform: Transform::from_translation(Vec3::new(4.0, 5.0, 4.0)), + transform: Transform::from_xyz(4.0, 5.0, 4.0), ..Default::default() }) .spawn(Camera3dBundle { - transform: Transform::from_translation(Vec3::new(1.05, 0.9, 1.5)) + transform: Transform::from_xyz(1.05, 0.9, 1.5) .looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::unit_y()), ..Default::default() }); @@ -39,7 +39,7 @@ fn setup( // with its parent commands .spawn(( - Transform::from_translation(Vec3::new(0.0, 0.0, -1.0)), + Transform::from_xyz(0.0, 0.0, -1.0), GlobalTransform::default(), )) .with_children(|parent| { diff --git a/examples/3d/z_sort_debug.rs b/examples/3d/z_sort_debug.rs index e1feccd9b0..d7a69e1b0f 100644 --- a/examples/3d/z_sort_debug.rs +++ b/examples/3d/z_sort_debug.rs @@ -55,7 +55,7 @@ fn setup( shaded: false, ..Default::default() }), - transform: Transform::from_translation(Vec3::new(0.0, 0.0, 1.0)), + transform: Transform::from_xyz(0.0, 0.0, 1.0), ..Default::default() }) .with(Rotator) @@ -68,7 +68,7 @@ fn setup( shaded: false, ..Default::default() }), - transform: Transform::from_translation(Vec3::new(0.0, 3.0, 0.0)), + transform: Transform::from_xyz(0.0, 3.0, 0.0), ..Default::default() }) .spawn(PbrBundle { @@ -77,13 +77,13 @@ fn setup( shaded: false, ..Default::default() }), - transform: Transform::from_translation(Vec3::new(0.0, -3.0, 0.0)), + transform: Transform::from_xyz(0.0, -3.0, 0.0), ..Default::default() }); }) // camera .spawn(Camera3dBundle { - transform: Transform::from_translation(Vec3::new(5.0, 10.0, 10.0)) + transform: Transform::from_xyz(5.0, 10.0, 10.0) .looking_at(Vec3::default(), Vec3::unit_y()), ..Default::default() }); diff --git a/examples/android/android.rs b/examples/android/android.rs index 4970307a62..ce8a9d616c 100644 --- a/examples/android/android.rs +++ b/examples/android/android.rs @@ -28,17 +28,17 @@ fn setup( .spawn(PbrBundle { mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })), material: materials.add(Color::rgb(0.8, 0.7, 0.6).into()), - transform: Transform::from_translation(Vec3::new(0.0, 0.5, 0.0)), + transform: Transform::from_xyz(0.0, 0.5, 0.0), ..Default::default() }) // light .spawn(LightBundle { - transform: Transform::from_translation(Vec3::new(4.0, 8.0, 4.0)), + transform: Transform::from_xyz(4.0, 8.0, 4.0), ..Default::default() }) // camera .spawn(Camera3dBundle { - transform: Transform::from_translation(Vec3::new(-2.0, 2.5, 5.0)) + transform: Transform::from_xyz(-2.0, 2.5, 5.0) .looking_at(Vec3::default(), Vec3::unit_y()), ..Default::default() }); diff --git a/examples/asset/asset_loading.rs b/examples/asset/asset_loading.rs index 793f468504..a471bc91e1 100644 --- a/examples/asset/asset_loading.rs +++ b/examples/asset/asset_loading.rs @@ -47,31 +47,31 @@ fn setup( .spawn(PbrBundle { mesh: monkey_handle, material: material_handle.clone(), - transform: Transform::from_translation(Vec3::new(-3.0, 0.0, 0.0)), + transform: Transform::from_xyz(-3.0, 0.0, 0.0), ..Default::default() }) // cube .spawn(PbrBundle { mesh: cube_handle, material: material_handle.clone(), - transform: Transform::from_translation(Vec3::new(0.0, 0.0, 0.0)), + transform: Transform::from_xyz(0.0, 0.0, 0.0), ..Default::default() }) // sphere .spawn(PbrBundle { mesh: sphere_handle, material: material_handle, - transform: Transform::from_translation(Vec3::new(3.0, 0.0, 0.0)), + transform: Transform::from_xyz(3.0, 0.0, 0.0), ..Default::default() }) // light .spawn(LightBundle { - transform: Transform::from_translation(Vec3::new(4.0, 5.0, 4.0)), + transform: Transform::from_xyz(4.0, 5.0, 4.0), ..Default::default() }) // camera .spawn(Camera3dBundle { - transform: Transform::from_translation(Vec3::new(0.0, 3.0, 10.0)) + transform: Transform::from_xyz(0.0, 3.0, 10.0) .looking_at(Vec3::default(), Vec3::unit_y()), ..Default::default() }); diff --git a/examples/asset/hot_asset_reloading.rs b/examples/asset/hot_asset_reloading.rs index 2209e7b2ab..62578443e5 100644 --- a/examples/asset/hot_asset_reloading.rs +++ b/examples/asset/hot_asset_reloading.rs @@ -26,12 +26,12 @@ fn setup(commands: &mut Commands, asset_server: Res) { .spawn_scene(scene_handle) // light .spawn(LightBundle { - transform: Transform::from_translation(Vec3::new(4.0, 5.0, 4.0)), + transform: Transform::from_xyz(4.0, 5.0, 4.0), ..Default::default() }) // camera .spawn(Camera3dBundle { - transform: Transform::from_translation(Vec3::new(2.0, 2.0, 6.0)) + transform: Transform::from_xyz(2.0, 2.0, 6.0) .looking_at(Vec3::default(), Vec3::unit_y()), ..Default::default() }); diff --git a/examples/game/breakout.rs b/examples/game/breakout.rs index 29e4532e3c..3d52641803 100644 --- a/examples/game/breakout.rs +++ b/examples/game/breakout.rs @@ -49,7 +49,7 @@ fn setup( // paddle .spawn(SpriteBundle { material: materials.add(Color::rgb(0.5, 0.5, 1.0).into()), - transform: Transform::from_translation(Vec3::new(0.0, -215.0, 0.0)), + transform: Transform::from_xyz(0.0, -215.0, 0.0), sprite: Sprite::new(Vec2::new(120.0, 30.0)), ..Default::default() }) @@ -58,7 +58,7 @@ fn setup( // ball .spawn(SpriteBundle { material: materials.add(Color::rgb(1.0, 0.5, 0.5).into()), - transform: Transform::from_translation(Vec3::new(0.0, -50.0, 1.0)), + transform: Transform::from_xyz(0.0, -50.0, 1.0), sprite: Sprite::new(Vec2::new(30.0, 30.0)), ..Default::default() }) @@ -97,7 +97,7 @@ fn setup( // left .spawn(SpriteBundle { material: wall_material.clone(), - transform: Transform::from_translation(Vec3::new(-bounds.x / 2.0, 0.0, 0.0)), + transform: Transform::from_xyz(-bounds.x / 2.0, 0.0, 0.0), sprite: Sprite::new(Vec2::new(wall_thickness, bounds.y + wall_thickness)), ..Default::default() }) @@ -105,7 +105,7 @@ fn setup( // right .spawn(SpriteBundle { material: wall_material.clone(), - transform: Transform::from_translation(Vec3::new(bounds.x / 2.0, 0.0, 0.0)), + transform: Transform::from_xyz(bounds.x / 2.0, 0.0, 0.0), sprite: Sprite::new(Vec2::new(wall_thickness, bounds.y + wall_thickness)), ..Default::default() }) @@ -113,7 +113,7 @@ fn setup( // bottom .spawn(SpriteBundle { material: wall_material.clone(), - transform: Transform::from_translation(Vec3::new(0.0, -bounds.y / 2.0, 0.0)), + transform: Transform::from_xyz(0.0, -bounds.y / 2.0, 0.0), sprite: Sprite::new(Vec2::new(bounds.x + wall_thickness, wall_thickness)), ..Default::default() }) @@ -121,7 +121,7 @@ fn setup( // top .spawn(SpriteBundle { material: wall_material, - transform: Transform::from_translation(Vec3::new(0.0, bounds.y / 2.0, 0.0)), + transform: Transform::from_xyz(0.0, bounds.y / 2.0, 0.0), sprite: Sprite::new(Vec2::new(bounds.x + wall_thickness, wall_thickness)), ..Default::default() }) diff --git a/examples/ios/src/lib.rs b/examples/ios/src/lib.rs index 3801169dd9..8ec9fa85cd 100644 --- a/examples/ios/src/lib.rs +++ b/examples/ios/src/lib.rs @@ -33,7 +33,7 @@ fn setup( .spawn(PbrBundle { mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })), material: materials.add(Color::rgb(0.5, 0.4, 0.3).into()), - transform: Transform::from_translation(Vec3::new(0.0, 0.5, 0.0)), + transform: Transform::from_xyz(0.0, 0.5, 0.0), ..Default::default() }) // sphere @@ -43,17 +43,17 @@ fn setup( radius: 0.5, })), material: materials.add(Color::rgb(0.1, 0.4, 0.8).into()), - transform: Transform::from_translation(Vec3::new(1.5, 1.5, 1.5)), + transform: Transform::from_xyz(1.5, 1.5, 1.5), ..Default::default() }) // light .spawn(LightBundle { - transform: Transform::from_translation(Vec3::new(4.0, 8.0, 4.0)), + transform: Transform::from_xyz(4.0, 8.0, 4.0), ..Default::default() }) // camera .spawn(Camera3dBundle { - transform: Transform::from_translation(Vec3::new(-2.0, 2.5, 5.0)) + transform: Transform::from_xyz(-2.0, 2.5, 5.0) .looking_at(Vec3::default(), Vec3::unit_y()), ..Default::default() }); diff --git a/examples/shader/array_texture.rs b/examples/shader/array_texture.rs index 6e6308613a..368831f7d3 100644 --- a/examples/shader/array_texture.rs +++ b/examples/shader/array_texture.rs @@ -110,8 +110,7 @@ fn setup( .unwrap(); commands.spawn(Camera3dBundle { - transform: Transform::from_translation(Vec3::new(2.0, 2.0, 2.0)) - .looking_at(Vec3::default(), Vec3::unit_y()), + transform: Transform::from_xyz(2.0, 2.0, 2.0).looking_at(Vec3::default(), Vec3::unit_y()), ..Default::default() }); } diff --git a/examples/shader/hot_shader_reloading.rs b/examples/shader/hot_shader_reloading.rs index df72952603..e64bfc0d00 100644 --- a/examples/shader/hot_shader_reloading.rs +++ b/examples/shader/hot_shader_reloading.rs @@ -67,13 +67,13 @@ fn setup( render_pipelines: RenderPipelines::from_pipelines(vec![RenderPipeline::new( pipeline_handle, )]), - transform: Transform::from_translation(Vec3::new(0.0, 0.0, 0.0)), + transform: Transform::from_xyz(0.0, 0.0, 0.0), ..Default::default() }) .with(material) // camera .spawn(Camera3dBundle { - transform: Transform::from_translation(Vec3::new(3.0, 5.0, -8.0)) + transform: Transform::from_xyz(3.0, 5.0, -8.0) .looking_at(Vec3::default(), Vec3::unit_y()), ..Default::default() }); diff --git a/examples/shader/mesh_custom_attribute.rs b/examples/shader/mesh_custom_attribute.rs index bd6f7562e5..03858f4a59 100644 --- a/examples/shader/mesh_custom_attribute.rs +++ b/examples/shader/mesh_custom_attribute.rs @@ -132,13 +132,13 @@ fn setup( render_pipelines: RenderPipelines::from_pipelines(vec![RenderPipeline::new( pipeline_handle, )]), - transform: Transform::from_translation(Vec3::new(0.0, 0.0, 0.0)), + transform: Transform::from_xyz(0.0, 0.0, 0.0), ..Default::default() }) .with(material) // camera .spawn(Camera3dBundle { - transform: Transform::from_translation(Vec3::new(3.0, 5.0, -8.0)) + transform: Transform::from_xyz(3.0, 5.0, -8.0) .looking_at(Vec3::default(), Vec3::unit_y()), ..Default::default() }); diff --git a/examples/shader/shader_custom_material.rs b/examples/shader/shader_custom_material.rs index 346a2c8338..ca74cdee0b 100644 --- a/examples/shader/shader_custom_material.rs +++ b/examples/shader/shader_custom_material.rs @@ -88,13 +88,13 @@ fn setup( render_pipelines: RenderPipelines::from_pipelines(vec![RenderPipeline::new( pipeline_handle, )]), - transform: Transform::from_translation(Vec3::new(0.0, 0.0, 0.0)), + transform: Transform::from_xyz(0.0, 0.0, 0.0), ..Default::default() }) .with(material) // camera .spawn(Camera3dBundle { - transform: Transform::from_translation(Vec3::new(3.0, 5.0, -8.0)) + transform: Transform::from_xyz(3.0, 5.0, -8.0) .looking_at(Vec3::default(), Vec3::unit_y()), ..Default::default() }); diff --git a/examples/shader/shader_defs.rs b/examples/shader/shader_defs.rs index e8b429c420..487e570520 100644 --- a/examples/shader/shader_defs.rs +++ b/examples/shader/shader_defs.rs @@ -109,7 +109,7 @@ fn setup( render_pipelines: RenderPipelines::from_pipelines(vec![RenderPipeline::new( pipeline_handle.clone(), )]), - transform: Transform::from_translation(Vec3::new(-2.0, 0.0, 0.0)), + transform: Transform::from_xyz(-2.0, 0.0, 0.0), ..Default::default() }) .with(green_material) @@ -119,13 +119,13 @@ fn setup( render_pipelines: RenderPipelines::from_pipelines(vec![RenderPipeline::new( pipeline_handle, )]), - transform: Transform::from_translation(Vec3::new(2.0, 0.0, 0.0)), + transform: Transform::from_xyz(2.0, 0.0, 0.0), ..Default::default() }) .with(blue_material) // camera .spawn(Camera3dBundle { - transform: Transform::from_translation(Vec3::new(3.0, 5.0, -8.0)) + transform: Transform::from_xyz(3.0, 5.0, -8.0) .looking_at(Vec3::default(), Vec3::unit_y()), ..Default::default() }); diff --git a/examples/window/multiple_windows.rs b/examples/window/multiple_windows.rs index be8f469298..b1929e525d 100644 --- a/examples/window/multiple_windows.rs +++ b/examples/window/multiple_windows.rs @@ -188,12 +188,12 @@ fn setup_pipeline( .spawn_scene(asset_server.load("models/monkey/Monkey.gltf#Scene0")) // light .spawn(LightBundle { - transform: Transform::from_translation(Vec3::new(4.0, 5.0, 4.0)), + transform: Transform::from_xyz(4.0, 5.0, 4.0), ..Default::default() }) // main camera .spawn(Camera3dBundle { - transform: Transform::from_translation(Vec3::new(0.0, 0.0, 6.0)) + transform: Transform::from_xyz(0.0, 0.0, 6.0) .looking_at(Vec3::default(), Vec3::unit_y()), ..Default::default() }) @@ -204,7 +204,7 @@ fn setup_pipeline( window: window_id, ..Default::default() }, - transform: Transform::from_translation(Vec3::new(6.0, 0.0, 0.0)) + transform: Transform::from_xyz(6.0, 0.0, 0.0) .looking_at(Vec3::default(), Vec3::unit_y()), ..Default::default() });