Skip to main content

Vector3

Struct Vector3 

Source
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: f64

The x component.

§y: f64

The y component.

§z: f64

The z component.

Implementations§

Source§

impl Vector3

Source

pub const ZERO: Self

(0, 0, 0).

Source

pub const fn new(x: f64, y: f64, z: f64) -> Self

new Vector3( x, y, z ).

Source

pub fn set(&mut self, x: f64, y: f64, z: f64) -> &mut Self

Vector3.set().

Source

pub fn set_scalar(&mut self, scalar: f64) -> &mut Self

Vector3.setScalar().

Source

pub fn set_x(&mut self, x: f64) -> &mut Self

Vector3.setX().

Source

pub fn set_y(&mut self, y: f64) -> &mut Self

Vector3.setY().

Source

pub fn set_z(&mut self, z: f64) -> &mut Self

Vector3.setZ().

Source

pub fn set_component(&mut self, index: usize, value: f64) -> &mut Self

Vector3.setComponent(); panics where three.js throws.

Source

pub fn get_component(&self, index: usize) -> f64

Vector3.getComponent().

Source

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

Vector3.copy().

Source

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

Vector3.add().

Source

pub fn add_scalar(&mut self, s: f64) -> &mut Self

Vector3.addScalar().

Source

pub fn add_vectors(&mut self, a: &Self, b: &Self) -> &mut Self

Vector3.addVectors().

Source

pub fn add_scaled_vector(&mut self, v: &Self, s: f64) -> &mut Self

Vector3.addScaledVector().

Source

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

Vector3.sub().

Source

pub fn sub_scalar(&mut self, s: f64) -> &mut Self

Vector3.subScalar().

Source

pub fn sub_vectors(&mut self, a: &Self, b: &Self) -> &mut Self

Vector3.subVectors().

Source

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

Vector3.multiply().

Source

pub fn multiply_scalar(&mut self, s: f64) -> &mut Self

Vector3.multiplyScalar().

Source

pub fn multiply_vectors(&mut self, a: &Self, b: &Self) -> &mut Self

Vector3.multiplyVectors().

Source

pub fn apply_euler(&mut self, euler: &Euler) -> &mut Self

Vector3.applyEuler().

Source

pub fn apply_axis_angle(&mut self, axis: &Self, angle: f64) -> &mut Self

Vector3.applyAxisAngle().

Source

pub fn apply_matrix3(&mut self, m: &Matrix3) -> &mut Self

Vector3.applyMatrix3().

Source

pub fn apply_normal_matrix(&mut self, m: &Matrix3) -> &mut Self

Vector3.applyNormalMatrix().

Source

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

Vector3.applyMatrix4().

Source

pub fn apply_quaternion(&mut self, q: &Quaternion) -> &mut Self

Vector3.applyQuaternion().

Source

pub fn project(&mut self, camera: &impl RenderCamera) -> &mut Self

Vector3.project(): world space to normalised device coordinates.

Source

pub fn unproject(&mut self, camera: &impl RenderCamera) -> &mut Self

Vector3.unproject(): normalised device coordinates back to world space.

Source

pub fn transform_direction(&mut self, m: &Matrix4) -> &mut Self

Vector3.transformDirection().

Source

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

Vector3.divide().

Source

pub fn divide_scalar(&mut self, s: f64) -> &mut Self

Vector3.divideScalar().

Source

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

Vector3.min().

Source

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

Vector3.max().

Source

pub fn clamp(&mut self, min: &Self, max: &Self) -> &mut Self

Vector3.clamp().

Source

pub fn clamp_scalar(&mut self, min_val: f64, max_val: f64) -> &mut Self

Vector3.clampScalar().

Source

pub fn clamp_length(&mut self, min: f64, max: f64) -> &mut Self

Vector3.clampLength().

Source

pub fn floor(&mut self) -> &mut Self

Vector3.floor().

Source

pub fn ceil(&mut self) -> &mut Self

Vector3.ceil().

Source

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.

Source

pub fn round_to_zero(&mut self) -> &mut Self

Vector3.roundToZero() — Math.trunc.

Source

pub fn negate(&mut self) -> &mut Self

Vector3.negate().

Source

pub fn dot(&self, v: &Self) -> f64

Vector3.dot().

Source

pub fn length_sq(&self) -> f64

Vector3.lengthSq().

Source

pub fn length(&self) -> f64

Vector3.length(): the Euclidean length of this vector.

Source

pub fn manhattan_length(&self) -> f64

Vector3.manhattanLength().

Source

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.

Source

pub fn normalized(self) -> Self

self scaled to unit length, as a value, for expressions. Vector3::normalize is the same scaling written in place.

Source

pub fn set_length(&mut self, length: f64) -> &mut Self

Vector3.setLength().

