Skip to content

Commit

Permalink
fix bevy build
Browse files Browse the repository at this point in the history
  • Loading branch information
kayhhh committed Jan 17, 2024
1 parent c4c3fc0 commit 18baabe
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
6 changes: 4 additions & 2 deletions bevy_gltf_kun/examples/bevy_round_trip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use bevy_gltf_kun::{
GltfKunPlugin,
};
use bevy_panorbit_camera::{PanOrbitCamera, PanOrbitCameraPlugin};
use gltf_kun::io::format::glb::GlbFormat;
use gltf_kun::io::format::{glb::GlbIO, DocumentIO};

const ASSETS_DIR: &str = "../assets";
const CARGO_MANIFEST_DIR: &str = env!("CARGO_MANIFEST_DIR");
Expand Down Expand Up @@ -94,7 +94,9 @@ fn get_result(
Err(e) => panic!("Failed to export from Bevy: {}", e),
};

let glb = match GlbFormat::export(doc) {
let io = GlbIO::default();

let glb = match io.export(doc) {
Ok(glb) => glb,
Err(e) => panic!("Failed to export to glb: {}", e),
};
Expand Down
12 changes: 7 additions & 5 deletions bevy_gltf_kun/src/import/gltf/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ use bevy::{
utils::BoxedFuture,
};
use gltf_kun::io::format::{
glb::{GlbFormat, GlbImportError},
gltf::{import::GltfImportError, GltfFormat},
glb::{GlbIO, GlbImportError},
gltf::{import::GltfImportError, GltfFormat, GltfIO},
DocumentIO,
};
use thiserror::Error;

Expand Down Expand Up @@ -53,8 +54,8 @@ impl AssetLoader for GltfLoader {
json: serde_json::from_slice(&bytes)?,
resources: std::collections::HashMap::new(),
};
let mut resolver = BevyAssetResolver { load_context };
let doc = format.import(Some(&mut resolver)).await?;
let mut io = GltfIO::new(BevyAssetResolver { load_context });
let doc = io.import(format).await?;
let gltf = import_gltf_document(doc, load_context)?;
Ok(gltf)
})
Expand Down Expand Up @@ -91,7 +92,8 @@ impl AssetLoader for GlbLoader {
Box::pin(async move {
let mut bytes = Vec::new();
reader.read_to_end(&mut bytes).await?;
let doc = GlbFormat::import_slice(&bytes).await?;
let mut io = GlbIO::default();
let doc = io.import_slice(&bytes).await?;
let gltf = import_gltf_document(doc, load_context)?;
Ok(gltf)
})
Expand Down
4 changes: 2 additions & 2 deletions gltf_kun/src/extensions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl<D, F> Clone for Extensions<D, F> {
}
}

pub trait ExtensionIO<D, F> {
pub trait ExtensionIO<D, F>: Send + Sync {
fn name(&self) -> &'static str;

/// Export the extension from the document to the format.
Expand All @@ -34,6 +34,6 @@ pub trait ExtensionIO<D, F> {
fn import(&self, format: &mut F, doc: &mut D) -> Result<(), Box<dyn Error>>;
}

pub trait ExtensionProperty: Debug {
pub trait ExtensionProperty: Debug + Send + Sync {
fn extension_name(&self) -> &'static str;
}

0 comments on commit 18baabe

Please sign in to comment.