3draft 0.0.1 → 26.11.1013

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/vec.js ADDED
@@ -0,0 +1,16 @@
1
+ // Tiny vec3 helpers on plain [x, y, z] arrays.
2
+
3
+ export const add = (a, b) => [a[0] + b[0], a[1] + b[1], a[2] + b[2]];
4
+ export const sub = (a, b) => [a[0] - b[0], a[1] - b[1], a[2] - b[2]];
5
+ export const scale = (a, s) => [a[0] * s, a[1] * s, a[2] * s];
6
+ export const dot = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
7
+ export const cross = (a, b) => [
8
+ a[1] * b[2] - a[2] * b[1],
9
+ a[2] * b[0] - a[0] * b[2],
10
+ a[0] * b[1] - a[1] * b[0],
11
+ ];
12
+ export const len = (a) => Math.hypot(a[0], a[1], a[2]);
13
+ export const norm = (a) => {
14
+ const l = len(a);
15
+ return l ? scale(a, 1 / l) : [0, 0, 0];
16
+ };
package/src/version.js ADDED
@@ -0,0 +1,8 @@
1
+ // Versions are date based and stored as semver YY.M.DNNN (see scripts/bump.js).
2
+ // This gives the readable form: '26.11.1001' -> '26.11.01.001'.
3
+
4
+ export const displayVersion = (version) => {
5
+ const [yy, mm, p] = version.split('.').map(Number);
6
+ const pad = (n, w) => String(n).padStart(w, '0');
7
+ return `${pad(yy, 2)}.${pad(mm, 2)}.${pad(Math.floor(p / 1000), 2)}.${pad(p % 1000, 3)}`;
8
+ };