Vector3

new Vector3(x?, y?, z?)
THREE: THREE.Vector3

Three-component vector used for positions, directions, and scales. All mutation methods return this for chaining.

Differs from THREE.js

x, y, z are private fields accessed via getters/setters. mul() is multiplyScalar with one argument when passed a scalar.

Properties

NameTypeDescription
x

number

X component.

y

number

Y component.

z

number

Z component.

length

number

Euclidean length (read-only).

lengthSq

number

Squared length (read-only, avoids sqrt).

Methods

MethodDescription
set(x: number, y: number, z: number): this

Sets all three components.

add(v: Vector3): this

Adds another vector in place.

sub(v: Vector3): this

Subtracts another vector in place.

mul(v: Vector3): this

Component-wise multiplication.

mulScalar(s: number): this

Multiplies all components by a scalar.

cross(v: Vector3): this

Sets this to the cross product of this and v.

dot(v: Vector3): number

Returns the dot product with v.

normalize(): this

Scales the vector to unit length.

distanceTo(v: Vector3): number

Returns the Euclidean distance to v.

applyMatrix4(m: Matrix4): this

Transforms this point by a 4x4 matrix (w = 1).

clone(): Vector3

Returns a new Vector3 with the same components.

copy(v: Vector3): this

Copies components from another vector.