@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.
- package/dist/classes/base/math-array.d.ts +1 -2
- package/dist/classes/base/math-array.js +220 -266
- package/dist/classes/base/matrix.d.ts +1 -2
- package/dist/classes/base/matrix.js +52 -53
- package/dist/classes/base/vector.d.ts +1 -2
- package/dist/classes/base/vector.js +121 -135
- package/dist/classes/euler.d.ts +2 -3
- package/dist/classes/euler.js +462 -533
- package/dist/classes/matrix3.d.ts +2 -3
- package/dist/classes/matrix3.js +185 -190
- package/dist/classes/matrix4.d.ts +1 -2
- package/dist/classes/matrix4.js +516 -452
- package/dist/classes/pose.d.ts +4 -5
- package/dist/classes/pose.js +104 -119
- package/dist/classes/quaternion.d.ts +1 -2
- package/dist/classes/quaternion.js +257 -233
- package/dist/classes/spherical-coordinates.d.ts +3 -4
- package/dist/classes/spherical-coordinates.js +138 -147
- package/dist/classes/vector2.d.ts +1 -2
- package/dist/classes/vector2.js +101 -85
- package/dist/classes/vector3.d.ts +1 -2
- package/dist/classes/vector3.js +125 -136
- package/dist/classes/vector4.d.ts +2 -3
- package/dist/classes/vector4.js +106 -114
- package/dist/gl-matrix/common.d.ts +0 -1
- package/dist/gl-matrix/common.js +38 -6
- package/dist/gl-matrix/mat3.d.ts +0 -1
- package/dist/gl-matrix/mat3.js +699 -425
- package/dist/gl-matrix/mat4.d.ts +0 -1
- package/dist/gl-matrix/mat4.js +1879 -1339
- package/dist/gl-matrix/quat.d.ts +0 -1
- package/dist/gl-matrix/quat.js +655 -257
- package/dist/gl-matrix/vec2.d.ts +0 -1
- package/dist/gl-matrix/vec2.js +529 -212
- package/dist/gl-matrix/vec3.d.ts +0 -1
- package/dist/gl-matrix/vec3.js +703 -335
- package/dist/gl-matrix/vec4.d.ts +0 -1
- package/dist/gl-matrix/vec4.js +579 -293
- package/dist/gl-matrix/wip/index.d.ts +3 -4
- package/dist/gl-matrix/wip/index.js +2 -1
- package/dist/gl-matrix/wip/mat2.d.ts +0 -1
- package/dist/gl-matrix/wip/mat2.js +333 -157
- package/dist/gl-matrix/wip/mat2d.d.ts +0 -1
- package/dist/gl-matrix/wip/mat2d.js +377 -202
- package/dist/gl-matrix/wip/quat2.d.ts +0 -1
- package/dist/gl-matrix/wip/quat2.js +647 -409
- package/dist/index.cjs +60 -100
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +21 -22
- package/dist/index.js +23 -16
- package/dist/lib/assert.d.ts +0 -1
- package/dist/lib/assert.js +3 -4
- package/dist/lib/common.d.ts +2 -3
- package/dist/lib/common.js +163 -134
- package/dist/lib/gl-matrix-extras.d.ts +0 -1
- package/dist/lib/gl-matrix-extras.js +39 -36
- package/dist/lib/math-utils.d.ts +0 -1
- package/dist/lib/math-utils.js +2 -1
- package/dist/lib/validators.d.ts +0 -1
- package/dist/lib/validators.js +22 -25
- package/package.json +5 -6
- package/src/classes/matrix3.ts +1 -1
- package/dist/classes/base/math-array.d.ts.map +0 -1
- package/dist/classes/base/math-array.js.map +0 -1
- package/dist/classes/base/matrix.d.ts.map +0 -1
- package/dist/classes/base/matrix.js.map +0 -1
- package/dist/classes/base/vector.d.ts.map +0 -1
- package/dist/classes/base/vector.js.map +0 -1
- package/dist/classes/euler.d.ts.map +0 -1
- package/dist/classes/euler.js.map +0 -1
- package/dist/classes/matrix3.d.ts.map +0 -1
- package/dist/classes/matrix3.js.map +0 -1
- package/dist/classes/matrix4.d.ts.map +0 -1
- package/dist/classes/matrix4.js.map +0 -1
- package/dist/classes/pose.d.ts.map +0 -1
- package/dist/classes/pose.js.map +0 -1
- package/dist/classes/quaternion.d.ts.map +0 -1
- package/dist/classes/quaternion.js.map +0 -1
- package/dist/classes/spherical-coordinates.d.ts.map +0 -1
- package/dist/classes/spherical-coordinates.js.map +0 -1
- package/dist/classes/vector2.d.ts.map +0 -1
- package/dist/classes/vector2.js.map +0 -1
- package/dist/classes/vector3.d.ts.map +0 -1
- package/dist/classes/vector3.js.map +0 -1
- package/dist/classes/vector4.d.ts.map +0 -1
- package/dist/classes/vector4.js.map +0 -1
- package/dist/gl-matrix/common.d.ts.map +0 -1
- package/dist/gl-matrix/common.js.map +0 -1
- package/dist/gl-matrix/mat3.d.ts.map +0 -1
- package/dist/gl-matrix/mat3.js.map +0 -1
- package/dist/gl-matrix/mat4.d.ts.map +0 -1
- package/dist/gl-matrix/mat4.js.map +0 -1
- package/dist/gl-matrix/quat.d.ts.map +0 -1
- package/dist/gl-matrix/quat.js.map +0 -1
- package/dist/gl-matrix/vec2.d.ts.map +0 -1
- package/dist/gl-matrix/vec2.js.map +0 -1
- package/dist/gl-matrix/vec3.d.ts.map +0 -1
- package/dist/gl-matrix/vec3.js.map +0 -1
- package/dist/gl-matrix/vec4.d.ts.map +0 -1
- package/dist/gl-matrix/vec4.js.map +0 -1
- package/dist/gl-matrix/wip/index.d.ts.map +0 -1
- package/dist/gl-matrix/wip/index.js.map +0 -1
- package/dist/gl-matrix/wip/mat2.d.ts.map +0 -1
- package/dist/gl-matrix/wip/mat2.js.map +0 -1
- package/dist/gl-matrix/wip/mat2d.d.ts.map +0 -1
- package/dist/gl-matrix/wip/mat2d.js.map +0 -1
- package/dist/gl-matrix/wip/quat2.d.ts.map +0 -1
- package/dist/gl-matrix/wip/quat2.js.map +0 -1
- package/dist/gl-matrix/wip/types.d.js +0 -2
- package/dist/gl-matrix/wip/types.d.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/assert.d.ts.map +0 -1
- package/dist/lib/assert.js.map +0 -1
- package/dist/lib/common.d.ts.map +0 -1
- package/dist/lib/common.js.map +0 -1
- package/dist/lib/gl-matrix-extras.d.ts.map +0 -1
- package/dist/lib/gl-matrix-extras.js.map +0 -1
- package/dist/lib/gl-matrix.d.js +0 -2
- package/dist/lib/gl-matrix.d.js.map +0 -1
- package/dist/lib/math-utils.d.ts.map +0 -1
- package/dist/lib/math-utils.js.map +0 -1
- package/dist/lib/validators.d.ts.map +0 -1
- 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
|
|
4
|
-
export { Vector3 } from
|
|
5
|
-
export { Vector4 } from
|
|
6
|
-
export { Matrix3 } from
|
|
7
|
-
export { Matrix4 } from
|
|
8
|
-
export { Quaternion } from
|
|
9
|
-
export { SphericalCoordinates } from
|
|
10
|
-
export { Pose } from
|
|
11
|
-
export { Euler } from
|
|
12
|
-
export * as _MathUtils from
|
|
13
|
-
export { assert } from
|
|
14
|
-
export { config, configure, formatValue, isArray, clone, equals, exactEquals, toRadians, toDegrees, radians, degrees, sin, cos, tan, asin, acos, atan, clamp, lerp, withEpsilon } from
|
|
15
|
-
export { SphericalCoordinates as _SphericalCoordinates } from
|
|
16
|
-
export { Pose as _Pose } from
|
|
17
|
-
export { Euler as _Euler } from
|
|
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
|
|
19
|
+
export * as mat3 from "./gl-matrix/mat3.js";
|
|
20
20
|
/** @deprecated Use Matrix4 */
|
|
21
|
-
export * as mat4 from
|
|
21
|
+
export * as mat4 from "./gl-matrix/mat4.js";
|
|
22
22
|
/** @deprecated Use Quaterinion */
|
|
23
|
-
export * as quat from
|
|
23
|
+
export * as quat from "./gl-matrix/quat.js";
|
|
24
24
|
/** @deprecated UseVector */
|
|
25
|
-
export * as vec2 from
|
|
25
|
+
export * as vec2 from "./gl-matrix/vec2.js";
|
|
26
26
|
/** @deprecated Use Vector3 */
|
|
27
|
-
export * as vec3 from
|
|
27
|
+
export * as vec3 from "./gl-matrix/vec3.js";
|
|
28
28
|
/** @deprecated Use Vector4 */
|
|
29
|
-
export * as vec4 from
|
|
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
|
-
|
|
11
|
-
|
|
13
|
+
export * as _MathUtils from "./lib/math-utils.js";
|
|
14
|
+
// lib
|
|
12
15
|
export { assert } from "./lib/assert.js";
|
|
13
|
-
export {
|
|
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
|
-
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
export
|
|
25
|
-
|
|
26
|
-
export
|
|
27
|
-
|
|
28
|
-
export
|
|
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";
|
package/dist/lib/assert.d.ts
CHANGED
package/dist/lib/assert.js
CHANGED
package/dist/lib/common.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { NumericArray } from '@math.gl/types';
|
|
2
|
-
import type { MathArray } from
|
|
3
|
-
export
|
|
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
|
package/dist/lib/common.js
CHANGED
|
@@ -1,184 +1,213 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
40
|
+
return Array.isArray(value) || (ArrayBuffer.isView(value) && !(value instanceof DataView));
|
|
29
41
|
}
|
|
30
42
|
export function clone(array) {
|
|
31
|
-
|
|
43
|
+
return 'clone' in array ? array.clone() : array.slice();
|
|
32
44
|
}
|
|
33
45
|
export function toRadians(degrees) {
|
|
34
|
-
|
|
46
|
+
return radians(degrees);
|
|
35
47
|
}
|
|
36
48
|
export function toDegrees(radians) {
|
|
37
|
-
|
|
49
|
+
return degrees(radians);
|
|
38
50
|
}
|
|
39
51
|
export function radians(degrees, result) {
|
|
40
|
-
|
|
52
|
+
return map(degrees, (degrees) => degrees * DEGREES_TO_RADIANS, result);
|
|
41
53
|
}
|
|
42
54
|
export function degrees(radians, result) {
|
|
43
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
97
|
+
return map(radians, (angle) => Math.atan(angle), result);
|
|
62
98
|
}
|
|
63
99
|
export function clamp(value, min, max) {
|
|
64
|
-
|
|
100
|
+
return map(value, (value) => Math.max(min, Math.min(max, value)));
|
|
65
101
|
}
|
|
66
102
|
export function lerp(a, b, t) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
86
|
-
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
-
|
|
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
|
-
|
|
118
|
-
|
|
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
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
package/dist/lib/math-utils.d.ts
CHANGED
package/dist/lib/math-utils.js
CHANGED
|
@@ -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
|
package/dist/lib/validators.d.ts
CHANGED
|
@@ -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
|
package/dist/lib/validators.js
CHANGED
|
@@ -1,36 +1,33 @@
|
|
|
1
1
|
import { config } from "./common.js";
|
|
2
2
|
export function validateVector(v, length) {
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
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
|
-
|
|
17
|
-
|
|
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
|
-
|
|
24
|
-
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|