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
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 }