@math.gl/core 4.0.0 → 4.0.1

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 (124) hide show
  1. package/dist/classes/base/math-array.d.ts +1 -2
  2. package/dist/classes/base/math-array.js +220 -266
  3. package/dist/classes/base/matrix.d.ts +1 -2
  4. package/dist/classes/base/matrix.js +52 -53
  5. package/dist/classes/base/vector.d.ts +1 -2
  6. package/dist/classes/base/vector.js +121 -135
  7. package/dist/classes/euler.d.ts +2 -3
  8. package/dist/classes/euler.js +462 -533
  9. package/dist/classes/matrix3.d.ts +2 -3
  10. package/dist/classes/matrix3.js +185 -190
  11. package/dist/classes/matrix4.d.ts +1 -2
  12. package/dist/classes/matrix4.js +516 -452
  13. package/dist/classes/pose.d.ts +4 -5
  14. package/dist/classes/pose.js +104 -119
  15. package/dist/classes/quaternion.d.ts +1 -2
  16. package/dist/classes/quaternion.js +257 -233
  17. package/dist/classes/spherical-coordinates.d.ts +3 -4
  18. package/dist/classes/spherical-coordinates.js +138 -147
  19. package/dist/classes/vector2.d.ts +1 -2
  20. package/dist/classes/vector2.js +101 -85
  21. package/dist/classes/vector3.d.ts +1 -2
  22. package/dist/classes/vector3.js +125 -136
  23. package/dist/classes/vector4.d.ts +2 -3
  24. package/dist/classes/vector4.js +106 -114
  25. package/dist/gl-matrix/common.d.ts +0 -1
  26. package/dist/gl-matrix/common.js +38 -6
  27. package/dist/gl-matrix/mat3.d.ts +0 -1
  28. package/dist/gl-matrix/mat3.js +699 -425
  29. package/dist/gl-matrix/mat4.d.ts +0 -1
  30. package/dist/gl-matrix/mat4.js +1879 -1339
  31. package/dist/gl-matrix/quat.d.ts +0 -1
  32. package/dist/gl-matrix/quat.js +655 -257
  33. package/dist/gl-matrix/vec2.d.ts +0 -1
  34. package/dist/gl-matrix/vec2.js +529 -212
  35. package/dist/gl-matrix/vec3.d.ts +0 -1
  36. package/dist/gl-matrix/vec3.js +703 -335
  37. package/dist/gl-matrix/vec4.d.ts +0 -1
  38. package/dist/gl-matrix/vec4.js +579 -293
  39. package/dist/gl-matrix/wip/index.d.ts +3 -4
  40. package/dist/gl-matrix/wip/index.js +2 -1
  41. package/dist/gl-matrix/wip/mat2.d.ts +0 -1
  42. package/dist/gl-matrix/wip/mat2.js +333 -157
  43. package/dist/gl-matrix/wip/mat2d.d.ts +0 -1
  44. package/dist/gl-matrix/wip/mat2d.js +377 -202
  45. package/dist/gl-matrix/wip/quat2.d.ts +0 -1
  46. package/dist/gl-matrix/wip/quat2.js +647 -409
  47. package/dist/index.cjs +60 -100
  48. package/dist/index.cjs.map +7 -0
  49. package/dist/index.d.ts +21 -22
  50. package/dist/index.js +23 -16
  51. package/dist/lib/assert.d.ts +0 -1
  52. package/dist/lib/assert.js +3 -4
  53. package/dist/lib/common.d.ts +2 -3
  54. package/dist/lib/common.js +163 -134
  55. package/dist/lib/gl-matrix-extras.d.ts +0 -1
  56. package/dist/lib/gl-matrix-extras.js +39 -36
  57. package/dist/lib/math-utils.d.ts +0 -1
  58. package/dist/lib/math-utils.js +2 -1
  59. package/dist/lib/validators.d.ts +0 -1
  60. package/dist/lib/validators.js +22 -25
  61. package/package.json +5 -6
  62. package/src/classes/matrix3.ts +1 -1
  63. package/dist/classes/base/math-array.d.ts.map +0 -1
  64. package/dist/classes/base/math-array.js.map +0 -1
  65. package/dist/classes/base/matrix.d.ts.map +0 -1
  66. package/dist/classes/base/matrix.js.map +0 -1
  67. package/dist/classes/base/vector.d.ts.map +0 -1
  68. package/dist/classes/base/vector.js.map +0 -1
  69. package/dist/classes/euler.d.ts.map +0 -1
  70. package/dist/classes/euler.js.map +0 -1
  71. package/dist/classes/matrix3.d.ts.map +0 -1
  72. package/dist/classes/matrix3.js.map +0 -1
  73. package/dist/classes/matrix4.d.ts.map +0 -1
  74. package/dist/classes/matrix4.js.map +0 -1
  75. package/dist/classes/pose.d.ts.map +0 -1
  76. package/dist/classes/pose.js.map +0 -1
  77. package/dist/classes/quaternion.d.ts.map +0 -1
  78. package/dist/classes/quaternion.js.map +0 -1
  79. package/dist/classes/spherical-coordinates.d.ts.map +0 -1
  80. package/dist/classes/spherical-coordinates.js.map +0 -1
  81. package/dist/classes/vector2.d.ts.map +0 -1
  82. package/dist/classes/vector2.js.map +0 -1
  83. package/dist/classes/vector3.d.ts.map +0 -1
  84. package/dist/classes/vector3.js.map +0 -1
  85. package/dist/classes/vector4.d.ts.map +0 -1
  86. package/dist/classes/vector4.js.map +0 -1
  87. package/dist/gl-matrix/common.d.ts.map +0 -1
  88. package/dist/gl-matrix/common.js.map +0 -1
  89. package/dist/gl-matrix/mat3.d.ts.map +0 -1
  90. package/dist/gl-matrix/mat3.js.map +0 -1
  91. package/dist/gl-matrix/mat4.d.ts.map +0 -1
  92. package/dist/gl-matrix/mat4.js.map +0 -1
  93. package/dist/gl-matrix/quat.d.ts.map +0 -1
  94. package/dist/gl-matrix/quat.js.map +0 -1
  95. package/dist/gl-matrix/vec2.d.ts.map +0 -1
  96. package/dist/gl-matrix/vec2.js.map +0 -1
  97. package/dist/gl-matrix/vec3.d.ts.map +0 -1
  98. package/dist/gl-matrix/vec3.js.map +0 -1
  99. package/dist/gl-matrix/vec4.d.ts.map +0 -1
  100. package/dist/gl-matrix/vec4.js.map +0 -1
  101. package/dist/gl-matrix/wip/index.d.ts.map +0 -1
  102. package/dist/gl-matrix/wip/index.js.map +0 -1
  103. package/dist/gl-matrix/wip/mat2.d.ts.map +0 -1
  104. package/dist/gl-matrix/wip/mat2.js.map +0 -1
  105. package/dist/gl-matrix/wip/mat2d.d.ts.map +0 -1
  106. package/dist/gl-matrix/wip/mat2d.js.map +0 -1
  107. package/dist/gl-matrix/wip/quat2.d.ts.map +0 -1
  108. package/dist/gl-matrix/wip/quat2.js.map +0 -1
  109. package/dist/gl-matrix/wip/types.d.js +0 -2
  110. package/dist/gl-matrix/wip/types.d.js.map +0 -1
  111. package/dist/index.d.ts.map +0 -1
  112. package/dist/index.js.map +0 -1
  113. package/dist/lib/assert.d.ts.map +0 -1
  114. package/dist/lib/assert.js.map +0 -1
  115. package/dist/lib/common.d.ts.map +0 -1
  116. package/dist/lib/common.js.map +0 -1
  117. package/dist/lib/gl-matrix-extras.d.ts.map +0 -1
  118. package/dist/lib/gl-matrix-extras.js.map +0 -1
  119. package/dist/lib/gl-matrix.d.js +0 -2
  120. package/dist/lib/gl-matrix.d.js.map +0 -1
  121. package/dist/lib/math-utils.d.ts.map +0 -1
  122. package/dist/lib/math-utils.js.map +0 -1
  123. package/dist/lib/validators.d.ts.map +0 -1
  124. package/dist/lib/validators.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,30 +1,29 @@
