Refactor hands (#110)
* cargo fmt and removed the unessecary examples. * added left and right hand components for each bone as well as the hand tracker.
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
use bevy_xr::hands::{LeftHand, RightHand};
|
||||||
use bevy_xr::{
|
use bevy_xr::{
|
||||||
hands::{HandBone, HandBoneRadius},
|
hands::{HandBone, HandBoneRadius},
|
||||||
session::{session_running, status_changed_to, XrStatus},
|
session::{session_running, status_changed_to, XrStatus},
|
||||||
@@ -74,10 +75,20 @@ fn spawn_default_hands(
|
|||||||
let mut right_bones = [Entity::PLACEHOLDER; 26];
|
let mut right_bones = [Entity::PLACEHOLDER; 26];
|
||||||
for bone in HandBone::get_all_bones() {
|
for bone in HandBone::get_all_bones() {
|
||||||
let bone_left = cmds
|
let bone_left = cmds
|
||||||
.spawn((SpatialBundle::default(), bone, HandBoneRadius(0.0)))
|
.spawn((
|
||||||
|
SpatialBundle::default(),
|
||||||
|
bone,
|
||||||
|
HandBoneRadius(0.0),
|
||||||
|
LeftHand,
|
||||||
|
))
|
||||||
.id();
|
.id();
|
||||||
let bone_right = cmds
|
let bone_right = cmds
|
||||||
.spawn((SpatialBundle::default(), bone, HandBoneRadius(0.0)))
|
.spawn((
|
||||||
|
SpatialBundle::default(),
|
||||||
|
bone,
|
||||||
|
HandBoneRadius(0.0),
|
||||||
|
RightHand,
|
||||||
|
))
|
||||||
.id();
|
.id();
|
||||||
cmds.entity(root).push_children(&[bone_left]);
|
cmds.entity(root).push_children(&[bone_left]);
|
||||||
cmds.entity(root).push_children(&[bone_right]);
|
cmds.entity(root).push_children(&[bone_right]);
|
||||||
@@ -88,11 +99,13 @@ fn spawn_default_hands(
|
|||||||
DefaultHandTracker,
|
DefaultHandTracker,
|
||||||
OxrHandTracker(tracker_left),
|
OxrHandTracker(tracker_left),
|
||||||
OxrHandBoneEntities(left_bones),
|
OxrHandBoneEntities(left_bones),
|
||||||
|
LeftHand,
|
||||||
));
|
));
|
||||||
cmds.spawn((
|
cmds.spawn((
|
||||||
DefaultHandTracker,
|
DefaultHandTracker,
|
||||||
OxrHandTracker(tracker_right),
|
OxrHandTracker(tracker_right),
|
||||||
OxrHandBoneEntities(right_bones),
|
OxrHandBoneEntities(right_bones),
|
||||||
|
RightHand,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,12 @@ use bevy::{
|
|||||||
prelude::{Deref, DerefMut},
|
prelude::{Deref, DerefMut},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Component, Debug)]
|
||||||
|
pub struct LeftHand;
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Component, Debug)]
|
||||||
|
pub struct RightHand;
|
||||||
|
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[derive(Clone, Copy, Component, Debug, DerefMut, Deref)]
|
#[derive(Clone, Copy, Component, Debug, DerefMut, Deref)]
|
||||||
pub struct HandBoneRadius(pub f32);
|
pub struct HandBoneRadius(pub f32);
|
||||||
|
|||||||
Reference in New Issue
Block a user