Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom asset source does not work with GLTF #10903

Open
torsteingrindvik opened this issue Dec 7, 2023 · 2 comments
Open

Custom asset source does not work with GLTF #10903

torsteingrindvik opened this issue Dec 7, 2023 · 2 comments
Labels
A-Assets Load files from disk to use for things like images, models, and sounds A-glTF Related to the glTF 3D scene/model format C-Bug An unexpected or incorrect behavior

Comments

@torsteingrindvik
Copy link
Contributor

torsteingrindvik commented Dec 7, 2023

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".

@torsteingrindvik torsteingrindvik added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Dec 7, 2023
@cart
Copy link
Member

cart commented Dec 7, 2023

This is the problem that would be resolved by Relative Asset Paths. See the end of this PR description for details: #9885.

I don't think we have an issue tracking this yet so we can use this one.

@cart cart added A-Assets Load files from disk to use for things like images, models, and sounds and removed S-Needs-Triage This issue needs to be labelled labels Dec 7, 2023
@cart cart added this to the 0.13 milestone Dec 7, 2023
@alice-i-cecile alice-i-cecile removed this from the 0.13 milestone Jan 24, 2024
@torsteingrindvik
Copy link
Contributor Author

Just making a note that I tried this on Bevy 0.13 and the results were the same:

Adding a custom asset source and doing my-assets://FlightHelmet.gltf finds the GLTF file in the correct location, but the related FlightHelmet.bin is not found since the GltfLoader is not aware of the initiating asset source.

@alice-i-cecile alice-i-cecile added the A-glTF Related to the glTF 3D scene/model format label Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Assets Load files from disk to use for things like images, models, and sounds A-glTF Related to the glTF 3D scene/model format C-Bug An unexpected or incorrect behavior
Projects
None yet
Development

No branches or pull requests

3 participants