Skip to content

Commit

Permalink
Add GltfLoader::new. (#9120)
Browse files Browse the repository at this point in the history
# Objective

In my application, I'm manually wrapping the built-in Bevy loaders with
a wrapper loader that stores some metadata before calling into the inner
Bevy loader. This worked for the glTF loader in Bevy 0.10, but in Bevy
0.11 it became impossible to do this because the glTF loader became
unconstructible outside Bevy due to the new private fields within it.
It's now in fact impossible to get a reference to a GltfLoader at all
from outside Bevy, because the only way to construct a GltfLoader is to
add the GltfPlugin to an App, and the GltfPlugin only hands out
references to its GltfLoader to the asset server, which provides no
public access to the loaders it manages.

## Solution

This commit fixes the problem by adding a public `new` method to allow
manual construction of a glTF loader.

---------

Co-authored-by: Carter Anderson <mcanders1@gmail.com>
  • Loading branch information
pcwalton and cart authored Jul 13, 2023
1 parent c7ca7dd commit 05a35f6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/bevy_gltf/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ pub enum GltfError {

/// Loads glTF files with all of their data as their corresponding bevy representations.
pub struct GltfLoader {
pub(crate) supported_compressed_formats: CompressedImageFormats,
pub(crate) custom_vertex_attributes: HashMap<String, MeshVertexAttribute>,
pub supported_compressed_formats: CompressedImageFormats,
pub custom_vertex_attributes: HashMap<String, MeshVertexAttribute>,
}

impl AssetLoader for GltfLoader {
Expand Down

0 comments on commit 05a35f6

Please sign in to comment.