feat: basic input
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
use super::data::{PulseReceiver, PulseSender};
|
use super::data::{PulseReceiver, PulseSender};
|
||||||
use super::field::Field;
|
use super::field::Field;
|
||||||
|
use super::input::{InputHandler, InputMethod};
|
||||||
use super::item::{Item, ItemAcceptor, ItemUI};
|
use super::item::{Item, ItemAcceptor, ItemUI};
|
||||||
use super::spatial::Spatial;
|
use super::spatial::Spatial;
|
||||||
use crate::core::client::Client;
|
use crate::core::client::Client;
|
||||||
@@ -38,6 +39,8 @@ pub struct Node {
|
|||||||
pub item: OnceCell<Arc<Item>>,
|
pub item: OnceCell<Arc<Item>>,
|
||||||
pub item_acceptor: OnceCell<Arc<ItemAcceptor>>,
|
pub item_acceptor: OnceCell<Arc<ItemAcceptor>>,
|
||||||
pub item_ui: OnceCell<Arc<ItemUI>>,
|
pub item_ui: OnceCell<Arc<ItemUI>>,
|
||||||
|
pub input_method: OnceCell<Arc<InputMethod>>,
|
||||||
|
pub input_handler: OnceCell<Arc<InputHandler>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Node {
|
impl Node {
|
||||||
@@ -77,6 +80,8 @@ impl Node {
|
|||||||
item: OnceCell::new(),
|
item: OnceCell::new(),
|
||||||
item_acceptor: OnceCell::new(),
|
item_acceptor: OnceCell::new(),
|
||||||
item_ui: OnceCell::new(),
|
item_ui: OnceCell::new(),
|
||||||
|
input_method: OnceCell::new(),
|
||||||
|
input_handler: OnceCell::new(),
|
||||||
};
|
};
|
||||||
node.add_local_signal("destroy", Node::destroy_flex);
|
node.add_local_signal("destroy", Node::destroy_flex);
|
||||||
node
|
node
|
||||||
|
|||||||
47
src/nodes/input.rs
Normal file
47
src/nodes/input.rs
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
use super::core::{Alias, Node};
|
||||||
|
use super::field::Field;
|
||||||
|
use super::spatial::{get_spatial_parent_flex, get_transform_pose_flex, Spatial};
|
||||||
|
use crate::core::client::Client;
|
||||||
|
use crate::core::nodelist::LifeLinkedNodeList;
|
||||||
|
use crate::core::registry::Registry;
|
||||||
|
use anyhow::{anyhow, ensure, Result};
|
||||||
|
use glam::{vec3a, Mat4};
|
||||||
|
use lazy_static::lazy_static;
|
||||||
|
use libstardustxr::flex::flexbuffer_from_vector_arguments;
|
||||||
|
use libstardustxr::{flex_to_quat, flex_to_vec3};
|
||||||
|
use parking_lot::Mutex;
|
||||||
|
use std::ops::Deref;
|
||||||
|
use std::sync::{Arc, Weak};
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
static ref INPUT_METHOD_REGISTRY: Registry<InputMethod> = Default::default();
|
||||||
|
static ref INPUT_HANDLER_REGISTRY: Registry<InputHandler> = Default::default();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct InputMethod {
|
||||||
|
spatial: Weak<Spatial>,
|
||||||
|
specialization: InputType,
|
||||||
|
}
|
||||||
|
trait InputMethodSpecialization {
|
||||||
|
fn distance(&self, space: &Spatial, field: &Field) -> f32;
|
||||||
|
}
|
||||||
|
enum InputType {}
|
||||||
|
impl Deref for InputType {
|
||||||
|
type Target = dyn InputMethodSpecialization;
|
||||||
|
fn deref(&self) -> &Self::Target {
|
||||||
|
todo!()
|
||||||
|
// match self {
|
||||||
|
// Field::Box(field) => field,
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub struct InputHandler {
|
||||||
|
spatial: Weak<Spatial>,
|
||||||
|
field: Weak<Field>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn create_interface(client: &Arc<Client>) {
|
||||||
|
let node = Node::create(client, "", "data", false);
|
||||||
|
// node.add_local_signal("createInputHandler", create_input_handler_flex);
|
||||||
|
node.add_to_scenegraph();
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
pub mod item;
|
|
||||||
pub mod root;
|
|
||||||
pub mod core;
|
pub mod core;
|
||||||
pub mod data;
|
pub mod data;
|
||||||
pub mod field;
|
pub mod field;
|
||||||
|
pub mod input;
|
||||||
|
pub mod item;
|
||||||
|
pub mod root;
|
||||||
pub mod spatial;
|
pub mod spatial;
|
||||||
|
|||||||
Reference in New Issue
Block a user