1
1
  export type { TypedArray, NumericArray } from '@math.gl/types';
2
2
  export type { isTypedArray, isNumericArray } from '@math.gl/types';
3
- export { Vector2 } from './classes/vector2';
4
- export { Vector3 } from './classes/vector3';
5
- export { Vector4 } from './classes/vector4';
6
- export { Matrix3 } from './classes/matrix3';
7
- export { Matrix4 } from './classes/matrix4';
8
- export { Quaternion } from './classes/quaternion';
9
- export { SphericalCoordinates } from './classes/spherical-coordinates';
10
- export { Pose } from './classes/pose';
11
- export { Euler } from './classes/euler';
12
- export * as _MathUtils from './lib/math-utils';
13
- export { assert } from './lib/assert';
14
- export { config, configure, formatValue, isArray, clone, equals, exactEquals, toRadians, toDegrees, radians, degrees, sin, cos, tan, asin, acos, atan, clamp, lerp, withEpsilon } from './lib/common';
15
- export { SphericalCoordinates as _SphericalCoordinates } from './classes/spherical-coordinates';
16
- export { Pose as _Pose } from './classes/pose';
17
- export { Euler as _Euler } from './classes/euler';
3
+ export { Vector2 } from "./classes/vector2.js";
4
+ export { Vector3 } from "./classes/vector3.js";
5
+ export { Vector4 } from "./classes/vector4.js";
6
+ export { Matrix3 } from "./classes/matrix3.js";
7
+ export { Matrix4 } from "./classes/matrix4.js";
8
+ export { Quaternion } from "./classes/quaternion.js";
9
+ export { SphericalCoordinates } from "./classes/spherical-coordinates.js";
10
+ export { Pose } from "./classes/pose.js";
11
+ export { Euler } from "./classes/euler.js";
12
+ export * as _MathUtils from "./lib/math-utils.js";
13
+ export { assert } from "./lib/assert.js";
14
+ export { config, configure, formatValue, isArray, clone, equals, exactEquals, toRadians, toDegrees, radians, degrees, sin, cos, tan, asin, acos, atan, clamp, lerp, withEpsilon } from "./lib/common.js";
15
+ export { SphericalCoordinates as _SphericalCoordinates } from "./classes/spherical-coordinates.js";
16
+ export { Pose as _Pose } from "./classes/pose.js";
17
+ export { Euler as _Euler } from "./classes/euler.js";
18
18
  /** @deprecated Use Matrix3 */
