5429bf4779
* feat(bevy_gltf_save_load): saving & loading implemented * created new crate for save & load features, uses & filters out blueprints for efficient loading * saving & loading, even with dynamically spawned nested hierarchies works * component filter , resource filter & save path root are configurable * for saving: added removal & cleanup logic for children component with children that have been filtered out: ie no more invalid children getting stored in the save files ! * added sending of event once saving is done * feat(examples/save-load): example for the new crate * loading level static & dynamic data as blueprints * added a bit of ui when entering saving & loading states & cleanup when exiting * feat(bevy_gltf_blueprints): significant rewrite of how the crate works * simplified spawning process, no more spawning children containing blueprints etc * simplified post process : instead of copying original entity into blueprint root we now copy blueprint root data (components & children) into the original entity ! fixes #96 * much simpler code wise * solves issue with needing to register components that we only use on the bevy side (not gltf) since we are not copying the bevy data into the blueprints data * added **copyComponents** helper to copy components from one entity to another, excluding existing components on the target entity, & some bells & whistles * **Name** is now optional when spawning a blueprint: closes #97 * **Transform** is now optional when spawning a blueprint: closes #98 * removed transform from bundle (BREAKING change) * added (optional) **NoInBlueprint** component to have finer control over whether to inject the **InBlueprint** component inside spawned blueprint entities * added (optional) **Library** component, so we can override library path when we want * added (optional) **AddToGameWorld** component for convenience to automatically add entities to the game world, if there is one * chore(bevy_gltf_components): removed verbose output, cleaned it up a bit * feat(tools/auto_export): added option to split out "dynamic" objects in main scenes * ie if a collection instance (or its original collection) has a "dynamic" (aka mutable, saveable etc) flag it can get exported to a seperate gltf file (essentially acting like an "initial save") * the rest of the levels (the "static" data) is exported without the dynamic objects and can be reused with save files ! |
||
---|---|---|
.. | ||
src | ||
Cargo.toml | ||
LICENSE.md | ||
LICENSE_APACHE.md | ||
LICENSE_MIT.md | ||
README.md |
README.md
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
- example
- or use
bevy_asset_loader
for a reliable workflow. - alternatively, use the
bevy_gltf_blueprints
crate, build on this crate's features, that allows you to directly spawn entities from gltf based blueprints.
Here's a minimal usage example:
# Cargo.toml
[dependencies]
bevy="0.12"
bevy_gltf_components = { version = "0.2"}
//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
Compatible Bevy versions
The main branch is compatible with the latest Bevy release, while the branch bevy_main
tries to track the main
branch of Bevy (PRs updating the tracked commit are welcome).
Compatibility of bevy_gltf_components
versions:
bevy_gltf_components |
bevy |
---|---|
0.2 |
0.12 |
0.1 |
0.11 |
branch main |
0.12 |
branch bevy_main |
main |
License
This crate, all its code, contents & assets is Dual-licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)