Crates.io | bevy_dae |
lib.rs | bevy_dae |
version | |
source | src |
created_at | 2025-05-06 10:49:11.501528+00 |
updated_at | 2025-05-06 10:49:11.501528+00 |
description | A Bevy plugin for loading and rendering DAE (Collada) files. |
homepage | |
repository | |
max_upload_size | |
id | 1662207 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | 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 |
A Bevy plugin for loading and rendering DAE (Collada) files in the Bevy game engine.
Add the following to your Cargo.toml
:
[dependencies]
bevy_dae = "0.1.0"
use bevy::prelude::*;
use bevy_dae::ColladaPlugin;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(ColladaPlugin)
.add_systems(Startup, setup)
.run();
}
fn setup(
mut commands: Commands,
asset_server: Res<AssetServer>,
mut materials: ResMut<Assets<StandardMaterial>>
) {
// Load and spawn a COLLADA model
commands.spawn((
Mesh3d(asset_server.load("models/your_model.dae")),
MeshMaterial3d(
materials.add(StandardMaterial {
base_color: Color::rgb(0.8, 0.7, 0.6),
perceptual_roughness: 0.5,
metallic: 0.2,
..default()
})
),
Transform::from_scale(Vec3::splat(0.5)),
));
// Add a camera
commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(0.0, 1.5, 5.0)
.looking_at(Vec3::new(0.0, 0.5, 0.0), Vec3::Y),
..default()
});
// Add some light
commands.spawn(PointLightBundle {
point_light: PointLight {
intensity: 1500.0,
shadows_enabled: true,
..default()
},
transform: Transform::from_xyz(4.0, 8.0, 4.0),
..default()
});
}
The library also provides utility functions for working with DAE files:
use bevy_dae::dae_to_triangle_mesh;
use mesh_loader::collada::from_str;
// Load a Collada file
let collada_str = include_str!("models/your_model.dae");
let collada = from_str(collada_str).unwrap();
// Convert a DAE mesh to a Bevy triangle mesh
if let Some(triangle_mesh) = dae_to_triangle_mesh(&collada, 0) {
// Use the converted mesh...
}
Check out the examples folder for working examples:
joint.rs
- Demonstrates loading and rendering a jointed modelRun an example with:
cargo run --example joint
Licensed under MIT license (LICENSE).
Contributions are welcome! Feel free to submit a Pull Request.
mesh-loader
crate for Collada file parsing