19
- export * as mat3 from './gl-matrix/mat3';
19
+ export * as mat3 from "./gl-matrix/mat3.js";
20
20
  /** @deprecated Use Matrix4 */
21
- export * as mat4 from './gl-matrix/mat4';
21
+ export * as mat4 from "./gl-matrix/mat4.js";
22
22
  /** @deprecated Use Quaterinion */
23
- export * as quat from './gl-matrix/quat';
23
+ export * as quat from "./gl-matrix/quat.js";
24
24
  /** @deprecated UseVector */
25
- export * as vec2 from './gl-matrix/vec2';
25
+ export * as vec2 from "./gl-matrix/vec2.js";
26
26
  /** @deprecated Use Vector3 */
27
- export * as vec3 from './gl-matrix/vec3';
27
+ export * as vec3 from "./gl-matrix/vec3.js";
28
28
  /** @deprecated Use Vector4 */
29
- export * as vec4 from './gl-matrix/vec4';
30
- //# sourceMappingURL=index.d.ts.map
29
+ export * as vec4 from "./gl-matrix/vec4.js";
package/dist/index.js CHANGED
@@ -1,29 +1,36 @@
1
+ // luma.gl, MIT license
2
+ // classes
1
3
  export { Vector2 } from "./classes/vector2.js";
2
4
  export { Vector3 } from "./classes/vector3.js";
3
5
  export { Vector4 } from "./classes/vector4.js";
4
6
  export { Matrix3 } from "./classes/matrix3.js";
5
7
  export { Matrix4 } from "./classes/matrix4.js";
6
8
  export { Quaternion } from "./classes/quaternion.js";
9
+ // experimental
7
10
  export { SphericalCoordinates } from "./classes/spherical-coordinates.js";
8
11
  export { Pose } from "./classes/pose.js";
9
12
  export { Euler } from "./classes/euler.js";
10
- import * as _MathUtils from "./lib/math-utils.js";
11
- export { _MathUtils };
13
+ export * as _MathUtils from "./lib/math-utils.js";
14
+ // lib
12
15
  export { assert } from "./lib/assert.js";
13
- export { config, configure, formatValue, isArray, clone, equals, exactEquals, toRadians, toDegrees, radians, degrees, sin, cos, tan, asin, acos, atan, clamp, lerp, withEpsilon } from "./lib/common.js";
16
+ export {
17
+ // math.gl global utility methods
18
+ config, configure, formatValue, isArray, clone, equals, exactEquals, toRadians, toDegrees,
19
+ // math.gl "GLSL"-style functions
20
+ radians, degrees, sin, cos, tan, asin, acos, atan, clamp, lerp, withEpsilon } from "./lib/common.js";
21
+ // DEPRECATED
14
22
  export { SphericalCoordinates as _SphericalCoordinates } from "./classes/spherical-coordinates.js";
15
23
  export { Pose as _Pose } from "./classes/pose.js";
16
24
  export { Euler as _Euler } from "./classes/euler.js";
