pub struct Lines;
Expand description
A line drawing class! This is an easy way to visualize lines or relationships between objects. The current implementation uses a quad strip that always faces the user, via vertex shader manipulation. https://stereokit.net/Pages/StereoKit/Lines.html
§Examples
use stereokit_rust::{maths::{Vec3, Pose, Ray}, system::{Lines, LinePoint},
util::{named_colors}};
let ray = Ray::new([-0.3, -0.8, 0.2], [1.0, 0.0, 0.0]);
let axis_pose = Pose::new([0.0, -0.35, 0.0], None);
filename_scr = "screenshots/lines.jpeg";
test_screenshot!( // !!!! Get a proper main loop !!!!
Lines::add(token, [0.7, 0.7, 0.2], [ 0.7,-0.7, 0.2], named_colors::LIME, None, 0.06);
Lines::add(token, [0.7, 0.7, 0.2], [-0.7, 0.7, 0.2], named_colors::RED, None, 0.03);
Lines::add_list(token, &[
LinePoint {pt: [-0.7,-0.7, 0.2].into(), thickness: 0.08, color: named_colors::FUCHSIA},
LinePoint::new([-0.5,-0.1, 0.2], 0.08, named_colors::BLACK),
LinePoint::new([-0.7, 0.7, 0.2], 0.01, named_colors::YELLOW),
]);
Lines::add_ray(token, ray, 0.6, named_colors::RED, None, 0.08 );
Lines::add_axis(token, axis_pose, Some(0.7), Some(0.04));
);

Implementations§
Source§impl Lines
impl Lines
Sourcepub fn add<V: Into<Vec3>>(
_token: &MainThreadToken,
start: V,
end: V,
color_start: Color32,
color_end: Option<Color32>,
thickness: f32,
)
pub fn add<V: Into<Vec3>>( _token: &MainThreadToken, start: V, end: V, color_start: Color32, color_end: Option<Color32>, thickness: f32, )
Adds a line to the environment for the current frame. https://stereokit.net/Pages/StereoKit/Lines/Add.html
start
- The start of the line.end
- The end of the line.color_start
- Color for the start of the line, this is embedded in the vertex color of the line.color_end
- Color for the end of the line, this is embedded in the vertex color of the line. If None, uses color_start.thickness
- The thickness of the line.
see also line_add
§Examples
use stereokit_rust::{maths::{Vec3, Pose, Ray}, system::{Lines, LinePoint},
util::{named_colors}};
test_steps!( // !!!! Get a proper main loop !!!!
Lines::add(token, [0.7, 0.7, 0.2], [ 0.7,-0.7, 0.2], named_colors::LIME, None, 0.06);
Lines::add(token, [0.7, 0.7, 0.2], [-0.7, 0.7, 0.2], named_colors::RED, None, 0.03);
);
Sourcepub fn add_ray<R: Into<Ray>>(
_token: &MainThreadToken,
ray: R,
length: f32,
color_start: Color32,
color_end: Option<Color32>,
thickness: f32,
)
pub fn add_ray<R: Into<Ray>>( _token: &MainThreadToken, ray: R, length: f32, color_start: Color32, color_end: Option<Color32>, thickness: f32, )
Adds a line based on a ray to the environment for the current frame. https://stereokit.net/Pages/StereoKit/Lines/Add.html
ray
- The ray we want to visualize!length
- How long should the ray be? Actual length will be ray.direction.Magnitude * length.color_start
- Color for the start of the line, this is embedded in the vertex color of the line.color_end
- Color for the end of the line, this is embedded in the vertex color of the line. If None, uses color_start.thickness
- The thickness of the line.
see also line_add
§Examples
use stereokit_rust::{maths::{Vec3, Ray}, system::{Lines, LinePoint},
util::{named_colors}};
// axis at the origins:
let ray1 = Ray::new(Vec3::ZERO, Vec3::X);
let ray2 = Ray::new(Vec3::ZERO, Vec3::Y);
let ray3 = Ray::new(Vec3::ZERO, Vec3::Z);
test_steps!( // !!!! Get a proper main loop !!!!
Lines::add_ray(token, ray1, 1.0, named_colors::WHITE, Some(named_colors::RED), 0.03 );
Lines::add_ray(token, ray2, 1.0, named_colors::WHITE, Some(named_colors::GREEN), 0.03 );
Lines::add_ray(token, ray2, 1.0, named_colors::WHITE, Some(named_colors::BLUE), 0.03 );
);
Sourcepub fn add_list(_token: &MainThreadToken, points: &[LinePoint])
pub fn add_list(_token: &MainThreadToken, points: &[LinePoint])
Adds a line from a list of line points to the environment. This does not close the path, so if you want it closed, you’ll have to add an extra point or two at the end yourself! https://stereokit.net/Pages/StereoKit/Lines/Add.html
points
- An array of LinePoint.
see also line_add
§Examples
use stereokit_rust::{maths::{Vec3, Pose, Ray}, system::{Lines, LinePoint},
util::{named_colors}};
test_steps!( // !!!! Get a proper main loop !!!!
Lines::add_list(token, &[
LinePoint {pt: [-0.7,-0.7, 0.2].into(), thickness: 0.08, color: named_colors::FUCHSIA},
LinePoint::new([-0.5,-0.1, 0.2], 0.08, named_colors::BLACK),
LinePoint::new([-0.7, 0.7, 0.2], 0.01, named_colors::YELLOW),
]);
);
Sourcepub fn add_axis<P: Into<Pose>>(
token: &MainThreadToken,
at_pose: P,
size: Option<f32>,
thickness: Option<f32>,
)
pub fn add_axis<P: Into<Pose>>( token: &MainThreadToken, at_pose: P, size: Option<f32>, thickness: Option<f32>, )
Displays an RGB/XYZ axis widget at the pose! Each line is extended along the positive direction of each axis, so the red line is +X, green is +Y, and blue is +Z. A white line is drawn along -Z to indicate the Forward vector of the pose (-Z is forward in StereoKit). https://stereokit.net/Pages/StereoKit/Lines/AddAxis.html
at_pose
- What position and orientation do we want this axis widget at?size
- How long should the widget lines be, in meters? If None, has value of 1 cmthickness
- How thick should the lines be, in meters? If None, will use a faster renderer with a thickness of one tenth of the size.
see also line_add
§Examples
use stereokit_rust::{maths::{Vec3, Pose, Ray}, system::{Lines, LinePoint},
util::{named_colors}};
// Axis at the origins:
let axis_pose = Pose::IDENTITY;
test_steps!( // !!!! Get a proper main loop !!!!
Lines::add_axis(token, axis_pose, Some(0.7), Some(0.02));
);
Auto Trait Implementations§
impl Freeze for Lines
impl RefUnwindSafe for Lines
impl Send for Lines
impl Sync for Lines
impl Unpin for Lines
impl UnwindSafe for Lines
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> 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.