use bevy::prelude::*;
use bevy_editor_cam::{controller::component::EditorCam, DefaultEditorCamPlugins};
use big_space::{FloatingOrigin, GridCell};
fn main() {
App::new()
.add_plugins((
DefaultPlugins.build().disable::<TransformPlugin>(),
bevy_mod_picking::DefaultPickingPlugins,
DefaultEditorCamPlugins,
big_space::FloatingOriginPlugin::<i128>::default(),
big_space::debug::FloatingOriginDebugPlugin::<i128>::default(),
))
.insert_resource(ClearColor(Color::BLACK))
.add_systems(Startup, (setup, ui_setup))
.run()
}
fn setup(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
) {
commands.spawn((
Camera3dBundle {
transform: Transform::from_xyz(0.0, 0.0, 8.0)
.looking_at(Vec3::new(0.0, 0.0, 0.0), Vec3::Y),
projection: Projection::Perspective(PerspectiveProjection {
near: 1e-18,
..default()
}),
..default()
},
GridCell::<i128>::default(),
FloatingOrigin,
EditorCam::default(),
));
let mesh_handle = meshes.add(Sphere::new(0.5).mesh().ico(32).unwrap());
let matl_handle = materials.add(StandardMaterial {
base_color: Color::BLUE,
perceptual_roughness: 0.8,
reflectance: 1.0,
..default()
});
let mut translation = Vec3::ZERO;
for i in -16..=27 {
let j = 10_f32.powf(i as f32);
translation.x += j;
commands.spawn((
PbrBundle {
mesh: mesh_handle.clone(),
material: matl_handle.clone(),
transform: Transform::from_scale(Vec3::splat(j)).with_translation(translation),
..default()
},
GridCell::<i128>::default(),
));
}
commands.spawn((DirectionalLightBundle {
directional_light: DirectionalLight {
illuminance: 100_000.0,
..default()
},
..default()
},));
}
#[derive(Component, Reflect)]
pub struct BigSpaceDebugText;
#[derive(Component, Reflect)]
pub struct FunFactText;
fn ui_setup(mut commands: Commands) {
commands.spawn((
TextBundle::from_section(
"",
TextStyle {
font_size: 28.0,
color: Color::WHITE,
..default()
},
)
.with_text_justify(JustifyText::Left)
.with_style(Style {
position_type: PositionType::Absolute,
top: Val::Px(10.0),
left: Val::Px(10.0),
..default()
}),
BigSpaceDebugText,
));
commands.spawn((
TextBundle::from_section(
"",
TextStyle {
font_size: 52.0,
color: Color::WHITE,
..default()
},
)
.with_style(Style {
position_type: PositionType::Absolute,
bottom: Val::Px(10.0),
right: Val::Px(10.0),
left: Val::Px(10.0),
..default()
})
.with_text_justify(JustifyText::Center),
FunFactText,
));
}