-
I want to create several balls using commands.spawn_bundle(PbrBundle {
mesh: meshes.add(Mesh::from(shape::UVSphere { radius: 0.5, ..default() })),
material: materials.add(Color::rgb(1.0, 1.0, 1.0).into()),
..default()
}); These are solid balls painted with a single color each one. What I want to accomplish is to paint them with a custom texture loaded from a PNG file. How can this be done? Is it needed to use commands.spawn_bundle(MaterialMeshBundle {
material: materials.add(Material {
color: Color::RED,
color_texture: asset_server.load("some_image.png"),
}),
..Default::default()
}); |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Yeah. Such an example can be found in this example: https://github.com/nicopap/bevy_mod_paramap/blob/f2ecc42b79e9eb469485d79c7f2357fdf21f9fee/examples/earth3d.rs#L126-L159 This uses a custom material, but you can translate this to use the standard bevy material with: commands
.spawn_bundle(PbrBundle {
transform: Transform::from_rotation(Quat::from_euler(XYZ, -TAU / 4.0, 0.0, TAU / 2.0)),
mesh: meshes.add(sphere),
material: materials.add(StandardMaterial {
base_color_texture: Some(asset_server.load("earth/base_color.jpg")),
..default()
}),
..default()
}) The default UV map seemingly uses an equirectangular projection. |
Beta Was this translation helpful? Give feedback.
Yeah. Such an example can be found in this example: https://github.com/nicopap/bevy_mod_paramap/blob/f2ecc42b79e9eb469485d79c7f2357fdf21f9fee/examples/earth3d.rs#L126-L159
This uses a custom material, but you can translate this to use the standard bevy material with:
The default UV map seemin…