#Trouble Loading a Model

8 messages · Page 1 of 1 (latest)

wild token
#

Trying to follow the Chess Game tutorial, while updating certain functionality to work with Bevy 0.10. As I understand it, the recommended way to import new models is with SceneBundles. As such I modified the spawn_piece functions to work like so.

fn create_pieces(
    mut commands: Commands,
    asset_server: Res<AssetServer>,
    mut materials: ResMut<Assets<StandardMaterial>>
) {
    let bishop_handle: Handle<Scene> =
        asset_server.load("models/pieces.glb#Mesh6/Primitive0");

    spawn_bishop(
        &mut commands,
        white_material.clone(),
        bishop_handle.clone(),
        Vec3::new(0., 0., 2.),
    );
}

pub fn spawn_bishop(
    commands: &mut Commands,
    material: Handle<StandardMaterial>,
    mesh: Handle<Scene>,
    position: Vec3,
) {
    commands.spawn(PbrBundle {
        transform: Transform::from_translation(position),
        ..default()
    })
    .with_children(|parent| {
        parent.spawn(SceneBundle {
            scene: mesh,
            transform: {
                let mut transform = Transform::from_translation(Vec3::new(-0.1, 0., 0.));
                transform.scale *= Vec3::new(0.2, 0.2, 0.2);
                transform
            },
            ..default()
        });
    });
}
#

This code doesn't seem to load the model, so I'm wondering if the issue might be with my use of SceneBundle or the parameters I'm passing to the spawn_bishop function.

hasty ocean
#

Do you see any warns in the logs about the model not being found? That could be one issue.

Another could be size. Maybe it's so small you can't see it.

wild token
#

No logs about not being found

#

Changing the scale doesn't affect the visibility

#

in my case

grizzled fable
#

Loading a mesh as a scene is not going to work. I'm kinda surprised that doesn't throw an error.
You can make it a Handle<Mesh> instead and place it inside the PbrBundle, no need for a SceneBundle

wild token
#

Would it help if I used get_handle for the mesh instead? What is the difference between load and get_handle?