Aevyrie 44ff1f32de
Bevy 0.16 (#46)
# Objective

- Working branch to target all fixes for bevy 0.16

Co-authored-by: Zachary Harrold <zac@harrold.com.au>
2025-04-09 23:09:19 -07:00

54 lines
1.6 KiB
Rust

//! Big spaces are infinite, looping back on themselves smoothly. This example requires the use of
//! the `i8` feature, because a small world is needed to be able to see the "edge".
use bevy::prelude::*;
use big_space::prelude::*;
fn main() {
App::new()
.add_plugins((
DefaultPlugins.build().disable::<TransformPlugin>(),
BigSpacePlugin::default(),
FloatingOriginDebugPlugin::default(),
CameraControllerPlugin::default(),
))
.add_systems(Startup, setup_scene)
.run();
}
fn setup_scene(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
) {
let sphere = Mesh3d(meshes.add(Sphere::default()));
let matl = MeshMaterial3d(materials.add(Color::WHITE));
commands.spawn_big_space(Grid::default(), |root_grid| {
let width = || -8..8;
for (x, y, z) in width()
.flat_map(|x| width().map(move |y| (x, y)))
.flat_map(|(x, y)| width().map(move |z| (x, y, z)))
{
root_grid.spawn_spatial((
sphere.clone(),
matl.clone(),
GridCell {
x: x * 16,
y: y * 16,
z: z * 16,
},
));
}
root_grid.spawn_spatial(DirectionalLight::default());
root_grid.spawn_spatial((
Camera3d::default(),
Transform::from_xyz(0.0, 0.0, 10.0),
FloatingOrigin,
CameraController::default()
.with_speed(10.)
.with_smoothness(0.99, 0.95),
));
});
}