Skip to content

Commit a03cdda

Browse files
fix(example): refactored
1 parent d672c6c commit a03cdda

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

examples/example.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,26 @@ const { calc, default: Vector } = require('../lib');
22

33
/* eslint-disable no-console */
44

5+
// create vector by numbers
56
const pos = new Vector(5, 6, 7);
67
const dir = new Vector(1, 0, 0);
78
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 }
810

11+
// or create vector by calculating other vectors and number
912
const offsetA = new Vector(() => dir * 30 + pos);
1013
console.log('offsetA:', offsetA);
14+
// offsetA: { [Number: 36.19] x: 35, y: 6, z: 7 }
1115

12-
const offsetB = calc(() => dir * 30 + pos);
16+
// calc two Vectors
17+
const offsetB = calc(() => dir * 20 + pos);
1318
console.log('offsetB:', offsetB);
19+
// offsetB: { [Number: 26.645825188948457] x: 25, y: 6, z: 7 }
1420

21+
// compare length
1522
let way = offsetA;
1623
if (way > 1) {
1724
way = way.normalize();
1825
}
1926
console.log('way:', way);
27+
// way: { [Number: 1] x: 0.96, y: 0.16, z: 0.19 }

0 commit comments

Comments
 (0)