Skip to main content

Ray

Struct Ray 

Source
pub struct Ray {
    pub origin: Vector3,
    pub direction: Vector3,
}
Expand description

Port of three.js’ Ray: an infinite ray from an origin along a direction, used by Raycaster for picking.

Fields§

§origin: Vector3

The origin of the ray.

§direction: Vector3

The (normalized) direction of the ray.

Implementations§

Source§

impl Ray

Source

pub const fn new(origin: Vector3, direction: Vector3) -> Self

new Ray().

Source

pub fn set(&mut self, origin: &Vector3, direction: &Vector3) -> &mut Self

Ray.set().

Source

pub fn copy(&mut self, ray: &Self) -> &mut Self

Ray.copy().

Source

pub fn at(&self, t: f64) -> Vector3

Ray.at().

Source

pub fn look_at(&mut self, v: &Vector3) -> &mut Self

Ray.lookAt().

Source

pub fn recast(&mut self, t: f64) -> &mut Self

Ray.recast().

Source

pub fn closest_point_to_point(&self, point: &Vector3) -> Vector3

Ray.closestPointToPoint().

Source

pub fn distance_to_point(&self, point: &Vector3) -> f64

Ray.distanceToPoint().

Source

pub fn distance_sq_to_point(&self, point: &Vector3) -> f64

Ray.distanceSqToPoint().

Source

pub fn distance_sq_to_segment( &self, v0: &Vector3, v1: &Vector3, optional_point_on_ray: Option<&mut Vector3>, optional_point_on_segment: Option<&mut Vector3>, ) -> f64

Ray.distanceSqToSegment().

optional_point_on_ray / optional_point_on_segment are three.js’ out-params: when given they receive the closest point on the ray and on the segment respectively.

Source

pub fn intersect_sphere(&self, sphere: &Sphere) -> Option<Vector3>

Ray.intersectSphere().

Source

pub fn intersects_sphere(&self, sphere: &Sphere) -> bool

Ray.intersectsSphere().

Source

pub fn distance_to_plane(&self, plane: &Plane) -> Option<f64>

Ray.distanceToPlane().

Source

pub fn intersect_plane(&self, plane: &Plane) -> Option<Vector3>

Ray.intersectPlane().

Source

pub fn intersects_plane(&self, plane: &Plane) -> bool

Ray.intersectsPlane().

Source

pub fn intersect_box(&self, box3: &Box3) -> Option<Vector3>

Ray.intersectBox().

Source

pub fn intersects_box(&self, box3: &Box3) -> bool

Ray.intersectsBox().

Source

pub fn intersect_triangle( &self, a: &Vector3, b: &Vector3, c: &Vector3, backface_culling: bool, ) -> Option<Vector3>

Ray.intersectTriangle().

Source

pub fn apply_matrix4(&mut self, matrix4: &Matrix4) -> &mut Self

Ray.applyMatrix4().

Source

pub fn equals(&self, ray: &Self) -> bool

Ray.equals().

Trait Implementations§

Source§

impl Clone for Ray

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Ray

Source§

impl Debug for Ray

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Ray

Source§

fn default() -> Self

new Ray() — origin (0,0,0), direction (0,0,-1).

Source§

impl PartialEq for Ray

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Ray

Auto Trait Implementations§

§

impl Freeze for Ray

§

impl RefUnwindSafe for Ray

§

impl Send for Ray

§

impl Sync for Ray

§

impl Unpin for Ray

§

impl UnsafeUnpin for Ray

§

impl UnwindSafe for Ray

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,