1.0.7 • Published 6 years ago
rovector3 v1.0.7
This package is a JS implementation of Roblox's Vector3 Class.
npm install rovector3 --save
Once you've installed the package you can simply add it to your code:
const CFrame = require('rovector3');
The great part about this package is that it functions similarly to Roblox's. However, since JS does not support operator overloading there are methods built into Vector3s as substitutes.
Addition
const Vector3 = require('rovector3');
let a = Vector3.new(0,0,0);
let b = a.add(Vector3.new(5,0,0));
Subtraction
const Vector3 = require('rovector3');
let a = Vector3.new(0,0,0);
let b = a.sub(Vector3.new(5,0,0));
Multiplication
const Vector3 = require('rovector3');
let a = Vector3.new(0,0,0);
let b = a.mult(Vector3.new(5,0,0));
Division
const Vector3 = require('rovector3');
let a = Vector3.new(0,0,0);
let b = a.div(Vector3.new(5,0,0));
Dot Product
const Vector3 = require('rovector3');
let a = Vector3.new(3,2,1);
let b = a.Dot(Vector3.new(5,0,0));
Cross Product
const Vector3 = require('rovector3');
let a = Vector3.new(5,12,2);
let b = a.Cross(Vector3.new(5,0,0));
Interpolation
const Vector3 = require('rovector3');
let a = Vector3.new(0,0,0);
let b = a.Lerp(Vector3.new(5,0,0),0.75);
Unit
const Vector3 = require('rovector3');
let a = Vector3.new(90,2,4).unit();