embrace the egui
This commit is contained in:
49
src/vrplugin.rs
Normal file
49
src/vrplugin.rs
Normal file
@@ -0,0 +1,49 @@
|
||||
use bevy::{
|
||||
prelude::*,
|
||||
render::render_resource::TextureFormat,
|
||||
window::{PresentMode, WindowResolution},
|
||||
};
|
||||
use bevy_mod_openxr::prelude::*;
|
||||
use bevy_mod_xr::session::XrSessionCreated;
|
||||
|
||||
use crate::vrcontrollerplugin::VrControllersPlugin;
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct Headset;
|
||||
|
||||
pub struct VrPlugin;
|
||||
|
||||
impl Plugin for VrPlugin {
|
||||
fn build(&self, app: &mut bevy::app::App) {
|
||||
app.add_plugins(
|
||||
add_xr_plugins(DefaultPlugins)
|
||||
.disable::<HandTrackingPlugin>()
|
||||
.build()
|
||||
.set(OxrInitPlugin {
|
||||
exts: {
|
||||
let mut exts = OxrExtensions::default();
|
||||
exts.extx_overlay = true;
|
||||
exts
|
||||
},
|
||||
..Default::default()
|
||||
}),
|
||||
);
|
||||
|
||||
app.insert_resource(ClearColor(Color::NONE))
|
||||
.insert_resource(OxrSessionConfig {
|
||||
blend_mode_preference: { vec![EnvironmentBlendMode::ALPHA_BLEND] },
|
||||
formats: Some(vec![TextureFormat::Rgba8UnormSrgb]),
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
app.add_systems(XrSessionCreated, create_view_space);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn create_view_space(session: Res<OxrSession>, mut commands: Commands) {
|
||||
let space = session
|
||||
.create_reference_space(openxr::ReferenceSpaceType::VIEW, Isometry3d::IDENTITY)
|
||||
.unwrap();
|
||||
|
||||
commands.spawn((Headset, space.0));
|
||||
}
|
||||
Reference in New Issue
Block a user