Vector2.setArray()

Set the x and y values of the vector from the array given as parameter. array[0] for x, array[1] for y

Parameters

NameTypeDescription
1arraynumber[]The array containing values for X and Y axis
2offset?numberthe starting index of the array

Return value

Vector2

The vector with its new values

Usage

import {Vector2} from '@lcluber/type6js';

// set from array
let vector = new Vector2([2,2]);
console.log(vector); //(2,2)
vector.setArray([1,1]);
console.log(vector); //(1,1)