0.0.2 • Published 1 year ago

vec3-rs v0.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

Vec3-rs

NPM version

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