Crates.io | bevy_vox |
lib.rs | bevy_vox |
version | |
source | src |
created_at | 2020-10-17 08:05:06.340365 |
updated_at | 2024-11-30 08:47:13.096205 |
description | Load MagicaVoxel Vox file for bevy engine |
homepage | |
repository | https://github.com/erasin/bevy_vox |
max_upload_size | |
id | 301212 |
Cargo.toml error: | TOML parse error at line 22, column 1 | 22 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Load MagicaVoxel Vox file for bevy engine.
bevy_vox | bevy |
---|---|
follow | >=0.15 |
0.10 | 0.14 |
Example
use bevy::prelude::*;
use bevy_vox::VoxPlugin;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(VoxPlugin { swap_yz: true })
.insert_resource(AmbientLight {
color: Color::WHITE,
brightness: 0.5,
})
.add_systems(Startup, setup)
.add_systems(Update, rotate_model)
.run();
}
#[derive(Component)]
struct VoxModel;
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
// add entities to the world
commands.spawn((
SceneRoot(asset_server.load("2x2x2.vox")),
Transform::from_xyz(-1.0, 0.0, 0.0),
VoxModel,
));
// light
commands.spawn((
PointLight {
intensity: 3_000_000.0,
..Default::default()
},
Transform::from_xyz(3.0, -3.5, 4.5),
));
// camera
commands.spawn((
Camera3d::default(),
Transform::from_xyz(6.0, -6.0, 6.0).looking_at(Vec3::ZERO, Vec3::Y),
));
}
fn rotate_model(mut query: Query<&mut Transform, With<VoxModel>>, time: Res<Time>) {
for mut transform in query.iter_mut() {
transform.rotation = Quat::from_euler(EulerRot::XYZ, 0.0, time.elapsed_secs(), 0.0);
}
}