17
- import * as _mat from "./gl-matrix/mat3.js";
18
- export { _mat as mat3 };
19
- import * as _mat2 from "./gl-matrix/mat4.js";
20
- export { _mat2 as mat4 };
21
- import * as _quat from "./gl-matrix/quat.js";
22
- export { _quat as quat };
23
- import * as _vec from "./gl-matrix/vec2.js";
24
- export { _vec as vec2 };
25
- import * as _vec2 from "./gl-matrix/vec3.js";
26
- export { _vec2 as vec3 };
27
- import * as _vec3 from "./gl-matrix/vec4.js";
28
- export { _vec3 as vec4 };
29
- //# sourceMappingURL=index.js.map
25
+ /** @deprecated Use Matrix3 */
26
+ export * as mat3 from "./gl-matrix/mat3.js";
27
+ /** @deprecated Use Matrix4 */
28
+ export * as mat4 from "./gl-matrix/mat4.js";
29
+ /** @deprecated Use Quaterinion */
30
+ export * as quat from "./gl-matrix/quat.js";
31
+ /** @deprecated UseVector */
32
+ export * as vec2 from "./gl-matrix/vec2.js";
33
+ /** @deprecated Use Vector3 */
34
+ export * as vec3 from "./gl-matrix/vec3.js";
35
+ /** @deprecated Use Vector4 */
36
+ export * as vec4 from "./gl-matrix/vec4.js";
@@ -1,2 +1 @@
1
1
  export declare function assert(condition: unknown, message?: string): void;
2
- //# sourceMappingURL=assert.d.ts.map
@@ -1,6 +1,5 @@
1
1
  export function assert(condition, message) {
2
- if (!condition) {
3
- throw new Error("math.gl assertion ".concat(message));
4
- }
2
+ if (!condition) {
3
+ throw new Error(`math.gl assertion ${message}`);
4
+ }
5
5
  }
6
- //# sourceMappingURL=assert.js.map
@@ -1,6 +1,6 @@
1
1
  import type { NumericArray } from '@math.gl/types';
