DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

fae2a3f74f5ef8b5e29bb1ecda41d84e4519dfe3 — Jonni Liljamo 1 year, 7 months ago 21e47c2
feat(client): add bevy_mod_picking
4 files changed, 82 insertions(+), 13 deletions(-)

M Cargo.lock
M client/Cargo.toml
M client/src/main.rs
M client/src/plugins/game/card/mod.rs
M Cargo.lock => Cargo.lock +52 -0
@@ 713,6 713,27 @@ dependencies = [
]

[[package]]
name = "bevy_mod_picking"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88f94e18ae111035e9bfd4793d1af9e090d35b0fd1048da2d9e32205a1a5104c"
dependencies = [
 "bevy",
 "bevy_picking_core",
 "bevy_picking_input",
 "bevy_picking_raycast",
]

[[package]]
name = "bevy_mod_raycast"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc98a75743120396c8f3e3b47bfeb7f3d39248c46a625972005e51ca4d110a2a"
dependencies = [
 "bevy",
]

[[package]]
name = "bevy_pbr"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 735,6 756,36 @@ dependencies = [
]

[[package]]
name = "bevy_picking_core"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce51af210395ad182b5ddc27375b660d68f105a9e279a887446d593b85299be2"
dependencies = [
 "bevy",
]

[[package]]
name = "bevy_picking_input"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9449ba2725ed32a035d5490bbe963f73c83751e363a9bd114d66e43e04355fcc"
dependencies = [
 "bevy",
 "bevy_picking_core",
]

[[package]]
name = "bevy_picking_raycast"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93fca29f78b3812dc864d60ec7b65007342f3494a0dfcfe4a2109519b1c60ea3"
dependencies = [
 "bevy",
 "bevy_mod_raycast",
 "bevy_picking_core",
]

[[package]]
name = "bevy_ptr"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 2320,6 2371,7 @@ dependencies = [
 "bevy",
 "bevy_editor_pls",
 "bevy_egui",
 "bevy_mod_picking",
 "bevy_rapier3d",
 "bevy_text_mesh",
 "chrono",

M client/Cargo.toml => client/Cargo.toml +7 -0
@@ 55,6 55,13 @@ features = [
[dependencies.bevy_text_mesh]
version = "0.6.0"

[dependencies.bevy_mod_picking]
version = "0.13.0"
default-features = false
features = [
    "backend_raycast",
]

[dependencies.bevy_egui]
version = "0.20.2"
default-features = false

M client/src/main.rs => client/src/main.rs +12 -6
@@ 13,6 13,7 @@ use api::user::User;
use bevy::prelude::*;
use bevy_editor_pls::EditorPlugin;
use bevy_egui::EguiPlugin;
use bevy_mod_picking::prelude::*;
use bevy_rapier3d::prelude::*;
use bevy_text_mesh::prelude::*;



@@ 44,6 45,8 @@ fn main() {
    app.add_plugin(RapierPhysicsPlugin::<NoUserData>::default());
    app.add_plugin(TextMeshPlugin);

    app.add_plugins(DefaultPickingPlugins);

    app.insert_resource(AmbientLight {
        color: Color::ANTIQUE_WHITE,
        brightness: 0.4,


@@ 96,14 99,17 @@ struct PlayerCamera;

fn setup(mut commands: Commands) {
    commands
        .spawn(Camera3dBundle {
            transform: Transform {
                translation: Vec3::new(0., 8., 8.),
                rotation: Quat::from_rotation_x(-0.5),
        .spawn((
            Camera3dBundle {
                transform: Transform {
                    translation: Vec3::new(0., 8., 8.),
                    rotation: Quat::from_rotation_x(-0.5),
                    ..Default::default()
                },
                ..Default::default()
            },
            ..Default::default()
        })
            RaycastPickCamera::default(),
        ))
        .insert(PlayerCamera);
}


M client/src/plugins/game/card/mod.rs => client/src/plugins/game/card/mod.rs +11 -7
@@ 7,6 7,7 @@
 */

use bevy::prelude::*;
use bevy_mod_picking::prelude::*;
use bevy_rapier3d::prelude::*;
use bevy_text_mesh::prelude::*;



@@ 135,15 136,18 @@ fn on_spawn_card(
) {
    for (entity, card) in &new_cards {
        commands.entity(entity).with_children(|parent| {
            parent.spawn(PbrBundle {
                material: card_data.card_background.clone(),
                mesh: card_data.mesh.clone(),
                transform: Transform {
                    scale: Vec3::new(2., 2., 1.),
            parent.spawn((
                PbrBundle {
                    material: card_data.card_background.clone(),
                    mesh: card_data.mesh.clone(),
                    transform: Transform {
                        scale: Vec3::new(2., 2., 1.),
                        ..Default::default()
                    },
                    ..Default::default()
                },
                ..Default::default()
            });
                RaycastPickTarget::default(),
            ));

            // card name
            parent.spawn(TextMeshBundle {