create scaffolding
This commit is contained in:
commit
82a0fbdb50
25 changed files with 6993 additions and 0 deletions
55
crates/physics/src/lib.rs
Normal file
55
crates/physics/src/lib.rs
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
//bevy system signatures often violate these rules
|
||||
#![allow(clippy::type_complexity)]
|
||||
#![allow(clippy::too_many_arguments)]
|
||||
|
||||
use avian3d::prelude::*;
|
||||
use bevy::prelude::*;
|
||||
use state::AppState;
|
||||
|
||||
pub struct PhysicsPlugin;
|
||||
|
||||
impl Plugin for PhysicsPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_plugins(PhysicsPlugins::default())
|
||||
.add_systems(OnEnter(AppState::Game), setup);
|
||||
}
|
||||
}
|
||||
|
||||
fn setup(
|
||||
mut commands: Commands,
|
||||
mut meshes: ResMut<Assets<Mesh>>,
|
||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||
) {
|
||||
// Static physics object with a collision shape
|
||||
commands.spawn((
|
||||
RigidBody::Static,
|
||||
Collider::cylinder(4.0, 0.1),
|
||||
Mesh3d(meshes.add(Cylinder::new(4.0, 0.1))),
|
||||
MeshMaterial3d(materials.add(Color::WHITE)),
|
||||
));
|
||||
|
||||
// Dynamic physics object with a collision shape and initial angular velocity
|
||||
commands.spawn((
|
||||
RigidBody::Dynamic,
|
||||
Collider::cuboid(1.0, 1.0, 1.0),
|
||||
AngularVelocity(Vec3::new(2.5, 3.5, 1.5)),
|
||||
Mesh3d(meshes.add(Cuboid::from_length(1.0))),
|
||||
MeshMaterial3d(materials.add(Color::srgb_u8(124, 144, 255))),
|
||||
Transform::from_xyz(0.0, 4.0, 0.0),
|
||||
));
|
||||
|
||||
// Light
|
||||
commands.spawn((
|
||||
PointLight {
|
||||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
Transform::from_xyz(4.0, 8.0, 4.0),
|
||||
));
|
||||
|
||||
// Camera
|
||||
commands.spawn((
|
||||
Camera3d::default(),
|
||||
Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Dir3::Y),
|
||||
));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue