From 4519fb94a586049f0908c5001a4462e67fc77ec2 Mon Sep 17 00:00:00 2001 From: "kaosat.dev" Date: Fri, 19 Jul 2024 12:44:46 +0200 Subject: [PATCH] refactor(): removed legacy crates --- crates/bevy_gltf_blueprints/Cargo.toml | 21 -- crates/bevy_gltf_blueprints/LICENSE.md | 4 - crates/bevy_gltf_blueprints/LICENSE_APACHE.md | 201 ----------- crates/bevy_gltf_blueprints/LICENSE_MIT.md | 21 -- crates/bevy_gltf_blueprints/src/aabb.rs | 61 ---- crates/bevy_gltf_blueprints/src/animation.rs | 18 - crates/bevy_gltf_blueprints/src/assets.rs | 60 ---- .../src/copy_components.rs | 106 ------ crates/bevy_gltf_blueprints/src/lib.rs | 179 ---------- crates/bevy_gltf_blueprints/src/materials.rs | 201 ----------- crates/bevy_gltf_blueprints/src/old.rs | 248 -------------- .../src/spawn_from_blueprints.rs | 312 ------------------ .../src/spawn_post_process.rs | 100 ------ crates/bevy_gltf_components/Cargo.toml | 22 -- crates/bevy_gltf_components/LICENSE.md | 4 - crates/bevy_gltf_components/LICENSE_APACHE.md | 201 ----------- crates/bevy_gltf_components/LICENSE_MIT.md | 21 -- .../src/blender_settings.rs | 8 - .../src/blender_settings/lighting.rs | 97 ------ crates/bevy_gltf_components/src/lib.rs | 102 ------ .../bevy_gltf_components/src/process_gltfs.rs | 97 ------ .../src/ronstring_to_reflect_component.rs | 134 -------- crates/bevy_gltf_components/src/utils.rs | 3 - crates/bevy_gltf_save_load/Cargo.toml | 21 -- crates/bevy_gltf_save_load/LICENSE.md | 4 - crates/bevy_gltf_save_load/LICENSE_APACHE.md | 201 ----------- crates/bevy_gltf_save_load/LICENSE_MIT.md | 21 -- .../bevy_gltf_save_load/src/gltf_out_test.rs | 216 ------------ crates/bevy_registry_export/Cargo.toml | 21 -- crates/bevy_registry_export/LICENSE.md | 4 - crates/bevy_registry_export/LICENSE_APACHE.md | 201 ----------- crates/bevy_registry_export/LICENSE_MIT.md | 21 -- .../bevy_registry_export/src/export_types.rs | 269 --------------- crates/bevy_registry_export/src/lib.rs | 73 ---- .../README.md => blenvy/README_blueprints.md} | 0 .../README.md => blenvy/README_components.md} | 0 .../README.md => blenvy/README_registry.md} | 0 .../README.md => blenvy/README_save_load.md} | 0 .../src => blenvy/src/save_load}/loading.rs | 0 .../lib.rs => blenvy/src/save_load/mod.rs} | 0 .../src => blenvy/src/save_load}/saveable.rs | 0 .../src => blenvy/src/save_load}/saving.rs | 0 examples/README.md | 4 +- 43 files changed, 2 insertions(+), 3275 deletions(-) delete mode 100644 crates/bevy_gltf_blueprints/Cargo.toml delete mode 100644 crates/bevy_gltf_blueprints/LICENSE.md delete mode 100644 crates/bevy_gltf_blueprints/LICENSE_APACHE.md delete mode 100644 crates/bevy_gltf_blueprints/LICENSE_MIT.md delete mode 100644 crates/bevy_gltf_blueprints/src/aabb.rs delete mode 100644 crates/bevy_gltf_blueprints/src/animation.rs delete mode 100644 crates/bevy_gltf_blueprints/src/assets.rs delete mode 100644 crates/bevy_gltf_blueprints/src/copy_components.rs delete mode 100644 crates/bevy_gltf_blueprints/src/lib.rs delete mode 100644 crates/bevy_gltf_blueprints/src/materials.rs delete mode 100644 crates/bevy_gltf_blueprints/src/old.rs delete mode 100644 crates/bevy_gltf_blueprints/src/spawn_from_blueprints.rs delete mode 100644 crates/bevy_gltf_blueprints/src/spawn_post_process.rs delete mode 100644 crates/bevy_gltf_components/Cargo.toml delete mode 100644 crates/bevy_gltf_components/LICENSE.md delete mode 100644 crates/bevy_gltf_components/LICENSE_APACHE.md delete mode 100644 crates/bevy_gltf_components/LICENSE_MIT.md delete mode 100644 crates/bevy_gltf_components/src/blender_settings.rs delete mode 100644 crates/bevy_gltf_components/src/blender_settings/lighting.rs delete mode 100644 crates/bevy_gltf_components/src/lib.rs delete mode 100644 crates/bevy_gltf_components/src/process_gltfs.rs delete mode 100644 crates/bevy_gltf_components/src/ronstring_to_reflect_component.rs delete mode 100644 crates/bevy_gltf_components/src/utils.rs delete mode 100644 crates/bevy_gltf_save_load/Cargo.toml delete mode 100644 crates/bevy_gltf_save_load/LICENSE.md delete mode 100644 crates/bevy_gltf_save_load/LICENSE_APACHE.md delete mode 100644 crates/bevy_gltf_save_load/LICENSE_MIT.md delete mode 100644 crates/bevy_gltf_save_load/src/gltf_out_test.rs delete mode 100644 crates/bevy_registry_export/Cargo.toml delete mode 100644 crates/bevy_registry_export/LICENSE.md delete mode 100644 crates/bevy_registry_export/LICENSE_APACHE.md delete mode 100644 crates/bevy_registry_export/LICENSE_MIT.md delete mode 100644 crates/bevy_registry_export/src/export_types.rs delete mode 100644 crates/bevy_registry_export/src/lib.rs rename crates/{bevy_gltf_blueprints/README.md => blenvy/README_blueprints.md} (100%) rename crates/{bevy_gltf_components/README.md => blenvy/README_components.md} (100%) rename crates/{bevy_registry_export/README.md => blenvy/README_registry.md} (100%) rename crates/{bevy_gltf_save_load/README.md => blenvy/README_save_load.md} (100%) rename crates/{bevy_gltf_save_load/src => blenvy/src/save_load}/loading.rs (100%) rename crates/{bevy_gltf_save_load/src/lib.rs => blenvy/src/save_load/mod.rs} (100%) rename crates/{bevy_gltf_save_load/src => blenvy/src/save_load}/saveable.rs (100%) rename crates/{bevy_gltf_save_load/src => blenvy/src/save_load}/saving.rs (100%) diff --git a/crates/bevy_gltf_blueprints/Cargo.toml b/crates/bevy_gltf_blueprints/Cargo.toml deleted file mode 100644 index 5ca181c..0000000 --- a/crates/bevy_gltf_blueprints/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -[package] -name = "bevy_gltf_blueprints" -version = "0.11.0" -authors = ["Mark 'kaosat-dev' Moissette"] -description = "Adds the ability to define Blueprints/Prefabs for Bevy inside gltf files and spawn them in Bevy." -homepage = "https://github.com/kaosat-dev/Blender_bevy_components_workflow" -repository = "https://github.com/kaosat-dev/Blender_bevy_components_workflow" -keywords = ["gamedev", "bevy", "gltf", "blueprint", "prefab"] -categories = ["game-development"] -edition = "2021" -license = "MIT OR Apache-2.0" - -[lints] -workspace = true - -[dependencies] -bevy_gltf_components = { version = "0.6", path = "../bevy_gltf_components" } -bevy = { version = "0.14", default-features = false, features = ["bevy_asset", "bevy_scene", "bevy_gltf", "bevy_animation", "animation"] } - -[dev-dependencies] -bevy = { version = "0.14", default-features = false, features = ["dynamic_linking"] } \ No newline at end of file diff --git a/crates/bevy_gltf_blueprints/LICENSE.md b/crates/bevy_gltf_blueprints/LICENSE.md deleted file mode 100644 index ad21aac..0000000 --- a/crates/bevy_gltf_blueprints/LICENSE.md +++ /dev/null @@ -1,4 +0,0 @@ -This crate is available under either: - -* The [MIT License](./LICENSE_MIT) -* The [Apache License, Version 2.0](./LICENSE_APACHE) \ No newline at end of file diff --git a/crates/bevy_gltf_blueprints/LICENSE_APACHE.md b/crates/bevy_gltf_blueprints/LICENSE_APACHE.md deleted file mode 100644 index f748977..0000000 --- a/crates/bevy_gltf_blueprints/LICENSE_APACHE.md +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [2023] [Mark "kaosat-dev" Moissette] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file diff --git a/crates/bevy_gltf_blueprints/LICENSE_MIT.md b/crates/bevy_gltf_blueprints/LICENSE_MIT.md deleted file mode 100644 index f8b9094..0000000 --- a/crates/bevy_gltf_blueprints/LICENSE_MIT.md +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2023 Mark "kaosat-dev" Moissette - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/crates/bevy_gltf_blueprints/src/aabb.rs b/crates/bevy_gltf_blueprints/src/aabb.rs deleted file mode 100644 index 7c1c218..0000000 --- a/crates/bevy_gltf_blueprints/src/aabb.rs +++ /dev/null @@ -1,61 +0,0 @@ -use bevy::{math::Vec3A, prelude::*, render::primitives::Aabb}; - -use crate::{BluePrintsConfig, Spawned}; - -/// helper system that computes the compound aabbs of the scenes/blueprints -pub fn compute_scene_aabbs( - root_entities: Query<(Entity, &Name), (With, Without)>, - children: Query<&Children>, - existing_aabbs: Query<&Aabb>, - - mut blueprints_config: ResMut, - mut commands: Commands, -) { - // compute compound aabb - for (root_entity, name) in root_entities.iter() { - // info!("generating aabb for {:?}", name); - - // only recompute aabb if it has not already been done before - if blueprints_config.aabb_cache.contains_key(&name.to_string()) { - let aabb = blueprints_config - .aabb_cache - .get(&name.to_string()) - .expect("we should have the aabb available"); - commands.entity(root_entity).insert(*aabb); - } else { - let aabb = compute_descendant_aabb(root_entity, &children, &existing_aabbs); - commands.entity(root_entity).insert(aabb); - blueprints_config.aabb_cache.insert(name.to_string(), aabb); - } - } -} - -pub fn compute_descendant_aabb( - root_entity: Entity, - children: &Query<&Children>, - existing_aabbs: &Query<&Aabb>, -) -> Aabb { - if let Ok(children_list) = children.get(root_entity) { - let mut chilren_aabbs: Vec = vec![]; - for child in children_list.iter() { - if let Ok(aabb) = existing_aabbs.get(*child) { - chilren_aabbs.push(*aabb); - } else { - let aabb = compute_descendant_aabb(*child, children, existing_aabbs); - chilren_aabbs.push(aabb); - } - } - - let mut min = Vec3A::splat(f32::MAX); - let mut max = Vec3A::splat(f32::MIN); - for aabb in chilren_aabbs.iter() { - min = min.min(aabb.min()); - max = max.max(aabb.max()); - } - let aabb = Aabb::from_min_max(Vec3::from(min), Vec3::from(max)); - - return aabb; - } - - Aabb::default() -} diff --git a/crates/bevy_gltf_blueprints/src/animation.rs b/crates/bevy_gltf_blueprints/src/animation.rs deleted file mode 100644 index 4f2d652..0000000 --- a/crates/bevy_gltf_blueprints/src/animation.rs +++ /dev/null @@ -1,18 +0,0 @@ -use bevy::prelude::*; -use bevy::utils::HashMap; - -#[derive(Component, Reflect, Default, Debug)] -#[reflect(Component)] -/// storage for animations for a given entity (hierarchy), essentially a clone of gltf's `named_animations` -pub struct Animations { - pub named_animations: HashMap>, - pub named_indices: HashMap, - pub graph: Handle, -} - -#[derive(Component, Debug)] -/// Stop gap helper component : this is inserted into a "root" entity (an entity representing a whole gltf file) -/// so that the root entity knows which of its children contains an actualy `AnimationPlayer` component -/// this is for convenience, because currently , Bevy's gltf parsing inserts `AnimationPlayers` "one level down" -/// ie armature/root for animated models, which means more complex queries to trigger animations that we want to avoid -pub struct AnimationPlayerLink(pub Entity); diff --git a/crates/bevy_gltf_blueprints/src/assets.rs b/crates/bevy_gltf_blueprints/src/assets.rs deleted file mode 100644 index 73d4bf5..0000000 --- a/crates/bevy_gltf_blueprints/src/assets.rs +++ /dev/null @@ -1,60 +0,0 @@ -use std::path::{Path, PathBuf}; - -use bevy::{asset::LoadedUntypedAsset, gltf::Gltf, prelude::*, utils::HashMap}; - -use crate::{BluePrintsConfig, BlueprintAnimations}; - -/// helper component, is used to store the list of sub blueprints to enable automatic loading of dependend blueprints -#[derive(Component, Reflect, Default, Debug)] -#[reflect(Component)] -pub struct BlueprintAsset { - pub name: String, - pub path: String, -} - -/// helper component, is used to store the list of sub blueprints to enable automatic loading of dependend blueprints -#[derive(Component, Reflect, Default, Debug)] -#[reflect(Component)] -pub struct LocalAssets(pub Vec); - -/// helper component, is used to store the list of sub blueprints to enable automatic loading of dependend blueprints -#[derive(Component, Reflect, Default, Debug)] -#[reflect(Component)] -pub struct BlueprintAssets(pub Vec); - -//////////////////////// -/// -/// flag component, usually added when a blueprint is loaded -#[derive(Component)] -pub(crate) struct BlueprintAssetsLoaded; -/// flag component -#[derive(Component)] -pub(crate) struct BlueprintAssetsNotLoaded; - -/// helper component, for tracking loaded assets's loading state, id , handle etc -#[derive(Debug)] -pub(crate) struct AssetLoadTracker { - #[allow(dead_code)] - pub name: String, - pub id: AssetId, - pub loaded: bool, - #[allow(dead_code)] - pub handle: Handle, -} - -/// helper component, for tracking loaded assets -#[derive(Component, Debug)] -pub(crate) struct AssetsToLoad { - pub all_loaded: bool, - pub asset_infos: Vec, - pub progress: f32, -} -impl Default for AssetsToLoad { - fn default() -> Self { - Self { - all_loaded: Default::default(), - asset_infos: Default::default(), - progress: Default::default(), - } - } -} diff --git a/crates/bevy_gltf_blueprints/src/copy_components.rs b/crates/bevy_gltf_blueprints/src/copy_components.rs deleted file mode 100644 index f978382..0000000 --- a/crates/bevy_gltf_blueprints/src/copy_components.rs +++ /dev/null @@ -1,106 +0,0 @@ -use bevy::{ecs::world::Command, prelude::*}; -use std::any::TypeId; - -// originally based https://github.com/bevyengine/bevy/issues/1515, -// more specifically https://gist.github.com/nwtnni/85d6b87ae75337a522166c500c9a8418 -// to work with Bevy 0.11 -// to copy components between entities but NOT overwriting any existing components -// plus some bells & whistles -pub struct CopyComponents { - pub source: Entity, - pub destination: Entity, - pub exclude: Vec, - pub stringent: bool, -} - -impl CopyComponents { - // Copy all components from an entity to another. - // Using an entity with no components as the destination creates a copy of the source entity. - // Panics if: - // - the components are not registered in the type registry, - // - the world does not have a type registry - // - the source or destination entity do not exist - fn transfer_components(self, world: &mut World) { - let components = { - let registry = world - .get_resource::() - .expect("the world should have a type registry") - .read(); - - world - .get_entity(self.source) - .expect("source entity should exist") - .archetype() - .components() - .filter_map(|component_id| { - let component_info = world - .components() - .get_info(component_id) - .expect("component info should be available"); - - let type_id = component_info.type_id().unwrap(); - if self.exclude.contains(&type_id) { - debug!("excluding component: {:?}", component_info.name()); - None - } else { - debug!( - "cloning: component: {:?} {:?}", - component_info.name(), - type_id - ); - - if let Some(type_registration) = registry.get(type_id) { - Some(type_registration) - } else if self.stringent { - return Some(registry.get(type_id).unwrap_or_else(|| { - panic!( - "cannot clone entity: component: {:?} is not registered", - component_info.name() - ) - })); - } else { - warn!( - "cannot clone component: component: {:?} is not registered", - component_info.name() - ); - None - } - } - }) - .map(|type_id| { - return ( - type_id.data::().unwrap().clone(), - type_id.type_info().type_id(), // we need the original type_id down the line - ); - }) - .collect::>() - }; - - for (component, type_id) in components { - let type_registry: &AppTypeRegistry = world.resource(); - let type_registry = type_registry.clone(); - let type_registry = type_registry.read(); - let source = component - .reflect(world.get_entity(self.source).unwrap()) - .unwrap() - .clone_value(); - - let mut destination = world - .get_entity_mut(self.destination) - .expect("destination entity should exist"); - - // println!("contains typeid {:?} {}", type_id, destination.contains_type_id(type_id)); - // we only want to copy components that are NOT already in the destination (ie no overwriting existing components) - if !destination.contains_type_id(type_id) { - component.insert(&mut destination, &*source, &type_registry); - } - } - } -} - -// This allows the command to be used in systems -impl Command for CopyComponents { - fn apply(self, world: &mut World) { - self.transfer_components(world); - } -} diff --git a/crates/bevy_gltf_blueprints/src/lib.rs b/crates/bevy_gltf_blueprints/src/lib.rs deleted file mode 100644 index db9181f..0000000 --- a/crates/bevy_gltf_blueprints/src/lib.rs +++ /dev/null @@ -1,179 +0,0 @@ -pub mod spawn_from_blueprints; -pub use spawn_from_blueprints::*; - -pub mod spawn_post_process; -pub(crate) use spawn_post_process::*; - -pub mod animation; -pub use animation::*; - -pub mod aabb; -pub use aabb::*; - -pub mod materials; -pub use materials::*; - -pub mod copy_components; -pub use copy_components::*; - -use core::fmt; -use std::path::PathBuf; - -use bevy::{ - prelude::*, - render::{primitives::Aabb, view::VisibilitySystems}, - utils::HashMap, -}; -use bevy_gltf_components::{ComponentsFromGltfPlugin, GltfComponentsSet}; - -#[derive(SystemSet, Debug, Hash, PartialEq, Eq, Clone)] -/// set for the two stages of blueprint based spawning : -pub enum GltfBlueprintsSet { - Spawn, - AfterSpawn, -} - -#[derive(Bundle)] -pub struct BluePrintBundle { - pub blueprint: BlueprintName, - pub spawn_here: SpawnHere, -} -impl Default for BluePrintBundle { - fn default() -> Self { - BluePrintBundle { - blueprint: BlueprintName("default".into()), - spawn_here: SpawnHere, - } - } -} - -#[derive(Clone, Resource)] -pub struct BluePrintsConfig { - pub(crate) format: GltfFormat, - pub(crate) library_folder: PathBuf, - pub(crate) aabbs: bool, - pub(crate) aabb_cache: HashMap, // cache for aabbs - - pub(crate) material_library: bool, - pub(crate) material_library_folder: PathBuf, - pub(crate) material_library_cache: HashMap>, -} - -#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, Default)] -pub enum GltfFormat { - #[default] - GLB, - GLTF, -} - -impl fmt::Display for GltfFormat { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - GltfFormat::GLB => { - write!(f, "glb",) - } - GltfFormat::GLTF => { - write!(f, "gltf") - } - } - } -} - -#[derive(Debug, Clone)] -/// Plugin for gltf blueprints -pub struct BlueprintsPlugin { - pub legacy_mode: bool, // flag that gets passed on to bevy_gltf_components - - pub format: GltfFormat, - /// The base folder where library/blueprints assets are loaded from, relative to the executable. - pub library_folder: PathBuf, - /// Automatically generate aabbs for the blueprints root objects - pub aabbs: bool, - pub material_library: bool, - pub material_library_folder: PathBuf, -} - -impl Default for BlueprintsPlugin { - fn default() -> Self { - Self { - legacy_mode: true, - format: GltfFormat::GLB, - library_folder: PathBuf::from("models/library"), - aabbs: false, - material_library: false, - material_library_folder: PathBuf::from("materials"), - } - } -} - -fn aabbs_enabled(blueprints_config: Res) -> bool { - blueprints_config.aabbs -} - -fn materials_library_enabled(blueprints_config: Res) -> bool { - blueprints_config.material_library -} - -impl Plugin for BlueprintsPlugin { - fn build(&self, app: &mut App) { - app.add_plugins(ComponentsFromGltfPlugin { - legacy_mode: self.legacy_mode, - }) - .register_type::() - .register_type::() - .register_type::() - .register_type::() - .register_type::() - .register_type::>() - .register_type::>>() - .insert_resource(BluePrintsConfig { - format: self.format, - library_folder: self.library_folder.clone(), - - aabbs: self.aabbs, - aabb_cache: HashMap::new(), - - material_library: self.material_library, - material_library_folder: self.material_library_folder.clone(), - material_library_cache: HashMap::new(), - }) - .configure_sets( - Update, - (GltfBlueprintsSet::Spawn, GltfBlueprintsSet::AfterSpawn) - .chain() - .after(GltfComponentsSet::Injection), - ) - .add_systems( - Update, - ( - ( - prepare_blueprints, - check_for_loaded, - spawn_from_blueprints, - apply_deferred, - ) - .chain(), - (compute_scene_aabbs, apply_deferred) - .chain() - .run_if(aabbs_enabled), - apply_deferred, - ( - materials_inject, - check_for_material_loaded, - materials_inject2, - ) - .chain() - .run_if(materials_library_enabled), - ) - .chain() - .in_set(GltfBlueprintsSet::Spawn), - ) - .add_systems( - PostUpdate, - (spawned_blueprint_post_process, apply_deferred) - .chain() - .in_set(GltfBlueprintsSet::AfterSpawn) - .before(VisibilitySystems::CheckVisibility), - ); - } -} diff --git a/crates/bevy_gltf_blueprints/src/materials.rs b/crates/bevy_gltf_blueprints/src/materials.rs deleted file mode 100644 index f942331..0000000 --- a/crates/bevy_gltf_blueprints/src/materials.rs +++ /dev/null @@ -1,201 +0,0 @@ -use std::path::Path; - -use bevy::{ - asset::{AssetServer, Assets, Handle}, - ecs::{ - component::Component, - entity::Entity, - query::{Added, With}, - reflect::ReflectComponent, - system::{Commands, Query, Res, ResMut}, - }, - gltf::Gltf, - hierarchy::{Children, Parent}, - log::debug, - pbr::StandardMaterial, - reflect::Reflect, - render::mesh::Mesh, -}; - -use crate::{AssetLoadTracker, AssetsToLoad, BluePrintsConfig}; - -#[derive(Component, Reflect, Default, Debug)] -#[reflect(Component)] -/// struct containing the name & source of the material to apply -pub struct MaterialInfo { - pub name: String, - pub source: String, -} - -/// flag component -#[derive(Component)] -pub(crate) struct BlueprintMaterialAssetsLoaded; -/// flag component -#[derive(Component)] -pub(crate) struct BlueprintMaterialAssetsNotLoaded; - -/// system that injects / replaces materials from material library -pub(crate) fn materials_inject( - blueprints_config: ResMut, - material_infos: Query<(Entity, &MaterialInfo), Added>, - asset_server: Res, - mut commands: Commands, -) { - for (entity, material_info) in material_infos.iter() { - let model_file_name = format!( - "{}_materials_library.{}", - &material_info.source, &blueprints_config.format - ); - let materials_path = Path::new(&blueprints_config.material_library_folder) - .join(Path::new(model_file_name.as_str())); - let material_name = &material_info.name; - let material_full_path = materials_path.to_str().unwrap().to_string() + "#" + material_name; // TODO: yikes, cleanup - - if blueprints_config - .material_library_cache - .contains_key(&material_full_path) - { - debug!("material is cached, retrieving"); - blueprints_config - .material_library_cache - .get(&material_full_path) - .expect("we should have the material available"); - commands - .entity(entity) - .insert(BlueprintMaterialAssetsLoaded); - } else { - let material_file_handle: Handle = asset_server.load(materials_path.clone()); - let material_file_id = material_file_handle.id(); - let asset_infos: Vec> = vec![AssetLoadTracker { - name: material_full_path, - id: material_file_id, - loaded: false, - handle: material_file_handle.clone(), - }]; - - commands - .entity(entity) - .insert(AssetsToLoad { - all_loaded: false, - asset_infos, - ..Default::default() - }) - .insert(BlueprintMaterialAssetsNotLoaded); - /**/ - } - } -} - -// TODO, merge with check_for_loaded, make generic ? -pub(crate) fn check_for_material_loaded( - mut blueprint_assets_to_load: Query< - (Entity, &mut AssetsToLoad), - With, - >, - asset_server: Res, - mut commands: Commands, -) { - for (entity, mut assets_to_load) in blueprint_assets_to_load.iter_mut() { - let mut all_loaded = true; - let mut loaded_amount = 0; - let total = assets_to_load.asset_infos.len(); - for tracker in assets_to_load.asset_infos.iter_mut() { - let asset_id = tracker.id; - let loaded = asset_server.is_loaded_with_dependencies(asset_id); - tracker.loaded = loaded; - if loaded { - loaded_amount += 1; - } else { - all_loaded = false; - } - } - let progress: f32 = loaded_amount as f32 / total as f32; - assets_to_load.progress = progress; - - if all_loaded { - assets_to_load.all_loaded = true; - commands - .entity(entity) - .insert(BlueprintMaterialAssetsLoaded) - .remove::(); - } - } -} - -/// system that injects / replaces materials from material library -pub(crate) fn materials_inject2( - mut blueprints_config: ResMut, - material_infos: Query< - (&MaterialInfo, &Children), - ( - Added, - With, - ), - >, - with_materials_and_meshes: Query< - (), - ( - With, - With>, - With>, - ), - >, - assets_gltf: Res>, - asset_server: Res, - - mut commands: Commands, -) { - for (material_info, children) in material_infos.iter() { - let model_file_name = format!( - "{}_materials_library.{}", - &material_info.source, &blueprints_config.format - ); - let materials_path = Path::new(&blueprints_config.material_library_folder) - .join(Path::new(model_file_name.as_str())); - let material_name = &material_info.name; - - let material_full_path = materials_path.to_str().unwrap().to_string() + "#" + material_name; // TODO: yikes, cleanup - let mut material_found: Option<&Handle> = None; - - if blueprints_config - .material_library_cache - .contains_key(&material_full_path) - { - debug!("material is cached, retrieving"); - let material = blueprints_config - .material_library_cache - .get(&material_full_path) - .expect("we should have the material available"); - material_found = Some(material); - } else { - let model_handle: Handle = asset_server.load(materials_path.clone()); // FIXME: kinda weird now - let mat_gltf = assets_gltf - .get(model_handle.id()) - .expect("material should have been preloaded"); - if mat_gltf.named_materials.contains_key(material_name as &str) { - let material = mat_gltf - .named_materials - .get(material_name as &str) - .expect("this material should have been loaded"); - blueprints_config - .material_library_cache - .insert(material_full_path, material.clone()); - material_found = Some(material); - } - } - - if let Some(material) = material_found { - for child in children.iter() { - if with_materials_and_meshes.contains(*child) { - debug!( - "injecting material {}, path: {:?}", - material_name, - materials_path.clone() - ); - - commands.entity(*child).insert(material.clone()); - } - } - } - } -} diff --git a/crates/bevy_gltf_blueprints/src/old.rs b/crates/bevy_gltf_blueprints/src/old.rs deleted file mode 100644 index 5cf01a0..0000000 --- a/crates/bevy_gltf_blueprints/src/old.rs +++ /dev/null @@ -1,248 +0,0 @@ - - -/// helper component, for tracking loaded assets's loading state, id , handle etc -#[derive(Default, Debug)] -pub(crate) struct AssetLoadTracker { - #[allow(dead_code)] - pub name: String, - pub id: AssetId, - pub loaded: bool, - #[allow(dead_code)] - pub handle: Handle, -} - -/// helper component, for tracking loaded assets -#[derive(Component, Debug)] -pub(crate) struct AssetsToLoad { - pub all_loaded: bool, - pub asset_infos: Vec>, - pub progress: f32, -} -impl Default for AssetsToLoad { - fn default() -> Self { - Self { - all_loaded: Default::default(), - asset_infos: Default::default(), - progress: Default::default(), - } - } -} - -/// flag component, usually added when a blueprint is loaded -#[derive(Component)] -pub(crate) struct BlueprintAssetsLoaded; -/// flag component -#[derive(Component)] -pub(crate) struct BlueprintAssetsNotLoaded; - - - -/// spawning prepare function, -/// * also takes into account the already exisiting "override" components, ie "override components" > components from blueprint -pub(crate) fn prepare_blueprints( - spawn_placeholders: Query< - ( - Entity, - &BlueprintName, - Option<&Parent>, - Option<&Library>, - Option<&Name>, - Option<&BlueprintsList>, - ), - (Added, Added, Without), - >, - - mut commands: Commands, - asset_server: Res, - blueprints_config: Res, -) { - for (entity, blupeprint_name, original_parent, library_override, name, blueprints_list) in - spawn_placeholders.iter() - { - debug!( - "requesting to spawn {:?} for entity {:?}, id: {:?}, parent:{:?}", - blupeprint_name.0, name, entity, original_parent - ); - - // println!("main model path {:?}", model_path); - if blueprints_list.is_some() { - let blueprints_list = blueprints_list.unwrap(); - // println!("blueprints list {:?}", blueprints_list.0.keys()); - let mut asset_infos: Vec> = vec![]; - let library_path = - library_override.map_or_else(|| &blueprints_config.library_folder, |l| &l.0); - for (blueprint_name, _) in blueprints_list.0.iter() { - let model_file_name = format!("{}.{}", &blueprint_name, &blueprints_config.format); - let model_path = Path::new(&library_path).join(Path::new(model_file_name.as_str())); - - let model_handle: Handle = asset_server.load(model_path.clone()); - let model_id = model_handle.id(); - let loaded = asset_server.is_loaded_with_dependencies(model_id); - if !loaded { - asset_infos.push(AssetLoadTracker { - name: model_path.to_string_lossy().into(), - id: model_id, - loaded: false, - handle: model_handle.clone(), - }); - } - } - // if not all assets are already loaded, inject a component to signal that we need them to be loaded - if !asset_infos.is_empty() { - commands - .entity(entity) - .insert(AssetsToLoad { - all_loaded: false, - asset_infos, - ..Default::default() - }) - .insert(BlueprintAssetsNotLoaded); - } else { - commands.entity(entity).insert(BlueprintAssetsLoaded); - } - } else { - // in case there are no blueprintsList, we revert back to the old behaviour - commands.entity(entity).insert(BlueprintAssetsLoaded); - } - } -} - -pub(crate) fn check_for_loaded( - mut blueprint_assets_to_load: Query< - (Entity, &mut AssetsToLoad), - With, - >, - asset_server: Res, - mut commands: Commands, -) { - for (entity, mut assets_to_load) in blueprint_assets_to_load.iter_mut() { - let mut all_loaded = true; - let mut loaded_amount = 0; - let total = assets_to_load.asset_infos.len(); - for tracker in assets_to_load.asset_infos.iter_mut() { - let asset_id = tracker.id; - let loaded = asset_server.is_loaded_with_dependencies(asset_id); - tracker.loaded = loaded; - if loaded { - loaded_amount += 1; - } else { - all_loaded = false; - } - } - let progress: f32 = loaded_amount as f32 / total as f32; - // println!("progress: {}",progress); - assets_to_load.progress = progress; - - if all_loaded { - assets_to_load.all_loaded = true; - commands - .entity(entity) - .insert(BlueprintAssetsLoaded) - .remove::(); - } - } -} - -pub(crate) fn spawn_from_blueprints( - spawn_placeholders: Query< - ( - Entity, - &BlueprintName, - Option<&Transform>, - Option<&Parent>, - Option<&Library>, - Option<&AddToGameWorld>, - Option<&Name>, - ), - ( - With, - Added, - Without, - ), - >, - - mut commands: Commands, - mut game_world: Query>, - - assets_gltf: Res>, - asset_server: Res, - blueprints_config: Res, - - children: Query<&Children>, -) { - for ( - entity, - blupeprint_name, - transform, - original_parent, - library_override, - add_to_world, - name, - ) in spawn_placeholders.iter() - { - debug!( - "attempting to spawn {:?} for entity {:?}, id: {:?}, parent:{:?}", - blupeprint_name.0, name, entity, original_parent - ); - - let what = &blupeprint_name.0; - let model_file_name = format!("{}.{}", &what, &blueprints_config.format); - - // library path is either defined at the plugin level or overriden by optional Library components - let library_path = - library_override.map_or_else(|| &blueprints_config.library_folder, |l| &l.0); - let model_path = Path::new(&library_path).join(Path::new(model_file_name.as_str())); - - // info!("attempting to spawn {:?}", model_path); - let model_handle: Handle = asset_server.load(model_path.clone()); // FIXME: kinda weird now - - let gltf = assets_gltf.get(&model_handle).unwrap_or_else(|| { - panic!( - "gltf file {:?} should have been loaded", - model_path.to_str() - ) - }); - - // WARNING we work under the assumtion that there is ONLY ONE named scene, and that the first one is the right one - let main_scene_name = gltf - .named_scenes - .keys() - .next() - .expect("there should be at least one named scene in the gltf file to spawn"); - - let scene = &gltf.named_scenes[main_scene_name]; - - // transforms are optional, but still deal with them correctly - let mut transforms: Transform = Transform::default(); - if transform.is_some() { - transforms = *transform.unwrap(); - } - - let mut original_children: Vec = vec![]; - if let Ok(c) = children.get(entity) { - for child in c.iter() { - original_children.push(*child); - } - } - commands.entity(entity).insert(( - SceneBundle { - scene: scene.clone(), - transform: transforms, - ..Default::default() - }, - Spawned, - OriginalChildren(original_children), - BlueprintAnimations { - // these are animations specific to the inside of the blueprint - named_animations: gltf.named_animations.clone(), - }, - )); - - if add_to_world.is_some() { - let world = game_world - .get_single_mut() - .expect("there should be a game world present"); - commands.entity(world).add_child(entity); - } - } -} diff --git a/crates/bevy_gltf_blueprints/src/spawn_from_blueprints.rs b/crates/bevy_gltf_blueprints/src/spawn_from_blueprints.rs deleted file mode 100644 index 8c2a94d..0000000 --- a/crates/bevy_gltf_blueprints/src/spawn_from_blueprints.rs +++ /dev/null @@ -1,312 +0,0 @@ -use std::path::{Path, PathBuf}; - -use bevy::{gltf::Gltf, prelude::*, utils::HashMap}; - -use crate::{Animations, BluePrintsConfig}; - -/// this is a flag component for our levels/game world -#[derive(Component)] -pub struct GameWorldTag; - -/// Main component for the blueprints -#[derive(Component, Reflect, Default, Debug)] -#[reflect(Component)] -pub struct BlueprintName(pub String); - -/// flag component needed to signify the intent to spawn a Blueprint -#[derive(Component, Reflect, Default, Debug)] -#[reflect(Component)] -pub struct SpawnHere; - -#[derive(Component)] -/// flag component for dynamically spawned scenes -pub struct Spawned; - -#[derive(Component, Reflect, Default, Debug)] -#[reflect(Component)] -/// flag component marking any spwaned child of blueprints ..unless the original entity was marked with the `NoInBlueprint` marker component -pub struct InBlueprint; - -#[derive(Component, Reflect, Default, Debug)] -#[reflect(Component)] -/// flag component preventing any spawned child of blueprints to be marked with the `InBlueprint` component -pub struct NoInBlueprint; - -#[derive(Component, Reflect, Default, Debug)] -#[reflect(Component)] -// this allows overriding the default library path for a given entity/blueprint -pub struct Library(pub PathBuf); - -#[derive(Component, Reflect, Default, Debug)] -#[reflect(Component)] -/// flag component to force adding newly spawned entity as child of game world -pub struct AddToGameWorld; - -#[derive(Component)] -/// helper component, just to transfer child data -pub(crate) struct OriginalChildren(pub Vec); - -/// helper component, is used to store the list of sub blueprints to enable automatic loading of dependend blueprints -#[derive(Component, Reflect, Default, Debug)] -#[reflect(Component)] -pub struct BlueprintsList(pub HashMap>); - -/// helper component, for tracking loaded assets's loading state, id , handle etc -#[derive(Default, Debug)] -pub(crate) struct AssetLoadTracker { - #[allow(dead_code)] - pub name: String, - pub id: AssetId, - pub loaded: bool, - #[allow(dead_code)] - pub handle: Handle, -} - -/// helper component, for tracking loaded assets -#[derive(Component, Debug)] -pub(crate) struct AssetsToLoad { - pub all_loaded: bool, - pub asset_infos: Vec>, - pub progress: f32, -} -impl Default for AssetsToLoad { - fn default() -> Self { - Self { - all_loaded: Default::default(), - asset_infos: Default::default(), - progress: Default::default(), - } - } -} - -/// flag component, usually added when a blueprint is loaded -#[derive(Component)] -pub(crate) struct BlueprintAssetsLoaded; -/// flag component -#[derive(Component)] -pub(crate) struct BlueprintAssetsNotLoaded; - -/// spawning prepare function, -/// * also takes into account the already exisiting "override" components, ie "override components" > components from blueprint -pub(crate) fn prepare_blueprints( - spawn_placeholders: Query< - ( - Entity, - &BlueprintName, - Option<&Parent>, - Option<&Library>, - Option<&Name>, - Option<&BlueprintsList>, - ), - (Added, Added, Without), - >, - - mut commands: Commands, - asset_server: Res, - blueprints_config: Res, -) { - for (entity, blupeprint_name, original_parent, library_override, name, blueprints_list) in - spawn_placeholders.iter() - { - debug!( - "requesting to spawn {:?} for entity {:?}, id: {:?}, parent:{:?}", - blupeprint_name.0, name, entity, original_parent - ); - - // println!("main model path {:?}", model_path); - if blueprints_list.is_some() { - let blueprints_list = blueprints_list.unwrap(); - // println!("blueprints list {:?}", blueprints_list.0.keys()); - let mut asset_infos: Vec> = vec![]; - let library_path = - library_override.map_or_else(|| &blueprints_config.library_folder, |l| &l.0); - for (blueprint_name, _) in blueprints_list.0.iter() { - let model_file_name = format!("{}.{}", &blueprint_name, &blueprints_config.format); - let model_path = Path::new(&library_path).join(Path::new(model_file_name.as_str())); - - let model_handle: Handle = asset_server.load(model_path.clone()); - let model_id = model_handle.id(); - let loaded = asset_server.is_loaded_with_dependencies(model_id); - if !loaded { - asset_infos.push(AssetLoadTracker { - name: model_path.to_string_lossy().into(), - id: model_id, - loaded: false, - handle: model_handle.clone(), - }); - } - } - // if not all assets are already loaded, inject a component to signal that we need them to be loaded - if !asset_infos.is_empty() { - commands - .entity(entity) - .insert(AssetsToLoad { - all_loaded: false, - asset_infos, - ..Default::default() - }) - .insert(BlueprintAssetsNotLoaded); - } else { - commands.entity(entity).insert(BlueprintAssetsLoaded); - } - } else { - // in case there are no blueprintsList, we revert back to the old behaviour - commands.entity(entity).insert(BlueprintAssetsLoaded); - } - } -} - -pub(crate) fn check_for_loaded( - mut blueprint_assets_to_load: Query< - (Entity, &mut AssetsToLoad), - With, - >, - asset_server: Res, - mut commands: Commands, -) { - for (entity, mut assets_to_load) in blueprint_assets_to_load.iter_mut() { - let mut all_loaded = true; - let mut loaded_amount = 0; - let total = assets_to_load.asset_infos.len(); - for tracker in assets_to_load.asset_infos.iter_mut() { - let asset_id = tracker.id; - let loaded = asset_server.is_loaded_with_dependencies(asset_id); - tracker.loaded = loaded; - if loaded { - loaded_amount += 1; - } else { - all_loaded = false; - } - } - let progress: f32 = loaded_amount as f32 / total as f32; - // println!("progress: {}",progress); - assets_to_load.progress = progress; - - if all_loaded { - assets_to_load.all_loaded = true; - commands - .entity(entity) - .insert(BlueprintAssetsLoaded) - .remove::(); - } - } -} - -#[allow(clippy::too_many_arguments)] -pub(crate) fn spawn_from_blueprints( - spawn_placeholders: Query< - ( - Entity, - &BlueprintName, - Option<&Transform>, - Option<&Parent>, - Option<&Library>, - Option<&AddToGameWorld>, - Option<&Name>, - ), - ( - With, - Added, - Without, - ), - >, - - mut commands: Commands, - mut game_world: Query>, - - assets_gltf: Res>, - mut graphs: ResMut>, - asset_server: Res, - blueprints_config: Res, - - children: Query<&Children>, -) { - for ( - entity, - blupeprint_name, - transform, - original_parent, - library_override, - add_to_world, - name, - ) in spawn_placeholders.iter() - { - debug!( - "attempting to spawn {:?} for entity {:?}, id: {:?}, parent:{:?}", - blupeprint_name.0, name, entity, original_parent - ); - - let what = &blupeprint_name.0; - let model_file_name = format!("{}.{}", &what, &blueprints_config.format); - - // library path is either defined at the plugin level or overriden by optional Library components - let library_path = - library_override.map_or_else(|| &blueprints_config.library_folder, |l| &l.0); - let model_path = Path::new(&library_path).join(Path::new(model_file_name.as_str())); - - // info!("attempting to spawn {:?}", model_path); - let model_handle: Handle = asset_server.load(model_path.clone()); // FIXME: kinda weird now - - let gltf = assets_gltf.get(&model_handle).unwrap_or_else(|| { - panic!( - "gltf file {:?} should have been loaded", - model_path.to_str() - ) - }); - - // WARNING we work under the assumtion that there is ONLY ONE named scene, and that the first one is the right one - let main_scene_name = gltf - .named_scenes - .keys() - .next() - .expect("there should be at least one named scene in the gltf file to spawn"); - - let scene = &gltf.named_scenes[main_scene_name]; - - // transforms are optional, but still deal with them correctly - let mut transforms: Transform = Transform::default(); - if transform.is_some() { - transforms = *transform.unwrap(); - } - - let mut original_children: Vec = vec![]; - if let Ok(c) = children.get(entity) { - for child in c.iter() { - original_children.push(*child); - } - } - - let mut graph = AnimationGraph::new(); - let mut named_animations: HashMap> = HashMap::new(); - let mut named_indices: HashMap = HashMap::new(); - - for (key, clip) in gltf.named_animations.iter() { - named_animations.insert(key.to_string(), clip.clone()); - let animation_index = graph.add_clip(clip.clone(), 1.0, graph.root); - named_indices.insert(key.to_string(), animation_index); - } - let graph = graphs.add(graph); - - commands.entity(entity).insert(( - SceneBundle { - scene: scene.clone(), - transform: transforms, - ..Default::default() - }, - Animations { - named_animations, - named_indices, - graph, - }, - Spawned, - OriginalChildren(original_children), - )); - - if add_to_world.is_some() { - let world = game_world - .get_single_mut() - .expect("there should be a game world present"); - commands.entity(world).add_child(entity); - } - } -} diff --git a/crates/bevy_gltf_blueprints/src/spawn_post_process.rs b/crates/bevy_gltf_blueprints/src/spawn_post_process.rs deleted file mode 100644 index b53f4d7..0000000 --- a/crates/bevy_gltf_blueprints/src/spawn_post_process.rs +++ /dev/null @@ -1,100 +0,0 @@ -use std::any::TypeId; - -use bevy::gltf::Gltf; -use bevy::prelude::*; -use bevy::scene::SceneInstance; -// use bevy::utils::hashbrown::HashSet; - -use super::{AnimationPlayerLink, Animations}; -use super::{SpawnHere, Spawned}; -use crate::{ - AssetsToLoad, BlueprintAssetsLoaded, CopyComponents, InBlueprint, NoInBlueprint, - OriginalChildren, -}; - -/// this system is in charge of doing any necessary post processing after a blueprint scene has been spawned -/// - it removes one level of useless nesting -/// - it copies the blueprint's root components to the entity it was spawned on (original entity) -/// - it copies the children of the blueprint scene into the original entity -/// - it add `AnimationLink` components so that animations can be controlled from the original entity -/// - it cleans up/ removes a few , by then uneeded components -pub(crate) fn spawned_blueprint_post_process( - unprocessed_entities: Query< - ( - Entity, - &Children, - &OriginalChildren, - &Animations, - Option<&NoInBlueprint>, - Option<&Name>, - ), - (With, With, With), - >, - added_animation_players: Query<(Entity, &Parent), Added>, - all_children: Query<&Children>, - - mut commands: Commands, -) { - for (original, children, original_children, animations, no_inblueprint, name) in - unprocessed_entities.iter() - { - debug!("post processing blueprint for entity {:?}", name); - - if children.len() == 0 { - warn!("timing issue ! no children found, please restart your bevy app (bug being investigated)"); - continue; - } - // the root node is the first & normally only child inside a scene, it is the one that has all relevant components - let mut root_entity = Entity::PLACEHOLDER; //FIXME: and what about childless ones ?? => should not be possible normally - // let diff = HashSet::from_iter(original_children.0).difference(HashSet::from_iter(children)); - // we find the first child that was not in the entity before (aka added during the scene spawning) - for c in children.iter() { - if !original_children.0.contains(c) { - root_entity = *c; - break; - } - } - - // we flag all children of the blueprint instance with 'InBlueprint' - // can be usefull to filter out anything that came from blueprints vs normal children - if no_inblueprint.is_none() { - for child in all_children.iter_descendants(root_entity) { - commands.entity(child).insert(InBlueprint); - } - } - - // copy components into from blueprint instance's root_entity to original entity - commands.add(CopyComponents { - source: root_entity, - destination: original, - exclude: vec![TypeId::of::(), TypeId::of::()], - stringent: false, - }); - - // we move all of children of the blueprint instance one level to the original entity - if let Ok(root_entity_children) = all_children.get(root_entity) { - for child in root_entity_children.iter() { - // info!("copying child {:?} upward from {:?} to {:?}", names.get(*child), root_entity, original); - commands.entity(original).add_child(*child); - } - } - - if animations.named_animations.keys().len() > 0 { - for (added, parent) in added_animation_players.iter() { - if parent.get() == root_entity { - // FIXME: stopgap solution: since we cannot use an AnimationPlayer at the root entity level - // and we cannot update animation clips so that the EntityPaths point to one level deeper, - // BUT we still want to have some marker/control at the root entity level, we add this - commands.entity(original).insert(AnimationPlayerLink(added)); - } - } - } - - commands.entity(original).remove::(); - commands.entity(original).remove::(); - commands.entity(original).remove::>(); - commands.entity(original).remove::>(); // also clear the sub assets tracker to free up handles, perhaps just freeing up the handles and leave the rest would be better ? - commands.entity(original).remove::(); - commands.entity(root_entity).despawn_recursive(); - } -} diff --git a/crates/bevy_gltf_components/Cargo.toml b/crates/bevy_gltf_components/Cargo.toml deleted file mode 100644 index f1ae355..0000000 --- a/crates/bevy_gltf_components/Cargo.toml +++ /dev/null @@ -1,22 +0,0 @@ -[package] -name = "bevy_gltf_components" -version = "0.6.0" -authors = ["Mark 'kaosat-dev' Moissette"] -description = "Allows you to define Bevy components direclty inside gltf files and instanciate the components on the Bevy side." -homepage = "https://github.com/kaosat-dev/Blender_bevy_components_workflow" -repository = "https://github.com/kaosat-dev/Blender_bevy_components_workflow" -keywords = ["gamedev", "bevy", "assets", "gltf", "components"] -categories = ["game-development"] -edition = "2021" -license = "MIT OR Apache-2.0" - -[lints] -workspace = true - -[dependencies] -bevy = { version = "0.14", default-features = false, features = ["bevy_asset", "bevy_scene", "bevy_gltf"] } -serde = "1.0.188" -ron = "0.8.1" - -[dev-dependencies] -bevy = { version = "0.14", default-features = false, features = ["dynamic_linking"] } \ No newline at end of file diff --git a/crates/bevy_gltf_components/LICENSE.md b/crates/bevy_gltf_components/LICENSE.md deleted file mode 100644 index ad21aac..0000000 --- a/crates/bevy_gltf_components/LICENSE.md +++ /dev/null @@ -1,4 +0,0 @@ -This crate is available under either: - -* The [MIT License](./LICENSE_MIT) -* The [Apache License, Version 2.0](./LICENSE_APACHE) \ No newline at end of file diff --git a/crates/bevy_gltf_components/LICENSE_APACHE.md b/crates/bevy_gltf_components/LICENSE_APACHE.md deleted file mode 100644 index f748977..0000000 --- a/crates/bevy_gltf_components/LICENSE_APACHE.md +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [2023] [Mark "kaosat-dev" Moissette] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file diff --git a/crates/bevy_gltf_components/LICENSE_MIT.md b/crates/bevy_gltf_components/LICENSE_MIT.md deleted file mode 100644 index f8b9094..0000000 --- a/crates/bevy_gltf_components/LICENSE_MIT.md +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2023 Mark "kaosat-dev" Moissette - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/crates/bevy_gltf_components/src/blender_settings.rs b/crates/bevy_gltf_components/src/blender_settings.rs deleted file mode 100644 index fe1b83c..0000000 --- a/crates/bevy_gltf_components/src/blender_settings.rs +++ /dev/null @@ -1,8 +0,0 @@ -use bevy::prelude::*; - -mod lighting; -pub use lighting::*; - -pub(crate) fn plugin(app: &mut App) { - app.add_plugins(lighting::plugin); -} diff --git a/crates/bevy_gltf_components/src/blender_settings/lighting.rs b/crates/bevy_gltf_components/src/blender_settings/lighting.rs deleted file mode 100644 index 622c0e1..0000000 --- a/crates/bevy_gltf_components/src/blender_settings/lighting.rs +++ /dev/null @@ -1,97 +0,0 @@ -use bevy::pbr::DirectionalLightShadowMap; -use bevy::prelude::*; - -use crate::GltfComponentsSet; - -pub(crate) fn plugin(app: &mut App) { - app.register_type::() - .register_type::() - .register_type::() - .add_systems( - Update, - (process_lights, process_shadowmap, process_background_shader) - .after(GltfComponentsSet::Injection), - ); -} - -#[derive(Component, Reflect, Default, Debug, PartialEq, Clone)] -#[reflect(Component)] -#[non_exhaustive] -/// The properties of a light's shadow , to enable controlling per light shadows from Blender -pub struct BlenderLightShadows { - pub enabled: bool, - pub buffer_bias: f32, -} - -/// The background color as described by Blender's [background shader](https://docs.blender.org/manual/en/latest/render/shader_nodes/shader/background.html). -#[derive(Component, Reflect, Default, Debug, PartialEq, Clone)] -#[reflect(Component)] -#[non_exhaustive] -pub struct BlenderBackgroundShader { - pub color: Color, - pub strength: f32, -} - -/// The settings used by EEVEE's [shadow rendering](https://docs.blender.org/manual/en/latest/render/eevee/render_settings/shadows.html). -#[derive(Component, Reflect, Default, Debug, PartialEq, Clone)] -#[reflect(Component)] -#[non_exhaustive] -pub struct BlenderShadowSettings { - pub cascade_size: usize, -} - -fn process_lights( - mut directional_lights: Query< - (&mut DirectionalLight, Option<&BlenderLightShadows>), - Added, - >, - mut spot_lights: Query<(&mut SpotLight, Option<&BlenderLightShadows>), Added>, - mut point_lights: Query<(&mut PointLight, Option<&BlenderLightShadows>), Added>, -) { - for (mut light, blender_light_shadows) in directional_lights.iter_mut() { - if let Some(blender_light_shadows) = blender_light_shadows { - light.shadows_enabled = blender_light_shadows.enabled; - } else { - light.shadows_enabled = true; - } - } - for (mut light, blender_light_shadows) in spot_lights.iter_mut() { - if let Some(blender_light_shadows) = blender_light_shadows { - light.shadows_enabled = blender_light_shadows.enabled; - } else { - light.shadows_enabled = true; - } - } - - for (mut light, blender_light_shadows) in point_lights.iter_mut() { - if let Some(blender_light_shadows) = blender_light_shadows { - light.shadows_enabled = blender_light_shadows.enabled; - } else { - light.shadows_enabled = true; - } - } -} - -fn process_shadowmap( - shadowmaps: Query<&BlenderShadowSettings, Added>, - mut commands: Commands, -) { - for shadowmap in shadowmaps.iter() { - commands.insert_resource(DirectionalLightShadowMap { - size: shadowmap.cascade_size, - }); - } -} - -fn process_background_shader( - background_shaders: Query<&BlenderBackgroundShader, Added>, - mut commands: Commands, -) { - for background_shader in background_shaders.iter() { - commands.insert_resource(AmbientLight { - color: background_shader.color, - // Just a guess, see - brightness: background_shader.strength * 400.0, - }); - } -} diff --git a/crates/bevy_gltf_components/src/lib.rs b/crates/bevy_gltf_components/src/lib.rs deleted file mode 100644 index ccba12f..0000000 --- a/crates/bevy_gltf_components/src/lib.rs +++ /dev/null @@ -1,102 +0,0 @@ -pub mod utils; -pub use utils::*; - -pub mod ronstring_to_reflect_component; -pub use ronstring_to_reflect_component::*; - -pub mod process_gltfs; -pub use process_gltfs::*; - -pub mod blender_settings; - -use bevy::{ - app::Startup, - ecs::{ - component::Component, - reflect::ReflectComponent, - system::{Res, Resource}, - }, - log::warn, - prelude::{App, IntoSystemConfigs, Plugin, SystemSet, Update}, - reflect::Reflect, -}; - -/// A Bevy plugin for extracting components from gltf files and automatically adding them to the relevant entities -/// It will automatically run every time you load a gltf file -/// Add this plugin to your Bevy app to get access to this feature -/// ``` -/// # use bevy::prelude::*; -/// # use bevy::gltf::*; -/// # use bevy_gltf_components::ComponentsFromGltfPlugin; -/// -/// //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, -/// mut commands: bevy::prelude::Commands, -/// keycode: Res>, - -/// ){ -/// if keycode.just_pressed(KeyCode::Return) { -/// commands.spawn(SceneBundle { -/// scene: asset_server.load("basic/models/level1.glb"), -/// transform: Transform::from_xyz(2.0, 0.0, -5.0), -/// ..Default::default() -/// }); -/// } -///} -/// ``` - -/// this is a flag component to tag a processed gltf, to avoid processing things multiple times -#[derive(Component, Reflect, Default, Debug)] -#[reflect(Component)] -pub struct GltfProcessed; - -#[derive(SystemSet, Debug, Hash, PartialEq, Eq, Clone)] -/// systemset to order your systems after the component injection when needed -pub enum GltfComponentsSet { - Injection, -} - -#[derive(Clone, Resource)] -pub struct GltfComponentsConfig { - pub(crate) legacy_mode: bool, -} - -pub struct ComponentsFromGltfPlugin { - pub legacy_mode: bool, -} - -impl Default for ComponentsFromGltfPlugin { - fn default() -> Self { - Self { legacy_mode: true } - } -} - -fn check_for_legacy_mode(gltf_components_config: Res) { - if gltf_components_config.legacy_mode { - warn!("using simplified component definitions is deprecated since 0.3, prefer defining components with real ron values (use the bevy_components tool for Blender for simplicity) "); - } -} - -impl Plugin for ComponentsFromGltfPlugin { - fn build(&self, app: &mut App) { - app.add_plugins(blender_settings::plugin) - .register_type::() - .insert_resource(GltfComponentsConfig { - legacy_mode: self.legacy_mode, - }) - .add_systems(Startup, check_for_legacy_mode) - .add_systems( - Update, - (add_components_from_gltf_extras).in_set(GltfComponentsSet::Injection), - ); - } -} diff --git a/crates/bevy_gltf_components/src/process_gltfs.rs b/crates/bevy_gltf_components/src/process_gltfs.rs deleted file mode 100644 index a37f537..0000000 --- a/crates/bevy_gltf_components/src/process_gltfs.rs +++ /dev/null @@ -1,97 +0,0 @@ -use bevy::{ - core::Name, - ecs::{ - entity::Entity, - query::{Added, Without}, - reflect::{AppTypeRegistry, ReflectComponent}, - world::World, - }, - gltf::GltfExtras, - hierarchy::Parent, - log::debug, - reflect::{Reflect, TypeRegistration}, - utils::HashMap, -}; - -use crate::{ronstring_to_reflect_component, GltfComponentsConfig, GltfProcessed}; - -/// main function: injects components into each entity in gltf files that have `gltf_extras`, using reflection -pub fn add_components_from_gltf_extras(world: &mut World) { - let mut extras = - world.query_filtered::<(Entity, &Name, &GltfExtras, &Parent), (Added, Without)>(); - let mut entity_components: HashMap, TypeRegistration)>> = - HashMap::new(); - - let gltf_components_config = world.resource::(); - - for (entity, name, extra, parent) in extras.iter(world) { - debug!( - "Name: {}, entity {:?}, parent: {:?}, extras {:?}", - name, entity, parent, extra - ); - - let type_registry: &AppTypeRegistry = world.resource(); - let type_registry = type_registry.read(); - - let reflect_components = ronstring_to_reflect_component( - &extra.value, - &type_registry, - gltf_components_config.legacy_mode, - ); - - // we assign the components specified /xxx_components objects to their parent node - let mut target_entity = entity; - // if the node contains "components" or ends with "_pa" (ie add to parent), the components will not be added to the entity itself but to its parent - // this is mostly used for Blender collections - if name.as_str().contains("components") || name.as_str().ends_with("_pa") { - debug!("adding components to parent"); - target_entity = parent.get(); - } - debug!("adding to {:?}", target_entity); - - // if there where already components set to be added to this entity (for example when entity_data was refering to a parent), update the vec of entity_components accordingly - // this allows for example blender collection to provide basic ecs data & the instances to override/ define their own values - if entity_components.contains_key(&target_entity) { - let mut updated_components: Vec<(Box, TypeRegistration)> = Vec::new(); - let current_components = &entity_components[&target_entity]; - // first inject the current components - for (component, type_registration) in current_components { - updated_components.push((component.clone_value(), type_registration.clone())); - } - // then inject the new components: this also enables overwrite components set in the collection - for (component, type_registration) in reflect_components { - updated_components.push((component.clone_value(), type_registration)); - } - entity_components.insert(target_entity, updated_components); - } else { - entity_components.insert(target_entity, reflect_components); - } - } - - for (entity, components) in entity_components { - let type_registry: &AppTypeRegistry = world.resource(); - let type_registry = type_registry.clone(); - let type_registry = type_registry.read(); - - if !components.is_empty() { - debug!("--entity {:?}, components {}", entity, components.len()); - } - for (component, type_registration) in components { - debug!( - "------adding {} {:?}", - component.get_represented_type_info().unwrap().type_path(), - component - ); - - { - let mut entity_mut = world.entity_mut(entity); - type_registration - .data::() - .expect("Unable to reflect component") - .insert(&mut entity_mut, &*component, &type_registry); - - entity_mut.insert(GltfProcessed); // this is how can we insert any additional components - } - } - } -} diff --git a/crates/bevy_gltf_components/src/ronstring_to_reflect_component.rs b/crates/bevy_gltf_components/src/ronstring_to_reflect_component.rs deleted file mode 100644 index 7506c89..0000000 --- a/crates/bevy_gltf_components/src/ronstring_to_reflect_component.rs +++ /dev/null @@ -1,134 +0,0 @@ -use bevy::log::{debug, warn}; -use bevy::reflect::serde::ReflectDeserializer; -use bevy::reflect::{Reflect, TypeInfo, TypeRegistration, TypeRegistry}; -use bevy::utils::HashMap; -use ron::Value; -use serde::de::DeserializeSeed; - -use super::capitalize_first_letter; - -pub fn ronstring_to_reflect_component( - ron_string: &str, - type_registry: &TypeRegistry, - simplified_types: bool, -) -> Vec<(Box, TypeRegistration)> { - let lookup: HashMap = ron::from_str(ron_string).unwrap(); - let mut components: Vec<(Box, TypeRegistration)> = Vec::new(); - for (key, value) in lookup.into_iter() { - let type_string = key.replace("component: ", "").trim().to_string(); - let capitalized_type_name = capitalize_first_letter(type_string.as_str()); - - let mut parsed_value: String; - match value.clone() { - Value::String(str) => { - parsed_value = str; - } - _ => parsed_value = ron::to_string(&value).unwrap().to_string(), - } - - if let Some(type_registration) = - type_registry.get_with_short_type_path(capitalized_type_name.as_str()) - { - debug!("TYPE INFO {:?}", type_registration.type_info()); - if simplified_types { - if let TypeInfo::TupleStruct(info) = type_registration.type_info() { - // we handle tupple strucs with only one field differently, as Blender's custom properties with custom ui (float, int, bool, etc) always give us a tupple struct - if info.field_len() == 1 { - let field = info - .field_at(0) - .expect("we should always have at least one field here"); - let field_name = field.type_path(); - let mut formated = parsed_value.clone(); - match field_name { - "f32" => { - formated = parsed_value.parse::().unwrap().to_string(); - } - "f64" => { - formated = parsed_value.parse::().unwrap().to_string(); - } - "u8" => { - formated = parsed_value.parse::().unwrap().to_string(); - } - "u16" => { - formated = parsed_value.parse::().unwrap().to_string(); - } - "u32" => { - formated = parsed_value.parse::().unwrap().to_string(); - } - "u64" => { - formated = parsed_value.parse::().unwrap().to_string(); - } - "u128" => { - formated = parsed_value.parse::().unwrap().to_string(); - } - "glam::Vec2" => { - let parsed: Vec = ron::from_str(&parsed_value).unwrap(); - formated = format!("(x:{},y:{})", parsed[0], parsed[1]); - } - "glam::Vec3" => { - let parsed: Vec = ron::from_str(&parsed_value).unwrap(); - formated = - format!("(x:{},y:{},z:{})", parsed[0], parsed[1], parsed[2]); - } - "bevy_render::color::Color" => { - let parsed: Vec = ron::from_str(&parsed_value).unwrap(); - if parsed.len() == 3 { - formated = format!( - "Rgba(red:{},green:{},blue:{}, alpha: 1.0)", - parsed[0], parsed[1], parsed[2] - ); - } - if parsed.len() == 4 { - formated = format!( - "Rgba(red:{},green:{},blue:{}, alpha:{})", - parsed[0], parsed[1], parsed[2], parsed[3] - ); - } - } - _ => {} - } - - parsed_value = format!("({formated})"); - } - } - - if parsed_value.is_empty() { - parsed_value = "()".to_string(); - } - } - let ron_string = format!( - "{{ \"{}\":{} }}", - type_registration.type_info().type_path(), - parsed_value - ); - - // usefull to determine what an entity looks like Serialized - /*let test_struct = CameraRenderGraph::new("name"); - let serializer = ReflectSerializer::new(&test_struct, &type_registry); - let serialized = - ron::ser::to_string_pretty(&serializer, ron::ser::PrettyConfig::default()).unwrap(); - println!("serialized Component {}", serialized);*/ - - debug!("component data ron string {}", ron_string); - let mut deserializer = ron::Deserializer::from_str(ron_string.as_str()) - .expect("deserialzer should have been generated from string"); - let reflect_deserializer = ReflectDeserializer::new(type_registry); - let component = reflect_deserializer - .deserialize(&mut deserializer) - .unwrap_or_else(|_| { - panic!( - "failed to deserialize component {} with value: {:?}", - key, value - ) - }); - - debug!("component {:?}", component); - debug!("real type {:?}", component.get_represented_type_info()); - components.push((component, type_registration.clone())); - debug!("found type registration for {}", capitalized_type_name); - } else { - warn!("no type registration for {}", capitalized_type_name); - } - } - components -} diff --git a/crates/bevy_gltf_components/src/utils.rs b/crates/bevy_gltf_components/src/utils.rs deleted file mode 100644 index 14d6da3..0000000 --- a/crates/bevy_gltf_components/src/utils.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub fn capitalize_first_letter(s: &str) -> String { - s[0..1].to_uppercase() + &s[1..] -} diff --git a/crates/bevy_gltf_save_load/Cargo.toml b/crates/bevy_gltf_save_load/Cargo.toml deleted file mode 100644 index a8f76c4..0000000 --- a/crates/bevy_gltf_save_load/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -[package] -name = "bevy_gltf_save_load" -version = "0.5.0" -authors = ["Mark 'kaosat-dev' Moissette"] -description = "Save & load your bevy games" -homepage = "https://github.com/kaosat-dev/Blender_bevy_components_workflow" -repository = "https://github.com/kaosat-dev/Blender_bevy_components_workflow" -keywords = ["gamedev", "bevy", "save", "load", "serialize"] -categories = ["game-development"] -edition = "2021" -license = "MIT OR Apache-2.0" - -[lints] -workspace = true - -[dependencies] -bevy = { version = "0.14", default-features = false, features = ["bevy_asset", "bevy_scene", "bevy_gltf"] } -bevy_gltf_blueprints = { version = "0.11", path = "../bevy_gltf_blueprints" } - -[dev-dependencies] -bevy = { version = "0.14", default-features = false, features = ["dynamic_linking"] } diff --git a/crates/bevy_gltf_save_load/LICENSE.md b/crates/bevy_gltf_save_load/LICENSE.md deleted file mode 100644 index ad21aac..0000000 --- a/crates/bevy_gltf_save_load/LICENSE.md +++ /dev/null @@ -1,4 +0,0 @@ -This crate is available under either: - -* The [MIT License](./LICENSE_MIT) -* The [Apache License, Version 2.0](./LICENSE_APACHE) \ No newline at end of file diff --git a/crates/bevy_gltf_save_load/LICENSE_APACHE.md b/crates/bevy_gltf_save_load/LICENSE_APACHE.md deleted file mode 100644 index f748977..0000000 --- a/crates/bevy_gltf_save_load/LICENSE_APACHE.md +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [2023] [Mark "kaosat-dev" Moissette] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file diff --git a/crates/bevy_gltf_save_load/LICENSE_MIT.md b/crates/bevy_gltf_save_load/LICENSE_MIT.md deleted file mode 100644 index f8b9094..0000000 --- a/crates/bevy_gltf_save_load/LICENSE_MIT.md +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2023 Mark "kaosat-dev" Moissette - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/crates/bevy_gltf_save_load/src/gltf_out_test.rs b/crates/bevy_gltf_save_load/src/gltf_out_test.rs deleted file mode 100644 index e47b1fa..0000000 --- a/crates/bevy_gltf_save_load/src/gltf_out_test.rs +++ /dev/null @@ -1,216 +0,0 @@ -use gltf_json as json; -use json::camera::Type; -use json::validation::{Checked, Validate}; -use serde_json::value::{to_raw_value, RawValue}; -use serde::Serialize; -use bevy::reflect::TypeRegistryArc; - - -#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] -enum Output { - /// Output standard glTF. - Standard, - - /// Output binary glTF. - Binary, -} -#[derive(Serialize)] -struct MyExtraData { - a: u32, - b: u32, - BlueprintName: String, - SpawnHere: String, -} - -/* -pub fn serialize_gltf_inner(serialize: S) -> Result -where - S: Serialize, -{ - let pretty_config = ron::ser::PrettyConfig::default() - .indentor(" ".to_string()) - .new_line("\n".to_string()); - ron::ser::to_string_pretty(&serialize, pretty_config) -}*/ - -pub fn serialize_gltf(scene:&DynamicScene, registry: &TypeRegistryArc) { - -} - -pub fn save_game( - world: &mut World, -) { - - let mut save_path:String = "".into(); - let mut events = world - .resource_mut::>(); - for event in events.get_reader().read(&events) { - info!("SAVE EVENT !! {:?}", event); - save_path = event.path.clone(); - } - info!("SAVING TO {}", save_path); - events.clear(); - - let saveable_entities: Vec = world - .query_filtered::>() - .iter(world) - .collect(); - - debug!("saveable entities {}", saveable_entities.len()); - - let components = HashSet::from([ - TypeId::of::(), - TypeId::of::(), - TypeId::of::() , - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - - - - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - - TypeId::of::(), - - - - ]); - - let filter = SceneFilter::Allowlist(components); - - - let mut scene_builder = DynamicSceneBuilder::from_world(world).with_filter(filter); - - let dyn_scene = scene_builder - - - /* .allow::() - .allow::() - .allow::()*/ - - /* .deny::() - .deny::() - .deny::() - .deny::() - .deny::() - .deny::() - .deny::() - .deny::() - .deny::() - // camera stuff - .deny::() - .deny::() - .deny::() - .deny::() - .deny::() - .deny::() - //.deny::() - */ - .extract_entities(saveable_entities.into_iter()) - .build(); - - let serialized_scene = dyn_scene - .serialize_ron(world.resource::()) - .unwrap(); - - let mut root = gltf_json::Root::default(); - - // unfortunatly, not available yet - /*let node = root.push(json::Node { - //mesh: Some(mesh), - ..Default::default() - }); - - root.push(json::Scene { - extensions: Default::default(), - extras: Default::default(), - name: None, - nodes: vec![node], - });*/ - - - - - - let camera = json::camera::Perspective{ - aspect_ratio: Some(0.5), - yfov: 32.0, - zfar: Some(30.), - znear: 0.0, - extensions: None, - extras: None - }; - /*let camera = json::Camera{ - name:Some("Camera".into()), - orthographic: None, - perspective:None, - extensions: None, - extras: None, - type_: Checked, - };*/ - let gna = to_raw_value(&MyExtraData { a: 1, b: 2, BlueprintName: "Foo".into(), SpawnHere:"".into() }).unwrap() ; - let node = json::Node { - camera: None,//Some(camera), - children: None, - extensions: None, - extras: Some(gna), - matrix: None, - mesh:None, - name: Some("yeah".into()), - rotation: None, - scale: None, - translation: Some([0.5, 10.0 ,-100.]), - skin: None, - weights: None - // mesh: Some(json::Index::new(0)), - //..Default::default() - }; - - let root = json::Root { - accessors: vec![], //[positions, colors], - buffers: vec![], - buffer_views: vec![], - meshes: vec![], - nodes: vec![node], - scenes: vec![json::Scene { - extensions: Default::default(), - extras: Default::default(), - name: Some("Foo".to_string()), - nodes: vec![json::Index::new(0)], - }], - ..Default::default() - }; - - - - - let gltf_save_name = "test.gltf"; - let writer = fs::File::create(format!("assets/scenes/{gltf_save_name}") ).expect("I/O error"); - json::serialize::to_writer_pretty(writer, &root).expect("Serialization error"); - - // let bin = to_padded_byte_vector(triangle_vertices); - // let mut writer = fs::File::create("triangle/buffer0.bin").expect("I/O error"); - // writer.write_all(&bin).expect("I/O error"); - - - #[cfg(not(target_arch = "wasm32"))] - IoTaskPool::get() - .spawn(async move { - // Write the scene RON data to file - File::create(format!("assets/scenes/{save_path}")) - .and_then(|mut file| file.write(serialized_scene.as_bytes())) - .expect("Error while writing scene to file"); - - - - }) - .detach(); -} \ No newline at end of file diff --git a/crates/bevy_registry_export/Cargo.toml b/crates/bevy_registry_export/Cargo.toml deleted file mode 100644 index 291f465..0000000 --- a/crates/bevy_registry_export/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -[package] -name = "bevy_registry_export" -version = "0.4.0" -authors = ["Mark 'kaosat-dev' Moissette", "Pascal 'Killercup' Hertleif"] -description = "Allows you to create a Json export of all your components/ registered types of your Bevy app/game" -homepage = "https://github.com/kaosat-dev/Blender_bevy_components_workflow" -repository = "https://github.com/kaosat-dev/Blender_bevy_components_workflow" -keywords = ["gamedev", "bevy", "assets", "registry", "components"] -categories = ["game-development"] -edition = "2021" -license = "MIT OR Apache-2.0" - -[dependencies] -bevy = { version = "0.14", default-features = false, features = ["bevy_scene"] } -bevy_reflect = { version = "0.14", default-features = false } -bevy_app = { version = "0.14", default-features = false, features = ["bevy_reflect"] } -bevy_ecs = { version = "0.14", default-features = false, features = ["bevy_reflect"] } -serde_json = "1.0.108" - -[dev-dependencies] -bevy = { version = "0.14", default-features = false, features = ["dynamic_linking"] } \ No newline at end of file diff --git a/crates/bevy_registry_export/LICENSE.md b/crates/bevy_registry_export/LICENSE.md deleted file mode 100644 index ad21aac..0000000 --- a/crates/bevy_registry_export/LICENSE.md +++ /dev/null @@ -1,4 +0,0 @@ -This crate is available under either: - -* The [MIT License](./LICENSE_MIT) -* The [Apache License, Version 2.0](./LICENSE_APACHE) \ No newline at end of file diff --git a/crates/bevy_registry_export/LICENSE_APACHE.md b/crates/bevy_registry_export/LICENSE_APACHE.md deleted file mode 100644 index 43c47c4..0000000 --- a/crates/bevy_registry_export/LICENSE_APACHE.md +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [2024] [Mark "kaosat-dev" Moissette] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file diff --git a/crates/bevy_registry_export/LICENSE_MIT.md b/crates/bevy_registry_export/LICENSE_MIT.md deleted file mode 100644 index c7e0144..0000000 --- a/crates/bevy_registry_export/LICENSE_MIT.md +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2024 Mark "kaosat-dev" Moissette - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/crates/bevy_registry_export/src/export_types.rs b/crates/bevy_registry_export/src/export_types.rs deleted file mode 100644 index 8a06ebf..0000000 --- a/crates/bevy_registry_export/src/export_types.rs +++ /dev/null @@ -1,269 +0,0 @@ -use std::{fs::File, path::Path}; - -use bevy::log::info; -use bevy_ecs::{ - reflect::{AppTypeRegistry, ReflectComponent, ReflectResource}, - world::World, -}; -use bevy_reflect::{TypeInfo, TypeRegistration, VariantInfo}; // TypePath // DynamicTypePath -use serde_json::{json, Map, Value}; - -use crate::{AssetRoot, ExportComponentsConfig}; - -pub fn export_types(world: &mut World) { - let config = world - .get_resource::() - .expect("ExportComponentsConfig should exist at this stage"); - - let asset_root = world.resource::(); - let registry_save_path = Path::join(&asset_root.0, &config.save_path); - println!("registry_save_path {}", registry_save_path.display()); - let writer = File::create(registry_save_path).expect("should have created schema file"); - - let types = world.resource_mut::(); - let types = types.read(); - let schemas = types.iter().map(export_type).collect::>(); - - serde_json::to_writer_pretty( - writer, - &json!({ - "$schema": "https://json-schema.org/draft/2020-12/schema", - "title": "bevy component registry schema", - "$defs": schemas, - }), - ) - .expect("valid json"); - - info!("Done exporting registry schema") -} - -pub fn export_type(reg: &TypeRegistration) -> (String, Value) { - let t = reg.type_info(); - let binding = t.type_path_table(); - let short_name = binding.short_path(); - let mut schema = match t { - TypeInfo::Struct(info) => { - let properties = info - .iter() - .enumerate() - .map(|(idx, field)| { - ( - field.name().to_owned(), - add_min_max(json!({ "type": typ(field.type_path()) }), reg, idx, None), - ) - }) - .collect::>(); - - json!({ - "type": "object", - "typeInfo": "Struct", - "title": t.type_path(), - "properties": properties, - "additionalProperties": false, - "required": info - .iter() - .filter(|field| !field.type_path().starts_with("core::option::Option")) - .map(|field| field.name()) - .collect::>(), - }) - } - TypeInfo::Enum(info) => { - let simple = info - .iter() - .all(|variant| matches!(variant, VariantInfo::Unit(_))); - if simple { - json!({ - "type": "string", - "typeInfo": "Enum", - "title": t.type_path(), - "oneOf": info - .iter() - .map(|variant| match variant { - VariantInfo::Unit(v) => v.name(), - _ => unreachable!(), - }) - .collect::>(), - }) - } else { - let variants = info - .iter() - .enumerate() - .map(|(field_idx, variant)| match variant { - //let binding = t.type_path_table(); - //let short_name = binding.short_path(); - VariantInfo::Struct(v) => json!({ - "type": "object", - "typeInfo": "Struct", - "title": v.name(), - "short_name": v.name().split("::").last().unwrap_or(v.name()), - "properties": v - .iter() - .enumerate() - .map(|(variant_idx, field)| (field.name().to_owned(), add_min_max(json!({"type": typ(field.type_path()), "title": field.name()}), reg, field_idx, Some(variant_idx)))) - .collect::>(), - "additionalProperties": false, - "required": v - .iter() - .filter(|field| !field.type_path().starts_with("core::option::Option")) - .map(|field| field.name()) - .collect::>(), - }), - VariantInfo::Tuple(v) => json!({ - "type": "array", - "typeInfo": "Tuple", - "title": v.name(), - "short_name":v.name(), - "prefixItems": v - .iter() - .enumerate() - .map(|(variant_idx, field)| add_min_max(json!({"type": typ(field.type_path())}), reg, field_idx, Some(variant_idx))) - .collect::>(), - "items": false, - }), - VariantInfo::Unit(v) => json!({ - "title": v.name(), - }), - }) - .collect::>(); - - json!({ - "type": "object", - "typeInfo": "Enum", - "title": t.type_path(), - "oneOf": variants, - }) - } - } - TypeInfo::TupleStruct(info) => json!({ - "title": t.type_path(), - "type": "array", - "typeInfo": "TupleStruct", - "prefixItems": info - .iter() - .enumerate() - .map(|(idx, field)| add_min_max(json!({"type": typ(field.type_path())}), reg, idx, None)) - .collect::>(), - "items": false, - }), - TypeInfo::List(info) => { - json!({ - "title": t.type_path(), - "type": "array", - "typeInfo": "List", - "items": json!({"type": typ(info.item_type_path_table().path())}), - }) - } - TypeInfo::Array(info) => json!({ - "title": t.type_path(), - "type": "array", - "typeInfo": "Array", - "items": json!({"type": typ(info.item_type_path_table().path())}), - }), - TypeInfo::Map(info) => json!({ - "title": t.type_path(), - "type": "object", - "typeInfo": "Map", - "additionalProperties": json!({"type": typ(info.value_type_path_table().path())}), - }), - TypeInfo::Tuple(info) => json!({ - "title": t.type_path(), - "type": "array", - "typeInfo": "Tuple", - "prefixItems": info - .iter() - .enumerate() - .map(|(idx, field)| add_min_max(json!({"type": typ(field.type_path())}), reg, idx, None)) - .collect::>(), - "items": false, - }), - TypeInfo::Value(info) => json!({ - "title": t.type_path(), - "type": map_json_type(info.type_path()), - "typeInfo": "Value", - }), - }; - schema.as_object_mut().unwrap().insert( - "isComponent".to_owned(), - reg.data::().is_some().into(), - ); - schema.as_object_mut().unwrap().insert( - "isResource".to_owned(), - reg.data::().is_some().into(), - ); - - schema - .as_object_mut() - .unwrap() - .insert("short_name".to_owned(), short_name.into()); - - (t.type_path().to_owned(), schema) -} - -fn typ(t: &str) -> Value { - json!({ "$ref": format!("#/$defs/{t}") }) -} - -fn map_json_type(t: &str) -> Value { - match t { - "bool" => "boolean", - "u8" | "u16" | "u32" | "u64" | "u128" | "usize" => "uint", - "i8" | "i16" | "i32" | "i64" | "i128" | "isize" => "int", - "f32" | "f64" => "float", - "char" | "str" | "alloc::string::String" => "string", - _ => "object", - } - .into() -} - -fn add_min_max( - mut val: Value, - reg: &TypeRegistration, - field_index: usize, - variant_index: Option, -) -> Value { - #[cfg(feature = "support-inspector")] - fn get_min_max( - reg: &TypeRegistration, - field_index: usize, - variant_index: Option, - ) -> Option<(Option, Option)> { - use bevy_inspector_egui::inspector_options::{ - std_options::NumberOptions, ReflectInspectorOptions, Target, - }; - - reg.data::() - .and_then(|ReflectInspectorOptions(o)| { - o.get(if let Some(variant_index) = variant_index { - Target::VariantField { - variant_index, - field_index, - } - } else { - Target::Field(field_index) - }) - }) - .and_then(|o| o.downcast_ref::>()) - .map(|num| (num.min, num.max)) - } - - #[cfg(not(feature = "support-inspector"))] - fn get_min_max( - _reg: &TypeRegistration, - _field_index: usize, - _variant_index: Option, - ) -> Option<(Option, Option)> { - None - } - - let Some((min, max)) = get_min_max(reg, field_index, variant_index) else { - return val; - }; - let obj = val.as_object_mut().unwrap(); - if let Some(min) = min { - obj.insert("minimum".to_owned(), min.into()); - } - if let Some(max) = max { - obj.insert("maximum".to_owned(), max.into()); - } - val -} diff --git a/crates/bevy_registry_export/src/lib.rs b/crates/bevy_registry_export/src/lib.rs deleted file mode 100644 index eef5136..0000000 --- a/crates/bevy_registry_export/src/lib.rs +++ /dev/null @@ -1,73 +0,0 @@ -pub mod export_types; -use std::path::PathBuf; - -use bevy_app::Startup; -use bevy_ecs::system::Resource; -pub use export_types::*; - -use bevy::{ - asset::AssetPlugin, - prelude::{App, Plugin}, - scene::SceneFilter, -}; - -// Plugin configuration -#[derive(Clone, Resource)] -pub struct ExportComponentsConfig { - pub(crate) save_path: PathBuf, - #[allow(dead_code)] - pub(crate) component_filter: SceneFilter, // unused for now - #[allow(dead_code)] - pub(crate) resource_filter: SceneFilter, // unused for now -} - -pub struct ExportRegistryPlugin { - pub component_filter: SceneFilter, - pub resource_filter: SceneFilter, - pub save_path: PathBuf, -} - -impl Default for ExportRegistryPlugin { - fn default() -> Self { - Self { - component_filter: SceneFilter::default(), // unused for now - resource_filter: SceneFilter::default(), // unused for now - save_path: PathBuf::from("registry.json"), // relative to assets folder - } - } -} - -impl Plugin for ExportRegistryPlugin { - fn build(&self, app: &mut App) { - app.register_asset_root() - .insert_resource(ExportComponentsConfig { - save_path: self.save_path.clone(), - component_filter: self.component_filter.clone(), - resource_filter: self.resource_filter.clone(), - }) - .add_systems(Startup, export_types); - } -} - -trait RegistryExportApp { - fn register_asset_root(&mut self) -> &mut Self; -} -impl RegistryExportApp for App { - fn register_asset_root(&mut self) -> &mut Self { - let asset_plugin = get_asset_plugin(self); - let path_str = asset_plugin.file_path.clone(); - let path = PathBuf::from(path_str); - self.insert_resource(AssetRoot(path)) - } -} - -fn get_asset_plugin(app: &App) -> &AssetPlugin { - let asset_plugins: Vec<&AssetPlugin> = app.get_added_plugins(); - asset_plugins.into_iter().next().expect(ASSET_ERROR) -} - -const ASSET_ERROR: &str = "Bevy_registry_export requires access to the Bevy asset plugin. \ - Please add `ExportRegistryPlugin` after `AssetPlugin`, which is commonly added as part of the `DefaultPlugins`"; - -#[derive(Debug, Clone, PartialEq, Eq, Hash, Resource)] -pub(crate) struct AssetRoot(pub(crate) PathBuf); diff --git a/crates/bevy_gltf_blueprints/README.md b/crates/blenvy/README_blueprints.md similarity index 100% rename from crates/bevy_gltf_blueprints/README.md rename to crates/blenvy/README_blueprints.md diff --git a/crates/bevy_gltf_components/README.md b/crates/blenvy/README_components.md similarity index 100% rename from crates/bevy_gltf_components/README.md rename to crates/blenvy/README_components.md diff --git a/crates/bevy_registry_export/README.md b/crates/blenvy/README_registry.md similarity index 100% rename from crates/bevy_registry_export/README.md rename to crates/blenvy/README_registry.md diff --git a/crates/bevy_gltf_save_load/README.md b/crates/blenvy/README_save_load.md similarity index 100% rename from crates/bevy_gltf_save_load/README.md rename to crates/blenvy/README_save_load.md diff --git a/crates/bevy_gltf_save_load/src/loading.rs b/crates/blenvy/src/save_load/loading.rs similarity index 100% rename from crates/bevy_gltf_save_load/src/loading.rs rename to crates/blenvy/src/save_load/loading.rs diff --git a/crates/bevy_gltf_save_load/src/lib.rs b/crates/blenvy/src/save_load/mod.rs similarity index 100% rename from crates/bevy_gltf_save_load/src/lib.rs rename to crates/blenvy/src/save_load/mod.rs diff --git a/crates/bevy_gltf_save_load/src/saveable.rs b/crates/blenvy/src/save_load/saveable.rs similarity index 100% rename from crates/bevy_gltf_save_load/src/saveable.rs rename to crates/blenvy/src/save_load/saveable.rs diff --git a/crates/bevy_gltf_save_load/src/saving.rs b/crates/blenvy/src/save_load/saving.rs similarity index 100% rename from crates/bevy_gltf_save_load/src/saving.rs rename to crates/blenvy/src/save_load/saving.rs diff --git a/examples/README.md b/examples/README.md index a1b00b0..3a63787 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,4 +1,4 @@ # Examples -This folder contains numerous examples showing how to use both bevy_gltf_components and bevy_gltf_blueprints. -Each example is its own crate so its dependencies are specific & clear. \ No newline at end of file +This folder contains numerous examples showing how to use Blenvy +Each example is its own crate so its dependencies and assets are specific & clear. \ No newline at end of file