Skip to main content

Triangle

Struct Triangle 

Source
pub struct Triangle {
    pub a: Vector3,
    pub b: Vector3,
    pub c: Vector3,
}
Expand description

Port of three.js/src/math/Triangle.js’s Triangle class: a geometric triangle defined by three corner vectors.

Fields§

§a: Vector3

The first corner of the triangle.

§b: Vector3

The second corner of the triangle.

§c: Vector3

The third corner of the triangle.

Implementations§

Source§

impl Triangle

Source

pub const fn new(a: Vector3, b: Vector3, c: Vector3) -> Self

new Triangle().

Source

pub fn static_get_normal(a: &Vector3, b: &Vector3, c: &Vector3) -> Vector3

Triangle.getNormal() (static).

Source

pub fn static_get_barycoord( point: &Vector3, a: &Vector3, b: &Vector3, c: &Vector3, ) -> Option<Vector3>

Triangle.getBarycoord() (static). None where three.js returns null (collinear or singular triangle).

Source

pub fn static_contains_point( point: &Vector3, a: &Vector3, b: &Vector3, c: &Vector3, ) -> bool

Triangle.containsPoint() (static).

Source

pub fn static_get_interpolation( point: &Vector3, p1: &Vector3, p2: &Vector3, p3: &Vector3, v1: &Vector3, v2: &Vector3, v3: &Vector3, ) -> Option<Vector3>

Triangle.getInterpolation() (static). None where three.js returns null (degenerate triangle).

Source

pub fn static_get_interpolated_attribute( attr: &BufferAttribute, i1: usize, i2: usize, i3: usize, barycoord: &Vector3, ) -> Vector4

Triangle.getInterpolatedAttribute() (static): the attribute’s values at vertices i1, i2, i3, weighted by barycoord.

three.js takes a Vector2/Vector3/Vector4 target and reads as many components as the target has; the port returns a Vector4 holding the first min( itemSize, 4 ) components, the rest 0, and the caller takes the swizzle it wants (Mesh takes xy for uv and xyz for normal, which is what its new Vector2() / new Vector3() targets read).

Source

pub fn static_is_front_facing( a: &Vector3, b: &Vector3, c: &Vector3, direction: &Vector3, ) -> bool

Triangle.isFrontFacing() (static).

Source

pub fn set(&mut self, a: &Vector3, b: &Vector3, c: &Vector3) -> &mut Self

Triangle.set().

Source

pub fn set_from_points_and_indices( &mut self, points: &[Vector3], i0: usize, i1: usize, i2: usize, ) -> &mut Self

Triangle.setFromPointsAndIndices().

Source

pub fn set_from_attribute_and_indices( &mut self, attribute: &BufferAttribute, i0: usize, i1: usize, i2: usize, ) -> &mut Self

Triangle.setFromAttributeAndIndices().

Source

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

Triangle.copy().

Source

pub fn get_area(&self) -> f64

Triangle.getArea().

Source

pub fn get_midpoint(&self) -> Vector3

Triangle.getMidpoint().

Source

pub fn get_normal(&self) -> Vector3

Triangle.getNormal().

Source

pub fn get_plane(&self) -> Plane

Triangle.getPlane().

Source

pub fn get_barycoord(&self, point: &Vector3) -> Option<Vector3>

Triangle.getBarycoord().

Source

pub fn get_interpolation( &self, point: &Vector3, v1: &Vector3, v2: &Vector3, v3: &Vector3, ) -> Option<Vector3>

Triangle.getInterpolation().

Source

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

Triangle.containsPoint().

Source

pub fn is_front_facing(&self, direction: &Vector3) -> bool

Triangle.isFrontFacing().

Source

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

Triangle.intersectsBox().

Source

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

Triangle.closestPointToPoint().

Source

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

Triangle.equals().

Trait Implementations§

Source§

impl Clone for Triangle

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 Triangle

Source§

impl Debug for Triangle

Source§

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

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

impl Default for Triangle

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Triangle

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 Triangle

Auto Trait Implementations§

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,