2
- import type { MathArray } from '../classes/base/math-array';
3
- export declare type ConfigurationOptions = {
2
+ import type { MathArray } from "../classes/base/math-array.js";
3
+ export type ConfigurationOptions = {
4
4
  EPSILON: number;
5
5
  debug?: boolean;
6
6
  precision: number;
@@ -97,4 +97,3 @@ export declare function lerp(a: NumericArray, b: NumericArray, t: number): Numer
97
97
  export declare function equals(a: any, b: any, epsilon?: number): boolean;
98
98
  export declare function exactEquals(a: any, b: any): boolean;
99
99
  export declare function withEpsilon<T>(epsilon: number, func: () => T): T;
100
- //# sourceMappingURL=common.d.ts.map
@@ -1,184 +1,213 @@
1
- const RADIANS_TO_DEGREES = 1 / Math.PI * 180;
2
- const DEGREES_TO_RADIANS = 1 / 180 * Math.PI;
1
+ // math.gl, MIT license
2
+ const RADIANS_TO_DEGREES = (1 / Math.PI) * 180;
3
+ const DEGREES_TO_RADIANS = (1 / 180) * Math.PI;
3
4
  const DEFAULT_CONFIG = {
4
- EPSILON: 1e-12,
5
- debug: false,
6
- precision: 4,
7
- printTypes: false,
8
- printDegrees: false,
9
- printRowMajor: true,
10
- _cartographicRadians: false
11
- };
12
- globalThis.mathgl = globalThis.mathgl || {
13
- config: { ...DEFAULT_CONFIG
14
- }
5
+ EPSILON: 1e-12,
6
+ debug: false,
7
+ precision: 4,
8
+ printTypes: false,
9
+ printDegrees: false,
10
+ printRowMajor: true,
11
+ _cartographicRadians: false
15
12
  };
13
+ // Configuration is truly global as of v3.6 to ensure single config even if multiple copies of math.gl
14
+ // Multiple copies of config can be quite tricky to debug...
15
+ globalThis.mathgl = globalThis.mathgl || { config: { ...DEFAULT_CONFIG } };
16
16
  export const config = globalThis.mathgl.config;
17
17
  export function configure(options) {
18
- Object.assign(config, options);
19
- return config;
20
- }
21
- export function formatValue(value, {
22
- precision = config.precision
23
- } = {}) {
24
- value = round(value);
25
- return "".concat(parseFloat(value.toPrecision(precision)));
26
- }
18
+ // Only copy existing keys
19
+ Object.assign(config, options);
20
+ return config;
21
+ }
22
+ /**
23
+ * Formats a value into a string
24
+ * @param value
25
+ * @param param1
26
+ * @returns
27
+ */
28
+ export function formatValue(value, { precision = config.precision } = {}) {
29
+ value = round(value);
30
+ // get rid of trailing zeros
31
+ return `${parseFloat(value.toPrecision(precision))}`;
32
+ }
33
+ /**
34
+ * Check if value is an "array"
35
+ * Returns `true` if value is either an array or a typed array
36
+ * Note: returns `false` for `ArrayBuffer` and `DataView` instances
37
+ * @note isTypedArray and isNumericArray are often more useful in TypeScript
38
+ */
27
39
  export function isArray(value) {
28
- return Array.isArray(value) || ArrayBuffer.isView(value) && !(value instanceof DataView);
40
+ return Array.isArray(value) || (ArrayBuffer.isView(value) && !(value instanceof DataView));
29
41
  }
30
42
  export function clone(array) {
31
- return 'clone' in array ? array.clone() : array.slice();
43
+ return 'clone' in array ? array.clone() : array.slice();
32
44
  }
33
45
  export function toRadians(degrees) {
34
- return radians(degrees);
46
+ return radians(degrees);
35
47
  }
36
48
  export function toDegrees(radians) {
37
- return degrees(radians);
49
+ return degrees(radians);
38
50
  }
39
51
  export function radians(degrees, result) {
40
- return map(degrees, degrees => degrees * DEGREES_TO_RADIANS, result);
52
+ return map(degrees, (degrees) => degrees * DEGREES_TO_RADIANS, result);
41
53
  }
42
54
  export function degrees(radians, result) {
43
- return map(radians, radians => radians * RADIANS_TO_DEGREES, result);
55
+ return map(radians, (radians) => radians * RADIANS_TO_DEGREES, result);
44
56
  }
57
+ /**
58
+ * "GLSL equivalent" of `Math.sin`: Works on single values and vectors
59
+ * @deprecated
60
+ */
45
61
  export function sin(radians, result) {
46
- return map(radians, angle => Math.sin(angle), result);
62
+ return map(radians, (angle) => Math.sin(angle), result);
47
63
  }
64
+ /**
65
+ * "GLSL equivalent" of `Math.cos`: Works on single values and vectors
66
+ * @deprecated
67
+ */
48
68
  export function cos(radians, result) {
49
- return map(radians, angle => Math.cos(angle), result);
69
+ return map(radians, (angle) => Math.cos(angle), result);
50
70
  }
71
+ /**
72
+ * "GLSL equivalent" of `Math.tan`: Works on single values and vectors
73
+ * @deprecated
74
+ */
51
75
  export function tan(radians, result) {
52
- return map(radians, angle => Math.tan(angle), result);
76
+ return map(radians, (angle) => Math.tan(angle), result);
53
77
  }
78
+ /**
79
+ * "GLSL equivalent" of `Math.asin`: Works on single values and vectors
80
+ * @deprecated
81
+ */
54
82
  export function asin(radians, result) {
55
- return map(radians, angle => Math.asin(angle), result);
83
+ return map(radians, (angle) => Math.asin(angle), result);
56
84
  }
85
+ /**
86
+ * "GLSL equivalent" of `Math.acos`: Works on single values and vectors
87
+ * @deprecated
88
+ */
57
89
  export function acos(radians, result) {
58
- return map(radians, angle => Math.acos(angle), result);
90
+ return map(radians, (angle) => Math.acos(angle), result);
59
91
  }
92
+ /**
93
+ * "GLSL equivalent" of `Math.atan`: Works on single values and vectors
94
+ * @deprecated
95
+ */
60
96
  export function atan(radians, result) {
61
- return map(radians, angle => Math.atan(angle), result);
97
+ return map(radians, (angle) => Math.atan(angle), result);
62
98
  }
63
99
  export function clamp(value, min, max) {
64
- return map(value, value => Math.max(min, Math.min(max, value)));
100
+ return map(value, (value) => Math.max(min, Math.min(max, value)));
65
101
  }
66
102
  export function lerp(a, b, t) {
67
- if (isArray(a)) {
68
- return a.map((ai, i) => lerp(ai, b[i], t));
69
- }
70
-
71
- return t * b + (1 - t) * a;
72
- }
103
+ if (isArray(a)) {
104
+ return a.map((ai, i) => lerp(ai, b[i], t));
105
+ }
106
+ return t * b + (1 - t) * a;
107
+ }
108
+ /* eslint-disable */
109
+ /**
110
+ * Compares any two math objects, using `equals` method if available.
111
+ * @param a
112
+ * @param b
113
+ * @param epsilon
114
+ * @returns
115
+ */
73
116
  export function equals(a, b, epsilon) {
74
- const oldEpsilon = config.EPSILON;
75
-
76
- if (epsilon) {
77
- config.EPSILON = epsilon;
78
- }
79
-
80
- try {
81
- if (a === b) {
82
- return true;
117
+ const oldEpsilon = config.EPSILON;
118
+ if (epsilon) {
119
+ config.EPSILON = epsilon;
83
120
  }
84
-
85
- if (isArray(a) && isArray(b)) {
86
- if (a.length !== b.length) {
87
- return false;
88
- }
89
-
90
- for (let i = 0; i < a.length; ++i) {
91
- if (!equals(a[i], b[i])) {
92
- return false;
121
+ try {
122
+ if (a === b) {
123
+ return true;
93
124
  }
94
- }
95
-
96
- return true;
97
- }
98
-
99
- if (a && a.equals) {
100
- return a.equals(b);
101
- }
102
-
103
- if (b && b.equals) {
104
- return b.equals(a);
125
+ if (isArray(a) && isArray(b)) {
126
+ if (a.length !== b.length) {
127
+ return false;
128
+ }
129
+ for (let i = 0; i < a.length; ++i) {
130
+ // eslint-disable-next-line max-depth
131
+ if (!equals(a[i], b[i])) {
132
+ return false;
133
+ }
134
+ }
135
+ return true;
136
+ }
137
+ if (a && a.equals) {
138
+ return a.equals(b);
139
+ }
140
+ if (b && b.equals) {
141
+ return b.equals(a);
142
+ }
143
+ if (typeof a === 'number' && typeof b === 'number') {
144
+ return Math.abs(a - b) <= config.EPSILON * Math.max(1, Math.abs(a), Math.abs(b));
145
+ }
146
+ return false;
105
147
  }
106
-
107
- if (typeof a === 'number' && typeof b === 'number') {
108
- return Math.abs(a - b) <= config.EPSILON * Math.max(1, Math.abs(a), Math.abs(b));
148
+ finally {
149
+ config.EPSILON = oldEpsilon;
109
150
  }
110
-
111
- return false;
112
- } finally {
113
- config.EPSILON = oldEpsilon;
114
- }
115
151
  }
116
152
  export function exactEquals(a, b) {
117
- if (a === b) {
118
- return true;
119
- }
120
-
121
- if (a && typeof a === 'object' && b && typeof b === 'object') {
122
- if (a.constructor !== b.constructor) {
123
- return false;
124
- }
125
-
126
- if (a.exactEquals) {
127
- return a.exactEquals(b);
153
+ if (a === b) {
154
+ return true;
128
155
  }
129
- }
130
-
131
- if (isArray(a) && isArray(b)) {
132
- if (a.length !== b.length) {
133
- return false;
156
+ if (a && typeof a === 'object' && b && typeof b === 'object') {
157
+ if (a.constructor !== b.constructor) {
158
+ return false;
159
+ }
160
+ if (a.exactEquals) {
161
+ return a.exactEquals(b);
162
+ }
134
163
  }
135
-
136
- for (let i = 0; i < a.length; ++i) {
137
- if (!exactEquals(a[i], b[i])) {
138
- return false;
139
- }
164
+ if (isArray(a) && isArray(b)) {
165
+ if (a.length !== b.length) {
166
+ return false;
167
+ }
168
+ for (let i = 0; i < a.length; ++i) {
169
+ if (!exactEquals(a[i], b[i])) {
170
+ return false;
171
+ }
172
+ }
173
+ return true;
140
174
  }
141
-
142
- return true;
143
- }
144
-
145
- return false;
175
+ return false;
146
176
  }
177
+ /* eslint-enable */
147
178
  export function withEpsilon(epsilon, func) {
148
- const oldPrecision = config.EPSILON;
149
- config.EPSILON = epsilon;
150
- let value;
151
-
152
- try {
153
- value = func();
154
- } finally {
155
- config.EPSILON = oldPrecision;
156
- }
157
-
158
- return value;
159
- }
160
-
179
+ const oldPrecision = config.EPSILON;
180
+ config.EPSILON = epsilon;
181
+ let value;
182
+ try {
183
+ value = func();
184
+ }
185
+ finally {
186
+ config.EPSILON = oldPrecision;
187
+ }
188
+ return value;
189
+ }
190
+ // HELPERS
161
191
  function round(value) {
162
- return Math.round(value / config.EPSILON) * config.EPSILON;
192
+ return Math.round(value / config.EPSILON) * config.EPSILON;
163
193
  }
164
-
194
+ // If the array has a clone function, calls it, otherwise returns a copy
165
195
  function duplicateArray(array) {
166
- return array.clone ? array.clone() : new Array(array.length);
196
+ // @ts-expect-error We check for math.gl class methods
197
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
198
+ return array.clone ? array.clone() : new Array(array.length);
167
199
  }
168
-
200
+ // If the argument value is an array, applies the func element wise,
201
+ // otherwise applies func to the argument value
169
202
  function map(value, func, result) {
170
- if (isArray(value)) {
171
- const array = value;
172
- result = result || duplicateArray(array);
173
-
174
- for (let i = 0; i < result.length && i < array.length; ++i) {
175
- const val = typeof value === 'number' ? value : value[i];
176
- result[i] = func(val, i, result);
203
+ if (isArray(value)) {
204
+ const array = value;
205
+ result = result || duplicateArray(array);
206
+ for (let i = 0; i < result.length && i < array.length; ++i) {
207
+ const val = typeof value === 'number' ? value : value[i];
208
+ result[i] = func(val, i, result);
209
+ }
210
+ return result;
177
211
  }
178
-
179
- return result;
180
- }
181
-
182
- return func(value);
212
+ return func(value);
183
213
  }
184
- //# sourceMappingURL=common.js.map
@@ -4,4 +4,3 @@ export declare function vec3_transformMat4AsVector<T extends NumericArray>(out:
4
4
  export declare function vec3_transformMat2<T extends NumericArray>(out: T, a: Readonly<NumericArray>, m: Readonly<NumericArray>): T;
5
5
  export declare function vec4_transformMat2<T extends NumericArray>(out: T, a: Readonly<NumericArray>, m: Readonly<NumericArray>): T;
6
6
  export declare function vec4_transformMat3<T extends NumericArray>(out: T, a: Readonly<NumericArray>, m: Readonly<NumericArray>): T;
7
- //# sourceMappingURL=gl-matrix-extras.d.ts.map
@@ -1,46 +1,49 @@
1
+ // vec2 additions
1
2
  export function vec2_transformMat4AsVector(out, a, m) {
2
- const x = a[0];
3
- const y = a[1];
4
- const w = m[3] * x + m[7] * y || 1.0;
5
- out[0] = (m[0] * x + m[4] * y) / w;
6
- out[1] = (m[1] * x + m[5] * y) / w;
7
- return out;
3
+ const x = a[0];
4
+ const y = a[1];
5
+ const w = m[3] * x + m[7] * y || 1.0;
6
+ out[0] = (m[0] * x + m[4] * y) / w;
7
+ out[1] = (m[1] * x + m[5] * y) / w;
8
+ return out;
8
9
  }
10
+ // vec3 additions
11
+ // Transform as vector, only uses 3x3 minor matrix
9
12
  export function vec3_transformMat4AsVector(out, a, m) {
10
- const x = a[0];
11
- const y = a[1];
12
- const z = a[2];
13
- const w = m[3] * x + m[7] * y + m[11] * z || 1.0;
14
- out[0] = (m[0] * x + m[4] * y + m[8] * z) / w;
15
- out[1] = (m[1] * x + m[5] * y + m[9] * z) / w;
16
- out[2] = (m[2] * x + m[6] * y + m[10] * z) / w;
17
- return out;
13
+ const x = a[0];
14
+ const y = a[1];
15
+ const z = a[2];
16
+ const w = m[3] * x + m[7] * y + m[11] * z || 1.0;
17
+ out[0] = (m[0] * x + m[4] * y + m[8] * z) / w;
18
+ out[1] = (m[1] * x + m[5] * y + m[9] * z) / w;
19
+ out[2] = (m[2] * x + m[6] * y + m[10] * z) / w;
20
+ return out;
18
21
  }
19
22
  export function vec3_transformMat2(out, a, m) {
20
- const x = a[0];
21
- const y = a[1];
22
- out[0] = m[0] * x + m[2] * y;
23
- out[1] = m[1] * x + m[3] * y;
24
- out[2] = a[2];
25
- return out;
23
+ const x = a[0];
24
+ const y = a[1];
25
+ out[0] = m[0] * x + m[2] * y;
26
+ out[1] = m[1] * x + m[3] * y;
27
+ out[2] = a[2];
28
+ return out;
26
29
  }
30
+ // vec4 additions
27
31
  export function vec4_transformMat2(out, a, m) {
28
- const x = a[0];
29
- const y = a[1];
30
- out[0] = m[0] * x + m[2] * y;
31
- out[1] = m[1] * x + m[3] * y;
32
- out[2] = a[2];
33
- out[3] = a[3];
34
- return out;
32
+ const x = a[0];
33
+ const y = a[1];
34
+ out[0] = m[0] * x + m[2] * y;
35
+ out[1] = m[1] * x + m[3] * y;
36
+ out[2] = a[2];
37
+ out[3] = a[3];
38
+ return out;
35
39
  }
36
40
  export function vec4_transformMat3(out, a, m) {
37
- const x = a[0];
38
- const y = a[1];
39
- const z = a[2];
40
- out[0] = m[0] * x + m[3] * y + m[6] * z;
41
- out[1] = m[1] * x + m[4] * y + m[7] * z;
42
- out[2] = m[2] * x + m[5] * y + m[8] * z;
43
- out[3] = a[3];
44
- return out;
41
+ const x = a[0];
42
+ const y = a[1];
43
+ const z = a[2];
44
+ out[0] = m[0] * x + m[3] * y + m[6] * z;
45
+ out[1] = m[1] * x + m[4] * y + m[7] * z;
46
+ out[2] = m[2] * x + m[5] * y + m[8] * z;
47
+ out[3] = a[3];
48
+ return out;
45
49
  }
46
- //# sourceMappingURL=gl-matrix-extras.js.map
@@ -22,4 +22,3 @@ export declare const PI_OVER_TWO: number;
22
22
  export declare const PI_OVER_FOUR: number;
23
23
  export declare const PI_OVER_SIX: number;
24
24
  export declare const TWO_PI: number;
25
- //# sourceMappingURL=math-utils.d.ts.map
@@ -1,3 +1,5 @@
1
+ // NOTE: Added to make Cesium-derived test cases work
2
+ // TODO: Determine if/how to keep
1
3
  export const EPSILON1 = 1e-1;
2
4
  export const EPSILON2 = 1e-2;
3
5
  export const EPSILON3 = 1e-3;
@@ -22,4 +24,3 @@ export const PI_OVER_TWO = Math.PI / 2;
22
24
  export const PI_OVER_FOUR = Math.PI / 4;
23
25
  export const PI_OVER_SIX = Math.PI / 6;
24
26
  export const TWO_PI = Math.PI * 2;
25
- //# sourceMappingURL=math-utils.js.map
@@ -3,4 +3,3 @@ export declare function validateVector(v: NumberArray, length: number): boolean;
3
3
  export declare function checkNumber(value: unknown): number;
4
4
  export declare function checkVector<T extends NumberArray>(v: T, length: number, callerName?: string): T;
5
5
  export declare function deprecated(method: string, version: string): void;
6
- //# sourceMappingURL=validators.d.ts.map
@@ -1,36 +1,33 @@
1
1
  import { config } from "./common.js";
2
2
  export function validateVector(v, length) {
3
- if (v.length !== length) {
4
- return false;
5
- }
6
-
7
- for (let i = 0; i < v.length; ++i) {
8
- if (!Number.isFinite(v[i])) {
9
- return false;
3
+ if (v.length !== length) {
4
+ return false;
10
5
  }
11
- }
12
-
13
- return true;
6
+ // Could be arguments "array" (v.every not availasble)
7
+ for (let i = 0; i < v.length; ++i) {
8
+ if (!Number.isFinite(v[i])) {
9
+ return false;
10
+ }
11
+ }
12
+ return true;
14
13
  }
15
14
  export function checkNumber(value) {
16
- if (!Number.isFinite(value)) {
17
- throw new Error("Invalid number ".concat(JSON.stringify(value)));
18
- }
19
-
20
- return value;
15
+ if (!Number.isFinite(value)) {
16
+ throw new Error(`Invalid number ${JSON.stringify(value)}`);
17
+ }
18
+ return value;
21
19
  }
22
20
  export function checkVector(v, length, callerName = '') {
23
- if (config.debug && !validateVector(v, length)) {
24
- throw new Error("math.gl: ".concat(callerName, " some fields set to invalid numbers'"));
25
- }
26
-
27
- return v;
21
+ if (config.debug && !validateVector(v, length)) {
22
+ throw new Error(`math.gl: ${callerName} some fields set to invalid numbers'`);
23
+ }
24
+ return v;
28
25
  }
29
26
  const map = {};
30
27
  export function deprecated(method, version) {
31
- if (!map[method]) {
32
- map[method] = true;
33
- console.warn("".concat(method, " has been removed in version ").concat(version, ", see upgrade guide for more information"));
34
- }
28
+ if (!map[method]) {
29
+ map[method] = true;
30
+ // eslint-disable-next-line
31
+ console.warn(`${method} has been removed in version ${version}, see upgrade guide for more information`);
32
+ }
35
33
  }
36
- //# sourceMappingURL=validators.js.map