use bevy::prelude::*; use crate::Label; pub const PLANET_RADIUS: f32 = 860.0; pub(crate) const SPAWN_ALTITUDE: f32 = PLANET_RADIUS + 100.0; #[derive(Component, Debug)] pub struct CyberBike; #[derive(Component)] pub struct CyberSphere; fn spawn_giant_sphere( mut commands: Commands, mut meshes: ResMut>, mut materials: ResMut>, ) { let mut color = Color::DARK_GRAY; color.set_a(0.8); commands .spawn_bundle(PbrBundle { mesh: meshes.add(Mesh::from(shape::Icosphere { radius: PLANET_RADIUS, subdivisions: 24, })), material: materials.add(StandardMaterial { base_color: color, metallic: 0.65, perceptual_roughness: 0.3, alpha_mode: AlphaMode::Blend, ..Default::default() }), ..Default::default() }) .insert(CyberSphere); } fn spawn_cyberbike(mut commands: Commands, asset_server: Res) { commands .spawn_bundle(( Transform { translation: Vec3::new(SPAWN_ALTITUDE, 0.0, 0.0), ..Default::default() } .looking_at(Vec3::ZERO, Vec3::Y), GlobalTransform::identity(), )) .with_children(|rider| { rider.spawn_scene(asset_server.load("cyber-bike_no_y_up.glb#Scene0")); }) .insert(CyberBike); } pub struct CyberGeomPlugin; impl Plugin for CyberGeomPlugin { fn build(&self, app: &mut App) { app.add_startup_system(spawn_giant_sphere.label(Label::Geometry)) .add_startup_system(spawn_cyberbike.label(Label::Geometry)); } }