Change deprecated shapes to new primitives in examples. Fix example lighting.
This commit is contained in:
parent
e8fe3d4b95
commit
9622c85367
|
@ -1,10 +1,6 @@
|
|||
use std::f32::consts::PI;
|
||||
|
||||
use bevy::{
|
||||
prelude::{shape::Plane, *},
|
||||
scene::SceneInstance,
|
||||
window::close_on_esc,
|
||||
};
|
||||
use bevy::{prelude::*, scene::SceneInstance, window::close_on_esc};
|
||||
use bevy_mod_outline::{
|
||||
AutoGenerateOutlineNormalsPlugin, InheritOutlineBundle, OutlineBundle, OutlinePlugin,
|
||||
OutlineVolume,
|
||||
|
@ -20,10 +16,7 @@ fn main() {
|
|||
OutlinePlugin,
|
||||
AutoGenerateOutlineNormalsPlugin,
|
||||
))
|
||||
.insert_resource(AmbientLight {
|
||||
color: Color::WHITE,
|
||||
brightness: 1.0,
|
||||
})
|
||||
.insert_resource(AmbientLight::default())
|
||||
.add_systems(Startup, setup)
|
||||
.add_systems(Update, (setup_scene_once_loaded, close_on_esc))
|
||||
.run();
|
||||
|
@ -47,10 +40,12 @@ fn setup(
|
|||
|
||||
// Plane
|
||||
commands.spawn(PbrBundle {
|
||||
mesh: meshes.add(Mesh::from(Plane {
|
||||
size: 500000.0,
|
||||
subdivisions: 0,
|
||||
})),
|
||||
mesh: meshes.add(
|
||||
Plane3d::new(Vec3::Y)
|
||||
.mesh()
|
||||
.size(500000.0, 500000.0)
|
||||
.build(),
|
||||
),
|
||||
material: materials.add(StandardMaterial::from(Color::rgb(0.3, 0.5, 0.3))),
|
||||
..default()
|
||||
});
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
use std::{f32::consts::TAU, num::Wrapping, time::Duration};
|
||||
|
||||
use bevy::{
|
||||
prelude::{shape::Capsule, *},
|
||||
window::close_on_esc,
|
||||
};
|
||||
use bevy::{prelude::*, window::close_on_esc};
|
||||
|
||||
use bevy_mod_outline::*;
|
||||
|
||||
|
@ -36,14 +33,14 @@ fn setup(
|
|||
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||
) {
|
||||
commands.insert_resource(MyAssets {
|
||||
mesh: meshes.add(Mesh::from(Capsule {
|
||||
radius: 1.0,
|
||||
rings: 10,
|
||||
depth: 2.0,
|
||||
latitudes: 15,
|
||||
longitudes: 15,
|
||||
..default()
|
||||
})),
|
||||
mesh: meshes.add(
|
||||
Capsule3d::new(1.0, 2.0)
|
||||
.mesh()
|
||||
.rings(10)
|
||||
.latitudes(15)
|
||||
.longitudes(15)
|
||||
.build(),
|
||||
),
|
||||
material: materials.add(StandardMaterial::from(Color::BEIGE)),
|
||||
});
|
||||
|
||||
|
|
|
@ -13,10 +13,7 @@ fn main() {
|
|||
),
|
||||
)
|
||||
.add_plugins(OutlinePlugin)
|
||||
.insert_resource(AmbientLight {
|
||||
color: Color::WHITE,
|
||||
brightness: 1.0,
|
||||
})
|
||||
.insert_resource(AmbientLight::default())
|
||||
.add_systems(Startup, setup)
|
||||
.add_systems(
|
||||
Update,
|
||||
|
|
|
@ -27,10 +27,7 @@ fn main() {
|
|||
OutlinePlugin,
|
||||
AutoGenerateOutlineNormalsPlugin,
|
||||
))
|
||||
.insert_resource(AmbientLight {
|
||||
brightness: 1.0,
|
||||
..default()
|
||||
})
|
||||
.insert_resource(AmbientLight::default())
|
||||
.add_systems(Startup, setup)
|
||||
.add_systems(Update, (name_morphs, setup_outlines, setup_animations))
|
||||
.run();
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
use std::f32::consts::TAU;
|
||||
|
||||
use bevy::{
|
||||
prelude::{
|
||||
shape::{Capsule, Plane, Torus, UVSphere},
|
||||
*,
|
||||
},
|
||||
window::close_on_esc,
|
||||
};
|
||||
use bevy::{prelude::*, window::close_on_esc};
|
||||
|
||||
use bevy_mod_outline::*;
|
||||
|
||||
|
@ -32,11 +26,7 @@ fn setup(
|
|||
// Add sphere with child meshes sticking out of it
|
||||
commands
|
||||
.spawn(PbrBundle {
|
||||
mesh: meshes.add(Mesh::from(UVSphere {
|
||||
radius: 0.75,
|
||||
sectors: 30,
|
||||
stacks: 30,
|
||||
})),
|
||||
mesh: meshes.add(Sphere::new(0.75).mesh().uv(30, 30)),
|
||||
material: materials.add(StandardMaterial::from(Color::rgb(0.9, 0.1, 0.1))),
|
||||
transform: Transform::from_translation(Vec3::new(0.0, 1.0, 0.0)),
|
||||
..default()
|
||||
|
@ -57,14 +47,14 @@ fn setup(
|
|||
.with_children(|parent| {
|
||||
parent
|
||||
.spawn(PbrBundle {
|
||||
mesh: meshes.add(Mesh::from(Capsule {
|
||||
radius: 0.2,
|
||||
rings: 15,
|
||||
depth: 1.0,
|
||||
latitudes: 15,
|
||||
longitudes: 15,
|
||||
..Default::default()
|
||||
})),
|
||||
mesh: meshes.add(
|
||||
Capsule3d::new(0.2, 1.0)
|
||||
.mesh()
|
||||
.rings(15)
|
||||
.latitudes(15)
|
||||
.longitudes(15)
|
||||
.build(),
|
||||
),
|
||||
material: materials.add(StandardMaterial::from(Color::rgb(0.1, 0.1, 0.9))),
|
||||
transform: Transform::from_rotation(Quat::from_axis_angle(Vec3::X, TAU / 4.0))
|
||||
.with_translation(Vec3::new(0.0, 0.0, 0.75)),
|
||||
|
@ -73,12 +63,16 @@ fn setup(
|
|||
.insert(InheritOutlineBundle::default());
|
||||
parent
|
||||
.spawn(PbrBundle {
|
||||
mesh: meshes.add(Mesh::from(Torus {
|
||||
radius: 0.5,
|
||||
ring_radius: 0.1,
|
||||
subdivisions_segments: 30,
|
||||
subdivisions_sides: 15,
|
||||
})),
|
||||
mesh: meshes.add(
|
||||
Torus {
|
||||
minor_radius: 0.1,
|
||||
major_radius: 0.5,
|
||||
}
|
||||
.mesh()
|
||||
.minor_resolution(15)
|
||||
.major_resolution(30)
|
||||
.build(),
|
||||
),
|
||||
material: materials.add(StandardMaterial::from(Color::rgb(0.1, 0.1, 0.9))),
|
||||
transform: Transform::from_rotation(Quat::from_axis_angle(Vec3::Z, TAU / 4.0))
|
||||
.with_translation(Vec3::new(0.0, 0.0, -0.75)),
|
||||
|
@ -89,16 +83,12 @@ fn setup(
|
|||
|
||||
// Add plane, light source, and camera
|
||||
commands.spawn(PbrBundle {
|
||||
mesh: meshes.add(Mesh::from(Plane {
|
||||
size: 5.0,
|
||||
subdivisions: 0,
|
||||
})),
|
||||
mesh: meshes.add(Plane3d::new(Vec3::Y).mesh().size(5.0, 5.0).build()),
|
||||
material: materials.add(StandardMaterial::from(Color::rgb(0.3, 0.5, 0.3))),
|
||||
..default()
|
||||
});
|
||||
commands.spawn(PointLightBundle {
|
||||
point_light: PointLight {
|
||||
intensity: 1500.0,
|
||||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
use std::f32::consts::PI;
|
||||
|
||||
use bevy::{
|
||||
prelude::{
|
||||
shape::{Plane, Torus},
|
||||
*,
|
||||
},
|
||||
prelude::*,
|
||||
render::{camera::Viewport, view::RenderLayers},
|
||||
window::{close_on_esc, PrimaryWindow},
|
||||
};
|
||||
|
@ -38,12 +35,16 @@ fn setup(
|
|||
// Add torus using the regular surface normals for outlining
|
||||
commands
|
||||
.spawn(PbrBundle {
|
||||
mesh: meshes.add(Mesh::from(Torus {
|
||||
radius: 0.6,
|
||||
ring_radius: 0.2,
|
||||
subdivisions_segments: 40,
|
||||
subdivisions_sides: 20,
|
||||
})),
|
||||
mesh: meshes.add(
|
||||
Torus {
|
||||
minor_radius: 0.2,
|
||||
major_radius: 0.6,
|
||||
}
|
||||
.mesh()
|
||||
.minor_resolution(20)
|
||||
.major_resolution(40)
|
||||
.build(),
|
||||
),
|
||||
material: materials.add(StandardMaterial::from(Color::rgb(0.1, 0.1, 0.9))),
|
||||
transform: Transform::from_rotation(Quat::from_rotation_x(0.5 * PI))
|
||||
.with_translation(0.8 * Vec3::Y),
|
||||
|
@ -62,16 +63,12 @@ fn setup(
|
|||
|
||||
// Add plane and light source
|
||||
commands.spawn(PbrBundle {
|
||||
mesh: meshes.add(Mesh::from(Plane {
|
||||
size: 5.0,
|
||||
subdivisions: 0,
|
||||
})),
|
||||
mesh: meshes.add(Plane3d::new(Vec3::Y).mesh().size(5.0, 5.0).build()),
|
||||
material: materials.add(StandardMaterial::from(Color::rgb(0.3, 0.5, 0.3))),
|
||||
..default()
|
||||
});
|
||||
commands.spawn(PointLightBundle {
|
||||
point_light: PointLight {
|
||||
intensity: 1500.0,
|
||||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
use std::f32::consts::{PI, TAU};
|
||||
|
||||
use bevy::{
|
||||
prelude::{
|
||||
shape::{Cube, Plane, Torus},
|
||||
*,
|
||||
},
|
||||
window::close_on_esc,
|
||||
};
|
||||
use bevy::{prelude::*, window::close_on_esc};
|
||||
|
||||
use bevy_mod_outline::*;
|
||||
|
||||
|
@ -33,7 +27,7 @@ fn setup(
|
|||
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||
) {
|
||||
// Add cube with generated outline normals
|
||||
let mut cube_mesh = Mesh::from(Cube { size: 1.0 });
|
||||
let mut cube_mesh = Cuboid::new(1.0, 1.0, 1.0).mesh();
|
||||
cube_mesh.generate_outline_normals().unwrap();
|
||||
commands
|
||||
.spawn(PbrBundle {
|
||||
|
@ -55,12 +49,16 @@ fn setup(
|
|||
// Add torus using the regular surface normals for outlining
|
||||
commands
|
||||
.spawn(PbrBundle {
|
||||
mesh: meshes.add(Mesh::from(Torus {
|
||||
radius: 0.3,
|
||||
ring_radius: 0.1,
|
||||
subdivisions_segments: 20,
|
||||
subdivisions_sides: 10,
|
||||
})),
|
||||
mesh: meshes.add(
|
||||
Torus {
|
||||
minor_radius: 0.1,
|
||||
major_radius: 0.3,
|
||||
}
|
||||
.mesh()
|
||||
.minor_resolution(10)
|
||||
.major_resolution(20)
|
||||
.build(),
|
||||
),
|
||||
material: materials.add(StandardMaterial::from(Color::rgb(0.9, 0.1, 0.1))),
|
||||
transform: Transform::from_xyz(0.0, 1.2, 2.0)
|
||||
.with_rotation(Quat::from_rotation_x(0.5 * PI)),
|
||||
|
@ -78,16 +76,12 @@ fn setup(
|
|||
|
||||
// Add plane, light source, and camera
|
||||
commands.spawn(PbrBundle {
|
||||
mesh: meshes.add(Mesh::from(Plane {
|
||||
size: 5.0,
|
||||
subdivisions: 0,
|
||||
})),
|
||||
mesh: meshes.add(Plane3d::new(Vec3::Y).mesh().size(5.0, 5.0).build()),
|
||||
material: materials.add(StandardMaterial::from(Color::rgb(0.3, 0.5, 0.3))),
|
||||
..default()
|
||||
});
|
||||
commands.spawn(PointLightBundle {
|
||||
point_light: PointLight {
|
||||
intensity: 1500.0,
|
||||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue