Skip to content

Commit 8be87d7

Browse files
committed
feat: scene root directory
1 parent c291da6 commit 8be87d7

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "bevy_gaussian_splatting"
33
description = "bevy gaussian splatting render pipeline plugin"
4-
version = "4.5.0"
4+
version = "4.6.0"
55
edition = "2021"
66
authors = ["mosure <[email protected]>"]
77
license = "MIT OR Apache-2.0"

src/io/scene.rs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ pub struct CloudBundle {
7575
)]
7676
pub struct GaussianScene {
7777
pub bundles: Vec<CloudBundle>,
78+
pub root: Option<String>,
7879
}
7980

8081
#[derive(Component, Clone, Debug, Default, Reflect)]
@@ -112,16 +113,23 @@ fn spawn_scene(
112113

113114
let bundles = scene.bundles
114115
.iter()
115-
.map(|bundle|(
116-
// TODO: switch between 3d and 4d clouds based on settings
116+
.map(|bundle|{
117+
let root = scene.root.clone().unwrap_or_default();
118+
119+
// TODO: switch between 3d and 4d clouds based on settings
120+
(
117121
PlanarGaussian3dHandle(
118-
asset_server.load::<PlanarGaussian3d>(bundle.asset_path.clone())
122+
asset_server.load::<PlanarGaussian3d>(
123+
bundle.asset_path
124+
.clone()
125+
.replace("{root}", &root)
126+
)
119127
),
120128
Name::new(bundle.name.clone()),
121129
bundle.settings.clone(),
122130
bundle.transform,
123131
)
124-
)
132+
})
125133
.collect::<Vec<_>>();
126134

127135
commands
@@ -155,8 +163,17 @@ impl AssetLoader for GaussianSceneLoader {
155163

156164
match load_context.path().extension() {
157165
Some(ext) if ext == "json" => {
158-
let scene: GaussianScene = serde_json::from_slice(&bytes)
166+
let mut scene: GaussianScene = serde_json::from_slice(&bytes)
159167
.map_err(|err| std::io::Error::new(ErrorKind::InvalidData, err))?;
168+
169+
scene.root = load_context
170+
.path()
171+
.parent()
172+
.expect("invalid scene path")
173+
.to_string_lossy()
174+
.to_string()
175+
.into();
176+
160177
Ok(scene)
161178
},
162179
_ => Err(std::io::Error::new(ErrorKind::Other, "only .json supported")),

0 commit comments

Comments
 (0)