Source

pub fn lerp(&mut self, v: &Self, alpha: f64) -> &mut Self

Vector3.lerp().

Source

pub fn lerp_vectors(&mut self, v1: &Self, v2: &Self, alpha: f64) -> &mut Self

Vector3.lerpVectors().

Source

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

Vector3.cross(), in place. See Vector3::crossed for the form that returns the result instead.

Source

pub fn crossed(&self, v: &Self) -> Self

self × v as a value, for expressions. Vector3::cross is the same product written in place.

Source

pub fn cross_vectors(&mut self, a: &Self, b: &Self) -> &mut Self

Vector3.crossVectors().

Source

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

Vector3.projectOnVector().

Source

pub fn project_on_plane(&mut self, plane_normal: &Self) -> &mut Self

Vector3.projectOnPlane().

Source

pub fn reflect(&mut self, normal: &Self) -> &mut Self

Vector3.reflect().

Source

pub fn angle_to(&self, v: &Self) -> f64

Vector3.angleTo().

Source

pub fn distance_to(&self, v: &Self) -> f64

Vector3.distanceTo().

Source

pub fn distance_to_squared(&self, v: &Self) -> f64

Vector3.distanceToSquared().

Source

pub fn manhattan_distance_to(&self, v: &Self) -> f64

Vector3.manhattanDistanceTo().

Source

pub fn set_from_spherical_coords( &mut self, radius: f64, phi: f64, theta: f64, ) -> &mut Self

Vector3.setFromSphericalCoords().

Source

pub fn set_from_cylindrical_coords( &mut self, radius: f64, theta: f64, y: f64, ) -> &mut Self

Vector3.setFromCylindricalCoords().

Source

pub fn set_from_matrix_position(&mut self, m: &Matrix4) -> &mut Self

Vector3.setFromMatrixPosition().

Source

pub fn set_from_matrix_scale(&mut self, m: &Matrix4) -> &mut Self

Vector3.setFromMatrixScale().

Source

pub fn set_from_matrix_column(&mut self, m: &Matrix4, index: usize) -> &mut Self

Vector3.setFromMatrixColumn().

Source

pub fn set_from_matrix3_column( &mut self, m: &Matrix3, index: usize, ) -> &mut Self

Vector3.setFromMatrix3Column().

Source

pub fn set_from_euler(&mut self, e: &Euler) -> &mut Self

Vector3.setFromEuler().

Source

pub fn set_from_color(&mut self, c: &Color) -> &mut Self

Vector3.setFromColor().

Source

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

Vector3.equals().

Source

pub fn from_array(&mut self, array: &[f64], offset: usize) -> &mut Self

Vector3.fromArray().

Source

pub fn to_array(&self) -> [f64; 3]

Vector3.toArray().

Trait Implementations§

Source§

impl BezierVector for Vector3

Source§

const QUADRATIC_TYPE_NAME: &'static str = "QuadraticBezierCurve3"

'QuadraticBezierCurve' / 'QuadraticBezierCurve3'.
Source§

const CUBIC_TYPE_NAME: &'static str = "CubicBezierCurve3"

'CubicBezierCurve' / 'CubicBezierCurve3'.
Source§

fn map_components(points: &[&Self], f: impl Fn(&[f64]) -> f64) -> Self

point.set( f( v0.x, ... ), f( v0.y, ... )[, f( v0.z, ... )] ).
Source§

impl Clone for Vector3

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 Vector3

Source§

impl CurveVector for Vector3

Source§

fn distance_to(&self, v: &Self) -> f64

v.distanceTo( w ).
Source§

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

v.equals( w ).
Source§

fn tangent(pt1: &Self, pt2: &Self) -> Self

new VectorN().copy( pt2 ).sub( pt1 ).normalize() — Curve.getTangent’s body.
Source§

fn to_vector3(&self) -> Vector3

The point as a 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.
Source§

impl Debug for Vector3

Source§

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

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

impl Default for Vector3

Source§

fn default() -> Self

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

impl From<Vector3> for NodeRef

Source§

fn from(v: Vector3) -> Self

Converts to this type from the input type.
Source§

impl From<Vector3> for RangeValue

Source§

fn from(v: Vector3) -> Self

Converts to this type from the input type.
Source§

impl LineVector for Vector3

Source§

const TYPE_NAME: &'static str = "LineCurve3"

'LineCurve' or 'LineCurve3'.
Source§

fn lerp_line(v1: &Self, v2: &Self, t: f64) -> Self

point.copy( v2 ).sub( v1 ); point.multiplyScalar( t ).add( v1 ).
Source§

fn direction(v1: &Self, v2: &Self) -> Self

optionalTarget.subVectors( v2, v1 ).normalize().
Source§

impl PartialEq for Vector3

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 Vector3

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,