just create a raycaster
This commit is contained in:
parent
b54e0a637f
commit
b34d771d65
1 changed files with 16 additions and 35 deletions
51
src/bike.rs
51
src/bike.rs
|
@ -146,16 +146,16 @@ fn spawn_children(
|
|||
let rear_rake = Vec3::new(0.0, -1.0, 0.9).normalize();
|
||||
let rear_wheel_pos = REAR_ATTACH + (rear_rake * REST_DISTANCE);
|
||||
|
||||
children!(
|
||||
children![
|
||||
body,
|
||||
wheel_caster(
|
||||
parent,
|
||||
FRONT_ATTACH,
|
||||
Dir3::new_unchecked(front_rake),
|
||||
REST_DISTANCE,
|
||||
CyberWheel::Front,
|
||||
(
|
||||
RayCaster::new(FRONT_ATTACH, Dir3::new_unchecked(front_rake))
|
||||
.with_max_hits(1)
|
||||
.with_max_distance(REST_DISTANCE)
|
||||
.with_query_filter(SpatialQueryFilter::from_excluded_entities([parent])),
|
||||
CyberWheel::Front
|
||||
),
|
||||
wheel_mesh(
|
||||
wheel_bundle(
|
||||
mesh.clone(),
|
||||
material.clone(),
|
||||
front_wheel_pos,
|
||||
|
@ -169,14 +169,14 @@ fn spawn_children(
|
|||
),
|
||||
CyberWheel::Front,
|
||||
),
|
||||
wheel_caster(
|
||||
parent,
|
||||
REAR_ATTACH,
|
||||
Dir3::new_unchecked(rear_rake),
|
||||
REST_DISTANCE,
|
||||
(
|
||||
RayCaster::new(REAR_ATTACH, Dir3::new_unchecked(rear_rake))
|
||||
.with_max_hits(1)
|
||||
.with_max_distance(REST_DISTANCE)
|
||||
.with_query_filter(SpatialQueryFilter::from_excluded_entities([parent])),
|
||||
CyberWheel::Rear,
|
||||
),
|
||||
wheel_mesh(
|
||||
wheel_bundle(
|
||||
mesh,
|
||||
material,
|
||||
rear_wheel_pos,
|
||||
|
@ -190,29 +190,10 @@ fn spawn_children(
|
|||
),
|
||||
CyberWheel::Rear,
|
||||
),
|
||||
)
|
||||
]
|
||||
}
|
||||
|
||||
//-************************************************************************
|
||||
// helper fns for the wheels
|
||||
//-************************************************************************
|
||||
|
||||
fn wheel_caster(
|
||||
parent: Entity,
|
||||
origin: Vec3,
|
||||
direction: Dir3,
|
||||
rest_dist: Scalar,
|
||||
wheel: CyberWheel,
|
||||
) -> impl Bundle {
|
||||
let caster = RayCaster::new(origin, direction)
|
||||
.with_max_distance(rest_dist)
|
||||
.with_max_hits(1)
|
||||
.with_query_filter(SpatialQueryFilter::from_excluded_entities([parent]));
|
||||
|
||||
(caster, wheel)
|
||||
}
|
||||
|
||||
fn wheel_mesh(
|
||||
fn wheel_bundle(
|
||||
mesh: Handle<Mesh>,
|
||||
material: Handle<StandardMaterial>,
|
||||
position: Vec3,
|
||||
|
|
Loading…
Reference in a new issue