Skip to content
Discussion options

You must be logged in to vote

It's not possible to query for Cube -- it is not a part of PbrBundle. PbrBundle only contains a handle to a mesh asset.

// this
commands.spawn(PbrBundle {
    mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
    ..default()
});

// is equivalent to:
let cube_shape = shape::Cube { size: 1.0 };
let mesh = Mesh::from(cube_shape);
let mesh_handle = meshes.add(mesh);

commands.spawn(PbrBundle {
    mesh: mesh_handle,
    ..default()
});

Now that we know what's going on, let's actually change the size of the cube.

#[derive(Component)]
struct MyCube;

commands.spawn((
    PbrBundle {
        mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
        ..default()
    },
    MyCube,
));

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@xiaohulu
Comment options

Answer selected by xiaohulu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants