pub struct Vector3 {
pub x: f64,
pub y: f64,
pub z: f64,
}Expand description
Port of three.js’ Vector3: an ordered triplet (x, y, z), used for
points, directions and anything else three.js models as three numbers.
Fields§
§x: f64The x component.
y: f64The y component.
z: f64The z component.
Implementations§
Source§impl Vector3
impl Vector3
Sourcepub fn set_scalar(&mut self, scalar: f64) -> &mut Self
pub fn set_scalar(&mut self, scalar: f64) -> &mut Self
Vector3.setScalar().
Sourcepub fn set_component(&mut self, index: usize, value: f64) -> &mut Self
pub fn set_component(&mut self, index: usize, value: f64) -> &mut Self
Vector3.setComponent(); panics where three.js throws.
Sourcepub fn get_component(&self, index: usize) -> f64
pub fn get_component(&self, index: usize) -> f64
Vector3.getComponent().
Sourcepub fn add_scalar(&mut self, s: f64) -> &mut Self
pub fn add_scalar(&mut self, s: f64) -> &mut Self
Vector3.addScalar().
Sourcepub fn add_vectors(&mut self, a: &Self, b: &Self) -> &mut Self
pub fn add_vectors(&mut self, a: &Self, b: &Self) -> &mut Self
Vector3.addVectors().
Sourcepub fn add_scaled_vector(&mut self, v: &Self, s: f64) -> &mut Self
pub fn add_scaled_vector(&mut self, v: &Self, s: f64) -> &mut Self
Vector3.addScaledVector().
Sourcepub fn sub_scalar(&mut self, s: f64) -> &mut Self
pub fn sub_scalar(&mut self, s: f64) -> &mut Self
Vector3.subScalar().
Sourcepub fn sub_vectors(&mut self, a: &Self, b: &Self) -> &mut Self
pub fn sub_vectors(&mut self, a: &Self, b: &Self) -> &mut Self
Vector3.subVectors().
Sourcepub fn multiply_scalar(&mut self, s: f64) -> &mut Self
pub fn multiply_scalar(&mut self, s: f64) -> &mut Self
Vector3.multiplyScalar().
Sourcepub fn multiply_vectors(&mut self, a: &Self, b: &Self) -> &mut Self
pub fn multiply_vectors(&mut self, a: &Self, b: &Self) -> &mut Self
Vector3.multiplyVectors().
Sourcepub fn apply_euler(&mut self, euler: &Euler) -> &mut Self
pub fn apply_euler(&mut self, euler: &Euler) -> &mut Self
Vector3.applyEuler().
Sourcepub fn apply_axis_angle(&mut self, axis: &Self, angle: f64) -> &mut Self
pub fn apply_axis_angle(&mut self, axis: &Self, angle: f64) -> &mut Self
Vector3.applyAxisAngle().
Sourcepub fn apply_matrix3(&mut self, m: &Matrix3) -> &mut Self
pub fn apply_matrix3(&mut self, m: &Matrix3) -> &mut Self
Vector3.applyMatrix3().
Sourcepub fn apply_normal_matrix(&mut self, m: &Matrix3) -> &mut Self
pub fn apply_normal_matrix(&mut self, m: &Matrix3) -> &mut Self
Vector3.applyNormalMatrix().
Sourcepub fn apply_matrix4(&mut self, m: &Matrix4) -> &mut Self
pub fn apply_matrix4(&mut self, m: &Matrix4) -> &mut Self
Vector3.applyMatrix4().
Sourcepub fn apply_quaternion(&mut self, q: &Quaternion) -> &mut Self
pub fn apply_quaternion(&mut self, q: &Quaternion) -> &mut Self
Vector3.applyQuaternion().
Sourcepub fn project(&mut self, camera: &impl RenderCamera) -> &mut Self
pub fn project(&mut self, camera: &impl RenderCamera) -> &mut Self
Vector3.project(): world space to normalised device coordinates.
Sourcepub fn unproject(&mut self, camera: &impl RenderCamera) -> &mut Self
pub fn unproject(&mut self, camera: &impl RenderCamera) -> &mut Self
Vector3.unproject(): normalised device coordinates back to world space.
Sourcepub fn transform_direction(&mut self, m: &Matrix4) -> &mut Self
pub fn transform_direction(&mut self, m: &Matrix4) -> &mut Self
Vector3.transformDirection().
Sourcepub fn divide_scalar(&mut self, s: f64) -> &mut Self
pub fn divide_scalar(&mut self, s: f64) -> &mut Self
Vector3.divideScalar().
Sourcepub fn clamp_scalar(&mut self, min_val: f64, max_val: f64) -> &mut Self
pub fn clamp_scalar(&mut self, min_val: f64, max_val: f64) -> &mut Self
Vector3.clampScalar().
Sourcepub fn clamp_length(&mut self, min: f64, max: f64) -> &mut Self
pub fn clamp_length(&mut self, min: f64, max: f64) -> &mut Self
Vector3.clampLength().
Sourcepub fn round(&mut self) -> &mut Self
pub fn round(&mut self) -> &mut Self
Vector3.round() — Math.round, which rounds half up (toward
+Infinity), not half away from zero the way Rust’s f64::round does.
Sourcepub fn round_to_zero(&mut self) -> &mut Self
pub fn round_to_zero(&mut self) -> &mut Self
Vector3.roundToZero() — Math.trunc.
Sourcepub fn manhattan_length(&self) -> f64
pub fn manhattan_length(&self) -> f64
Vector3.manhattanLength().
Sourcepub fn normalize(&mut self) -> &mut Self
pub fn normalize(&mut self) -> &mut Self
Vector3.normalize(): divides by the length, or by 1 when the length is
0. See Vector3::normalized for the form that returns the result
instead.
Sourcepub fn normalized(self) -> Self
pub fn normalized(self) -> Self
self scaled to unit length, as a value, for expressions.
Vector3::normalize is the same scaling written in place.
Sourcepub fn set_length(&mut self, length: f64) -> &mut Self
pub fn set_length(&mut self, length: f64) -> &mut Self
Vector3.setLength().
Sourcepub fn lerp_vectors(&mut self, v1: &Self, v2: &Self, alpha: f64) -> &mut Self
pub fn lerp_vectors(&mut self, v1: &Self, v2: &Self, alpha: f64) -> &mut Self
Vector3.lerpVectors().
Sourcepub fn cross(&mut self, v: &Self) -> &mut Self
pub fn cross(&mut self, v: &Self) -> &mut Self
Vector3.cross(), in place. See Vector3::crossed for the form that
returns the result instead.
Sourcepub fn crossed(&self, v: &Self) -> Self
pub fn crossed(&self, v: &Self) -> Self
self × v as a value, for expressions. Vector3::cross is the same
product written in place.
Sourcepub fn cross_vectors(&mut self, a: &Self, b: &Self) -> &mut Self
pub fn cross_vectors(&mut self, a: &Self, b: &Self) -> &mut Self
Vector3.crossVectors().
Sourcepub fn project_on_vector(&mut self, v: &Self) -> &mut Self
pub fn project_on_vector(&mut self, v: &Self) -> &mut Self
Vector3.projectOnVector().
Sourcepub fn project_on_plane(&mut self, plane_normal: &Self) -> &mut Self
pub fn project_on_plane(&mut self, plane_normal: &Self) -> &mut Self
Vector3.projectOnPlane().
Sourcepub fn distance_to(&self, v: &Self) -> f64
pub fn distance_to(&self, v: &Self) -> f64
Vector3.distanceTo().
Sourcepub fn distance_to_squared(&self, v: &Self) -> f64
pub fn distance_to_squared(&self, v: &Self) -> f64
Vector3.distanceToSquared().
Sourcepub fn manhattan_distance_to(&self, v: &Self) -> f64
pub fn manhattan_distance_to(&self, v: &Self) -> f64
Vector3.manhattanDistanceTo().
Sourcepub fn set_from_spherical_coords(
&mut self,
radius: f64,
phi: f64,
theta: f64,
) -> &mut Self
pub fn set_from_spherical_coords( &mut self, radius: f64, phi: f64, theta: f64, ) -> &mut Self
Vector3.setFromSphericalCoords().
Sourcepub fn set_from_cylindrical_coords(
&mut self,
radius: f64,
theta: f64,
y: f64,
) -> &mut Self
pub fn set_from_cylindrical_coords( &mut self, radius: f64, theta: f64, y: f64, ) -> &mut Self
Vector3.setFromCylindricalCoords().
Sourcepub fn set_from_matrix_position(&mut self, m: &Matrix4) -> &mut Self
pub fn set_from_matrix_position(&mut self, m: &Matrix4) -> &mut Self
Vector3.setFromMatrixPosition().
Sourcepub fn set_from_matrix_scale(&mut self, m: &Matrix4) -> &mut Self
pub fn set_from_matrix_scale(&mut self, m: &Matrix4) -> &mut Self
Vector3.setFromMatrixScale().
Sourcepub fn set_from_matrix_column(&mut self, m: &Matrix4, index: usize) -> &mut Self
pub fn set_from_matrix_column(&mut self, m: &Matrix4, index: usize) -> &mut Self
Vector3.setFromMatrixColumn().
Sourcepub fn set_from_matrix3_column(
&mut self,
m: &Matrix3,
index: usize,
) -> &mut Self
pub fn set_from_matrix3_column( &mut self, m: &Matrix3, index: usize, ) -> &mut Self
Vector3.setFromMatrix3Column().
Sourcepub fn set_from_euler(&mut self, e: &Euler) -> &mut Self
pub fn set_from_euler(&mut self, e: &Euler) -> &mut Self
Vector3.setFromEuler().
Sourcepub fn set_from_color(&mut self, c: &Color) -> &mut Self
pub fn set_from_color(&mut self, c: &Color) -> &mut Self
Vector3.setFromColor().
Sourcepub fn from_array(&mut self, array: &[f64], offset: usize) -> &mut Self
pub fn from_array(&mut self, array: &[f64], offset: usize) -> &mut Self
Vector3.fromArray().
Trait Implementations§
Source§impl BezierVector for Vector3
impl BezierVector for Vector3
Source§const QUADRATIC_TYPE_NAME: &'static str = "QuadraticBezierCurve3"
const QUADRATIC_TYPE_NAME: &'static str = "QuadraticBezierCurve3"
'QuadraticBezierCurve' / 'QuadraticBezierCurve3'.Source§const CUBIC_TYPE_NAME: &'static str = "CubicBezierCurve3"
const CUBIC_TYPE_NAME: &'static str = "CubicBezierCurve3"
'CubicBezierCurve' / 'CubicBezierCurve3'.impl Copy for Vector3
Source§impl CurveVector for Vector3
impl CurveVector for Vector3
Source§fn distance_to(&self, v: &Self) -> f64
fn distance_to(&self, v: &Self) -> f64
v.distanceTo( w ).Source§fn tangent(pt1: &Self, pt2: &Self) -> Self
fn tangent(pt1: &Self, pt2: &Self) -> Self
new VectorN().copy( pt2 ).sub( pt1 ).normalize() — Curve.getTangent’s
body.Source§fn to_vector3(&self) -> Vector3
fn to_vector3(&self) -> Vector3
Vector3, z = 0 for a Vector2. Only
Curve::compute_frenet_frames uses it; three.js copies a Vector2
tangent into a Vector3 there, which leaves z undefined (NaN
downstream), so frames of a 2D curve are meaningless in three.js and
merely planar here.