more required components and other stuff
Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
@@ -2,17 +2,11 @@ use std::ops::Deref;
|
|||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy_mod_openxr::{
|
use bevy_mod_openxr::{
|
||||||
action_binding::{OxrSendActionBindings, OxrSuggestActionBinding},
|
action_binding::{OxrSendActionBindings, OxrSuggestActionBinding}, action_set_attaching::OxrAttachActionSet, action_set_syncing::{OxrActionSetSyncSet, OxrSyncActionSet}, add_xr_plugins, openxr_session_running, resources::OxrInstance, session::OxrSession, spaces::OxrSpaceExt
|
||||||
action_set_attaching::OxrAttachActionSet,
|
|
||||||
action_set_syncing::{OxrActionSetSyncSet, OxrSyncActionSet},
|
|
||||||
add_xr_plugins,
|
|
||||||
resources::OxrInstance,
|
|
||||||
session::OxrSession,
|
|
||||||
spaces::OxrSpaceExt,
|
|
||||||
};
|
};
|
||||||
use bevy_mod_xr::{
|
use bevy_mod_xr::{
|
||||||
session::{session_available, session_running, XrSessionCreated},
|
session::{session_available, session_running, XrSessionCreated},
|
||||||
spaces::XrSpace,
|
spaces::{XrSpace, XrSpaceLocationFlags},
|
||||||
};
|
};
|
||||||
use openxr::Posef;
|
use openxr::Posef;
|
||||||
|
|
||||||
@@ -25,7 +19,7 @@ fn main() {
|
|||||||
PreUpdate,
|
PreUpdate,
|
||||||
sync_actions
|
sync_actions
|
||||||
.before(OxrActionSetSyncSet)
|
.before(OxrActionSetSyncSet)
|
||||||
.run_if(session_running),
|
.run_if(openxr_session_running),
|
||||||
);
|
);
|
||||||
app.add_systems(OxrSendActionBindings, suggest_action_bindings);
|
app.add_systems(OxrSendActionBindings, suggest_action_bindings);
|
||||||
app.add_systems(Startup, create_actions.run_if(session_available));
|
app.add_systems(Startup, create_actions.run_if(session_available));
|
||||||
@@ -131,12 +125,16 @@ fn spawn_hands(
|
|||||||
Mesh3d(meshes.add(Cuboid::new(0.1, 0.1, 0.05))),
|
Mesh3d(meshes.add(Cuboid::new(0.1, 0.1, 0.05))),
|
||||||
MeshMaterial3d(materials.add(Color::srgb_u8(124, 144, 255))),
|
MeshMaterial3d(materials.add(Color::srgb_u8(124, 144, 255))),
|
||||||
left_space,
|
left_space,
|
||||||
|
// runtime required components are not inserted for non runrime required components, should
|
||||||
|
// be fixed in the final bevy 0.15 release
|
||||||
|
XrSpaceLocationFlags::default(),
|
||||||
Controller,
|
Controller,
|
||||||
));
|
));
|
||||||
cmds.spawn((
|
cmds.spawn((
|
||||||
Mesh3d(meshes.add(Cuboid::new(0.1, 0.1, 0.05))),
|
Mesh3d(meshes.add(Cuboid::new(0.1, 0.1, 0.05))),
|
||||||
MeshMaterial3d(materials.add(Color::srgb_u8(124, 144, 255))),
|
MeshMaterial3d(materials.add(Color::srgb_u8(124, 144, 255))),
|
||||||
right_space,
|
right_space,
|
||||||
|
XrSpaceLocationFlags::default(),
|
||||||
Controller,
|
Controller,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,19 @@
|
|||||||
//! A simple 3D scene with light shining over a cube sitting on a plane.
|
//! A simple 3D scene with light shining over a cube sitting on a plane.
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy_mod_openxr::add_xr_plugins;
|
use bevy_mod_openxr::{add_xr_plugins, init::OxrInitPlugin};
|
||||||
use bevy_mod_xr::session::{XrSessionPlugin, XrState};
|
use bevy_mod_xr::session::{XrSessionPlugin, XrState};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(add_xr_plugins(DefaultPlugins).set(XrSessionPlugin { auto_handle: true }))
|
.add_plugins(
|
||||||
|
add_xr_plugins(DefaultPlugins)
|
||||||
|
.set(XrSessionPlugin { auto_handle: true })
|
||||||
|
.set(OxrInitPlugin {
|
||||||
|
blend_modes: Some(vec![openxr::EnvironmentBlendMode::OPAQUE]),
|
||||||
|
..Default::default()
|
||||||
|
}),
|
||||||
|
)
|
||||||
.add_plugins(bevy_xr_utils::hand_gizmos::HandGizmosPlugin)
|
.add_plugins(bevy_xr_utils::hand_gizmos::HandGizmosPlugin)
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
.add_systems(Update, handle_input)
|
.add_systems(Update, handle_input)
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ fn sync_sets(session: Res<OxrSession>, mut events: EventReader<OxrSyncActionSet>
|
|||||||
.map(|v| &v.0)
|
.map(|v| &v.0)
|
||||||
.map(openxr::ActiveActionSet::new)
|
.map(openxr::ActiveActionSet::new)
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
if sets.is_empty() {
|
if sets.is_empty() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ impl OxrExtensions {
|
|||||||
self.0.ext_hand_tracking = false;
|
self.0.ext_hand_tracking = false;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
pub fn enable_extx_overlay(&mut self) -> &mut Self {
|
||||||
|
self.0.extx_overlay = true;
|
||||||
|
self
|
||||||
|
}
|
||||||
/// returns true if all of the extensions enabled are also available in `available_exts`
|
/// returns true if all of the extensions enabled are also available in `available_exts`
|
||||||
pub fn is_available(&self, available_exts: &OxrExtensions) -> bool {
|
pub fn is_available(&self, available_exts: &OxrExtensions) -> bool {
|
||||||
self.clone() & available_exts.clone() == *self
|
self.clone() & available_exts.clone() == *self
|
||||||
|
|||||||
Reference in New Issue
Block a user