Refactor loading
This commit is contained in:
+59
-41
@@ -1,49 +1,67 @@
|
||||
//! The scene content that gets spawned at startup.
|
||||
//! Code-defined deterministic stage collision and development lighting.
|
||||
|
||||
use std::f32::consts::PI;
|
||||
|
||||
use bevy::{camera_controller::free_camera::FreeCamera, prelude::*};
|
||||
|
||||
use crate::{math::vec::FGVec2, stage::{StagePoly, line::{StageCollision, StagePolyLineSegmentType}}};
|
||||
use crate::{
|
||||
math::vec::FGVec2,
|
||||
stage::{
|
||||
StagePoly,
|
||||
line::{StageCollision, StagePolyLineSegmentType, StagePolyType},
|
||||
},
|
||||
};
|
||||
|
||||
/// set up a simple 3D scene
|
||||
pub fn test_scene() -> impl SceneList {
|
||||
pub fn spawn_stage_support(commands: &mut Commands, match_root: Entity) {
|
||||
let stage_poly = StagePoly::build(
|
||||
StagePolyType::Closed,
|
||||
&[
|
||||
(
|
||||
FGVec2::lit("-56.0", "-3.5"),
|
||||
StagePolyLineSegmentType::Floor,
|
||||
),
|
||||
(FGVec2::lit("-39.2", "0.0"), StagePolyLineSegmentType::Floor),
|
||||
(FGVec2::lit("0.0", "0.0"), StagePolyLineSegmentType::Floor),
|
||||
(FGVec2::lit("39.2", "0.0"), StagePolyLineSegmentType::Floor),
|
||||
(FGVec2::lit("56.0", "-3.5"), StagePolyLineSegmentType::Wall),
|
||||
(
|
||||
FGVec2::lit("56.0", "-200.0"),
|
||||
StagePolyLineSegmentType::Ceiling,
|
||||
),
|
||||
(FGVec2::lit("-56", "-200.0"), StagePolyLineSegmentType::Wall),
|
||||
],
|
||||
);
|
||||
|
||||
let stage_poly = StagePoly::build(crate::stage::line::StagePolyType::Closed, &[
|
||||
(FGVec2::lit("-56.0", "-3.5"), StagePolyLineSegmentType::Floor),
|
||||
(FGVec2::lit("-39.2", "0.0"), StagePolyLineSegmentType::Floor),
|
||||
(FGVec2::lit("0.0", "0.0"), StagePolyLineSegmentType::Floor),
|
||||
(FGVec2::lit("39.2", "0.0"), StagePolyLineSegmentType::Floor),
|
||||
(FGVec2::lit("56.0", "-3.5"), StagePolyLineSegmentType::Wall),
|
||||
(FGVec2::lit("56.0", "-200.0"), StagePolyLineSegmentType::Ceiling),
|
||||
(FGVec2::lit("-56", "-200.0"), StagePolyLineSegmentType::Wall)
|
||||
]);
|
||||
|
||||
bsn_list! [
|
||||
(
|
||||
#StageCollision
|
||||
template_value(StageCollision {
|
||||
stage_polys: vec!(stage_poly)
|
||||
})
|
||||
),
|
||||
(
|
||||
DirectionalLight {
|
||||
shadow_maps_enabled: true,
|
||||
}
|
||||
Transform {
|
||||
translation: Vec3::new(0.0, 2.0, 0.0),
|
||||
rotation: Quat::from_rotation_x(-PI / 4.),
|
||||
}
|
||||
),
|
||||
(
|
||||
Camera3d
|
||||
template_value(Transform::from_xyz(0.0, 1.5, 9.0))
|
||||
FreeCamera {
|
||||
sensitivity: 0.2,
|
||||
friction: 25.0,
|
||||
walk_speed: 3.0,
|
||||
run_speed: 9.0,
|
||||
}
|
||||
)
|
||||
]
|
||||
commands.insert_resource(StageCollision {
|
||||
stage_polys: vec![stage_poly.clone()],
|
||||
});
|
||||
commands.spawn((
|
||||
Name::new("Stage Collision"),
|
||||
stage_poly,
|
||||
ChildOf(match_root),
|
||||
));
|
||||
commands.spawn((
|
||||
DirectionalLight {
|
||||
shadow_maps_enabled: true,
|
||||
..default()
|
||||
},
|
||||
Transform {
|
||||
translation: Vec3::new(0.0, 2.0, 0.0),
|
||||
rotation: Quat::from_rotation_x(-PI / 4.0),
|
||||
..default()
|
||||
},
|
||||
ChildOf(match_root),
|
||||
));
|
||||
commands.spawn((
|
||||
Camera3d::default(),
|
||||
Transform::from_xyz(0.0, 10.5, 150.0),
|
||||
/*FreeCamera {
|
||||
sensitivity: 0.2,
|
||||
friction: 25.0,
|
||||
walk_speed: 3.0,
|
||||
run_speed: 9.0,
|
||||
..default()
|
||||
},*/
|
||||
ChildOf(match_root),
|
||||
));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user