mirror of
https://github.com/kaosat-dev/Blender_bevy_components_workflow.git
synced 2024-12-22 07:34:10 +00:00
feat(bevy_gltf_blueprints): library_folder is now using path/pathbuf instead of strings (#15)
* feat(bevy_gltf_blueprints): library_folder is now using path/pathbuf instead of strings * chore(bevy_gltf_blueprints): bumped version
This commit is contained in:
parent
868fa163e0
commit
94b20bdf0e
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -721,7 +721,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "bevy_gltf_blueprints"
|
||||
version = "0.1.2"
|
||||
version = "0.1.3"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"bevy_gltf_components 0.1.2",
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "bevy_gltf_blueprints"
|
||||
version = "0.1.2"
|
||||
version = "0.1.3"
|
||||
authors = ["Mark 'kaosat-dev' Moissette"]
|
||||
description = "Adds the ability to define Blueprints/Prefabs for [Bevy](https://bevyengine.org/) inside gltf files and spawn them in Bevy."
|
||||
homepage = "https://github.com/kaosat-dev/Blender_bevy_components_workflow"
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
pub mod spawn_from_blueprints;
|
||||
use bevy_gltf_components::GltfComponentsSet;
|
||||
pub use spawn_from_blueprints::*;
|
||||
|
||||
pub mod spawn_post_process;
|
||||
@ -9,7 +9,10 @@ pub use spawn_post_process::*;
|
||||
pub mod clone_entity;
|
||||
pub use clone_entity::*;
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use bevy::prelude::*;
|
||||
use bevy_gltf_components::GltfComponentsSet;
|
||||
|
||||
#[derive(SystemSet, Debug, Hash, PartialEq, Eq, Clone)]
|
||||
/// set for the two stages of blueprint based spawning :
|
||||
@ -37,19 +40,19 @@ impl Default for BluePrintBundle {
|
||||
|
||||
#[derive(Clone, Resource)]
|
||||
pub(crate) struct BluePrintsConfig {
|
||||
pub(crate) library_folder: String,
|
||||
pub(crate) library_folder: PathBuf,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct BlueprintsPlugin {
|
||||
/// The base folder where library/blueprints assets are loaded from, relative to the executable.
|
||||
pub library_folder: String,
|
||||
pub library_folder: PathBuf,
|
||||
}
|
||||
|
||||
impl Default for BlueprintsPlugin {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
library_folder: "assets/models/library".to_string(),
|
||||
library_folder: PathBuf::from("assets/models/library"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
use std::path::Path;
|
||||
|
||||
use bevy::{prelude::*, gltf::Gltf};
|
||||
|
||||
use crate::BluePrintsConfig;
|
||||
@ -45,10 +47,13 @@ pub(crate) fn spawn_from_blueprints(
|
||||
for (entity, name, blupeprint_name, global_transform) in spawn_placeholders.iter() {
|
||||
info!("need to spawn {:?}", blupeprint_name.0);
|
||||
let what = &blupeprint_name.0;
|
||||
let model_path = format!("{}/{}.glb", &blueprints_config.library_folder, &what); // FIXME: needs to be platform agnostic
|
||||
let scene:Handle<Gltf> = asset_server.load(&model_path);
|
||||
// let scene = game_assets.models.get(&model_path).expect(&format!("no matching model {:?} found", model_path));
|
||||
let model_file_name = format!("{}.glb",&what);
|
||||
let model_path = Path::new(&blueprints_config.library_folder)
|
||||
.join(Path::new(model_file_name.as_str()));
|
||||
|
||||
info!("attempting to spawn {:?}",model_path);
|
||||
let scene:Handle<Gltf> = asset_server.load(model_path);
|
||||
// let scene = game_assets.models.get(&model_path).expect(&format!("no matching model {:?} found", model_path));
|
||||
|
||||
let world = game_world.single_mut();
|
||||
let world = world.1[0]; // FIXME: dangerous hack because our gltf data have a single child like this, but might not always be the case
|
||||
|
Loading…
Reference in New Issue
Block a user