Vector2
Defined in: client/api.d.ts:3678
Mutable two-dimensional vector.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Vector2(
x,y):Vector2
Defined in: client/api.d.ts:3684
Creates a vector from two numeric components.
Parameters
Section titled “Parameters”number
Initial X component.
number
Initial Y component.
Returns
Section titled “Returns”Vector2
Methods
Section titled “Methods”add(
other):this
Defined in: client/api.d.ts:3711
Adds another vector to this vector in place.
Parameters
Section titled “Parameters”Vector2
Vector to add component-wise.
Returns
Section titled “Returns”this
This mutated vector for chaining.
clone()
Section titled “clone()”clone():
Vector2
Defined in: client/api.d.ts:3774
Creates an independent copy of this vector.
Returns
Section titled “Returns”Vector2
New vector with the same components.
distance()
Section titled “distance()”distance(
other):number
Defined in: client/api.d.ts:3768
Computes Euclidean distance to another vector.
Parameters
Section titled “Parameters”Vector2
Vector to measure from this vector.
Returns
Section titled “Returns”number
Distance between the two vectors.
div(
scalar):this
Defined in: client/api.d.ts:3732
Divides this vector by a scalar in place.
Parameters
Section titled “Parameters”scalar
Section titled “scalar”number
Divisor applied to both components; must be non-zero.
Returns
Section titled “Returns”this
This mutated vector for chaining.
dot(
other):number
Defined in: client/api.d.ts:3739
Computes the dot product without changing either vector.
Parameters
Section titled “Parameters”Vector2
Vector used for the dot product.
Returns
Section titled “Returns”number
Scalar dot product.
lerp()
Section titled “lerp()”lerp(
target,t):this
Defined in: client/api.d.ts:3753
Linearly interpolates this vector toward a target in place.
Parameters
Section titled “Parameters”target
Section titled “target”Vector2
Destination vector.
number
Interpolation factor; 0 keeps the current value and 1 reaches target.
Returns
Section titled “Returns”this
This mutated vector for chaining.
mul(
scalar):this
Defined in: client/api.d.ts:3725
Multiplies this vector by a scalar in place.
Parameters
Section titled “Parameters”scalar
Section titled “scalar”number
Multiplier applied to both components.
Returns
Section titled “Returns”this
This mutated vector for chaining.
normalize()
Section titled “normalize()”normalize():
this
Defined in: client/api.d.ts:3745
Normalizes this vector in place; a zero vector remains unchanged.
Returns
Section titled “Returns”this
This mutated vector for chaining.
set(
x,y):this
Defined in: client/api.d.ts:3761
Replaces both components in place.
Parameters
Section titled “Parameters”number
Replacement X component.
number
Replacement Y component.
Returns
Section titled “Returns”this
This mutated vector for chaining.
sub(
other):this
Defined in: client/api.d.ts:3718
Subtracts another vector from this vector in place.
Parameters
Section titled “Parameters”Vector2
Vector to subtract component-wise.
Returns
Section titled “Returns”this
This mutated vector for chaining.
toJSON()
Section titled “toJSON()”toJSON():
object
Defined in: client/api.d.ts:3786
Converts this vector to a plain object for JSON.stringify.
Returns
Section titled “Returns”object
Object containing the current components.
x:
number
y:
number
toString()
Section titled “toString()”toString():
string
Defined in: client/api.d.ts:3780
Formats this vector for logging and debugging.
Returns
Section titled “Returns”string
Text in Vector2(x, y) form.
staticone():Vector2
Defined in: client/api.d.ts:3798
Creates a vector whose components are one.
Returns
Section titled “Returns”Vector2
New Vector2(1, 1).
zero()
Section titled “zero()”
staticzero():Vector2
Defined in: client/api.d.ts:3792
Creates a vector whose components are zero.
Returns
Section titled “Returns”Vector2
New Vector2(0, 0).
Properties
Section titled “Properties”length
Section titled “length”
readonlylength:number
Defined in: client/api.d.ts:3699
Read-only Euclidean magnitude of this vector.
lengthSquared
Section titled “lengthSquared”
readonlylengthSquared:number
Defined in: client/api.d.ts:3704
Read-only squared magnitude, avoiding a square-root calculation.
x:
number
Defined in: client/api.d.ts:3689
Mutable X component.
y:
number
Defined in: client/api.d.ts:3694
Mutable Y component.