We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d672c6c commit a03cddaCopy full SHA for a03cdda
examples/example.js
@@ -2,18 +2,26 @@ const { calc, default: Vector } = require('../lib');
2
3
/* eslint-disable no-console */
4
5
+// create vector by numbers
6
const pos = new Vector(5, 6, 7);
7
const dir = new Vector(1, 0, 0);
8
console.log('pos:', pos, ' dir:', dir);
9
+// pos: { [Number: 10.48] x: 5, y: 6, z: 7 } dir: { [Number: 1] x: 1, y: 0, z: 0 }
10
11
+// or create vector by calculating other vectors and number
12
const offsetA = new Vector(() => dir * 30 + pos);
13
console.log('offsetA:', offsetA);
14
+// offsetA: { [Number: 36.19] x: 35, y: 6, z: 7 }
15
-const offsetB = calc(() => dir * 30 + pos);
16
+// calc two Vectors
17
+const offsetB = calc(() => dir * 20 + pos);
18
console.log('offsetB:', offsetB);
19
+// offsetB: { [Number: 26.645825188948457] x: 25, y: 6, z: 7 }
20
21
+// compare length
22
let way = offsetA;
23
if (way > 1) {
24
way = way.normalize();
25
}
26
console.log('way:', way);
27
+// way: { [Number: 1] x: 0.96, y: 0.16, z: 0.19 }
0 commit comments