From 2358d53b7a060a323c25882ff1b61ac15586973d Mon Sep 17 00:00:00 2001 From: Joe Ardent Date: Thu, 25 Jul 2024 14:51:08 -0700 Subject: [PATCH] done with it for now, bringing back into cyber rider --- src/bike.rs | 28 ++++++++++++---------------- src/main.rs | 3 ++- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/bike.rs b/src/bike.rs index 1816a2c..67affe6 100644 --- a/src/bike.rs +++ b/src/bike.rs @@ -157,28 +157,31 @@ fn wheels_helper( }; let xform = Transform::from_translation(position); + let hub_mesh: Mesh = Sphere::new(0.1).into(); let hub = commands .spawn(( Name::new("hub"), - SpatialBundle::from_transform(xform), RigidBody::Dynamic, MassPropertiesBundle::new_computed(&Collider::sphere(0.1), 200.0), - )) - .with_children(|parent| { - let mesh: Mesh = Sphere::new(0.1).into(); - parent.spawn(PbrBundle { - mesh: meshes.add(mesh), + PbrBundle { + mesh: meshes.add(hub_mesh), material: materials.add(wheel_material.clone()), + transform: xform, ..Default::default() - }); - }) + }, + )) .id(); let tire = commands .spawn(( Name::new("tire"), - SpatialBundle::from_transform(xform), + PbrBundle { + mesh: meshes.add(tire_mesh), + material: materials.add(wheel_material.clone()), + transform: xform, + ..Default::default() + }, CyberWheel, RigidBody::Dynamic, collider, @@ -190,13 +193,6 @@ fn wheels_helper( CollisionMargin(0.05), SweptCcd::NON_LINEAR, )) - .with_children(|p| { - p.spawn(PbrBundle { - mesh: meshes.add(tire_mesh), - material: materials.add(wheel_material.clone()), - ..Default::default() - }); - }) .id(); // connect hubs and tires to make wheels diff --git a/src/main.rs b/src/main.rs index 3af1149..e766fec 100644 --- a/src/main.rs +++ b/src/main.rs @@ -43,6 +43,7 @@ fn ground_and_light( ) { commands .spawn(( + SpatialBundle::default(), RigidBody::Static, Collider::cuboid(50.0, 0.5, 50.0), CollisionMargin(0.1), @@ -53,7 +54,7 @@ fn ground_and_light( p.spawn(PbrBundle { mesh: meshes.add(Plane3d::default().mesh().size(50.0, 50.0)), material: materials.add(Color::from(SILVER)), - transform: Transform::from_xyz(0.0, 1.0, 0.0), + transform: Transform::from_xyz(0.0, 0.4, 0.0), ..default() }); });