2022-01-12 08:18:13 +00:00
|
|
|
use bevy::prelude::*;
|
|
|
|
|
2022-02-08 21:27:57 +00:00
|
|
|
use crate::Label;
|
2022-01-14 06:05:51 +00:00
|
|
|
|
2022-02-09 06:00:05 +00:00
|
|
|
pub const PLANET_RADIUS: f32 = 860.0;
|
2022-01-14 00:14:08 +00:00
|
|
|
pub(crate) const SPAWN_ALTITUDE: f32 = PLANET_RADIUS + 100.0;
|
2022-01-12 08:18:13 +00:00
|
|
|
|
|
|
|
#[derive(Component, Debug)]
|
|
|
|
pub struct CyberBike;
|
|
|
|
|
2022-01-14 00:14:08 +00:00
|
|
|
#[derive(Component)]
|
|
|
|
pub struct CyberSphere;
|
|
|
|
|
|
|
|
fn spawn_giant_sphere(
|
2022-01-12 08:18:13 +00:00
|
|
|
mut commands: Commands,
|
|
|
|
mut meshes: ResMut<Assets<Mesh>>,
|
|
|
|
mut materials: ResMut<Assets<StandardMaterial>>,
|
|
|
|
) {
|
2022-02-08 04:28:06 +00:00
|
|
|
let mut color = Color::DARK_GRAY;
|
|
|
|
color.set_a(0.0);
|
2022-01-12 08:18:13 +00:00
|
|
|
commands
|
|
|
|
.spawn_bundle(PbrBundle {
|
|
|
|
mesh: meshes.add(Mesh::from(shape::Icosphere {
|
|
|
|
radius: PLANET_RADIUS,
|
2022-01-29 21:31:15 +00:00
|
|
|
subdivisions: 24,
|
2022-01-12 08:18:13 +00:00
|
|
|
})),
|
|
|
|
material: materials.add(StandardMaterial {
|
2022-02-08 04:28:06 +00:00
|
|
|
base_color: color,
|
2022-01-29 21:31:15 +00:00
|
|
|
metallic: 0.6,
|
|
|
|
perceptual_roughness: 0.4,
|
2022-02-08 04:28:06 +00:00
|
|
|
alpha_mode: AlphaMode::Mask(0.5),
|
2022-01-12 08:18:13 +00:00
|
|
|
..Default::default()
|
|
|
|
}),
|
|
|
|
|
|
|
|
..Default::default()
|
|
|
|
})
|
2022-02-08 04:28:06 +00:00
|
|
|
.insert(CyberSphere);
|
2022-01-12 08:18:13 +00:00
|
|
|
}
|
|
|
|
|
2022-01-14 00:14:08 +00:00
|
|
|
fn spawn_cyberbike(mut commands: Commands, asset_server: Res<AssetServer>) {
|
2022-01-12 08:18:13 +00:00
|
|
|
commands
|
|
|
|
.spawn_bundle((
|
|
|
|
Transform {
|
2022-01-14 00:14:08 +00:00
|
|
|
translation: Vec3::new(SPAWN_ALTITUDE, 0.0, 0.0),
|
2022-01-12 08:18:13 +00:00
|
|
|
..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"));
|
|
|
|
})
|
2022-02-08 21:27:57 +00:00
|
|
|
.insert(CyberBike);
|
2022-01-14 00:14:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub struct CyberGeomPlugin;
|
|
|
|
impl Plugin for CyberGeomPlugin {
|
|
|
|
fn build(&self, app: &mut App) {
|
2022-01-14 06:05:51 +00:00
|
|
|
app.add_startup_system(spawn_giant_sphere.label(Label::Geometry))
|
|
|
|
.add_startup_system(spawn_cyberbike.label(Label::Geometry));
|
2022-01-14 00:14:08 +00:00
|
|
|
}
|
2022-01-12 08:18:13 +00:00
|
|
|
}
|