Skip to content

How can I apply a texture loaded from a file to a UVSphere mesh? #6541

Answered by nicopap
pfueyor asked this question in Q&A
Discussion options

You must be logged in to vote

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 seemin…

Replies: 1 comment 1 reply

Comment options

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

Answer selected by pfueyor
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