1126
Cargo.lock
generated
1126
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
13
Cargo.toml
13
Cargo.toml
@@ -1,8 +1,15 @@
|
||||
[package]
|
||||
name = "bevy_mod_xr_backends"
|
||||
version = "0.1.0"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
description.workspace = true
|
||||
repository.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
[workspace.package]
|
||||
version = "0.1.0-rc1"
|
||||
edition = "2021"
|
||||
description = "Community crate for OpenXR in Bevy"
|
||||
description = "Community crate for XR in Bevy"
|
||||
repository = "https://github.com/awtterpip/bevy_oxr"
|
||||
license = "MIT/Apache-2.0"
|
||||
|
||||
@@ -15,4 +22,4 @@ bevy.workspace = true
|
||||
members = ["crates/*", "crates/bevy_openxr/examples/android"]
|
||||
|
||||
[workspace.dependencies]
|
||||
bevy = "0.13.0"
|
||||
bevy = "0.14.0"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "bevy_mod_openxr"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
|
||||
[features]
|
||||
default = ["vulkan", "d3d12", "passthrough"]
|
||||
@@ -24,9 +24,9 @@ bevy.workspace = true
|
||||
[target.'cfg(not(target_family = "wasm"))'.dependencies]
|
||||
openxr = "0.18.0"
|
||||
thiserror = "1.0.57"
|
||||
wgpu = "0.19.3"
|
||||
wgpu-hal = "0.19.3"
|
||||
bevy_mod_xr.path = "../bevy_xr"
|
||||
wgpu = "0.20"
|
||||
wgpu-hal = "0.21"
|
||||
bevy_mod_xr={path = "../bevy_xr",version = "0.1.0-rc1"}
|
||||
|
||||
ash = { version = "0.37.3", optional = true }
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ fn setup(
|
||||
// cube
|
||||
commands.spawn(PbrBundle {
|
||||
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
|
||||
material: materials.add(Color::rgb_u8(124, 144, 255)),
|
||||
material: materials.add(Color::srgb_u8(124, 144, 255)),
|
||||
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
||||
..default()
|
||||
});
|
||||
|
||||
@@ -43,7 +43,7 @@ fn setup_scene(
|
||||
// cube
|
||||
commands.spawn(PbrBundle {
|
||||
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
|
||||
material: materials.add(Color::rgb_u8(124, 144, 255)),
|
||||
material: materials.add(Color::srgb_u8(124, 144, 255)),
|
||||
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
||||
..default()
|
||||
});
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
[package]
|
||||
name = "bevy_openxr_android"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
publish = false
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ fn setup(
|
||||
transform: Transform::from_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)),
|
||||
..default()
|
||||
});
|
||||
let mut cube_mat: StandardMaterial = Color::rgb_u8(124, 144, 255).into();
|
||||
let mut cube_mat: StandardMaterial = Color::srgb_u8(124, 144, 255).into();
|
||||
cube_mat.unlit = true;
|
||||
// cube
|
||||
commands.spawn(PbrBundle {
|
||||
|
||||
@@ -88,7 +88,7 @@ fn setup(
|
||||
// cube
|
||||
commands.spawn(PbrBundle {
|
||||
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
|
||||
material: materials.add(Color::rgb_u8(124, 144, 255)),
|
||||
material: materials.add(Color::srgb_u8(124, 144, 255)),
|
||||
transform: Transform::from_xyz(0.0, 2.5, 0.0),
|
||||
..default()
|
||||
});
|
||||
|
||||
@@ -60,7 +60,7 @@ fn setup(
|
||||
// cube
|
||||
commands.spawn(PbrBundle {
|
||||
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
|
||||
material: materials.add(Color::rgb_u8(124, 144, 255)),
|
||||
material: materials.add(Color::srgb_u8(124, 144, 255)),
|
||||
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
||||
..default()
|
||||
});
|
||||
@@ -132,7 +132,7 @@ fn spawn_hands(
|
||||
.spawn((
|
||||
PbrBundle {
|
||||
mesh: meshes.add(Cuboid::new(0.1, 0.1, 0.05)),
|
||||
material: materials.add(Color::rgb_u8(124, 144, 255)),
|
||||
material: materials.add(Color::srgb_u8(124, 144, 255)),
|
||||
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
||||
..default()
|
||||
},
|
||||
@@ -144,7 +144,7 @@ fn spawn_hands(
|
||||
.spawn((
|
||||
PbrBundle {
|
||||
mesh: meshes.add(Cuboid::new(0.1, 0.1, 0.05)),
|
||||
material: materials.add(Color::rgb_u8(124, 144, 255)),
|
||||
material: materials.add(Color::srgb_u8(124, 144, 255)),
|
||||
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
||||
..default()
|
||||
},
|
||||
|
||||
@@ -64,7 +64,7 @@ fn setup(
|
||||
// cube
|
||||
commands.spawn(PbrBundle {
|
||||
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
|
||||
material: materials.add(Color::rgb_u8(124, 144, 255)),
|
||||
material: materials.add(Color::srgb_u8(124, 144, 255)),
|
||||
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
||||
..default()
|
||||
});
|
||||
|
||||
@@ -50,35 +50,35 @@ fn setup(
|
||||
// red cube
|
||||
commands.spawn(PbrBundle {
|
||||
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
|
||||
material: materials.add(Color::rgb_u8(252, 44, 3)),
|
||||
material: materials.add(Color::srgb_u8(252, 44, 3)),
|
||||
transform: Transform::from_xyz(4.0, 0.5, 0.0).with_scale(Vec3::splat(0.5)),
|
||||
..default()
|
||||
});
|
||||
// blue cube
|
||||
commands.spawn(PbrBundle {
|
||||
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
|
||||
material: materials.add(Color::rgb_u8(3, 28, 252)),
|
||||
material: materials.add(Color::srgb_u8(3, 28, 252)),
|
||||
transform: Transform::from_xyz(-4.0, 0.5, 0.0).with_scale(Vec3::splat(0.5)),
|
||||
..default()
|
||||
});
|
||||
// green cube
|
||||
commands.spawn(PbrBundle {
|
||||
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
|
||||
material: materials.add(Color::rgb_u8(3, 252, 32)),
|
||||
material: materials.add(Color::srgb_u8(3, 252, 32)),
|
||||
transform: Transform::from_xyz(0.0, 0.5, 4.0).with_scale(Vec3::splat(0.5)),
|
||||
..default()
|
||||
});
|
||||
// white cube
|
||||
commands.spawn(PbrBundle {
|
||||
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
|
||||
material: materials.add(Color::rgb_u8(250, 250, 250)),
|
||||
material: materials.add(Color::srgb_u8(250, 250, 250)),
|
||||
transform: Transform::from_xyz(0.0, 0.5, -4.0).with_scale(Vec3::splat(0.5)),
|
||||
..default()
|
||||
});
|
||||
// black cube
|
||||
commands.spawn(PbrBundle {
|
||||
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
|
||||
material: materials.add(Color::rgb_u8(0, 0, 0)),
|
||||
material: materials.add(Color::srgb_u8(0, 0, 0)),
|
||||
transform: Transform::from_xyz(0.0, 0.1, 0.0).with_scale(Vec3::splat(0.2)),
|
||||
..default()
|
||||
});
|
||||
|
||||
@@ -15,10 +15,10 @@ pub struct OxrPassthroughPlugin;
|
||||
impl Plugin for OxrPassthroughPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
let resources = app
|
||||
.world
|
||||
.world()
|
||||
.get_resource::<OxrInstance>()
|
||||
.and_then(|instance| {
|
||||
app.world
|
||||
app.world()
|
||||
.get_resource::<OxrSystemId>()
|
||||
.map(|system_id| (instance, system_id))
|
||||
});
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use bevy::prelude::*;
|
||||
use bevy::render::extract_resource::ExtractResourcePlugin;
|
||||
use bevy::render::renderer::RenderAdapter;
|
||||
@@ -5,6 +7,7 @@ use bevy::render::renderer::RenderAdapterInfo;
|
||||
use bevy::render::renderer::RenderDevice;
|
||||
use bevy::render::renderer::RenderInstance;
|
||||
use bevy::render::renderer::RenderQueue;
|
||||
use bevy::render::renderer::WgpuWrapper;
|
||||
use bevy::render::settings::RenderCreation;
|
||||
use bevy::render::MainWorld;
|
||||
use bevy::render::RenderApp;
|
||||
@@ -90,10 +93,10 @@ impl Plugin for OxrInitPlugin {
|
||||
RenderPlugin {
|
||||
render_creation: RenderCreation::manual(
|
||||
device.into(),
|
||||
RenderQueue(queue.into()),
|
||||
RenderAdapterInfo(adapter_info),
|
||||
RenderAdapter(adapter.into()),
|
||||
RenderInstance(wgpu_instance.into()),
|
||||
RenderQueue(Arc::new(WgpuWrapper::new(queue))),
|
||||
RenderAdapterInfo(WgpuWrapper::new(adapter_info)),
|
||||
RenderAdapter(Arc::new(WgpuWrapper::new(adapter))),
|
||||
RenderInstance(Arc::new(WgpuWrapper::new(wgpu_instance))),
|
||||
),
|
||||
synchronous_pipeline_compilation: self.synchronous_pipeline_compilation,
|
||||
},
|
||||
@@ -121,10 +124,10 @@ impl Plugin for OxrInitPlugin {
|
||||
.insert_non_send_resource(session_create_info)
|
||||
.init_non_send_resource::<OxrSessionCreateNextChain>();
|
||||
|
||||
app.world
|
||||
app.world_mut()
|
||||
.spawn((TransformBundle::default(), XrTrackingRoot));
|
||||
|
||||
app.world
|
||||
app.world_mut()
|
||||
.resource_mut::<Events<XrStateChanged>>()
|
||||
.send(XrStateChanged(XrState::Available));
|
||||
|
||||
|
||||
@@ -277,7 +277,7 @@ pub fn update_views_render_world(
|
||||
let openxr::Vector3f { x, y, z } = view.pose.position;
|
||||
let translation = Vec3::new(x, y, z);
|
||||
transform.translation = translation;
|
||||
extracted_view.transform = root.0.mul_transform(transform);
|
||||
extracted_view.world_from_view = root.0.mul_transform(transform);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "bevy_mod_webxr"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
|
||||
# bevy can't be placed behind target or proc macros won't work properly
|
||||
[dependencies]
|
||||
@@ -13,4 +13,4 @@ thiserror = "1.0.57"
|
||||
wgpu = "0.19.3"
|
||||
wgpu-hal = "0.19.3"
|
||||
|
||||
bevy_mod_xr.path = "../bevy_xr"
|
||||
bevy_mod_xr = { path = "../bevy_xr", version = "0.1.0-rc1" }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "bevy_mod_xr"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ impl<A: Action> Plugin for ActionPlugin<A> {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.init_resource::<ActionList>()
|
||||
.init_resource::<ActionState<A>>();
|
||||
app.world.resource_mut::<ActionList>().0.push(A::info());
|
||||
app.world_mut().resource_mut::<ActionList>().0.push(A::info());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ impl Plugin for XrCameraPlugin {
|
||||
PostUpdate,
|
||||
update_frusta::<XrProjection>
|
||||
.after(TransformSystem::TransformPropagate)
|
||||
.before(VisibilitySystems::UpdatePerspectiveFrusta),
|
||||
.before(VisibilitySystems::UpdateFrusta),
|
||||
);
|
||||
app.add_plugins((
|
||||
ExtractComponentPlugin::<XrProjection>::default(),
|
||||
@@ -58,10 +58,6 @@ impl Default for XrProjection {
|
||||
pub struct XrCamera(pub u32);
|
||||
|
||||
impl CameraProjection for XrProjection {
|
||||
fn get_projection_matrix(&self) -> Mat4 {
|
||||
self.projection_matrix
|
||||
}
|
||||
|
||||
fn update(&mut self, _width: f32, _height: f32) {}
|
||||
|
||||
fn far(&self) -> f32 {
|
||||
@@ -92,6 +88,10 @@ impl CameraProjection for XrProjection {
|
||||
|
||||
view_space_corners
|
||||
}
|
||||
|
||||
fn get_clip_from_view(&self) -> Mat4 {
|
||||
self.projection_matrix
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Bundle)]
|
||||
|
||||
@@ -128,7 +128,7 @@ impl Plugin for XrSessionPlugin {
|
||||
.in_set(XrHandleEvents),
|
||||
);
|
||||
|
||||
app.world
|
||||
app.world_mut()
|
||||
.resource_mut::<MainScheduleOrder>()
|
||||
.labels
|
||||
.insert(0, XrFirst.intern());
|
||||
@@ -139,7 +139,7 @@ impl Plugin for XrSessionPlugin {
|
||||
}
|
||||
|
||||
fn finish(&self, app: &mut App) {
|
||||
if app.get_sub_app(RenderApp).is_err() {
|
||||
if app.get_sub_app(RenderApp).is_none() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@ edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
bevy.workspace = true
|
||||
bevy_mod_xr.path = "../bevy_xr"
|
||||
bevy_mod_openxr.path = "../bevy_openxr"
|
||||
bevy_mod_xr = { path = "../bevy_xr", version = "0.1.0-rc1" }
|
||||
bevy_mod_openxr = { path = "../bevy_openxr", version = "0.1.0-rc1" }
|
||||
|
||||
[target.'cfg(not(target_family = "wasm"))'.dependencies]
|
||||
openxr = "0.18.0"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use bevy::color::palettes::css;
|
||||
use bevy::{prelude::*, transform::TransformSystem};
|
||||
use bevy_mod_xr::hands::{HandBone, HandBoneRadius};
|
||||
pub struct HandGizmosPlugin;
|
||||
@@ -19,16 +20,16 @@ fn draw_hand_gizmos(
|
||||
}
|
||||
}
|
||||
|
||||
fn gizmo_color(bone: &HandBone) -> Color {
|
||||
fn gizmo_color(bone: &HandBone) -> Srgba {
|
||||
match bone {
|
||||
HandBone::Palm => Color::WHITE,
|
||||
HandBone::Wrist => Color::GRAY,
|
||||
b if b.is_thumb() => Color::RED,
|
||||
b if b.is_index() => Color::ORANGE,
|
||||
b if b.is_middle() => Color::YELLOW,
|
||||
b if b.is_ring() => Color::GREEN,
|
||||
b if b.is_little() => Color::BLUE,
|
||||
HandBone::Palm => css::WHITE,
|
||||
HandBone::Wrist => css::GRAY,
|
||||
b if b.is_thumb() => css::RED,
|
||||
b if b.is_index() => css::ORANGE,
|
||||
b if b.is_middle() => css::YELLOW,
|
||||
b if b.is_ring() => css::GREEN,
|
||||
b if b.is_little() => css::BLUE,
|
||||
// should be impossible to hit
|
||||
_ => Color::rgb(1.0, 0.0, 1.0),
|
||||
_ => Srgba::rgb(1.0, 0.0, 1.0),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user