Crates.io | voxy |
lib.rs | voxy |
version | 0.2.0-alpha.1 |
source | src |
created_at | 2024-10-16 02:17:13.778109 |
updated_at | 2024-10-31 15:32:35.963334 |
description | Voxel engine for Bevy |
homepage | |
repository | |
max_upload_size | |
id | 1411052 |
size | 232,476 |
A voxel engine for Bevy.
Features:
.vox
files
Scene
use bevy::{core_pipeline::bloom::BloomSettings, prelude::*};
use voxy::prelude::*;
fn main() {
App::new()
.add_plugins((DefaultPlugins, voxy::DefaultPlugins))
.add_systems(Startup, setup)
.add_systems(Update, rotate)
.run();
}
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
// Spawn a scene with multiple models from a `.vox` file.
commands.spawn((
asset_server.load::<VoxelScene>("character.vox"),
SpatialBundle::default(),
));
// Setup default lighting.
commands.insert_resource(AmbientLight {
brightness: 500.,
..default()
});
// Setup the camera.
commands.spawn((
Camera3dBundle {
camera: Camera {
hdr: true,
..default()
},
transform: Transform::from_translation(Vec3::new(-60., 60., -60.))
.looking_at(Vec3::ZERO, Vec3::Y),
..Default::default()
},
BloomSettings::NATURAL,
));
}
// Rotate the right arm of our character.
fn rotate(models_query: Query<&VoxelSceneModels>, mut transform_query: Query<&mut Transform>) {
for models in &models_query {
if let Some(entity) = models.entities.get("right_arm") {
let mut transform = transform_query.get_mut(*entity).unwrap();
transform.rotate_around(Vec3::new(0., 24., 4.), Quat::from_rotation_x(0.01));
}
}
}