Skip to content

Vector2

new Vector2(x?, y?)

THREE equivalent: THREE.Vector2

Two-component vector used for UV coordinates, 2D positions, and curve points.

Differs from THREE.js

mulScalar instead of multiplyScalar.

Name Type Description
x number X component.
y number Y component.
length number Euclidean length (read-only).
lengthSq number Squared length (read-only).
Method Description
set(x: number, y: number): this Sets both components.
add(v: Vector2): this Adds another vector in place.
sub(v: Vector2): this Subtracts another vector in place.
mulScalar(s: number): this Multiplies both components by a scalar.
normalize(): this Scales the vector to unit length.
dot(v: Vector2): number Returns the dot product with v.
cross(v: Vector2): number Returns the 2D cross product (scalar): xv.y - yv.x.
distanceTo(v: Vector2): number Returns the Euclidean distance to v.
min(v: Vector2): this Component-wise minimum.
max(v: Vector2): this Component-wise maximum.
lerp(v: Vector2, alpha: number): this Linear interpolation toward v by alpha.
clone(): Vector2 Returns a new Vector2 with the same components.
copy(v: Vector2): this Copies components from another vector.