JSPM

  • Created
  • Published
  • Downloads 341
  • Score
    100M100P100Q69136F
  • License MIT

A vector lib with support for (+ - * /) operator handling

Package Exports

  • @js-basics/vector

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@js-basics/vector) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

GitHub package version license

OSX/Linux Build Status Windows Build status NSP Status Dependencies Status DevDependencies Status

Greenkeeper badge

basics - vector

this libary provides 3D Vector in js including support for + - * / operator handling

create vector by numbers

const pos = new Vector(5, 6, 7);
const dir = new Vector(1, 0, 0);

console.log('pos:', pos, ' dir:', dir);

pos: { x: 5, y: 6, z: 7 } dir: { x: 1, y: 0, z: 0 }

create vector by calculating other vectors and number

const offset = new Vector(() => dir * 30 + pos);

console.log('offset:', offset);

offset: { x: 35, y: 6, z: 7 }

compare lengths

let way = offset;
if (way > 1) {
  way = way.normalize();
}
console.log('way:', way);

way: { x: 0.96, y: 0.16, z: 0.19 }