Skip to content

Custom asset source does not work with GLTF #10903

@torsteingrindvik

Description

@torsteingrindvik

Bevy version

Recent main: d2614f2

What you did

Added a custom asset source and tried loading a GLTF with it.
Loading simple assets (e.g. single file images) works fine.

What went wrong

It finds the gltf file, but fails to load the scene.bin mentioned within the GLTF.

Additional information

Logs

2023-12-07T13:22:34.813576Z ERROR bevy_asset::server: Failed to load asset 'gltf://FlightHelmet.gltf' with asset loader 'bevy_gltf::loader::GltfLoader': failed to read bytes from an asset path: path not found: <path>/bevy/assets/FlightHelmet.bin
2023-12-07T13:22:34.813584Z ERROR bevy_asset::server: Failed to load asset 'gltf://FlightHelmet.gltf' with asset loader 'bevy_gltf::loader::GltfLoader': failed to read bytes from an asset path: path not found: <path>/bevy/assets/FlightHelmet.bin

Minimal reproduction

Make a folder foo and copy-paste the flight helmet files into it first.

use bevy::asset::io::*;
use bevy::{gltf::Gltf, prelude::*};

pub struct GltfFailomatic;

impl Plugin for GltfFailomatic {
    fn build(&self, app: &mut App) {
        app.register_asset_source(
            AssetSourceId::from("gltf"),
            AssetSource::build().with_reader(AssetSource::get_default_reader("foo".into())),
        );
    }
}
fn main() {
    App::new()
        .add_plugins((GltfFailomatic, DefaultPlugins))
        .add_systems(Startup, (setup, setup2))
        .run();
}

fn setup(asset_server: Res<AssetServer>) {
    let _: Handle<Gltf> = asset_server.load("gltf://FlightHelmet.gltf");
}

fn setup2(asset_server: Res<AssetServer>) {
    let _: Handle<Scene> = asset_server.load("gltf://FlightHelmet.gltf#Scene0");
}

It seems when loading the scene.bin it tries look in the default asset source instead of the one used for the GLTF "parent asset".

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-AssetsLoad files from disk to use for things like images, models, and soundsA-glTFRelated to the glTF 3D scene/model formatC-BugAn unexpected or incorrect behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions