diff --git a/Cargo.toml b/Cargo.toml index 67fcddc790..6dc1010c6a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,6 @@ profiler = ["bevy_ecs/profiler", "bevy_diagnostic/profiler"] members = [ "crates/*", "crates/bevy_ecs/hecs", - "examples/app/dynamic_plugin_loading/example_plugin" ] [dependencies] @@ -88,10 +87,6 @@ path = "examples/3d/texture.rs" name = "z_sort_debug" path = "examples/3d/z_sort_debug.rs" -[[example]] -name = "dynamic_plugin_loading" -path = "examples/app/dynamic_plugin_loading/main.rs" - [[example]] name = "empty_defaults" path = "examples/app/empty_defaults.rs" diff --git a/crates/bevy_pbr/src/material.rs b/crates/bevy_pbr/src/material.rs index 0ba5c76c23..7c4900feb7 100644 --- a/crates/bevy_pbr/src/material.rs +++ b/crates/bevy_pbr/src/material.rs @@ -20,3 +20,21 @@ impl Default for StandardMaterial { } } } + +impl From for StandardMaterial { + fn from(color: Color) -> Self { + StandardMaterial { + albedo: color, + ..Default::default() + } + } +} + +impl From> for StandardMaterial { + fn from(texture: Handle) -> Self { + StandardMaterial { + albedo_texture: Some(texture), + ..Default::default() + } + } +} diff --git a/crates/bevy_transform/src/components/rotation.rs b/crates/bevy_transform/src/components/rotation.rs index 5d7811397e..758b1bc982 100644 --- a/crates/bevy_transform/src/components/rotation.rs +++ b/crates/bevy_transform/src/components/rotation.rs @@ -9,6 +9,31 @@ impl Rotation { pub fn identity() -> Self { Self(Quat::identity()) } + + #[inline(always)] + pub fn from_rotation_yxz(yaw: f32, pitch: f32, roll: f32) -> Self { + Self(Quat::from_rotation_ypr(yaw, pitch, roll)) + } + + #[inline(always)] + pub fn from_rotation_xyz(x: f32, y: f32, z: f32) -> Self { + Self(Quat::from_rotation_ypr(y, x, z)) + } + + #[inline(always)] + pub fn from_rotation_x(x: f32) -> Self { + Self(Quat::from_rotation_x(x)) + } + + #[inline(always)] + pub fn from_rotation_y(y: f32) -> Self { + Self(Quat::from_rotation_y(y)) + } + + #[inline(always)] + pub fn from_rotation_z(z: f32) -> Self { + Self(Quat::from_rotation_z(z)) + } } impl Default for Rotation { diff --git a/examples/3d/3d_scene.rs b/examples/3d/3d_scene.rs index bae9313a34..e5a4a6d2cb 100644 --- a/examples/3d/3d_scene.rs +++ b/examples/3d/3d_scene.rs @@ -14,32 +14,18 @@ fn setup( mut meshes: ResMut>, mut materials: ResMut>, ) { - // create a cube and a plane mesh - let cube_handle = meshes.add(Mesh::from(shape::Cube { size: 1.0 })); - let plane_handle = meshes.add(Mesh::from(shape::Plane { size: 10.0 })); - - // create materials for our cube and plane - let cube_material_handle = materials.add(StandardMaterial { - albedo: Color::rgb(0.5, 0.4, 0.3), - ..Default::default() - }); - let plane_material_handle = materials.add(StandardMaterial { - albedo: Color::rgb(0.1, 0.2, 0.1), - ..Default::default() - }); - // add entities to the world commands // plane .spawn(PbrComponents { - mesh: plane_handle, - material: plane_material_handle, + mesh: meshes.add(Mesh::from(shape::Plane { size: 10.0 })), + material: materials.add(Color::rgb(0.1, 0.2, 0.1).into()), ..Default::default() }) // cube .spawn(PbrComponents { - mesh: cube_handle, - material: cube_material_handle, + mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })), + material: materials.add(Color::rgb(0.5, 0.4, 0.3).into()), translation: Translation::new(0.0, 1.0, 0.0), ..Default::default() }) diff --git a/examples/3d/load_model.rs b/examples/3d/load_model.rs index 2af55ab588..f759c5e18b 100644 --- a/examples/3d/load_model.rs +++ b/examples/3d/load_model.rs @@ -13,23 +13,14 @@ fn setup( asset_server: Res, mut materials: ResMut>, ) { - // load the mesh - let mesh_handle = asset_server - .load("assets/models/monkey/Monkey.gltf") - .unwrap(); - - // create a material for the mesh - let material_handle = materials.add(StandardMaterial { - albedo: Color::rgb(0.5, 0.4, 0.3), - ..Default::default() - }); - // add entities to the world commands // mesh .spawn(PbrComponents { - mesh: mesh_handle, - material: material_handle, + // load the mesh + mesh: asset_server.load("assets/models/monkey/Monkey.gltf").unwrap(), + // create a material for the mesh + material: materials.add(Color::rgb(0.5, 0.4, 0.3).into()), ..Default::default() }) // light diff --git a/examples/3d/msaa.rs b/examples/3d/msaa.rs index 63336ae07c..fa70a2deaa 100644 --- a/examples/3d/msaa.rs +++ b/examples/3d/msaa.rs @@ -22,10 +22,7 @@ fn setup( // cube .spawn(PbrComponents { mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })), - material: materials.add(StandardMaterial { - albedo: Color::rgb(0.5, 0.4, 0.3), - ..Default::default() - }), + material: materials.add(Color::rgb(0.5, 0.4, 0.3).into()), ..Default::default() }) // light diff --git a/examples/3d/parenting.rs b/examples/3d/parenting.rs index 720b6efc81..abcf7a0d22 100644 --- a/examples/3d/parenting.rs +++ b/examples/3d/parenting.rs @@ -1,7 +1,7 @@ use bevy::prelude::*; -struct Rotator; - +/// This example illustrates how to create parent->child relationships between entities how parent transforms +/// are propagated to their descendants fn main() { App::build() .add_resource(Msaa { samples: 4 }) @@ -11,6 +11,9 @@ fn main() { .run(); } +/// this component indicates what entities should rotate +struct Rotator; + /// rotates the parent, which will result in the child also rotating fn rotator_system(time: Res