update to bevy 0.15 rc

Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
Schmarni
2024-11-20 10:04:49 +01:00
parent 690b433516
commit 7320ae8dac
34 changed files with 1338 additions and 1079 deletions

View File

@@ -2,7 +2,7 @@
use bevy::prelude::*;
use bevy_mod_openxr::add_xr_plugins;
use bevy_mod_xr::session::{XrSessionCreated, XrTrackingRoot};
use bevy_mod_xr::session::XrSessionCreated;
use bevy_xr_utils::tracking_utils::{
TrackingUtilitiesPlugin, XrTrackedLeftGrip, XrTrackedLocalFloor, XrTrackedRightGrip,
XrTrackedStage, XrTrackedView,
@@ -29,25 +29,23 @@ fn setup(
mut materials: ResMut<Assets<StandardMaterial>>,
) {
// circular base
commands.spawn(PbrBundle {
mesh: meshes.add(Circle::new(4.0)),
material: materials.add(Color::WHITE),
transform: Transform::from_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)),
..default()
});
commands.spawn((
Mesh3d(meshes.add(Circle::new(4.0))),
MeshMaterial3d(materials.add(Color::WHITE)),
Transform::from_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)),
));
// light
commands.spawn(PointLightBundle {
point_light: PointLight {
commands.spawn((
PointLight {
shadows_enabled: true,
..default()
},
transform: Transform::from_xyz(4.0, 8.0, 4.0),
..default()
});
commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y),
..default()
});
Transform::from_xyz(4.0, 8.0, 4.0),
));
commands.spawn((
Camera3d::default(),
Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y),
));
}
fn spawn_hands(
@@ -57,22 +55,16 @@ fn spawn_hands(
) {
let left = cmds
.spawn((
PbrBundle {
mesh: meshes.add(Cuboid::new(0.1, 0.1, 0.05)),
material: materials.add(Color::srgb_u8(124, 144, 255)),
transform: Transform::from_xyz(0.0, 0.5, 0.0),
..default()
},
Mesh3d(meshes.add(Cuboid::new(0.1, 0.1, 0.05))),
MeshMaterial3d(materials.add(Color::srgb_u8(124, 144, 255))),
Transform::from_xyz(0.0, 0.5, 0.0),
XrTrackedLeftGrip,
))
.id();
let bundle = (
PbrBundle {
mesh: meshes.add(Cuboid::new(0.1, 0.1, 0.05)),
material: materials.add(Color::srgb_u8(124, 144, 255)),
transform: Transform::from_xyz(0.0, 0.5, 0.0),
..default()
},
Mesh3d(meshes.add(Cuboid::new(0.1, 0.1, 0.05))),
MeshMaterial3d(materials.add(Color::srgb_u8(124, 144, 255))),
Transform::from_xyz(0.0, 0.5, 0.0),
XrTrackedRightGrip,
);
let right = cmds.spawn(bundle).id();
@@ -80,40 +72,31 @@ fn spawn_hands(
let head = cmds
.spawn((
PbrBundle {
mesh: meshes.add(Cuboid::new(0.2, 0.2, 0.2)),
material: materials.add(Color::srgb_u8(255, 144, 144)),
transform: Transform::from_xyz(0.0, 0.0, 0.0),
..default()
},
Mesh3d(meshes.add(Cuboid::new(0.2, 0.2, 0.2))),
MeshMaterial3d(materials.add(Color::srgb_u8(255, 144, 144))),
Transform::from_xyz(0.0, 0.0, 0.0),
XrTrackedView,
))
.id();
//local_floor emulated
let local_floor = cmds
.spawn((
PbrBundle {
mesh: meshes.add(Cuboid::new(0.5, 0.1, 0.5)),
material: materials.add(Color::srgb_u8(144, 255, 144)),
transform: Transform::from_xyz(0.0, 0.0, 0.0),
..default()
},
Mesh3d(meshes.add(Cuboid::new(0.5, 0.1, 0.5))),
MeshMaterial3d(materials.add(Color::srgb_u8(144, 255, 144))),
Transform::from_xyz(0.0, 0.0, 0.0),
XrTrackedLocalFloor,
))
.id();
let stage = cmds
.spawn((
PbrBundle {
mesh: meshes.add(Cuboid::new(0.5, 0.1, 0.5)),
material: materials.add(Color::srgb_u8(144, 255, 255)),
transform: Transform::from_xyz(0.0, 0.0, 0.0),
..default()
},
Mesh3d(meshes.add(Cuboid::new(0.5, 0.1, 0.5))),
MeshMaterial3d(materials.add(Color::srgb_u8(144, 255, 255))),
Transform::from_xyz(0.0, 0.0, 0.0),
XrTrackedStage,
))
.id();
cmds.entity(stage)
.push_children(&[left, right, head, local_floor]);
.add_children(&[left, right, head, local_floor]);
}