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
|
@ -721,7 +721,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bevy_gltf_blueprints"
|
name = "bevy_gltf_blueprints"
|
||||||
version = "0.1.2"
|
version = "0.1.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bevy",
|
"bevy",
|
||||||
"bevy_gltf_components 0.1.2",
|
"bevy_gltf_components 0.1.2",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "bevy_gltf_blueprints"
|
name = "bevy_gltf_blueprints"
|
||||||
version = "0.1.2"
|
version = "0.1.3"
|
||||||
authors = ["Mark 'kaosat-dev' Moissette"]
|
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."
|
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"
|
homepage = "https://github.com/kaosat-dev/Blender_bevy_components_workflow"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
|
|
||||||
pub mod spawn_from_blueprints;
|
pub mod spawn_from_blueprints;
|
||||||
use bevy_gltf_components::GltfComponentsSet;
|
|
||||||
pub use spawn_from_blueprints::*;
|
pub use spawn_from_blueprints::*;
|
||||||
|
|
||||||
pub mod spawn_post_process;
|
pub mod spawn_post_process;
|
||||||
|
@ -9,7 +9,10 @@ pub use spawn_post_process::*;
|
||||||
pub mod clone_entity;
|
pub mod clone_entity;
|
||||||
pub use clone_entity::*;
|
pub use clone_entity::*;
|
||||||
|
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
use bevy_gltf_components::GltfComponentsSet;
|
||||||
|
|
||||||
#[derive(SystemSet, Debug, Hash, PartialEq, Eq, Clone)]
|
#[derive(SystemSet, Debug, Hash, PartialEq, Eq, Clone)]
|
||||||
/// set for the two stages of blueprint based spawning :
|
/// set for the two stages of blueprint based spawning :
|
||||||
|
@ -37,19 +40,19 @@ impl Default for BluePrintBundle {
|
||||||
|
|
||||||
#[derive(Clone, Resource)]
|
#[derive(Clone, Resource)]
|
||||||
pub(crate) struct BluePrintsConfig {
|
pub(crate) struct BluePrintsConfig {
|
||||||
pub(crate) library_folder: String,
|
pub(crate) library_folder: PathBuf,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct BlueprintsPlugin {
|
pub struct BlueprintsPlugin {
|
||||||
/// The base folder where library/blueprints assets are loaded from, relative to the executable.
|
/// 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 {
|
impl Default for BlueprintsPlugin {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
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 bevy::{prelude::*, gltf::Gltf};
|
||||||
|
|
||||||
use crate::BluePrintsConfig;
|
use crate::BluePrintsConfig;
|
||||||
|
@ -45,10 +47,13 @@ pub(crate) fn spawn_from_blueprints(
|
||||||
for (entity, name, blupeprint_name, global_transform) in spawn_placeholders.iter() {
|
for (entity, name, blupeprint_name, global_transform) in spawn_placeholders.iter() {
|
||||||
info!("need to spawn {:?}", blupeprint_name.0);
|
info!("need to spawn {:?}", blupeprint_name.0);
|
||||||
let what = &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 model_file_name = format!("{}.glb",&what);
|
||||||
let scene:Handle<Gltf> = asset_server.load(&model_path);
|
let model_path = Path::new(&blueprints_config.library_folder)
|
||||||
// let scene = game_assets.models.get(&model_path).expect(&format!("no matching model {:?} found", model_path));
|
.join(Path::new(model_file_name.as_str()));
|
||||||
|
|
||||||
info!("attempting to spawn {:?}",model_path);
|
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 = 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
|
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