Vec2
The Vec2 class represents a vector in 2D space. Here is how you initialize one and get values from it.
let pos = new Vec2(0, 1); log(pos); // output: {0, 1} log(pos.x); // output: 0
Here’s more examples of its usage.
let a = new Vec2(1, 3); let b = new Vec2(3, 7); let sum = a.add(b); let length = a.length(); let sqrLength = a.sqrLength(); //squared length let normalized = a.normalize(); let diff = a.sub(b); let dotProduct = a.dot(b); let distanceBetweenPoints = a.distance(b); let factor = 2; let scaled = a.scale(factor); let alpha = 0.5; let lerp = a.lerp(b, alpha); let pivot = new Vec2(3,1); let angle = Math.PI/4; let rotated = rotateByAngle(pivot, angle); let c = new Vec3(101, null); let cxe = c.isXEmpty(); //false let cye = c.isYEmpty(); //true