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: Vector3The first corner of the triangle.
b: Vector3The second corner of the triangle.
c: Vector3The third corner of the triangle.
Implementations§
Source§impl Triangle
impl Triangle
Sourcepub fn static_get_normal(a: &Vector3, b: &Vector3, c: &Vector3) -> Vector3
pub fn static_get_normal(a: &Vector3, b: &Vector3, c: &Vector3) -> Vector3
Triangle.getNormal() (static).
Sourcepub fn static_get_barycoord(
point: &Vector3,
a: &Vector3,
b: &Vector3,
c: &Vector3,
) -> Option<Vector3>
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).
Sourcepub fn static_contains_point(
point: &Vector3,
a: &Vector3,
b: &Vector3,
c: &Vector3,
) -> bool
pub fn static_contains_point( point: &Vector3, a: &Vector3, b: &Vector3, c: &Vector3, ) -> bool
Triangle.containsPoint() (static).
Sourcepub fn static_get_interpolation(
point: &Vector3,
p1: &Vector3,
p2: &Vector3,
p3: &Vector3,
v1: &Vector3,
v2: &Vector3,
v3: &Vector3,
) -> Option<Vector3>
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).
Sourcepub fn static_get_interpolated_attribute(
attr: &BufferAttribute,
i1: usize,
i2: usize,
i3: usize,
barycoord: &Vector3,
) -> Vector4
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).
Sourcepub fn static_is_front_facing(
a: &Vector3,
b: &Vector3,
c: &Vector3,
direction: &Vector3,
) -> bool
pub fn static_is_front_facing( a: &Vector3, b: &Vector3, c: &Vector3, direction: &Vector3, ) -> bool
Triangle.isFrontFacing() (static).
Sourcepub fn set_from_points_and_indices(
&mut self,
points: &[Vector3],
i0: usize,
i1: usize,
i2: usize,
) -> &mut Self
pub fn set_from_points_and_indices( &mut self, points: &[Vector3], i0: usize, i1: usize, i2: usize, ) -> &mut Self
Triangle.setFromPointsAndIndices().
Sourcepub fn set_from_attribute_and_indices(
&mut self,
attribute: &BufferAttribute,
i0: usize,
i1: usize,
i2: usize,
) -> &mut Self
pub fn set_from_attribute_and_indices( &mut self, attribute: &BufferAttribute, i0: usize, i1: usize, i2: usize, ) -> &mut Self
Triangle.setFromAttributeAndIndices().
Sourcepub fn get_midpoint(&self) -> Vector3
pub fn get_midpoint(&self) -> Vector3
Triangle.getMidpoint().
Sourcepub fn get_normal(&self) -> Vector3
pub fn get_normal(&self) -> Vector3
Triangle.getNormal().
Sourcepub fn get_barycoord(&self, point: &Vector3) -> Option<Vector3>
pub fn get_barycoord(&self, point: &Vector3) -> Option<Vector3>
Triangle.getBarycoord().
Sourcepub fn get_interpolation(
&self,
point: &Vector3,
v1: &Vector3,
v2: &Vector3,
v3: &Vector3,
) -> Option<Vector3>
pub fn get_interpolation( &self, point: &Vector3, v1: &Vector3, v2: &Vector3, v3: &Vector3, ) -> Option<Vector3>
Triangle.getInterpolation().
Sourcepub fn contains_point(&self, point: &Vector3) -> bool
pub fn contains_point(&self, point: &Vector3) -> bool
Triangle.containsPoint().
Sourcepub fn is_front_facing(&self, direction: &Vector3) -> bool
pub fn is_front_facing(&self, direction: &Vector3) -> bool
Triangle.isFrontFacing().
Sourcepub fn intersects_box(&self, box3: &Box3) -> bool
pub fn intersects_box(&self, box3: &Box3) -> bool
Triangle.intersectsBox().
Sourcepub fn closest_point_to_point(&self, p: &Vector3) -> Vector3
pub fn closest_point_to_point(&self, p: &Vector3) -> Vector3
Triangle.closestPointToPoint().