@thi.ng/geom 6.0.6 → 6.0.8

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.
Files changed (104) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +1 -1
  3. package/aabb.js +31 -32
  4. package/api/aabb.js +34 -29
  5. package/api/apc.js +15 -13
  6. package/api/arc.js +82 -66
  7. package/api/bpatch.js +79 -96
  8. package/api/circle.js +21 -21
  9. package/api/cubic.js +28 -25
  10. package/api/ellipse.js +26 -21
  11. package/api/group.js +45 -47
  12. package/api/line.js +26 -27
  13. package/api/path.js +62 -58
  14. package/api/plane.js +21 -21
  15. package/api/points.js +30 -26
  16. package/api/polygon.js +19 -16
  17. package/api/polyline.js +25 -22
  18. package/api/quad.js +20 -17
  19. package/api/quad3.js +20 -17
  20. package/api/quadratic.js +28 -25
  21. package/api/ray.js +30 -26
  22. package/api/rect.js +34 -29
  23. package/api/sphere.js +21 -21
  24. package/api/text.js +21 -28
  25. package/api/triangle.js +20 -17
  26. package/apply-transforms.js +28 -48
  27. package/arc-length.js +17 -30
  28. package/arc.js +17 -6
  29. package/area.js +19 -45
  30. package/as-cubic.js +38 -57
  31. package/as-path.js +4 -8
  32. package/as-polygon.js +12 -29
  33. package/as-polyline.js +18 -38
  34. package/as-svg.js +32 -63
  35. package/bounds.js +46 -48
  36. package/bpatch.js +22 -14
  37. package/center.js +22 -17
  38. package/centroid.js +14 -34
  39. package/circle.js +11 -6
  40. package/classify-point.js +20 -27
  41. package/clip-convex.js +40 -39
  42. package/closest-point.js +28 -34
  43. package/convex-hull.js +12 -27
  44. package/cubic.js +13 -5
  45. package/edges.js +31 -60
  46. package/ellipse.js +5 -2
  47. package/fit-into-bounds.js +78 -61
  48. package/flip.js +24 -41
  49. package/group.js +4 -1
  50. package/internal/args.js +18 -51
  51. package/internal/bounds.js +23 -38
  52. package/internal/collate.js +33 -17
  53. package/internal/copy.js +12 -23
  54. package/internal/dispatch.js +6 -4
  55. package/internal/edges.js +4 -1
  56. package/internal/pclike.js +8 -4
  57. package/internal/points-as-shape.js +4 -3
  58. package/internal/rotate.js +6 -2
  59. package/internal/scale.js +8 -2
  60. package/internal/split.js +9 -6
  61. package/internal/transform.js +24 -12
  62. package/internal/translate.js +6 -2
  63. package/internal/vertices.js +15 -31
  64. package/intersects.js +15 -39
  65. package/line.js +11 -9
  66. package/map-point.js +10 -18
  67. package/offset.js +31 -29
  68. package/package.json +33 -31
  69. package/path-builder.js +152 -143
  70. package/path-from-svg.js +129 -131
  71. package/path.js +28 -25
  72. package/plane.js +10 -5
  73. package/point-at.js +12 -30
  74. package/point-inside.js +20 -25
  75. package/points.js +6 -2
  76. package/polygon.js +15 -47
  77. package/polyline.js +18 -22
  78. package/quad.js +23 -15
  79. package/quadratic.js +7 -3
  80. package/ray.js +4 -1
  81. package/rect.js +47 -46
  82. package/resample.js +12 -27
  83. package/rotate.js +30 -42
  84. package/scale.js +66 -64
  85. package/scatter.js +18 -30
  86. package/simplify.js +38 -55
  87. package/sphere.js +7 -3
  88. package/split-arclength.js +53 -108
  89. package/split-at.js +46 -26
  90. package/split-near.js +28 -22
  91. package/subdiv-curve.js +33 -72
  92. package/tangent-at.js +12 -24
  93. package/tessellate.js +22 -47
  94. package/text.js +4 -1
  95. package/transform-vertices.js +31 -55
  96. package/transform.js +31 -54
  97. package/translate.js +39 -46
  98. package/triangle.js +7 -3
  99. package/union.js +12 -15
  100. package/unmap-point.js +21 -25
  101. package/vertices.js +91 -113
  102. package/volume.js +10 -14
  103. package/warp-points.js +15 -25
  104. package/with-attribs.js +4 -11
