vec3-rs
v0.0.2
Published
3D Vector math for node (Rust-built)
Downloads
3
Readme
Vec3-rs
3D vector math with Rust backend
Installation
- Via NPM:
npm install vec3-rs
Building
- Via NAPI-RS:
npm install -g @napi-rs/cli
git clone https://github.com/firejoust/node-vec3-rs.git
cd node-vec3-rs
napi build --platform --release # this will generate index.js and index.d.ts
Usage
const Vec3 = require('vec3-rs');
let v1 = new Vec3(1, 2, 3)
console.log(v1) // prints "(1, 2, 3)"
let v2 = v1.offset(0, 0, 1)
console.log(v2) // prints "(1, 2, 4)"
Or:
const { Vec3 } = require('vec3-rs');
let v1 = new Vec3(1, 2, 3);
// etc...
More available functions are listed below:
API
Vec3
✓ rounded
✓ round
✓ floored
✓ floor
✓ offset
✓ translate
✓ plus
✓ minus
✓ scaled
✓ abs
✓ distanceTo
✓ equals
✓ toString
✓ clone
✓ add
✓ subtract
✓ multiply
✓ divide
✓ set
✓ modulus
✓ volume
✓ min
✓ max
✓ update
✓ norm
✓ dot
✓ cross
✓ unit
✓ normalize
✓ scale
✓ xyDistanceTo
✓ xzDistanceTo
✓ yzDistanceTo
✓ innerProduct
✓ manhattanDistanceTo
✓ toArray