Blender_bevy_components_wor.../crates/bevy_gltf_components/README.md
Mark Moissette 0cd7d5d53b
chore(): minor tweaks (#8)
* relaxed bevy version requirements to work with all v0.11.xx versions & the dependency between blueprints & components crate
* bevy_gltf_blueprints: added a more clear warning message for the random timing/ no children in scene issue
* docs(crates): modified the install instruction to be patch version agnostic
2023-09-29 12:59:07 +02:00

3.4 KiB

Crates.io Docs License Bevy tracking

bevy_gltf_components

This crate allows you to define Bevy components direclty inside gltf files and instanciate the components on the Bevy side.

Usage

important : the plugin for processing gltf files runs in update , so you cannot use the components directly if you spawn your scene from gltf in setup (the additional components will not show up)

Please see the

Here's a minimal usage example:

# Cargo.toml
[dependencies]
bevy="0.11"
bevy_gltf_components = { version = "0.1"} 

//too barebones of an example to be meaningfull, please see https://github.com/kaosat-dev/Blender_bevy_components_workflow/examples/basic for a real example
 fn main() {
    App::new()
         .add_plugins(DefaultPlugins)
         .add_plugin(ComponentsFromGltfPlugin)
         .add_system(spawn_level)
         .run();
 }
 
 fn spawn_level(
   asset_server: Res<AssetServer>, 
   mut commands: bevy::prelude::Commands,
   keycode: Res<Input<KeyCode>>,

 ){
 if keycode.just_pressed(KeyCode::Return) {
  commands.spawn(SceneBundle {
   scene: asset_server.load("basic/models/level1.glb#Scene0"),
   transform: Transform::from_xyz(2.0, 0.0, -5.0),
 ..Default::default()
 });
 }
}

Installation

Add the following to your [dependencies] section in Cargo.toml:

bevy_gltf_components = "0.1"

Or use cargo add:

cargo add bevy_gltf_components

SystemSet

the ordering of systems is very important !

For example to replace your proxy components (stand-in components when you cannot/ do not want to use real components in the gltf file) with actual ones,

which should happen AFTER the components from the gltf files have been injected,

so bevy_gltf_components provides a SystemSet for that purpose:GltfComponentsSet

Typically , the order of systems should be

bevy_gltf_components (GltfComponentsSet::Injection) => replace_proxies

Examples

https://github.com/kaosat-dev/Blender_bevy_components_workflow/tree/main/examples/basic

License

This crate, all its code, contents & assets is Dual-licensed under either of