Create, Compete & Win at Redbrick Connect 2024! 🎉

Vector3

A 3-dimensional vector class providing various vector operations.

Besides the information below, you can also utilize various properties and methods of THREE.Vector3.

Properties

.x

The x value of the vector. Default is 0.

.y

The y value of the vector. Default is 0.

.z

The z value of the vector. Default is 0.

Methods

.add()

origin_vector.add(add_vector: Vector3): this

Adds add_vector to origin_vector and returns the result.
This method does not modify the original vector itself but returns a new vector.

.angleTo()

origin_vector.angleTo(target_vector: Vector3): Float

Returns the angle between origin_vector and target_vector in radians.

.distanceTo()

origin_vector.distanceTo(target_vector: Vector3): Float

Calculates the distance from origin_vector to target_vector.

.clone()

origin_vector.clone(): Vector3

Returns a new Vector3 with the same x, y, and z values as origin_vector.
This method does not modify the original vector but returns a cloned vector as a new object.

.copy()

origin_vector.copy(target_vector: Vector3): this

Copies the x, y, and z properties from target_vector to origin_vector and returns origin_vector.
The values of origin_vector are replaced with those of target_vector.

.length()

target_vector.length(): Float

Calculates the Euclidean length (straight-line distance) from (0, 0, 0) to target_vector (x, y, z).

.multiplyScalar()

origin_vector.multiplyScalar(s: Float): this

Multiplies origin_vector by a scalar s.
This method does not modify the original vector itself but returns a new vector with each component multiplied by the scalar value.

.normalize()

origin_vector.normalize(): this

Normalizes the current vector to a unit vector.
Normalization means setting the length of the vector to 1 while retaining its direction.
This method modifies origin_vector and returns the normalized unit vector.

.set()

origin_vector.set(x: Float, y: Float, z: Float): this

Sets the x, y, and z components of the vector.
This method modifies origin_vector and returns the modified vector itself.