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

Gltf scene is not properly rendered. #6679

Closed
AllenDang opened this issue Nov 18, 2022 · 10 comments
Closed

Gltf scene is not properly rendered. #6679

AllenDang opened this issue Nov 18, 2022 · 10 comments
Labels
A-Assets Load files from disk to use for things like images, models, and sounds C-Bug An unexpected or incorrect behavior

Comments

@AllenDang
Copy link

Bevy version

0.9.0

[Optional] Relevant system information

If you cannot get Bevy to build or run on your machine, please include:

  • the Rust version you're using (you can get this by running cargo --version)
    • cargo 1.65.0 (4bc8f24d3 2022-10-20)
  • the operating system or browser used, including its version
    • macOS 13.0

What you did

Load a gltf scene from file.

What went wrong

image

  • what actually happened?
    Only one model is rendered.

image

Additional information

Here is a minimal code to reproduce. Make sure to enable "jpeg" feature for bevy in Cargo.toml.

use bevy::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_startup_system(setup)
        .run();
}

/// set up a simple 3D scene
fn setup(mut commands: Commands, server: ResMut<AssetServer>) {
    // load asset
    commands.spawn((SceneBundle {
        scene: server.load("/Users/allen/Downloads/shu.glb#Scene0"),
        ..default()
    },));

    // camera
    commands.spawn(Camera3dBundle {
        transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
        ..default()
    });
}

Here is the gltf model to repo.
shu.glb.zip

@AllenDang AllenDang added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Nov 18, 2022
@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 Nov 18, 2022
@AllenDang
Copy link
Author

@alice-i-cecile I know the core dev of bevy may not have time to fix it now, I'm wondering if you or anyone could give me a hint about where should I start to look at, I could start fixing this and contribute a PR.

@alice-i-cecile
Copy link
Member

This looks like a gltf file with multiple sub-scenes. Have you tried changing or removing #scene0?

@AllenDang
Copy link
Author

@alice-i-cecile Removing #scene0 still the same.

@alice-i-cecile
Copy link
Member

And changing it to e.g. #scene1? Does that change what's displayed? Are there multiple scenes withing the gltf file?

@AllenDang
Copy link
Author

@alice-i-cecile I'm loading it directly with file path and omit #scene section like server.load(path). I think all meshes are loaded, because I can read all kind of information like face count, vertex and AABB from them, just cannot see them.

@alice-i-cecile
Copy link
Member

@mockersf you've looked into 3D much more than I have; any ideas on where to look?

@mockersf
Copy link
Member

mockersf commented Dec 5, 2022

after opening the glb file in blender and re-exporting it, I get something similar to the online gltf viewer:
Screenshot 2022-12-05 at 02 04 27

and when moving the camera inside the cube
Screenshot 2022-12-05 at 02 03 59

Do you know how the original gltf file was produced? Would it be possible to create a smaller file showing the same kind of issue?

@AllenDang
Copy link
Author

@mockersf It is created by Blender. Here is the blender file.
lowpoly_final.blend.zip

@mockersf
Copy link
Member

mockersf commented Dec 5, 2022

@AllenDang there are two scenes in your blender file (and your glb too I guess)
Screenshot 2022-12-05 at 10 00 49

If in blender you delete the "Library" scene, or if you try to display the second scene in Bevy, you will get what you expect.

@AllenDang
Copy link
Author

@mockersf I think we should iterate and display all models from all scenes if no scene is specified.

@bors bors bot closed this as completed in f4818bc Dec 11, 2022
alradish pushed a commit to alradish/bevy that referenced this issue Jan 22, 2023
# Objective

- Fixes bevyengine#6630, fixes bevyengine#6679
- Improve scene viewer in cases where there are more than one scene in a gltf file

## Solution

- Can select which scene to display using `#SceneN`, defaults to scene 0 if not present
- Display the number of scenes available if there are more than one
ItsDoot pushed a commit to ItsDoot/bevy that referenced this issue Feb 1, 2023
# Objective

- Fixes bevyengine#6630, fixes bevyengine#6679
- Improve scene viewer in cases where there are more than one scene in a gltf file

## Solution

- Can select which scene to display using `#SceneN`, defaults to scene 0 if not present
- Display the number of scenes available if there are more than one
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 C-Bug An unexpected or incorrect behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants