StaticdownReturns a new Vec2 representing (0, -1)
StaticleftReturns a new Vec2 representing (-1, 0)
StaticoneReturns a new Vec2 representing (1, 1)
StaticrightReturns a new Vec2 representing (1, 0)
StaticupReturns a new Vec2 representing (0, 1)
StaticzeroReturns a new Vec2 representing (0, 0)
Create a new Vec2
Optionalx: number = 0X component
Optionaly: number = 0Y component
Adds another vector to this one (in-place)
The vector to add
The current vector (for chaining)
Adds a scaled vector to this one (in-place) without allocating temporary objects. Computes: this += v * s
The vector to scale and add
The scalar factor
The current vector (for chaining)
Copy the values of another vector into this vector
The vector to copy from
The current vector (for chaining)
Calculates the distance to another vector
The other vector
The distance
Calculates the squared distance to another vector
The other vector
The squared distance
Calculates the dot product of this vector and another
The other vector
The dot product
Checks for strict equality with another vector
The vector to compare with
True if the components are exactly equal
Calculates the length of this vector
The length
Calculates the squared length of this vector
The squared length
Linearly interpolate to a target vector (in-place)
The target vector to interpolate towards
Interpolation factor
The current vector (for chaining)
Multiplies this vector by another vector (in-place)
The vector to multiply by
The current vector (for chaining)
Normalizes this vector (in-place)
The current vector (for chaining)
Scales this vector by a scalar value (in-place)
The scalar value
The current vector (for chaining)
Set the x and y components of this vector
The new x value
The new y value
The current vector (for chaining)
Subtracts another vector from this one (in-place)
The vector to subtract
The current vector (for chaining)
Get the vector as a Float32Array or fill an existing array
Optionalout: Float32Array<ArrayBufferLike>Optional Float32Array to fill
Optionaloffset: number = 0Optional offset in the array
The filled array
Staticlerp
2D vector representation containing x and y components. Used for positional and texture coordinate calculations.