created player model, added rotation with movement, better lighting and camera positioning

This commit is contained in:
2026-01-01 22:50:34 +00:00
parent 01a94832a1
commit 6218b4999a
6 changed files with 45 additions and 10 deletions

10
Cargo.lock generated
View File

@@ -320,6 +320,7 @@ version = "0.17.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76d3ee8652fe0577fd8a99054e147740850140d530be8e044a9be4e23a3e8a24" checksum = "76d3ee8652fe0577fd8a99054e147740850140d530be8e044a9be4e23a3e8a24"
dependencies = [ dependencies = [
"bevy_dylib",
"bevy_internal", "bevy_internal",
] ]
@@ -604,6 +605,15 @@ dependencies = [
"sysinfo", "sysinfo",
] ]
[[package]]
name = "bevy_dylib"
version = "0.17.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d50a92aea6e896b6939ea51db6ced3a7e2dfd591016286e3eed9cb60d9e4f149"
dependencies = [
"bevy_internal",
]
[[package]] [[package]]
name = "bevy_ecs" name = "bevy_ecs"
version = "0.17.3" version = "0.17.3"

View File

@@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2024" edition = "2024"
[dependencies] [dependencies]
bevy = "0.17.3" bevy = { version = "0.17.3", features = ["default", "dynamic_linking"] }
[profile.release] [profile.release]
opt-level = 3 opt-level = 3

BIN
assets/models/employee.glb Normal file

Binary file not shown.

BIN
modelling/employee.blend Normal file

Binary file not shown.

BIN
modelling/employee.blend1 Normal file

Binary file not shown.

View File

@@ -23,36 +23,58 @@ fn setup(
mut commands: Commands, mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>, mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>, mut materials: ResMut<Assets<StandardMaterial>>,
asset_server: Res<AssetServer>,
) { ) {
// Camera // Camera
commands.spawn(( commands.spawn((
Camera3d::default(), Camera3d::default(),
Transform::from_xyz(10.0, 10.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y), Transform::from_xyz(0.0, 25.0, -25.0).looking_at(Vec3::ZERO, Vec3::Y),
)); ));
// Cube // Player
commands.spawn(( commands.spawn((
Mesh3d(meshes.add(Cuboid::new(2.0, 2.0, 2.0))), SceneRoot(asset_server.load("models/employee.glb#Scene0")),
MeshMaterial3d(materials.add(Color::srgb(1.0, 0.0, 0.0))), //MeshMaterial3d(materials.add(Color::srgb(0.9, 0.83, 0.6))),
Transform::from_xyz(0.0, 1.0, 0.0), Transform::from_xyz(0.0, 1.5, 0.0).with_scale(Vec3::splat(0.5)),
Player { Player {
move_speed: 10.0, move_speed: 10.0,
height_offset: 1.0, height_offset: 1.5,
}, },
MoveTarget { MoveTarget {
position: Vec3::new(0.0, 0.0, 0.0), position: Vec3::new(0.0, 0.0, 0.0),
}, },
)); ));
// Light (DOESN'T WORK) // Light
commands.insert_resource(AmbientLight {
color: Color::WHITE,
brightness: 200.0, // Subtle fill light so shadows aren't pitch black
..default()
});
commands.spawn(( commands.spawn((
DirectionalLight {
illuminance: 1000.0,
shadows_enabled: true,
..default()
},
Transform::from_rotation(Quat::from_euler(
EulerRot::XYZ,
-0.8, // Pitch down (looking down at scene)
0.5, // Yaw (angle from side)
0.0, // Roll (no rotation)
)),
));
/*commands.spawn((
PointLight { PointLight {
intensity: 1000000.0, intensity: 1000000.0,
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
Transform::from_xyz(0.0, 10.0, 0.0).looking_at(Vec3::ZERO, Vec3::Y), Transform::from_xyz(0.0, 10.0, 0.0),
)); ));*/
// Plane // Plane
commands.spawn(( commands.spawn((
@@ -122,6 +144,9 @@ fn move_to_target(mut query: Query<(&mut Transform, &MoveTarget, &Player)>, time
transform.translation = adjusted_target; transform.translation = adjusted_target;
} else { } else {
transform.translation += direction.normalize() * move_amount; transform.translation += direction.normalize() * move_amount;
let target_look = target.position + Vec3::Y * player.height_offset;
transform.look_at(target_look, Vec3::Y);
} }
} }
} }