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

Load GLTF/GLB misses an object clearly in Blender #4588

Closed
fgadaleta opened this issue Apr 25, 2022 · 11 comments
Closed

Load GLTF/GLB misses an object clearly in Blender #4588

fgadaleta opened this issue Apr 25, 2022 · 11 comments
Labels
A-Assets Load files from disk to use for things like images, models, and sounds A-Transform Translations, rotations and scales C-Bug An unexpected or incorrect behavior

Comments

@fgadaleta
Copy link

This is how I load the gltf/glb

struct SceneHandle {
    handle: Handle<Gltf>,
    animations: Vec<Handle<AnimationClip>>,
    instance_id: Option<InstanceId>,
    is_loaded: bool,
    has_camera: bool,
    has_light: bool,
}


fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
    // Load scene
    let scene_path = "../assets/hangar.gltf".to_string();
    info!("Loading scene {}", scene_path);
    let gltf_scene = asset_server.load(&scene_path);

    commands
    .insert_resource(SceneHandle {
        handle: gltf_scene,
        animations: Vec::new(),
        instance_id: None,
        is_loaded: false,
        has_camera: false,
        has_light: false,
    });
}

Blender version
blender

How Bevy renders the scene (ladder not present)
bevy

The ladder is actually outside the hangar
image

@fgadaleta fgadaleta added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Apr 25, 2022
@mockersf
Copy link
Member

could you share your model?

@fgadaleta
Copy link
Author

the gltf is something like 0.5GB
sure i can share. How?

@alice-i-cecile alice-i-cecile 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 Apr 25, 2022
@alice-i-cecile
Copy link
Member

Perhaps post a link to Google Drive / Dropbox, or some other file hosting service?

@fgadaleta
Copy link
Author

Ok I have simplified the .blend file and exported to a smaller gltf that still reproduce the loading error.
Please find the gltf here
https://drive.google.com/file/d/1ePfyheHnzydXRJcSLFmJF9MN1pKea6VJ/view?usp=sharing

@mockersf
Copy link
Member

Here is a very simplified version:
very_simplified_hangar.glb.zip

In Blender (and other gltf viewer), the ladder is under the drone. In Bevy, the ladder is on the other side of the wall

@fgadaleta
Copy link
Author

exactly

@mockersf
Copy link
Member

This would probably be fixed by #4379, or one of the other issues about transform order.

I tried changing

pub fn mul_transform(&self, transform: Transform) -> Self {
let translation = self.mul_vec3(transform.translation);
let rotation = self.rotation * transform.rotation;
let scale = self.scale * transform.scale;
Self {
translation,
rotation,
scale,
}
}
to

    pub fn mul_transform(&self, transform: Transform) -> Self {
        let (scale, rotation, translation) = (Affine3A::from_scale_rotation_translation(
            self.scale,
            self.rotation,
            self.translation,
        ) * Affine3A::from_scale_rotation_translation(
            transform.scale,
            transform.rotation,
            transform.translation,
        ))
        .to_scale_rotation_translation();
        Self {
            translation,
            rotation,
            scale,
        }
    }

and it fixes the issue

@mockersf mockersf added the A-Transform Translations, rotations and scales label Apr 25, 2022
@oddfacade
Copy link
Contributor

yeah, it looks like the current implementation is effectively doing

when what you actually want is

(non-uniform) scaling and rotation don't commute.

@superdump
Copy link
Contributor

superdump commented Jul 8, 2022

I was just pointed to this issue. I'm glad it would be fixed by #4379 . Also, the images at the beginning feel like a meme, and I love it. :) Maybe bevy merch with "The ladder is outside the hangar" and zero context. :D

@mockersf
Copy link
Member

this is fixed now that #4379 has been merged
Screenshot 2022-07-16 at 03 35 41
(it's now not displaying anything due to #5334 which will be fixed soon)

@mockersf
Copy link
Member

completely fixed with #5335!

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-Transform Translations, rotations and scales C-Bug An unexpected or incorrect behavior
Projects
None yet
Development

No branches or pull requests

5 participants