pub struct Interactor { /* private fields */ }
Expand description
Interactors are essentially capsules that allow interaction with StereoKit’s interaction primitives used by the UI system. While StereoKit does provide a number of interactors by default, you can replace StereoKit’s defaults, add additional interactors, or generally just customize your interactions! https://stereokit.net/Pages/StereoKit/Interactor.html
see also InteractorType
InteractorEvent
InteractorActivation
DefaultInteractors
§Examples
use stereokit_rust::{system::{Interactor, InteractorType, InteractorEvent, InteractorActivation, BtnState},
maths::{Vec3, Pose}};
let interactor = Interactor::create(
InteractorType::Point,
InteractorEvent::Poke,
InteractorActivation::State,
0,
0.01,
0
);
interactor.update(
Vec3::new(0.0, 0.0, 0.0),
Vec3::new(0.0, 0.0, 0.1),
Pose::IDENTITY,
Vec3::ZERO,
Vec3::ZERO,
BtnState::Active,
BtnState::Active
);
let radius = interactor.get_radius();
let start = interactor.get_start();
let end = interactor.get_end();
let tracked = interactor.get_tracked();
let focused = interactor.get_focused();
let active = interactor.get_active();
let motion = interactor.get_motion();
interactor.destroy();
Implementations§
Source§impl Interactor
impl Interactor
Sourcepub fn create(
shape_type: InteractorType,
events: InteractorEvent,
activation_type: InteractorActivation,
input_source_id: i32,
capsule_radius: f32,
secondary_motion_dimensions: i32,
) -> Self
pub fn create( shape_type: InteractorType, events: InteractorEvent, activation_type: InteractorActivation, input_source_id: i32, capsule_radius: f32, secondary_motion_dimensions: i32, ) -> Self
Create a new custom Interactor. https://stereokit.net/Pages/StereoKit/Interactor/Create.html
shape_type
- A line, or a point? These interactors behave slightly differently with respect to distance checks and directionality. SeeInteractorType
for more details.events
- What type of interaction events should this interactor fire? Interaction elements use this bitflag as a filter to avoid interacting with certain interactors.activation_type
- How does this interactor activate elements?input_source_id
- An identifier that uniquely indicates a shared source for inputs. This will deactivate other interactors with a shared source if one is already active. For example, 3 interactors for poke, pinch, and aim on a hand would all come from a single hand, and if one is actively interacting, then the whole hand source is considered busy.capsule_radius
- The radius of the interactor’s capsule, in meters.secondary_motion_dimensions
- How many axes of secondary motion can this interactor provide? This should be 0-3.
Returns the Interactor that was just created.
see also interactor_create
Sourcepub fn update(
&self,
capsule_start: impl Into<Vec3>,
capsule_end: impl Into<Vec3>,
motion: impl Into<Pose>,
motion_anchor: impl Into<Vec3>,
secondary_motion: impl Into<Vec3>,
active: BtnState,
tracked: BtnState,
)
pub fn update( &self, capsule_start: impl Into<Vec3>, capsule_end: impl Into<Vec3>, motion: impl Into<Pose>, motion_anchor: impl Into<Vec3>, secondary_motion: impl Into<Vec3>, active: BtnState, tracked: BtnState, )
Update the interactor with data for the current frame! This should be called as soon as possible at the start of the frame before any UI is done, otherwise the UI will not properly react. https://stereokit.net/Pages/StereoKit/Interactor/Update.html
capsule_start
- World space location of the collision capsule’s start. For Line interactors, this should be the ‘origin’ of the capsule’s orientation.capsule_end
- World space location of the collision capsule’s end. For Line interactors, this should be in the direction the Start/origin is facing.motion
- This pose is the source of translation and rotation motion caused by the interactor. In most cases it will be the same as your capsuleStart with the orientation of your interactor, but in some instance may be something else!motion_anchor
- Some motion, like that of amplified motion, needs some anchor point with which to determine the amplification from. This might be a shoulder, or a head, or some other point that the interactor will push from / pull towards.secondary_motion
- This is motion that comes from somewhere other than the interactor itself! This can be something like an analog stick on a controller, or the scroll wheel of a mouse.active
- The activation state of the Interactor.tracked
- The tracking state of the Interactor.
see also interactor_update
Sourcepub fn destroy(&self)
pub fn destroy(&self)
Destroy this interactor and free its resources. https://stereokit.net/Pages/StereoKit/Interactor/Destroy.html
see also interactor_destroy
Sourcepub fn get_min_distance(&self) -> f32
pub fn get_min_distance(&self) -> f32
The distance at which a ray starts being interactive. For pointing rays, you may not want them to interact right at their start, or you may want the start to move depending on how outstretched the hand is! This allows you to change that start location without affecting the movement caused by the ray, and still capturing occlusion from blocking elements too close to the start. By default, this is a large negative value. https://stereokit.net/Pages/StereoKit/Interactor/MinDistance.html
see also interactor_get_min_distance
Interactor::min_distance
Sourcepub fn min_distance(&self, min_distance: f32)
pub fn min_distance(&self, min_distance: f32)
Set the distance at which a ray starts being interactive. https://stereokit.net/Pages/StereoKit/Interactor/MinDistance.html
see also interactor_set_min_distance
Interactor::get_min_distance
Sourcepub fn get_radius(&self) -> f32
pub fn get_radius(&self) -> f32
The world space radius of the interactor capsule, in meters. https://stereokit.net/Pages/StereoKit/Interactor/Radius.html
see also interactor_get_radius
Interactor::radius
Sourcepub fn radius(&self, radius: f32)
pub fn radius(&self, radius: f32)
Set the world space radius of the interactor capsule, in meters. https://stereokit.net/Pages/StereoKit/Interactor/Radius.html
Sourcepub fn get_start(&self) -> Vec3
pub fn get_start(&self) -> Vec3
The world space start of the interactor capsule. Some interactions can be directional, especially for Line
type interactors, so if you think of the interactor as an “oriented” capsule, this would be the origin which
points towards the capsule End
.
https://stereokit.net/Pages/StereoKit/Interactor/Start.html
Sourcepub fn get_end(&self) -> Vec3
pub fn get_end(&self) -> Vec3
The world space end of the interactor capsule. Some interactions can be directional, especially for Line
type interactors, so if you think of the interactor as an “oriented” capsule, this would be the end which the
Start
/origin points towards.
https://stereokit.net/Pages/StereoKit/Interactor/End.html
Sourcepub fn get_tracked(&self) -> BtnState
pub fn get_tracked(&self) -> BtnState
The tracking state of this interactor. https://stereokit.net/Pages/StereoKit/Interactor/Tracked.html
see also interactor_get_tracked
Interactor::get_focused
Interactor::get_active
Sourcepub fn get_focused(&self) -> IdHashT
pub fn get_focused(&self) -> IdHashT
The id of the interaction element that is currently focused, this will be IdHashT::NONE
if this interactor
has nothing focused.
https://stereokit.net/Pages/StereoKit/Interactor/Focused.html
Sourcepub fn get_active(&self) -> IdHashT
pub fn get_active(&self) -> IdHashT
The id of the interaction element that is currently active, this will be IdHashT::NONE
if this interactor
has nothing active. This will always be the same id as Focused
when not None
.
https://stereokit.net/Pages/StereoKit/Interactor/Active.html
Sourcepub fn get_motion(&self) -> Pose
pub fn get_motion(&self) -> Pose
This pose is the source of translation and rotation motion caused by the interactor. In most cases it will be the same as your Start with the orientation of your interactor, but in some instance may be something else! https://stereokit.net/Pages/StereoKit/Interactor/Motion.html
see also interactor_get_motion
Interactor::update
Sourcepub fn try_get_focus_bounds(&self) -> Option<(Pose, Bounds, Vec3)>
pub fn try_get_focus_bounds(&self) -> Option<(Pose, Bounds, Vec3)>
If this interactor has an element focused, this will output information about the location of that element, as well as the interactor’s intersection point with that element. https://stereokit.net/Pages/StereoKit/Interactor/TryGetFocusBounds.html
pose_world
- The world space Pose of the element’s hierarchy space. This is typically the Pose of the Window/Handle/Surface the element belongs to.bounds_local
- The bounds of the UI element relative to the Pose. Note that thecenter
should always be accounted for here!at_local
- The intersection point relative to the Bounds, NOT relative to the Pose!
Returns Some((pose_world, bounds_local, at_local))
if bounds data is available, None
otherwise.
see also interactor_get_focus_bounds
Interactor::get_focused
Sourcepub fn count() -> i32
pub fn count() -> i32
The number of interactors currently in the system. Can be used with get
.
https://stereokit.net/Pages/StereoKit/Interactor/Count.html
see also interactor_count
Interactor::get
Sourcepub fn get(index: i32) -> Self
pub fn get(index: i32) -> Self
Returns the Interactor
at the given index. Should be used with count
.
https://stereokit.net/Pages/StereoKit/Interactor/Get.html
index
- The index.
Returns an Interactor.
see also interactor_get
Interactor::count
Trait Implementations§
Source§impl Clone for Interactor
impl Clone for Interactor
Source§fn clone(&self) -> Interactor
fn clone(&self) -> Interactor
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for Interactor
impl Debug for Interactor
Source§impl PartialEq for Interactor
impl PartialEq for Interactor
impl Copy for Interactor
impl Eq for Interactor
impl StructuralPartialEq for Interactor
Auto Trait Implementations§
impl Freeze for Interactor
impl RefUnwindSafe for Interactor
impl Send for Interactor
impl Sync for Interactor
impl Unpin for Interactor
impl UnwindSafe for Interactor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.