@math.gl/geometry 5.0.0-alpha.19 → 5.0.0-alpha.20

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 (69) hide show
  1. package/LICENSE +95 -54
  2. package/README.md +9 -0
  3. package/THIRD-PARTY-NOTICES.md +18 -0
  4. package/dist/culling/index.cjs +22 -30
  5. package/dist/culling/index.cjs.map +3 -3
  6. package/dist/culling/index.d.ts +1 -0
  7. package/dist/culling/index.d.ts.map +1 -1
  8. package/dist/culling/index.js +1 -0
  9. package/dist/culling/index.js.map +1 -1
  10. package/dist/culling/lib/algorithms/bounding-box-from-points.js +1 -1
  11. package/dist/culling/lib/algorithms/bounding-box-from-points.js.map +1 -1
  12. package/dist/culling/lib/algorithms/bounding-sphere-from-points.js +1 -1
  13. package/dist/culling/lib/algorithms/bounding-sphere-from-points.js.map +1 -1
  14. package/dist/culling/lib/algorithms/compute-eigen-decomposition.js +1 -1
  15. package/dist/culling/lib/algorithms/compute-eigen-decomposition.js.map +1 -1
  16. package/dist/culling/lib/algorithms/oriented-bounding-box-quaternion.d.ts +7 -0
  17. package/dist/culling/lib/algorithms/oriented-bounding-box-quaternion.d.ts.map +1 -0
  18. package/dist/culling/lib/algorithms/oriented-bounding-box-quaternion.js +26 -0
  19. package/dist/culling/lib/algorithms/oriented-bounding-box-quaternion.js.map +1 -0
  20. package/dist/culling/lib/bounding-volumes/bounding-sphere.js +1 -1
  21. package/dist/culling/lib/bounding-volumes/bounding-sphere.js.map +1 -1
  22. package/dist/culling/lib/bounding-volumes/oriented-bounding-box.d.ts +1 -7
  23. package/dist/culling/lib/bounding-volumes/oriented-bounding-box.d.ts.map +1 -1
  24. package/dist/culling/lib/bounding-volumes/oriented-bounding-box.js +1 -30
  25. package/dist/culling/lib/bounding-volumes/oriented-bounding-box.js.map +1 -1
  26. package/dist/culling/lib/culling-volume.js +1 -1
  27. package/dist/culling/lib/culling-volume.js.map +1 -1
  28. package/dist/culling/lib/perspective-off-center-frustum.js +1 -1
  29. package/dist/culling/lib/perspective-off-center-frustum.js.map +1 -1
  30. package/dist/culling/lib/plane.js +1 -1
  31. package/dist/culling/lib/plane.js.map +1 -1
  32. package/dist/culling/lib/ray.js +1 -1
  33. package/dist/culling/lib/ray.js.map +1 -1
  34. package/dist/index.cjs +126 -0
  35. package/dist/index.cjs.map +2 -2
  36. package/dist/index.d.ts +2 -0
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +1 -0
  39. package/dist/index.js.map +1 -1
  40. package/dist/lib/hinge-tree.d.ts +33 -0
  41. package/dist/lib/hinge-tree.d.ts.map +1 -0
  42. package/dist/lib/hinge-tree.js +144 -0
  43. package/dist/lib/hinge-tree.js.map +1 -0
  44. package/dist/polygon/index.cjs +34 -11
  45. package/dist/polygon/index.cjs.map +1 -1
  46. package/dist/polygon/index.d.ts +1 -1
  47. package/dist/polygon/index.d.ts.map +1 -1
  48. package/dist/polygon/index.js.map +1 -1
  49. package/dist/polygon/subdivide-polyline.d.ts +17 -3
  50. package/dist/polygon/subdivide-polyline.d.ts.map +1 -1
  51. package/dist/polygon/subdivide-polyline.js +44 -12
  52. package/dist/polygon/subdivide-polyline.js.map +1 -1
  53. package/package.json +6 -4
  54. package/src/culling/index.ts +5 -0
  55. package/src/culling/lib/algorithms/bounding-box-from-points.ts +1 -1
  56. package/src/culling/lib/algorithms/bounding-sphere-from-points.ts +1 -1
  57. package/src/culling/lib/algorithms/compute-eigen-decomposition.ts +1 -1
  58. package/src/culling/lib/algorithms/oriented-bounding-box-quaternion.ts +32 -0
  59. package/src/culling/lib/bounding-volumes/bounding-sphere.ts +1 -1
  60. package/src/culling/lib/bounding-volumes/oriented-bounding-box.ts +2 -37
  61. package/src/culling/lib/culling-volume.ts +1 -1
  62. package/src/culling/lib/perspective-frustum.ts +1 -1
  63. package/src/culling/lib/perspective-off-center-frustum.ts +1 -1
  64. package/src/culling/lib/plane.ts +1 -1
  65. package/src/culling/lib/ray.ts +1 -1
  66. package/src/index.ts +3 -0
  67. package/src/lib/hinge-tree.ts +170 -0
  68. package/src/polygon/index.ts +5 -1
  69. package/src/polygon/subdivide-polyline.ts +76 -13
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/polygon/index.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAE5D,OAAO,EAAC,OAAO,EAAC,qBAAkB;AAElC,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,uBAAuB,EACvB,6BAA6B,EAC9B,2BAAwB;AAGzB,OAAO,EAAC,MAAM,EAAC,oBAAiB;AAEhC,OAAO,EAAC,WAAW,EAAE,YAAY,EAAC,sBAAmB;AAErD,OAAO,EAAC,gBAAgB,EAAE,iBAAiB,EAAC,yBAAsB;AAElE,OAAO,EAAC,2BAA2B,EAAE,0BAA0B,EAAC,oCAAiC;AAEjG,OAAO,EAAC,iBAAiB,EAAC,gCAA6B;AAGvD,OAAO,EAAC,qBAAqB,EAAC,qCAAkC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/polygon/index.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAE5D,OAAO,EAAC,OAAO,EAAC,qBAAkB;AAElC,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,uBAAuB,EACvB,6BAA6B,EAC9B,2BAAwB;AAGzB,OAAO,EAAC,MAAM,EAAC,oBAAiB;AAEhC,OAAO,EAAC,WAAW,EAAE,YAAY,EAAC,sBAAmB;AAErD,OAAO,EAAC,gBAAgB,EAAE,iBAAiB,EAAC,yBAAsB;AAElE,OAAO,EAAC,2BAA2B,EAAE,0BAA0B,EAAC,oCAAiC;AAEjG,OAAO,EAAC,iBAAiB,EAAC,gCAA6B;AAOvD,OAAO,EAAC,qBAAqB,EAAC,qCAAkC"}
@@ -1,4 +1,11 @@
1
- /** Configuration for sampling straight source edges through a nonlinear transform. */
1
+ /** A constant-speed source edge, sampled at fractions of its declared length.
2
+ * Endpoints must match the factory inputs exactly. Samples are copied before use.
3
+ */
4
+ export type PolylineEdgeSampler = {
5
+ readonly length: number;
6
+ sample: (fraction: number) => ArrayLike<number>;
7
+ };
8
+ /** Configuration for sampling source edges through a nonlinear transform. */
2
9
  export type SubdividePolylineOptions = {
3
10
  /** Maps a source position to target coordinates; null or nonfinite output rejects the geometry.
4
11
  * Must be deterministic. A fresh array is passed on every invocation.
@@ -6,11 +13,17 @@ export type SubdividePolylineOptions = {
6
13
  transform: (position: readonly number[]) => ArrayLike<number> | null;
7
14
  /** Positive error tolerance in target-coordinate units, measured across all output components. */
8
15
  tolerance: number;
16
+ /** Optional factory, called once per original edge with independent endpoint copies.
17
+ * Without it, source coordinates interpolate linearly. Must be deterministic.
18
+ */
19
+ createEdgeSampler?: (start: readonly number[], end: readonly number[], segmentIndex: number) => PolylineEdgeSampler;
9
20
  /** Number of source components per vertex. Default 2. */
10
21
  size?: 2 | 3;
11
22
  /** Number of target components per vertex. Defaults to size. */
12
23
  targetSize?: 2 | 3;
13
- /** Optional positive maximum Euclidean edge length in source-coordinate units. */
24
+ /** Positive maximum leaf length: Euclidean source distance by default, or the
25
+ * custom sampler's declared length multiplied by its fraction interval.
26
+ */
14
27
  maxSegmentLength?: number;
15
28
  /** Maximum bisection depth per input edge. Default 16; maximum 30. */
16
29
  maxDepth?: number;
@@ -33,7 +46,8 @@ export type SubdividedPolyline = {
33
46
  /** Adaptively subdivides a flat polyline by sampling a supplied coordinate transform.
34
47
  * Each leaf edge checks its quarter, midpoint and three-quarter positions against linear
35
48
  * interpolation of its target endpoints. This is a sampled criterion, not a guaranteed
36
- * bound for arbitrary transforms. Source edges and extra source components interpolate linearly.
49
+ * bound for arbitrary transforms. Source components interpolate linearly unless a custom
50
+ * constant-speed source-edge sampler is supplied.
37
51
  * Explicitly closed rings stay closed. Split seams and clip invalid domains before calling.
38
52
  * @throws RangeError For invalid options/coordinates, rejected transform samples, or exhausted limits.
39
53
  * Exceptions thrown by the transform itself propagate unchanged.
@@ -1 +1 @@
1
- {"version":3,"file":"subdivide-polyline.d.ts","sourceRoot":"","sources":["../../src/polygon/subdivide-polyline.ts"],"names":[],"mappings":"AAIA,sFAAsF;AACtF,MAAM,MAAM,wBAAwB,GAAG;IACrC;;OAEG;IACH,SAAS,EAAE,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,KAAK,SAAS,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IACrE,kGAAkG;IAClG,SAAS,EAAE,MAAM,CAAC;IAClB,yDAAyD;IACzD,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IACb,gEAAgE;IAChE,UAAU,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IACnB,kFAAkF;IAClF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,sEAAsE;IACtE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0EAA0E;IAC1E,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,8FAA8F;AAC9F,MAAM,MAAM,kBAAkB,GAAG;IAC/B,2FAA2F;IAC3F,eAAe,EAAE,YAAY,CAAC;IAC9B,mEAAmE;IACnE,SAAS,EAAE,YAAY,CAAC;IACxB;;OAEG;IACH,cAAc,EAAE,WAAW,CAAC;IAC5B,0FAA0F;IAC1F,gBAAgB,EAAE,YAAY,CAAC;CAChC,CAAC;AAIF;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,EACxB,OAAO,EAAE,wBAAwB,GAChC,kBAAkB,CA4GpB"}
1
+ {"version":3,"file":"subdivide-polyline.d.ts","sourceRoot":"","sources":["../../src/polygon/subdivide-polyline.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,SAAS,CAAC,MAAM,CAAC,CAAC;CACjD,CAAC;AAEF,6EAA6E;AAC7E,MAAM,MAAM,wBAAwB,GAAG;IACrC;;OAEG;IACH,SAAS,EAAE,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,KAAK,SAAS,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IACrE,kGAAkG;IAClG,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,iBAAiB,CAAC,EAAE,CAClB,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,GAAG,EAAE,SAAS,MAAM,EAAE,EACtB,YAAY,EAAE,MAAM,KACjB,mBAAmB,CAAC;IACzB,yDAAyD;IACzD,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IACb,gEAAgE;IAChE,UAAU,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IACnB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,sEAAsE;IACtE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0EAA0E;IAC1E,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,8FAA8F;AAC9F,MAAM,MAAM,kBAAkB,GAAG;IAC/B,2FAA2F;IAC3F,eAAe,EAAE,YAAY,CAAC;IAC9B,mEAAmE;IACnE,SAAS,EAAE,YAAY,CAAC;IACxB;;OAEG;IACH,cAAc,EAAE,WAAW,CAAC;IAC5B,0FAA0F;IAC1F,gBAAgB,EAAE,YAAY,CAAC;CAChC,CAAC;AAIF;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,EACxB,OAAO,EAAE,wBAAwB,GAChC,kBAAkB,CAwJpB"}
@@ -4,14 +4,16 @@
4
4
  /** Adaptively subdivides a flat polyline by sampling a supplied coordinate transform.
5
5
  * Each leaf edge checks its quarter, midpoint and three-quarter positions against linear
6
6
  * interpolation of its target endpoints. This is a sampled criterion, not a guaranteed
7
- * bound for arbitrary transforms. Source edges and extra source components interpolate linearly.
7
+ * bound for arbitrary transforms. Source components interpolate linearly unless a custom
8
+ * constant-speed source-edge sampler is supplied.
8
9
  * Explicitly closed rings stay closed. Split seams and clip invalid domains before calling.
9
10
  * @throws RangeError For invalid options/coordinates, rejected transform samples, or exhausted limits.
10
11
  * Exceptions thrown by the transform itself propagate unchanged.
11
12
  */
12
13
  export function subdividePolyline(input, options) {
13
- const { transform, tolerance, size = 2, targetSize = size, maxSegmentLength = Infinity, maxDepth = 16, maxVertices = 65536 } = options;
14
+ const { transform, tolerance, createEdgeSampler, size = 2, targetSize = size, maxSegmentLength = Infinity, maxDepth = 16, maxVertices = 65536 } = options;
14
15
  if (typeof transform !== 'function' ||
16
+ (createEdgeSampler !== undefined && typeof createEdgeSampler !== 'function') ||
15
17
  !Number.isFinite(tolerance) ||
16
18
  tolerance <= 0 ||
17
19
  (size !== 2 && size !== 3) ||
@@ -64,22 +66,36 @@ export function subdividePolyline(input, options) {
64
66
  segmentIndices.push(segment);
65
67
  segmentFractions.push(point.fraction);
66
68
  }
67
- function interpolate(a, b, fraction) {
68
- // Weighted sum avoids overflow from subtracting opposite large finite values.
69
- const source = a.source.map((value, i) => value * (1 - fraction) + b.source[i] * fraction);
70
- return sample(source, a.fraction * (1 - fraction) + b.fraction * fraction);
69
+ function sampledSource(sampler, fraction) {
70
+ const value = sampler.sample(fraction);
71
+ if (!value || value.length !== size)
72
+ throw new RangeError('Invalid source-edge sample size');
73
+ const source = Array.from(value);
74
+ if (!source.every(Number.isFinite))
75
+ throw new RangeError('Nonfinite source-edge sample');
76
+ return source;
71
77
  }
72
- function subdivide(a, b, segment, depth) {
78
+ function interpolate(a, b, fraction, sampler) {
79
+ const originalFraction = a.fraction * (1 - fraction) + b.fraction * fraction;
80
+ // Always sample the original edge, never a new curve fitted to recursive endpoints.
81
+ const source = sampler
82
+ ? sampledSource(sampler, originalFraction)
83
+ : a.source.map((value, i) => value * (1 - fraction) + b.source[i] * fraction);
84
+ return sample(source, originalFraction);
85
+ }
86
+ function subdivide(a, b, segment, depth, sampler) {
73
87
  let error = 0;
74
88
  let midpoint;
75
89
  for (const fraction of [0.25, 0.5, 0.75]) {
76
- const point = interpolate(a, b, fraction);
90
+ const point = interpolate(a, b, fraction, sampler);
77
91
  if (fraction === 0.5)
78
92
  midpoint = point;
79
93
  const delta = point.target.map((value, i) => value - (a.target[i] * (1 - fraction) + b.target[i] * fraction));
80
94
  error = Math.max(error, Math.hypot(...delta));
81
95
  }
82
- const sourceLength = Math.hypot(...a.source.map((value, i) => value - b.source[i]));
96
+ const sourceLength = sampler
97
+ ? sampler.length * (b.fraction - a.fraction)
98
+ : Math.hypot(...a.source.map((value, i) => value - b.source[i]));
83
99
  if (error <= tolerance && sourceLength <= maxSegmentLength) {
84
100
  append(b, segment);
85
101
  return;
@@ -87,15 +103,31 @@ export function subdividePolyline(input, options) {
87
103
  if (depth >= maxDepth) {
88
104
  throw new RangeError(`Polyline subdivision exceeded maxDepth on input edge ${segment}`);
89
105
  }
90
- subdivide(a, midpoint, segment, depth + 1);
91
- subdivide(midpoint, b, segment, depth + 1);
106
+ subdivide(a, midpoint, segment, depth + 1, sampler);
107
+ subdivide(midpoint, b, segment, depth + 1, sampler);
92
108
  }
93
109
  if (vertexCount) {
94
110
  let previous = sample(sources.slice(0, size), 0);
95
111
  append(previous, 0);
96
112
  for (let i = 1; i < vertexCount; i++) {
97
113
  const next = sample(sources.slice(i * size, (i + 1) * size), 1);
98
- subdivide({ ...previous, fraction: 0 }, next, i - 1, 0);
114
+ const start = { ...previous, fraction: 0 };
115
+ const sampler = createEdgeSampler?.(start.source.slice(), next.source.slice(), i - 1);
116
+ if (createEdgeSampler) {
117
+ if (!sampler ||
118
+ typeof sampler.sample !== 'function' ||
119
+ !Number.isFinite(sampler.length) ||
120
+ sampler.length < 0) {
121
+ throw new RangeError('Invalid source-edge sampler');
122
+ }
123
+ for (const endpoint of [start, next]) {
124
+ const sampled = sampledSource(sampler, endpoint.fraction);
125
+ if (sampled.some((value, component) => value !== endpoint.source[component])) {
126
+ throw new RangeError('Source-edge sampler endpoints must match input');
127
+ }
128
+ }
129
+ }
130
+ subdivide(start, next, i - 1, 0, sampler);
99
131
  previous = next;
100
132
  }
101
133
  }
@@ -1 +1 @@
1
- {"version":3,"file":"subdivide-polyline.js","sourceRoot":"","sources":["../../src/polygon/subdivide-polyline.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAsC5D;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAC/B,KAAwB,EACxB,OAAiC;IAEjC,MAAM,EACJ,SAAS,EACT,SAAS,EACT,IAAI,GAAG,CAAC,EACR,UAAU,GAAG,IAAI,EACjB,gBAAgB,GAAG,QAAQ,EAC3B,QAAQ,GAAG,EAAE,EACb,WAAW,GAAG,KAAK,EACpB,GAAG,OAAO,CAAC;IACZ,IACE,OAAO,SAAS,KAAK,UAAU;QAC/B,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC;QAC3B,SAAS,IAAI,CAAC;QACd,CAAC,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,CAAC;QAC1B,CAAC,UAAU,KAAK,CAAC,IAAI,UAAU,KAAK,CAAC,CAAC;QACtC,CAAC,CAAC,gBAAgB,GAAG,CAAC,CAAC;QACvB,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,gBAAgB,KAAK,QAAQ,CAAC;QACrE,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC;QAC3B,QAAQ,GAAG,CAAC;QACZ,QAAQ,GAAG,EAAE;QACb,CAAC,MAAM,CAAC,aAAa,CAAC,WAAW,CAAC;QAClC,WAAW,GAAG,CAAC;QACf,WAAW,GAAG,UAAU;QACxB,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC;QACnC,KAAK,CAAC,MAAM,GAAG,C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AC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC;wBAC7E,MAAM,IAAI,UAAU,CAAC,gDAAgD,CAAC,CAAC;oBACzE,CAAC;gBACH,CAAC;YACH,CAAC;YACD,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;YAC1C,QAAQ,GAAG,IAAI,CAAC;QAClB,CAAC;IACH,CAAC;IACD,OAAO;QACL,eAAe,EAAE,IAAI,YAAY,CAAC,eAAe,CAAC;QAClD,SAAS,EAAE,IAAI,YAAY,CAAC,SAAS,CAAC;QACtC,cAAc,EAAE,IAAI,WAAW,CAAC,cAAc,CAAC;QAC/C,gBAAgB,EAAE,IAAI,YAAY,CAAC,gBAAgB,CAAC;KACrD,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
9
- "version": "5.0.0-alpha.19",
9
+ "version": "5.0.0-alpha.20",
10
10
  "keywords": [
11
11
  "geometry",
12
12
  "gltf",
@@ -81,11 +81,13 @@
81
81
  },
82
82
  "files": [
83
83
  "dist",
84
- "src"
84
+ "src",
85
+ "LICENSE",
86
+ "THIRD-PARTY-NOTICES.md"
85
87
  ],
86
88
  "dependencies": {
87
- "@math.gl/core": "5.0.0-alpha.19"
89
+ "@math.gl/core": "5.0.0-alpha.20"
88
90
  },
89
91
  "sideEffects": false,
90
- "gitHead": "f5700027934faf25c37230905c7ffa14d7f677a7"
92
+ "gitHead": "ad8c205a98e5e057d9055300b1a71f422b275c73"
91
93
  }
@@ -38,3 +38,8 @@ export type {QueryPoint, TriangleRayHit} from './queries';
38
38
 
39
39
  export {intersectOrientedBoxes2D} from './oriented-box-2d';
40
40
  export type {OrientedBox2D} from './oriented-box-2d';
41
+
42
+ export {
43
+ getOrientedBoundingBoxQuaternion,
44
+ makeOrientedBoundingBoxFromQuaternion
45
+ } from './lib/algorithms/oriented-bounding-box-quaternion';
@@ -5,7 +5,7 @@
5
5
  // SPDX-FileComment: Derived from Cesium. See the repository LICENSE for upstream attribution and Apache-2.0 terms.
6
6
 
7
7
  // This file is derived from the Cesium math library under Apache 2 license
8
- // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
8
+ // See ../../../../LICENSE for the retained Cesium notice and Apache-2.0 terms.
9
9
 
10
10
  import {Vector3, Matrix3} from '@math.gl/core';
11
11
  import {computeEigenDecomposition} from './compute-eigen-decomposition';
@@ -5,7 +5,7 @@
5
5
  // SPDX-FileComment: Derived from Cesium. See the repository LICENSE for upstream attribution and Apache-2.0 terms.
6
6
 
7
7
  // This file is derived from the Cesium math library under Apache 2 license
8
- // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
8
+ // See ../../../../LICENSE for the retained Cesium notice and Apache-2.0 terms.
9
9
 
10
10
  import {Vector3} from '@math.gl/core';
11
11
  import {BoundingSphere} from '../bounding-volumes/bounding-sphere';
@@ -5,7 +5,7 @@
5
5
  // SPDX-FileComment: Derived from Cesium. See the repository LICENSE for upstream attribution and Apache-2.0 terms.
6
6
 
7
7
  // This file is derived from the Cesium math library under Apache 2 license
8
- // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
8
+ // See ../../../../LICENSE for the retained Cesium notice and Apache-2.0 terms.
9
9
 
10
10
  import {Matrix3, _MathUtils} from '@math.gl/core';
11
11
 
@@ -0,0 +1,32 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT AND Apache-2.0
3
+ // SPDX-FileCopyrightText: Copyright 2011-2018 CesiumJS Contributors
4
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
5
+ // SPDX-FileComment: Extracted Cesium-derived OBB quaternion operations; see ../../../../LICENSE for attribution.
6
+
7
+ import {Matrix3, Quaternion, Vector3} from '@math.gl/core';
8
+ import {OrientedBoundingBox} from '../bounding-volumes/oriented-bounding-box';
9
+
10
+ /** Return the orientation of a box, excluding the scale of its half axes. */
11
+ export function getOrientedBoundingBoxQuaternion(box: OrientedBoundingBox): Quaternion {
12
+ const x = new Vector3(box.halfAxes.getColumn(0)).normalize();
13
+ const y = new Vector3(box.halfAxes.getColumn(1)).normalize();
14
+ const z = new Vector3(box.halfAxes.getColumn(2)).normalize();
15
+ return new Quaternion().fromMatrix3(new Matrix3([...x, ...y, ...z]));
16
+ }
17
+
18
+ /** Construct a box from its center, half sizes and quaternion, optionally reusing a box. */
19
+ export function makeOrientedBoundingBoxFromQuaternion(
20
+ center: readonly number[],
21
+ halfSize: readonly number[],
22
+ quaternion: readonly number[],
23
+ result = new OrientedBoundingBox()
24
+ ): OrientedBoundingBox {
25
+ const halfAxes = new Matrix3().fromQuaternion(quaternion);
26
+ for (let column = 0; column < 3; column++) {
27
+ for (let row = 0; row < 3; row++) halfAxes[column * 3 + row] *= halfSize[column];
28
+ }
29
+ result.center = new Vector3(center);
30
+ result.halfAxes = halfAxes;
31
+ return result;
32
+ }
@@ -5,7 +5,7 @@
5
5
  // SPDX-FileComment: Derived from Cesium. See the repository LICENSE for upstream attribution and Apache-2.0 terms.
6
6
 
7
7
  // This file is derived from the Cesium math library under Apache 2 license
8
- // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
8
+ // See ../../../../LICENSE for the retained Cesium notice and Apache-2.0 terms.
9
9
 
10
10
  import {NumericArray, Vector3} from '@math.gl/core';
11
11
  import * as mat4 from '@math.gl/core/mat4';
@@ -5,10 +5,10 @@
5
5
  // SPDX-FileComment: Derived from Cesium. See the repository LICENSE for upstream attribution and Apache-2.0 terms.
6
6
 
7
7
  // This file is derived from the Cesium math library under Apache 2 license
8
- // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
8
+ // See ../../../../LICENSE for the retained Cesium notice and Apache-2.0 terms.
9
9
 
10
10
  import {NumericArray} from '@math.gl/core/types';
11
- import {Vector3, Matrix3, Matrix4, Quaternion} from '@math.gl/core';
11
+ import {Vector3, Matrix3, Matrix4} from '@math.gl/core';
12
12
 
13
13
  import type {BoundingVolume} from './bounding-volume';
14
14
  import {BoundingSphere} from './bounding-sphere';
@@ -66,41 +66,6 @@ export class OrientedBoundingBox implements BoundingVolume {
66
66
  return [new Vector3(xAxis).len(), new Vector3(yAxis).len(), new Vector3(zAxis).len()];
67
67
  }
68
68
 
69
- /** Returns a quaternion describing the orientation of the bounding box */
70
- get quaternion(): Quaternion {
71
- const xAxis = this.halfAxes.getColumn(0);
72
- const yAxis = this.halfAxes.getColumn(1);
73
- const zAxis = this.halfAxes.getColumn(2);
74
- const normXAxis = new Vector3(xAxis).normalize();
75
- const normYAxis = new Vector3(yAxis).normalize();
76
- const normZAxis = new Vector3(zAxis).normalize();
77
- return new Quaternion().fromMatrix3(new Matrix3([...normXAxis, ...normYAxis, ...normZAxis]));
78
- }
79
-
80
- /**
81
- * Create OrientedBoundingBox from quaternion based OBB,
82
- */
83
- fromCenterHalfSizeQuaternion(
84
- center: number[],
85
- halfSize: number[],
86
- quaternion: number[]
87
- ): OrientedBoundingBox {
88
- const quaternionObject = new Quaternion(quaternion);
89
- const directionsMatrix = new Matrix3().fromQuaternion(quaternionObject);
90
- directionsMatrix[0] = directionsMatrix[0] * halfSize[0];
91
- directionsMatrix[1] = directionsMatrix[1] * halfSize[0];
92
- directionsMatrix[2] = directionsMatrix[2] * halfSize[0];
93
- directionsMatrix[3] = directionsMatrix[3] * halfSize[1];
94
- directionsMatrix[4] = directionsMatrix[4] * halfSize[1];
95
- directionsMatrix[5] = directionsMatrix[5] * halfSize[1];
96
- directionsMatrix[6] = directionsMatrix[6] * halfSize[2];
97
- directionsMatrix[7] = directionsMatrix[7] * halfSize[2];
98
- directionsMatrix[8] = directionsMatrix[8] * halfSize[2];
99
- this.center = new Vector3().from(center);
100
- this.halfAxes = directionsMatrix;
101
- return this;
102
- }
103
-
104
69
  /** Duplicates a OrientedBoundingBox instance. */
105
70
  clone(): OrientedBoundingBox {
106
71
  return new OrientedBoundingBox(this.center, this.halfAxes);
@@ -5,7 +5,7 @@
5
5
  // SPDX-FileComment: Derived from Cesium. See the repository LICENSE for upstream attribution and Apache-2.0 terms.
6
6
 
7
7
  // This file is derived from the Cesium math library under Apache 2 license
8
- // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
8
+ // See ../../../LICENSE for the retained Cesium notice and Apache-2.0 terms.
9
9
 
10
10
  /* eslint-disable */
11
11
  import {Vector3, assert} from '@math.gl/core';
@@ -5,7 +5,7 @@
5
5
  // SPDX-FileComment: Derived from Cesium. See the repository LICENSE for upstream attribution and Apache-2.0 terms.
6
6
 
7
7
  // This file is derived from the Cesium math library under Apache 2 license
8
- // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
8
+ // See ../../../LICENSE for the retained Cesium notice and Apache-2.0 terms.
9
9
 
10
10
  // Note: This class is still an experimental export, mainly used by other test cases
11
11
  // - It has not been fully adapted to math.gl conventions
@@ -5,7 +5,7 @@
5
5
  // SPDX-FileComment: Derived from Cesium. See the repository LICENSE for upstream attribution and Apache-2.0 terms.
6
6
 
7
7
  // This file is derived from the Cesium math library under Apache 2 license
8
- // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
8
+ // See ../../../LICENSE for the retained Cesium notice and Apache-2.0 terms.
9
9
 
10
10
  // Note: This class is still an experimental export, mainly used by other test cases
11
11
  // - It has not been fully adapted to math.gl conventions
@@ -5,7 +5,7 @@
5
5
  // SPDX-FileComment: Derived from Cesium. See the repository LICENSE for upstream attribution and Apache-2.0 terms.
6
6
 
7
7
  // This file is derived from the Cesium math library under Apache 2 license
8
- // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
8
+ // See ../../../LICENSE for the retained Cesium notice and Apache-2.0 terms.
9
9
 
10
10
  /* eslint-disable */
11
11
  import {Vector3, equals, assert, NumericArray, _MathUtils} from '@math.gl/core';
@@ -5,7 +5,7 @@
5
5
  // SPDX-FileComment: Derived from Cesium. See the repository LICENSE for upstream attribution and Apache-2.0 terms.
6
6
 
7
7
  // This file is derived from the Cesium library under Apache 2 license
8
- // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
8
+ // See ../../../LICENSE for the retained Cesium notice and Apache-2.0 terms.
9
9
 
10
10
  import {Vector3} from '@math.gl/core';
11
11
 
package/src/index.ts CHANGED
@@ -10,6 +10,9 @@ export type {
10
10
  GeometryAttributes,
11
11
  PrimitiveTopology
12
12
  } from './lib/geometry';
13
+ export {HingeTree} from './lib/hinge-tree';
14
+ export type {HingePanel} from './lib/hinge-tree';
15
+
13
16
  export {unpackIndexedGeometry} from './lib/geometry-utils';
14
17
 
15
18
  export {BoxGeometry, CubeGeometry} from './geometries/box-geometry';
@@ -0,0 +1,170 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
4
+
5
+ import {Matrix4} from '@math.gl/core';
6
+ import type {NumericArray} from '@math.gl/core';
7
+
8
+ /** A rigid panel attached to its parent by a revolute joint. */
9
+ export type HingePanel = {
10
+ /** Parent index in the input array; -1 for a root. Input order is arbitrary. */
11
+ parent: number;
12
+ /** Child-local to parent-local transform at zero angle; defaults to identity. */
13
+ restTransform?: Readonly<NumericArray>;
14
+ /** Hinge pivot in parent-local coordinates. Required for nonroots. */
15
+ pivot?: readonly [number, number, number];
16
+ /** Right-handed rotation axis in parent-local coordinates; normalized internally. */
17
+ axis?: readonly [number, number, number];
18
+ };
19
+
20
+ type Joint = {
21
+ parent: number;
22
+ rest: Matrix4;
23
+ pivot: number[];
24
+ negativePivot: number[];
25
+ axis: number[];
26
+ };
27
+
28
+ /** Experimental rigid-panel kinematics, independent of mesh topology and rendering.
29
+ * Snapshots its inputs. Does not infer shared edges, solve closed loops or detect collisions.
30
+ */
31
+ export class HingeTree {
32
+ readonly panelCount: number;
33
+ private readonly joints: Joint[];
34
+ private readonly order: number[];
35
+ private readonly angles: Float64Array;
36
+ private readonly local = new Matrix4();
37
+ private readonly world = new Matrix4();
38
+ private readonly root = new Matrix4();
39
+
40
+ constructor(panels: readonly HingePanel[]) {
41
+ this.panelCount = panels.length;
42
+ const children: number[][] = panels.map(() => []);
43
+ const order: number[] = [];
44
+ this.joints = panels.map((panel, index) => {
45
+ const {parent} = panel;
46
+ if (!Number.isInteger(parent) || parent < -1 || parent >= panels.length || parent === index) {
47
+ throw new RangeError('Invalid hinge parent index');
48
+ }
49
+ if (parent === -1) order.push(index);
50
+ else children[parent].push(index);
51
+ const rest = new Matrix4();
52
+ if (panel.restTransform !== undefined) {
53
+ validateRigidTransform(panel.restTransform);
54
+ rest.copy(panel.restTransform);
55
+ }
56
+ const pivot = parent === -1 ? [0, 0, 0] : copyVector(panel.pivot);
57
+ const axis = parent === -1 ? [1, 0, 0] : copyVector(panel.axis);
58
+ const length = Math.hypot(...axis);
59
+ if (!Number.isFinite(length) || length === 0) throw new RangeError('Invalid hinge axis');
60
+ for (let i = 0; i < 3; i++) axis[i] /= length;
61
+ return {
62
+ parent,
63
+ rest,
64
+ pivot,
65
+ negativePivot: pivot.map(value => -value),
66
+ axis
67
+ };
68
+ });
69
+ // Iterative traversal supports deep trees without consuming the call stack.
70
+ for (let i = 0; i < order.length; i++) {
71
+ for (const child of children[order[i]]) order.push(child);
72
+ }
73
+ if (order.length !== panels.length) throw new RangeError('Hinge parents contain a cycle');
74
+ this.order = order;
75
+ this.angles = new Float64Array(panels.length);
76
+ }
77
+
78
+ /** Evaluate one angle per panel in radians (root angles must be zero).
79
+ * Returns column-major matrices in input-panel order, 16 doubles per panel.
80
+ * rootTransform places the whole forest; omitted means identity.
81
+ * Output may alias the inputs: angles and root transform are snapshotted first.
82
+ * Finite inputs that overflow during composition throw; output may then be partial.
83
+ */
84
+ evaluate(
85
+ angles: Readonly<NumericArray>,
86
+ output = new Float64Array(this.panelCount * 16),
87
+ rootTransform?: Readonly<NumericArray>
88
+ ): Float64Array {
89
+ if (angles.length !== this.panelCount) throw new RangeError('Expected one angle per panel');
90
+ if (!(output instanceof Float64Array) || output.length !== this.panelCount * 16) {
91
+ throw new RangeError('Expected 16 Float64 values per panel');
92
+ }
93
+ for (let i = 0; i < angles.length; i++) {
94
+ if (!Number.isFinite(angles[i]) || (this.joints[i].parent === -1 && angles[i] !== 0)) {
95
+ throw new RangeError('Expected finite angles and zero root angles');
96
+ }
97
+ this.angles[i] = angles[i];
98
+ }
99
+ this.root.identity();
100
+ if (rootTransform !== undefined) {
101
+ validateRigidTransform(rootTransform);
102
+ this.root.copy(rootTransform);
103
+ }
104
+ for (const index of this.order) {
105
+ const joint = this.joints[index];
106
+ this.local.identity();
107
+ if (joint.parent !== -1) {
108
+ this.local
109
+ .translate(joint.pivot)
110
+ .rotateAxis(this.angles[index], joint.axis)
111
+ .translate(joint.negativePivot);
112
+ }
113
+ this.local.multiplyRight(joint.rest);
114
+ if (joint.parent === -1) this.world.copy(this.root);
115
+ else {
116
+ for (let i = 0; i < 16; i++) this.world[i] = output[joint.parent * 16 + i];
117
+ }
118
+ this.world.multiplyRight(this.local);
119
+ for (let i = 0; i < 16; i++) {
120
+ if (!Number.isFinite(this.world[i])) throw new RangeError('Hinge transform overflow');
121
+ output[index * 16 + i] = this.world[i];
122
+ }
123
+ }
124
+ return output;
125
+ }
126
+ }
127
+
128
+ function copyVector(vector?: readonly number[]): number[] {
129
+ if (
130
+ !vector ||
131
+ vector.length !== 3 ||
132
+ !Number.isFinite(vector[0]) ||
133
+ !Number.isFinite(vector[1]) ||
134
+ !Number.isFinite(vector[2])
135
+ ) {
136
+ throw new RangeError('Expected a finite hinge pivot and axis');
137
+ }
138
+ return [...vector];
139
+ }
140
+
141
+ /** Accept proper rigid affine transforms, allowing numerical roundoff. */
142
+ function validateRigidTransform(matrix: Readonly<NumericArray>): void {
143
+ if (matrix.length !== 16) throw new RangeError('Expected a 4x4 rigid transform');
144
+ for (let i = 0; i < 16; i++) {
145
+ if (!Number.isFinite(matrix[i])) throw new RangeError('Expected a finite rigid transform');
146
+ }
147
+ const tolerance = 1e-6;
148
+ if (
149
+ Math.abs(matrix[3]) > tolerance ||
150
+ Math.abs(matrix[7]) > tolerance ||
151
+ Math.abs(matrix[11]) > tolerance ||
152
+ Math.abs(matrix[15] - 1) > tolerance
153
+ )
154
+ throw new RangeError('Expected an affine rigid transform');
155
+ for (let a = 0; a < 3; a++) {
156
+ for (let b = a; b < 3; b++) {
157
+ let dot = 0;
158
+ for (let row = 0; row < 3; row++) dot += matrix[a * 4 + row] * matrix[b * 4 + row];
159
+ if (Math.abs(dot - (a === b ? 1 : 0)) > tolerance) {
160
+ throw new RangeError('Rigid transforms cannot scale or shear');
161
+ }
162
+ }
163
+ }
164
+ const determinant =
165
+ matrix[0] * (matrix[5] * matrix[10] - matrix[6] * matrix[9]) -
166
+ matrix[4] * (matrix[1] * matrix[10] - matrix[2] * matrix[9]) +
167
+ matrix[8] * (matrix[1] * matrix[6] - matrix[2] * matrix[5]);
168
+ if (Math.abs(determinant - 1) > tolerance)
169
+ throw new RangeError('Rigid transforms cannot reflect');
170
+ }
@@ -21,7 +21,11 @@ export {cutPolygonByGrid, cutPolylineByGrid} from './cut-by-grid';
21
21
  export {cutPolylineByMercatorBounds, cutPolygonByMercatorBounds} from './cut-by-mercator-bounds';
22
22
 
23
23
  export {subdividePolyline} from './subdivide-polyline';
24
- export type {SubdividePolylineOptions, SubdividedPolyline} from './subdivide-polyline';
24
+ export type {
25
+ SubdividePolylineOptions,
26
+ SubdividedPolyline,
27
+ PolylineEdgeSampler
28
+ } from './subdivide-polyline';
25
29
 
26
30
  export {subdivideTriangleMesh} from './subdivide-triangle-mesh';
27
31
  export type {