Aevyrie 5345af11d4
Plugin Refactors (#45)
Refactors plugins to make usage more flexible. Originally intended to
allow for running in the fixed update schedule, but decided against this
in favor of making plugins more granular, and realizing running in fixed
update wouldn't actually be desirable.

---------

Co-authored-by: Zachary Harrold <zac@harrold.com.au>
2025-05-14 21:10:58 -07:00

52 lines
1.5 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>(),
BigSpaceDefaultPlugins,
))
.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,
BigSpaceCameraController::default()
.with_speed(10.)
.with_smoothness(0.99, 0.95),
));
});
}