package/rect.js CHANGED
@@ -10,54 +10,55 @@ import { sub2 } from "@thi.ng/vectors/sub";
10
10
  import { subN2 } from "@thi.ng/vectors/subn";
11
11
  import { Rect } from "./api/rect.js";
12
12
  import { __argAttribs, __argsVV, __asVec } from "./internal/args.js";
13
- export function rect(...args) {
14
- return new Rect(...__argsVV(args));
13
+ function rect(...args) {
14
+ return new Rect(...__argsVV(args));
15
15
  }
16
- export const rectFromMinMax = (min, max, attribs) => new Rect(min, sub2([], max, min), attribs);
17
- export const rectFromMinMaxWithMargin = (min, max, margin, attribs) => rectFromMinMax(min, max, attribs).offset(margin);
18
- export const rectWithCentroid = (centroid, size, attribs) => {
19
- size = __asVec(size);
20
- return new Rect(maddN2([], size, -0.5, centroid), size, attribs);
16
+ const rectFromMinMax = (min, max, attribs) => new Rect(min, sub2([], max, min), attribs);
17
+ const rectFromMinMaxWithMargin = (min, max, margin, attribs) => rectFromMinMax(min, max, attribs).offset(margin);
18
+ const rectWithCentroid = (centroid2, size, attribs) => {
19
+ size = __asVec(size);
20
+ return new Rect(maddN2([], size, -0.5, centroid2), size, attribs);
21
21
  };
22
- export const rectWithCentroidAndMargin = (centroid, size, margin, attribs) => rectWithCentroid(centroid, size, attribs).offset(margin);
23
- /**
24
- * Returns the intersection rect of given inputs or `undefined` if they
25
- * are non-overlapping.
26
- *
27
- * @param a -
28
- * @param b -
29
- */
30
- export const intersectionRect = (a, b) => {
31
- const p = max2([], a.pos, b.pos);
32
- const q = min2(null, add2([], a.pos, a.size), add2([], b.pos, b.size));
33
- const size = max2(null, sub2(null, q, p), ZERO2);
34
- return size[0] > 0 && size[1] > 0 ? new Rect(p, size) : undefined;
22
+ const rectWithCentroidAndMargin = (centroid2, size, margin, attribs) => rectWithCentroid(centroid2, size, attribs).offset(margin);
23
+ const intersectionRect = (a, b) => {
24
+ const p = max2([], a.pos, b.pos);
25
+ const q = min2(null, add2([], a.pos, a.size), add2([], b.pos, b.size));
26
+ const size = max2(null, sub2(null, q, p), ZERO2);
27
+ return size[0] > 0 && size[1] > 0 ? new Rect(p, size) : void 0;
35
28
  };
36
- export function inscribedSquare(...args) {
37
- let pos, r;
38
- const attribs = __argAttribs(args);
39
- if (args.length === 1) {
40
- const c = args[0];
41
- pos = c.pos;
42
- r = c.r;
43
- }
44
- else {
45
- [pos, r] = args;
46
- }
47
- r *= SQRT2_2;
48
- return rect(subN2([], pos, r), r * 2, attribs);
29
+ function inscribedSquare(...args) {
30
+ let pos, r;
31
+ const attribs = __argAttribs(args);
32
+ if (args.length === 1) {
33
+ const c = args[0];
34
+ pos = c.pos;
35
+ r = c.r;
36
+ } else {
37
+ [pos, r] = args;
38
+ }
39
+ r *= SQRT2_2;
40
+ return rect(subN2([], pos, r), r * 2, attribs);
49
41
  }
50
- export function inscribedSquareHex(...args) {
51
- let pos, l;
52
- const attribs = __argAttribs(args);
53
- if (args.length === 1) {
54
- const pts = args[0].points;
55
- pos = centroid(pts);
56
- l = dist(pts[0], pts[1]);
57
- }
58
- else {
59
- [pos, l] = args;
60
- }
61
- l *= 3 - SQRT3;
62
- return rect(subN2([], pos, l / 2), l, attribs);
42
+ function inscribedSquareHex(...args) {
43
+ let pos, l;
44
+ const attribs = __argAttribs(args);
45
+ if (args.length === 1) {
46
+ const pts = args[0].points;
47
+ pos = centroid(pts);
48
+ l = dist(pts[0], pts[1]);
49
+ } else {
50
+ [pos, l] = args;
51
+ }
52
+ l *= 3 - SQRT3;
53
+ return rect(subN2([], pos, l / 2), l, attribs);
63
54
  }
55
+ export {
56
+ inscribedSquare,
57
+ inscribedSquareHex,
58
+ intersectionRect,
59
+ rect,
60
+ rectFromMinMax,
61
+ rectFromMinMaxWithMargin,
62
+ rectWithCentroid,
63
+ rectWithCentroidAndMargin
64
+ };
package/resample.js CHANGED
@@ -5,36 +5,21 @@ import { Polyline } from "./api/polyline.js";
5
5
  import { asPolygon } from "./as-polygon.js";
6
6
  import { __copyAttribsNoSamples as __attribs } from "./internal/copy.js";
7
7
  import { __dispatch } from "./internal/dispatch.js";
8
- /**
9
- * Resamples given 2D shape with given options and returns result as polygon (if
10
- * closed) or polyline (if open).
11
- *
12
- * @remarks
13
- * If the shape has a `__samples` attribute, it will be removed in the result to
14
- * avoid recursive application.
15
- *
16
- * Currently implemented for:
17
- *
18
- * - {@link Circle}
19
- * - {@link Ellipse}
20
- * - {@link Line}
21
- * - {@link Polygon}
22
- * - {@link Polyline}
23
- * - {@link Quad}
24
- * - {@link Rect}
25
- * - {@link Triangle}
26
- *
27
- * @param shape
28
- * @param opts
29
- */
30
- export const resample = defmulti(__dispatch, {
8
+ const resample = defmulti(
9
+ __dispatch,
10
+ {
31
11
  ellipse: "circle",
32
12
  line: "polyline",
33
13
  quad: "poly",
34
14
  tri: "poly",
35
- rect: "circle",
36
- }, {
15
+ rect: "circle"
16
+ },
17
+ {
37
18
  circle: ($, opts) => asPolygon($, opts),
38
19
  poly: ($, opts) => new Polygon(_resample($.points, opts, true, true), __attribs($)),
39
- polyline: ($, opts) => new Polyline(_resample($.points, opts, false, true), __attribs($)),
40
- });
20
+ polyline: ($, opts) => new Polyline(_resample($.points, opts, false, true), __attribs($))
21
+ }
22
+ );
23
+ export {
24
+ resample
25
+ };
package/rotate.js CHANGED
@@ -17,37 +17,14 @@ import { asPolygon } from "./as-polygon.js";
17
17
  import { __copyAttribs } from "./internal/copy.js";
18
18
  import { __dispatch } from "./internal/dispatch.js";
19
19
  import { __rotatedShape as tx } from "./internal/rotate.js";
20
- /**
21
- * Rotates given 2D shape by `theta` (in radians).
22
- *
23
- * @remarks
24
- * Currently implemented for:
25
- *
26
- * - {@link Arc}
27
- * - {@link Circle}
28
- * - {@link Cubic}
29
- * - {@link Ellipse}
30
- * - {@link Group}
31
- * - {@link Line}
32
- * - {@link Path}
33
- * - {@link Points}
34
- * - {@link Polygon}
35
- * - {@link Polyline}
36
- * - {@link Quad}
37
- * - {@link Quadratic}
38
- * - {@link Ray}
39
- * - {@link Rect}
40
- * - {@link Text}
41
- * - {@link Triangle}
42
- *
43
- * @param shape
44
- * @param theta
45
- */
46
- export const rotate = defmulti(__dispatch, {}, {
20
+ const rotate = defmulti(
21
+ __dispatch,
22
+ {},
23
+ {
47
24
  arc: ($, theta) => {
48
- const a = $.copy();
49
- $rotate(null, a.pos, theta);
50
- return a;
25
+ const a = $.copy();
26
+ $rotate(null, a.pos, theta);
27
+ return a;
51
28
  },
52
29
  circle: ($, theta) => new Circle($rotate([], $.pos, theta), $.r, __copyAttribs($)),
53
30
  cubic: tx(Cubic),
@@ -55,15 +32,18 @@ export const rotate = defmulti(__dispatch, {}, {
55
32
  group: ($, theta) => $.copyTransformed((x) => rotate(x, theta)),
56
33
  line: tx(Line),
57
34
  path: ($, theta) => {
58
- return new Path($.segments.map((s) => s.geo
59
- ? {
60
- type: s.type,
61
- geo: rotate(s.geo, theta),
62
- }
63
- : {
64
- type: s.type,
65
- point: $rotate([], s.point, theta),
66
- }), __copyAttribs($));
35
+ return new Path(
36
+ $.segments.map(
37
+ (s) => s.geo ? {
38
+ type: s.type,
39
+ geo: rotate(s.geo, theta)
40
+ } : {
41
+ type: s.type,
42
+ point: $rotate([], s.point, theta)
43
+ }
44
+ ),
45
+ __copyAttribs($)
46
+ );
67
47
  },
68
48
  points: tx(Points),
69
49
  poly: tx(Polygon),
@@ -71,9 +51,17 @@ export const rotate = defmulti(__dispatch, {}, {
71
51
  quad: tx(Quad),
72
52
  quadratic: tx(Quadratic),
73
53
  ray: ($, theta) => {
74
- return new Ray($rotate([], $.pos, theta), $rotate([], $.dir, theta), __copyAttribs($));
54
+ return new Ray(
55
+ $rotate([], $.pos, theta),
56
+ $rotate([], $.dir, theta),
57
+ __copyAttribs($)
58
+ );
75
59
  },
76
60
  rect: ($, theta) => rotate(asPolygon($), theta),
77
61
  text: ($, theta) => new Text($rotate([], $.pos, theta), $.body, __copyAttribs($)),
78
- tri: tx(Triangle),
79
- });
62
+ tri: tx(Triangle)
63
+ }
64
+ );
65
+ export {
66
+ rotate
67
+ };
package/scale.js CHANGED
@@ -24,71 +24,59 @@ import { __asVec } from "./internal/args.js";
24
24
  import { __copyAttribs } from "./internal/copy.js";
25
25
  import { __dispatch } from "./internal/dispatch.js";
26
26
  import { __scaledShape as tx } from "./internal/scale.js";
27
- /**
28
- * Scales given shape uniformly or non-uniformly by given `factor`.
29
- *
30
- * @remarks
31
- * Scaling non-uniformly might result in different result types, e.g.
32
- * {@link Circle} => {@link Ellipse}.
33
- *
34
- * Currently implemented for:
35
- *
36
- * - {@link AABB}
37
- * - {@link Arc}
38
- * - {@link Circle}
39
- * - {@link Cubic}
40
- * - {@link Ellipse}
41
- * - {@link Group}
42
- * - {@link Line}
43
- * - {@link Path}
44
- * - {@link Points}
45
- * - {@link Points3}
46
- * - {@link Polygon}
47
- * - {@link Polyline}
48
- * - {@link Quad}
49
- * - {@link Quadratic}
50
- * - {@link Ray}
51
- * - {@link Rect}
52
- * - {@link Sphere}
53
- * - {@link Text}
54
- * - {@link Triangle}
55
- *
56
- * @param shape
57
- * @param factor
58
- */
59
- export const scale = defmulti(__dispatch, {}, {
27
+ const scale = defmulti(
28
+ __dispatch,
29
+ {},
30
+ {
60
31
  aabb: ($, delta) => {
61
- delta = __asVec(delta, 3);
62
- return new AABB(mul3([], $.pos, delta), mul3([], $.size, delta), __copyAttribs($));
32
+ delta = __asVec(delta, 3);
33
+ return new AABB(
34
+ mul3([], $.pos, delta),
35
+ mul3([], $.size, delta),
36
+ __copyAttribs($)
37
+ );
63
38
  },
64
39
  arc: ($, delta) => {
65
- delta = __asVec(delta);
66
- const a = $.copy();
67
- mul2(null, a.pos, delta);
68
- mul2(null, a.r, delta);
69
- return a;
40
+ delta = __asVec(delta);
41
+ const a = $.copy();
42
+ mul2(null, a.pos, delta);
43
+ mul2(null, a.r, delta);
44
+ return a;
70
45
  },
71
- circle: ($, delta) => isNumber(delta)
72
- ? new Circle(mulN2([], $.pos, delta), $.r * delta, __copyAttribs($))
73
- : new Ellipse(mul2([], $.pos, delta), mulN2([], delta, $.r), __copyAttribs($)),
46
+ circle: ($, delta) => isNumber(delta) ? new Circle(
47
+ mulN2([], $.pos, delta),
48
+ $.r * delta,
49
+ __copyAttribs($)
50
+ ) : new Ellipse(
51
+ mul2([], $.pos, delta),
52
+ mulN2([], delta, $.r),
53
+ __copyAttribs($)
54
+ ),
74
55
  cubic: tx(Cubic),
75
56
  ellipse: ($, delta) => {
76
- delta = __asVec(delta);
77
- return new Ellipse(mul2([], $.pos, delta), mul2([], $.r, delta), __copyAttribs($));
57
+ delta = __asVec(delta);
58
+ return new Ellipse(
59
+ mul2([], $.pos, delta),
60
+ mul2([], $.r, delta),
61
+ __copyAttribs($)
62
+ );
78
63
  },
79
64
  group: ($, delta) => $.copyTransformed((x) => scale(x, delta)),
80
65
  line: tx(Line),
81
66
  path: ($, delta) => {
82
- delta = __asVec(delta);
83
- return new Path($.segments.map((s) => s.geo
84
- ? {
85
- type: s.type,
86
- geo: scale(s.geo, delta),
87
- }
88
- : {
89
- type: s.type,
90
- point: mul2([], s.point, delta),
91
- }), __copyAttribs($));
67
+ delta = __asVec(delta);
68
+ return new Path(
69
+ $.segments.map(
70
+ (s) => s.geo ? {
71
+ type: s.type,
72
+ geo: scale(s.geo, delta)
73
+ } : {
74
+ type: s.type,
75
+ point: mul2([], s.point, delta)
76
+ }
77
+ ),
78
+ __copyAttribs($)
79
+ );
92
80
  },
93
81
  points: tx(Points),
94
82
  points3: tx(Points3),
@@ -97,16 +85,30 @@ export const scale = defmulti(__dispatch, {}, {
97
85
  quad: tx(Quad),
98
86
  quadratic: tx(Quadratic),
99
87
  ray: ($, delta) => {
100
- delta = __asVec(delta);
101
- return new Ray(mul2([], $.pos, delta), normalize2(null, mul2([], $.dir, delta)), __copyAttribs($));
88
+ delta = __asVec(delta);
89
+ return new Ray(
90
+ mul2([], $.pos, delta),
91
+ normalize2(null, mul2([], $.dir, delta)),
92
+ __copyAttribs($)
93
+ );
102
94
  },
103
95
  rect: ($, delta) => {
104
- delta = __asVec(delta);
105
- return new Rect(mul2([], $.pos, delta), mul2([], $.size, delta), __copyAttribs($));
96
+ delta = __asVec(delta);
97
+ return new Rect(
98
+ mul2([], $.pos, delta),
99
+ mul2([], $.size, delta),
100
+ __copyAttribs($)
101
+ );
106
102
  },
107
- sphere: ($, delta) => isNumber(delta)
108
- ? new Sphere(mulN3([], $.pos, delta), $.r * delta, __copyAttribs($))
109
- : unsupported("can't non-uniformly scale sphere"),
103
+ sphere: ($, delta) => isNumber(delta) ? new Sphere(
104
+ mulN3([], $.pos, delta),
105
+ $.r * delta,
106
+ __copyAttribs($)
107
+ ) : unsupported("can't non-uniformly scale sphere"),
110
108
  text: ($, delta) => new Text(mul2([], $.pos, __asVec(delta)), $.body, __copyAttribs($)),
111
- tri: tx(Triangle),
112
- });
109
+ tri: tx(Triangle)
110
+ }
111
+ );
112
+ export {
113
+ scale
114
+ };
package/scatter.js CHANGED
@@ -2,35 +2,23 @@ import { SYSTEM } from "@thi.ng/random/system";
2
2
  import { randMinMax } from "@thi.ng/vectors/rand-minmax";
3
3
  import { bounds } from "./bounds.js";
4
4
  import { pointInside } from "./point-inside.js";
5
- /**
6
- * Produces `num` random points for which {@link pointInside} succeeds for the
7
- * given `shape`. Writes results into `out` array (or creates a new one).
8
- *
9
- * @remarks
10
- * Samples are only created with the shapes bounding box and are chosen using
11
- * optionally provided `rnd`
12
- * [`IRandom`](https://docs.thi.ng/umbrella/random/interfaces/IRandom.html)
13
- * instance.
14
- *
15
- * @param shape
16
- * @param num
17
- * @param rnd
18
- * @param out
19
- */
20
- export const scatter = (shape, num, rnd = SYSTEM, out = []) => {
21
- const b = bounds(shape);
22
- if (!b)
23
- return;
24
- const mi = b.pos;
25
- const mx = b.max();
26
- for (; num-- > 0;) {
27
- while (true) {
28
- const p = randMinMax([], mi, mx, rnd);
29
- if (pointInside(shape, p)) {
30
- out.push(p);
31
- break;
32
- }
33
- }
5
+ const scatter = (shape, num, rnd = SYSTEM, out = []) => {
6
+ const b = bounds(shape);
7
+ if (!b)
8
+ return;
9
+ const mi = b.pos;
10
+ const mx = b.max();
11
+ for (; num-- > 0; ) {
12
+ while (true) {
13
+ const p = randMinMax([], mi, mx, rnd);
14
+ if (pointInside(shape, p)) {
15
+ out.push(p);
16
+ break;
17
+ }
34
18
  }
35
- return out;
19
+ }
20
+ return out;
21
+ };
22
+ export {
23
+ scatter
36
24
  };
package/simplify.js CHANGED
@@ -7,62 +7,45 @@ import { Polyline } from "./api/polyline.js";
7
7
  import { __copyAttribs } from "./internal/copy.js";
8
8
  import { __dispatch } from "./internal/dispatch.js";
9
9
  import { vertices } from "./vertices.js";
10
- /**
11
- * Simplifies given 2D shape boundary using Douglas-Peucker algorithm
12
- * (implemented by
13
- * [`simplify()`](https://docs.thi.ng/umbrella/geom-resample/functions/simplify.html))
14
- * and given `threshold` distance (default: 0, which removes only co-linear
15
- * vertices).
16
- *
17
- * @remarks
18
- * Currently only implemented for:
19
- *
20
- * - {@link Path}
21
- * - {@link Polygon}
22
- * - {@link Polyline}
23
- *
24
- * Use {@link asPath}, {@link asPolygon} or {@link asPolyline} to convert other
25
- * shape types first.
26
- *
27
- * @param shape
28
- * @param threshold
29
- */
30
- export const simplify = defmulti(__dispatch, {}, {
10
+ const simplify = defmulti(
11
+ __dispatch,
12
+ {},
13
+ {
31
14
  path: ($, eps = 0) => {
32
- const res = [];
33
- const orig = $.segments;
34
- const n = orig.length;
35
- let points;
36
- let lastP;
37
- for (let i = 0; i < n; i++) {
38
- const s = orig[i];
39
- if (s.type === "l" || s.type === "p") {
40
- points = points
41
- ? points.concat(vertices(s.geo))
42
- : vertices(s.geo);
43
- lastP = peek(points);
44
- }
45
- else if (points) {
46
- points.push(lastP);
47
- res.push({
48
- geo: new Polyline(_simplify(points, eps)),
49
- type: "p",
50
- });
51
- points = null;
52
- }
53
- else {
54
- res.push({ ...s });
55
- }
15
+ const res = [];
16
+ const orig = $.segments;
17
+ const n = orig.length;
18
+ let points;
19
+ let lastP;
20
+ for (let i = 0; i < n; i++) {
21
+ const s = orig[i];
22
+ if (s.type === "l" || s.type === "p") {
23
+ points = points ? points.concat(vertices(s.geo)) : vertices(s.geo);
24
+ lastP = peek(points);
25
+ } else if (points) {
26
+ points.push(lastP);
27
+ res.push({
28
+ geo: new Polyline(_simplify(points, eps)),
29
+ type: "p"
30
+ });
31
+ points = null;
32
+ } else {
33
+ res.push({ ...s });
56
34
  }
57
- if (points) {
58
- points.push(lastP);
59
- res.push({
60
- geo: new Polyline(points),
61
- type: "p",
62
- });
63
- }
64
- return new Path(res, __copyAttribs($));
35
+ }
36
+ if (points) {
37
+ points.push(lastP);
38
+ res.push({
39
+ geo: new Polyline(points),
40
+ type: "p"
41
+ });
42
+ }
43
+ return new Path(res, __copyAttribs($));
65
44
  },
66
45
  poly: ($, eps = 0) => new Polygon(_simplify($.points, eps, true), __copyAttribs($)),
67
- polyline: ($, eps = 0) => new Polyline(_simplify($.points, eps), __copyAttribs($)),
68
- });
46
+ polyline: ($, eps = 0) => new Polyline(_simplify($.points, eps), __copyAttribs($))
47
+ }
48
+ );
49
+ export {
50
+ simplify
51
+ };
package/sphere.js CHANGED
@@ -2,7 +2,11 @@ import { dist } from "@thi.ng/vectors/dist";
2
2
  import { mixN3 } from "@thi.ng/vectors/mixn";
3
3
  import { Sphere } from "./api/sphere.js";
4
4
  import { __argsVN } from "./internal/args.js";
5
- export function sphere(...args) {
6
- return new Sphere(...__argsVN(args));
5
+ function sphere(...args) {
6
+ return new Sphere(...__argsVN(args));
7
7
  }
8
- export const sphereFrom2Points = (a, b, attribs) => new Sphere(mixN3([], a, b, 0.5), dist(a, b) / 2, attribs);
8
+ const sphereFrom2Points = (a, b, attribs) => new Sphere(mixN3([], a, b, 0.5), dist(a, b) / 2, attribs);
9
+ export {
10
+ sphere,
11
+ sphereFrom2Points
12
+ };